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
+99
-63
@@ -39,76 +39,112 @@ function csvListWithDefault(defaultValue: string[]) {
|
||||
}, z.array(z.string()));
|
||||
}
|
||||
|
||||
const configSchema = z.object({
|
||||
port: z.coerce.number().int().positive().default(3000),
|
||||
githubToken: optionalString,
|
||||
githubAppId: optionalString,
|
||||
githubAppPrivateKey: optionalString,
|
||||
githubAppInstallationId: z.preprocess((value) => {
|
||||
if (value === "" || value === undefined) {
|
||||
return undefined;
|
||||
const configSchema = z
|
||||
.object({
|
||||
port: z.coerce.number().int().positive().default(3000),
|
||||
githubToken: optionalString,
|
||||
githubAppId: optionalString,
|
||||
githubAppPrivateKey: optionalString,
|
||||
githubAppInstallationId: z.preprocess((value) => {
|
||||
if (value === "" || value === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return value;
|
||||
}, z.coerce.number().int().positive().optional()),
|
||||
webhookEnabled: envBoolean.default(false),
|
||||
webhookSecret: optionalString,
|
||||
webhookPath: z.string().startsWith("/").default("/webhooks/github"),
|
||||
webhookChatPermission: z.enum(["anyone", "read", "write"]).default("read"),
|
||||
webhookQueueConcurrency: z.coerce.number().int().positive().max(20).default(2),
|
||||
webhookQueueLimit: z.coerce.number().int().positive().max(10_000).default(500),
|
||||
webhookTriageEnabled: envBoolean.default(true),
|
||||
runtimeDirectory: optionalString,
|
||||
gooseModel: optionalString.default("gpt-5.4"),
|
||||
gooseThinkingEffort: z.preprocess(
|
||||
(value) => {
|
||||
if (value === "" || value === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (value === "minimal") {
|
||||
return "low";
|
||||
}
|
||||
|
||||
if (value === "xhigh") {
|
||||
return "max";
|
||||
}
|
||||
|
||||
return value;
|
||||
},
|
||||
z.enum(["off", "low", "medium", "high", "max"]).optional()
|
||||
),
|
||||
gooseBaseUrl: optionalString.default("https://api.openai.com/v1"),
|
||||
gooseApiKey: optionalString,
|
||||
reviewPolicy: z.enum(["allow", "require_approval", "reject"]).default("allow"),
|
||||
reviewStrictness: z.enum(["normal", "strict"]).default("normal"),
|
||||
reviewInstructions: optionalString,
|
||||
reviewBranches: csvListWithDefault([]),
|
||||
repositoryKnowledgeEnabled: envBoolean.default(true),
|
||||
repositoryKnowledgeWrite: envBoolean.default(false),
|
||||
r2Endpoint: optionalString,
|
||||
r2BucketName: optionalString,
|
||||
r2Prefix: optionalString,
|
||||
r2AccessKeyId: optionalString,
|
||||
r2SecretAccessKey: optionalString,
|
||||
triageEnabled: envBoolean.default(true),
|
||||
triageLabels: csvListWithDefault([
|
||||
"bug",
|
||||
"enhancement",
|
||||
"documentation",
|
||||
"question",
|
||||
"maintenance"
|
||||
]).refine((labels) => labels.length > 0, "TRIAGE_LABELS must contain at least one label."),
|
||||
triageDuplicateLabel: z.string().min(1).default("duplicate"),
|
||||
triageCandidateLimit: z.coerce.number().int().positive().max(100).default(50),
|
||||
triageInstructions: optionalString,
|
||||
botName: z.string().min(1).default("ghbot"),
|
||||
autoMerge: envBoolean.default(false),
|
||||
autoResolveConflicts: envBoolean.default(false),
|
||||
conflictTestCommand: optionalString,
|
||||
mergeMethod: z.enum(["merge", "squash", "rebase"]).default("squash"),
|
||||
requireChecks: envBoolean.default(true),
|
||||
maxPatchChars: z.coerce.number().int().positive().default(120_000),
|
||||
logLevel: z.string().min(1).default("info")
|
||||
})
|
||||
.superRefine((value, ctx) => {
|
||||
if (value.webhookEnabled && !value.webhookSecret) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: ["webhookSecret"],
|
||||
message: "WEBHOOK_SECRET is required when WEBHOOK_ENABLED=true."
|
||||
});
|
||||
}
|
||||
|
||||
return value;
|
||||
}, z.coerce.number().int().positive().optional()),
|
||||
webhookEnabled: envBoolean.default(false),
|
||||
webhookSecret: optionalString,
|
||||
webhookPath: z.string().startsWith("/").default("/webhooks/github"),
|
||||
webhookChatPermission: z.enum(["anyone", "read", "write"]).default("read"),
|
||||
webhookQueueConcurrency: z.coerce.number().int().positive().max(20).default(2),
|
||||
webhookQueueLimit: z.coerce.number().int().positive().max(10_000).default(500),
|
||||
webhookTriageEnabled: envBoolean.default(true),
|
||||
gooseModel: optionalString.default("gpt-5.4"),
|
||||
gooseThinkingEffort: z.preprocess((value) => {
|
||||
if (value === "" || value === undefined) {
|
||||
return undefined;
|
||||
const r2Values = [
|
||||
value.r2Endpoint,
|
||||
value.r2BucketName,
|
||||
value.r2AccessKeyId,
|
||||
value.r2SecretAccessKey
|
||||
];
|
||||
const configuredR2Values = r2Values.filter(Boolean).length;
|
||||
if (configuredR2Values > 0 && configuredR2Values < r2Values.length) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: ["r2Endpoint"],
|
||||
message:
|
||||
"R2_ENDPOINT, R2_BUCKET_NAME, R2_ACCESS_KEY_ID, and R2_SECRET_ACCESS_KEY must be configured together."
|
||||
});
|
||||
}
|
||||
|
||||
if (value === "minimal") {
|
||||
return "low";
|
||||
}
|
||||
|
||||
if (value === "xhigh") {
|
||||
return "max";
|
||||
}
|
||||
|
||||
return value;
|
||||
}, z.enum(["off", "low", "medium", "high", "max"]).optional()),
|
||||
gooseBaseUrl: optionalString,
|
||||
gooseApiKey: optionalString,
|
||||
reviewPolicy: z.enum(["allow", "require_approval", "reject"]).default("allow"),
|
||||
reviewStrictness: z.enum(["normal", "strict"]).default("normal"),
|
||||
reviewInstructions: optionalString,
|
||||
reviewBranches: csvListWithDefault([]),
|
||||
repositoryKnowledgeEnabled: envBoolean.default(true),
|
||||
repositoryKnowledgeWrite: envBoolean.default(false),
|
||||
r2Endpoint: optionalString,
|
||||
r2BucketName: optionalString,
|
||||
r2Prefix: optionalString,
|
||||
r2AccessKeyId: optionalString,
|
||||
r2SecretAccessKey: optionalString,
|
||||
triageEnabled: envBoolean.default(true),
|
||||
triageLabels: csvListWithDefault(["bug", "enhancement", "documentation", "question", "maintenance"])
|
||||
.refine((labels) => labels.length > 0, "TRIAGE_LABELS must contain at least one label."),
|
||||
triageDuplicateLabel: z.string().min(1).default("duplicate"),
|
||||
triageCandidateLimit: z.coerce.number().int().positive().max(100).default(50),
|
||||
triageInstructions: optionalString,
|
||||
botName: z.string().min(1).default("ghbot"),
|
||||
autoMerge: envBoolean.default(false),
|
||||
autoResolveConflicts: envBoolean.default(false),
|
||||
conflictTestCommand: optionalString,
|
||||
mergeMethod: z.enum(["merge", "squash", "rebase"]).default("squash"),
|
||||
requireChecks: envBoolean.default(true),
|
||||
maxPatchChars: z.coerce.number().int().positive().default(120_000),
|
||||
logLevel: z.string().min(1).default("info")
|
||||
});
|
||||
});
|
||||
|
||||
export const config = configSchema.parse({
|
||||
port: process.env.PORT,
|
||||
githubToken: process.env.GITHUB_TOKEN,
|
||||
githubAppId: process.env.GH_APP_ID ?? process.env.GITHUB_APP_ID,
|
||||
githubAppPrivateKey: process.env.GH_APP_PRIVATE_KEY ?? process.env.GITHUB_APP_PRIVATE_KEY,
|
||||
githubAppInstallationId: process.env.GH_APP_INSTALLATION_ID ?? process.env.GITHUB_APP_INSTALLATION_ID,
|
||||
githubAppInstallationId:
|
||||
process.env.GH_APP_INSTALLATION_ID ?? process.env.GITHUB_APP_INSTALLATION_ID,
|
||||
webhookEnabled: process.env.WEBHOOK_ENABLED,
|
||||
webhookSecret: process.env.WEBHOOK_SECRET,
|
||||
webhookPath: process.env.WEBHOOK_PATH,
|
||||
@@ -116,9 +152,9 @@ export const config = configSchema.parse({
|
||||
webhookQueueConcurrency: process.env.WEBHOOK_QUEUE_CONCURRENCY,
|
||||
webhookQueueLimit: process.env.WEBHOOK_QUEUE_LIMIT,
|
||||
webhookTriageEnabled: process.env.WEBHOOK_TRIAGE_ENABLED,
|
||||
runtimeDirectory: process.env.GHBOT_RUNTIME_DIR,
|
||||
gooseModel: process.env.GOOSE_MODEL ?? process.env.OPENCODE_MODEL,
|
||||
gooseThinkingEffort:
|
||||
process.env.GOOSE_THINKING_EFFORT ?? process.env.OPENCODE_REASONING_EFFORT,
|
||||
gooseThinkingEffort: process.env.GOOSE_THINKING_EFFORT ?? process.env.OPENCODE_REASONING_EFFORT,
|
||||
gooseBaseUrl: process.env.GOOSE_BASE_URL ?? process.env.OPENCODE_BASE_URL,
|
||||
gooseApiKey: process.env.GOOSE_API_KEY ?? process.env.OPENCODE_API_KEY,
|
||||
reviewPolicy: process.env.REVIEW_POLICY,
|
||||
|
||||
Reference in new issue
Block a user