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:
commit
9e47ab339e
180 files changed
+15130
-1209
No files matched your search
+66
-14
@@ -36,19 +36,46 @@ test("triage events are parsed for issues and pull requests on open/edit/reopen"
|
||||
number: 5
|
||||
});
|
||||
|
||||
const pull = parseWebhookTriageEvent("pull_request", triagePayload({
|
||||
action: "reopened",
|
||||
pull_request: { number: 9 }
|
||||
}));
|
||||
const pull = parseWebhookTriageEvent(
|
||||
"pull_request",
|
||||
triagePayload({
|
||||
action: "reopened",
|
||||
pull_request: { number: 9 }
|
||||
})
|
||||
);
|
||||
assert.equal(pull?.kind, "pull_request");
|
||||
assert.equal(pull?.number, 9);
|
||||
});
|
||||
|
||||
test("triage parsing rejects other events, pushes, PR issues, and missing installation", () => {
|
||||
assert.equal(parseWebhookTriageEvent("issues", triagePayload({ action: "synchronize", issue: { number: 5 } })), null);
|
||||
assert.equal(parseWebhookTriageEvent("pull_request", triagePayload({ action: "closed", pull_request: { number: 9 } })), null);
|
||||
assert.equal(parseWebhookTriageEvent("issues", triagePayload({ issue: { number: 5, pull_request: { url: "x" } } })), null);
|
||||
assert.equal(parseWebhookTriageEvent("issues", triagePayload({ installation: undefined, issue: { number: 5 } })), null);
|
||||
assert.equal(
|
||||
parseWebhookTriageEvent(
|
||||
"issues",
|
||||
triagePayload({ action: "synchronize", issue: { number: 5 } })
|
||||
),
|
||||
null
|
||||
);
|
||||
assert.equal(
|
||||
parseWebhookTriageEvent(
|
||||
"pull_request",
|
||||
triagePayload({ action: "closed", pull_request: { number: 9 } })
|
||||
),
|
||||
null
|
||||
);
|
||||
assert.equal(
|
||||
parseWebhookTriageEvent(
|
||||
"issues",
|
||||
triagePayload({ issue: { number: 5, pull_request: { url: "x" } } })
|
||||
),
|
||||
null
|
||||
);
|
||||
assert.equal(
|
||||
parseWebhookTriageEvent(
|
||||
"issues",
|
||||
triagePayload({ installation: undefined, issue: { number: 5 } })
|
||||
),
|
||||
null
|
||||
);
|
||||
assert.equal(parseWebhookTriageEvent("issue_comment", triagePayload()), null);
|
||||
});
|
||||
|
||||
@@ -76,8 +103,21 @@ const mention: WebhookMention = {
|
||||
};
|
||||
|
||||
const baseContext: WebhookContext = {
|
||||
repository: { fullName: "forumlify/public", description: null, defaultBranch: "main", readme: "" },
|
||||
item: { number: 3, title: "t", body: "", state: "open", url: "", kind: "pull_request", author: null },
|
||||
repository: {
|
||||
fullName: "forumlify/public",
|
||||
description: null,
|
||||
defaultBranch: "main",
|
||||
readme: ""
|
||||
},
|
||||
item: {
|
||||
number: 3,
|
||||
title: "t",
|
||||
body: "",
|
||||
state: "open",
|
||||
url: "",
|
||||
kind: "pull_request",
|
||||
author: null
|
||||
},
|
||||
discussion: []
|
||||
};
|
||||
|
||||
@@ -88,7 +128,10 @@ test("webhook chat prompt embeds host-curated knowledge when available", () => {
|
||||
});
|
||||
assert.match(withKnowledge, /Verified repository knowledge curated by the host process/);
|
||||
assert.match(withKnowledge, /npm test\./);
|
||||
assert.match(withKnowledge, /current repository evidence always takes precedence over cached knowledge/);
|
||||
assert.match(
|
||||
withKnowledge,
|
||||
/current repository evidence always takes precedence over cached knowledge/
|
||||
);
|
||||
|
||||
const withoutKnowledge = buildWebhookChatPrompt(mention, baseContext);
|
||||
assert.doesNotMatch(withoutKnowledge, /Verified repository knowledge/);
|
||||
@@ -99,15 +142,24 @@ test("uninitialized knowledge scaffold is detected and never injected", async ()
|
||||
try {
|
||||
const scaffold = await loadRepositoryKnowledge(runtimeDirectory);
|
||||
assert.equal(isUninitializedRepositoryKnowledge(scaffold), true);
|
||||
assert.equal(isUninitializedRepositoryKnowledge("# ghbot repository knowledge\n\nTests: npm test.\n"), false);
|
||||
assert.equal(
|
||||
isUninitializedRepositoryKnowledge("# ghbot repository knowledge\n\nTests: npm test.\n"),
|
||||
false
|
||||
);
|
||||
} finally {
|
||||
await fs.rm(runtimeDirectory, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("webhook knowledge loader degrades to undefined without R2 or repository id", async () => {
|
||||
assert.equal(await loadWebhookRepositoryKnowledge({ owner: "forumlify", repo: "public" }), undefined);
|
||||
assert.equal(await loadWebhookRepositoryKnowledge({ repositoryId: 7, owner: "forumlify", repo: "public" }), undefined);
|
||||
assert.equal(
|
||||
await loadWebhookRepositoryKnowledge({ owner: "forumlify", repo: "public" }),
|
||||
undefined
|
||||
);
|
||||
assert.equal(
|
||||
await loadWebhookRepositoryKnowledge({ repositoryId: 7, owner: "forumlify", repo: "public" }),
|
||||
undefined
|
||||
);
|
||||
});
|
||||
|
||||
test("webhook chat prompt stays read-only in both variants", () => {
|
||||
|
||||
Reference in new issue
Block a user