@tobi-or-not/quorum 0.4.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 +3 -1
- package/dist/bench/fingerprint.d.ts +8 -5
- package/dist/bench/fingerprint.js +28 -9
- package/dist/bench/records.d.ts +168 -0
- package/dist/bench/records.js +106 -1
- package/dist/bench/runner.d.ts +18 -0
- package/dist/bench/runner.js +30 -4
- package/dist/cli/bench.d.ts +11 -4
- package/dist/cli/bench.js +34 -17
- package/dist/cli/bin.js +2 -2
- package/dist/cli/io.d.ts +5 -0
- package/dist/cli/main.d.ts +67 -24
- package/dist/cli/main.js +288 -59
- package/dist/cli/print-config.d.ts +8 -6
- package/dist/cli/print-config.js +26 -8
- package/dist/cli/render.d.ts +9 -3
- package/dist/cli/render.js +43 -2
- 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/env.d.ts +32 -19
- package/dist/config/env.js +95 -32
- package/dist/config/from-config.js +21 -3
- package/dist/config/resolve.d.ts +13 -1
- package/dist/config/resolve.js +27 -1
- package/dist/config/schema.d.ts +152 -5
- package/dist/config/schema.js +156 -12
- package/dist/core/clock.d.ts +17 -0
- package/dist/core/clock.js +14 -0
- package/dist/core/coverage.d.ts +74 -0
- package/dist/core/coverage.js +221 -0
- package/dist/core/diff.d.ts +101 -0
- package/dist/core/diff.js +178 -35
- package/dist/core/errors.d.ts +12 -3
- package/dist/core/errors.js +21 -2
- package/dist/core/estimate.d.ts +45 -0
- package/dist/core/estimate.js +188 -0
- package/dist/core/exclude.d.ts +42 -0
- package/dist/core/exclude.js +189 -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 +83 -0
- package/dist/core/limits.js +169 -0
- package/dist/core/output.d.ts +3 -2
- package/dist/core/output.js +3 -2
- package/dist/core/parts.d.ts +146 -0
- package/dist/core/parts.js +388 -0
- package/dist/core/ports.d.ts +67 -2
- package/dist/core/ports.js +36 -1
- package/dist/core/prompts.d.ts +22 -3
- package/dist/core/prompts.js +43 -7
- package/dist/core/quorum.d.ts +26 -8
- package/dist/core/quorum.js +310 -73
- package/dist/core/retry.d.ts +36 -0
- package/dist/core/retry.js +46 -0
- package/dist/core/secrets.d.ts +98 -0
- package/dist/core/secrets.js +507 -0
- package/dist/core/stages/context.d.ts +131 -23
- package/dist/core/stages/context.js +331 -46
- package/dist/core/stages/panel.d.ts +13 -6
- package/dist/core/stages/panel.js +79 -19
- package/dist/core/stages/research.d.ts +110 -25
- package/dist/core/stages/research.js +338 -44
- package/dist/core/tokens.d.ts +31 -0
- package/dist/core/tokens.js +81 -0
- package/dist/core/types.d.ts +280 -25
- 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 +3 -1
- package/dist/providers/anthropic.js +10 -3
- package/dist/providers/claude-code.d.ts +56 -11
- package/dist/providers/claude-code.js +70 -25
- package/dist/providers/gemini.d.ts +5 -1
- package/dist/providers/gemini.js +65 -11
- package/dist/providers/http.d.ts +49 -4
- package/dist/providers/http.js +155 -14
- package/dist/providers/ollama.d.ts +4 -1
- package/dist/providers/ollama.js +13 -5
- package/dist/providers/openai-compatible.d.ts +4 -1
- package/dist/providers/openai-compatible.js +13 -5
- package/dist/providers/options.d.ts +12 -3
- package/dist/providers/options.js +30 -10
- package/dist/providers/size.d.ts +19 -15
- package/dist/providers/size.js +33 -73
- 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 +49 -1
|
@@ -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",
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
]
|
|
154
154
|
},
|
|
155
155
|
"maxTokens": {
|
|
156
|
-
"description": "The most tokens the reply may hold",
|
|
156
|
+
"description": "The most tokens the reply may hold, thinking included, sent as the server's limit; 16000 when unset. On claude-code, Claude Code's own limit on each reply",
|
|
157
157
|
"type": "integer",
|
|
158
158
|
"minimum": 1,
|
|
159
159
|
"maximum": 9007199254740991
|
|
@@ -174,6 +174,18 @@
|
|
|
174
174
|
"inline"
|
|
175
175
|
]
|
|
176
176
|
},
|
|
177
|
+
"timeoutMs": {
|
|
178
|
+
"description": "The deadline of one attempt of a call, in milliseconds; 600000 when unset. On claude-code, Claude Code's wait for each attempt's response headers, and the whole run's deadline is timeoutMs times retries plus one",
|
|
179
|
+
"type": "integer",
|
|
180
|
+
"minimum": 1000,
|
|
181
|
+
"maximum": 86400000
|
|
182
|
+
},
|
|
183
|
+
"retries": {
|
|
184
|
+
"description": "How many times a call that failed in passing is tried again; 2 when unset",
|
|
185
|
+
"type": "integer",
|
|
186
|
+
"minimum": 0,
|
|
187
|
+
"maximum": 5
|
|
188
|
+
},
|
|
177
189
|
"args": {
|
|
178
190
|
"description": "On claude-code, extra claude flags, each with its value: --effort, --fallback-model, --max-budget-usd, or --betas with auth api-key",
|
|
179
191
|
"type": "array",
|
|
@@ -214,6 +226,42 @@
|
|
|
214
226
|
"minimum": 1,
|
|
215
227
|
"maximum": 9007199254740991
|
|
216
228
|
},
|
|
229
|
+
"partTokens": {
|
|
230
|
+
"description": "The most tokens of diff text, at one token per byte, one research request of a large change holds; 32768 when unset",
|
|
231
|
+
"type": "integer",
|
|
232
|
+
"minimum": 1024,
|
|
233
|
+
"maximum": 9007199254740991
|
|
234
|
+
},
|
|
235
|
+
"maxReviewTokens": {
|
|
236
|
+
"description": "The most tokens, input and output, one review may spend; 2000000 when unset. Set here or in QUORUM_MAX_REVIEW_TOKENS",
|
|
237
|
+
"type": "integer",
|
|
238
|
+
"minimum": 1,
|
|
239
|
+
"maximum": 9007199254740991
|
|
240
|
+
},
|
|
241
|
+
"reviewTimeoutMs": {
|
|
242
|
+
"description": "The deadline of one review, in milliseconds; 1800000 when unset. Set here or in QUORUM_REVIEW_TIMEOUT_MS",
|
|
243
|
+
"type": "integer",
|
|
244
|
+
"minimum": 1000,
|
|
245
|
+
"maximum": 86400000
|
|
246
|
+
},
|
|
247
|
+
"exclude": {
|
|
248
|
+
"description": "The files left out of every request, by path pattern, each listed as excluded in meta.leftOut; nothing is excluded by default",
|
|
249
|
+
"maxItems": 100,
|
|
250
|
+
"type": "array",
|
|
251
|
+
"items": {
|
|
252
|
+
"type": "string",
|
|
253
|
+
"description": "A path pattern: * and ? within a name, ** for whole directories, no / to match a file name in any directory, a leading / for the root"
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
"send": {
|
|
257
|
+
"description": "The files sent to the models though held as secrets, each the path as the diff writes it and meta.leftOut lists it; none by default",
|
|
258
|
+
"type": "array",
|
|
259
|
+
"items": {
|
|
260
|
+
"type": "string",
|
|
261
|
+
"minLength": 1,
|
|
262
|
+
"description": "A file's path as the diff writes it, decoded"
|
|
263
|
+
}
|
|
264
|
+
},
|
|
217
265
|
"profiles": {
|
|
218
266
|
"description": "The review profiles, by id: a built-in profile, one that extends it, or one of your own. The ones --profile names run, else the ones QUORUM_PROFILES names, else every one listed here, else the security profile alone",
|
|
219
267
|
"type": "object",
|