tryharness 0.7.53 → 0.7.57
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 +23 -19
- package/assets/dsh-plugin.mjs +72 -0
- package/assets/opencode-plugin.js +4 -3
- package/cli.mjs +484 -90
- package/lib/activity.mjs +10 -10
- package/lib/adapters.mjs +173 -222
- package/lib/agentBinaries.mjs +71 -0
- package/lib/agentRuntimeConfig.mjs +1 -1
- package/lib/agentRuntimes.mjs +34 -18
- package/lib/agentSignIn.mjs +456 -0
- package/lib/answers.mjs +5 -5
- package/lib/archetypes.d.ts +64 -0
- package/lib/archetypes.js +989 -0
- package/lib/asks.mjs +4 -4
- package/lib/audit.mjs +666 -0
- package/lib/backupSetup.mjs +143 -0
- package/lib/boardAccess.mjs +24 -11
- package/lib/boardBackup.mjs +283 -0
- package/lib/boardFileCommands.mjs +6 -6
- package/lib/boardFiles.mjs +13 -12
- package/lib/boardMirror.mjs +124 -25
- package/lib/boardProtocol.json +88 -2
- package/lib/boardWaits.mjs +101 -0
- package/lib/book.mjs +659 -0
- package/lib/bridge.mjs +6 -6
- package/lib/cards.mjs +138 -28
- package/lib/cloudAgents.mjs +216 -0
- package/lib/cloudAi.mjs +1312 -0
- package/lib/cloudAssistants.mjs +242 -0
- package/lib/cloudBoot.mjs +119 -0
- package/lib/cloudSave.mjs +197 -0
- package/lib/cloudSsh.mjs +178 -0
- package/lib/commands.mjs +7 -2
- package/lib/context.mjs +19 -5
- package/lib/contractGate.mjs +399 -0
- package/lib/control-client.mjs +9 -1
- package/lib/controlSocket.mjs +86 -0
- package/lib/coordinator.mjs +252 -144
- package/lib/daemon.mjs +1351 -2767
- package/lib/desk.mjs +240 -0
- package/lib/desktop.mjs +178 -74
- package/lib/directLink.mjs +16 -5
- package/lib/environment.mjs +2 -1
- package/lib/environments.mjs +247 -9
- package/lib/firewall.mjs +9 -9
- package/lib/folders.mjs +20 -16
- package/lib/frames.mjs +2 -3
- package/lib/gitHost.mjs +174 -0
- package/lib/goalCommands.mjs +25 -7
- package/lib/goals.mjs +7 -7
- package/lib/guestRequests.mjs +94 -0
- package/lib/handoffs.mjs +8 -7
- package/lib/handover.mjs +4 -4
- package/lib/harnessModel.mjs +6 -6
- package/lib/harnessOffers.mjs +266 -0
- package/lib/hookDialects.mjs +298 -0
- package/lib/inference.mjs +26 -8
- package/lib/jobAnswers.mjs +190 -0
- package/lib/landed.mjs +887 -0
- package/lib/lane.mjs +42 -11
- package/lib/lessons.mjs +16 -16
- package/lib/library.mjs +3 -3
- package/lib/lineup.mjs +3 -0
- package/lib/linkRelay.mjs +574 -0
- package/lib/live.mjs +284 -13
- package/lib/localAgentAsk.mjs +74 -0
- package/lib/localStack.mjs +536 -0
- package/lib/localmodels.mjs +6 -4
- package/lib/loopBackstop.mjs +4 -4
- package/lib/machineIdentity.mjs +9 -1
- package/lib/machineRoutes.mjs +181 -2
- package/lib/machineRuns.mjs +76 -1
- package/lib/machineSeal.mjs +39 -12
- package/lib/mcp-stdio.mjs +163 -27
- package/lib/mcpRelay.mjs +1 -1
- package/lib/members.json +29 -2
- package/lib/members.mjs +1 -1
- package/lib/models.mjs +85 -31
- package/lib/museSession.mjs +21 -13
- package/lib/nativeHost.mjs +36 -8
- package/lib/neovim.mjs +126 -0
- package/lib/network.mjs +50 -5
- package/lib/notify.mjs +7 -5
- package/lib/nudge.mjs +50 -19
- package/lib/ocr.mjs +9 -9
- package/lib/onboard.mjs +26 -20
- package/lib/oneLine.mjs +7 -7
- package/lib/ownMachines.mjs +1223 -140
- package/lib/pairing.mjs +60 -16
- package/lib/paths.mjs +19 -1
- package/lib/peerProcess.mjs +124 -0
- package/lib/personModel.mjs +89 -0
- package/lib/personNotices.mjs +151 -0
- package/lib/phones.mjs +538 -31
- package/lib/placeCommands.mjs +4 -4
- package/lib/places.mjs +400 -12
- package/lib/profile.mjs +67 -14
- package/lib/projectGit.mjs +158 -14
- package/lib/projectPieces.mjs +902 -0
- package/lib/projectSettings.mjs +7 -4
- package/lib/projects.mjs +384 -62
- package/lib/provenance.mjs +5 -1
- package/lib/proxyLinks.mjs +267 -0
- package/lib/reactions.mjs +7 -5
- package/lib/readiness.mjs +145 -23
- package/lib/record.mjs +128 -0
- package/lib/redact.mjs +4 -4
- package/lib/relayLimits.mjs +62 -0
- package/lib/release.mjs +170 -0
- package/lib/releaseKeys.json +6 -0
- package/lib/repoLinks.mjs +4 -4
- package/lib/roomChannels.mjs +24 -0
- package/lib/roomPage.mjs +1 -1
- package/lib/runAuthority.mjs +101 -0
- package/lib/runBrief.mjs +19 -8
- package/lib/runWorker.mjs +31 -7
- package/lib/runner.mjs +223 -29
- package/lib/runtime-install.mjs +143 -9
- package/lib/schedules.mjs +2 -2
- package/lib/screens.mjs +1 -1
- package/lib/sealed.mjs +11 -2
- package/lib/sealedThreads.mjs +671 -0
- package/lib/secretPatterns.json +1 -1
- package/lib/secrets.mjs +4 -4
- package/lib/seen.mjs +6 -6
- package/lib/serverWords.mjs +175 -0
- package/lib/service.mjs +22 -12
- package/lib/sessionControl.mjs +378 -90
- package/lib/specialties.json +74 -0
- package/lib/specialties.mjs +477 -0
- package/lib/specialtyKeys.d.ts +3 -0
- package/lib/specialtyKeys.js +57 -0
- package/lib/specialtyNotice.mjs +147 -0
- package/lib/specialtySnapshot.mjs +138 -0
- package/lib/speech.mjs +5 -5
- package/lib/store.mjs +420 -36
- package/lib/stuck.mjs +1 -1
- package/lib/swarm.mjs +304 -37
- package/lib/swarmDevices.mjs +319 -0
- package/lib/swarmMemory.mjs +27 -25
- package/lib/t3.mjs +24 -15
- package/lib/taskCommands.mjs +80 -20
- package/lib/taskRooms.mjs +125 -0
- package/lib/taskRuns.mjs +45 -3
- package/lib/team.json +255 -148
- package/lib/team.mjs +554 -190
- package/lib/threadActions.mjs +315 -0
- package/lib/threadAuthority.mjs +101 -0
- package/lib/threadBriefs.mjs +178 -0
- package/lib/threadLine.mjs +116 -0
- package/lib/threadRuns.mjs +209 -50
- package/lib/threadView.mjs +20 -7
- package/lib/usageTotals.mjs +2 -3
- package/lib/vault.mjs +101 -10
- package/lib/vaultCloud.mjs +2 -2
- package/lib/vaultCommands.mjs +15 -6
- package/lib/vaultTools.js +2 -2
- package/lib/verdicts.mjs +328 -0
- package/lib/wakes.mjs +1 -1
- package/lib/watches.mjs +2 -2
- package/lib/windowAsks.mjs +13 -5
- package/lib/worktrees.mjs +157 -25
- package/npm-shrinkwrap.json +1093 -0
- package/package.json +12 -11
- package/release.json +220 -0
- package/lib/modelTiers.json +0 -1183
- package/lib/modelTiers.mjs +0 -133
package/lib/projectGit.mjs
CHANGED
|
@@ -8,11 +8,17 @@ import { spawn, spawnSync } from "node:child_process";
|
|
|
8
8
|
// Each agent works on a branch of its own, in a worktree of the person's checkout made from canon's head; code moves
|
|
9
9
|
// between the two people only through the remote.
|
|
10
10
|
|
|
11
|
+
// Hooks and the file-system monitor off for every call Harness makes itself: a repository the other person also writes
|
|
12
|
+
// to can set core.hooksPath to a tracked folder, and its scripts would run here, outside any agent's sandbox.
|
|
11
13
|
const IDENTITY = [
|
|
12
14
|
"-c",
|
|
13
15
|
"user.name=Harness",
|
|
14
16
|
"-c",
|
|
15
17
|
"user.email=harness@localhost",
|
|
18
|
+
"-c",
|
|
19
|
+
"core.hooksPath=/dev/null",
|
|
20
|
+
"-c",
|
|
21
|
+
"core.fsmonitor=false",
|
|
16
22
|
];
|
|
17
23
|
const LONG_MS = 120_000;
|
|
18
24
|
|
|
@@ -74,6 +80,25 @@ export const remoteName = (remote) =>
|
|
|
74
80
|
const SHA = /^[0-9a-f]{40}$/;
|
|
75
81
|
export const validSha = (value) => SHA.test(String(value || ""));
|
|
76
82
|
|
|
83
|
+
// A branch name the other side sent (canon in an invitation) reaches git only as a plain branch name: letters, digits
|
|
84
|
+
// and . _ / -, never starting with "-" (git would read it as an option, --upload-pack=... runs a command), and one git
|
|
85
|
+
// itself accepts as a branch.
|
|
86
|
+
const BRANCH = /^[A-Za-z0-9][A-Za-z0-9._/-]{0,199}$/;
|
|
87
|
+
export const validBranch = (name) =>
|
|
88
|
+
typeof name === "string" &&
|
|
89
|
+
BRANCH.test(name) &&
|
|
90
|
+
spawnSync("git", ["check-ref-format", "--branch", name], {
|
|
91
|
+
encoding: "utf8",
|
|
92
|
+
}).status === 0;
|
|
93
|
+
|
|
94
|
+
// A remote the other side sent reaches git clone only as an address git fetches over: https, ssh, git or file, the
|
|
95
|
+
// user@host:path form, or a folder on disk. Never one starting with "-", and never a transport that runs a command
|
|
96
|
+
// (ext::, fd::).
|
|
97
|
+
const REMOTE =
|
|
98
|
+
/^(?:(?:https?|ssh|git|file):\/\/[^\s]+|[A-Za-z0-9._-]+@[A-Za-z0-9.-]+:[^\s]+|\/[^\s]*)$/;
|
|
99
|
+
export const validRemote = (remote) =>
|
|
100
|
+
typeof remote === "string" && remote.length <= 500 && REMOTE.test(remote);
|
|
101
|
+
|
|
77
102
|
/**
|
|
78
103
|
* What names a folder's repository for a project: its top folder, its first commit, its shared remote and that remote's
|
|
79
104
|
* main branch with the commit it is at. An error the person can act on when the folder cannot be shared.
|
|
@@ -86,7 +111,7 @@ export function anchorOf(folder) {
|
|
|
86
111
|
return { ok: false, error: "That folder is not a git repository." };
|
|
87
112
|
const root = top.out;
|
|
88
113
|
// A repository with more than one first commit (merged histories) is named by the oldest.
|
|
89
|
-
const firsts = git(root, ["rev-list", "--max-parents=0", "HEAD"]);
|
|
114
|
+
const firsts = git(root, ["rev-list", "--max-parents=0", "HEAD", "--"]);
|
|
90
115
|
const first = firsts.ok
|
|
91
116
|
? firsts.out.split("\n").filter(validSha).at(-1)
|
|
92
117
|
: null;
|
|
@@ -99,7 +124,7 @@ export function anchorOf(folder) {
|
|
|
99
124
|
error:
|
|
100
125
|
"That repository has no shared remote. Push it somewhere you can both reach first (GitHub, for example).",
|
|
101
126
|
};
|
|
102
|
-
const
|
|
127
|
+
const named =
|
|
103
128
|
git(root, [
|
|
104
129
|
"symbolic-ref",
|
|
105
130
|
"--short",
|
|
@@ -109,9 +134,16 @@ export function anchorOf(folder) {
|
|
|
109
134
|
(name) => git(root, ["rev-parse", "--verify", `origin/${name}`]).ok
|
|
110
135
|
) ||
|
|
111
136
|
git(root, ["rev-parse", "--abbrev-ref", "HEAD"]).out;
|
|
137
|
+
if (!validBranch(named))
|
|
138
|
+
return {
|
|
139
|
+
ok: false,
|
|
140
|
+
error: `That repository's main branch (${named}) has a name Harness can't share.`,
|
|
141
|
+
};
|
|
142
|
+
const canon = named;
|
|
112
143
|
const head =
|
|
113
|
-
git(root, ["rev-parse", `origin/${canon}`])
|
|
114
|
-
|
|
144
|
+
git(root, ["rev-parse", "--verify", "--end-of-options", `origin/${canon}`])
|
|
145
|
+
.out ||
|
|
146
|
+
git(root, ["rev-parse", "--verify", "--end-of-options", canon]).out;
|
|
115
147
|
return {
|
|
116
148
|
ok: true,
|
|
117
149
|
folder: fs.realpathSync(root),
|
|
@@ -129,7 +161,7 @@ export function anchorOf(folder) {
|
|
|
129
161
|
export const holds = (folder, sha) =>
|
|
130
162
|
validSha(sha) &&
|
|
131
163
|
fs.existsSync(folder) &&
|
|
132
|
-
git(folder, ["cat-file", "-e", `${sha}^{commit}`]).ok;
|
|
164
|
+
git(folder, ["cat-file", "-e", "--end-of-options", `${sha}^{commit}`]).ok;
|
|
133
165
|
|
|
134
166
|
/** The person's own checkout of a repository among the folders they work in: the one holding its first commit. */
|
|
135
167
|
export function findCheckout(folders, first) {
|
|
@@ -143,11 +175,16 @@ export function findCheckout(folders, first) {
|
|
|
143
175
|
|
|
144
176
|
/** A new checkout of the shared remote in the home folder, named for the repository, next to nothing already there. */
|
|
145
177
|
export async function cloneInto(remote, name) {
|
|
178
|
+
if (!validRemote(remote))
|
|
179
|
+
return {
|
|
180
|
+
ok: false,
|
|
181
|
+
error: "That repository's address isn't one Harness copies from.",
|
|
182
|
+
};
|
|
146
183
|
const base = path.basename(String(name || "project")) || "project";
|
|
147
184
|
let target = path.join(os.homedir(), base);
|
|
148
185
|
for (let n = 2; fs.existsSync(target); n += 1)
|
|
149
186
|
target = path.join(os.homedir(), `${base}-${n}`);
|
|
150
|
-
const cloned = await gitLater(os.homedir(), ["clone", remote, target]);
|
|
187
|
+
const cloned = await gitLater(os.homedir(), ["clone", "--", remote, target]);
|
|
151
188
|
if (!cloned.ok)
|
|
152
189
|
return {
|
|
153
190
|
ok: false,
|
|
@@ -158,16 +195,33 @@ export async function cloneInto(remote, name) {
|
|
|
158
195
|
|
|
159
196
|
/** Canon's newest commit on the remote, fetched now; null when the remote could not be reached. */
|
|
160
197
|
export async function fetchCanon(folder, canon) {
|
|
161
|
-
|
|
198
|
+
if (!validBranch(canon)) return null;
|
|
199
|
+
const fetched = await gitLater(folder, [
|
|
200
|
+
"fetch",
|
|
201
|
+
"--quiet",
|
|
202
|
+
"--",
|
|
203
|
+
"origin",
|
|
204
|
+
canon,
|
|
205
|
+
]);
|
|
162
206
|
if (!fetched.ok) return null;
|
|
163
|
-
const head = git(folder, [
|
|
207
|
+
const head = git(folder, [
|
|
208
|
+
"rev-parse",
|
|
209
|
+
"--verify",
|
|
210
|
+
"--end-of-options",
|
|
211
|
+
`origin/${canon}`,
|
|
212
|
+
]).out;
|
|
164
213
|
return validSha(head) ? head : null;
|
|
165
214
|
}
|
|
166
215
|
|
|
167
216
|
/** How many commits canon has that `sha` does not: how far a branch made from `sha` is behind. */
|
|
168
217
|
export function behind(folder, sha, canonHead) {
|
|
169
218
|
if (!validSha(sha) || !validSha(canonHead) || sha === canonHead) return 0;
|
|
170
|
-
const counted = git(folder, [
|
|
219
|
+
const counted = git(folder, [
|
|
220
|
+
"rev-list",
|
|
221
|
+
"--count",
|
|
222
|
+
"--end-of-options",
|
|
223
|
+
`${sha}..${canonHead}`,
|
|
224
|
+
]);
|
|
171
225
|
return counted.ok ? Number(counted.out) || 0 : 0;
|
|
172
226
|
}
|
|
173
227
|
|
|
@@ -184,15 +238,18 @@ export const branchSlug = (text) =>
|
|
|
184
238
|
*/
|
|
185
239
|
export function laneFor({ checkout, where, branch, base }) {
|
|
186
240
|
if (fs.existsSync(path.join(where, ".git"))) return { ok: true, path: where };
|
|
241
|
+
if (!validBranch(branch) || !(validSha(base) || validBranch(base)))
|
|
242
|
+
return { ok: false, error: `could not make ${branch}: not a branch name` };
|
|
187
243
|
fs.mkdirSync(path.dirname(where), { recursive: true });
|
|
188
244
|
const existing = git(checkout, [
|
|
189
245
|
"rev-parse",
|
|
190
246
|
"--verify",
|
|
247
|
+
"--end-of-options",
|
|
191
248
|
`refs/heads/${branch}`,
|
|
192
249
|
]).ok;
|
|
193
250
|
const added = existing
|
|
194
|
-
? git(checkout, ["worktree", "add", where, branch])
|
|
195
|
-
: git(checkout, ["worktree", "add", "-b", branch, where, base]);
|
|
251
|
+
? git(checkout, ["worktree", "add", "--", where, branch])
|
|
252
|
+
: git(checkout, ["worktree", "add", "-b", branch, "--", where, base]);
|
|
196
253
|
return added.ok
|
|
197
254
|
? { ok: true, path: where }
|
|
198
255
|
: {
|
|
@@ -216,19 +273,78 @@ export function commitLane(where, message) {
|
|
|
216
273
|
return git(where, ["rev-parse", "HEAD"]).out || null;
|
|
217
274
|
}
|
|
218
275
|
|
|
276
|
+
/** The commit at a lane, including commits an agent made itself before returning. */
|
|
277
|
+
export function laneHead(where) {
|
|
278
|
+
if (!where || !fs.existsSync(where)) return null;
|
|
279
|
+
const head = git(where, ["rev-parse", "HEAD"]);
|
|
280
|
+
return head.ok && validSha(head.out) ? head.out : null;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export function containsCommit(where, ancestor, head) {
|
|
284
|
+
return Boolean(
|
|
285
|
+
where &&
|
|
286
|
+
validSha(ancestor) &&
|
|
287
|
+
validSha(head) &&
|
|
288
|
+
git(where, ["merge-base", "--is-ancestor", ancestor, head]).ok
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** Commits on top of the returned result, minus intervals owned by another recorded agent run. */
|
|
293
|
+
export function personChanges(where, returned, runs) {
|
|
294
|
+
const head = laneHead(where);
|
|
295
|
+
if (!containsCommit(where, returned, head) || returned === head) return [];
|
|
296
|
+
const after = git(where, ["rev-list", `${returned}..${head}`]);
|
|
297
|
+
if (!after.ok) return [];
|
|
298
|
+
const agentCommits = new Set();
|
|
299
|
+
for (const run of runs) {
|
|
300
|
+
const span = run.returned;
|
|
301
|
+
if (
|
|
302
|
+
!span?.start ||
|
|
303
|
+
!span.commit ||
|
|
304
|
+
!containsCommit(where, span.start, span.commit)
|
|
305
|
+
)
|
|
306
|
+
continue;
|
|
307
|
+
const owned = git(where, ["rev-list", `${span.start}..${span.commit}`]);
|
|
308
|
+
if (owned.ok)
|
|
309
|
+
for (const sha of owned.out.split("\n")) agentCommits.add(sha);
|
|
310
|
+
}
|
|
311
|
+
const files = new Set();
|
|
312
|
+
for (const sha of after.out.split("\n").filter(Boolean)) {
|
|
313
|
+
if (agentCommits.has(sha)) continue;
|
|
314
|
+
const read = git(where, [
|
|
315
|
+
"diff-tree",
|
|
316
|
+
"--no-commit-id",
|
|
317
|
+
"--name-only",
|
|
318
|
+
"-r",
|
|
319
|
+
sha,
|
|
320
|
+
]);
|
|
321
|
+
if (read.ok)
|
|
322
|
+
for (const file of read.out.split("\n").filter(Boolean)) files.add(file);
|
|
323
|
+
}
|
|
324
|
+
return [...files];
|
|
325
|
+
}
|
|
326
|
+
|
|
219
327
|
/** The files a lane changed since it was made from canon. */
|
|
220
328
|
export function changedFiles(where, base) {
|
|
221
329
|
if (!fs.existsSync(where) || !validSha(base)) return [];
|
|
222
|
-
const listed = git(where, [
|
|
330
|
+
const listed = git(where, [
|
|
331
|
+
"diff",
|
|
332
|
+
"--name-only",
|
|
333
|
+
"--end-of-options",
|
|
334
|
+
`${base}..HEAD`,
|
|
335
|
+
]);
|
|
223
336
|
return listed.ok ? listed.out.split("\n").filter(Boolean).slice(0, 200) : [];
|
|
224
337
|
}
|
|
225
338
|
|
|
226
339
|
/** Sends the lane's branch to the shared remote. */
|
|
227
340
|
export async function pushLane(where, branch) {
|
|
341
|
+
if (!validBranch(branch))
|
|
342
|
+
return { ok: false, error: "not a branch name git can push" };
|
|
228
343
|
const pushed = await gitLater(where, [
|
|
229
344
|
"push",
|
|
230
345
|
"--quiet",
|
|
231
346
|
"-u",
|
|
347
|
+
"--",
|
|
232
348
|
"origin",
|
|
233
349
|
branch,
|
|
234
350
|
]);
|
|
@@ -238,7 +354,7 @@ export async function pushLane(where, branch) {
|
|
|
238
354
|
}
|
|
239
355
|
|
|
240
356
|
export function removeLane(checkout, where) {
|
|
241
|
-
git(checkout, ["worktree", "remove", "--force", where]);
|
|
357
|
+
git(checkout, ["worktree", "remove", "--force", "--", where]);
|
|
242
358
|
git(checkout, ["worktree", "prune"]);
|
|
243
359
|
}
|
|
244
360
|
|
|
@@ -264,6 +380,8 @@ function gh(cwd, args) {
|
|
|
264
380
|
|
|
265
381
|
/** Opens a pull request from the lane's branch into canon; its number and address. */
|
|
266
382
|
export async function openPullRequest(where, { branch, canon, title, body }) {
|
|
383
|
+
if (!validBranch(branch) || !validBranch(canon))
|
|
384
|
+
return { ok: false, error: "not a branch name GitHub takes" };
|
|
267
385
|
const made = await gh(where, [
|
|
268
386
|
"pr",
|
|
269
387
|
"create",
|
|
@@ -296,7 +414,7 @@ export async function pullRequestState(where, number) {
|
|
|
296
414
|
"view",
|
|
297
415
|
String(number),
|
|
298
416
|
"--json",
|
|
299
|
-
"state,url,statusCheckRollup",
|
|
417
|
+
"state,url,statusCheckRollup,reviewDecision,reviews",
|
|
300
418
|
]);
|
|
301
419
|
if (!read.ok) return null;
|
|
302
420
|
try {
|
|
@@ -311,8 +429,34 @@ export async function pullRequestState(where, number) {
|
|
|
311
429
|
const pending = checks.some((check) =>
|
|
312
430
|
["PENDING", "QUEUED", "IN_PROGRESS", "EXPECTED"].includes(outcome(check))
|
|
313
431
|
);
|
|
432
|
+
const verdictStates = ["APPROVED", "CHANGES_REQUESTED"];
|
|
433
|
+
const reviews = pr.reviews ?? [];
|
|
434
|
+
const latestByPerson = new Map(
|
|
435
|
+
reviews.map((review) => [review.author?.login, review])
|
|
436
|
+
);
|
|
437
|
+
const current = reviews.filter(
|
|
438
|
+
(review) =>
|
|
439
|
+
latestByPerson.get(review.author?.login) === review &&
|
|
440
|
+
verdictStates.includes(review.state)
|
|
441
|
+
);
|
|
442
|
+
const review = current.findLast((review) =>
|
|
443
|
+
verdictStates.includes(pr.reviewDecision)
|
|
444
|
+
? review.state === pr.reviewDecision
|
|
445
|
+
: true
|
|
446
|
+
);
|
|
314
447
|
return {
|
|
315
448
|
state: String(pr.state || "").toLowerCase(),
|
|
449
|
+
reviewDecision: pr.reviewDecision || review?.state || null,
|
|
450
|
+
review: review
|
|
451
|
+
? {
|
|
452
|
+
id: review.id,
|
|
453
|
+
state: review.state,
|
|
454
|
+
body: review.body ?? "",
|
|
455
|
+
at: review.submittedAt ?? null,
|
|
456
|
+
by: review.author?.login ?? null,
|
|
457
|
+
commit: review.commit?.oid ?? null,
|
|
458
|
+
}
|
|
459
|
+
: null,
|
|
316
460
|
url: pr.url ?? null,
|
|
317
461
|
checks: !checks.length
|
|
318
462
|
? "none"
|