@andorra-labs/code 0.1.16 → 0.1.17
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/dist/src/acp-agent.d.ts +6 -0
- package/dist/src/acp-agent.js +15 -4
- package/dist/src/agent-execution.js +11 -8
- package/dist/src/agent-mcp-catalog.js +1 -0
- package/dist/src/agent-mcp.d.ts +3 -0
- package/dist/src/agent-mcp.js +33 -1
- package/dist/src/andorra/entry.d.ts +10 -0
- package/dist/src/andorra/entry.js +18 -4
- package/dist/src/andorra/hosted.d.ts +2 -1
- package/dist/src/andorra/hosted.js +2 -1
- package/dist/src/andorra/notices.d.ts +5 -0
- package/dist/src/andorra/notices.js +7 -0
- package/dist/src/andorra/state.d.ts +3 -2
- package/dist/src/andorra/state.js +4 -4
- package/dist/src/andorra/terminal.js +7 -2
- package/dist/src/anthropic-credentials.js +2 -0
- package/dist/src/app-server/error.d.ts +5 -0
- package/dist/src/app-server/error.js +7 -0
- package/dist/src/app-server/protocol.d.ts +19 -44
- package/dist/src/app-server/protocol.js +5 -1
- package/dist/src/app-server/workspace.d.ts +89 -0
- package/dist/src/app-server/workspace.js +457 -11
- package/dist/src/app-server.d.ts +358 -32
- package/dist/src/app-server.js +2429 -509
- package/dist/src/bridge/cloud.d.ts +27 -0
- package/dist/src/bridge/cloud.js +187 -0
- package/dist/src/bridge/command.d.ts +30 -0
- package/dist/src/bridge/command.js +347 -0
- package/dist/src/bridge/control.d.ts +68 -0
- package/dist/src/bridge/control.js +233 -0
- package/dist/src/bridge/engines.d.ts +90 -0
- package/dist/src/bridge/engines.js +601 -0
- package/dist/src/bridge/host-ops.d.ts +9 -0
- package/dist/src/bridge/host-ops.js +129 -0
- package/dist/src/bridge/host.d.ts +47 -0
- package/dist/src/bridge/host.js +540 -0
- package/dist/src/bridge/link.d.ts +38 -0
- package/dist/src/bridge/link.js +508 -0
- package/dist/src/bridge/login-link.d.ts +29 -0
- package/dist/src/bridge/login-link.js +54 -0
- package/dist/src/bridge/protocol.d.ts +136 -0
- package/dist/src/bridge/protocol.js +11 -0
- package/dist/src/bridge/store.d.ts +12 -0
- package/dist/src/bridge/store.js +61 -0
- package/dist/src/bridge/wording.d.ts +6 -0
- package/dist/src/bridge/wording.js +10 -0
- package/dist/src/browser-server.js +7 -1
- package/dist/src/browser-ui/tokens.css +1 -1
- package/dist/src/change-authors.d.ts +41 -0
- package/dist/src/change-authors.js +146 -0
- package/dist/src/cli.js +182 -32
- package/dist/src/coding-tools.js +15 -15
- package/dist/src/command-screens.d.ts +6 -0
- package/dist/src/command-screens.js +14 -11
- package/dist/src/commands.d.ts +14 -2
- package/dist/src/compaction-phrases.js +1 -1
- package/dist/src/completion.js +82 -5
- package/dist/src/config.d.ts +71 -3
- package/dist/src/config.js +202 -77
- package/dist/src/deadline.js +13 -1
- package/dist/src/decision/checks.js +1 -1
- package/dist/src/decision/requestPhrases.js +0 -1
- package/dist/src/default-graph.js +1 -1
- package/dist/src/file-diff.d.ts +4 -0
- package/dist/src/file-diff.js +2 -1
- package/dist/src/github-app/agent-writes.d.ts +102 -0
- package/dist/src/github-app/agent-writes.js +320 -0
- package/dist/src/github-app/client.d.ts +349 -0
- package/dist/src/github-app/client.js +810 -0
- package/dist/src/github-app/event-source.d.ts +208 -0
- package/dist/src/github-app/event-source.js +684 -0
- package/dist/src/github-app/metrics.d.ts +32 -0
- package/dist/src/github-app/metrics.js +49 -0
- package/dist/src/github-app/review-loop.d.ts +274 -0
- package/dist/src/github-app/review-loop.js +1177 -0
- package/dist/src/github-app/review-node.d.ts +81 -0
- package/dist/src/github-app/review-node.js +205 -0
- package/dist/src/github-app/review-post.d.ts +73 -0
- package/dist/src/github-app/review-post.js +139 -0
- package/dist/src/github-app/review-text.d.ts +107 -0
- package/dist/src/github-app/review-text.js +1133 -0
- package/dist/src/github-app/review-threads.d.ts +47 -0
- package/dist/src/github-app/review-threads.js +107 -0
- package/dist/src/github-app/reviewer.d.ts +121 -0
- package/dist/src/github-app/reviewer.js +598 -0
- package/dist/src/github-app/store.d.ts +59 -0
- package/dist/src/github-app/store.js +148 -0
- package/dist/src/github-app/triggers.d.ts +141 -0
- package/dist/src/github-app/triggers.js +441 -0
- package/dist/src/github-names.d.ts +8 -0
- package/dist/src/github-names.js +8 -0
- package/dist/src/glob-search.d.ts +61 -0
- package/dist/src/glob-search.js +180 -0
- package/dist/src/graph-health.js +6 -1
- package/dist/src/graph-manager-chat.js +1 -1
- package/dist/src/graph-preview.d.ts +46 -0
- package/dist/src/graph-preview.js +55 -0
- package/dist/src/graph-provider-portability.js +2 -1
- package/dist/src/graph-runner.js +64 -3
- package/dist/src/graph-server.js +3 -3
- package/dist/src/graph-sync.js +3 -3
- package/dist/src/graph-ui/app.js +91 -7
- package/dist/src/graph-ui/icons.js +2 -1
- package/dist/src/graph-ui/studio.js +15 -1
- package/dist/src/graph-ui/tokens.css +1 -1
- package/dist/src/graphs.d.ts +34 -1
- package/dist/src/graphs.js +158 -14
- package/dist/src/image-input.d.ts +16 -0
- package/dist/src/image-input.js +41 -0
- package/dist/src/membership.d.ts +10 -0
- package/dist/src/membership.js +19 -4
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.d.ts +6 -0
- package/dist/src/model-metadata.js +35 -15
- package/dist/src/model-relay/local.d.ts +116 -0
- package/dist/src/model-relay/local.js +468 -0
- package/dist/src/model-relay/remote.d.ts +129 -0
- package/dist/src/model-relay/remote.js +252 -0
- package/dist/src/model-relay/runs.d.ts +34 -0
- package/dist/src/model-relay/runs.js +146 -0
- package/dist/src/model-relay/wire.d.ts +5 -0
- package/dist/src/model-relay/wire.js +5 -0
- package/dist/src/project-registry.d.ts +21 -0
- package/dist/src/project-registry.js +74 -0
- package/dist/src/provider-import.d.ts +0 -12
- package/dist/src/provider-import.js +7 -195
- package/dist/src/providers.d.ts +23 -2
- package/dist/src/providers.js +25 -4
- package/dist/src/pull-request-logs.d.ts +12 -1
- package/dist/src/pull-request-logs.js +14 -3
- package/dist/src/pull-requests.d.ts +327 -7
- package/dist/src/pull-requests.js +429 -51
- package/dist/src/react-runtime.js +1 -1
- package/dist/src/remote/engine-pool.d.ts +88 -4
- package/dist/src/remote/engine-pool.js +366 -89
- package/dist/src/remote/roots.d.ts +19 -0
- package/dist/src/remote/roots.js +45 -7
- package/dist/src/remote/types.d.ts +0 -44
- package/dist/src/run-control.d.ts +7 -0
- package/dist/src/run-control.js +23 -0
- package/dist/src/run-records.d.ts +7 -2
- package/dist/src/run-records.js +71 -6
- package/dist/src/runtime.d.ts +5 -1
- package/dist/src/runtime.js +10 -2
- package/dist/src/session-changes.d.ts +35 -0
- package/dist/src/session-changes.js +194 -6
- package/dist/src/session-monitor.js +2 -1
- package/dist/src/session-reaper.d.ts +1 -1
- package/dist/src/session-reaper.js +6 -1
- package/dist/src/session-summary.d.ts +2 -1
- package/dist/src/session-summary.js +2 -1
- package/dist/src/sessions.d.ts +11 -1
- package/dist/src/sessions.js +17 -4
- package/dist/src/skills/bundled/diagram/SKILL.md +5 -3
- package/dist/src/skills/bundled/graph-manager/SKILL.md +7 -4
- package/dist/src/skills/bundled/provenance.json +2 -2
- package/dist/src/skills/runtime-skills.js +1 -1
- package/dist/src/telemetry/emitter.d.ts +15 -0
- package/dist/src/telemetry/emitter.js +35 -1
- package/dist/src/telemetry/schema.d.ts +25 -2
- package/dist/src/telemetry/schema.js +52 -4
- package/dist/src/telemetry/surface.d.ts +2 -1
- package/dist/src/telemetry/surface.js +4 -1
- package/dist/src/terminal-ui.d.ts +1 -0
- package/dist/src/terminal-ui.js +10 -3
- package/dist/src/test-edit-guard.d.ts +7 -0
- package/dist/src/test-edit-guard.js +49 -1
- package/dist/src/timers.d.ts +2 -0
- package/dist/src/tools.js +59 -9
- package/package.json +6 -1
- package/dist/src/remote/cert.d.ts +0 -11
- package/dist/src/remote/cert.js +0 -87
- package/dist/src/remote/client.d.ts +0 -119
- package/dist/src/remote/client.js +0 -544
- package/dist/src/remote/command.d.ts +0 -4
- package/dist/src/remote/command.js +0 -194
- package/dist/src/remote/errors.d.ts +0 -11
- package/dist/src/remote/errors.js +0 -14
- package/dist/src/remote/network.d.ts +0 -22
- package/dist/src/remote/network.js +0 -102
- package/dist/src/remote/pairing.d.ts +0 -63
- package/dist/src/remote/pairing.js +0 -299
- package/dist/src/remote/pem.d.ts +0 -2
- package/dist/src/remote/pem.js +0 -7
- package/dist/src/remote/serve.d.ts +0 -68
- package/dist/src/remote/serve.js +0 -244
- package/dist/src/remote/server.d.ts +0 -21
- package/dist/src/remote/server.js +0 -406
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type GhRunner } from '../pull-requests.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reading the Andorra review loop's own reviews and threads back from GitHub, with `gh` as the person
|
|
4
|
+
* (design/specs/andorra-review-loop.md, "Telling findings from replies" and "The marker check").
|
|
5
|
+
*/
|
|
6
|
+
export interface ReviewMarker {
|
|
7
|
+
loop: string;
|
|
8
|
+
round: number;
|
|
9
|
+
of: number;
|
|
10
|
+
}
|
|
11
|
+
export interface PullRequestCoordinates {
|
|
12
|
+
owner: string;
|
|
13
|
+
repo: string;
|
|
14
|
+
number: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A thread the bot started in a review whose marker names this loop: a finding thread (R1). `path` and `line` are its first
|
|
18
|
+
* comment's, as posted (`originalLine`), so the loop can match it to an inline finding; `reply` is the thread's latest
|
|
19
|
+
* comment when it has more than the finding (the fixer's answer, or the person's), cut to 2,000 characters.
|
|
20
|
+
*/
|
|
21
|
+
export interface FindingThread {
|
|
22
|
+
threadId: string;
|
|
23
|
+
reviewId: string;
|
|
24
|
+
round: number;
|
|
25
|
+
isResolved: boolean;
|
|
26
|
+
isOutdated: boolean;
|
|
27
|
+
path?: string;
|
|
28
|
+
line?: number;
|
|
29
|
+
reply?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function parseReviewMarker(body: unknown): ReviewMarker | undefined;
|
|
32
|
+
/** An Andorra Code App's bot, as REST (`…[bot]`) or GraphQL (without the suffix) names it. */
|
|
33
|
+
export declare function isAndorraBot(login: unknown): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The finding threads of `loop` on the PR. A thread counts only when its first comment is the bot's and was
|
|
36
|
+
* written in a review whose marker names this loop: the bot's replies, its PR comments, an unmarked review by
|
|
37
|
+
* the bot and a marked review of another loop never count.
|
|
38
|
+
*/
|
|
39
|
+
export declare function readFindingThreads(gh: GhRunner, pr: PullRequestCoordinates, loop: string): Promise<FindingThread[]>;
|
|
40
|
+
/**
|
|
41
|
+
* The marker check: the bot's review of `loop`'s `round` on the PR, if GitHub has one. It reads the reviews
|
|
42
|
+
* newest first, back to `since` (the round's start), so a clean review, which has no threads, is found too.
|
|
43
|
+
*/
|
|
44
|
+
export declare function findRoundReview(gh: GhRunner, pr: PullRequestCoordinates, loop: string, round: number, since?: string): Promise<{
|
|
45
|
+
reviewId: string;
|
|
46
|
+
url?: string;
|
|
47
|
+
} | undefined>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { ANDORRA_BOT_LOGINS } from '../pull-requests.js';
|
|
2
|
+
/** The marker the service writes at the very top of a review's body, and nowhere else. */
|
|
3
|
+
const MARKER = /^<!--\s*andorra-review\s+loop=([0-7][0-9A-HJKMNP-TV-Z]{25})\s+round=(\d{1,2})\s+of=(\d{1,2})\s*-->/;
|
|
4
|
+
const THREAD_ID = /^PRRT_[A-Za-z0-9_-]{1,120}$/;
|
|
5
|
+
const REVIEW_ID = /^PRR_[A-Za-z0-9_-]{1,120}$/;
|
|
6
|
+
const MAX_PAGES = 20;
|
|
7
|
+
export function parseReviewMarker(body) {
|
|
8
|
+
if (typeof body !== 'string')
|
|
9
|
+
return undefined;
|
|
10
|
+
const match = MARKER.exec(body);
|
|
11
|
+
if (!match)
|
|
12
|
+
return undefined;
|
|
13
|
+
const round = Number(match[2]);
|
|
14
|
+
const of = Number(match[3]);
|
|
15
|
+
if (round < 1 || of < 1 || round > of || of > 10)
|
|
16
|
+
return undefined;
|
|
17
|
+
return { loop: match[1], round, of };
|
|
18
|
+
}
|
|
19
|
+
/** An Andorra Code App's bot, as REST (`…[bot]`) or GraphQL (without the suffix) names it. */
|
|
20
|
+
export function isAndorraBot(login) {
|
|
21
|
+
return typeof login === 'string' && ANDORRA_BOT_LOGINS.includes(login.toLowerCase().replace(/\[bot\]$/, ''));
|
|
22
|
+
}
|
|
23
|
+
const graphql = (gh, query, pr, extra = []) => gh(['api', 'graphql', '--hostname', 'github.com', '-f', `query=${query}`, '-f', `owner=${pr.owner}`, '-f', `name=${pr.repo}`, '-F', `number=${pr.number}`, ...extra], { maxBuffer: 16 * 1024 * 1024 });
|
|
24
|
+
const THREADS_QUERY = 'query($owner: String!, $name: String!, $number: Int!, $after: String) { repository(owner: $owner, name: $name) { pullRequest(number: $number) { reviewThreads(first: 100, after: $after) { pageInfo { hasNextPage endCursor } nodes { id isResolved isOutdated comments(first: 1) { nodes { author { login } path line originalLine pullRequestReview { id } } } latest: comments(last: 1) { totalCount nodes { body } } } } } } }';
|
|
25
|
+
const REPLY_CHARS = 2_000;
|
|
26
|
+
const BODIES_QUERY = 'query($ids: [ID!]!) { nodes(ids: $ids) { ... on PullRequestReview { id body } } }';
|
|
27
|
+
const lineOf = (value) => Number.isSafeInteger(value) && value > 0 ? value : undefined;
|
|
28
|
+
/**
|
|
29
|
+
* The finding threads of `loop` on the PR. A thread counts only when its first comment is the bot's and was
|
|
30
|
+
* written in a review whose marker names this loop: the bot's replies, its PR comments, an unmarked review by
|
|
31
|
+
* the bot and a marked review of another loop never count.
|
|
32
|
+
*/
|
|
33
|
+
export async function readFindingThreads(gh, pr, loop) {
|
|
34
|
+
const candidates = [];
|
|
35
|
+
let cursor;
|
|
36
|
+
for (let page = 0; page < MAX_PAGES; page++) {
|
|
37
|
+
const raw = JSON.parse(await graphql(gh, THREADS_QUERY, pr, cursor === undefined ? [] : ['-f', `after=${cursor}`]));
|
|
38
|
+
const threads = raw.data?.repository?.pullRequest?.reviewThreads;
|
|
39
|
+
for (const node of threads?.nodes ?? []) {
|
|
40
|
+
const first = node.comments?.nodes?.[0];
|
|
41
|
+
const reviewId = first?.pullRequestReview?.id;
|
|
42
|
+
if (typeof node.id !== 'string' || !THREAD_ID.test(node.id) || !isAndorraBot(first?.author?.login))
|
|
43
|
+
continue;
|
|
44
|
+
if (typeof reviewId !== 'string' || !REVIEW_ID.test(reviewId))
|
|
45
|
+
continue;
|
|
46
|
+
const path = typeof first?.path === 'string' && first.path ? first.path : undefined;
|
|
47
|
+
const line = lineOf(first?.originalLine) ?? lineOf(first?.line);
|
|
48
|
+
const latest = node.latest?.nodes?.[0]?.body;
|
|
49
|
+
const reply = typeof node.latest?.totalCount === 'number' && node.latest.totalCount > 1 && typeof latest === 'string' && latest.trim()
|
|
50
|
+
? (latest.length > REPLY_CHARS ? `${latest.slice(0, REPLY_CHARS)}\u2026` : latest) : undefined;
|
|
51
|
+
candidates.push({ threadId: node.id, reviewId, isResolved: node.isResolved === true, isOutdated: node.isOutdated === true,
|
|
52
|
+
...(path === undefined ? {} : { path }), ...(line === undefined ? {} : { line }), ...(reply === undefined ? {} : { reply }) });
|
|
53
|
+
}
|
|
54
|
+
if (threads?.pageInfo?.hasNextPage !== true || typeof threads.pageInfo.endCursor !== 'string')
|
|
55
|
+
break;
|
|
56
|
+
cursor = threads.pageInfo.endCursor;
|
|
57
|
+
}
|
|
58
|
+
if (!candidates.length)
|
|
59
|
+
return [];
|
|
60
|
+
// Every bot reply is filed in an empty-body review of its own, so the review's body, not its author, decides.
|
|
61
|
+
const markers = new Map();
|
|
62
|
+
const ids = [...new Set(candidates.map(candidate => candidate.reviewId))];
|
|
63
|
+
for (let start = 0; start < ids.length; start += 100) {
|
|
64
|
+
const batch = ids.slice(start, start + 100);
|
|
65
|
+
const raw = JSON.parse(await gh(['api', 'graphql', '--hostname', 'github.com', '-f', `query=${BODIES_QUERY}`, ...batch.flatMap(id => ['-f', `ids[]=${id}`])], { maxBuffer: 16 * 1024 * 1024 }));
|
|
66
|
+
for (const node of raw.data?.nodes ?? [])
|
|
67
|
+
if (node && typeof node.id === 'string')
|
|
68
|
+
markers.set(node.id, parseReviewMarker(node.body));
|
|
69
|
+
}
|
|
70
|
+
return candidates.flatMap(candidate => {
|
|
71
|
+
const marker = markers.get(candidate.reviewId);
|
|
72
|
+
return marker?.loop === loop ? [{ ...candidate, round: marker.round }] : [];
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
const REVIEWS_QUERY = 'query($owner: String!, $name: String!, $number: Int!, $before: String) { repository(owner: $owner, name: $name) { pullRequest(number: $number) { reviews(last: 50, before: $before) { pageInfo { hasPreviousPage startCursor } nodes { id url body createdAt author { login } } } } } }';
|
|
76
|
+
/**
|
|
77
|
+
* The marker check: the bot's review of `loop`'s `round` on the PR, if GitHub has one. It reads the reviews
|
|
78
|
+
* newest first, back to `since` (the round's start), so a clean review, which has no threads, is found too.
|
|
79
|
+
*/
|
|
80
|
+
export async function findRoundReview(gh, pr, loop, round, since) {
|
|
81
|
+
const floor = since === undefined ? Number.NEGATIVE_INFINITY : Date.parse(since) - 60_000;
|
|
82
|
+
let cursor;
|
|
83
|
+
for (let page = 0; page < MAX_PAGES; page++) {
|
|
84
|
+
const raw = JSON.parse(await graphql(gh, REVIEWS_QUERY, pr, cursor === undefined ? [] : ['-f', `before=${cursor}`]));
|
|
85
|
+
const reviews = raw.data?.repository?.pullRequest?.reviews;
|
|
86
|
+
const nodes = reviews?.nodes ?? [];
|
|
87
|
+
let older = false;
|
|
88
|
+
for (const node of [...nodes].reverse()) {
|
|
89
|
+
const at = typeof node.createdAt === 'string' ? Date.parse(node.createdAt) : Number.NaN;
|
|
90
|
+
if (Number.isFinite(at) && at < floor) {
|
|
91
|
+
older = true;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (!isAndorraBot(node.author?.login) || typeof node.id !== 'string' || !REVIEW_ID.test(node.id))
|
|
95
|
+
continue;
|
|
96
|
+
const marker = parseReviewMarker(node.body);
|
|
97
|
+
if (marker?.loop !== loop || marker.round !== round)
|
|
98
|
+
continue;
|
|
99
|
+
const url = typeof node.url === 'string' && /^https:\/\/github\.com\/\S+$/.test(node.url) ? node.url : undefined;
|
|
100
|
+
return { reviewId: node.id, ...(url === undefined ? {} : { url }) };
|
|
101
|
+
}
|
|
102
|
+
if (older || reviews?.pageInfo?.hasPreviousPage !== true || typeof reviews.pageInfo.startCursor !== 'string')
|
|
103
|
+
return undefined;
|
|
104
|
+
cursor = reviews.pageInfo.startCursor;
|
|
105
|
+
}
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The review loop's reviewer, outside the model: the throwaway worktree it reads, and the headless CLI child that runs
|
|
3
|
+
* the built-in `andorra-reviewer` graph in it (design/specs/andorra-review-loop.md, "The reviewer").
|
|
4
|
+
*
|
|
5
|
+
* - The worktree is detached at the pull request's head, under the engine's temporary directory, never the task's own
|
|
6
|
+
* checkout. It holds none of the task's uncommitted edits or untracked files, and its inputs live in
|
|
7
|
+
* `.andorra-review/` inside it, so they never reach the task's tree. `cleanup()` removes it whatever happened, and a
|
|
8
|
+
* start-up sweep removes any a crash left behind.
|
|
9
|
+
* - The child is the same CLI build, in a process of its own, so it never takes the task's run slot. It is stopped by
|
|
10
|
+
* its own handle (`child.kill()`), never by name.
|
|
11
|
+
*/
|
|
12
|
+
/** Where every review worktree is made: one `round-<random>` folder per round. */
|
|
13
|
+
/**
|
|
14
|
+
* The review root, one per user: on a shared temporary folder another account cannot block or share it. It is named by
|
|
15
|
+
* the user id where there is one, otherwise by a hash of the home folder.
|
|
16
|
+
*/
|
|
17
|
+
export declare const REVIEW_WORKSPACE_ROOT: () => string;
|
|
18
|
+
export interface ReviewWorkspace {
|
|
19
|
+
/** The detached worktree at the pull request's head; the reviewer's `--cwd`. */
|
|
20
|
+
dir: string;
|
|
21
|
+
/** The full three-dot diff (merge base to head), never cut. */
|
|
22
|
+
diff: string;
|
|
23
|
+
mergeBase: string;
|
|
24
|
+
files: {
|
|
25
|
+
path: string;
|
|
26
|
+
added: number;
|
|
27
|
+
deleted: number;
|
|
28
|
+
}[];
|
|
29
|
+
/** Removes the worktree and its folder. Never throws, and a second call does nothing more. */
|
|
30
|
+
cleanup(): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export type GitRunner = (args: string[], cwd: string, options?: {
|
|
33
|
+
input?: string;
|
|
34
|
+
}) => Promise<string>;
|
|
35
|
+
/** The largest diff.patch, and the largest per-file patch, written for the reviewer. */
|
|
36
|
+
export declare const REVIEW_DIFF_INPUT_BYTES: number;
|
|
37
|
+
/** The github.com owner and repository a remote URL names (https, ssh or scp-like form, `.git` optional), if any. */
|
|
38
|
+
export declare function githubRepositoryOf(url: string): {
|
|
39
|
+
owner: string;
|
|
40
|
+
repo: string;
|
|
41
|
+
} | undefined;
|
|
42
|
+
/** One changed file from `git diff --numstat -z`: binary files count no lines. */
|
|
43
|
+
interface ChangedFile {
|
|
44
|
+
path: string;
|
|
45
|
+
previousPath?: string;
|
|
46
|
+
added: number;
|
|
47
|
+
deleted: number;
|
|
48
|
+
binary: boolean;
|
|
49
|
+
}
|
|
50
|
+
export declare function parseNumstat(output: string): ChangedFile[];
|
|
51
|
+
/** `text` cut to at most `limit` bytes at a line end, its last line saying it was cut; unchanged when it fits. */
|
|
52
|
+
export declare function cutPatch(text: string, limit: number, note: (bytes: number) => string): string;
|
|
53
|
+
export declare function prepareReviewWorkspace(input: {
|
|
54
|
+
repoDir: string;
|
|
55
|
+
owner: string;
|
|
56
|
+
repo: string;
|
|
57
|
+
number: number;
|
|
58
|
+
headSha: string;
|
|
59
|
+
baseRef: string;
|
|
60
|
+
pr: {
|
|
61
|
+
url: string;
|
|
62
|
+
title: string;
|
|
63
|
+
body: string;
|
|
64
|
+
};
|
|
65
|
+
rounds: unknown;
|
|
66
|
+
instruction?: string;
|
|
67
|
+
git?: GitRunner;
|
|
68
|
+
signal?: AbortSignal;
|
|
69
|
+
sleep?: (ms: number) => Promise<void>;
|
|
70
|
+
}): Promise<ReviewWorkspace>;
|
|
71
|
+
export interface ReviewerRun {
|
|
72
|
+
/** The run's status (`succeeded`, `exhausted`, `cancelled`, `infrastructure_error`, ...), or `failed` when it left no result. */
|
|
73
|
+
status: string;
|
|
74
|
+
runId?: string;
|
|
75
|
+
reason?: string;
|
|
76
|
+
/** The reviewer node's structured output: `{ summary, findings }` when the run succeeded. */
|
|
77
|
+
output?: unknown;
|
|
78
|
+
usage?: {
|
|
79
|
+
inputTokens: number;
|
|
80
|
+
outputTokens: number;
|
|
81
|
+
};
|
|
82
|
+
toolCalls?: number;
|
|
83
|
+
exitCode: number | null;
|
|
84
|
+
stderrTail: string;
|
|
85
|
+
}
|
|
86
|
+
/** A little over the graph's 20 minutes, for the CLI's start and the model check before the run. */
|
|
87
|
+
export declare const REVIEWER_TIMEOUT_MS: number;
|
|
88
|
+
/** The run result the CLI printed as its last JSON line under `--json`, if any. */
|
|
89
|
+
export declare function parseRunResult(stdout: string): Record<string, unknown> | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Runs the reviewer as a headless CLI child on `workspace` and reads its findings from the run result. The child's
|
|
92
|
+
* session is saved with the `andorra-review` origin, which keeps it out of the task lists. It is stopped through its
|
|
93
|
+
* own handle on abort or timeout: SIGTERM, then SIGKILL a few seconds later.
|
|
94
|
+
*/
|
|
95
|
+
export declare function runReviewer(input: {
|
|
96
|
+
workspace: string;
|
|
97
|
+
cliPath?: string;
|
|
98
|
+
provider: string;
|
|
99
|
+
model: string;
|
|
100
|
+
runInput: {
|
|
101
|
+
round: number;
|
|
102
|
+
rounds: number;
|
|
103
|
+
loop: string;
|
|
104
|
+
hasInstruction: boolean;
|
|
105
|
+
};
|
|
106
|
+
env?: NodeJS.ProcessEnv;
|
|
107
|
+
signal?: AbortSignal;
|
|
108
|
+
timeoutMs?: number;
|
|
109
|
+
onSpawn?: (pid: number) => void;
|
|
110
|
+
nodePath?: string;
|
|
111
|
+
}): Promise<ReviewerRun>;
|
|
112
|
+
/**
|
|
113
|
+
* Removes the `round-*` folders under the review root older than `olderThanMs` (an hour by default) that a crash left
|
|
114
|
+
* behind, and answers how many. It never follows a symbolic link: a linked root or round is left alone.
|
|
115
|
+
*/
|
|
116
|
+
export declare function sweepReviewWorkspaces(options?: {
|
|
117
|
+
root?: string;
|
|
118
|
+
olderThanMs?: number;
|
|
119
|
+
now?: () => number;
|
|
120
|
+
}): Promise<number>;
|
|
121
|
+
export {};
|