@mrciphersmith/keryx 0.4.59 → 0.4.61
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/cli.js +480 -253
- package/dist/keryx-general-worker-entry.js +51 -4
- package/package.json +1 -1
- package/src/gdskills/bundled/skills/review/review-architecture/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/review/review-backend/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/review/review-clean-code/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/review/review-core-boundaries/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/review/review-flow-graph/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/review/review-frontend/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/review/review-frontend-conventions/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/review/review-highload/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/review/review-logic/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/review/review-orchestrator/SKILL.md +5 -5
- package/src/gdskills/bundled/skills/review/review-performance/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/review/review-premise/SKILL.md +2 -2
- package/src/gdskills/bundled/skills/review/review-security-code/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/review/review-style/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/review/review-testing-practices/SKILL.md +1 -1
package/dist/cli.js
CHANGED
|
@@ -38567,7 +38567,7 @@ var package_default;
|
|
|
38567
38567
|
var init_package = __esm(() => {
|
|
38568
38568
|
package_default = {
|
|
38569
38569
|
name: "@mrciphersmith/keryx",
|
|
38570
|
-
version: "0.4.
|
|
38570
|
+
version: "0.4.61",
|
|
38571
38571
|
description: "Version-controlled project context for AI coding agents: code graph, architecture wiki, project memory, relevant tests, quality signals, and task flows.",
|
|
38572
38572
|
private: false,
|
|
38573
38573
|
publishConfig: {
|
|
@@ -56968,6 +56968,10 @@ function mergePremises(findings, parsedInput) {
|
|
|
56968
56968
|
reject("challenged-without-evidence", "`challenged` needs at least one intent signal (a cited ref) or practice source (a named guideline). A challenge with neither is the reviewer's argument turned around.");
|
|
56969
56969
|
continue;
|
|
56970
56970
|
}
|
|
56971
|
+
if (verdict === "owner-decision" && (signals.value?.length ?? 0) + (sources.value?.length ?? 0) === 0) {
|
|
56972
|
+
reject("owner-decision-without-evidence", "`owner-decision` needs at least one intent signal (a cited ref: the PR body, a code line, a commit) or practice source (a named rule) showing the choice is the owner's. Without one the finding goes on as reported: use `upheld`.");
|
|
56973
|
+
continue;
|
|
56974
|
+
}
|
|
56971
56975
|
if (!present3(claim.question)) {
|
|
56972
56976
|
reject("held-without-question", `\`${verdict}\` holds the finding for the operator, who needs a question to answer.`);
|
|
56973
56977
|
continue;
|
|
@@ -78254,6 +78258,33 @@ var init_active_review = __esm(() => {
|
|
|
78254
78258
|
ACTIVE_REVIEW_DIR = path171.join(".metaproject", "data", "review-active");
|
|
78255
78259
|
});
|
|
78256
78260
|
|
|
78261
|
+
// src/review/machine-fences.ts
|
|
78262
|
+
function stripMachineFences(text) {
|
|
78263
|
+
let rest = text;
|
|
78264
|
+
let out = "";
|
|
78265
|
+
for (;; ) {
|
|
78266
|
+
const open = OPENING.exec(rest);
|
|
78267
|
+
if (open === null)
|
|
78268
|
+
break;
|
|
78269
|
+
const marker = open[1] ?? "```";
|
|
78270
|
+
const char = marker.startsWith("~") ? "~" : "`";
|
|
78271
|
+
const afterOpen = open.index + open[0].length;
|
|
78272
|
+
const tail = rest.slice(afterOpen);
|
|
78273
|
+
const closing = new RegExp(`^ {0,3}\\${char}{${marker.length},}[ \\t]*$`, "m").exec(tail.replace(/^\r?\n/, ""));
|
|
78274
|
+
const skipped = tail.length - tail.replace(/^\r?\n/, "").length;
|
|
78275
|
+
const end = closing === null ? rest.length : afterOpen + skipped + closing.index + closing[0].length;
|
|
78276
|
+
out += rest.slice(0, open.index);
|
|
78277
|
+
rest = rest.slice(end);
|
|
78278
|
+
}
|
|
78279
|
+
return (out + rest).replace(/\n{3,}/g, `
|
|
78280
|
+
|
|
78281
|
+
`);
|
|
78282
|
+
}
|
|
78283
|
+
var OPENING;
|
|
78284
|
+
var init_machine_fences = __esm(() => {
|
|
78285
|
+
OPENING = /^ {0,3}(`{3,}|~{3,})[^\n`]*\bkeryx:[\w-]+\b[^\n]*$/m;
|
|
78286
|
+
});
|
|
78287
|
+
|
|
78257
78288
|
// src/review/report-overlay.ts
|
|
78258
78289
|
import { lstat as lstat14, readdir as readdir29, readFile as readFile88, realpath as realpath22 } from "fs/promises";
|
|
78259
78290
|
import { createHash as createHash60 } from "crypto";
|
|
@@ -78436,12 +78467,13 @@ ${end}`;
|
|
|
78436
78467
|
` + metadata;
|
|
78437
78468
|
}
|
|
78438
78469
|
function publicProjectReport(report) {
|
|
78439
|
-
return report.replace(slotsFence, "").replace(savedSlotMarker, "").trim();
|
|
78470
|
+
return stripMachineFences(report.replace(slotsFence, "").replace(savedSlotMarker, "")).trim();
|
|
78440
78471
|
}
|
|
78441
78472
|
var text4 = (value) => typeof value === "string" ? value.trim() : "", object3 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : undefined, overlayPath = ".metaproject/review-publish-template.md", placeholder = "{{review}}", projectSkills = ".metaproject/project-skills/orchestration", baseTemplate = ".metaproject/skills/gdskills/review/review-orchestrator/templates/review-report.md", slotNames, DESK_TEMPLATE_SELECTION = "publication-template.json", VANTAGE_CHECKS, slotsFence, savedSlotMarker;
|
|
78442
78473
|
var init_report_overlay = __esm(() => {
|
|
78443
78474
|
init_fs();
|
|
78444
78475
|
init_git_worktrees();
|
|
78476
|
+
init_machine_fences();
|
|
78445
78477
|
slotNames = ["pre-verdict", "after-verdict", "verified-clean", "how-run"];
|
|
78446
78478
|
VANTAGE_CHECKS = [
|
|
78447
78479
|
"Owner intent",
|
|
@@ -80486,6 +80518,8 @@ function withSpendSection(report, research) {
|
|
|
80486
80518
|
const section = `${SPEND_HEADING}
|
|
80487
80519
|
|
|
80488
80520
|
${usageTotalsLine(totals)}
|
|
80521
|
+
|
|
80522
|
+
${SPEND_SCOPE_NOTE}
|
|
80489
80523
|
`;
|
|
80490
80524
|
const lines = report.split(`
|
|
80491
80525
|
`);
|
|
@@ -80503,7 +80537,7 @@ ${section}${next === -1 ? "" : `
|
|
|
80503
80537
|
${lines.slice(next).join(`
|
|
80504
80538
|
`)}`}`;
|
|
80505
80539
|
}
|
|
80506
|
-
var USAGE_MARKER = "KERYX_USAGE", OTHER_USAGE_MARKER = "KERYX_USAGE_OTHER", NO_TEXT_PLACEHOLDER = "(subagent produced no text)", SPEND_HEADING = "## Token spend", HOST_MARK = "host", MAX_DISPATCH_TOKENS = 1e8, USAGE_LINE, MAX_USAGE_LINE_CHARS = 4096, toTokenCount = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= MAX_DISPATCH_TOKENS ? Math.round(value) : undefined, isObject2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
80540
|
+
var USAGE_MARKER = "KERYX_USAGE", OTHER_USAGE_MARKER = "KERYX_USAGE_OTHER", NO_TEXT_PLACEHOLDER = "(subagent produced no text)", SPEND_HEADING = "## Token spend", SPEND_SCOPE_NOTE = "_Reviewer dispatches only: the orchestrating session's own tokens are not counted._", HOST_MARK = "host", MAX_DISPATCH_TOKENS = 1e8, USAGE_LINE, MAX_USAGE_LINE_CHARS = 4096, toTokenCount = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= MAX_DISPATCH_TOKENS ? Math.round(value) : undefined, isObject2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
80507
80541
|
var init_dispatch_usage = __esm(() => {
|
|
80508
80542
|
USAGE_LINE = /^[ \t]*KERYX_USAGE(_OTHER)?[ \t]+(.*?)\r?$/;
|
|
80509
80543
|
});
|
|
@@ -81221,7 +81255,7 @@ function parseReviewResult(reply) {
|
|
|
81221
81255
|
const raw = splitUsage(reply).body;
|
|
81222
81256
|
const labelled = labelledFence(raw);
|
|
81223
81257
|
if (labelled !== undefined)
|
|
81224
|
-
return labelled.result ?? lenientReviewResult(raw.slice(labelled.at));
|
|
81258
|
+
return labelled.result ?? lenientReviewResult(raw.slice(labelled.at)) ?? statusLineResult(raw);
|
|
81225
81259
|
const marked = afterMarker(raw)?.result;
|
|
81226
81260
|
if (marked !== undefined)
|
|
81227
81261
|
return marked;
|
|
@@ -81233,7 +81267,43 @@ function parseReviewResult(reply) {
|
|
|
81233
81267
|
const strict = scannedResult(raw);
|
|
81234
81268
|
if (strict !== undefined)
|
|
81235
81269
|
return strict;
|
|
81236
|
-
return lenientReviewResult(raw);
|
|
81270
|
+
return lenientReviewResult(raw) ?? statusLineResult(raw);
|
|
81271
|
+
}
|
|
81272
|
+
function lacksOnlyStatus(value) {
|
|
81273
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
81274
|
+
return false;
|
|
81275
|
+
const object = value;
|
|
81276
|
+
return object.status === undefined && (typeof object.reviewer === "string" || Array.isArray(object.findings));
|
|
81277
|
+
}
|
|
81278
|
+
function statusLineResult(raw) {
|
|
81279
|
+
const inFence = fenceTester(raw);
|
|
81280
|
+
const statuses = new Set([...raw.matchAll(STATUS_LINE)].filter((line) => !inFence(line.index)).map((line) => line[1]));
|
|
81281
|
+
if (statuses.size !== 1)
|
|
81282
|
+
return;
|
|
81283
|
+
const status = [...statuses][0];
|
|
81284
|
+
const withStatus = (value) => ({ ...value, status });
|
|
81285
|
+
const labelled = [...raw.matchAll(/```REVIEW_RESULT[ \t]*\r?\n([\s\S]*?)```/gi)];
|
|
81286
|
+
if (labelled.length > 0) {
|
|
81287
|
+
const parsed = tryParse2(labelled[labelled.length - 1][1]);
|
|
81288
|
+
return lacksOnlyStatus(parsed) ? withStatus(parsed) : undefined;
|
|
81289
|
+
}
|
|
81290
|
+
const markers = [...raw.matchAll(MARKER)].filter((marker) => !inFence(marker.index)).slice(-MAX_MARKERS);
|
|
81291
|
+
for (let at = markers.length - 1;at >= 0; at -= 1) {
|
|
81292
|
+
const start = markers[at].index + markers[at][0].length;
|
|
81293
|
+
const { end } = objectEnd(raw, start);
|
|
81294
|
+
if (end === undefined)
|
|
81295
|
+
continue;
|
|
81296
|
+
const parsed = tryParse2(raw.slice(start, end + 1));
|
|
81297
|
+
if (lacksOnlyStatus(parsed))
|
|
81298
|
+
return withStatus(parsed);
|
|
81299
|
+
}
|
|
81300
|
+
const { found, truncated } = topLevelObjects(raw);
|
|
81301
|
+
if (truncated)
|
|
81302
|
+
return;
|
|
81303
|
+
const shaped = found.filter(({ value }) => lacksOnlyStatus(value));
|
|
81304
|
+
const fenced = shaped.filter(({ start }) => inFence(start));
|
|
81305
|
+
const chosen = (fenced.length > 0 ? fenced : shaped).at(-1)?.value;
|
|
81306
|
+
return lacksOnlyStatus(chosen) ? withStatus(chosen) : undefined;
|
|
81237
81307
|
}
|
|
81238
81308
|
function explainUnparsedResult(raw) {
|
|
81239
81309
|
return describeUnusableResult(raw);
|
|
@@ -81621,7 +81691,7 @@ async function ledgerBlockers(ledger, canonical, options) {
|
|
|
81621
81691
|
const coverage = await packageCoverageErrors(options.packageDir, ledger.dispatch);
|
|
81622
81692
|
return [...researchErrors(ledger, canonical), ...coverage, ...await coverageGateErrors(options.packageDir, ledger)];
|
|
81623
81693
|
}
|
|
81624
|
-
var FINISHED, CLOSED, CLAIM_QUOTE_CHARS = 120, sha = (value) => createHash64("sha256").update(value).digest("hex").slice(0, 12), text5 = (v) => typeof v === "string" && v.trim().length > 0, namesObligation = (key, oid) => key === oid || typeof key === "string" && key.endsWith(`#${oid}`), holdsKey = (finding, key) => finding.id === key || finding.global_id === key, mergedFromHas = (finding, id) => Array.isArray(finding.merged_from) && finding.merged_from.some((entry) => namesObligation(entry, id)), OBJECT_START, RESULT_KEYS, KEY_COLON, MAX_UNCLOSED = 64, FENCE_OPEN, FENCE_CLOSE, LINE_CLOSE, MAX_MARKERS = 64, MARKER, PARENT_FOLLOW_UP, sliceIdsOf = (value) => readSliceIds(value).ids, AUDIT_ROLES, DISPOSITION_WRAPPER_KEYS, DISPOSITION_SCHEMA = `{"id":"<raw stem>:<Fn>","status":"finding|refuted|out-of-scope|narrowed","evidence":\u2026,"reason":\u2026,"finding":\u2026 (status finding; optional: defaults to the canonical finding whose id is the row's id, or the one the raw finding resolves to),"remains":\u2026 (status narrowed)}`;
|
|
81694
|
+
var FINISHED, CLOSED, CLAIM_QUOTE_CHARS = 120, sha = (value) => createHash64("sha256").update(value).digest("hex").slice(0, 12), text5 = (v) => typeof v === "string" && v.trim().length > 0, namesObligation = (key, oid) => key === oid || typeof key === "string" && key.endsWith(`#${oid}`), holdsKey = (finding, key) => finding.id === key || finding.global_id === key, mergedFromHas = (finding, id) => Array.isArray(finding.merged_from) && finding.merged_from.some((entry) => namesObligation(entry, id)), OBJECT_START, RESULT_KEYS, KEY_COLON, MAX_UNCLOSED = 64, FENCE_OPEN, FENCE_CLOSE, LINE_CLOSE, MAX_MARKERS = 64, MARKER, RESULT_STATUSES, STATUS_LINE, PARENT_FOLLOW_UP, sliceIdsOf = (value) => readSliceIds(value).ids, AUDIT_ROLES, DISPOSITION_WRAPPER_KEYS, DISPOSITION_SCHEMA = `{"id":"<raw stem>:<Fn>","status":"finding|refuted|out-of-scope|narrowed","evidence":\u2026,"reason":\u2026,"finding":\u2026 (status finding; optional: defaults to the canonical finding whose id is the row's id, or the one the raw finding resolves to),"remains":\u2026 (status narrowed)}`;
|
|
81625
81695
|
var init_ledger = __esm(() => {
|
|
81626
81696
|
init_coverage();
|
|
81627
81697
|
init_coverage_complete();
|
|
@@ -81643,6 +81713,8 @@ var init_ledger = __esm(() => {
|
|
|
81643
81713
|
FENCE_CLOSE = /^ {0,3}(`{3,})[ \t]*$/;
|
|
81644
81714
|
LINE_CLOSE = /^ {0,3}```[ \t]*\r?$/gm;
|
|
81645
81715
|
MARKER = /(?<![^\n])[ \t>*#-]*REVIEW_RESULT(?:[ \t]*[:=])?\s*(?=\{)/g;
|
|
81716
|
+
RESULT_STATUSES = ["DONE_WITH_CONCERNS", "DONE", "NEEDS_CONTEXT", "BLOCKED"];
|
|
81717
|
+
STATUS_LINE = new RegExp(`(?<![^\\n])[ \\t>*_#-]*STATUS[*_]*:[*_ \\t]*(${RESULT_STATUSES.join("|")})\\b`, "g");
|
|
81646
81718
|
PARENT_FOLLOW_UP = /^[ \t>*_-]*Parent follow-up[ \t]*\**:\**[ \t]*(.*\S)[ \t]*$/i;
|
|
81647
81719
|
AUDIT_ROLES = new Set(DEEP_ROLES.filter((role) => role !== ALWAYS_ROLE));
|
|
81648
81720
|
DISPOSITION_WRAPPER_KEYS = ["dispositions", "items", "results", "data", "entries", "obligations"];
|
|
@@ -88759,6 +88831,9 @@ function reviewPackagePaths(text) {
|
|
|
88759
88831
|
floor = end;
|
|
88760
88832
|
}
|
|
88761
88833
|
}
|
|
88834
|
+
function continuesReview(invocation) {
|
|
88835
|
+
return !LOOKUP_SUBCOMMANDS.has(invocation.subcommand) && !invocation.args.some((arg) => arg === "--help" || arg === "-h");
|
|
88836
|
+
}
|
|
88762
88837
|
function endWord(state) {
|
|
88763
88838
|
if (state.inWord) {
|
|
88764
88839
|
if (state.dropNext)
|
|
@@ -89045,7 +89120,8 @@ class SessionReviewTracker {
|
|
|
89045
89120
|
continue;
|
|
89046
89121
|
const cwd = path198.resolve(this.cwd);
|
|
89047
89122
|
for (const invocation of keryxReviewInvocations(command, cwd)) {
|
|
89048
|
-
|
|
89123
|
+
if (continuesReview(invocation))
|
|
89124
|
+
this.runSeen = true;
|
|
89049
89125
|
if (invocation.cwd !== cwd && inside2(cwd, invocation.cwd))
|
|
89050
89126
|
remember(this.roots, invocation.cwd, MAX_SESSION_REVIEW_ROOTS);
|
|
89051
89127
|
for (const arg of invocation.args)
|
|
@@ -89258,7 +89334,7 @@ ${describeBlockers(open, card)}
|
|
|
89258
89334
|
` + "Do the next missing step now. Step 1 (Build Review Context Pack) has no CLI command; it is a prose step, so mark it done and move on. " + "A command that is refused is not a blocker: run `keryx review --help` for the accepted usage and retry with the right flags. " + "A routing refusal is the exception: when `keryx review tier` reports `dispatchable: false`, the operator's routing configuration refuses the reviewer model and no retry changes that, so report it as the one real blocker with the `routing:` lines it printed. " + "A plan item you marked blocked for such a reason is not blocked: mark it in_progress. " + "A tool loop guard or an empty child result is not a reason to ask the operator to resend the request or to continue: change the arguments, retry the failed pass on a smaller slice, and keep going. " + `Stop only after ${card ? "the `review_complete` card has" : "`keryx review complete` has"} closed the package, or report the one real blocker with its evidence.`
|
|
89259
89335
|
};
|
|
89260
89336
|
}
|
|
89261
|
-
var MAX_REVIEW_GATE_CONTINUES = 20, MAX_REVIEW_GATE_STALLS = 3, MAX_HASHED_FILES = 4096, SIGNATURE_WALKS_PER_STOP = 2, MAX_SIGNATURE_FILES, RACY_WINDOW_MS = 2000, fileHashes, fileReads = 0, MAX_CONTENT_HASH_BYTES, ReviewGateAbortedError, TRUNCATION_MARKER = "\u2026truncated", byName = (a, b) => a < b ? -1 : a > b ? 1 : 0, METAPROJECT = ".metaproject", REVIEWS = "reviews", PREFIX_DELIMITERS, MAX_PREFIX_CHARS = 1024, MAX_NAME_CHARS = 255, MAX_SESSION_REVIEW_ROOTS = 8, MAX_SESSION_REVIEW_DIRS = 32, MAX_SESSION_REVIEW_IDS = 32, MAX_PENDING_CALLS = 64, SAFE_REVIEW_ID, isPathDelimiter = (ch) => PREFIX_DELIMITERS.has(ch) || /\s/.test(ch), isSeparator = (ch) => ch === "/" || ch === "\\", OPENING_SUBCOMMANDS, PACKAGE_ARG_SUBCOMMANDS, VALUELESS_FLAGS, OWN_OUTPUT_LINE, KERYX_PACKAGE, PIPE_FILTERS, NO_VALUE_OPTIONS, HEAD_TAIL_VALUE_OPTIONS, GREP_VALUE_OPTIONS, READER_VALUE_OPTIONS, GREP_PATTERN_OPTIONS, GREP_TREE_OPTION, KERYX_PACKAGE_NAMES, nextIs = (line, at, chars) => at + 1 < line.length && chars.includes(line[at + 1]), baseName2 = (word) => path198.posix.basename(word.replace(/\\/g, "/")), trackers, SCAN_CONCURRENCY = 16, NO_PACKAGE_BLOCKER = "no review package this session opened or named: `keryx review start` has not opened one, and no `keryx review` command in this session names an open package by its path or review id", MAX_NUDGE_BLOCKERS = 20, MAX_NUDGE_BLOCKER_CHARS = 300;
|
|
89337
|
+
var MAX_REVIEW_GATE_CONTINUES = 20, MAX_REVIEW_GATE_STALLS = 3, MAX_HASHED_FILES = 4096, SIGNATURE_WALKS_PER_STOP = 2, MAX_SIGNATURE_FILES, RACY_WINDOW_MS = 2000, fileHashes, fileReads = 0, MAX_CONTENT_HASH_BYTES, ReviewGateAbortedError, TRUNCATION_MARKER = "\u2026truncated", byName = (a, b) => a < b ? -1 : a > b ? 1 : 0, METAPROJECT = ".metaproject", REVIEWS = "reviews", PREFIX_DELIMITERS, MAX_PREFIX_CHARS = 1024, MAX_NAME_CHARS = 255, MAX_SESSION_REVIEW_ROOTS = 8, MAX_SESSION_REVIEW_DIRS = 32, MAX_SESSION_REVIEW_IDS = 32, MAX_PENDING_CALLS = 64, SAFE_REVIEW_ID, isPathDelimiter = (ch) => PREFIX_DELIMITERS.has(ch) || /\s/.test(ch), isSeparator = (ch) => ch === "/" || ch === "\\", LOOKUP_SUBCOMMANDS, OPENING_SUBCOMMANDS, PACKAGE_ARG_SUBCOMMANDS, VALUELESS_FLAGS, OWN_OUTPUT_LINE, KERYX_PACKAGE, PIPE_FILTERS, NO_VALUE_OPTIONS, HEAD_TAIL_VALUE_OPTIONS, GREP_VALUE_OPTIONS, READER_VALUE_OPTIONS, GREP_PATTERN_OPTIONS, GREP_TREE_OPTION, KERYX_PACKAGE_NAMES, nextIs = (line, at, chars) => at + 1 < line.length && chars.includes(line[at + 1]), baseName2 = (word) => path198.posix.basename(word.replace(/\\/g, "/")), trackers, SCAN_CONCURRENCY = 16, NO_PACKAGE_BLOCKER = "no review package this session opened or named: `keryx review start` has not opened one, and no `keryx review` command in this session names an open package by its path or review id", MAX_NUDGE_BLOCKERS = 20, MAX_NUDGE_BLOCKER_CHARS = 300;
|
|
89262
89338
|
var init_completion_gate = __esm(() => {
|
|
89263
89339
|
init_active_review();
|
|
89264
89340
|
init_managed();
|
|
@@ -89276,6 +89352,7 @@ var init_completion_gate = __esm(() => {
|
|
|
89276
89352
|
};
|
|
89277
89353
|
PREFIX_DELIMITERS = new Set([..."\"'`<>|;&()="]);
|
|
89278
89354
|
SAFE_REVIEW_ID = /^[A-Za-z0-9._:-]{1,120}$/;
|
|
89355
|
+
LOOKUP_SUBCOMMANDS = new Set(["", "pr-context", "board", "reviews", "accounts", "help", "--help", "-h"]);
|
|
89279
89356
|
OPENING_SUBCOMMANDS = new Set(["start", "attach", "ingest"]);
|
|
89280
89357
|
PACKAGE_ARG_SUBCOMMANDS = new Set(["status", "readiness", "complete", "attach", "publish", "verdict", "show"]);
|
|
89281
89358
|
VALUELESS_FLAGS = new Set([
|
|
@@ -103039,7 +103116,7 @@ function auditorBody(pack) {
|
|
|
103039
103116
|
"",
|
|
103040
103117
|
"Findings section, ordered by severity: file path and line, which audit-focus pattern it matches, and a specific remediation. Note anything checked and found clean.",
|
|
103041
103118
|
"",
|
|
103042
|
-
`${
|
|
103119
|
+
`${STATUS_LINE2} Use \`DONE_WITH_CONCERNS\` when findings exist; \`BLOCKED\` only when the scope could not be read.`,
|
|
103043
103120
|
""
|
|
103044
103121
|
].join(`
|
|
103045
103122
|
`);
|
|
@@ -103071,7 +103148,7 @@ function fixerBody(pack) {
|
|
|
103071
103148
|
"",
|
|
103072
103149
|
"Findings section: which command(s) were failing, the root cause, the fix applied, and the final re-run result for each command from step 1.",
|
|
103073
103150
|
"",
|
|
103074
|
-
`${
|
|
103151
|
+
`${STATUS_LINE2} Use \`DONE_WITH_CONCERNS\` when a fix landed but a related risk remains; \`BLOCKED\` when the failure could not be reproduced at all.`,
|
|
103075
103152
|
""
|
|
103076
103153
|
].join(`
|
|
103077
103154
|
`);
|
|
@@ -103125,7 +103202,7 @@ ${fixerBody(pack)}`
|
|
|
103125
103202
|
};
|
|
103126
103203
|
return { auditor, fixer };
|
|
103127
103204
|
}
|
|
103128
|
-
var AUDITOR_TOOLS, FIXER_TOOLS, IDENTIFIER_PATTERN, CONTROL_CHAR_PATTERN, InvalidStackPackFieldError,
|
|
103205
|
+
var AUDITOR_TOOLS, FIXER_TOOLS, IDENTIFIER_PATTERN, CONTROL_CHAR_PATTERN, InvalidStackPackFieldError, STATUS_LINE2 = "The reply's first line is `STATUS: DONE|DONE_WITH_CONCERNS|NEEDS_CONTEXT|BLOCKED` per the subagent-result contract.";
|
|
103129
103206
|
var init_generate = __esm(() => {
|
|
103130
103207
|
AUDITOR_TOOLS = ["read_file", "list_dir", "get_cwd", "search_code", "graph_affected", "memory_search"];
|
|
103131
103208
|
FIXER_TOOLS = ["read_file", "list_dir", "get_cwd", "search_code", "graph_affected", "apply_patch", "shell_exec"];
|
|
@@ -154958,6 +155035,47 @@ function mentionsFindingId(report, id) {
|
|
|
154958
155035
|
const escaped = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
154959
155036
|
return new RegExp(`(?<!${ID_CHAR})${escaped}(?!${ID_CHAR})`).test(report);
|
|
154960
155037
|
}
|
|
155038
|
+
function withoutHeldSections(report) {
|
|
155039
|
+
const lines = report.split(`
|
|
155040
|
+
`);
|
|
155041
|
+
const kept = [];
|
|
155042
|
+
let skipping = 0;
|
|
155043
|
+
for (const line of lines) {
|
|
155044
|
+
const heading = /^(#{1,6})[ \t]/.exec(line);
|
|
155045
|
+
if (skipping > 0 && heading !== null && heading[1].length <= skipping)
|
|
155046
|
+
skipping = 0;
|
|
155047
|
+
const held = HELD_HEADING.exec(line);
|
|
155048
|
+
if (held !== null) {
|
|
155049
|
+
skipping = held[1].length;
|
|
155050
|
+
continue;
|
|
155051
|
+
}
|
|
155052
|
+
if (skipping === 0)
|
|
155053
|
+
kept.push(line);
|
|
155054
|
+
}
|
|
155055
|
+
return kept.join(`
|
|
155056
|
+
`).replace(/\n{3,}/g, `
|
|
155057
|
+
|
|
155058
|
+
`);
|
|
155059
|
+
}
|
|
155060
|
+
function heldSection(held, decisions) {
|
|
155061
|
+
const latest = new Map;
|
|
155062
|
+
for (const decision of decisions)
|
|
155063
|
+
latest.set(decision.finding, decision);
|
|
155064
|
+
const parts = [];
|
|
155065
|
+
if (held.length > 0) {
|
|
155066
|
+
parts.push("### Held for a decision", "", ...held.map((finding) => `- **${finding.id}** (${finding.severity}): ${finding.problem}`), "");
|
|
155067
|
+
}
|
|
155068
|
+
if (latest.size > 0) {
|
|
155069
|
+
const shortId = (finding) => finding.slice(finding.lastIndexOf("#") + 1);
|
|
155070
|
+
parts.push("### Decided by the operator", "", ...[...latest.values()].map((decision) => `- **${shortId(decision.finding)}**: ${decision.answer === "dismiss" ? "dismissed" : "upheld"}${decision.reason.trim() ? ` (${oneLine8(decision.reason)})` : ""}`), "");
|
|
155071
|
+
}
|
|
155072
|
+
return parts.length === 0 ? "" : `
|
|
155073
|
+
${parts.join(`
|
|
155074
|
+
`)}`;
|
|
155075
|
+
}
|
|
155076
|
+
function oneLine8(text) {
|
|
155077
|
+
return text.replace(/\s+/g, " ").trim();
|
|
155078
|
+
}
|
|
154961
155079
|
function minorsLeftOut(count) {
|
|
154962
155080
|
return `- \u2026 ${count} more minor finding(s) \u2014 see verdict-interim.md / \`keryx review verdict\``;
|
|
154963
155081
|
}
|
|
@@ -155059,18 +155177,21 @@ async function publishReview(packageDir, options) {
|
|
|
155059
155177
|
if (partial && event === "APPROVE") {
|
|
155060
155178
|
throw new Error(`A partial review cannot approve: ${failing.length} readiness item(s) are failing (${failing.map((item) => item.id).join(", ")}). Use --event COMMENT or REQUEST_CHANGES, or repair the items.`);
|
|
155061
155179
|
}
|
|
155062
|
-
const
|
|
155180
|
+
const stored = await readFile160(path357.join(packageDir, "report.md"), "utf8").catch(() => "");
|
|
155181
|
+
const research = await readJsonFileOr(path357.join(packageDir, "research.json"), undefined);
|
|
155182
|
+
const report = withoutHeldSections(publicProjectReport(withSpendSection(stored, research)));
|
|
155063
155183
|
if (report === "")
|
|
155064
155184
|
throw new Error(`Review ${manifest.reviewId} has no report.md body to publish.`);
|
|
155065
155185
|
const movedLine = moved === undefined || firstLineSaysMoved(report, reviewedHead) ? "" : `${headMovedLine({ reviewedHead, currentHead: moved })}
|
|
155066
155186
|
|
|
155067
155187
|
`;
|
|
155188
|
+
const [verdict, { decisions }] = await Promise.all([computeVerdict(packageDir), premiseRecords(packageDir)]);
|
|
155068
155189
|
const head = `${movedLine}${partial ? `${partialPublishHeader(readiness).join(`
|
|
155069
155190
|
`)}
|
|
155070
155191
|
` : ""}${runModeHeader(packageDir)}${report}
|
|
155071
|
-
`;
|
|
155192
|
+
${heldSection(verdict.held, decisions)}`;
|
|
155072
155193
|
const foot = runModeFooter(packageDir);
|
|
155073
|
-
const minors = minorSection(
|
|
155194
|
+
const minors = minorSection(verdict.minors, report, PUBLISHED_BODY_LIMIT - head.length - foot.length - ROUND_BLOCK_LIMIT);
|
|
155074
155195
|
const visible = `${head}${minors}${foot}`;
|
|
155075
155196
|
const findings = await readJsonFileOr(path357.join(packageDir, "findings.json"), []);
|
|
155076
155197
|
const roundBlock = buildRoundBlock({ body: visible, round: readRoundNumber(packageDir) ?? 1, reviewId: manifest.reviewId, reviewedHead, findings: Array.isArray(findings) ? findings : [] });
|
|
@@ -155134,7 +155255,7 @@ ${marker}
|
|
|
155134
155255
|
const registered = recordFinishedRound(packageDir, "publish");
|
|
155135
155256
|
return { readiness, body, event, partial, posted: true, ...url === "" ? {} : { url }, ...registered.error === undefined ? {} : { registryWarning: `round not recorded in the local round registry: ${registered.error}` } };
|
|
155136
155257
|
}
|
|
155137
|
-
var REVIEW_EVENTS, FULL_SHA, sameCommit3 = (a, b) => a.toLowerCase() === b.toLowerCase(), PUBLISHED_BODY_LIMIT = 60000, ID_CHAR = "[A-Za-z0-9_-]", ROUND_BLOCK_LIMIT = 4000;
|
|
155258
|
+
var REVIEW_EVENTS, FULL_SHA, sameCommit3 = (a, b) => a.toLowerCase() === b.toLowerCase(), PUBLISHED_BODY_LIMIT = 60000, ID_CHAR = "[A-Za-z0-9_-]", HELD_HEADING, ROUND_BLOCK_LIMIT = 4000;
|
|
155138
155259
|
var init_publish = __esm(() => {
|
|
155139
155260
|
init_fs();
|
|
155140
155261
|
init_json();
|
|
@@ -155146,10 +155267,12 @@ var init_publish = __esm(() => {
|
|
|
155146
155267
|
init_round_record();
|
|
155147
155268
|
init_round_registry();
|
|
155148
155269
|
init_verdict();
|
|
155270
|
+
init_dispatch_usage();
|
|
155149
155271
|
init_readiness();
|
|
155150
155272
|
init_types();
|
|
155151
155273
|
REVIEW_EVENTS = ["COMMENT", "REQUEST_CHANGES", "APPROVE"];
|
|
155152
155274
|
FULL_SHA = /^[0-9a-f]{40}$/i;
|
|
155275
|
+
HELD_HEADING = /^(#{2,4})[ \t]+Held for\b/i;
|
|
155153
155276
|
});
|
|
155154
155277
|
|
|
155155
155278
|
// src/review/desk-publication.ts
|
|
@@ -156310,7 +156433,7 @@ async function projectGithubEnvironment(cwd, env = process.env) {
|
|
|
156310
156433
|
}
|
|
156311
156434
|
async function applyProjectGithubAccount(args, cwd = process.cwd(), env = process.env) {
|
|
156312
156435
|
const [command, sub] = args;
|
|
156313
|
-
if (!command || !GITHUB_COMMANDS.has(command) || command === "review" && sub === "accounts")
|
|
156436
|
+
if (!command || !GITHUB_COMMANDS.has(command) || command === "review" && (sub === "accounts" || sub === "state"))
|
|
156314
156437
|
return;
|
|
156315
156438
|
if (env.GH_TOKEN || env.GITHUB_TOKEN)
|
|
156316
156439
|
return;
|
|
@@ -165191,231 +165314,6 @@ var init_review_entity = __esm(() => {
|
|
|
165191
165314
|
FINISHED2 = new Set(["completed", "partial", "budget"]);
|
|
165192
165315
|
});
|
|
165193
165316
|
|
|
165194
|
-
// src/commands/review-reviews.ts
|
|
165195
|
-
import { parseArgs as parseArgs11 } from "util";
|
|
165196
|
-
async function readReviews({ repo, repositories, query, compare, root = deskRunRoot(), compareBudgetMs = REVIEW_COMPARE_BUDGET_MS, includeClosed = false }) {
|
|
165197
|
-
const [owner, name] = repo.split("/");
|
|
165198
|
-
const identity = await query(identityQuery, { owner, name });
|
|
165199
|
-
const viewer = identity.viewer?.login;
|
|
165200
|
-
const repositoryId = identity.repository?.id;
|
|
165201
|
-
if (!viewer || !repositoryId)
|
|
165202
|
-
throw new Error("access: GitHub repository or account is unavailable.");
|
|
165203
|
-
const snapshot = { version: 1, repo, repositories, repositoryId, viewer, fetchedAt: new Date().toISOString(), reviews: [], warnings: [] };
|
|
165204
|
-
const rows = readReviewRows(repositoryId, viewer, root).map((row) => ({ row, at: latestActivity(row) })).sort((a, b) => b.at.localeCompare(a.at) || b.row.number - a.row.number).map(({ row }) => row);
|
|
165205
|
-
if (!rows.length)
|
|
165206
|
-
return snapshot;
|
|
165207
|
-
const cards = await readCards(snapshot, includeClosed ? rows : rows.filter((row) => row.closedAt === null), query);
|
|
165208
|
-
const behind = rows.flatMap((row) => {
|
|
165209
|
-
const pair = headComparison(row, cards.get(row.number) ?? null);
|
|
165210
|
-
return pair && OBJECT_ID.test(pair.reviewed) && OBJECT_ID.test(pair.head) ? [{ id: row.id, ...pair }] : [];
|
|
165211
|
-
});
|
|
165212
|
-
if (behind.length > MAX_REVIEW_COMPARES)
|
|
165213
|
-
snapshot.warnings.push(`Commit counts are shown for ${MAX_REVIEW_COMPARES} Reviews behind their pull request. Refresh to read more.`);
|
|
165214
|
-
const comparisons = await compareHeads(behind.slice(0, MAX_REVIEW_COMPARES), compare, compareBudgetMs, snapshot.warnings);
|
|
165215
|
-
snapshot.reviews = rows.map((row) => summarizeReview(row, cards.get(row.number) ?? null, comparisons.get(row.id)));
|
|
165216
|
-
return snapshot;
|
|
165217
|
-
}
|
|
165218
|
-
async function readCards(snapshot, rows, query) {
|
|
165219
|
-
const numbers = [...new Set(rows.map((row) => row.number))];
|
|
165220
|
-
const batches = Array.from({ length: Math.ceil(numbers.length / CARD_BATCH) }, (_, i) => numbers.slice(i * CARD_BATCH, (i + 1) * CARD_BATCH));
|
|
165221
|
-
let unreadable = false;
|
|
165222
|
-
const read = await mapPool(batches, CARD_PARALLEL, async (batch) => {
|
|
165223
|
-
try {
|
|
165224
|
-
return await listActiveReviewCards(snapshot, batch, query);
|
|
165225
|
-
} catch (error) {
|
|
165226
|
-
if (cannotRetainData2(error))
|
|
165227
|
-
throw error;
|
|
165228
|
-
unreadable = true;
|
|
165229
|
-
return [];
|
|
165230
|
-
}
|
|
165231
|
-
}, { stopOnError: true });
|
|
165232
|
-
if (unreadable)
|
|
165233
|
-
snapshot.warnings.push("Some pull requests could not be loaded. Refresh to retry.");
|
|
165234
|
-
return new Map(read.flat().map((card) => [card.number, card]));
|
|
165235
|
-
}
|
|
165236
|
-
async function compareHeads(pairs, compare, budgetMs, warnings) {
|
|
165237
|
-
const deadline = Date.now() + budgetMs;
|
|
165238
|
-
let failed = false;
|
|
165239
|
-
let late = false;
|
|
165240
|
-
const compared = await mapPool(pairs, COMPARE_PARALLEL, async ({ id, reviewed, head }) => {
|
|
165241
|
-
const left = deadline - Date.now();
|
|
165242
|
-
if (left <= 0) {
|
|
165243
|
-
late = true;
|
|
165244
|
-
return null;
|
|
165245
|
-
}
|
|
165246
|
-
let timer;
|
|
165247
|
-
const expired = new Promise((resolve) => {
|
|
165248
|
-
timer = setTimeout(() => resolve("late"), left);
|
|
165249
|
-
});
|
|
165250
|
-
try {
|
|
165251
|
-
const result = await Promise.race([compare(reviewed, head), expired]);
|
|
165252
|
-
if (result === "late") {
|
|
165253
|
-
late = true;
|
|
165254
|
-
return null;
|
|
165255
|
-
}
|
|
165256
|
-
return [id, result];
|
|
165257
|
-
} catch {
|
|
165258
|
-
failed = true;
|
|
165259
|
-
return null;
|
|
165260
|
-
} finally {
|
|
165261
|
-
clearTimeout(timer);
|
|
165262
|
-
}
|
|
165263
|
-
});
|
|
165264
|
-
if (failed)
|
|
165265
|
-
warnings.push("Some commit counts could not be read. Refresh to retry.");
|
|
165266
|
-
if (late)
|
|
165267
|
-
warnings.push("Some commit counts took too long to read. Refresh to retry.");
|
|
165268
|
-
return new Map(compared.flatMap((entry) => entry ? [entry] : []));
|
|
165269
|
-
}
|
|
165270
|
-
function parseCompare(raw) {
|
|
165271
|
-
const value = JSON.parse(raw);
|
|
165272
|
-
if (typeof value?.status !== "string" || !compareStates.has(value.status) || !Number.isSafeInteger(value.ahead_by) || value.ahead_by < 0) {
|
|
165273
|
-
throw new Error("unavailable: GitHub returned an unreadable comparison.");
|
|
165274
|
-
}
|
|
165275
|
-
return { status: value.status, aheadBy: value.ahead_by };
|
|
165276
|
-
}
|
|
165277
|
-
async function runReviewReviews(args, cwd = process.cwd()) {
|
|
165278
|
-
if (args.length === 1 && (args[0] === "--help" || args[0] === "-h")) {
|
|
165279
|
-
console.log(REVIEWS_USAGE);
|
|
165280
|
-
return;
|
|
165281
|
-
}
|
|
165282
|
-
const { values } = parseArgs11({ args, strict: true, allowPositionals: false, options: { json: { type: "boolean" }, repo: { type: "string" }, "include-closed": { type: "boolean" } } });
|
|
165283
|
-
if (!values.json)
|
|
165284
|
-
throw new Error(REVIEWS_USAGE);
|
|
165285
|
-
const repositories = await reviewRepositories(cwd);
|
|
165286
|
-
const repo = selectRepository(repositories, values.repo);
|
|
165287
|
-
const auth = await projectGithubConnection(cwd);
|
|
165288
|
-
const result = await readReviews({
|
|
165289
|
-
repo,
|
|
165290
|
-
repositories,
|
|
165291
|
-
includeClosed: values["include-closed"] === true,
|
|
165292
|
-
query: (text, params) => boardGraphql(cwd, text, params, auth),
|
|
165293
|
-
compare: async (base, head) => parseCompare(await boardGh(cwd, ["api", "--hostname", "github.com", `repos/${repo}/compare/${base}...${head}?per_page=1`, "--jq", "{status, ahead_by}"], auth))
|
|
165294
|
-
});
|
|
165295
|
-
await writeBoundJson(result, auth);
|
|
165296
|
-
}
|
|
165297
|
-
var REVIEWS_USAGE = "keryx review reviews --json [--repo owner/name] [--include-closed]", MAX_REVIEW_COMPARES = 25, REVIEW_COMPARE_BUDGET_MS = 60000, COMPARE_PARALLEL = 4, CARD_BATCH = 20, CARD_PARALLEL = 3, OBJECT_ID, identityQuery = `query ReviewIdentity($owner:String!, $name:String!) { viewer { login } repository(owner:$owner,name:$name) { id } }`, cannotRetainData2 = (error) => error instanceof Error && /^(access|configuration):/.test(error.message), latestActivity = (row) => row.attempts.reduce((max, a) => a.createdAt > max ? a.createdAt : max, ""), compareStates;
|
|
165298
|
-
var init_review_reviews = __esm(() => {
|
|
165299
|
-
init_board();
|
|
165300
|
-
init_board_github();
|
|
165301
|
-
init_desk_run_store();
|
|
165302
|
-
init_review_entity();
|
|
165303
|
-
OBJECT_ID = /^[0-9a-f]{40}$/;
|
|
165304
|
-
compareStates = new Set(["ahead", "behind", "diverged", "identical"]);
|
|
165305
|
-
});
|
|
165306
|
-
|
|
165307
|
-
// src/review/review-advance.ts
|
|
165308
|
-
function updateRoundOptions(options) {
|
|
165309
|
-
if (options === undefined)
|
|
165310
|
-
return;
|
|
165311
|
-
const { autoPublish: _automatic, ...rest } = options;
|
|
165312
|
-
return rest;
|
|
165313
|
-
}
|
|
165314
|
-
function reviewedAttempt(runs, id) {
|
|
165315
|
-
const candidates = runs.filter((run) => run.source !== "existing" && !withdrawn2(run));
|
|
165316
|
-
if (id !== undefined) {
|
|
165317
|
-
const named = candidates.find((run) => run.id === id);
|
|
165318
|
-
if (!named)
|
|
165319
|
-
throw new Error("stale: This attempt was archived, deleted or imported, so it cannot be updated. Update the review from its latest round.");
|
|
165320
|
-
return named;
|
|
165321
|
-
}
|
|
165322
|
-
const latest = [...candidates].sort((a, b) => (b.round ?? 0) - (a.round ?? 0) || b.createdAt.localeCompare(a.createdAt))[0];
|
|
165323
|
-
if (!latest)
|
|
165324
|
-
throw new Error("configuration: This pull request has no review to update. Start a review first.");
|
|
165325
|
-
return latest;
|
|
165326
|
-
}
|
|
165327
|
-
function advanceRequest({ reviewed, runs, current, prState }) {
|
|
165328
|
-
if (prState !== "OPEN")
|
|
165329
|
-
throw new Error("stale: This pull request is no longer open.");
|
|
165330
|
-
if (newerRoundOf(runs, reviewed) !== undefined) {
|
|
165331
|
-
throw new Error("stale: A later round of this Review already exists. Refresh the Review and update from its latest round.");
|
|
165332
|
-
}
|
|
165333
|
-
if (reviewed.baseSha === current.baseSha && reviewed.headSha === current.headSha) {
|
|
165334
|
-
throw new Error("configuration: This round already reviews the pull request's current head; there is nothing to update.");
|
|
165335
|
-
}
|
|
165336
|
-
const options = updateRoundOptions(reviewed.options);
|
|
165337
|
-
return { revision: current, ...options && { options } };
|
|
165338
|
-
}
|
|
165339
|
-
async function advanceReview(args, deps) {
|
|
165340
|
-
const { key, pr } = await deps.resolve(args.repo, args.number);
|
|
165341
|
-
if (args.repositoryId !== undefined && args.repositoryId !== key.repositoryId || args.viewer !== undefined && args.viewer.toLowerCase() !== key.viewer.toLowerCase()) {
|
|
165342
|
-
throw new Error("access: GitHub account or repository changed. Refresh the board.");
|
|
165343
|
-
}
|
|
165344
|
-
const current = { baseSha: pr.baseRefOid, headSha: pr.headRefOid };
|
|
165345
|
-
if (args.revision !== undefined && (args.revision.baseSha !== current.baseSha || args.revision.headSha !== current.headSha)) {
|
|
165346
|
-
throw new Error("stale: The pull request revision has changed. Refresh the board to review its current range.");
|
|
165347
|
-
}
|
|
165348
|
-
const runs = deps.history(key);
|
|
165349
|
-
const reviewed = reviewedAttempt(runs, args.id);
|
|
165350
|
-
const { revision, options } = advanceRequest({ reviewed, runs, current, prState: pr.state });
|
|
165351
|
-
return deps.start(key, revision, options);
|
|
165352
|
-
}
|
|
165353
|
-
var withdrawn2 = (run) => run.decision?.action === "delete" || run.decision?.action === "archive";
|
|
165354
|
-
var init_review_advance = __esm(() => {
|
|
165355
|
-
init_update_round();
|
|
165356
|
-
});
|
|
165357
|
-
|
|
165358
|
-
// src/commands/review-advance.ts
|
|
165359
|
-
import { parseArgs as parseArgs12 } from "util";
|
|
165360
|
-
async function runReviewAdvance(args, cwd = process.cwd()) {
|
|
165361
|
-
if (args.length === 1 && (args[0] === "--help" || args[0] === "-h")) {
|
|
165362
|
-
console.log(ADVANCE_USAGE);
|
|
165363
|
-
return;
|
|
165364
|
-
}
|
|
165365
|
-
const { values: v } = parseArgs12({
|
|
165366
|
-
args,
|
|
165367
|
-
strict: true,
|
|
165368
|
-
allowPositionals: false,
|
|
165369
|
-
options: {
|
|
165370
|
-
json: { type: "boolean" },
|
|
165371
|
-
repo: { type: "string" },
|
|
165372
|
-
number: { type: "string" },
|
|
165373
|
-
id: { type: "string" },
|
|
165374
|
-
"repository-id": { type: "string" },
|
|
165375
|
-
viewer: { type: "string" },
|
|
165376
|
-
base: { type: "string" },
|
|
165377
|
-
head: { type: "string" }
|
|
165378
|
-
}
|
|
165379
|
-
});
|
|
165380
|
-
const number = Number(v.number);
|
|
165381
|
-
if (!v.json || !v.repo || !/^[\w.-]+\/[\w.-]+$/.test(v.repo) || !v.number || !/^[1-9]\d*$/.test(v.number) || !Number.isSafeInteger(number) || v.id !== undefined && !uuid4.test(v.id) || v.base === undefined !== (v.head === undefined) || v.base !== undefined && (!sha6.test(v.base) || !sha6.test(v.head))) {
|
|
165382
|
-
throw new Error(ADVANCE_USAGE);
|
|
165383
|
-
}
|
|
165384
|
-
const snapshot = await advanceReview({
|
|
165385
|
-
repo: v.repo,
|
|
165386
|
-
number,
|
|
165387
|
-
id: v.id,
|
|
165388
|
-
repositoryId: v["repository-id"],
|
|
165389
|
-
viewer: v.viewer,
|
|
165390
|
-
...v.base !== undefined && { revision: { baseSha: v.base, headSha: v.head } }
|
|
165391
|
-
}, {
|
|
165392
|
-
resolve: async (repo, pr) => resolveDeskSubject(cwd, repo, pr, await projectGithubConnection(cwd)),
|
|
165393
|
-
history: (key) => {
|
|
165394
|
-
const store = new DeskRunStore;
|
|
165395
|
-
try {
|
|
165396
|
-
return store.history(key).runs;
|
|
165397
|
-
} finally {
|
|
165398
|
-
store.close();
|
|
165399
|
-
}
|
|
165400
|
-
},
|
|
165401
|
-
start: async (key, revision, options) => {
|
|
165402
|
-
await Promise.resolve().then(() => init_review_desk_provider());
|
|
165403
|
-
return requestDeskRun(cwd, key, { action: "start", revision, ...options && { options } }, resolveDeskReviewOptions);
|
|
165404
|
-
}
|
|
165405
|
-
});
|
|
165406
|
-
await new Promise((resolve, reject) => process.stdout.write(JSON.stringify(snapshot) + `
|
|
165407
|
-
`, (error) => error ? reject(error) : resolve()));
|
|
165408
|
-
}
|
|
165409
|
-
var ADVANCE_USAGE = "keryx review advance --json --repo owner/name --number N [--id UUID] [--repository-id ID --viewer LOGIN] [--base SHA --head SHA]", sha6, uuid4;
|
|
165410
|
-
var init_review_advance2 = __esm(() => {
|
|
165411
|
-
init_board_github();
|
|
165412
|
-
init_desk_run_store();
|
|
165413
|
-
init_desk_run_service();
|
|
165414
|
-
init_review_advance();
|
|
165415
|
-
sha6 = /^[0-9a-f]{40}$/;
|
|
165416
|
-
uuid4 = /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/i;
|
|
165417
|
-
});
|
|
165418
|
-
|
|
165419
165317
|
// src/review/review-state-id.ts
|
|
165420
165318
|
function slug4(text) {
|
|
165421
165319
|
return text.toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
@@ -165500,7 +165398,7 @@ async function requireReview(projectRoot, id) {
|
|
|
165500
165398
|
throw new ReviewStateError("not-found", `no review ${id} (${reviewStateRelativeDir(id)}/${REVIEW_STATE_FILE})`);
|
|
165501
165399
|
return review;
|
|
165502
165400
|
}
|
|
165503
|
-
function
|
|
165401
|
+
function oneLine9(text) {
|
|
165504
165402
|
return text.replace(/\s+/g, " ").trim();
|
|
165505
165403
|
}
|
|
165506
165404
|
async function writeReview(projectRoot, id, verb, options, change) {
|
|
@@ -165514,7 +165412,7 @@ async function writeReview(projectRoot, id, verb, options, change) {
|
|
|
165514
165412
|
await writeFileAtomic(path365.join(dir, REVIEW_STATE_FILE), `${JSON.stringify(next, null, 2)}
|
|
165515
165413
|
`);
|
|
165516
165414
|
}
|
|
165517
|
-
await appendFile15(path365.join(dir, REVIEW_STATE_JOURNAL), `- ${at} ${verb} ${
|
|
165415
|
+
await appendFile15(path365.join(dir, REVIEW_STATE_JOURNAL), `- ${at} ${verb} ${oneLine9(summary)}
|
|
165518
165416
|
`, "utf8");
|
|
165519
165417
|
return result;
|
|
165520
165418
|
});
|
|
@@ -165579,7 +165477,7 @@ async function openReviewRound(projectRoot, input, options) {
|
|
|
165579
165477
|
review.onHeadMove = input.onHeadMove;
|
|
165580
165478
|
const reopened = current?.state === "closed";
|
|
165581
165479
|
const last = currentRound(review);
|
|
165582
|
-
if (last && last.baseSha === baseSha && last.headSha === headSha && settingsMatch(last.settingsKey, settingsKey)) {
|
|
165480
|
+
if (last && last.baseSha === baseSha && last.headSha === headSha && settingsMatch(last.settingsKey, settingsKey) && !isPublished(review, last)) {
|
|
165583
165481
|
if (last.settingsKey === null && settingsKey !== null)
|
|
165584
165482
|
last.settingsKey = settingsKey;
|
|
165585
165483
|
const restarted = sessionId !== null && sessionId !== last.sessionId;
|
|
@@ -165743,7 +165641,7 @@ async function markReview(projectRoot, id, mark, options) {
|
|
|
165743
165641
|
});
|
|
165744
165642
|
}
|
|
165745
165643
|
async function appendNote(projectRoot, id, text, options) {
|
|
165746
|
-
const line =
|
|
165644
|
+
const line = oneLine9(text);
|
|
165747
165645
|
if (!line)
|
|
165748
165646
|
throw new ReviewStateError("invalid", "a note needs text");
|
|
165749
165647
|
return writeReview(projectRoot, id, "note", options, (current) => {
|
|
@@ -165801,6 +165699,323 @@ var init_review_state = __esm(() => {
|
|
|
165801
165699
|
REVIEW_MARKS = ["stale", "closed", "ready"];
|
|
165802
165700
|
});
|
|
165803
165701
|
|
|
165702
|
+
// src/review/review-state-rows.ts
|
|
165703
|
+
function recordMatches(record, repo, repositoryId, viewer) {
|
|
165704
|
+
const sameRepository = record.pr.repositoryId ? record.pr.repositoryId === repositoryId : record.pr.repo.toLowerCase() === repo.toLowerCase();
|
|
165705
|
+
return sameRepository && (record.viewer === null || record.viewer === viewer);
|
|
165706
|
+
}
|
|
165707
|
+
function roundAttempts(record, stored) {
|
|
165708
|
+
let highest = stored.reduce((max, attempt) => Math.max(max, attempt.round), 0);
|
|
165709
|
+
const assigned = [];
|
|
165710
|
+
return [...record.rounds].sort((a, b) => a.number - b.number).map((round) => {
|
|
165711
|
+
const known = stored.find((attempt) => sameRange2(attempt, round)) ?? assigned.find((entry) => sameRange2(entry, round));
|
|
165712
|
+
const number = known ? known.round : ++highest;
|
|
165713
|
+
if (!known)
|
|
165714
|
+
assigned.push({ baseSha: round.baseSha, headSha: round.headSha, round: number });
|
|
165715
|
+
return roundAttempt(record, round, number);
|
|
165716
|
+
});
|
|
165717
|
+
}
|
|
165718
|
+
function roundAttempt(record, round, number) {
|
|
165719
|
+
const state = ROUND_ATTEMPT_STATE[round.state];
|
|
165720
|
+
const finished = state === "completed";
|
|
165721
|
+
const published = record.publications.some((publication) => publication.round === round.number);
|
|
165722
|
+
return {
|
|
165723
|
+
...round.sessionId ? { sessionId: round.sessionId } : {},
|
|
165724
|
+
id: `${record.id}#${round.number}`,
|
|
165725
|
+
round: number,
|
|
165726
|
+
previousRunId: null,
|
|
165727
|
+
state,
|
|
165728
|
+
source: "session",
|
|
165729
|
+
baseSha: round.baseSha,
|
|
165730
|
+
headSha: round.headSha,
|
|
165731
|
+
reviewed: finished ? { baseSha: round.baseSha, headSha: round.headSha } : null,
|
|
165732
|
+
coverage: null,
|
|
165733
|
+
findings: round.findings ? { blocker: round.findings.blocker, major: round.findings.major, minor: round.findings.minor, info: round.findings.info } : null,
|
|
165734
|
+
verdict: round.verdict,
|
|
165735
|
+
publication: published ? "published" : finished ? "pending" : null,
|
|
165736
|
+
decision: null,
|
|
165737
|
+
flowId: null,
|
|
165738
|
+
tokens: round.usage.tokens > 0 ? round.usage.tokens : null,
|
|
165739
|
+
awaitingAnswer: false,
|
|
165740
|
+
archived: false,
|
|
165741
|
+
createdAt: round.openedAt,
|
|
165742
|
+
finishedAt: finished || state === "cancelled" ? round.updatedAt : null
|
|
165743
|
+
};
|
|
165744
|
+
}
|
|
165745
|
+
function mergeReviewStateRows(rows, records, repositoryId, viewer) {
|
|
165746
|
+
const byNumber = new Map(rows.map((row) => [row.number, { ...row, attempts: [...row.attempts] }]));
|
|
165747
|
+
for (const record of records) {
|
|
165748
|
+
if (!record.rounds.length)
|
|
165749
|
+
continue;
|
|
165750
|
+
const existing = byNumber.get(record.pr.number);
|
|
165751
|
+
const row = existing ?? {
|
|
165752
|
+
id: record.id,
|
|
165753
|
+
repositoryId,
|
|
165754
|
+
number: record.pr.number,
|
|
165755
|
+
viewer,
|
|
165756
|
+
closedAt: null,
|
|
165757
|
+
onHeadMove: record.onHeadMove,
|
|
165758
|
+
attempts: []
|
|
165759
|
+
};
|
|
165760
|
+
row.attempts.push(...roundAttempts(record, row.attempts));
|
|
165761
|
+
row.attempts.sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
165762
|
+
if (record.state === "closed" && row.closedAt === null)
|
|
165763
|
+
row.closedAt = record.updatedAt;
|
|
165764
|
+
byNumber.set(record.pr.number, row);
|
|
165765
|
+
}
|
|
165766
|
+
return [...byNumber.values()];
|
|
165767
|
+
}
|
|
165768
|
+
var ROUND_ATTEMPT_STATE, sameRange2 = (a, b) => a.baseSha === b.baseSha && a.headSha === b.headSha;
|
|
165769
|
+
var init_review_state_rows = __esm(() => {
|
|
165770
|
+
ROUND_ATTEMPT_STATE = {
|
|
165771
|
+
planning: "running",
|
|
165772
|
+
dispatching: "running",
|
|
165773
|
+
reconciling: "running",
|
|
165774
|
+
paused: "cancelled",
|
|
165775
|
+
ready: "completed"
|
|
165776
|
+
};
|
|
165777
|
+
});
|
|
165778
|
+
|
|
165779
|
+
// src/commands/review-reviews.ts
|
|
165780
|
+
import { parseArgs as parseArgs11 } from "util";
|
|
165781
|
+
async function readReviews({ repo, repositories, query, compare, root = deskRunRoot(), compareBudgetMs = REVIEW_COMPARE_BUDGET_MS, includeClosed = false, projectRoot }) {
|
|
165782
|
+
const [owner, name] = repo.split("/");
|
|
165783
|
+
const identity = await query(identityQuery, { owner, name });
|
|
165784
|
+
const viewer = identity.viewer?.login;
|
|
165785
|
+
const repositoryId = identity.repository?.id;
|
|
165786
|
+
if (!viewer || !repositoryId)
|
|
165787
|
+
throw new Error("access: GitHub repository or account is unavailable.");
|
|
165788
|
+
const snapshot = { version: 1, repo, repositories, repositoryId, viewer, fetchedAt: new Date().toISOString(), reviews: [], warnings: [] };
|
|
165789
|
+
const records = projectRoot ? await sessionReviewRecords(projectRoot, repo, repositoryId, viewer, snapshot.warnings) : [];
|
|
165790
|
+
const rows = mergeReviewStateRows(readReviewRows(repositoryId, viewer, root), records, repositoryId, viewer).map((row) => ({ row, at: latestActivity(row) })).sort((a, b) => b.at.localeCompare(a.at) || b.row.number - a.row.number).map(({ row }) => row);
|
|
165791
|
+
if (!rows.length)
|
|
165792
|
+
return snapshot;
|
|
165793
|
+
const cards = await readCards(snapshot, includeClosed ? rows : rows.filter((row) => row.closedAt === null), query);
|
|
165794
|
+
const behind = rows.flatMap((row) => {
|
|
165795
|
+
const pair = headComparison(row, cards.get(row.number) ?? null);
|
|
165796
|
+
return pair && OBJECT_ID.test(pair.reviewed) && OBJECT_ID.test(pair.head) ? [{ id: row.id, ...pair }] : [];
|
|
165797
|
+
});
|
|
165798
|
+
if (behind.length > MAX_REVIEW_COMPARES)
|
|
165799
|
+
snapshot.warnings.push(`Commit counts are shown for ${MAX_REVIEW_COMPARES} Reviews behind their pull request. Refresh to read more.`);
|
|
165800
|
+
const comparisons = await compareHeads(behind.slice(0, MAX_REVIEW_COMPARES), compare, compareBudgetMs, snapshot.warnings);
|
|
165801
|
+
snapshot.reviews = rows.map((row) => summarizeReview(row, cards.get(row.number) ?? null, comparisons.get(row.id)));
|
|
165802
|
+
return snapshot;
|
|
165803
|
+
}
|
|
165804
|
+
async function sessionReviewRecords(projectRoot, repo, repositoryId, viewer, warnings) {
|
|
165805
|
+
try {
|
|
165806
|
+
const listing = await listReviewStates(projectRoot);
|
|
165807
|
+
if (listing.unreadable.length)
|
|
165808
|
+
warnings.push(`${listing.unreadable.length} session review record(s) could not be read.`);
|
|
165809
|
+
return listing.reviews.filter((record) => recordMatches(record, repo, repositoryId, viewer));
|
|
165810
|
+
} catch {
|
|
165811
|
+
warnings.push("Session reviews could not be read.");
|
|
165812
|
+
return [];
|
|
165813
|
+
}
|
|
165814
|
+
}
|
|
165815
|
+
async function readCards(snapshot, rows, query) {
|
|
165816
|
+
const numbers = [...new Set(rows.map((row) => row.number))];
|
|
165817
|
+
const batches = Array.from({ length: Math.ceil(numbers.length / CARD_BATCH) }, (_, i) => numbers.slice(i * CARD_BATCH, (i + 1) * CARD_BATCH));
|
|
165818
|
+
let unreadable = false;
|
|
165819
|
+
const read = await mapPool(batches, CARD_PARALLEL, async (batch) => {
|
|
165820
|
+
try {
|
|
165821
|
+
return await listActiveReviewCards(snapshot, batch, query);
|
|
165822
|
+
} catch (error) {
|
|
165823
|
+
if (cannotRetainData2(error))
|
|
165824
|
+
throw error;
|
|
165825
|
+
unreadable = true;
|
|
165826
|
+
return [];
|
|
165827
|
+
}
|
|
165828
|
+
}, { stopOnError: true });
|
|
165829
|
+
if (unreadable)
|
|
165830
|
+
snapshot.warnings.push("Some pull requests could not be loaded. Refresh to retry.");
|
|
165831
|
+
return new Map(read.flat().map((card) => [card.number, card]));
|
|
165832
|
+
}
|
|
165833
|
+
async function compareHeads(pairs, compare, budgetMs, warnings) {
|
|
165834
|
+
const deadline = Date.now() + budgetMs;
|
|
165835
|
+
let failed = false;
|
|
165836
|
+
let late = false;
|
|
165837
|
+
const compared = await mapPool(pairs, COMPARE_PARALLEL, async ({ id, reviewed, head }) => {
|
|
165838
|
+
const left = deadline - Date.now();
|
|
165839
|
+
if (left <= 0) {
|
|
165840
|
+
late = true;
|
|
165841
|
+
return null;
|
|
165842
|
+
}
|
|
165843
|
+
let timer;
|
|
165844
|
+
const expired = new Promise((resolve) => {
|
|
165845
|
+
timer = setTimeout(() => resolve("late"), left);
|
|
165846
|
+
});
|
|
165847
|
+
try {
|
|
165848
|
+
const result = await Promise.race([compare(reviewed, head), expired]);
|
|
165849
|
+
if (result === "late") {
|
|
165850
|
+
late = true;
|
|
165851
|
+
return null;
|
|
165852
|
+
}
|
|
165853
|
+
return [id, result];
|
|
165854
|
+
} catch {
|
|
165855
|
+
failed = true;
|
|
165856
|
+
return null;
|
|
165857
|
+
} finally {
|
|
165858
|
+
clearTimeout(timer);
|
|
165859
|
+
}
|
|
165860
|
+
});
|
|
165861
|
+
if (failed)
|
|
165862
|
+
warnings.push("Some commit counts could not be read. Refresh to retry.");
|
|
165863
|
+
if (late)
|
|
165864
|
+
warnings.push("Some commit counts took too long to read. Refresh to retry.");
|
|
165865
|
+
return new Map(compared.flatMap((entry) => entry ? [entry] : []));
|
|
165866
|
+
}
|
|
165867
|
+
function parseCompare(raw) {
|
|
165868
|
+
const value = JSON.parse(raw);
|
|
165869
|
+
if (typeof value?.status !== "string" || !compareStates.has(value.status) || !Number.isSafeInteger(value.ahead_by) || value.ahead_by < 0) {
|
|
165870
|
+
throw new Error("unavailable: GitHub returned an unreadable comparison.");
|
|
165871
|
+
}
|
|
165872
|
+
return { status: value.status, aheadBy: value.ahead_by };
|
|
165873
|
+
}
|
|
165874
|
+
async function runReviewReviews(args, cwd = process.cwd()) {
|
|
165875
|
+
if (args.length === 1 && (args[0] === "--help" || args[0] === "-h")) {
|
|
165876
|
+
console.log(REVIEWS_USAGE);
|
|
165877
|
+
return;
|
|
165878
|
+
}
|
|
165879
|
+
const { values } = parseArgs11({ args, strict: true, allowPositionals: false, options: { json: { type: "boolean" }, repo: { type: "string" }, "include-closed": { type: "boolean" } } });
|
|
165880
|
+
if (!values.json)
|
|
165881
|
+
throw new Error(REVIEWS_USAGE);
|
|
165882
|
+
const repositories = await reviewRepositories(cwd);
|
|
165883
|
+
const repo = selectRepository(repositories, values.repo);
|
|
165884
|
+
const auth = await projectGithubConnection(cwd);
|
|
165885
|
+
const result = await readReviews({
|
|
165886
|
+
repo,
|
|
165887
|
+
repositories,
|
|
165888
|
+
includeClosed: values["include-closed"] === true,
|
|
165889
|
+
projectRoot: cwd,
|
|
165890
|
+
query: (text, params) => boardGraphql(cwd, text, params, auth),
|
|
165891
|
+
compare: async (base, head) => parseCompare(await boardGh(cwd, ["api", "--hostname", "github.com", `repos/${repo}/compare/${base}...${head}?per_page=1`, "--jq", "{status, ahead_by}"], auth))
|
|
165892
|
+
});
|
|
165893
|
+
await writeBoundJson(result, auth);
|
|
165894
|
+
}
|
|
165895
|
+
var REVIEWS_USAGE = "keryx review reviews --json [--repo owner/name] [--include-closed]", MAX_REVIEW_COMPARES = 25, REVIEW_COMPARE_BUDGET_MS = 60000, COMPARE_PARALLEL = 4, CARD_BATCH = 20, CARD_PARALLEL = 3, OBJECT_ID, identityQuery = `query ReviewIdentity($owner:String!, $name:String!) { viewer { login } repository(owner:$owner,name:$name) { id } }`, cannotRetainData2 = (error) => error instanceof Error && /^(access|configuration):/.test(error.message), latestActivity = (row) => row.attempts.reduce((max, a) => a.createdAt > max ? a.createdAt : max, ""), compareStates;
|
|
165896
|
+
var init_review_reviews = __esm(() => {
|
|
165897
|
+
init_board();
|
|
165898
|
+
init_board_github();
|
|
165899
|
+
init_desk_run_store();
|
|
165900
|
+
init_review_entity();
|
|
165901
|
+
init_review_state();
|
|
165902
|
+
init_review_state_rows();
|
|
165903
|
+
OBJECT_ID = /^[0-9a-f]{40}$/;
|
|
165904
|
+
compareStates = new Set(["ahead", "behind", "diverged", "identical"]);
|
|
165905
|
+
});
|
|
165906
|
+
|
|
165907
|
+
// src/review/review-advance.ts
|
|
165908
|
+
function updateRoundOptions(options) {
|
|
165909
|
+
if (options === undefined)
|
|
165910
|
+
return;
|
|
165911
|
+
const { autoPublish: _automatic, ...rest } = options;
|
|
165912
|
+
return rest;
|
|
165913
|
+
}
|
|
165914
|
+
function reviewedAttempt(runs, id) {
|
|
165915
|
+
const candidates = runs.filter((run) => run.source !== "existing" && !withdrawn2(run));
|
|
165916
|
+
if (id !== undefined) {
|
|
165917
|
+
const named = candidates.find((run) => run.id === id);
|
|
165918
|
+
if (!named)
|
|
165919
|
+
throw new Error("stale: This attempt was archived, deleted or imported, so it cannot be updated. Update the review from its latest round.");
|
|
165920
|
+
return named;
|
|
165921
|
+
}
|
|
165922
|
+
const latest = [...candidates].sort((a, b) => (b.round ?? 0) - (a.round ?? 0) || b.createdAt.localeCompare(a.createdAt))[0];
|
|
165923
|
+
if (!latest)
|
|
165924
|
+
throw new Error("configuration: This pull request has no review to update. Start a review first.");
|
|
165925
|
+
return latest;
|
|
165926
|
+
}
|
|
165927
|
+
function advanceRequest({ reviewed, runs, current, prState }) {
|
|
165928
|
+
if (prState !== "OPEN")
|
|
165929
|
+
throw new Error("stale: This pull request is no longer open.");
|
|
165930
|
+
if (newerRoundOf(runs, reviewed) !== undefined) {
|
|
165931
|
+
throw new Error("stale: A later round of this Review already exists. Refresh the Review and update from its latest round.");
|
|
165932
|
+
}
|
|
165933
|
+
if (reviewed.baseSha === current.baseSha && reviewed.headSha === current.headSha) {
|
|
165934
|
+
throw new Error("configuration: This round already reviews the pull request's current head; there is nothing to update.");
|
|
165935
|
+
}
|
|
165936
|
+
const options = updateRoundOptions(reviewed.options);
|
|
165937
|
+
return { revision: current, ...options && { options } };
|
|
165938
|
+
}
|
|
165939
|
+
async function advanceReview(args, deps) {
|
|
165940
|
+
const { key, pr } = await deps.resolve(args.repo, args.number);
|
|
165941
|
+
if (args.repositoryId !== undefined && args.repositoryId !== key.repositoryId || args.viewer !== undefined && args.viewer.toLowerCase() !== key.viewer.toLowerCase()) {
|
|
165942
|
+
throw new Error("access: GitHub account or repository changed. Refresh the board.");
|
|
165943
|
+
}
|
|
165944
|
+
const current = { baseSha: pr.baseRefOid, headSha: pr.headRefOid };
|
|
165945
|
+
if (args.revision !== undefined && (args.revision.baseSha !== current.baseSha || args.revision.headSha !== current.headSha)) {
|
|
165946
|
+
throw new Error("stale: The pull request revision has changed. Refresh the board to review its current range.");
|
|
165947
|
+
}
|
|
165948
|
+
const runs = deps.history(key);
|
|
165949
|
+
const reviewed = reviewedAttempt(runs, args.id);
|
|
165950
|
+
const { revision, options } = advanceRequest({ reviewed, runs, current, prState: pr.state });
|
|
165951
|
+
return deps.start(key, revision, options);
|
|
165952
|
+
}
|
|
165953
|
+
var withdrawn2 = (run) => run.decision?.action === "delete" || run.decision?.action === "archive";
|
|
165954
|
+
var init_review_advance = __esm(() => {
|
|
165955
|
+
init_update_round();
|
|
165956
|
+
});
|
|
165957
|
+
|
|
165958
|
+
// src/commands/review-advance.ts
|
|
165959
|
+
import { parseArgs as parseArgs12 } from "util";
|
|
165960
|
+
async function runReviewAdvance(args, cwd = process.cwd()) {
|
|
165961
|
+
if (args.length === 1 && (args[0] === "--help" || args[0] === "-h")) {
|
|
165962
|
+
console.log(ADVANCE_USAGE);
|
|
165963
|
+
return;
|
|
165964
|
+
}
|
|
165965
|
+
const { values: v } = parseArgs12({
|
|
165966
|
+
args,
|
|
165967
|
+
strict: true,
|
|
165968
|
+
allowPositionals: false,
|
|
165969
|
+
options: {
|
|
165970
|
+
json: { type: "boolean" },
|
|
165971
|
+
repo: { type: "string" },
|
|
165972
|
+
number: { type: "string" },
|
|
165973
|
+
id: { type: "string" },
|
|
165974
|
+
"repository-id": { type: "string" },
|
|
165975
|
+
viewer: { type: "string" },
|
|
165976
|
+
base: { type: "string" },
|
|
165977
|
+
head: { type: "string" }
|
|
165978
|
+
}
|
|
165979
|
+
});
|
|
165980
|
+
const number = Number(v.number);
|
|
165981
|
+
if (!v.json || !v.repo || !/^[\w.-]+\/[\w.-]+$/.test(v.repo) || !v.number || !/^[1-9]\d*$/.test(v.number) || !Number.isSafeInteger(number) || v.id !== undefined && !uuid4.test(v.id) || v.base === undefined !== (v.head === undefined) || v.base !== undefined && (!sha6.test(v.base) || !sha6.test(v.head))) {
|
|
165982
|
+
throw new Error(ADVANCE_USAGE);
|
|
165983
|
+
}
|
|
165984
|
+
const snapshot = await advanceReview({
|
|
165985
|
+
repo: v.repo,
|
|
165986
|
+
number,
|
|
165987
|
+
id: v.id,
|
|
165988
|
+
repositoryId: v["repository-id"],
|
|
165989
|
+
viewer: v.viewer,
|
|
165990
|
+
...v.base !== undefined && { revision: { baseSha: v.base, headSha: v.head } }
|
|
165991
|
+
}, {
|
|
165992
|
+
resolve: async (repo, pr) => resolveDeskSubject(cwd, repo, pr, await projectGithubConnection(cwd)),
|
|
165993
|
+
history: (key) => {
|
|
165994
|
+
const store = new DeskRunStore;
|
|
165995
|
+
try {
|
|
165996
|
+
return store.history(key).runs;
|
|
165997
|
+
} finally {
|
|
165998
|
+
store.close();
|
|
165999
|
+
}
|
|
166000
|
+
},
|
|
166001
|
+
start: async (key, revision, options) => {
|
|
166002
|
+
await Promise.resolve().then(() => init_review_desk_provider());
|
|
166003
|
+
return requestDeskRun(cwd, key, { action: "start", revision, ...options && { options } }, resolveDeskReviewOptions);
|
|
166004
|
+
}
|
|
166005
|
+
});
|
|
166006
|
+
await new Promise((resolve, reject) => process.stdout.write(JSON.stringify(snapshot) + `
|
|
166007
|
+
`, (error) => error ? reject(error) : resolve()));
|
|
166008
|
+
}
|
|
166009
|
+
var ADVANCE_USAGE = "keryx review advance --json --repo owner/name --number N [--id UUID] [--repository-id ID --viewer LOGIN] [--base SHA --head SHA]", sha6, uuid4;
|
|
166010
|
+
var init_review_advance2 = __esm(() => {
|
|
166011
|
+
init_board_github();
|
|
166012
|
+
init_desk_run_store();
|
|
166013
|
+
init_desk_run_service();
|
|
166014
|
+
init_review_advance();
|
|
166015
|
+
sha6 = /^[0-9a-f]{40}$/;
|
|
166016
|
+
uuid4 = /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/i;
|
|
166017
|
+
});
|
|
166018
|
+
|
|
165804
166019
|
// src/commands/review-state.ts
|
|
165805
166020
|
import { parseArgs as parseArgs13 } from "util";
|
|
165806
166021
|
function usageError(message) {
|
|
@@ -225501,8 +225716,10 @@ function presentDecisions(open, otui, chrome, options) {
|
|
|
225501
225716
|
return handle;
|
|
225502
225717
|
}
|
|
225503
225718
|
async function openDecisions(otui, chrome, options) {
|
|
225504
|
-
const { cwd, confirmationLines, ...rest } = options;
|
|
225719
|
+
const { cwd, confirmationLines, alive, ...rest } = options;
|
|
225505
225720
|
const report = await reportText(cwd).catch(() => UNREADABLE);
|
|
225721
|
+
if (alive?.() === false)
|
|
225722
|
+
return;
|
|
225506
225723
|
const text = withConfirmationLines(report, confirmationLines?.() ?? []);
|
|
225507
225724
|
return presentDecisions((hostOtui, hostChrome, input) => openModal(hostOtui, hostChrome, input), otui, chrome, { ...rest, text });
|
|
225508
225725
|
}
|
|
@@ -225513,8 +225730,10 @@ ${cards.join(`
|
|
|
225513
225730
|
`)}`;
|
|
225514
225731
|
}
|
|
225515
225732
|
async function openDecisionsArms(otui, chrome, options) {
|
|
225516
|
-
const { cwd, confirmationLines: _cards, ...rest } = options;
|
|
225733
|
+
const { cwd, confirmationLines: _cards, alive, ...rest } = options;
|
|
225517
225734
|
const text = await armsText(cwd);
|
|
225735
|
+
if (alive?.() === false)
|
|
225736
|
+
return;
|
|
225518
225737
|
return presentDecisions((hostOtui, hostChrome, input) => openModal(hostOtui, hostChrome, input), otui, chrome, { ...rest, text, tabLabel: "Arms" });
|
|
225519
225738
|
}
|
|
225520
225739
|
function projectDecisionsPanel(count, width, backfilled = 0, annotated = 0, hostQuestions = 0) {
|
|
@@ -225604,14 +225823,22 @@ function mountDecisionsSidebar(options) {
|
|
|
225604
225823
|
}
|
|
225605
225824
|
}));
|
|
225606
225825
|
};
|
|
225826
|
+
let openGeneration = 0;
|
|
225827
|
+
const gone = () => disposed || isRenderableGone(box);
|
|
225607
225828
|
const openWith = async (open) => {
|
|
225829
|
+
if (gone())
|
|
225830
|
+
return;
|
|
225831
|
+
const generation = ++openGeneration;
|
|
225608
225832
|
modal?.close({ restoreFocus: false });
|
|
225609
|
-
|
|
225833
|
+
const opened = await open(core, chrome, {
|
|
225610
225834
|
cwd: options.cwd,
|
|
225835
|
+
alive: () => !gone() && generation === openGeneration,
|
|
225611
225836
|
...options.confirmationLines !== undefined ? { confirmationLines: options.confirmationLines } : {},
|
|
225612
225837
|
...options.onKeypress !== undefined ? { onKeypress: options.onKeypress } : {}
|
|
225613
225838
|
});
|
|
225614
|
-
|
|
225839
|
+
if (generation === openGeneration)
|
|
225840
|
+
modal = opened;
|
|
225841
|
+
return opened;
|
|
225615
225842
|
};
|
|
225616
225843
|
const show = () => openWith(openDecisions);
|
|
225617
225844
|
const showArms = () => openWith(openDecisionsArms);
|
|
@@ -246604,11 +246831,11 @@ var init_background_job_inspector = __esm(() => {
|
|
|
246604
246831
|
});
|
|
246605
246832
|
|
|
246606
246833
|
// src/tui/sidebar-work.ts
|
|
246607
|
-
function
|
|
246834
|
+
function oneLine10(text) {
|
|
246608
246835
|
return text.replace(/\s+/g, " ").trim();
|
|
246609
246836
|
}
|
|
246610
246837
|
function shortLabel(text, max = DETAIL_LABEL_CHARS) {
|
|
246611
|
-
const line =
|
|
246838
|
+
const line = oneLine10(text);
|
|
246612
246839
|
return line.length <= max ? line : `${line.slice(0, Math.max(1, max - 1))}\u2026`;
|
|
246613
246840
|
}
|
|
246614
246841
|
function jobMeta(job) {
|
|
@@ -335369,7 +335596,7 @@ var init_native_coverage_generated = __esm(() => {
|
|
|
335369
335596
|
registryDigest: "96f6ac176ce1847bcc637495a22b7e217d5f472d7a97651ea1614cfe26bfc27e",
|
|
335370
335597
|
contractDigest: "95fd86252f56e1ddca9e5acc8f3817e1dba30c7a576e7a7130ded3424d23b018",
|
|
335371
335598
|
subjectCatalogueDigest: "0aaa0f567b5b26de53e54af7b8441fd4f475d2e044c127543db635eb47569430",
|
|
335372
|
-
inventoryDigest: "
|
|
335599
|
+
inventoryDigest: "c1349c9c1db960093bd995a61945ae23313a2e2c827bd22ab974cb2ed66de5f6",
|
|
335373
335600
|
releaseReady: true,
|
|
335374
335601
|
counts: {
|
|
335375
335602
|
registeredCommands: 76,
|
|
@@ -335649,7 +335876,7 @@ var init_native_coverage_generated = __esm(() => {
|
|
|
335649
335876
|
"workspace.navigate"
|
|
335650
335877
|
],
|
|
335651
335878
|
otherBlockers: [],
|
|
335652
|
-
descriptorDigest: "
|
|
335879
|
+
descriptorDigest: "2d26ab2a2343691b0f5eba412bc324f7d6edaf395d3795093b71f54746780539"
|
|
335653
335880
|
};
|
|
335654
335881
|
});
|
|
335655
335882
|
|