feat: sync ghbot-Nodeloc v1.2.0 capabilities into upstream

Merges all 33 commits from lza6/ghbot-Nodeloc (v1.0.0 through v1.2.0)
while keeping both sides' features in every conflicted file:

- EventRouter dispatch extracted from runReview.ts (7.1), with the
  runtime environment block preserved on the review-start comment
- Unified command ack messages (6.3) combined with the collapsed
  runtime environment block and bot signature on /recheck replies
- Status banner and collapsible unposted findings in review bodies (6.1)
- Centralized runtime directories behind GHBOT_RUNTIME_DIR (D-13);
  webhook knowledge cache now lives under tempRootDirectory()
- Production hardening for merge races, timeouts, webhook ops;
  atomic temp-file rename for R2 cache restores kept from upstream
- Webhook parity retained: triage events gated by WEBHOOK_TRIAGE_ENABLED,
  read-only command guidance, repository knowledge injection,
  runtime environment block on webhook chat replies
- Sanitization/secret redaction centralization, error-aware retry,
  duplicate merge prevention, in-process webhook retries, /metrics
- Infra: eslint/prettier gates with CI verify workflow, docs archives

typecheck, eslint, prettier format:check, and 164 tests all pass.
This commit is contained in:
lezi-fun committed 2026-08-24 11:47:28 +08:00
commit 9e47ab339e
180 files changed
+15130 -1209

No files matched your search

+3 -1
View File
@@ -23,7 +23,9 @@ export async function createGitHubCredentials(params?: {
(params ? await resolveInstallationId(auth, params.owner, params.repo) : undefined);
if (!installationId) {
throw new Error("GitHub App installation id is not configured and could not be resolved from the repository.");
throw new Error(
"GitHub App installation id is not configured and could not be resolved from the repository."
);
}
const installationAuthentication = await auth({
+17
View File
@@ -14,6 +14,23 @@ export function formatPermissionDeniedMessage(
].join(" ");
}
export function formatCommandAckMessage(
commenterLogin: string,
actorName: string,
command: "/recheck" | "/conflict"
): string {
if (command === "/recheck") {
return [
`${actorName} received \`/recheck\` requested by @${commenterLogin}.`,
"The full review is running now with the repository's current strictness settings; the result will be posted in this conversation when it completes."
].join(" ");
}
return [
`${actorName} received \`/conflict\` requested by @${commenterLogin}.`,
"Conflict repair can take up to 45 minutes (editing, isolated validation, and a final safety confirmation). A follow-up comment will report the outcome, and nothing is pushed unless every guard passes."
].join(" ");
}
export async function postPermissionDeniedComment(
octokit: Octokit,
params: {
+28
View File
@@ -0,0 +1,28 @@
import type { Octokit } from "@octokit/rest";
import type { PullRequestFile } from "../types.js";
/**
* Shared paginated PR file listing used by the review processor, the PR chat
* snapshot flow, and the webhook context loader.
*/
export async function listPullRequestFiles(
octokit: Octokit,
owner: string,
repo: string,
pullNumber: number
): Promise<PullRequestFile[]> {
const files = await octokit.paginate(octokit.rest.pulls.listFiles, {
owner,
repo,
pull_number: pullNumber,
per_page: 100
});
return files.map((file) => ({
filename: file.filename,
patch: file.patch,
status: file.status,
additions: file.additions,
deletions: file.deletions
}));
}
+10 -11
View File
@@ -35,10 +35,7 @@ function eventLine(): string | undefined {
function r2CacheEnabled(): boolean {
return Boolean(
config.r2Endpoint &&
config.r2BucketName &&
config.r2AccessKeyId &&
config.r2SecretAccessKey
config.r2Endpoint && config.r2BucketName && config.r2AccessKeyId && config.r2SecretAccessKey
);
}
@@ -58,13 +55,15 @@ export function formatRuntimeEnvironmentDetails(mode: RuntimeMode = detectRuntim
);
} else {
const event = eventLine();
const modeLabel = mode === "actions"
? event ? `GitHub Actions (${event})` : "GitHub Actions"
: event ? `local run (${event})` : "local run";
lines.push(
`- **Mode:** ${modeLabel}`,
`- **Runner:** ${hostLine()}`
);
const modeLabel =
mode === "actions"
? event
? `GitHub Actions (${event})`
: "GitHub Actions"
: event
? `local run (${event})`
: "local run";
lines.push(`- **Mode:** ${modeLabel}`, `- **Runner:** ${hostLine()}`);
}
const gooseParts = [