@open-cr-agent/core 0.1.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/LICENSE +202 -0
- package/README.md +3 -0
- package/dist/anchor/anchor.d.ts +24 -0
- package/dist/anchor/anchor.js +66 -0
- package/dist/anchor/index.d.ts +3 -0
- package/dist/anchor/index.js +3 -0
- package/dist/anchor/match.d.ts +22 -0
- package/dist/anchor/match.js +94 -0
- package/dist/anchor/relocate.d.ts +5 -0
- package/dist/anchor/relocate.js +38 -0
- package/dist/bundle/bundle.d.ts +22 -0
- package/dist/bundle/bundle.js +102 -0
- package/dist/bundle/grouping.d.ts +16 -0
- package/dist/bundle/grouping.js +25 -0
- package/dist/bundle/index.d.ts +3 -0
- package/dist/bundle/index.js +3 -0
- package/dist/contracts.d.ts +77 -0
- package/dist/contracts.js +2 -0
- package/dist/diff/hunks.d.ts +3 -0
- package/dist/diff/hunks.js +64 -0
- package/dist/diff/index.d.ts +3 -0
- package/dist/diff/index.js +3 -0
- package/dist/diff/parse.d.ts +3 -0
- package/dist/diff/parse.js +116 -0
- package/dist/diff/quoted-path.d.ts +6 -0
- package/dist/diff/quoted-path.js +46 -0
- package/dist/domain.d.ts +126 -0
- package/dist/domain.js +23 -0
- package/dist/errors.d.ts +8 -0
- package/dist/errors.js +16 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +18 -0
- package/dist/judge/index.d.ts +4 -0
- package/dist/judge/index.js +4 -0
- package/dist/judge/judge.d.ts +46 -0
- package/dist/judge/judge.js +122 -0
- package/dist/judge/prompt.d.ts +25 -0
- package/dist/judge/prompt.js +62 -0
- package/dist/judge/verdict.d.ts +9 -0
- package/dist/judge/verdict.js +26 -0
- package/dist/memory/index.d.ts +2 -0
- package/dist/memory/index.js +2 -0
- package/dist/memory/memory.d.ts +19 -0
- package/dist/memory/memory.js +49 -0
- package/dist/pipeline/budget.d.ts +9 -0
- package/dist/pipeline/budget.js +19 -0
- package/dist/pipeline/context.d.ts +6 -0
- package/dist/pipeline/context.js +71 -0
- package/dist/pipeline/execute.d.ts +32 -0
- package/dist/pipeline/execute.js +122 -0
- package/dist/pipeline/findings.d.ts +6 -0
- package/dist/pipeline/findings.js +44 -0
- package/dist/pipeline/helpers.d.ts +6 -0
- package/dist/pipeline/helpers.js +32 -0
- package/dist/pipeline/index.d.ts +9 -0
- package/dist/pipeline/index.js +9 -0
- package/dist/pipeline/matrix.d.ts +38 -0
- package/dist/pipeline/matrix.js +93 -0
- package/dist/pipeline/output.d.ts +69 -0
- package/dist/pipeline/output.js +123 -0
- package/dist/pipeline/plan.d.ts +34 -0
- package/dist/pipeline/plan.js +68 -0
- package/dist/pipeline/pool.d.ts +2 -0
- package/dist/pipeline/pool.js +13 -0
- package/dist/pipeline/preview.d.ts +42 -0
- package/dist/pipeline/preview.js +73 -0
- package/dist/pipeline/report.d.ts +118 -0
- package/dist/pipeline/report.js +27 -0
- package/dist/pipeline/run.d.ts +36 -0
- package/dist/pipeline/run.js +301 -0
- package/dist/pipeline/task.d.ts +19 -0
- package/dist/pipeline/task.js +143 -0
- package/dist/pipeline/usage.d.ts +4 -0
- package/dist/pipeline/usage.js +13 -0
- package/dist/plugin/builtin.d.ts +14 -0
- package/dist/plugin/builtin.js +47 -0
- package/dist/plugin/host.d.ts +9 -0
- package/dist/plugin/host.js +78 -0
- package/dist/plugin/index.d.ts +5 -0
- package/dist/plugin/index.js +5 -0
- package/dist/plugin/registry.d.ts +37 -0
- package/dist/plugin/registry.js +104 -0
- package/dist/plugin/types.d.ts +53 -0
- package/dist/plugin/types.js +2 -0
- package/dist/rereview/index.d.ts +4 -0
- package/dist/rereview/index.js +4 -0
- package/dist/rereview/presence.d.ts +3 -0
- package/dist/rereview/presence.js +27 -0
- package/dist/rereview/quote.d.ts +4 -0
- package/dist/rereview/quote.js +28 -0
- package/dist/rereview/reconcile.d.ts +20 -0
- package/dist/rereview/reconcile.js +55 -0
- package/dist/review/impact.d.ts +11 -0
- package/dist/review/impact.js +53 -0
- package/dist/review/index.d.ts +10 -0
- package/dist/review/index.js +10 -0
- package/dist/review/plan-phase.d.ts +10 -0
- package/dist/review/plan-phase.js +33 -0
- package/dist/review/prompt-text.d.ts +16 -0
- package/dist/review/prompt-text.js +90 -0
- package/dist/review/prompt.d.ts +28 -0
- package/dist/review/prompt.js +85 -0
- package/dist/review/reviewer.d.ts +17 -0
- package/dist/review/reviewer.js +2 -0
- package/dist/review/reviewers/agents-md.d.ts +3 -0
- package/dist/review/reviewers/agents-md.js +45 -0
- package/dist/review/reviewers/correctness.d.ts +3 -0
- package/dist/review/reviewers/correctness.js +48 -0
- package/dist/review/reviewers/docs.d.ts +3 -0
- package/dist/review/reviewers/docs.js +47 -0
- package/dist/review/reviewers/performance.d.ts +3 -0
- package/dist/review/reviewers/performance.js +59 -0
- package/dist/review/reviewers/scopes.d.ts +3 -0
- package/dist/review/reviewers/scopes.js +9 -0
- package/dist/review/reviewers/security.d.ts +3 -0
- package/dist/review/reviewers/security.js +52 -0
- package/dist/review/tools.d.ts +9 -0
- package/dist/review/tools.js +8 -0
- package/dist/rules/builtin/general.d.ts +2 -0
- package/dist/rules/builtin/general.js +9 -0
- package/dist/rules/builtin/go.d.ts +2 -0
- package/dist/rules/builtin/go.js +9 -0
- package/dist/rules/builtin/index.d.ts +9 -0
- package/dist/rules/builtin/index.js +16 -0
- package/dist/rules/builtin/java.d.ts +2 -0
- package/dist/rules/builtin/java.js +9 -0
- package/dist/rules/builtin/performance.d.ts +2 -0
- package/dist/rules/builtin/performance.js +9 -0
- package/dist/rules/builtin/python.d.ts +2 -0
- package/dist/rules/builtin/python.js +9 -0
- package/dist/rules/builtin/security.d.ts +2 -0
- package/dist/rules/builtin/security.js +11 -0
- package/dist/rules/builtin/typescript.d.ts +2 -0
- package/dist/rules/builtin/typescript.js +9 -0
- package/dist/rules/index.d.ts +5 -0
- package/dist/rules/index.js +5 -0
- package/dist/rules/languages.d.ts +3 -0
- package/dist/rules/languages.js +20 -0
- package/dist/rules/repo-rules.d.ts +15 -0
- package/dist/rules/repo-rules.js +22 -0
- package/dist/rules/resolve.d.ts +4 -0
- package/dist/rules/resolve.js +27 -0
- package/dist/rules/rule-set.d.ts +6 -0
- package/dist/rules/rule-set.js +2 -0
- package/dist/select/index.d.ts +2 -0
- package/dist/select/index.js +2 -0
- package/dist/select/patterns.d.ts +6 -0
- package/dist/select/patterns.js +132 -0
- package/dist/select/select.d.ts +19 -0
- package/dist/select/select.js +52 -0
- package/dist/session/index.d.ts +2 -0
- package/dist/session/index.js +2 -0
- package/dist/session/jsonl.d.ts +11 -0
- package/dist/session/jsonl.js +57 -0
- package/dist/triage.d.ts +11 -0
- package/dist/triage.js +55 -0
- package/dist/verify/index.d.ts +3 -0
- package/dist/verify/index.js +3 -0
- package/dist/verify/prompt.d.ts +24 -0
- package/dist/verify/prompt.js +71 -0
- package/dist/verify/verify.d.ts +29 -0
- package/dist/verify/verify.js +98 -0
- package/package.json +40 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { ChangeRequest, FileDiff, PriorReview } from "./domain.js";
|
|
2
|
+
import type { ReviewReport } from "./pipeline/report.js";
|
|
3
|
+
export interface CodeMatch {
|
|
4
|
+
path: string;
|
|
5
|
+
line: number;
|
|
6
|
+
text: string;
|
|
7
|
+
}
|
|
8
|
+
export interface VcsAdapter {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
getChangeRequest(): Promise<ChangeRequest>;
|
|
11
|
+
getDiff(): Promise<FileDiff[]>;
|
|
12
|
+
readFile(path: string): Promise<string | undefined>;
|
|
13
|
+
searchCode(literal: string): Promise<CodeMatch[]>;
|
|
14
|
+
getPriorReview(): Promise<PriorReview | undefined>;
|
|
15
|
+
publish(report: ReviewReport): Promise<{
|
|
16
|
+
warnings: string[];
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
export type ModelTier = "top" | "standard" | "light";
|
|
20
|
+
export interface AgentTaskSpec {
|
|
21
|
+
taskId: string;
|
|
22
|
+
reviewer: string;
|
|
23
|
+
modelTier: ModelTier;
|
|
24
|
+
systemPrompt: string;
|
|
25
|
+
userPrompt: string;
|
|
26
|
+
context: ReviewContext;
|
|
27
|
+
timeoutMs: number;
|
|
28
|
+
}
|
|
29
|
+
export interface ReviewContext {
|
|
30
|
+
readFile(path: string): Promise<string | undefined>;
|
|
31
|
+
readDiff(path: string): string | undefined;
|
|
32
|
+
searchCode(literal: string): Promise<CodeMatch[]>;
|
|
33
|
+
}
|
|
34
|
+
export type AgentEvent = {
|
|
35
|
+
type: "progress";
|
|
36
|
+
taskId: string;
|
|
37
|
+
message: string;
|
|
38
|
+
} | {
|
|
39
|
+
type: "finding";
|
|
40
|
+
taskId: string;
|
|
41
|
+
finding: unknown;
|
|
42
|
+
} | ({
|
|
43
|
+
type: "usage";
|
|
44
|
+
taskId: string;
|
|
45
|
+
} & Usage) | {
|
|
46
|
+
type: "done";
|
|
47
|
+
taskId: string;
|
|
48
|
+
} | {
|
|
49
|
+
type: "error";
|
|
50
|
+
taskId: string;
|
|
51
|
+
error: string;
|
|
52
|
+
retryable: boolean;
|
|
53
|
+
};
|
|
54
|
+
export interface Usage {
|
|
55
|
+
inputTokens: number;
|
|
56
|
+
outputTokens: number;
|
|
57
|
+
reasoningTokens: number;
|
|
58
|
+
cachedTokens: number;
|
|
59
|
+
costUsd: number;
|
|
60
|
+
}
|
|
61
|
+
export interface CompletionRequest {
|
|
62
|
+
tier: ModelTier;
|
|
63
|
+
system: string;
|
|
64
|
+
user: string;
|
|
65
|
+
timeoutMs: number;
|
|
66
|
+
}
|
|
67
|
+
export interface CompletionResult {
|
|
68
|
+
text: string;
|
|
69
|
+
usage: Usage;
|
|
70
|
+
}
|
|
71
|
+
export interface AgentRuntime {
|
|
72
|
+
readonly name: string;
|
|
73
|
+
runTask(spec: AgentTaskSpec, signal: AbortSignal): AsyncIterable<AgentEvent>;
|
|
74
|
+
complete?(request: CompletionRequest, signal: AbortSignal): Promise<CompletionResult>;
|
|
75
|
+
dispose?(): Promise<void>;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const HUNK_HEADER = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;
|
|
2
|
+
export function parseHunks(lines) {
|
|
3
|
+
const hunks = [];
|
|
4
|
+
let i = 0;
|
|
5
|
+
while (i < lines.length) {
|
|
6
|
+
const header = lines[i];
|
|
7
|
+
const match = HUNK_HEADER.exec(header);
|
|
8
|
+
i += 1;
|
|
9
|
+
if (!match)
|
|
10
|
+
continue;
|
|
11
|
+
const hunk = {
|
|
12
|
+
header,
|
|
13
|
+
oldStart: Number(match[1]),
|
|
14
|
+
oldLines: match[2] === undefined ? 1 : Number(match[2]),
|
|
15
|
+
newStart: Number(match[3]),
|
|
16
|
+
newLines: match[4] === undefined ? 1 : Number(match[4]),
|
|
17
|
+
lines: [],
|
|
18
|
+
};
|
|
19
|
+
i = readHunkBody(lines, i, hunk);
|
|
20
|
+
hunks.push(hunk);
|
|
21
|
+
}
|
|
22
|
+
return hunks;
|
|
23
|
+
}
|
|
24
|
+
// The body is consumed by the counts in the header rather than by prefixes,
|
|
25
|
+
// because a removed line such as "-- comment" would otherwise look like "--- ".
|
|
26
|
+
function readHunkBody(lines, start, hunk) {
|
|
27
|
+
let oldRemaining = hunk.oldLines;
|
|
28
|
+
let newRemaining = hunk.newLines;
|
|
29
|
+
let oldLine = hunk.oldStart;
|
|
30
|
+
let newLine = hunk.newStart;
|
|
31
|
+
let i = start;
|
|
32
|
+
while (i < lines.length && (oldRemaining > 0 || newRemaining > 0)) {
|
|
33
|
+
const raw = lines[i];
|
|
34
|
+
if (raw.startsWith("\\")) {
|
|
35
|
+
i += 1;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const marker = raw[0] ?? " ";
|
|
39
|
+
const content = raw.slice(1);
|
|
40
|
+
let line;
|
|
41
|
+
if (marker === "+" && newRemaining > 0) {
|
|
42
|
+
line = { kind: "add", content, newLine: newLine++ };
|
|
43
|
+
newRemaining -= 1;
|
|
44
|
+
}
|
|
45
|
+
else if (marker === "-" && oldRemaining > 0) {
|
|
46
|
+
line = { kind: "delete", content, oldLine: oldLine++ };
|
|
47
|
+
oldRemaining -= 1;
|
|
48
|
+
}
|
|
49
|
+
else if (marker === " " && oldRemaining > 0 && newRemaining > 0) {
|
|
50
|
+
line = { kind: "context", content, oldLine: oldLine++, newLine: newLine++ };
|
|
51
|
+
oldRemaining -= 1;
|
|
52
|
+
newRemaining -= 1;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
hunk.lines.push(line);
|
|
58
|
+
i += 1;
|
|
59
|
+
}
|
|
60
|
+
while (lines[i]?.startsWith("\\"))
|
|
61
|
+
i += 1;
|
|
62
|
+
return i;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=hunks.js.map
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { parseHunks } from "./hunks.js";
|
|
2
|
+
import { readQuotedToken } from "./quoted-path.js";
|
|
3
|
+
const FILE_HEADER = "diff --git ";
|
|
4
|
+
export function parseUnifiedDiff(text) {
|
|
5
|
+
const lines = splitLines(text);
|
|
6
|
+
const sections = [];
|
|
7
|
+
for (const line of lines) {
|
|
8
|
+
if (line.startsWith(FILE_HEADER))
|
|
9
|
+
sections.push([line]);
|
|
10
|
+
else
|
|
11
|
+
sections.at(-1)?.push(line);
|
|
12
|
+
}
|
|
13
|
+
return sections.map(parseFileSection);
|
|
14
|
+
}
|
|
15
|
+
// Trailing CRs are dropped so a diff saved with CRLF endings parses like any
|
|
16
|
+
// other; reviewers compare normalized text, so CRLF content loses nothing.
|
|
17
|
+
function splitLines(text) {
|
|
18
|
+
const lines = text.split("\n").map((l) => (l.endsWith("\r") ? l.slice(0, -1) : l));
|
|
19
|
+
if (lines.at(-1) === "")
|
|
20
|
+
lines.pop();
|
|
21
|
+
return lines;
|
|
22
|
+
}
|
|
23
|
+
function parseFileSection(lines) {
|
|
24
|
+
const header = parseHeaderPaths(lines[0].slice(FILE_HEADER.length));
|
|
25
|
+
let oldPath = header?.oldPath ?? "";
|
|
26
|
+
let newPath = header?.newPath ?? "";
|
|
27
|
+
let kind = "modified";
|
|
28
|
+
let isBinary = false;
|
|
29
|
+
let i = 1;
|
|
30
|
+
for (; i < lines.length && !lines[i].startsWith("@@"); i += 1) {
|
|
31
|
+
const line = lines[i];
|
|
32
|
+
if (line.startsWith("new file mode"))
|
|
33
|
+
kind = "added";
|
|
34
|
+
else if (line.startsWith("deleted file mode"))
|
|
35
|
+
kind = "deleted";
|
|
36
|
+
else if (line.startsWith("rename from ")) {
|
|
37
|
+
oldPath = unquote(line.slice("rename from ".length));
|
|
38
|
+
kind = "renamed";
|
|
39
|
+
}
|
|
40
|
+
else if (line.startsWith("rename to "))
|
|
41
|
+
newPath = unquote(line.slice("rename to ".length));
|
|
42
|
+
else if (line.startsWith("copy from ")) {
|
|
43
|
+
oldPath = unquote(line.slice("copy from ".length));
|
|
44
|
+
kind = "added";
|
|
45
|
+
}
|
|
46
|
+
else if (line.startsWith("copy to "))
|
|
47
|
+
newPath = unquote(line.slice("copy to ".length));
|
|
48
|
+
else if (line.startsWith("Binary files ") || line === "GIT binary patch")
|
|
49
|
+
isBinary = true;
|
|
50
|
+
else if (line.startsWith("--- "))
|
|
51
|
+
oldPath = parseMarkerPath(line.slice(4)) ?? oldPath;
|
|
52
|
+
else if (line.startsWith("+++ "))
|
|
53
|
+
newPath = parseMarkerPath(line.slice(4)) ?? newPath;
|
|
54
|
+
}
|
|
55
|
+
const hunks = parseHunks(lines.slice(i));
|
|
56
|
+
let additions = 0;
|
|
57
|
+
let deletions = 0;
|
|
58
|
+
for (const line of hunks.flatMap((h) => h.lines)) {
|
|
59
|
+
if (line.kind === "add")
|
|
60
|
+
additions += 1;
|
|
61
|
+
else if (line.kind === "delete")
|
|
62
|
+
deletions += 1;
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
oldPath,
|
|
66
|
+
newPath,
|
|
67
|
+
kind,
|
|
68
|
+
isBinary,
|
|
69
|
+
additions,
|
|
70
|
+
deletions,
|
|
71
|
+
hunks,
|
|
72
|
+
patch: lines.join("\n"),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function parseHeaderPaths(rest) {
|
|
76
|
+
const quotedOld = readQuotedToken(rest, 0);
|
|
77
|
+
if (quotedOld) {
|
|
78
|
+
const newRaw = rest.slice(quotedOld.end + 1);
|
|
79
|
+
return { oldPath: stripPrefix(quotedOld.value), newPath: stripPrefix(unquote(newRaw)) };
|
|
80
|
+
}
|
|
81
|
+
const quotedNewAt = rest.indexOf(' "');
|
|
82
|
+
if (quotedNewAt >= 0) {
|
|
83
|
+
return {
|
|
84
|
+
oldPath: stripPrefix(rest.slice(0, quotedNewAt)),
|
|
85
|
+
newPath: stripPrefix(unquote(rest.slice(quotedNewAt + 1))),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
// Unquoted paths may contain spaces, so "a/x b/x" is split at its midpoint
|
|
89
|
+
// when both halves name the same file, which is the only unambiguous case.
|
|
90
|
+
const mid = (rest.length - 1) / 2;
|
|
91
|
+
if (Number.isInteger(mid) && rest[mid] === " ") {
|
|
92
|
+
const oldPath = stripPrefix(rest.slice(0, mid));
|
|
93
|
+
const newPath = stripPrefix(rest.slice(mid + 1));
|
|
94
|
+
if (oldPath === newPath)
|
|
95
|
+
return { oldPath, newPath };
|
|
96
|
+
}
|
|
97
|
+
const split = rest.indexOf(" b/");
|
|
98
|
+
if (split < 0)
|
|
99
|
+
return undefined;
|
|
100
|
+
return {
|
|
101
|
+
oldPath: stripPrefix(rest.slice(0, split)),
|
|
102
|
+
newPath: stripPrefix(rest.slice(split + 1)),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function parseMarkerPath(rest) {
|
|
106
|
+
const quoted = readQuotedToken(rest, 0);
|
|
107
|
+
const path = quoted ? quoted.value : rest.split("\t")[0];
|
|
108
|
+
return path === "/dev/null" ? undefined : stripPrefix(path);
|
|
109
|
+
}
|
|
110
|
+
function unquote(raw) {
|
|
111
|
+
return readQuotedToken(raw, 0)?.value ?? raw;
|
|
112
|
+
}
|
|
113
|
+
function stripPrefix(path) {
|
|
114
|
+
return path.startsWith("a/") || path.startsWith("b/") ? path.slice(2) : path;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const SIMPLE_ESCAPES = {
|
|
2
|
+
a: 0x07,
|
|
3
|
+
b: 0x08,
|
|
4
|
+
t: 0x09,
|
|
5
|
+
n: 0x0a,
|
|
6
|
+
v: 0x0b,
|
|
7
|
+
f: 0x0c,
|
|
8
|
+
r: 0x0d,
|
|
9
|
+
'"': 0x22,
|
|
10
|
+
"\\": 0x5c,
|
|
11
|
+
};
|
|
12
|
+
// Git C-quotes paths with special characters and encodes non-ASCII bytes as
|
|
13
|
+
// octal escapes, so the escapes must be decoded as UTF-8 bytes, not code points.
|
|
14
|
+
export function readQuotedToken(text, start) {
|
|
15
|
+
if (text[start] !== '"')
|
|
16
|
+
return undefined;
|
|
17
|
+
const encoder = new TextEncoder();
|
|
18
|
+
const bytes = [];
|
|
19
|
+
let i = start + 1;
|
|
20
|
+
while (i < text.length) {
|
|
21
|
+
const ch = text[i];
|
|
22
|
+
if (ch === '"') {
|
|
23
|
+
return { value: new TextDecoder().decode(new Uint8Array(bytes)), end: i + 1 };
|
|
24
|
+
}
|
|
25
|
+
if (ch !== "\\") {
|
|
26
|
+
bytes.push(...encoder.encode(ch));
|
|
27
|
+
i += 1;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const next = text[i + 1] ?? "";
|
|
31
|
+
const octal = /^[0-7]{3}/.exec(text.slice(i + 1, i + 4));
|
|
32
|
+
if (octal) {
|
|
33
|
+
bytes.push(Number.parseInt(octal[0], 8));
|
|
34
|
+
i += 4;
|
|
35
|
+
}
|
|
36
|
+
else if (next in SIMPLE_ESCAPES) {
|
|
37
|
+
bytes.push(SIMPLE_ESCAPES[next]);
|
|
38
|
+
i += 2;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=quoted-path.js.map
|
package/dist/domain.d.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const severitySchema: z.ZodEnum<{
|
|
3
|
+
critical: "critical";
|
|
4
|
+
suggestion: "suggestion";
|
|
5
|
+
warning: "warning";
|
|
6
|
+
}>;
|
|
7
|
+
export type Severity = z.infer<typeof severitySchema>;
|
|
8
|
+
export declare const findingStatusSchema: z.ZodEnum<{
|
|
9
|
+
new: "new";
|
|
10
|
+
unfixed: "unfixed";
|
|
11
|
+
}>;
|
|
12
|
+
export type FindingStatus = z.infer<typeof findingStatusSchema>;
|
|
13
|
+
export declare const lineRangeSchema: z.ZodObject<{
|
|
14
|
+
start: z.ZodNumber;
|
|
15
|
+
end: z.ZodNumber;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export type LineRange = z.infer<typeof lineRangeSchema>;
|
|
18
|
+
export declare const reportedFindingSchema: z.ZodObject<{
|
|
19
|
+
category: z.ZodString;
|
|
20
|
+
severity: z.ZodEnum<{
|
|
21
|
+
critical: "critical";
|
|
22
|
+
suggestion: "suggestion";
|
|
23
|
+
warning: "warning";
|
|
24
|
+
}>;
|
|
25
|
+
file: z.ZodString;
|
|
26
|
+
existingCode: z.ZodString;
|
|
27
|
+
title: z.ZodString;
|
|
28
|
+
body: z.ZodString;
|
|
29
|
+
suggestion: z.ZodOptional<z.ZodString>;
|
|
30
|
+
evidence: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
export type ReportedFinding = z.infer<typeof reportedFindingSchema>;
|
|
33
|
+
export type AnchorMethod = "hunk" | "file" | "cross_file" | "relocated" | "file_level";
|
|
34
|
+
export interface QuoteSignature {
|
|
35
|
+
lines: number;
|
|
36
|
+
hash: string;
|
|
37
|
+
}
|
|
38
|
+
export declare const verificationSchema: z.ZodEnum<{
|
|
39
|
+
confirmed: "confirmed";
|
|
40
|
+
uncertain: "uncertain";
|
|
41
|
+
unchecked: "unchecked";
|
|
42
|
+
}>;
|
|
43
|
+
export type Verification = z.infer<typeof verificationSchema>;
|
|
44
|
+
export interface Finding extends ReportedFinding {
|
|
45
|
+
id: string;
|
|
46
|
+
fingerprint: string;
|
|
47
|
+
reviewer: string;
|
|
48
|
+
lineRange?: LineRange;
|
|
49
|
+
anchor: {
|
|
50
|
+
method: AnchorMethod;
|
|
51
|
+
inDiff: boolean;
|
|
52
|
+
ambiguous?: true;
|
|
53
|
+
};
|
|
54
|
+
status: FindingStatus;
|
|
55
|
+
lowConfidence?: boolean;
|
|
56
|
+
quote?: QuoteSignature;
|
|
57
|
+
verification?: Verification;
|
|
58
|
+
replies?: string[];
|
|
59
|
+
}
|
|
60
|
+
export type FileChangeKind = "added" | "modified" | "deleted" | "renamed";
|
|
61
|
+
export type DiffLine = {
|
|
62
|
+
kind: "context";
|
|
63
|
+
content: string;
|
|
64
|
+
oldLine: number;
|
|
65
|
+
newLine: number;
|
|
66
|
+
} | {
|
|
67
|
+
kind: "add";
|
|
68
|
+
content: string;
|
|
69
|
+
newLine: number;
|
|
70
|
+
} | {
|
|
71
|
+
kind: "delete";
|
|
72
|
+
content: string;
|
|
73
|
+
oldLine: number;
|
|
74
|
+
};
|
|
75
|
+
export interface Hunk {
|
|
76
|
+
header: string;
|
|
77
|
+
oldStart: number;
|
|
78
|
+
oldLines: number;
|
|
79
|
+
newStart: number;
|
|
80
|
+
newLines: number;
|
|
81
|
+
lines: DiffLine[];
|
|
82
|
+
}
|
|
83
|
+
export interface FileDiff {
|
|
84
|
+
oldPath: string;
|
|
85
|
+
newPath: string;
|
|
86
|
+
kind: FileChangeKind;
|
|
87
|
+
isBinary: boolean;
|
|
88
|
+
additions: number;
|
|
89
|
+
deletions: number;
|
|
90
|
+
hunks: Hunk[];
|
|
91
|
+
patch: string;
|
|
92
|
+
}
|
|
93
|
+
export interface ChangeRequest {
|
|
94
|
+
id: string;
|
|
95
|
+
title: string;
|
|
96
|
+
description: string;
|
|
97
|
+
baseSha: string;
|
|
98
|
+
headSha: string;
|
|
99
|
+
override?: {
|
|
100
|
+
by: string;
|
|
101
|
+
reason: string;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export type RiskTier = "trivial" | "lite" | "full";
|
|
105
|
+
export type Verdict = "approved" | "approved_with_comments" | "minor_issues" | "significant_concerns";
|
|
106
|
+
export interface PriorFinding {
|
|
107
|
+
fingerprint: string;
|
|
108
|
+
title: string;
|
|
109
|
+
file: string;
|
|
110
|
+
severity: Severity;
|
|
111
|
+
commented: boolean;
|
|
112
|
+
dismissed?: boolean;
|
|
113
|
+
quote?: QuoteSignature;
|
|
114
|
+
verification?: Verification;
|
|
115
|
+
}
|
|
116
|
+
export interface PriorReview {
|
|
117
|
+
findings: PriorFinding[];
|
|
118
|
+
changedSince?: {
|
|
119
|
+
head: string;
|
|
120
|
+
files: string[];
|
|
121
|
+
};
|
|
122
|
+
fullReviewReason?: string;
|
|
123
|
+
tier?: RiskTier;
|
|
124
|
+
replies?: Readonly<Record<string, readonly string[]>>;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=domain.d.ts.map
|
package/dist/domain.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const severitySchema = z.enum(["critical", "warning", "suggestion"]);
|
|
3
|
+
// A finding in a report is new or reported before; fixed and dismissed
|
|
4
|
+
// earlier findings are listed separately (report.rereview).
|
|
5
|
+
export const findingStatusSchema = z.enum(["new", "unfixed"]);
|
|
6
|
+
export const lineRangeSchema = z.object({
|
|
7
|
+
start: z.number().int().positive(),
|
|
8
|
+
end: z.number().int().positive(),
|
|
9
|
+
});
|
|
10
|
+
export const reportedFindingSchema = z.object({
|
|
11
|
+
category: z.string().min(1),
|
|
12
|
+
severity: severitySchema,
|
|
13
|
+
file: z.string().min(1),
|
|
14
|
+
existingCode: z.string().min(1),
|
|
15
|
+
title: z.string().min(1),
|
|
16
|
+
body: z.string().min(1),
|
|
17
|
+
suggestion: z.string().optional(),
|
|
18
|
+
evidence: z.array(z.string()).default([]),
|
|
19
|
+
});
|
|
20
|
+
// What Verify concluded about a finding it kept. "unchecked" covers a skipped
|
|
21
|
+
// or failed verification. Refuted findings are dropped, so have no value here.
|
|
22
|
+
export const verificationSchema = z.enum(["confirmed", "uncertain", "unchecked"]);
|
|
23
|
+
//# sourceMappingURL=domain.js.map
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Usage } from "./contracts.js";
|
|
2
|
+
export declare class CompletionError extends Error {
|
|
3
|
+
readonly usage: Usage;
|
|
4
|
+
constructor(message: string, usage: Usage);
|
|
5
|
+
}
|
|
6
|
+
export declare function usageSpent(error: unknown): Usage | undefined;
|
|
7
|
+
export declare function errorMessage(error: unknown): string;
|
|
8
|
+
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// A helper completion that failed on every model has still spent tokens on
|
|
2
|
+
// the attempts; callers record them so reports and spend limits stay true.
|
|
3
|
+
export class CompletionError extends Error {
|
|
4
|
+
usage;
|
|
5
|
+
constructor(message, usage) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.usage = usage;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export function usageSpent(error) {
|
|
11
|
+
return error instanceof CompletionError ? error.usage : undefined;
|
|
12
|
+
}
|
|
13
|
+
export function errorMessage(error) {
|
|
14
|
+
return error instanceof Error ? error.message : String(error);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=errors.js.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from "./anchor/index.js";
|
|
2
|
+
export * from "./bundle/index.js";
|
|
3
|
+
export * from "./contracts.js";
|
|
4
|
+
export * from "./diff/index.js";
|
|
5
|
+
export * from "./domain.js";
|
|
6
|
+
export * from "./errors.js";
|
|
7
|
+
export * from "./judge/index.js";
|
|
8
|
+
export * from "./memory/index.js";
|
|
9
|
+
export * from "./pipeline/index.js";
|
|
10
|
+
export * from "./plugin/index.js";
|
|
11
|
+
export * from "./rereview/index.js";
|
|
12
|
+
export * from "./review/index.js";
|
|
13
|
+
export * from "./rules/index.js";
|
|
14
|
+
export * from "./select/index.js";
|
|
15
|
+
export * from "./session/index.js";
|
|
16
|
+
export * from "./triage.js";
|
|
17
|
+
export * from "./verify/index.js";
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from "./anchor/index.js";
|
|
2
|
+
export * from "./bundle/index.js";
|
|
3
|
+
export * from "./contracts.js";
|
|
4
|
+
export * from "./diff/index.js";
|
|
5
|
+
export * from "./domain.js";
|
|
6
|
+
export * from "./errors.js";
|
|
7
|
+
export * from "./judge/index.js";
|
|
8
|
+
export * from "./memory/index.js";
|
|
9
|
+
export * from "./pipeline/index.js";
|
|
10
|
+
export * from "./plugin/index.js";
|
|
11
|
+
export * from "./rereview/index.js";
|
|
12
|
+
export * from "./review/index.js";
|
|
13
|
+
export * from "./rules/index.js";
|
|
14
|
+
export * from "./select/index.js";
|
|
15
|
+
export * from "./session/index.js";
|
|
16
|
+
export * from "./triage.js";
|
|
17
|
+
export * from "./verify/index.js";
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { AgentRuntime, Usage } from "../contracts.js";
|
|
2
|
+
import type { ChangeRequest, Finding, PriorFinding, RiskTier, Severity, Verdict } from "../domain.js";
|
|
3
|
+
import { type JudgeResponse } from "./prompt.js";
|
|
4
|
+
export declare const JUDGE_TIMEOUT_MS = 180000;
|
|
5
|
+
export interface JudgeDecisions {
|
|
6
|
+
merged: {
|
|
7
|
+
kept: string;
|
|
8
|
+
merged: string[];
|
|
9
|
+
}[];
|
|
10
|
+
dropped: {
|
|
11
|
+
fingerprint: string;
|
|
12
|
+
file: string;
|
|
13
|
+
title: string;
|
|
14
|
+
reason: string;
|
|
15
|
+
}[];
|
|
16
|
+
recalibrated: {
|
|
17
|
+
fingerprint: string;
|
|
18
|
+
from: Severity;
|
|
19
|
+
to: Severity;
|
|
20
|
+
reason: string;
|
|
21
|
+
}[];
|
|
22
|
+
}
|
|
23
|
+
export interface JudgeResult {
|
|
24
|
+
findings: Finding[];
|
|
25
|
+
verdict: Verdict;
|
|
26
|
+
summary: string;
|
|
27
|
+
decisions?: JudgeDecisions;
|
|
28
|
+
usage: Usage[];
|
|
29
|
+
warnings: string[];
|
|
30
|
+
}
|
|
31
|
+
export interface JudgeOptions {
|
|
32
|
+
runtime: AgentRuntime;
|
|
33
|
+
changeRequest: ChangeRequest;
|
|
34
|
+
tier: RiskTier;
|
|
35
|
+
signal: AbortSignal;
|
|
36
|
+
enabled: boolean;
|
|
37
|
+
keepDropped?: boolean;
|
|
38
|
+
carried?: readonly PriorFinding[];
|
|
39
|
+
}
|
|
40
|
+
export declare function judgeFindings(findings: readonly Finding[], options: JudgeOptions): Promise<JudgeResult>;
|
|
41
|
+
export declare function applyDecisions(findings: readonly Finding[], response: JudgeResponse): {
|
|
42
|
+
findings: Finding[];
|
|
43
|
+
decisions: JudgeDecisions;
|
|
44
|
+
warnings: string[];
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=judge.d.ts.map
|