crysk 0.3.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SKILL-dsnffnfp.md +140 -0
- package/dist/SKILL-gnrbph72.md +140 -0
- package/dist/SKILL-kq0xejn3.md +553 -0
- package/dist/SKILL-qaqsbygw.md +66 -0
- package/dist/SKILL-vws0aqb8.md +553 -0
- package/dist/ci-admission-t0f5qwth.md +128 -0
- package/dist/cli.js +408 -155
- package/dist/index.js +151 -20
- package/package.json +2 -2
- package/skills/crysk-ci-setup/SKILL.md +1 -1
- package/skills/crysk-ci-setup/references/ci-admission.md +1 -1
- package/skills/crysk-loop/SKILL.md +19 -8
- package/skills/crysk-pr/SKILL.md +1 -1
- package/src/assets.ts +2 -2
- package/src/ci/gates.ts +9 -6
- package/src/ci/platform-config.ts +127 -0
- package/src/ci/platform-report.ts +702 -0
- package/src/ci/platform.ts +449 -0
- package/src/ci/reporter.ts +9 -7
- package/src/ci/review-admission.ts +8 -4
- package/src/ci/setup.ts +112 -9
- package/src/compare/loop.ts +9 -1
- package/src/compare/martian-adapter.ts +1 -1
- package/src/index.ts +1 -1
- package/src/pr/admission.ts +53 -11
- package/src/pr/ci-admission-gate.ts +2 -1
- package/src/pr/finding-state-record.ts +58 -0
- package/src/pr/gate-record.ts +22 -0
- package/src/pr/inline.ts +3 -0
- package/src/pr/posting.ts +4 -0
- package/src/pr/pr-status.ts +27 -7
- package/src/pr/pr.ts +39 -8
- package/src/pr/preflight.ts +43 -1
- package/src/pr/publish-outcome.ts +10 -2
- package/src/pr/review-pr.ts +5 -3
- package/src/rereview/classify.ts +4 -0
- package/src/rereview/prepare.ts +47 -22
- package/src/rereview/state.ts +34 -8
- package/src/review/report.ts +34 -14
- package/src/security/published-text.ts +161 -0
- package/src/triage/triage.ts +2 -1
- package/src/updater.ts +1 -1
package/dist/cli.js
CHANGED
|
@@ -1723,6 +1723,101 @@ var init_spec = __esm(() => {
|
|
|
1723
1723
|
};
|
|
1724
1724
|
});
|
|
1725
1725
|
|
|
1726
|
+
// src/security/published-text.ts
|
|
1727
|
+
function isSecretValue(name, separator, raw) {
|
|
1728
|
+
const quoted = raw.startsWith('"') || raw.startsWith("'");
|
|
1729
|
+
const value = quoted ? raw.slice(1, -1) : raw;
|
|
1730
|
+
if (value.length < 6 || /^[\d_,.]+$/.test(value) || value.includes("$")) {
|
|
1731
|
+
return false;
|
|
1732
|
+
}
|
|
1733
|
+
if (separator === ":" && /^\d+-\d+$/.test(value))
|
|
1734
|
+
return false;
|
|
1735
|
+
const colon = separator.includes(":");
|
|
1736
|
+
if (!quoted) {
|
|
1737
|
+
if (!colon && separator !== "=")
|
|
1738
|
+
return false;
|
|
1739
|
+
if (/[.()[\]{}<>]/.test(value))
|
|
1740
|
+
return false;
|
|
1741
|
+
if (colon && /^[A-Z][a-z]/.test(value))
|
|
1742
|
+
return false;
|
|
1743
|
+
}
|
|
1744
|
+
if (/\d/.test(value))
|
|
1745
|
+
return true;
|
|
1746
|
+
if (!/pass(?:word|wd)$/i.test(name) || /pass(?:word|wd)/i.test(value)) {
|
|
1747
|
+
return false;
|
|
1748
|
+
}
|
|
1749
|
+
return quoted || !colon || name === name.toUpperCase();
|
|
1750
|
+
}
|
|
1751
|
+
function redactPrivateKeys(text) {
|
|
1752
|
+
if (!text.includes("PRIVATE KEY"))
|
|
1753
|
+
return text;
|
|
1754
|
+
let out = "";
|
|
1755
|
+
let from = 0;
|
|
1756
|
+
let noMoreEnds = false;
|
|
1757
|
+
PEM_BEGIN.lastIndex = 0;
|
|
1758
|
+
for (;; ) {
|
|
1759
|
+
const begin = PEM_BEGIN.exec(text);
|
|
1760
|
+
if (begin === null)
|
|
1761
|
+
break;
|
|
1762
|
+
let to = PEM_BEGIN.lastIndex;
|
|
1763
|
+
let closed = false;
|
|
1764
|
+
if (!noMoreEnds) {
|
|
1765
|
+
PEM_END.lastIndex = to;
|
|
1766
|
+
closed = PEM_END.test(text);
|
|
1767
|
+
if (closed)
|
|
1768
|
+
to = PEM_END.lastIndex;
|
|
1769
|
+
else
|
|
1770
|
+
noMoreEnds = true;
|
|
1771
|
+
}
|
|
1772
|
+
if (!closed) {
|
|
1773
|
+
PEM_BODY.lastIndex = to;
|
|
1774
|
+
PEM_BODY.test(text);
|
|
1775
|
+
to = PEM_BODY.lastIndex;
|
|
1776
|
+
}
|
|
1777
|
+
out += text.slice(from, begin.index) + REDACTED2;
|
|
1778
|
+
from = to;
|
|
1779
|
+
PEM_BEGIN.lastIndex = to;
|
|
1780
|
+
}
|
|
1781
|
+
return out + text.slice(from);
|
|
1782
|
+
}
|
|
1783
|
+
function redactSecrets(text) {
|
|
1784
|
+
let out = redactPrivateKeys(text);
|
|
1785
|
+
for (const shape of SECRET_SHAPES)
|
|
1786
|
+
out = out.replace(shape, REDACTED2);
|
|
1787
|
+
return out.replace(URL_CREDENTIALS, `$1${REDACTED2}@`).replace(SECRET_ASSIGNMENT, (match, quote, name, separator, raw) => isSecretValue(name, separator, raw) ? `${quote}${name}${quote}${separator}${REDACTED2}` : match);
|
|
1788
|
+
}
|
|
1789
|
+
function wasRedacted(text) {
|
|
1790
|
+
return text.includes(REDACTED2);
|
|
1791
|
+
}
|
|
1792
|
+
function defuseMarkup(text) {
|
|
1793
|
+
return text.replace(/(?<![A-Za-z0-9/])@(?!\u200b)/g, `@${ZERO_WIDTH_SPACE}`).replace(/&(?=#|commat)/gi, `&${ZERO_WIDTH_SPACE}`).replaceAll("![", `!${ZERO_WIDTH_SPACE}[`).replace(/<(?=[a-zA-Z/!?])/g, `<${ZERO_WIDTH_SPACE}`).replaceAll("-->", `--${ZERO_WIDTH_SPACE}>`);
|
|
1794
|
+
}
|
|
1795
|
+
function publishedText(text) {
|
|
1796
|
+
return defuseMarkup(redactSecrets(text));
|
|
1797
|
+
}
|
|
1798
|
+
var REDACTED2 = "[REDACTED]", ZERO_WIDTH_SPACE = "\u200B", SECRET_SHAPES, URL_CREDENTIALS, SECRET_ASSIGNMENT, PEM_BEGIN, PEM_END, PEM_BODY;
|
|
1799
|
+
var init_published_text = __esm(() => {
|
|
1800
|
+
SECRET_SHAPES = [
|
|
1801
|
+
/(?<![A-Za-z0-9])gh[pousr]_[A-Za-z0-9_]{20,}/g,
|
|
1802
|
+
/(?<![A-Za-z0-9])github_pat_[A-Za-z0-9_]{20,}/g,
|
|
1803
|
+
/(?<![A-Za-z0-9])glpat-[A-Za-z0-9_-]{20,}/g,
|
|
1804
|
+
/(?<![A-Za-z0-9])(?:AKIA|ASIA)[A-Z0-9]{16}\b/g,
|
|
1805
|
+
/(?<![A-Za-z0-9])sk-(?:ant|proj|svcacct|admin)-[A-Za-z0-9_-]{16,}/g,
|
|
1806
|
+
/(?<![A-Za-z0-9])sk-[A-Za-z0-9]{32,}/g,
|
|
1807
|
+
/(?<![A-Za-z0-9])[sr]k_(?:live|test)_[A-Za-z0-9]{16,}/g,
|
|
1808
|
+
/(?<![A-Za-z0-9])xox[abeoprs]-[A-Za-z0-9-]{10,}/g,
|
|
1809
|
+
/(?<![A-Za-z0-9])AIza[A-Za-z0-9_-]{35}/g,
|
|
1810
|
+
/(?<![A-Za-z0-9])npm_[A-Za-z0-9]{36}\b/g,
|
|
1811
|
+
/(?<![A-Za-z0-9])eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{5,}/g,
|
|
1812
|
+
/(?<![A-Za-z0-9])Bearer\s+(?=[A-Za-z0-9._~+/=-]{0,512}\d)[A-Za-z0-9._~+/=-]{20,}/gi
|
|
1813
|
+
];
|
|
1814
|
+
URL_CREDENTIALS = /(?<![A-Za-z0-9+.-])([a-z][a-z0-9+.-]{0,30}:\/\/)(?:[^\s/?#${<]{0,256}:[^\s/?#${<]{1,256}|[^\s/?#${<:@]{20,256})@/gi;
|
|
1815
|
+
SECRET_ASSIGNMENT = /(?<![A-Za-z0-9_-])(["']?)((?:[A-Za-z0-9_-]{0,40}[_-])?(?:password|passwd|secret|token|api[_-]?key|private[_-]?key|credentials?)(?:[_-][A-Za-z0-9_-]{0,40})?)\1(\s*[=:](?![=:])\s*)("[^"\n]{1,256}"|'[^'\n]{1,256}'|[^\s"',;]{1,256})/gi;
|
|
1816
|
+
PEM_BEGIN = /-----BEGIN [A-Z0-9 ]{0,40}PRIVATE KEY(?: BLOCK)?-----/g;
|
|
1817
|
+
PEM_END = /-----END [A-Z0-9 ]{0,40}PRIVATE KEY(?: BLOCK)?-----/g;
|
|
1818
|
+
PEM_BODY = /(?:\s*[A-Za-z0-9+/=]{16,})*/y;
|
|
1819
|
+
});
|
|
1820
|
+
|
|
1726
1821
|
// src/triage/triage.ts
|
|
1727
1822
|
function triageBadge(fields) {
|
|
1728
1823
|
const badge = TRIAGE_BADGE[fields.tag];
|
|
@@ -1739,7 +1834,7 @@ function renderTriageReplyBody(fields, reasoning) {
|
|
|
1739
1834
|
const head = `${triageMarker(fields)}
|
|
1740
1835
|
|
|
1741
1836
|
${triageBadge(fields)}`;
|
|
1742
|
-
const prose = reasoning.trim();
|
|
1837
|
+
const prose = publishedText(reasoning.trim());
|
|
1743
1838
|
return prose.length === 0 ? `${head}
|
|
1744
1839
|
` : `${head}
|
|
1745
1840
|
|
|
@@ -1817,6 +1912,7 @@ function parseTriageMarker(body) {
|
|
|
1817
1912
|
var TRIAGE_MARKER_PREFIX, TRIAGE_TAGS, TRIAGE_ACTORS, TRIAGE_VERDICTS, FULL_SHA, ADJUDICATED_TAGS, TRIAGE_BADGE;
|
|
1818
1913
|
var init_triage = __esm(() => {
|
|
1819
1914
|
init_brand();
|
|
1915
|
+
init_published_text();
|
|
1820
1916
|
TRIAGE_MARKER_PREFIX = `${MARKER_OPEN}triage `;
|
|
1821
1917
|
TRIAGE_TAGS = new Set([
|
|
1822
1918
|
"applied",
|
|
@@ -1900,7 +1996,7 @@ var workflow_default = "./workflow-w1g9szna.yml";
|
|
|
1900
1996
|
var init_workflow = () => {};
|
|
1901
1997
|
|
|
1902
1998
|
// skills/crysk-ci-setup/references/ci-admission.md
|
|
1903
|
-
var ci_admission_default = "./ci-admission-
|
|
1999
|
+
var ci_admission_default = "./ci-admission-t0f5qwth.md";
|
|
1904
2000
|
var init_ci_admission = () => {};
|
|
1905
2001
|
|
|
1906
2002
|
// skills/crysk-ci-setup/references/opencode-ci.md
|
|
@@ -1908,7 +2004,7 @@ var opencode_ci_default = "./opencode-ci-7b0be64p.md";
|
|
|
1908
2004
|
var init_opencode_ci = () => {};
|
|
1909
2005
|
|
|
1910
2006
|
// skills/crysk-ci-setup/SKILL.md
|
|
1911
|
-
var SKILL_default2 = "./SKILL-
|
|
2007
|
+
var SKILL_default2 = "./SKILL-dsnffnfp.md";
|
|
1912
2008
|
var init_SKILL2 = () => {};
|
|
1913
2009
|
|
|
1914
2010
|
// skills/crysk-loop/adjudicator.md
|
|
@@ -1916,11 +2012,11 @@ var adjudicator_default = "./adjudicator-dtg2axnh.md";
|
|
|
1916
2012
|
var init_adjudicator = () => {};
|
|
1917
2013
|
|
|
1918
2014
|
// skills/crysk-loop/SKILL.md
|
|
1919
|
-
var SKILL_default3 = "./SKILL-
|
|
2015
|
+
var SKILL_default3 = "./SKILL-vws0aqb8.md";
|
|
1920
2016
|
var init_SKILL3 = () => {};
|
|
1921
2017
|
|
|
1922
2018
|
// skills/crysk-pr/SKILL.md
|
|
1923
|
-
var SKILL_default4 = "./SKILL-
|
|
2019
|
+
var SKILL_default4 = "./SKILL-qaqsbygw.md";
|
|
1924
2020
|
var init_SKILL4 = () => {};
|
|
1925
2021
|
|
|
1926
2022
|
// src/asset-manifest.ts
|
|
@@ -2002,7 +2098,7 @@ function resolveVersion() {
|
|
|
2002
2098
|
}
|
|
2003
2099
|
}
|
|
2004
2100
|
} catch {}
|
|
2005
|
-
return "0.
|
|
2101
|
+
return "0.4.0";
|
|
2006
2102
|
}
|
|
2007
2103
|
function resolveEngineAssets() {
|
|
2008
2104
|
const mode = detectAssetMode();
|
|
@@ -5583,18 +5679,36 @@ function latestStatusInContext(statuses, context) {
|
|
|
5583
5679
|
}
|
|
5584
5680
|
return latest;
|
|
5585
5681
|
}
|
|
5682
|
+
function manualReviewHoldDescription(label, sha) {
|
|
5683
|
+
return clipStatusDescription(`${STATUS_CONTEXT}: waiting for a manual review (${label}); carried from ${sha.slice(0, 7)} \u2014 /pr-hero review or /pr-hero override`);
|
|
5684
|
+
}
|
|
5685
|
+
function isManualReviewHold(status) {
|
|
5686
|
+
return status.state === "pending" && MANUAL_REVIEW_HOLD.test(status.description ?? "");
|
|
5687
|
+
}
|
|
5688
|
+
function heldVerdictSha(status) {
|
|
5689
|
+
if (!isManualReviewHold(status))
|
|
5690
|
+
return null;
|
|
5691
|
+
const description = status.description ?? "";
|
|
5692
|
+
const match = HELD_VERDICT.exec(description);
|
|
5693
|
+
if (match === null)
|
|
5694
|
+
return null;
|
|
5695
|
+
const [, label, sha] = match;
|
|
5696
|
+
return manualReviewHoldDescription(label, sha) === description ? sha : null;
|
|
5697
|
+
}
|
|
5586
5698
|
function isInFlightCommitStatus(statuses, nowMs, ttlMs = IN_FLIGHT_TTL_MS, contexts = [COMMIT_STATUS_CONTEXT]) {
|
|
5587
5699
|
return contexts.some((context) => {
|
|
5588
5700
|
const latest = latestStatusInContext(statuses, context);
|
|
5589
5701
|
if (latest === null || latest.state !== "pending")
|
|
5590
5702
|
return false;
|
|
5703
|
+
if (isManualReviewHold(latest))
|
|
5704
|
+
return false;
|
|
5591
5705
|
const createdMs = Date.parse(latest.created_at);
|
|
5592
5706
|
if (Number.isNaN(createdMs))
|
|
5593
5707
|
return false;
|
|
5594
5708
|
return nowMs - createdMs < ttlMs;
|
|
5595
5709
|
});
|
|
5596
5710
|
}
|
|
5597
|
-
var PR_COMMENT_MARKER_PREFIX, PR_REREVIEW_CLOSED_MARKER_PREFIX, PR_COMMENT_COVERAGE_PARTIAL_TOKEN = "coverage=partial", PR_FINDING_MARKER_PREFIX, COMMIT_STATUS_CONTEXT, LOCAL_COMMIT_STATUS_CONTEXT, RUN_STATUS_CONTEXTS, IN_FLIGHT_TTL_MS, COMMIT_STATUS_TIMEOUT_MS = 15000, CANCELLATION_COMMIT_STATUS_TIMEOUT_MS = 5000, COMMIT_STATUS_DESCRIPTION_MAX = 140;
|
|
5711
|
+
var PR_COMMENT_MARKER_PREFIX, PR_REREVIEW_CLOSED_MARKER_PREFIX, PR_COMMENT_COVERAGE_PARTIAL_TOKEN = "coverage=partial", PR_FINDING_MARKER_PREFIX, COMMIT_STATUS_CONTEXT, LOCAL_COMMIT_STATUS_CONTEXT, RUN_STATUS_CONTEXTS, IN_FLIGHT_TTL_MS, COMMIT_STATUS_TIMEOUT_MS = 15000, CANCELLATION_COMMIT_STATUS_TIMEOUT_MS = 5000, COMMIT_STATUS_DESCRIPTION_MAX = 140, MANUAL_REVIEW_HOLD, HELD_VERDICT;
|
|
5598
5712
|
var init_preflight2 = __esm(() => {
|
|
5599
5713
|
init_publish();
|
|
5600
5714
|
init_preflight();
|
|
@@ -5611,6 +5725,8 @@ var init_preflight2 = __esm(() => {
|
|
|
5611
5725
|
LOCAL_COMMIT_STATUS_CONTEXT
|
|
5612
5726
|
];
|
|
5613
5727
|
IN_FLIGHT_TTL_MS = 90 * 60 * 1000;
|
|
5728
|
+
MANUAL_REVIEW_HOLD = /^crysk: waiting for a manual review \(/;
|
|
5729
|
+
HELD_VERDICT = /^crysk: waiting for a manual review \((.+)\); carried from ([0-9a-f]{7}) \u2014 /;
|
|
5614
5730
|
});
|
|
5615
5731
|
|
|
5616
5732
|
// src/watch/preflight.ts
|
|
@@ -7700,6 +7816,7 @@ function applyWorsening(input) {
|
|
|
7700
7816
|
// src/review/report.ts
|
|
7701
7817
|
init_findings();
|
|
7702
7818
|
init_brand();
|
|
7819
|
+
init_published_text();
|
|
7703
7820
|
var USD_PER_AGENT_BASE = 1.2;
|
|
7704
7821
|
var USD_PER_CHANGED_LINE = 0.00021;
|
|
7705
7822
|
var USD_PER_FILE = 0.008;
|
|
@@ -7979,7 +8096,7 @@ function liveFindingLines(rereview) {
|
|
|
7979
8096
|
for (const row of listed) {
|
|
7980
8097
|
const loc = row.locs[0] ?? row.id;
|
|
7981
8098
|
const badge = row.sev === SEVERITY_UNRECOVERABLE ? "\u26A0\uFE0F severity unavailable" : severityEmoji(row.sev);
|
|
7982
|
-
out.push(`- \`${row.status}\` ${badge}
|
|
8099
|
+
out.push(`- \`${row.status}\` ${badge} ${code(loc)} \u2014 ${liveClaimText(row.claim)} (${row.id})`);
|
|
7983
8100
|
}
|
|
7984
8101
|
out.push("");
|
|
7985
8102
|
}
|
|
@@ -8116,7 +8233,7 @@ function refuterLabel(verdict) {
|
|
|
8116
8233
|
}
|
|
8117
8234
|
function findingLocationLine(finding, headSha, webUrl, linkLocation) {
|
|
8118
8235
|
const loc = code(`${finding.path}:${finding.line}`);
|
|
8119
|
-
const linked = linkLocation && webUrl !== undefined ? `[${loc}](${blobUrl(webUrl, headSha, finding.path, `L${finding.line}`)})` : loc;
|
|
8236
|
+
const linked = linkLocation && webUrl !== undefined && isLinkablePath(finding.path) ? `[${loc}](${blobUrl(webUrl, headSha, finding.path, `L${finding.line}`)})` : loc;
|
|
8120
8237
|
return typeof finding.symbol === "string" && finding.symbol.length > 0 ? `${linked} \u2014 ${oneLine(finding.symbol)}` : linked;
|
|
8121
8238
|
}
|
|
8122
8239
|
function tierExplanationLines(finding) {
|
|
@@ -8143,7 +8260,7 @@ function tierExplanationLines(finding) {
|
|
|
8143
8260
|
}
|
|
8144
8261
|
var MATERIALITY_REASON_MAX = 280;
|
|
8145
8262
|
function materialityReason(reason) {
|
|
8146
|
-
const flat = oneLine(reason)
|
|
8263
|
+
const flat = oneLine(reason);
|
|
8147
8264
|
return flat.length <= MATERIALITY_REASON_MAX ? flat : `${flat.slice(0, MATERIALITY_REASON_MAX - 1).trimEnd()}\u2026`;
|
|
8148
8265
|
}
|
|
8149
8266
|
function promptToFixBlock(finding) {
|
|
@@ -8152,7 +8269,7 @@ function promptToFixBlock(finding) {
|
|
|
8152
8269
|
"<details><summary>Prompt to fix with AI</summary>",
|
|
8153
8270
|
"",
|
|
8154
8271
|
"```",
|
|
8155
|
-
`Fix this issue in ${finding.path} at line ${finding.line}:`,
|
|
8272
|
+
`Fix this issue in ${oneLine(finding.path)} at line ${finding.line}:`,
|
|
8156
8273
|
"",
|
|
8157
8274
|
oneLine(finding.claim),
|
|
8158
8275
|
"```",
|
|
@@ -8261,7 +8378,7 @@ function renderRef(ref, headSha, webUrl) {
|
|
|
8261
8378
|
if (webUrl === undefined)
|
|
8262
8379
|
return code(ref);
|
|
8263
8380
|
const parsed = parseRefAnchor(ref);
|
|
8264
|
-
if (parsed === null)
|
|
8381
|
+
if (parsed === null || !isLinkablePath(parsed.path))
|
|
8265
8382
|
return code(ref);
|
|
8266
8383
|
const fragment = parsed.end === undefined ? `L${parsed.start}` : `L${parsed.start}-L${parsed.end}`;
|
|
8267
8384
|
const url = blobUrl(webUrl, headSha, parsed.path, fragment);
|
|
@@ -8286,8 +8403,14 @@ function parseRefAnchor(ref) {
|
|
|
8286
8403
|
prose: ref.trim().slice(anchor.length).trim()
|
|
8287
8404
|
};
|
|
8288
8405
|
}
|
|
8406
|
+
function isLinkablePath(path) {
|
|
8407
|
+
return redactSecrets(path) === path;
|
|
8408
|
+
}
|
|
8409
|
+
function encodeBlobPath(path) {
|
|
8410
|
+
return path.toWellFormed().split("/").map(encodeURIComponent).join("/").replaceAll("(", "%28").replaceAll(")", "%29");
|
|
8411
|
+
}
|
|
8289
8412
|
function blobUrl(webUrl, sha, path, fragment) {
|
|
8290
|
-
return `${webUrl}/blob/${sha}/${path}#${fragment}`;
|
|
8413
|
+
return `${webUrl}/blob/${sha}/${encodeBlobPath(path)}#${fragment}`;
|
|
8291
8414
|
}
|
|
8292
8415
|
function runLines(doc, meta) {
|
|
8293
8416
|
const { files, insertions, deletions } = meta.diffStat;
|
|
@@ -8427,7 +8550,7 @@ function code(text) {
|
|
|
8427
8550
|
return `\`${oneLine(text).replaceAll("`", "'")}\``;
|
|
8428
8551
|
}
|
|
8429
8552
|
function oneLine(text) {
|
|
8430
|
-
return text.replace(/\s+/g, " ").trim();
|
|
8553
|
+
return publishedText(text.replace(/\s+/g, " ").trim());
|
|
8431
8554
|
}
|
|
8432
8555
|
function usd(amount) {
|
|
8433
8556
|
return `$${amount.toFixed(2)}`;
|
|
@@ -8476,6 +8599,7 @@ function envelopeModel(options, agentFiles) {
|
|
|
8476
8599
|
|
|
8477
8600
|
// src/ci/reporter.ts
|
|
8478
8601
|
init_primitives();
|
|
8602
|
+
init_published_text();
|
|
8479
8603
|
function escapeData(value) {
|
|
8480
8604
|
return value.replaceAll("%", "%25").replaceAll("\r", "%0D").replaceAll(`
|
|
8481
8605
|
`, "%0A");
|
|
@@ -8519,7 +8643,7 @@ function severityRank2(severity) {
|
|
|
8519
8643
|
}
|
|
8520
8644
|
}
|
|
8521
8645
|
function oneLine2(text) {
|
|
8522
|
-
return text.replace(/\s+/g, " ").trim();
|
|
8646
|
+
return publishedText(text.replace(/\s+/g, " ").trim());
|
|
8523
8647
|
}
|
|
8524
8648
|
function groupFindingsByPath(findings) {
|
|
8525
8649
|
const sorted = [...findings].sort((a, b) => {
|
|
@@ -8541,8 +8665,8 @@ function groupFindingsByPath(findings) {
|
|
|
8541
8665
|
return groups;
|
|
8542
8666
|
}
|
|
8543
8667
|
function findingLine(finding, headSha, webUrl) {
|
|
8544
|
-
const loc = `${finding.path}:${finding.line}
|
|
8545
|
-
const linked = webUrl === undefined ?
|
|
8668
|
+
const loc = code(`${finding.path}:${finding.line}`);
|
|
8669
|
+
const linked = webUrl === undefined || !isLinkablePath(finding.path) ? loc : `[${loc}](${blobUrl(webUrl, headSha, finding.path, `L${finding.line}`)})`;
|
|
8546
8670
|
return `- ${severityEmoji(finding.severity)} ${finding.severity} \xB7 ` + `${finding.tier} \u2014 ${linked} \u2014 ${oneLine2(finding.claim)}`;
|
|
8547
8671
|
}
|
|
8548
8672
|
function formatDeltaLine(delta) {
|
|
@@ -8656,7 +8780,7 @@ function manualRequiredLines(data) {
|
|
|
8656
8780
|
return [
|
|
8657
8781
|
`### \u23F9\uFE0F Crysk Review \u2014 Automatic Reviews Done \u2014 PR #${data.prNumber}`,
|
|
8658
8782
|
"",
|
|
8659
|
-
"**Reason:** no automatic review is left for this pull request; the gate keeps
|
|
8783
|
+
"**Reason:** no automatic review is left for this pull request; the gate keeps a red verdict and holds a green one `pending` for a manual review (`/crysk review` or `/crysk override`).",
|
|
8660
8784
|
"",
|
|
8661
8785
|
"| Metric | Value |",
|
|
8662
8786
|
"| --- | --- |",
|
|
@@ -8687,7 +8811,7 @@ function reviewedLines(data) {
|
|
|
8687
8811
|
} else {
|
|
8688
8812
|
out.push("#### Findings", "");
|
|
8689
8813
|
for (const [filePath, group] of groupFindingsByPath(data.findings)) {
|
|
8690
|
-
out.push(
|
|
8814
|
+
out.push(`**${code(filePath)}**`);
|
|
8691
8815
|
for (const finding of group) {
|
|
8692
8816
|
out.push(findingLine(finding, data.headSha, data.repoWebUrl));
|
|
8693
8817
|
}
|
|
@@ -9053,8 +9177,9 @@ function ciReviewPolicyHash(policy) {
|
|
|
9053
9177
|
}
|
|
9054
9178
|
function resolveCiTrustedActors(input) {
|
|
9055
9179
|
const actors = new Set;
|
|
9056
|
-
|
|
9057
|
-
|
|
9180
|
+
for (const login of [input.githubActor, input.platformActor]) {
|
|
9181
|
+
if (login !== undefined && login.length > 0)
|
|
9182
|
+
actors.add(login);
|
|
9058
9183
|
}
|
|
9059
9184
|
for (const login of input.extra ?? []) {
|
|
9060
9185
|
if (login.length > 0)
|
|
@@ -9513,6 +9638,7 @@ function ciReviewManualRequiredDetail(verdict) {
|
|
|
9513
9638
|
}
|
|
9514
9639
|
|
|
9515
9640
|
// src/ci/gates.ts
|
|
9641
|
+
init_trigger();
|
|
9516
9642
|
function usd3(amount) {
|
|
9517
9643
|
return `$${amount.toFixed(2)}`;
|
|
9518
9644
|
}
|
|
@@ -9736,7 +9862,7 @@ function buildManualRequiredComment(data) {
|
|
|
9736
9862
|
"",
|
|
9737
9863
|
...rules,
|
|
9738
9864
|
"",
|
|
9739
|
-
"What the gate does with the next pushes: it
|
|
9865
|
+
"What the gate does with the next pushes: no review reads them, so it never turns green on its own. " + "A red verdict stays red while a blocking finding is unanswered. A green verdict, or a red one whose " + "blocking findings all have a reply from someone with write access (`applied`, or a `dismissed` the " + "CI adjudicator upheld), waits as `pending` until a review verifies the head or " + `${commandHint(OVERRIDE_COMMAND)} merges it unverified. Reply before you push: the gate reads the ` + "replies when the push arrives.",
|
|
9740
9866
|
"",
|
|
9741
9867
|
"The existing review comment still describes the last head Crysk reviewed.",
|
|
9742
9868
|
"",
|
|
@@ -10034,13 +10160,6 @@ function postingLine(value) {
|
|
|
10034
10160
|
}
|
|
10035
10161
|
|
|
10036
10162
|
// src/ci/setup.ts
|
|
10037
|
-
init_trigger();
|
|
10038
|
-
init_preflight();
|
|
10039
|
-
init_brand();
|
|
10040
|
-
init_brand_paths();
|
|
10041
|
-
init_errors();
|
|
10042
|
-
init_home_preflight();
|
|
10043
|
-
init_ignore_file();
|
|
10044
10163
|
import { existsSync as existsSync9 } from "fs";
|
|
10045
10164
|
import {
|
|
10046
10165
|
chmod,
|
|
@@ -10052,6 +10171,23 @@ import {
|
|
|
10052
10171
|
} from "fs/promises";
|
|
10053
10172
|
import path14 from "path";
|
|
10054
10173
|
|
|
10174
|
+
// src/ci/platform.ts
|
|
10175
|
+
if (false) {}
|
|
10176
|
+
|
|
10177
|
+
// src/ci/platform-config.ts
|
|
10178
|
+
init_preflight();
|
|
10179
|
+
init_brand_paths();
|
|
10180
|
+
|
|
10181
|
+
// src/ci/setup.ts
|
|
10182
|
+
init_trigger();
|
|
10183
|
+
init_git();
|
|
10184
|
+
init_preflight();
|
|
10185
|
+
init_brand();
|
|
10186
|
+
init_brand_paths();
|
|
10187
|
+
init_errors();
|
|
10188
|
+
init_home_preflight();
|
|
10189
|
+
init_ignore_file();
|
|
10190
|
+
|
|
10055
10191
|
// src/security/credential-broker.ts
|
|
10056
10192
|
import { randomUUID } from "crypto";
|
|
10057
10193
|
import {
|
|
@@ -12366,6 +12502,7 @@ init_preflight2();
|
|
|
12366
12502
|
init_findings();
|
|
12367
12503
|
init_materiality_gate();
|
|
12368
12504
|
init_brand();
|
|
12505
|
+
init_published_text();
|
|
12369
12506
|
var PR_STATE_MARKER_PREFIX = `${MARKER_OPEN}state `;
|
|
12370
12507
|
var GITHUB_ISSUE_COMMENT_MAX = 65536;
|
|
12371
12508
|
var STATE_HEADER = new RegExp(`^<!-- ${MARKER_BRAND_PATTERN}-state v=1 head=([0-9a-f]{40}) -->`);
|
|
@@ -12421,7 +12558,7 @@ function renderStateBlock(headSha, findings, reviews, hw) {
|
|
|
12421
12558
|
channel: f.channel,
|
|
12422
12559
|
locs: f.locs,
|
|
12423
12560
|
c: f.c,
|
|
12424
|
-
claim: f.claim
|
|
12561
|
+
claim: redactSecrets(f.claim)
|
|
12425
12562
|
}))
|
|
12426
12563
|
};
|
|
12427
12564
|
if (reviews !== undefined && Number.isInteger(reviews) && reviews >= 1) {
|
|
@@ -12502,7 +12639,7 @@ function lastEvictableIndex(entries, status, protectedIds) {
|
|
|
12502
12639
|
return -1;
|
|
12503
12640
|
}
|
|
12504
12641
|
function encodeStateJson(value) {
|
|
12505
|
-
return JSON.stringify(value).replaceAll("\u2028", "\\u2028").replaceAll("\u2029", "\\u2029").replaceAll("
|
|
12642
|
+
return JSON.stringify(value).replaceAll("\u2028", "\\u2028").replaceAll("\u2029", "\\u2029").replaceAll("<", "\\u003c").replaceAll(">", "\\u003e");
|
|
12506
12643
|
}
|
|
12507
12644
|
function asStateFindings(parsed) {
|
|
12508
12645
|
if (typeof parsed !== "object" || parsed === null)
|
|
@@ -12616,7 +12753,7 @@ function assembleLive(input) {
|
|
|
12616
12753
|
tier: gatePrior.tier,
|
|
12617
12754
|
channel: gatePrior.channel,
|
|
12618
12755
|
locs: row.locs,
|
|
12619
|
-
c: liveFingerprint(gatePrior.id, gatePrior.claim),
|
|
12756
|
+
c: gatePrior.c ?? liveFingerprint(gatePrior.id, gatePrior.claim),
|
|
12620
12757
|
claim: gatePrior.claim,
|
|
12621
12758
|
status: persisted
|
|
12622
12759
|
});
|
|
@@ -12709,7 +12846,7 @@ function gatePairing(survivors, rows) {
|
|
|
12709
12846
|
}
|
|
12710
12847
|
function isReleasable(row) {
|
|
12711
12848
|
const claim = row?.claim;
|
|
12712
|
-
if (row === undefined || claim === undefined || claim.trim().length === 0) {
|
|
12849
|
+
if (row === undefined || claim === undefined || claim.trim().length === 0 || wasRedacted(claim)) {
|
|
12713
12850
|
return false;
|
|
12714
12851
|
}
|
|
12715
12852
|
const paths = [...identityFromLocs(row.locs).keys()];
|
|
@@ -12767,6 +12904,9 @@ function mergeStateFindings(input) {
|
|
|
12767
12904
|
}
|
|
12768
12905
|
}
|
|
12769
12906
|
const touched = new Set;
|
|
12907
|
+
const freshIds = input.fresh.map(() => {
|
|
12908
|
+
return;
|
|
12909
|
+
});
|
|
12770
12910
|
const pairs = pairBlockingSurvivors(input.fresh, rows.map((row) => ({ tier: row.tier, locs: row.locs })));
|
|
12771
12911
|
const rowOfSurvivor = new Map(pairs.map((p) => [p.survivor, p.row]));
|
|
12772
12912
|
const takenRows = new Set(pairs.map((p) => p.row));
|
|
@@ -12801,6 +12941,7 @@ function mergeStateFindings(input) {
|
|
|
12801
12941
|
status: prior.status
|
|
12802
12942
|
};
|
|
12803
12943
|
touched.add(prior.id);
|
|
12944
|
+
freshIds[s] = prior.id;
|
|
12804
12945
|
continue;
|
|
12805
12946
|
}
|
|
12806
12947
|
hw += 1;
|
|
@@ -12817,6 +12958,7 @@ function mergeStateFindings(input) {
|
|
|
12817
12958
|
status: "unconfirmed"
|
|
12818
12959
|
});
|
|
12819
12960
|
touched.add(id);
|
|
12961
|
+
freshIds[s] = id;
|
|
12820
12962
|
}
|
|
12821
12963
|
const capped = capLiveFindings(rows, "", input.headSha, input.stateBudget, {
|
|
12822
12964
|
reviews: input.reviews,
|
|
@@ -12826,7 +12968,8 @@ function mergeStateFindings(input) {
|
|
|
12826
12968
|
return {
|
|
12827
12969
|
rows: capped.kept,
|
|
12828
12970
|
hw,
|
|
12829
|
-
dropped: capped.droppedUnconfirmed + capped.droppedCarried
|
|
12971
|
+
dropped: capped.droppedUnconfirmed + capped.droppedCarried,
|
|
12972
|
+
freshIds
|
|
12830
12973
|
};
|
|
12831
12974
|
}
|
|
12832
12975
|
function droppedStateNote(count) {
|
|
@@ -29526,7 +29669,7 @@ var PRHERO_GITHUB_REPO = "cryskai/crysk";
|
|
|
29526
29669
|
function detectInstallMethod(options = {}) {
|
|
29527
29670
|
const home = options.home ?? os14.homedir();
|
|
29528
29671
|
const execPath = options.execPath ?? process.execPath;
|
|
29529
|
-
const version = options.version ?? "0.
|
|
29672
|
+
const version = options.version ?? "0.4.0";
|
|
29530
29673
|
const exists = options.exists ?? existsSync25;
|
|
29531
29674
|
const isSource = options.isDev !== undefined ? options.isDev : version === "dev" || exists("./src/cli.ts") && !execPath.includes(".crysk/bin") && !execPath.includes(".prhero/bin");
|
|
29532
29675
|
if (isSource) {
|
|
@@ -30515,11 +30658,11 @@ init_git();
|
|
|
30515
30658
|
// src/review/review.ts
|
|
30516
30659
|
import { existsSync as existsSync32 } from "fs";
|
|
30517
30660
|
import os20 from "os";
|
|
30518
|
-
import
|
|
30661
|
+
import path53 from "path";
|
|
30519
30662
|
init_git();
|
|
30520
30663
|
|
|
30521
30664
|
// src/pr/review-pr.ts
|
|
30522
|
-
import
|
|
30665
|
+
import path52 from "path";
|
|
30523
30666
|
|
|
30524
30667
|
// src/ci/cli-record.ts
|
|
30525
30668
|
init_outcome();
|
|
@@ -30678,7 +30821,7 @@ init_override();
|
|
|
30678
30821
|
// src/pr/pr.ts
|
|
30679
30822
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
30680
30823
|
import { existsSync as existsSync27 } from "fs";
|
|
30681
|
-
import
|
|
30824
|
+
import path46 from "path";
|
|
30682
30825
|
|
|
30683
30826
|
// src/pr/reverts-preflight.ts
|
|
30684
30827
|
init_errors();
|
|
@@ -32454,6 +32597,7 @@ function priorsFromStateFindings(findings) {
|
|
|
32454
32597
|
channel: finding.channel,
|
|
32455
32598
|
locs: finding.locs,
|
|
32456
32599
|
claim: finding.claim,
|
|
32600
|
+
c: finding.c,
|
|
32457
32601
|
triage: null,
|
|
32458
32602
|
newThreadReply: false
|
|
32459
32603
|
}));
|
|
@@ -32461,6 +32605,7 @@ function priorsFromStateFindings(findings) {
|
|
|
32461
32605
|
function priorsFromPostedMarkers(posted) {
|
|
32462
32606
|
return posted.map((item, i) => {
|
|
32463
32607
|
const recovered = parseFindingCommentBadge(item.body);
|
|
32608
|
+
const c = recovered === null ? undefined : parseFindingMarker(item.body)?.c;
|
|
32464
32609
|
return {
|
|
32465
32610
|
id: `R${String(i + 1).padStart(3, "0")}`,
|
|
32466
32611
|
sev: recovered?.sev ?? SEVERITY_UNRECOVERABLE,
|
|
@@ -32468,6 +32613,7 @@ function priorsFromPostedMarkers(posted) {
|
|
|
32468
32613
|
channel: item.channel,
|
|
32469
32614
|
locs: [`${item.path}:${item.line}`],
|
|
32470
32615
|
claim: recovered?.claim ?? "",
|
|
32616
|
+
...c === undefined ? {} : { c },
|
|
32471
32617
|
triage: null,
|
|
32472
32618
|
newThreadReply: false
|
|
32473
32619
|
};
|
|
@@ -32483,7 +32629,12 @@ function bindPriorsToPosted(priors, posted, window = IDENTITY_LINE_WINDOW) {
|
|
|
32483
32629
|
const distance = anchorDistance(identity, row, window);
|
|
32484
32630
|
if (distance === null)
|
|
32485
32631
|
continue;
|
|
32486
|
-
pairs.push({
|
|
32632
|
+
pairs.push({
|
|
32633
|
+
priorId: prior.id,
|
|
32634
|
+
fingerprint: priorFingerprint(prior),
|
|
32635
|
+
row,
|
|
32636
|
+
distance
|
|
32637
|
+
});
|
|
32487
32638
|
}
|
|
32488
32639
|
}
|
|
32489
32640
|
const bound = new Map;
|
|
@@ -32507,7 +32658,7 @@ function bindPriorsToPosted(priors, posted, window = IDENTITY_LINE_WINDOW) {
|
|
|
32507
32658
|
let changed = false;
|
|
32508
32659
|
const proposals = [];
|
|
32509
32660
|
for (const [priorId, group] of byPrior) {
|
|
32510
|
-
const winner = resolvePriorTie(group, group[0]?.
|
|
32661
|
+
const winner = resolvePriorTie(group, group[0]?.fingerprint);
|
|
32511
32662
|
if (winner === undefined) {
|
|
32512
32663
|
disqualified.add(priorId);
|
|
32513
32664
|
changed = true;
|
|
@@ -32562,19 +32713,23 @@ function anchorDistance(identity, row, window) {
|
|
|
32562
32713
|
}
|
|
32563
32714
|
return best;
|
|
32564
32715
|
}
|
|
32565
|
-
function
|
|
32716
|
+
function priorFingerprint(prior) {
|
|
32717
|
+
if (prior.claim.trim().length === 0)
|
|
32718
|
+
return;
|
|
32719
|
+
return prior.c ?? claimFingerprint(prior.claim);
|
|
32720
|
+
}
|
|
32721
|
+
function resolvePriorTie(tied, fingerprint) {
|
|
32566
32722
|
if (tied.length === 1)
|
|
32567
32723
|
return tied[0]?.row;
|
|
32568
|
-
if (
|
|
32724
|
+
if (fingerprint === undefined)
|
|
32569
32725
|
return;
|
|
32570
|
-
const fingerprint = claimFingerprint(claim);
|
|
32571
32726
|
const matching = tied.filter((c) => c.row.marker.c === fingerprint);
|
|
32572
32727
|
return matching.length === 1 ? matching[0]?.row : undefined;
|
|
32573
32728
|
}
|
|
32574
32729
|
function resolveRowTie(contenders) {
|
|
32575
32730
|
if (contenders.length === 1)
|
|
32576
32731
|
return contenders[0];
|
|
32577
|
-
const matching = contenders.filter((contender) => contender.
|
|
32732
|
+
const matching = contenders.filter((contender) => contender.fingerprint !== undefined && contender.row.marker.c === contender.fingerprint);
|
|
32578
32733
|
return matching.length === 1 ? matching[0] : undefined;
|
|
32579
32734
|
}
|
|
32580
32735
|
function adjudicationQueue(priors) {
|
|
@@ -32665,6 +32820,32 @@ init_preflight3();
|
|
|
32665
32820
|
init_brand();
|
|
32666
32821
|
init_errors();
|
|
32667
32822
|
|
|
32823
|
+
// src/pr/finding-state-record.ts
|
|
32824
|
+
import { writeFileSync as writeFileSync9 } from "fs";
|
|
32825
|
+
import path45 from "path";
|
|
32826
|
+
var FINDING_STATE_FILE = "finding-state.json";
|
|
32827
|
+
function buildFindingStateRecord(input) {
|
|
32828
|
+
const fresh = {};
|
|
32829
|
+
input.freshFindingIds.forEach((findingId, index) => {
|
|
32830
|
+
const stable = input.freshIds[index];
|
|
32831
|
+
if (stable !== undefined)
|
|
32832
|
+
fresh[findingId] = stable;
|
|
32833
|
+
});
|
|
32834
|
+
return {
|
|
32835
|
+
open: input.rows.map(({ id, status, tier }) => ({ id, status, tier })),
|
|
32836
|
+
fresh,
|
|
32837
|
+
resolved: [...input.resolvedIds],
|
|
32838
|
+
superseded: [...input.supersededIds],
|
|
32839
|
+
dropped: input.dropped
|
|
32840
|
+
};
|
|
32841
|
+
}
|
|
32842
|
+
function writeFindingStateRecord(runDir, record) {
|
|
32843
|
+
try {
|
|
32844
|
+
writeFileSync9(path45.join(runDir, FINDING_STATE_FILE), `${JSON.stringify(record)}
|
|
32845
|
+
`);
|
|
32846
|
+
} catch {}
|
|
32847
|
+
}
|
|
32848
|
+
|
|
32668
32849
|
// src/pr/inline.ts
|
|
32669
32850
|
init_size_gate();
|
|
32670
32851
|
init_preflight2();
|
|
@@ -33410,7 +33591,7 @@ function is422(stderr) {
|
|
|
33410
33591
|
function is404(stderr) {
|
|
33411
33592
|
return /\(HTTP 404\)/.test(stderr);
|
|
33412
33593
|
}
|
|
33413
|
-
var PR_ISSUE_COMMENTS_QUERY = "query($repoOwner:String!,$repoName:String!,$number:Int!,$cursor:String){" + "repository(owner:$repoOwner,name:$repoName){pullRequest(number:$number){" + "comments(first:100,after:$cursor){" + "pageInfo{endCursor hasNextPage}" + "nodes{databaseId body createdAt updatedAt author{login}}}}}}";
|
|
33594
|
+
var PR_ISSUE_COMMENTS_QUERY = "query($repoOwner:String!,$repoName:String!,$number:Int!,$cursor:String){" + "repository(owner:$repoOwner,name:$repoName){pullRequest(number:$number){" + "comments(first:100,after:$cursor){" + "pageInfo{endCursor hasNextPage}" + "nodes{databaseId body createdAt updatedAt author{login __typename}}}}}}";
|
|
33414
33595
|
var PR_REVIEW_COMMENTS_QUERY = "query($repoOwner:String!,$repoName:String!,$number:Int!,$cursor:String){" + "repository(owner:$repoOwner,name:$repoName){pullRequest(number:$number){" + `reviewThreads(first:${THREAD_PAGE_SIZE},after:$cursor){` + "pageInfo{endCursor hasNextPage}" + "nodes{comments(first:100){nodes{" + "fullDatabaseId body createdAt author{login __typename} path line originalLine " + "replyTo{fullDatabaseId}}}}}}}}";
|
|
33415
33596
|
var COMPARE_CHANGED_FILE_STATUSES = new Set([
|
|
33416
33597
|
"added",
|
|
@@ -33569,7 +33750,7 @@ function issueCommentsFromNodes(nodes) {
|
|
|
33569
33750
|
continue;
|
|
33570
33751
|
comments.push({
|
|
33571
33752
|
id,
|
|
33572
|
-
user:
|
|
33753
|
+
user: graphqlReviewLogin(record.author),
|
|
33573
33754
|
body: typeof record.body === "string" ? record.body : "",
|
|
33574
33755
|
...typeof record.createdAt === "string" ? { created_at: record.createdAt } : {},
|
|
33575
33756
|
...typeof record.updatedAt === "string" ? { updated_at: record.updatedAt } : {}
|
|
@@ -34185,21 +34366,23 @@ async function postInlineFindings(input) {
|
|
|
34185
34366
|
channel: freshChannel(f.id)
|
|
34186
34367
|
}));
|
|
34187
34368
|
const referenceBody = renderPrComment(postedDoc, webUrl, overlayDelta({ ...plan.delta, previousHeadSha }), plannedOutsideDiff, undefined, undefined, input.ciMode, undefined, notPosted);
|
|
34188
|
-
const
|
|
34369
|
+
const stateFramed = framing !== undefined || input.rereview === undefined && (existingSummaryId === null || previousState?.headSha === doc.head_sha);
|
|
34370
|
+
const mergeStateWithBudget = (stateBudget) => !stateFramed ? undefined : mergeStateFindings({
|
|
34189
34371
|
headSha: doc.head_sha,
|
|
34190
34372
|
reviews: postedReviewCount,
|
|
34191
|
-
live: framing
|
|
34373
|
+
live: framing?.live ?? [],
|
|
34192
34374
|
previous: previousState,
|
|
34193
34375
|
previousHead: previousState?.headSha ?? null,
|
|
34194
34376
|
retiredIds: [
|
|
34195
|
-
...framing
|
|
34196
|
-
...(framing
|
|
34377
|
+
...framing?.resolved_ids ?? [],
|
|
34378
|
+
...(framing?.worsened ?? []).map((w) => w.priorId)
|
|
34197
34379
|
],
|
|
34198
|
-
...
|
|
34380
|
+
...framing?.materiality_released_ids === undefined ? {} : { releasedIds: framing.materiality_released_ids },
|
|
34199
34381
|
fresh: freshFindings,
|
|
34200
34382
|
stateBudget
|
|
34201
34383
|
});
|
|
34202
34384
|
const merged = mergeStateWithBudget(stateBlockBudget(referenceBody.length));
|
|
34385
|
+
let writtenState = merged;
|
|
34203
34386
|
const renderWithState = (delta, outside, moved, urls, state, compactFrom) => {
|
|
34204
34387
|
const body = renderPrComment(postedDoc, webUrl, overlayDelta(delta), outside, moved, urls, input.ciMode, compactFrom, notPosted);
|
|
34205
34388
|
const counts = tierCountsFromFindings(canonicalAdmissionFindings(postedDoc.findings));
|
|
@@ -34276,6 +34459,7 @@ async function postInlineFindings(input) {
|
|
|
34276
34459
|
const bodyWithoutState = renderPatch(undefined, 0);
|
|
34277
34460
|
const reMerged = mergeStateWithBudget(stateBlockBudget(bodyWithoutState.length));
|
|
34278
34461
|
patchBody = renderPatch(reMerged, 0);
|
|
34462
|
+
writtenState = reMerged;
|
|
34279
34463
|
}
|
|
34280
34464
|
if (patchBody.length > GITHUB_ISSUE_COMMENT_MAX) {
|
|
34281
34465
|
process.stdout.write(`::warning::crysk: the summary is ${patchBody.length} characters, over GitHub's ${GITHUB_ISSUE_COMMENT_MAX}-character comment limit even with every Outside Diff entry compacted; sending it as is
|
|
@@ -34367,7 +34551,17 @@ async function postInlineFindings(input) {
|
|
|
34367
34551
|
droppedFindingIds,
|
|
34368
34552
|
commentUrls: commentUrlByFindingId,
|
|
34369
34553
|
movedHeadSha,
|
|
34370
|
-
...closingCommentId === undefined ? {} : { closingCommentId }
|
|
34554
|
+
...closingCommentId === undefined ? {} : { closingCommentId },
|
|
34555
|
+
...writtenState === undefined ? {} : {
|
|
34556
|
+
findingState: buildFindingStateRecord({
|
|
34557
|
+
rows: writtenState.rows,
|
|
34558
|
+
freshFindingIds: postedDoc.findings.map((f) => f.id),
|
|
34559
|
+
freshIds: writtenState.freshIds,
|
|
34560
|
+
resolvedIds: framing?.resolved_ids ?? [],
|
|
34561
|
+
supersededIds: (framing?.worsened ?? []).map((w) => w.priorId),
|
|
34562
|
+
dropped: writtenState.dropped
|
|
34563
|
+
})
|
|
34564
|
+
}
|
|
34371
34565
|
};
|
|
34372
34566
|
}
|
|
34373
34567
|
async function buildCommentUrlMap(input) {
|
|
@@ -34420,7 +34614,7 @@ async function writePostReceipt(runDir, pr, headSha, outcome) {
|
|
|
34420
34614
|
delta: outcome.delta,
|
|
34421
34615
|
dropped_finding_ids: outcome.droppedFindingIds
|
|
34422
34616
|
};
|
|
34423
|
-
await Bun.write(
|
|
34617
|
+
await Bun.write(path46.join(runDir, "post.json"), `${JSON.stringify(receipt, null, 2)}
|
|
34424
34618
|
`);
|
|
34425
34619
|
}
|
|
34426
34620
|
|
|
@@ -34581,6 +34775,9 @@ async function recordCiAdmissionGateSkip(input) {
|
|
|
34581
34775
|
function isCarriedReason(reason) {
|
|
34582
34776
|
return reason !== "same-head";
|
|
34583
34777
|
}
|
|
34778
|
+
function holdsForManualReview(reason) {
|
|
34779
|
+
return reason === "max-attempts-exhausted" || reason === "manual-only-policy";
|
|
34780
|
+
}
|
|
34584
34781
|
var BLOCKING_COUNT = /^crysk: (\d+) blocking finding\(s\)/;
|
|
34585
34782
|
function blockingCountIn(description) {
|
|
34586
34783
|
const match = BLOCKING_COUNT.exec(canonicalStatusText(description ?? ""));
|
|
@@ -34716,6 +34913,12 @@ function admissionSkipDecision(input) {
|
|
|
34716
34913
|
if (verdict === undefined)
|
|
34717
34914
|
return failClosed(label);
|
|
34718
34915
|
if (verdict.state === "success") {
|
|
34916
|
+
if (holdsForManualReview(input.reason)) {
|
|
34917
|
+
return {
|
|
34918
|
+
state: "pending",
|
|
34919
|
+
description: manualReviewHoldDescription(label, input.carried.sha)
|
|
34920
|
+
};
|
|
34921
|
+
}
|
|
34719
34922
|
const answeredCount = answeredCountIn(verdict.description ?? "");
|
|
34720
34923
|
return {
|
|
34721
34924
|
state: "success",
|
|
@@ -34734,6 +34937,12 @@ function admissionSkipDecision(input) {
|
|
|
34734
34937
|
return failClosed(label);
|
|
34735
34938
|
const answered = input.answered ?? null;
|
|
34736
34939
|
if (answered !== null && answered.open === 0 && answered.blocking > 0 && answered.blocking >= blocking) {
|
|
34940
|
+
if (holdsForManualReview(input.reason)) {
|
|
34941
|
+
return {
|
|
34942
|
+
state: "pending",
|
|
34943
|
+
description: manualReviewHoldDescription(label, input.carried.sha)
|
|
34944
|
+
};
|
|
34945
|
+
}
|
|
34737
34946
|
return {
|
|
34738
34947
|
state: "success",
|
|
34739
34948
|
description: unverifiedFixesDescription(answered.blocking, label, input.carried.sha)
|
|
@@ -34764,18 +34973,35 @@ async function findCarriedVerdict(input) {
|
|
|
34764
34973
|
const headIndex = shas.indexOf(input.headSha);
|
|
34765
34974
|
if (headIndex < 0)
|
|
34766
34975
|
return null;
|
|
34767
|
-
|
|
34768
|
-
|
|
34769
|
-
|
|
34770
|
-
|
|
34771
|
-
|
|
34772
|
-
|
|
34976
|
+
let end = headIndex;
|
|
34977
|
+
walk:
|
|
34978
|
+
while (true) {
|
|
34979
|
+
const earlier = shas.slice(0, end).reverse().slice(0, CARRY_WALK_CAP);
|
|
34980
|
+
for (const sha of earlier) {
|
|
34981
|
+
const statuses = await input.readStatuses(input.operatorRoot, sha, {
|
|
34982
|
+
spawnFn: input.spawnFn
|
|
34983
|
+
});
|
|
34984
|
+
if (statuses === null)
|
|
34985
|
+
return null;
|
|
34986
|
+
if (newestCarriedVerdict(statuses) !== undefined) {
|
|
34987
|
+
return {
|
|
34988
|
+
sha,
|
|
34989
|
+
statuses,
|
|
34990
|
+
older: earlier.slice(earlier.indexOf(sha) + 1)
|
|
34991
|
+
};
|
|
34992
|
+
}
|
|
34993
|
+
const newest = newestStatusInContext(statuses, COMMIT_STATUS_CONTEXT);
|
|
34994
|
+
const held = newest === undefined ? null : heldVerdictSha(newest);
|
|
34995
|
+
if (held !== null) {
|
|
34996
|
+
const target = shas.findIndex((s) => s.startsWith(held));
|
|
34997
|
+
if (target >= 0 && target < shas.indexOf(sha)) {
|
|
34998
|
+
end = target + 1;
|
|
34999
|
+
continue walk;
|
|
35000
|
+
}
|
|
35001
|
+
}
|
|
35002
|
+
}
|
|
34773
35003
|
return null;
|
|
34774
|
-
if (newestCarriedVerdict(statuses) !== undefined) {
|
|
34775
|
-
return { sha, statuses, older: earlier.slice(earlier.indexOf(sha) + 1) };
|
|
34776
35004
|
}
|
|
34777
|
-
}
|
|
34778
|
-
return null;
|
|
34779
35005
|
}
|
|
34780
35006
|
async function overrideStandsOnHead(input) {
|
|
34781
35007
|
let statuses;
|
|
@@ -35188,6 +35414,12 @@ function upheldDismissal(a) {
|
|
|
35188
35414
|
function decideNext(gate, analyzed, head, summary) {
|
|
35189
35415
|
const liveBlocking = analyzed.filter((a) => a.finding.blocking && a.finding.live_on_head);
|
|
35190
35416
|
if (gate.state === "pending") {
|
|
35417
|
+
if (isManualReviewHold({ state: gate.state, description: gate.description })) {
|
|
35418
|
+
return {
|
|
35419
|
+
next_action: "override-or-fix",
|
|
35420
|
+
reason: `The gate holds this head for a manual review: the automatic review budget is used up, or the review policy is manual (ci_review_policy is manual_only), so no review read it and none will on its own. Comment ${commandHint(REVIEW_COMMAND, "")} to verify it, or ${commandHint(OVERRIDE_COMMAND, "")} to merge it unverified.`
|
|
35421
|
+
};
|
|
35422
|
+
}
|
|
35191
35423
|
if (gate.pending_in_flight) {
|
|
35192
35424
|
return {
|
|
35193
35425
|
next_action: "wait",
|
|
@@ -35212,10 +35444,12 @@ function decideNext(gate, analyzed, head, summary) {
|
|
|
35212
35444
|
};
|
|
35213
35445
|
}
|
|
35214
35446
|
if (gate.state === "success") {
|
|
35447
|
+
const summaryOnly = analyzed.filter((a) => a.finding.comment_id === null).length;
|
|
35448
|
+
const summaryNote = summaryOnly === 0 ? "" : ` ${summaryOnly} finding(s) live only in the summary comment (outside the diff, no thread to reply in); read them there before merging.`;
|
|
35215
35449
|
if (gate.override.active) {
|
|
35216
35450
|
return {
|
|
35217
35451
|
next_action: "done",
|
|
35218
|
-
reason: `The gate is green through an override by @${gate.override.by ?? "an unknown login"}; nothing is owed on this head
|
|
35452
|
+
reason: `The gate is green through an override by @${gate.override.by ?? "an unknown login"}; nothing is owed on this head.${summaryNote}`
|
|
35219
35453
|
};
|
|
35220
35454
|
}
|
|
35221
35455
|
if (summary.head === head && summary.complete === false) {
|
|
@@ -35234,18 +35468,18 @@ function decideNext(gate, analyzed, head, summary) {
|
|
|
35234
35468
|
if (UNVERIFIED_FIXES_GATE.test(canonicalStatusText(gate.description ?? ""))) {
|
|
35235
35469
|
return {
|
|
35236
35470
|
next_action: "done",
|
|
35237
|
-
reason: `The gate is green on answered findings no review verified (${gate.description}); the PR is ready to merge, or comment ${commandHint(REVIEW_COMMAND, "")} for another review
|
|
35471
|
+
reason: `The gate is green on answered findings no review verified (${gate.description}); the PR is ready to merge, or comment ${commandHint(REVIEW_COMMAND, "")} for another review.${summaryNote}`
|
|
35238
35472
|
};
|
|
35239
35473
|
}
|
|
35240
35474
|
if (NOTHING_TO_REVIEW_GATE.test(canonicalStatusText(gate.description ?? ""))) {
|
|
35241
35475
|
return {
|
|
35242
35476
|
next_action: "done",
|
|
35243
|
-
reason:
|
|
35477
|
+
reason: `Every changed file on this head is excluded from review, so there was nothing to review; nothing is owed.${summaryNote}`
|
|
35244
35478
|
};
|
|
35245
35479
|
}
|
|
35246
35480
|
return {
|
|
35247
35481
|
next_action: "done",
|
|
35248
|
-
reason:
|
|
35482
|
+
reason: `The review on this head passed the gate, and every finding on this head has a reply.${summaryNote}`
|
|
35249
35483
|
};
|
|
35250
35484
|
}
|
|
35251
35485
|
if (REVIEW_TRIGGER_GATE.test(canonicalStatusText(gate.description ?? ""))) {
|
|
@@ -35277,7 +35511,7 @@ function decideNext(gate, analyzed, head, summary) {
|
|
|
35277
35511
|
const unseen = counted === null ? 0 : Math.max(0, counted - liveBlocking.length);
|
|
35278
35512
|
return {
|
|
35279
35513
|
next_action: "fix",
|
|
35280
|
-
reason: open === 0 && unseen === 0 ? "Every live blocking finding is answered and a review rule skipped this head; push the fix. If a rule skips that push too, the gate reads the replies on it and can turn green, marked unverified; otherwise the review verifies it." : `A live blocking finding is tagged applied, but ${open + unseen} blocking finding(s) are still open (deferred, misclassified, a dismissal not upheld, a reply at another head, or one this read cannot see), so replies alone will not unlock the carried red; push the fix, and answer or fix the rest.`
|
|
35514
|
+
reason: open === 0 && unseen === 0 ? "Every live blocking finding is answered and a review rule skipped this head; push the fix. If a rule skips that push too, the gate reads the replies on it and can turn green, marked unverified, or, under a used-up budget or manual_only, hold the head for a manual review; otherwise the review verifies it." : `A live blocking finding is tagged applied, but ${open + unseen} blocking finding(s) are still open (deferred, misclassified, a dismissal not upheld, a reply at another head, or one this read cannot see), so replies alone will not unlock the carried red; push the fix, and answer or fix the rest.`
|
|
35281
35515
|
};
|
|
35282
35516
|
}
|
|
35283
35517
|
return {
|
|
@@ -35492,6 +35726,7 @@ async function evaluateCiAdmissionGate(input) {
|
|
|
35492
35726
|
}
|
|
35493
35727
|
const trustedActors = resolveCiTrustedActors({
|
|
35494
35728
|
githubActor: process.env.GITHUB_ACTOR,
|
|
35729
|
+
platformActor: process.env.CRYSK_PLATFORM_ACTOR,
|
|
35495
35730
|
extra: config.ci_trusted_actors
|
|
35496
35731
|
});
|
|
35497
35732
|
const allComments = [...reviewComments, ...issueComments];
|
|
@@ -35987,7 +36222,7 @@ init_preflight();
|
|
|
35987
36222
|
// src/ui/plan.ts
|
|
35988
36223
|
init_git();
|
|
35989
36224
|
import { existsSync as existsSync28 } from "fs";
|
|
35990
|
-
import
|
|
36225
|
+
import path47 from "path";
|
|
35991
36226
|
init_preflight();
|
|
35992
36227
|
init_size_gate();
|
|
35993
36228
|
init_primitives();
|
|
@@ -36494,7 +36729,7 @@ function renderPlan(ctx, styles) {
|
|
|
36494
36729
|
lines.push(...row(label, summarizerRow(ctx.summary), { styles, width }));
|
|
36495
36730
|
lines.push(...row("", scoutRow(ctx.options), { styles, width }));
|
|
36496
36731
|
label = "";
|
|
36497
|
-
lines.push("", ...row("BASE", `${ctx.baseRef.ref} \u2192 ${shortSha(ctx.baseSha)} (${baseSourceTag(ctx)})`, { styles, width }), ...row("RANGE", `${shortSha(ctx.diffFromSha)} \u2192 ${shortSha(ctx.headSha)} ` + (ctx.options.twoDot ? "(--two-dot, two-point range)" : "(merge base)"), { styles, width }), ...row("RUN", `${
|
|
36732
|
+
lines.push("", ...row("BASE", `${ctx.baseRef.ref} \u2192 ${shortSha(ctx.baseSha)} (${baseSourceTag(ctx)})`, { styles, width }), ...row("RANGE", `${shortSha(ctx.diffFromSha)} \u2192 ${shortSha(ctx.headSha)} ` + (ctx.options.twoDot ? "(--two-dot, two-point range)" : "(merge base)"), { styles, width }), ...row("RUN", `${path47.basename(ctx.runDir)} \xB7 ` + (ctx.codegraphAvailable ? "codegraph live" : "codegraph NOT FOUND") + ` \xB7 hop budget ${ctx.options.hopBudget}` + ` \xB7 ${ctx.config.suspicion_priors.length} suspicion prior(s)`, { styles, width }), ...configRow(ctx.configProvenance, ctx.options, styles, width), ...decisionLines({
|
|
36498
36733
|
sizeGate: ctx.sizeGate,
|
|
36499
36734
|
droppedPaths: ctx.droppedPaths,
|
|
36500
36735
|
force: ctx.options.force,
|
|
@@ -36522,13 +36757,13 @@ function worktreePlanNote(worktreePath) {
|
|
|
36522
36757
|
return existsSync28(worktreePath) ? "exists \u2014 reuse/recreate decided at run time" : "will create (git worktree add --detach)";
|
|
36523
36758
|
}
|
|
36524
36759
|
function codegraphPlanNote(worktreePath) {
|
|
36525
|
-
if (existsSync28(
|
|
36760
|
+
if (existsSync28(path47.join(worktreePath, ".codegraph"))) {
|
|
36526
36761
|
return "available (.codegraph found in the worktree; codegraph_explore " + "is live)";
|
|
36527
36762
|
}
|
|
36528
36763
|
return Bun.which("codegraph") === null ? "codegraph CLI not found \u2014 hunters run on Read/Grep/Glob alone" : "will `codegraph init` in the worktree (~10s measured)";
|
|
36529
36764
|
}
|
|
36530
36765
|
function codegraphPlanTag(worktreePath) {
|
|
36531
|
-
if (existsSync28(
|
|
36766
|
+
if (existsSync28(path47.join(worktreePath, ".codegraph"))) {
|
|
36532
36767
|
return "codegraph live";
|
|
36533
36768
|
}
|
|
36534
36769
|
return Bun.which("codegraph") === null ? "codegraph NOT FOUND" : "codegraph init ~10s";
|
|
@@ -36614,7 +36849,7 @@ function renderPrPlan(ctx, styles) {
|
|
|
36614
36849
|
}));
|
|
36615
36850
|
}
|
|
36616
36851
|
label = "";
|
|
36617
|
-
lines.push("", ...row("BASE", ctx.resolved ? `${shortRev(ctx.target.baseRef)} \u2192 ` + `${shortSha(ctx.resolved.baseSha)} ` + `(${prBaseSourceTag(ctx.target)})` : `${shortRev(ctx.target.baseRef)} (${prBaseSourceTag(ctx.target)}; ` + "resolved after fetch)", { styles, width }), ...row("RANGE", ctx.resolved ? `${shortSha(ctx.resolved.diffFromSha)} \u2192 ` + `${shortSha(ctx.target.headSha)} (merge base)` : `merge base of ${shortRev(ctx.target.baseRef)} \u2192 ` + `${shortSha(ctx.target.headSha)} (exact sha after fetch)`, { styles, width }), ...row("RUN", `${
|
|
36852
|
+
lines.push("", ...row("BASE", ctx.resolved ? `${shortRev(ctx.target.baseRef)} \u2192 ` + `${shortSha(ctx.resolved.baseSha)} ` + `(${prBaseSourceTag(ctx.target)})` : `${shortRev(ctx.target.baseRef)} (${prBaseSourceTag(ctx.target)}; ` + "resolved after fetch)", { styles, width }), ...row("RANGE", ctx.resolved ? `${shortSha(ctx.resolved.diffFromSha)} \u2192 ` + `${shortSha(ctx.target.headSha)} (merge base)` : `merge base of ${shortRev(ctx.target.baseRef)} \u2192 ` + `${shortSha(ctx.target.headSha)} (exact sha after fetch)`, { styles, width }), ...row("RUN", `${path47.basename(ctx.runDir)} \xB7 ` + `${prWorktreePlanTag(ctx.worktreePath)} \xB7 ` + `${codegraphPlanTag(ctx.worktreePath)} \xB7 ` + `hop budget ${ctx.options.hopBudget} \xB7 ` + `${ctx.config.suspicion_priors.length} suspicion prior(s)`, { styles, width }), ...configRow(ctx.configProvenance, ctx.options, styles, width));
|
|
36618
36853
|
if (ctx.options.post) {
|
|
36619
36854
|
lines.push(...row("POST", "\u2713 one marked PR comment \u2014 created, or updated in place (idempotent)", { styles, width }));
|
|
36620
36855
|
}
|
|
@@ -37266,7 +37501,7 @@ async function resolvePrPlanAndConfirm(params) {
|
|
|
37266
37501
|
init_preflight2();
|
|
37267
37502
|
|
|
37268
37503
|
// src/pr/publish-outcome.ts
|
|
37269
|
-
import
|
|
37504
|
+
import path48 from "path";
|
|
37270
37505
|
init_git();
|
|
37271
37506
|
|
|
37272
37507
|
// src/pr/ci-publish.ts
|
|
@@ -37328,6 +37563,9 @@ async function postFindingsIfEnabled(input) {
|
|
|
37328
37563
|
if (posted) {
|
|
37329
37564
|
input.onDelivered?.();
|
|
37330
37565
|
await writePostReceipt(input.runDir, input.pr, input.headSha, posted);
|
|
37566
|
+
if (posted.findingState !== undefined) {
|
|
37567
|
+
writeFindingStateRecord(input.runDir, posted.findingState);
|
|
37568
|
+
}
|
|
37331
37569
|
log(`posted: review ${posted.reviewOutcome} (${posted.reviewFindingCount} ` + `finding(s)), ${posted.outsideDiffCount} outside diff, ` + `summary ${posted.summary.action} comment ${posted.summary.commentId}`);
|
|
37332
37570
|
if (posted.movedHeadSha) {
|
|
37333
37571
|
log(`warning: the PR head moved while the review ran \u2014 reviewed ` + `${input.headSha}, head is now ${posted.movedHeadSha}; the ` + "comments are pinned to the reviewed commit");
|
|
@@ -37516,11 +37754,11 @@ async function publishRunOutcome(input) {
|
|
|
37516
37754
|
telemetry
|
|
37517
37755
|
});
|
|
37518
37756
|
const blockingCount = unresolvedBlockingCount(doc.findings, result.gatePriors ?? []);
|
|
37519
|
-
input.onBlockingCount(blockingCount);
|
|
37757
|
+
input.onBlockingCount(blockingCount, blockingCount > 0 || result.sessionFailed !== true && result.noReviewerRan !== true && (result.hunterFailures?.length ?? 0) === 0);
|
|
37520
37758
|
const reportPath = await writeRunReport({
|
|
37521
37759
|
runDir: input.runDir,
|
|
37522
37760
|
doc,
|
|
37523
|
-
repo:
|
|
37761
|
+
repo: path48.basename(input.operatorRoot),
|
|
37524
37762
|
base: input.baseRef,
|
|
37525
37763
|
head: `PR #${input.prNumber}`,
|
|
37526
37764
|
diffStat: input.diffStat,
|
|
@@ -37603,8 +37841,8 @@ async function publishRunOutcome(input) {
|
|
|
37603
37841
|
estimate: { low: input.estimate.low, high: input.estimate.high },
|
|
37604
37842
|
runDir: input.runDir,
|
|
37605
37843
|
artifacts: [
|
|
37606
|
-
|
|
37607
|
-
|
|
37844
|
+
path48.basename(reportPath),
|
|
37845
|
+
path48.basename(findingsPath),
|
|
37608
37846
|
...posted ? ["post.json"] : []
|
|
37609
37847
|
],
|
|
37610
37848
|
worktree: {
|
|
@@ -37834,7 +38072,7 @@ init_git();
|
|
|
37834
38072
|
import { existsSync as existsSync30 } from "fs";
|
|
37835
38073
|
import { mkdir as mkdir10, readdir as readdir2, rm as rm6, stat as stat2 } from "fs/promises";
|
|
37836
38074
|
import os19 from "os";
|
|
37837
|
-
import
|
|
38075
|
+
import path49 from "path";
|
|
37838
38076
|
init_preflight();
|
|
37839
38077
|
init_primitives();
|
|
37840
38078
|
init_preflight3();
|
|
@@ -37865,7 +38103,7 @@ async function discoverWorktrees(home, onlyRepoId) {
|
|
|
37865
38103
|
const found = [];
|
|
37866
38104
|
const glob = new Bun.Glob("**/registry.json");
|
|
37867
38105
|
for await (const rel of glob.scan({ cwd: reposDir })) {
|
|
37868
|
-
const registryPath =
|
|
38106
|
+
const registryPath = path49.join(reposDir, rel);
|
|
37869
38107
|
let registry;
|
|
37870
38108
|
try {
|
|
37871
38109
|
registry = parseRepoRegistry(await Bun.file(registryPath).text());
|
|
@@ -37886,7 +38124,7 @@ async function discoverWorktrees(home, onlyRepoId) {
|
|
|
37886
38124
|
const pr = parseWorktreePr(entry.name);
|
|
37887
38125
|
if (pr === null)
|
|
37888
38126
|
continue;
|
|
37889
|
-
const worktreePath =
|
|
38127
|
+
const worktreePath = path49.join(paths.worktrees, entry.name);
|
|
37890
38128
|
let dirMtimeMs = null;
|
|
37891
38129
|
try {
|
|
37892
38130
|
dirMtimeMs = (await stat2(worktreePath)).mtimeMs;
|
|
@@ -38015,7 +38253,7 @@ async function gcCommand(options) {
|
|
|
38015
38253
|
if (options.repo !== ".") {
|
|
38016
38254
|
const resolved = await resolveRepoHome({
|
|
38017
38255
|
home,
|
|
38018
|
-
operatorRoot:
|
|
38256
|
+
operatorRoot: path49.resolve(options.repo),
|
|
38019
38257
|
persist: false
|
|
38020
38258
|
});
|
|
38021
38259
|
repoId = resolved.repoId;
|
|
@@ -38056,7 +38294,7 @@ async function gcInstall(intervalMin) {
|
|
|
38056
38294
|
const plistPath = gcPlistPath(home);
|
|
38057
38295
|
const logPath = gcLaunchdLogPath(home);
|
|
38058
38296
|
await mkdir10(prheroLayout(home).dir, { recursive: true });
|
|
38059
|
-
await mkdir10(
|
|
38297
|
+
await mkdir10(path49.dirname(plistPath), { recursive: true });
|
|
38060
38298
|
const plist = renderGcPlist({
|
|
38061
38299
|
invocation,
|
|
38062
38300
|
intervalSeconds: intervalMin * 60,
|
|
@@ -38256,7 +38494,7 @@ async function finalizePrReviewRun(input) {
|
|
|
38256
38494
|
|
|
38257
38495
|
// src/pr/worktree-setup.ts
|
|
38258
38496
|
import { existsSync as existsSync31 } from "fs";
|
|
38259
|
-
import
|
|
38497
|
+
import path50 from "path";
|
|
38260
38498
|
init_primitives();
|
|
38261
38499
|
init_home();
|
|
38262
38500
|
async function setupPrWorktree(input) {
|
|
@@ -38266,7 +38504,7 @@ async function setupPrWorktree(input) {
|
|
|
38266
38504
|
log(`worktree ${worktree.action}: ${worktreePath} (${worktree.reason})`);
|
|
38267
38505
|
await stampWorktree(registryPath, prNumber, new Date().toISOString());
|
|
38268
38506
|
let indexMs = 0;
|
|
38269
|
-
if (!existsSync31(
|
|
38507
|
+
if (!existsSync31(path50.join(worktreePath, ".codegraph"))) {
|
|
38270
38508
|
if (Bun.which("codegraph") === null) {
|
|
38271
38509
|
log("codegraph CLI not found \u2014 no index will be built; hunters run on " + "Read/Grep/Glob alone");
|
|
38272
38510
|
} else {
|
|
@@ -38274,8 +38512,8 @@ async function setupPrWorktree(input) {
|
|
|
38274
38512
|
log(`codegraph init: ${Math.round(indexMs / 1000)}s`);
|
|
38275
38513
|
}
|
|
38276
38514
|
}
|
|
38277
|
-
const mcpConfigPath =
|
|
38278
|
-
const codegraphAvailable = existsSync31(
|
|
38515
|
+
const mcpConfigPath = path50.join(runDir, "mcp.json");
|
|
38516
|
+
const codegraphAvailable = existsSync31(path50.join(worktreePath, ".codegraph"));
|
|
38279
38517
|
await writeMcpConfig(mcpConfigPath, codegraphAvailable);
|
|
38280
38518
|
return { mcpConfigPath, indexMs };
|
|
38281
38519
|
}
|
|
@@ -38290,6 +38528,19 @@ init_errors();
|
|
|
38290
38528
|
init_home();
|
|
38291
38529
|
init_home_preflight();
|
|
38292
38530
|
init_ignore_read();
|
|
38531
|
+
|
|
38532
|
+
// src/pr/gate-record.ts
|
|
38533
|
+
import { writeFileSync as writeFileSync10 } from "fs";
|
|
38534
|
+
import path51 from "path";
|
|
38535
|
+
var GATE_RECORD_FILE = "gate.json";
|
|
38536
|
+
function writeGateRecord(runDir, unresolvedBlocking) {
|
|
38537
|
+
try {
|
|
38538
|
+
writeFileSync10(path51.join(runDir, GATE_RECORD_FILE), `${JSON.stringify({ unresolved_blocking: unresolvedBlocking })}
|
|
38539
|
+
`);
|
|
38540
|
+
} catch {}
|
|
38541
|
+
}
|
|
38542
|
+
|
|
38543
|
+
// src/pr/review-pr.ts
|
|
38293
38544
|
function recordPipelineOutcome(result, headSha, env = process.env) {
|
|
38294
38545
|
if (result?.sessionFailed !== true)
|
|
38295
38546
|
return;
|
|
@@ -38345,7 +38596,7 @@ async function postAdjudicationReplies(input) {
|
|
|
38345
38596
|
const evidence = entry.evidence.length > 0 ? `
|
|
38346
38597
|
|
|
38347
38598
|
Evidence:
|
|
38348
|
-
${entry.evidence.map((e) => `-
|
|
38599
|
+
${entry.evidence.map((e) => `- ${code(e)}`).join(`
|
|
38349
38600
|
`)}` : "";
|
|
38350
38601
|
const body = `${marker}
|
|
38351
38602
|
|
|
@@ -38610,11 +38861,11 @@ async function reviewPr(options, prArg) {
|
|
|
38610
38861
|
if (inFlightExit !== undefined)
|
|
38611
38862
|
return inFlightExit;
|
|
38612
38863
|
const runDir = await createPrRunDir(options, operatorRoot, worktreePath, repoHome.paths.runs, prNumber, headSha);
|
|
38613
|
-
const diffPath =
|
|
38864
|
+
const diffPath = path52.join(runDir, "diff.patch");
|
|
38614
38865
|
await Bun.write(diffPath, effectiveDiff.patch);
|
|
38615
|
-
await Bun.write(
|
|
38866
|
+
await Bun.write(path52.join(runDir, "anchor.patch"), anchorPatch);
|
|
38616
38867
|
if (effectiveDiff.droppedPaths.length > 0) {
|
|
38617
|
-
await Bun.write(
|
|
38868
|
+
await Bun.write(path52.join(runDir, "diff.raw.patch"), rawDiff);
|
|
38618
38869
|
}
|
|
38619
38870
|
const parityFires = resolveParityFires(effectiveDiff.patch, config.parity_trigger_paths);
|
|
38620
38871
|
const activeHunters = discoveryHunters({
|
|
@@ -38704,7 +38955,7 @@ async function reviewPr(options, prArg) {
|
|
|
38704
38955
|
productionRuntime = prepared.productionRuntime;
|
|
38705
38956
|
await registerActiveRun({
|
|
38706
38957
|
pid: process.pid,
|
|
38707
|
-
repo: repoHome.paths.repoId ??
|
|
38958
|
+
repo: repoHome.paths.repoId ?? path52.basename(gitDirOwner),
|
|
38708
38959
|
pr: prNumber,
|
|
38709
38960
|
runDir,
|
|
38710
38961
|
startedAt: new Date().toISOString()
|
|
@@ -38727,7 +38978,7 @@ async function reviewPr(options, prArg) {
|
|
|
38727
38978
|
agentsDir,
|
|
38728
38979
|
...agents.files ? { agentFiles: agents.files } : {},
|
|
38729
38980
|
runDir,
|
|
38730
|
-
outPath:
|
|
38981
|
+
outPath: path52.join(runDir, "findings.json"),
|
|
38731
38982
|
mcpConfigPath,
|
|
38732
38983
|
hopBudget: options.hopBudget,
|
|
38733
38984
|
...options.model ? { model: options.model } : {},
|
|
@@ -38793,8 +39044,10 @@ async function reviewPr(options, prArg) {
|
|
|
38793
39044
|
onPosted: (outcome) => {
|
|
38794
39045
|
posted = outcome;
|
|
38795
39046
|
},
|
|
38796
|
-
onBlockingCount: (count) => {
|
|
39047
|
+
onBlockingCount: (count, conclusive) => {
|
|
38797
39048
|
blockingCount = count;
|
|
39049
|
+
if (conclusive)
|
|
39050
|
+
writeGateRecord(runDir, count);
|
|
38798
39051
|
}
|
|
38799
39052
|
});
|
|
38800
39053
|
if (postEnabled && options.ci === true) {
|
|
@@ -38879,7 +39132,7 @@ async function review(options) {
|
|
|
38879
39132
|
await validateGotchas(gotchasPath);
|
|
38880
39133
|
const userIgnore = await readLocalIgnoreRules(repoRoot);
|
|
38881
39134
|
const { runDir, repoId } = await createRunDir(options, repoRoot, headSha);
|
|
38882
|
-
const diffPath =
|
|
39135
|
+
const diffPath = path53.join(runDir, "diff.patch");
|
|
38883
39136
|
const diff = await git(repoRoot, ["diff", `${diffFromSha}..${headSha}`]);
|
|
38884
39137
|
if (!diff.ok)
|
|
38885
39138
|
throw new CliError(`git diff failed: ${diff.stderr}`);
|
|
@@ -38893,7 +39146,7 @@ async function review(options) {
|
|
|
38893
39146
|
}
|
|
38894
39147
|
await Bun.write(diffPath, effectiveDiff.patch);
|
|
38895
39148
|
if (effectiveDiff.droppedPaths.length > 0) {
|
|
38896
|
-
await Bun.write(
|
|
39149
|
+
await Bun.write(path53.join(runDir, "diff.raw.patch"), diff.stdout);
|
|
38897
39150
|
}
|
|
38898
39151
|
const { diffStat, sizeGate } = await computeDiffStatAndSizeGate({
|
|
38899
39152
|
runGit: (args) => git(repoRoot, args),
|
|
@@ -38901,8 +39154,8 @@ async function review(options) {
|
|
|
38901
39154
|
pathArgs: [],
|
|
38902
39155
|
gateConfig
|
|
38903
39156
|
});
|
|
38904
|
-
const mcpConfigPath =
|
|
38905
|
-
const codegraphAvailable = existsSync32(
|
|
39157
|
+
const mcpConfigPath = path53.join(runDir, "mcp.json");
|
|
39158
|
+
const codegraphAvailable = existsSync32(path53.join(repoRoot, ".codegraph"));
|
|
38906
39159
|
await writeMcpConfig(mcpConfigPath, codegraphAvailable);
|
|
38907
39160
|
const parityFires = resolveParityFires(effectiveDiff.patch, config.parity_trigger_paths);
|
|
38908
39161
|
const activeHunters = selectActiveHunters(spec.agents, parityFires);
|
|
@@ -38984,7 +39237,7 @@ async function review(options) {
|
|
|
38984
39237
|
let result;
|
|
38985
39238
|
await registerActiveRun({
|
|
38986
39239
|
pid: process.pid,
|
|
38987
|
-
repo: repoId ??
|
|
39240
|
+
repo: repoId ?? path53.basename(repoRoot),
|
|
38988
39241
|
runDir,
|
|
38989
39242
|
startedAt: new Date().toISOString()
|
|
38990
39243
|
});
|
|
@@ -39021,7 +39274,7 @@ async function review(options) {
|
|
|
39021
39274
|
agentsDir,
|
|
39022
39275
|
...agents.files ? { agentFiles: agents.files } : {},
|
|
39023
39276
|
runDir,
|
|
39024
|
-
outPath:
|
|
39277
|
+
outPath: path53.join(runDir, "findings.json"),
|
|
39025
39278
|
mcpConfigPath,
|
|
39026
39279
|
hopBudget: options.hopBudget,
|
|
39027
39280
|
...options.model ? { model: options.model } : {},
|
|
@@ -39080,7 +39333,7 @@ async function review(options) {
|
|
|
39080
39333
|
const reportPath = await writeRunReport({
|
|
39081
39334
|
runDir,
|
|
39082
39335
|
doc,
|
|
39083
|
-
repo:
|
|
39336
|
+
repo: path53.basename(repoRoot),
|
|
39084
39337
|
base: baseRef.ref,
|
|
39085
39338
|
head: options.head,
|
|
39086
39339
|
diffStat,
|
|
@@ -39097,7 +39350,7 @@ async function review(options) {
|
|
|
39097
39350
|
wallMs,
|
|
39098
39351
|
estimate: { low: estimate.low, high: estimate.high },
|
|
39099
39352
|
runDir,
|
|
39100
|
-
artifacts: [
|
|
39353
|
+
artifacts: [path53.basename(reportPath), path53.basename(findingsPath)],
|
|
39101
39354
|
...links === undefined ? {} : { links },
|
|
39102
39355
|
sessionFailed: result.sessionFailed,
|
|
39103
39356
|
...result.unresolved.length > 0 ? { unresolved: result.unresolved } : {},
|
|
@@ -39115,14 +39368,14 @@ init_preflight();
|
|
|
39115
39368
|
init_size_gate();
|
|
39116
39369
|
import { existsSync as existsSync34, readFileSync as readFileSync15 } from "fs";
|
|
39117
39370
|
import os21 from "os";
|
|
39118
|
-
import
|
|
39371
|
+
import path55 from "path";
|
|
39119
39372
|
init_preflight3();
|
|
39120
39373
|
init_brand_paths();
|
|
39121
39374
|
|
|
39122
39375
|
// src/menu-context.ts
|
|
39123
39376
|
init_brand_paths();
|
|
39124
39377
|
import { existsSync as existsSync33, readFileSync as readFileSync14 } from "fs";
|
|
39125
|
-
import
|
|
39378
|
+
import path54 from "path";
|
|
39126
39379
|
async function findGitRoot(dir) {
|
|
39127
39380
|
try {
|
|
39128
39381
|
const proc = Bun.spawn(["git", "-C", dir, "rev-parse", "--show-toplevel"], {
|
|
@@ -39153,8 +39406,8 @@ async function resolveMenuContext(cwd = process.cwd(), deps = {}) {
|
|
|
39153
39406
|
if (!root) {
|
|
39154
39407
|
return { kind: "not-a-repo", cwd };
|
|
39155
39408
|
}
|
|
39156
|
-
const name =
|
|
39157
|
-
const configPath =
|
|
39409
|
+
const name = path54.basename(root) || "repository";
|
|
39410
|
+
const configPath = path54.join(resolveRepoDir(root), "config.json");
|
|
39158
39411
|
if (!exists(configPath)) {
|
|
39159
39412
|
return { kind: "unconfigured-repo", root, name };
|
|
39160
39413
|
}
|
|
@@ -39307,7 +39560,7 @@ function renderPersistentFooter(selectedItem, _width, styles) {
|
|
|
39307
39560
|
async function gatherMenuStatus(home = os21.homedir(), cwd = process.cwd()) {
|
|
39308
39561
|
let upgradeAvailable = false;
|
|
39309
39562
|
try {
|
|
39310
|
-
const upgradeCache =
|
|
39563
|
+
const upgradeCache = path55.join(resolveHomeDir(home), "upgrade-check.json");
|
|
39311
39564
|
if (existsSync34(upgradeCache)) {
|
|
39312
39565
|
const parsed = JSON.parse(readFileSync15(upgradeCache, "utf-8"));
|
|
39313
39566
|
upgradeAvailable = Boolean(parsed.latestVersion && parsed.updateAvailable);
|
|
@@ -39851,7 +40104,7 @@ async function runWatcherSubmenu(deps) {
|
|
|
39851
40104
|
drawn = 0;
|
|
39852
40105
|
await runLayerConfigCardEditor({
|
|
39853
40106
|
layer: "watch",
|
|
39854
|
-
title: `Watcher Daemon Configuration (${
|
|
40107
|
+
title: `Watcher Daemon Configuration (${path55.join(resolveHomeDir(home), "watch.json")})`,
|
|
39855
40108
|
createReader,
|
|
39856
40109
|
io,
|
|
39857
40110
|
styles,
|
|
@@ -39906,11 +40159,11 @@ async function runLayerConfigCardEditor(deps) {
|
|
|
39906
40159
|
if (deps.layer === "team") {
|
|
39907
40160
|
if (!repoRoot)
|
|
39908
40161
|
return {};
|
|
39909
|
-
filePath =
|
|
40162
|
+
filePath = path55.join(resolveRepoDir(repoRoot), "config.json");
|
|
39910
40163
|
} else if (deps.layer === "person") {
|
|
39911
|
-
filePath =
|
|
40164
|
+
filePath = path55.join(resolveHomeDir(home), "config.json");
|
|
39912
40165
|
} else if (deps.layer === "watch") {
|
|
39913
|
-
filePath =
|
|
40166
|
+
filePath = path55.join(resolveHomeDir(home), "watch.json");
|
|
39914
40167
|
}
|
|
39915
40168
|
if (filePath && existsSync34(filePath)) {
|
|
39916
40169
|
try {
|
|
@@ -40155,13 +40408,13 @@ async function runConfigSubmenu(deps) {
|
|
|
40155
40408
|
{
|
|
40156
40409
|
id: "team",
|
|
40157
40410
|
label: "Repository configuration",
|
|
40158
|
-
file: repoRoot ?
|
|
40411
|
+
file: repoRoot ? path55.join(resolveRepoDir(repoRoot), "config.json") : ".crysk/config.json",
|
|
40159
40412
|
disabled: !inRepo
|
|
40160
40413
|
},
|
|
40161
40414
|
{
|
|
40162
40415
|
id: "person",
|
|
40163
40416
|
label: "Global configuration",
|
|
40164
|
-
file:
|
|
40417
|
+
file: path55.join(resolveHomeDir(home), "config.json"),
|
|
40165
40418
|
disabled: false
|
|
40166
40419
|
},
|
|
40167
40420
|
{
|
|
@@ -40258,7 +40511,7 @@ async function runConfigSubmenu(deps) {
|
|
|
40258
40511
|
}
|
|
40259
40512
|
if (selectedNext === "back" || !selectedNext)
|
|
40260
40513
|
return "back";
|
|
40261
|
-
const title = selectedNext === "team" ? `Repository Configuration (${
|
|
40514
|
+
const title = selectedNext === "team" ? `Repository Configuration (${path55.join(resolveRepoDir(repoRoot ?? "."), "config.json")})` : `Global Configuration (${path55.join(resolveHomeDir(home), "config.json")})`;
|
|
40262
40515
|
drawn = 0;
|
|
40263
40516
|
await runLayerConfigCardEditor({
|
|
40264
40517
|
layer: selectedNext,
|
|
@@ -40522,7 +40775,7 @@ init_git();
|
|
|
40522
40775
|
import { existsSync as existsSync35 } from "fs";
|
|
40523
40776
|
import { appendFile as appendFile2, mkdir as mkdir11, readdir as readdir3, rm as rm7 } from "fs/promises";
|
|
40524
40777
|
import os22 from "os";
|
|
40525
|
-
import
|
|
40778
|
+
import path56 from "path";
|
|
40526
40779
|
init_preflight2();
|
|
40527
40780
|
init_findings();
|
|
40528
40781
|
init_preflight();
|
|
@@ -40718,8 +40971,8 @@ async function scanRunDirs(runsRoot) {
|
|
|
40718
40971
|
for (const entry of await readdir3(runsRoot, { withFileTypes: true })) {
|
|
40719
40972
|
if (!entry.isDirectory())
|
|
40720
40973
|
continue;
|
|
40721
|
-
const dir =
|
|
40722
|
-
const findingsPath =
|
|
40974
|
+
const dir = path56.join(runsRoot, entry.name);
|
|
40975
|
+
const findingsPath = path56.join(dir, "findings.json");
|
|
40723
40976
|
if (existsSync35(findingsPath)) {
|
|
40724
40977
|
try {
|
|
40725
40978
|
const doc = validateFindingsDocument(JSON.parse(await Bun.file(findingsPath).text()));
|
|
@@ -40732,7 +40985,7 @@ async function scanRunDirs(runsRoot) {
|
|
|
40732
40985
|
throw new CliError(`${findingsPath}: ${reason}`);
|
|
40733
40986
|
}
|
|
40734
40987
|
}
|
|
40735
|
-
const pipelinePath =
|
|
40988
|
+
const pipelinePath = path56.join(dir, "pipeline.json");
|
|
40736
40989
|
facts.push({
|
|
40737
40990
|
name: entry.name,
|
|
40738
40991
|
pipelineMeta: existsSync35(pipelinePath) ? parsePipelineMeta(await Bun.file(pipelinePath).text()) : null
|
|
@@ -40803,12 +41056,12 @@ async function selectLaunchAfterVeto(io, eligible, repos) {
|
|
|
40803
41056
|
async function runTick(paths, decision, repos, ghPrFilesFn) {
|
|
40804
41057
|
await appendLog(paths.logPath, logLine(localIsoTimestamp(new Date), "tick start"));
|
|
40805
41058
|
for (const skip of decision.skips) {
|
|
40806
|
-
await appendLog(paths.logPath, skipLine(localIsoTimestamp(new Date),
|
|
41059
|
+
await appendLog(paths.logPath, skipLine(localIsoTimestamp(new Date), path56.basename(skip.repo), skip.pr, skip.head, skip.reason));
|
|
40807
41060
|
}
|
|
40808
41061
|
await settleOrphanPendings(repos, decision.skips);
|
|
40809
41062
|
const selection = decision.launch === null ? { launch: null, vetoed: [], capReached: false } : await selectLaunchAfterVeto({ ghPrFiles: ghPrFilesFn }, decision.eligible, repos);
|
|
40810
41063
|
for (const vetoed of selection.vetoed) {
|
|
40811
|
-
await appendLog(paths.logPath, skipLine(localIsoTimestamp(new Date),
|
|
41064
|
+
await appendLog(paths.logPath, skipLine(localIsoTimestamp(new Date), path56.basename(vetoed.repo), vetoed.pr, vetoed.head, "nothing-to-review"));
|
|
40812
41065
|
}
|
|
40813
41066
|
if (selection.capReached) {
|
|
40814
41067
|
await appendLog(paths.logPath, logLine(localIsoTimestamp(new Date), `tick veto-cap-reached attempts=${PRE_LAUNCH_VETO_MAX_ATTEMPTS}`));
|
|
@@ -40819,7 +41072,7 @@ async function runTick(paths, decision, repos, ghPrFilesFn) {
|
|
|
40819
41072
|
await appendLog(paths.logPath, logLine(localIsoTimestamp(new Date), `tick end launched=0 skipped=${skippedThisTick}`));
|
|
40820
41073
|
return 0;
|
|
40821
41074
|
}
|
|
40822
|
-
const repoBase =
|
|
41075
|
+
const repoBase = path56.basename(launch.repo);
|
|
40823
41076
|
const launched = repos.find((r) => r.path === launch.repo);
|
|
40824
41077
|
const sizeArgs = launched === undefined ? [] : [
|
|
40825
41078
|
"--max-changed-lines",
|
|
@@ -40859,7 +41112,7 @@ async function readTierCounts(runsRoot, pr, headSha) {
|
|
|
40859
41112
|
const latest = latestRunDirName(names, pr, headSha);
|
|
40860
41113
|
if (latest === null)
|
|
40861
41114
|
return null;
|
|
40862
|
-
const parsed = await Bun.file(
|
|
41115
|
+
const parsed = await Bun.file(path56.join(runsRoot, latest, "findings.json")).json();
|
|
40863
41116
|
return findingsTierCounts(parsed);
|
|
40864
41117
|
} catch {
|
|
40865
41118
|
return null;
|
|
@@ -40927,7 +41180,7 @@ function printDryRun(paths, config, launchedToday, decision, repos) {
|
|
|
40927
41180
|
emit("LAUNCH", "nothing \u2014 no eligible (pr, head)");
|
|
40928
41181
|
}
|
|
40929
41182
|
if (decision.eligible.length > 1) {
|
|
40930
|
-
emit("WAITING", decision.eligible.slice(1).map((e) => `pr ${e.pr} (${
|
|
41183
|
+
emit("WAITING", decision.eligible.slice(1).map((e) => `pr ${e.pr} (${path56.basename(e.repo)})`).join(", "));
|
|
40931
41184
|
}
|
|
40932
41185
|
}
|
|
40933
41186
|
async function watchInstall(intervalMin) {
|
|
@@ -40940,7 +41193,7 @@ async function watchInstall(intervalMin) {
|
|
|
40940
41193
|
}
|
|
40941
41194
|
const paths = prheroHomePaths(os22.homedir());
|
|
40942
41195
|
await mkdir11(paths.dir, { recursive: true });
|
|
40943
|
-
await mkdir11(
|
|
41196
|
+
await mkdir11(path56.dirname(paths.plistPath), { recursive: true });
|
|
40944
41197
|
const plist = renderWatchPlist({
|
|
40945
41198
|
invocation,
|
|
40946
41199
|
intervalSeconds: intervalMin * 60,
|
|
@@ -41069,9 +41322,9 @@ async function watchStatus() {
|
|
|
41069
41322
|
|
|
41070
41323
|
// src/wizard.ts
|
|
41071
41324
|
init_preflight();
|
|
41072
|
-
import { existsSync as existsSync36, mkdirSync as mkdirSync11, readFileSync as readFileSync16, writeFileSync as
|
|
41325
|
+
import { existsSync as existsSync36, mkdirSync as mkdirSync11, readFileSync as readFileSync16, writeFileSync as writeFileSync11 } from "fs";
|
|
41073
41326
|
import os23 from "os";
|
|
41074
|
-
import
|
|
41327
|
+
import path57 from "path";
|
|
41075
41328
|
init_assets();
|
|
41076
41329
|
init_brand_paths();
|
|
41077
41330
|
var CURRENT_ONBOARDING_VERSION = 1;
|
|
@@ -41114,7 +41367,7 @@ function isMachineOnboarded(options = {}) {
|
|
|
41114
41367
|
return;
|
|
41115
41368
|
}
|
|
41116
41369
|
});
|
|
41117
|
-
const setupPath =
|
|
41370
|
+
const setupPath = path57.join(resolveHomeDir(home), "setup.json");
|
|
41118
41371
|
if (!exists(setupPath))
|
|
41119
41372
|
return false;
|
|
41120
41373
|
try {
|
|
@@ -41370,14 +41623,14 @@ var WIZARD_STEPS = [
|
|
|
41370
41623
|
const home = deps.home ?? os23.homedir();
|
|
41371
41624
|
const exists = deps.exists ?? existsSync36;
|
|
41372
41625
|
const writeFile = deps.writeFile ?? ((p, c) => {
|
|
41373
|
-
mkdirSync11(
|
|
41374
|
-
|
|
41626
|
+
mkdirSync11(path57.dirname(p), { recursive: true });
|
|
41627
|
+
writeFileSync11(p, c, "utf-8");
|
|
41375
41628
|
});
|
|
41376
41629
|
const exec = deps.exec ?? defaultExec2;
|
|
41377
41630
|
const repoDir = resolveRepoDir(cwd, exists);
|
|
41378
|
-
const configPath =
|
|
41631
|
+
const configPath = path57.join(repoDir, "config.json");
|
|
41379
41632
|
const existingInstructions = resolveReviewInstructions(undefined, cwd, exists);
|
|
41380
|
-
const gotchasPath = existingInstructions.path ??
|
|
41633
|
+
const gotchasPath = existingInstructions.path ?? path57.join(cwd, REVIEW_MD_FILE_NAME);
|
|
41381
41634
|
const isGit = await exec(["git", "rev-parse", "--is-inside-work-tree"], {
|
|
41382
41635
|
cwd
|
|
41383
41636
|
});
|
|
@@ -41410,7 +41663,7 @@ ${state.gotchas.entries.map((e) => `- ${e}`).join(`
|
|
|
41410
41663
|
reviewMdWritten = existingInstructions.path === undefined;
|
|
41411
41664
|
}
|
|
41412
41665
|
}
|
|
41413
|
-
const setupPath =
|
|
41666
|
+
const setupPath = path57.join(resolveHomeDir(home), "setup.json");
|
|
41414
41667
|
const setupRecord = {
|
|
41415
41668
|
onboarding_version: CURRENT_ONBOARDING_VERSION,
|
|
41416
41669
|
completed_at: new Date().toISOString()
|
|
@@ -41419,8 +41672,8 @@ ${state.gotchas.entries.map((e) => `- ${e}`).join(`
|
|
|
41419
41672
|
`);
|
|
41420
41673
|
let workspaceCommitted = false;
|
|
41421
41674
|
if (isRepo && state.commitChoice === "commit") {
|
|
41422
|
-
await exec(["git", "add",
|
|
41423
|
-
if (exists(
|
|
41675
|
+
await exec(["git", "add", path57.basename(repoDir)], { cwd });
|
|
41676
|
+
if (exists(path57.join(cwd, REVIEW_MD_FILE_NAME))) {
|
|
41424
41677
|
await exec(["git", "add", REVIEW_MD_FILE_NAME], { cwd });
|
|
41425
41678
|
}
|
|
41426
41679
|
const commitRes = await exec([
|
|
@@ -41431,17 +41684,17 @@ ${state.gotchas.entries.map((e) => `- ${e}`).join(`
|
|
|
41431
41684
|
], { cwd });
|
|
41432
41685
|
workspaceCommitted = commitRes.exitCode === 0;
|
|
41433
41686
|
} else if (isRepo && state.commitChoice === "ignore") {
|
|
41434
|
-
const gitignorePath =
|
|
41687
|
+
const gitignorePath = path57.join(cwd, ".gitignore");
|
|
41435
41688
|
const existingGitignore = deps.readFile ? deps.readFile(gitignorePath) : deps.exists?.(gitignorePath) ? readFileSync16(gitignorePath, "utf-8") : "";
|
|
41436
41689
|
const updated = `${existingGitignore ?? ""}
|
|
41437
|
-
${
|
|
41690
|
+
${path57.basename(repoDir)}/
|
|
41438
41691
|
`;
|
|
41439
41692
|
await writeFile(gitignorePath, updated);
|
|
41440
41693
|
}
|
|
41441
41694
|
return {
|
|
41442
41695
|
workspaceFilesWritten,
|
|
41443
|
-
repoDirName:
|
|
41444
|
-
instructionsFile:
|
|
41696
|
+
repoDirName: path57.basename(repoDir),
|
|
41697
|
+
instructionsFile: path57.relative(cwd, gotchasPath),
|
|
41445
41698
|
reviewMdWritten,
|
|
41446
41699
|
placeholderGotchasWritten,
|
|
41447
41700
|
setupStateWritten: true,
|
|
@@ -41659,7 +41912,7 @@ async function menuCommand(options) {
|
|
|
41659
41912
|
// src/commands/post.ts
|
|
41660
41913
|
import { existsSync as existsSync37 } from "fs";
|
|
41661
41914
|
import os25 from "os";
|
|
41662
|
-
import
|
|
41915
|
+
import path58 from "path";
|
|
41663
41916
|
init_git();
|
|
41664
41917
|
init_preflight2();
|
|
41665
41918
|
init_findings();
|
|
@@ -41689,10 +41942,10 @@ async function postCommand(options) {
|
|
|
41689
41942
|
}
|
|
41690
41943
|
async function runPostCommand(input) {
|
|
41691
41944
|
const { operatorRoot, pr: prNumber, dryRun, spawnFn } = input;
|
|
41692
|
-
const runDir =
|
|
41693
|
-
const findingsPath =
|
|
41694
|
-
const anchorPath =
|
|
41695
|
-
const diffPath = existsSync37(anchorPath) ? anchorPath :
|
|
41945
|
+
const runDir = path58.resolve(input.from);
|
|
41946
|
+
const findingsPath = path58.join(runDir, "findings.json");
|
|
41947
|
+
const anchorPath = path58.join(runDir, "anchor.patch");
|
|
41948
|
+
const diffPath = existsSync37(anchorPath) ? anchorPath : path58.join(runDir, "diff.patch");
|
|
41696
41949
|
if (!existsSync37(findingsPath) || !existsSync37(diffPath)) {
|
|
41697
41950
|
throw new CliUsageError(`${runDir} is missing findings.json or diff.patch \u2014 point --from at ` + 'a completed run directory ("crysk review --pr <n>" writes both)');
|
|
41698
41951
|
}
|
|
@@ -41704,7 +41957,7 @@ async function runPostCommand(input) {
|
|
|
41704
41957
|
log(`post skipped: ${findingsPath} is not a complete run ` + `(run_status=${doc.run_status}), so there is no review to publish`);
|
|
41705
41958
|
return dryRun ? 0 : 1;
|
|
41706
41959
|
}
|
|
41707
|
-
const pipelinePath =
|
|
41960
|
+
const pipelinePath = path58.join(runDir, "pipeline.json");
|
|
41708
41961
|
let rereview;
|
|
41709
41962
|
if (existsSync37(pipelinePath)) {
|
|
41710
41963
|
let parsed;
|
|
@@ -41946,7 +42199,7 @@ async function runStatusCommand(input) {
|
|
|
41946
42199
|
// src/commands/triage.ts
|
|
41947
42200
|
import { existsSync as existsSync38 } from "fs";
|
|
41948
42201
|
import os27 from "os";
|
|
41949
|
-
import
|
|
42202
|
+
import path59 from "path";
|
|
41950
42203
|
init_git();
|
|
41951
42204
|
init_preflight2();
|
|
41952
42205
|
init_findings();
|
|
@@ -42053,8 +42306,8 @@ async function outsidePullUrl(operatorRoot, prNumber, spawnFn) {
|
|
|
42053
42306
|
}
|
|
42054
42307
|
async function runTriageReplyCommand(input) {
|
|
42055
42308
|
const { operatorRoot, pr: prNumber, dryRun, spawnFn } = input;
|
|
42056
|
-
const runDir =
|
|
42057
|
-
const findingsPath =
|
|
42309
|
+
const runDir = path59.resolve(input.from);
|
|
42310
|
+
const findingsPath = path59.join(runDir, "findings.json");
|
|
42058
42311
|
if (!existsSync38(findingsPath)) {
|
|
42059
42312
|
throw new CliUsageError(`${runDir} is missing findings.json \u2014 point --from at a completed ` + 'PR-mode run directory ("crysk review --pr <n>" writes it)');
|
|
42060
42313
|
}
|
|
@@ -42064,7 +42317,7 @@ async function runTriageReplyCommand(input) {
|
|
|
42064
42317
|
if (finding === undefined) {
|
|
42065
42318
|
throw new CliUsageError(`${findingsPath} has no finding ${input.findingId}`);
|
|
42066
42319
|
}
|
|
42067
|
-
const bodyPath =
|
|
42320
|
+
const bodyPath = path59.resolve(input.bodyFile);
|
|
42068
42321
|
if (!existsSync38(bodyPath)) {
|
|
42069
42322
|
throw new CliUsageError(`--body-file not found: ${bodyPath}`);
|
|
42070
42323
|
}
|
|
@@ -42072,8 +42325,8 @@ async function runTriageReplyCommand(input) {
|
|
|
42072
42325
|
if (matchMarkerPrefix(reasoning, TRIAGE_MARKER_PREFIX) !== undefined) {
|
|
42073
42326
|
throw new CliUsageError("--body-file must be reasoning prose only \u2014 the driver prepends the " + "triage marker and badge (do not start the file with " + "`<!-- crysk-triage`)");
|
|
42074
42327
|
}
|
|
42075
|
-
const anchorPath =
|
|
42076
|
-
const diffPath = existsSync38(anchorPath) ? anchorPath :
|
|
42328
|
+
const anchorPath = path59.join(runDir, "anchor.patch");
|
|
42329
|
+
const diffPath = existsSync38(anchorPath) ? anchorPath : path59.join(runDir, "diff.patch");
|
|
42077
42330
|
if (!existsSync38(diffPath)) {
|
|
42078
42331
|
throw new CliUsageError(`${runDir} is missing diff.patch \u2014 point --from at a completed ` + 'PR-mode run directory ("crysk review --pr <n>" writes it)');
|
|
42079
42332
|
}
|
|
@@ -42166,7 +42419,7 @@ In reply to: ${pullUrl}#issuecomment-${parent.id}
|
|
|
42166
42419
|
if (repoId) {
|
|
42167
42420
|
const db = openProductStore(layout.prheroDbPath);
|
|
42168
42421
|
try {
|
|
42169
|
-
const runDirBasename =
|
|
42422
|
+
const runDirBasename = path59.basename(runDir);
|
|
42170
42423
|
const runRow = db.query("SELECT id FROM runs WHERE repo_id = ? AND run_dir = ? LIMIT 1").get(repoId, runDirBasename);
|
|
42171
42424
|
if (runRow) {
|
|
42172
42425
|
recordFindingTriage(db, {
|
|
@@ -42276,7 +42529,7 @@ async function usageCommand(options) {
|
|
|
42276
42529
|
|
|
42277
42530
|
// src/corpus/corpus.ts
|
|
42278
42531
|
init_git();
|
|
42279
|
-
import
|
|
42532
|
+
import path60 from "path";
|
|
42280
42533
|
init_primitives();
|
|
42281
42534
|
init_errors();
|
|
42282
42535
|
async function gh2(operatorRoot, args, spawnFn) {
|
|
@@ -42909,7 +43162,7 @@ async function corpusCommand(options) {
|
|
|
42909
43162
|
threadCandidates
|
|
42910
43163
|
});
|
|
42911
43164
|
if (options.out) {
|
|
42912
|
-
const outPath =
|
|
43165
|
+
const outPath = path60.resolve(options.out);
|
|
42913
43166
|
await Bun.write(outPath, markdown);
|
|
42914
43167
|
log(`corpus: wrote ${outPath} (${selected.length} fix-shaped + ` + `${threadCandidates.length} caught-in-review candidate(s) from ` + `${mergedPrs.length} scanned PR(s))`);
|
|
42915
43168
|
return 0;
|
|
@@ -42925,7 +43178,7 @@ init_preflight2();
|
|
|
42925
43178
|
init_git();
|
|
42926
43179
|
init_primitives();
|
|
42927
43180
|
init_errors();
|
|
42928
|
-
import
|
|
43181
|
+
import path61 from "path";
|
|
42929
43182
|
async function gh3(operatorRoot, args, spawnFn) {
|
|
42930
43183
|
const spawn = spawnFn ?? Bun.spawn;
|
|
42931
43184
|
if (spawnFn === undefined && Bun.which("gh") === null) {
|
|
@@ -43122,7 +43375,7 @@ async function revertsCommand(options) {
|
|
|
43122
43375
|
candidates: mined.candidates
|
|
43123
43376
|
});
|
|
43124
43377
|
if (options.out) {
|
|
43125
|
-
const outPath =
|
|
43378
|
+
const outPath = path61.resolve(options.out);
|
|
43126
43379
|
await Bun.write(outPath, markdown);
|
|
43127
43380
|
log(`reverts: wrote ${outPath} (${mined.candidates.length} candidate(s) ` + `from ${mined.scannedCommits} commit(s))`);
|
|
43128
43381
|
return 0;
|