@jonit-dev/night-watch-cli 1.8.12-beta.11 → 1.8.12-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +159 -45
- package/dist/commands/audit.d.ts.map +1 -1
- package/dist/commands/audit.js +5 -1
- package/dist/commands/audit.js.map +1 -1
- package/dist/commands/run.d.ts +14 -1
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +97 -40
- package/dist/commands/run.js.map +1 -1
- package/dist/scripts/night-watch-audit-cron.sh +11 -1
- package/dist/scripts/night-watch-cron.sh +4 -2
- package/dist/templates/audit.md +64 -30
- package/dist/templates/night-watch-audit.md +71 -30
- package/dist/web/assets/index-CL3Q-KB4.css +1 -0
- package/dist/web/assets/index-FDOCfjkP.js +442 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -290,13 +290,14 @@ var init_job_registry = __esm({
|
|
|
290
290
|
{
|
|
291
291
|
id: "audit",
|
|
292
292
|
name: "Auditor",
|
|
293
|
-
description: "Performs
|
|
293
|
+
description: "Performs consolidated architecture and code quality audits",
|
|
294
294
|
cliCommand: "audit",
|
|
295
295
|
logName: "audit",
|
|
296
296
|
lockSuffix: "-audit.lock",
|
|
297
297
|
queuePriority: 10,
|
|
298
298
|
envPrefix: "NW_AUDIT",
|
|
299
299
|
extraFields: [
|
|
300
|
+
{ name: "createIssues", type: "boolean", defaultValue: false },
|
|
300
301
|
{
|
|
301
302
|
name: "targetColumn",
|
|
302
303
|
type: "enum",
|
|
@@ -305,9 +306,10 @@ var init_job_registry = __esm({
|
|
|
305
306
|
}
|
|
306
307
|
],
|
|
307
308
|
defaultConfig: {
|
|
308
|
-
enabled:
|
|
309
|
+
enabled: false,
|
|
309
310
|
schedule: "50 3 * * 1",
|
|
310
311
|
maxRuntime: 1800,
|
|
312
|
+
createIssues: false,
|
|
311
313
|
targetColumn: "Draft"
|
|
312
314
|
}
|
|
313
315
|
},
|
|
@@ -390,7 +392,7 @@ function resolveProviderBucketKey(provider, providerEnv) {
|
|
|
390
392
|
return `claude-proxy:${baseUrl}`;
|
|
391
393
|
}
|
|
392
394
|
}
|
|
393
|
-
var DEFAULT_DEFAULT_BRANCH, DEFAULT_PRD_DIR, DEFAULT_SUMMARY_WINDOW_HOURS, DEFAULT_MAX_RUNTIME, DEFAULT_REVIEWER_MAX_RUNTIME, DEFAULT_CRON_SCHEDULE, DEFAULT_REVIEWER_SCHEDULE, DEFAULT_CRON_SCHEDULE_OFFSET, DEFAULT_MAX_RETRIES, DEFAULT_REVIEWER_MAX_RETRIES, DEFAULT_REVIEWER_RETRY_DELAY, DEFAULT_REVIEWER_MAX_PRS_PER_RUN, DEFAULT_FEEDBACK, DEFAULT_BRANCH_PREFIX, DEFAULT_BRANCH_PATTERNS, DEFAULT_MIN_REVIEW_SCORE, DEFAULT_MAX_LOG_SIZE, DEFAULT_PROVIDER, DEFAULT_EXECUTOR_ENABLED, DEFAULT_REVIEWER_ENABLED, DEFAULT_PROVIDER_ENV, DEFAULT_FALLBACK_ON_RATE_LIMIT, DEFAULT_CLAUDE_MODEL, DEFAULT_PRIMARY_FALLBACK_MODEL, DEFAULT_SECONDARY_FALLBACK_MODEL, VALID_CLAUDE_MODELS, CLAUDE_MODEL_IDS, DEFAULT_NOTIFICATIONS, DEFAULT_PRD_PRIORITY, DEFAULT_SLICER_SCHEDULE, DEFAULT_SLICER_MAX_RUNTIME, DEFAULT_ROADMAP_SCANNER, DEFAULT_TEMPLATES_DIR, DEFAULT_BOARD_PROVIDER, DEFAULT_LOCAL_BOARD_INFO, DEFAULT_AUTO_MERGE, DEFAULT_AUTO_MERGE_METHOD, VALID_MERGE_METHODS, DEFAULT_QA_ENABLED, DEFAULT_QA_SCHEDULE, DEFAULT_QA_MAX_RUNTIME, DEFAULT_QA_ARTIFACTS, DEFAULT_QA_SKIP_LABEL, DEFAULT_QA_AUTO_INSTALL_PLAYWRIGHT, DEFAULT_QA_VALIDATED_LABEL, DEFAULT_QA, QA_LOG_NAME, DEFAULT_AUDIT_ENABLED, DEFAULT_AUDIT_SCHEDULE, DEFAULT_AUDIT_MAX_RUNTIME, DEFAULT_AUDIT_TARGET_COLUMN, DEFAULT_AUDIT, DEFAULT_ANALYTICS_ENABLED, DEFAULT_ANALYTICS_SCHEDULE, DEFAULT_ANALYTICS_MAX_RUNTIME, DEFAULT_ANALYTICS_LOOKBACK_DAYS, DEFAULT_ANALYTICS_TARGET_COLUMN, DEFAULT_ANALYTICS_PROMPT, DEFAULT_ANALYTICS, DEFAULT_PR_RESOLVER_ENABLED, DEFAULT_PR_RESOLVER_SCHEDULE, DEFAULT_PR_RESOLVER_MAX_RUNTIME, DEFAULT_PR_RESOLVER_MAX_PRS_PER_RUN, DEFAULT_PR_RESOLVER_PER_PR_TIMEOUT, DEFAULT_PR_RESOLVER_AI_CONFLICT_RESOLUTION, DEFAULT_PR_RESOLVER_AI_REVIEW_RESOLUTION, DEFAULT_PR_RESOLVER_READY_LABEL, DEFAULT_PR_RESOLVER, DEFAULT_MERGER_ENABLED, DEFAULT_MERGER_SCHEDULE, DEFAULT_MERGER_MAX_RUNTIME, DEFAULT_MERGER_MERGE_METHOD, DEFAULT_MERGER_MIN_REVIEW_SCORE, DEFAULT_MERGER_REBASE_BEFORE_MERGE, DEFAULT_MERGER_MAX_PRS_PER_RUN, DEFAULT_MERGER, MERGER_LOG_NAME, AUDIT_LOG_NAME, PLANNER_LOG_NAME, ANALYTICS_LOG_NAME, PR_RESOLVER_LOG_NAME, VALID_PROVIDERS, VALID_JOB_TYPES, DEFAULT_JOB_PROVIDERS, DEFAULT_PROVIDER_SCHEDULE_OVERRIDES, DEFAULT_WEBHOOK_TRIGGER_SECRET_ENV, DEFAULT_WEBHOOK_TRIGGER_MAX_SKEW_SECONDS, DEFAULT_WEBHOOK_TRIGGERS, BUILT_IN_PRESETS, BUILT_IN_PRESET_IDS, PROVIDER_COMMANDS, CONFIG_FILE_NAME, LOCK_FILE_PREFIX, LOG_DIR, CLAIM_FILE_EXTENSION, EXECUTOR_LOG_NAME, REVIEWER_LOG_NAME, EXECUTOR_LOG_FILE, REVIEWER_LOG_FILE, LOG_FILE_NAMES, GLOBAL_CONFIG_DIR, REGISTRY_FILE_NAME, HISTORY_FILE_NAME, PRD_STATES_FILE_NAME, STATE_DB_FILE_NAME, GLOBAL_NOTIFICATIONS_FILE_NAME, MAX_HISTORY_RECORDS_PER_PRD, DEFAULT_QUEUE_ENABLED, DEFAULT_QUEUE_MODE, DEFAULT_QUEUE_MAX_CONCURRENCY, DEFAULT_QUEUE_MAX_WAIT_TIME, DEFAULT_QUEUE_PRIORITY, DEFAULT_QUEUE, DEFAULT_SCHEDULING_PRIORITY;
|
|
395
|
+
var DEFAULT_DEFAULT_BRANCH, DEFAULT_PRD_DIR, DEFAULT_SUMMARY_WINDOW_HOURS, DEFAULT_MAX_RUNTIME, DEFAULT_REVIEWER_MAX_RUNTIME, DEFAULT_CRON_SCHEDULE, DEFAULT_REVIEWER_SCHEDULE, DEFAULT_CRON_SCHEDULE_OFFSET, DEFAULT_MAX_RETRIES, DEFAULT_REVIEWER_MAX_RETRIES, DEFAULT_REVIEWER_RETRY_DELAY, DEFAULT_REVIEWER_MAX_PRS_PER_RUN, DEFAULT_FEEDBACK, DEFAULT_BRANCH_PREFIX, DEFAULT_BRANCH_PATTERNS, DEFAULT_MIN_REVIEW_SCORE, DEFAULT_MAX_LOG_SIZE, DEFAULT_PROVIDER, DEFAULT_EXECUTOR_ENABLED, DEFAULT_REVIEWER_ENABLED, DEFAULT_PROVIDER_ENV, DEFAULT_FALLBACK_ON_RATE_LIMIT, DEFAULT_CLAUDE_MODEL, DEFAULT_PRIMARY_FALLBACK_MODEL, DEFAULT_SECONDARY_FALLBACK_MODEL, VALID_CLAUDE_MODELS, CLAUDE_MODEL_IDS, DEFAULT_NOTIFICATIONS, DEFAULT_PRD_PRIORITY, DEFAULT_SLICER_SCHEDULE, DEFAULT_SLICER_MAX_RUNTIME, DEFAULT_ROADMAP_SCANNER, DEFAULT_TEMPLATES_DIR, DEFAULT_BOARD_PROVIDER, DEFAULT_LOCAL_BOARD_INFO, DEFAULT_AUTO_MERGE, DEFAULT_AUTO_MERGE_METHOD, VALID_MERGE_METHODS, DEFAULT_QA_ENABLED, DEFAULT_QA_SCHEDULE, DEFAULT_QA_MAX_RUNTIME, DEFAULT_QA_ARTIFACTS, DEFAULT_QA_SKIP_LABEL, DEFAULT_QA_AUTO_INSTALL_PLAYWRIGHT, DEFAULT_QA_VALIDATED_LABEL, DEFAULT_QA, QA_LOG_NAME, DEFAULT_AUDIT_ENABLED, DEFAULT_AUDIT_SCHEDULE, DEFAULT_AUDIT_MAX_RUNTIME, DEFAULT_AUDIT_CREATE_ISSUES, DEFAULT_AUDIT_TARGET_COLUMN, DEFAULT_AUDIT, DEFAULT_ANALYTICS_ENABLED, DEFAULT_ANALYTICS_SCHEDULE, DEFAULT_ANALYTICS_MAX_RUNTIME, DEFAULT_ANALYTICS_LOOKBACK_DAYS, DEFAULT_ANALYTICS_TARGET_COLUMN, DEFAULT_ANALYTICS_PROMPT, DEFAULT_ANALYTICS, DEFAULT_PR_RESOLVER_ENABLED, DEFAULT_PR_RESOLVER_SCHEDULE, DEFAULT_PR_RESOLVER_MAX_RUNTIME, DEFAULT_PR_RESOLVER_MAX_PRS_PER_RUN, DEFAULT_PR_RESOLVER_PER_PR_TIMEOUT, DEFAULT_PR_RESOLVER_AI_CONFLICT_RESOLUTION, DEFAULT_PR_RESOLVER_AI_REVIEW_RESOLUTION, DEFAULT_PR_RESOLVER_READY_LABEL, DEFAULT_PR_RESOLVER, DEFAULT_MERGER_ENABLED, DEFAULT_MERGER_SCHEDULE, DEFAULT_MERGER_MAX_RUNTIME, DEFAULT_MERGER_MERGE_METHOD, DEFAULT_MERGER_MIN_REVIEW_SCORE, DEFAULT_MERGER_REBASE_BEFORE_MERGE, DEFAULT_MERGER_MAX_PRS_PER_RUN, DEFAULT_MERGER, MERGER_LOG_NAME, AUDIT_LOG_NAME, PLANNER_LOG_NAME, ANALYTICS_LOG_NAME, PR_RESOLVER_LOG_NAME, VALID_PROVIDERS, VALID_JOB_TYPES, DEFAULT_JOB_PROVIDERS, DEFAULT_PROVIDER_SCHEDULE_OVERRIDES, DEFAULT_WEBHOOK_TRIGGER_SECRET_ENV, DEFAULT_WEBHOOK_TRIGGER_MAX_SKEW_SECONDS, DEFAULT_WEBHOOK_TRIGGERS, BUILT_IN_PRESETS, BUILT_IN_PRESET_IDS, PROVIDER_COMMANDS, CONFIG_FILE_NAME, LOCK_FILE_PREFIX, LOG_DIR, CLAIM_FILE_EXTENSION, EXECUTOR_LOG_NAME, REVIEWER_LOG_NAME, EXECUTOR_LOG_FILE, REVIEWER_LOG_FILE, LOG_FILE_NAMES, GLOBAL_CONFIG_DIR, REGISTRY_FILE_NAME, HISTORY_FILE_NAME, PRD_STATES_FILE_NAME, STATE_DB_FILE_NAME, GLOBAL_NOTIFICATIONS_FILE_NAME, MAX_HISTORY_RECORDS_PER_PRD, DEFAULT_QUEUE_ENABLED, DEFAULT_QUEUE_MODE, DEFAULT_QUEUE_MAX_CONCURRENCY, DEFAULT_QUEUE_MAX_WAIT_TIME, DEFAULT_QUEUE_PRIORITY, DEFAULT_QUEUE, DEFAULT_SCHEDULING_PRIORITY;
|
|
394
396
|
var init_constants = __esm({
|
|
395
397
|
"../core/dist/constants.js"() {
|
|
396
398
|
"use strict";
|
|
@@ -471,14 +473,16 @@ var init_constants = __esm({
|
|
|
471
473
|
validatedLabel: DEFAULT_QA_VALIDATED_LABEL
|
|
472
474
|
};
|
|
473
475
|
QA_LOG_NAME = "night-watch-qa";
|
|
474
|
-
DEFAULT_AUDIT_ENABLED =
|
|
476
|
+
DEFAULT_AUDIT_ENABLED = false;
|
|
475
477
|
DEFAULT_AUDIT_SCHEDULE = "50 3 * * 1";
|
|
476
478
|
DEFAULT_AUDIT_MAX_RUNTIME = 1800;
|
|
479
|
+
DEFAULT_AUDIT_CREATE_ISSUES = false;
|
|
477
480
|
DEFAULT_AUDIT_TARGET_COLUMN = "Draft";
|
|
478
481
|
DEFAULT_AUDIT = {
|
|
479
482
|
enabled: DEFAULT_AUDIT_ENABLED,
|
|
480
483
|
schedule: DEFAULT_AUDIT_SCHEDULE,
|
|
481
484
|
maxRuntime: DEFAULT_AUDIT_MAX_RUNTIME,
|
|
485
|
+
createIssues: DEFAULT_AUDIT_CREATE_ISSUES,
|
|
482
486
|
targetColumn: DEFAULT_AUDIT_TARGET_COLUMN
|
|
483
487
|
};
|
|
484
488
|
DEFAULT_ANALYTICS_ENABLED = false;
|
|
@@ -867,7 +871,11 @@ function normalizeConfig(rawConfig) {
|
|
|
867
871
|
continue;
|
|
868
872
|
const rawJob = readObject2(rawConfig[jobId]);
|
|
869
873
|
if (rawJob) {
|
|
870
|
-
|
|
874
|
+
const normalizedJob = normalizeJobConfig(rawJob, jobDef);
|
|
875
|
+
if (jobId === "audit" && rawJob.createIssues === void 0 && rawJob.targetColumn !== void 0) {
|
|
876
|
+
normalizedJob.createIssues = true;
|
|
877
|
+
}
|
|
878
|
+
normalized[jobId] = normalizedJob;
|
|
871
879
|
}
|
|
872
880
|
}
|
|
873
881
|
const prResolverDef = getJobDef("pr-resolver");
|
|
@@ -5977,12 +5985,19 @@ function formatDiscordPayload(ctx) {
|
|
|
5977
5985
|
function formatTelegramPayload(ctx) {
|
|
5978
5986
|
const emoji = getEventEmoji(ctx.event);
|
|
5979
5987
|
const title = ctx.event === "run_succeeded" ? "PR Opened" : getEventTitle(ctx.event);
|
|
5980
|
-
if (ctx.prUrl
|
|
5988
|
+
if (ctx.prUrl || ctx.prTitle || ctx.prNumber !== void 0) {
|
|
5981
5989
|
const lines = [];
|
|
5990
|
+
const prLabelParts = ["PR"];
|
|
5991
|
+
if (ctx.prNumber !== void 0) {
|
|
5992
|
+
prLabelParts.push(`#${ctx.prNumber}`);
|
|
5993
|
+
}
|
|
5994
|
+
const prLabel = ctx.prTitle ? `${prLabelParts.join(" ")}: ${ctx.prTitle}` : prLabelParts.join(" ");
|
|
5982
5995
|
lines.push(`*${escapeMarkdownV2(emoji + " " + title)}*`);
|
|
5983
5996
|
lines.push("");
|
|
5984
|
-
lines.push(`${escapeMarkdownV2("\u{1F4CB}")} *${escapeMarkdownV2(
|
|
5985
|
-
|
|
5997
|
+
lines.push(`${escapeMarkdownV2("\u{1F4CB}")} *${escapeMarkdownV2(prLabel)}*`);
|
|
5998
|
+
if (ctx.prUrl) {
|
|
5999
|
+
lines.push(`${escapeMarkdownV2("\u{1F517}")} ${escapeMarkdownV2(ctx.prUrl)}`);
|
|
6000
|
+
}
|
|
5986
6001
|
if (ctx.prBody && ctx.prBody.trim().length > 0) {
|
|
5987
6002
|
const summary = extractSummary(ctx.prBody);
|
|
5988
6003
|
if (summary) {
|
|
@@ -6030,7 +6045,16 @@ function formatTelegramPayload(ctx) {
|
|
|
6030
6045
|
}
|
|
6031
6046
|
}
|
|
6032
6047
|
lines.push("");
|
|
6033
|
-
lines.push(escapeMarkdownV2(
|
|
6048
|
+
lines.push(escapeMarkdownV2("\u2699\uFE0F Meta"));
|
|
6049
|
+
lines.push(escapeMarkdownV2(`Project: ${ctx.projectName}`));
|
|
6050
|
+
lines.push(escapeMarkdownV2(`Provider: ${ctx.provider}`));
|
|
6051
|
+
lines.push(escapeMarkdownV2(`Exit code: ${ctx.exitCode}`));
|
|
6052
|
+
if (ctx.prdName) {
|
|
6053
|
+
lines.push(escapeMarkdownV2(`PRD: ${ctx.prdName}`));
|
|
6054
|
+
}
|
|
6055
|
+
if (ctx.branchName) {
|
|
6056
|
+
lines.push(escapeMarkdownV2(`Branch: ${ctx.branchName}`));
|
|
6057
|
+
}
|
|
6034
6058
|
return {
|
|
6035
6059
|
text: lines.join("\n"),
|
|
6036
6060
|
parse_mode: "MarkdownV2"
|
|
@@ -8651,6 +8675,16 @@ function buildIssueBody(finding) {
|
|
|
8651
8675
|
async function syncAuditFindingsToBoard(config, projectDir) {
|
|
8652
8676
|
const findings = loadAuditFindings(projectDir);
|
|
8653
8677
|
const targetColumn = config.audit.targetColumn;
|
|
8678
|
+
if (!config.audit.createIssues) {
|
|
8679
|
+
return {
|
|
8680
|
+
status: "skipped",
|
|
8681
|
+
findingsCount: findings.length,
|
|
8682
|
+
issuesCreated: 0,
|
|
8683
|
+
issuesFailed: 0,
|
|
8684
|
+
targetColumn: null,
|
|
8685
|
+
summary: "audit board issue creation is disabled"
|
|
8686
|
+
};
|
|
8687
|
+
}
|
|
8654
8688
|
if (findings.length === 0) {
|
|
8655
8689
|
return {
|
|
8656
8690
|
status: "skipped",
|
|
@@ -9597,6 +9631,7 @@ __export(dist_exports, {
|
|
|
9597
9631
|
DEFAULT_ANALYTICS_SCHEDULE: () => DEFAULT_ANALYTICS_SCHEDULE,
|
|
9598
9632
|
DEFAULT_ANALYTICS_TARGET_COLUMN: () => DEFAULT_ANALYTICS_TARGET_COLUMN,
|
|
9599
9633
|
DEFAULT_AUDIT: () => DEFAULT_AUDIT,
|
|
9634
|
+
DEFAULT_AUDIT_CREATE_ISSUES: () => DEFAULT_AUDIT_CREATE_ISSUES,
|
|
9600
9635
|
DEFAULT_AUDIT_ENABLED: () => DEFAULT_AUDIT_ENABLED,
|
|
9601
9636
|
DEFAULT_AUDIT_MAX_RUNTIME: () => DEFAULT_AUDIT_MAX_RUNTIME,
|
|
9602
9637
|
DEFAULT_AUDIT_SCHEDULE: () => DEFAULT_AUDIT_SCHEDULE,
|
|
@@ -10888,6 +10923,27 @@ function resolveRunNotificationEvent(exitCode, scriptStatus) {
|
|
|
10888
10923
|
}
|
|
10889
10924
|
return null;
|
|
10890
10925
|
}
|
|
10926
|
+
function extractPrUrlFromOutput(output) {
|
|
10927
|
+
if (!output) {
|
|
10928
|
+
return void 0;
|
|
10929
|
+
}
|
|
10930
|
+
const matches = Array.from(
|
|
10931
|
+
output.matchAll(/https:\/\/github\.com\/[^\s)]+\/pull\/\d+/g),
|
|
10932
|
+
(match) => match[0]
|
|
10933
|
+
);
|
|
10934
|
+
return matches.at(-1);
|
|
10935
|
+
}
|
|
10936
|
+
function extractResultValueFromOutput(output, key) {
|
|
10937
|
+
if (!output) {
|
|
10938
|
+
return void 0;
|
|
10939
|
+
}
|
|
10940
|
+
const escapedKey = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
10941
|
+
const regex = new RegExp(`\\b${escapedKey}=([^\\s|]+)`, "g");
|
|
10942
|
+
const matches = Array.from(output.matchAll(regex), (match) => match[1]).filter(
|
|
10943
|
+
(value) => value !== void 0 && value.length > 0
|
|
10944
|
+
);
|
|
10945
|
+
return matches.at(-1);
|
|
10946
|
+
}
|
|
10891
10947
|
function shouldAttemptCrossProjectFallback(options, scriptStatus) {
|
|
10892
10948
|
if (options.crossProjectFallback !== true) {
|
|
10893
10949
|
return false;
|
|
@@ -10903,6 +10959,71 @@ function shouldAttemptCrossProjectFallback(options, scriptStatus) {
|
|
|
10903
10959
|
}
|
|
10904
10960
|
return scriptStatus === "skip_no_eligible_prd";
|
|
10905
10961
|
}
|
|
10962
|
+
function parsePrNumberFromUrl(prUrl) {
|
|
10963
|
+
const match = prUrl?.match(/\/pull\/(\d+)(?:\b|[/?#])/);
|
|
10964
|
+
if (!match?.[1]) {
|
|
10965
|
+
return void 0;
|
|
10966
|
+
}
|
|
10967
|
+
const parsed = parseInt(match[1], 10);
|
|
10968
|
+
return Number.isNaN(parsed) ? void 0 : parsed;
|
|
10969
|
+
}
|
|
10970
|
+
function getRunPrMetadata(scriptResult, rawOutput) {
|
|
10971
|
+
const prUrl = scriptResult?.data.pr_url ?? extractPrUrlFromOutput(rawOutput);
|
|
10972
|
+
const branchName = scriptResult?.data.branch ?? extractResultValueFromOutput(rawOutput, "branch");
|
|
10973
|
+
const prNumber = parsePrNumberFromUrl(prUrl) ?? (scriptResult?.data.pr_number ? parseInt(scriptResult.data.pr_number, 10) : void 0);
|
|
10974
|
+
return {
|
|
10975
|
+
prUrl,
|
|
10976
|
+
branchName,
|
|
10977
|
+
prNumber: prNumber !== void 0 && !Number.isNaN(prNumber) ? prNumber : void 0
|
|
10978
|
+
};
|
|
10979
|
+
}
|
|
10980
|
+
function fetchRunPrDetails(config, projectDir, metadata) {
|
|
10981
|
+
if (metadata.prNumber !== void 0) {
|
|
10982
|
+
const details = fetchPrDetailsByNumber(metadata.prNumber, projectDir);
|
|
10983
|
+
if (details) {
|
|
10984
|
+
return details;
|
|
10985
|
+
}
|
|
10986
|
+
}
|
|
10987
|
+
if (metadata.prUrl) {
|
|
10988
|
+
const details = fetchPrDetailsForBranch(metadata.prUrl, projectDir);
|
|
10989
|
+
if (details) {
|
|
10990
|
+
return details;
|
|
10991
|
+
}
|
|
10992
|
+
}
|
|
10993
|
+
if (metadata.branchName) {
|
|
10994
|
+
const details = fetchPrDetailsForBranch(metadata.branchName, projectDir);
|
|
10995
|
+
if (details) {
|
|
10996
|
+
return details;
|
|
10997
|
+
}
|
|
10998
|
+
}
|
|
10999
|
+
return fetchPrDetails(config.branchPrefix, projectDir);
|
|
11000
|
+
}
|
|
11001
|
+
function buildRunNotificationContext(config, projectDir, event, exitCode, scriptResult, prDetails, rawOutput) {
|
|
11002
|
+
const metadata = getRunPrMetadata(scriptResult, rawOutput);
|
|
11003
|
+
const timeoutDuration = event === "run_timeout" ? config.maxRuntime : void 0;
|
|
11004
|
+
const checkpointValue = scriptResult?.data.checkpoint;
|
|
11005
|
+
const checkpointStatus = checkpointValue === "created" || checkpointValue === "available" || checkpointValue === "none" ? checkpointValue : void 0;
|
|
11006
|
+
return {
|
|
11007
|
+
event,
|
|
11008
|
+
projectName: path23.basename(projectDir),
|
|
11009
|
+
exitCode,
|
|
11010
|
+
provider: config.provider,
|
|
11011
|
+
prdName: scriptResult?.data.prd ?? extractResultValueFromOutput(rawOutput, "prd"),
|
|
11012
|
+
branchName: metadata.branchName,
|
|
11013
|
+
duration: timeoutDuration,
|
|
11014
|
+
scriptStatus: scriptResult?.status,
|
|
11015
|
+
failureReason: scriptResult?.data.reason,
|
|
11016
|
+
failureDetail: scriptResult?.data.detail,
|
|
11017
|
+
checkpointStatus,
|
|
11018
|
+
prUrl: prDetails?.url || metadata.prUrl,
|
|
11019
|
+
prTitle: prDetails?.title,
|
|
11020
|
+
prBody: prDetails?.body,
|
|
11021
|
+
prNumber: prDetails?.number ?? metadata.prNumber,
|
|
11022
|
+
filesChanged: prDetails?.changedFiles,
|
|
11023
|
+
additions: prDetails?.additions,
|
|
11024
|
+
deletions: prDetails?.deletions
|
|
11025
|
+
};
|
|
11026
|
+
}
|
|
10906
11027
|
function getCrossProjectFallbackCandidates(currentProjectDir) {
|
|
10907
11028
|
const current = path23.resolve(currentProjectDir);
|
|
10908
11029
|
const { valid, invalid } = validateRegistry();
|
|
@@ -10911,7 +11032,7 @@ function getCrossProjectFallbackCandidates(currentProjectDir) {
|
|
|
10911
11032
|
}
|
|
10912
11033
|
return valid.filter((entry) => path23.resolve(entry.path) !== current);
|
|
10913
11034
|
}
|
|
10914
|
-
async function sendRunCompletionNotifications(config, projectDir, options, exitCode, scriptResult) {
|
|
11035
|
+
async function sendRunCompletionNotifications(config, projectDir, options, exitCode, scriptResult, rawOutput) {
|
|
10915
11036
|
if (isRateLimitFallbackTriggered(scriptResult?.data)) {
|
|
10916
11037
|
const nonTelegramWebhooks = (config.notifications?.webhooks ?? []).filter(
|
|
10917
11038
|
(wh) => wh.type !== "telegram"
|
|
@@ -10935,42 +11056,18 @@ async function sendRunCompletionNotifications(config, projectDir, options, exitC
|
|
|
10935
11056
|
const event = resolveRunNotificationEvent(exitCode, scriptResult?.status);
|
|
10936
11057
|
let prDetails = null;
|
|
10937
11058
|
if (event === "run_succeeded") {
|
|
10938
|
-
|
|
10939
|
-
const branch = scriptResult?.data.branch;
|
|
10940
|
-
if (prUrl) {
|
|
10941
|
-
prDetails = fetchPrDetailsForBranch(prUrl, projectDir);
|
|
10942
|
-
}
|
|
10943
|
-
if (!prDetails && branch) {
|
|
10944
|
-
prDetails = fetchPrDetailsForBranch(branch, projectDir);
|
|
10945
|
-
}
|
|
10946
|
-
if (!prDetails) {
|
|
10947
|
-
prDetails = fetchPrDetails(config.branchPrefix, projectDir);
|
|
10948
|
-
}
|
|
11059
|
+
prDetails = fetchRunPrDetails(config, projectDir, getRunPrMetadata(scriptResult, rawOutput));
|
|
10949
11060
|
}
|
|
10950
11061
|
if (event) {
|
|
10951
|
-
const
|
|
10952
|
-
|
|
10953
|
-
|
|
10954
|
-
const _ctx = {
|
|
11062
|
+
const _ctx = buildRunNotificationContext(
|
|
11063
|
+
config,
|
|
11064
|
+
projectDir,
|
|
10955
11065
|
event,
|
|
10956
|
-
projectName: path23.basename(projectDir),
|
|
10957
11066
|
exitCode,
|
|
10958
|
-
|
|
10959
|
-
|
|
10960
|
-
|
|
10961
|
-
|
|
10962
|
-
scriptStatus: scriptResult?.status,
|
|
10963
|
-
failureReason: scriptResult?.data.reason,
|
|
10964
|
-
failureDetail: scriptResult?.data.detail,
|
|
10965
|
-
checkpointStatus,
|
|
10966
|
-
prUrl: prDetails?.url,
|
|
10967
|
-
prTitle: prDetails?.title,
|
|
10968
|
-
prBody: prDetails?.body,
|
|
10969
|
-
prNumber: prDetails?.number,
|
|
10970
|
-
filesChanged: prDetails?.changedFiles,
|
|
10971
|
-
additions: prDetails?.additions,
|
|
10972
|
-
deletions: prDetails?.deletions
|
|
10973
|
-
};
|
|
11067
|
+
scriptResult,
|
|
11068
|
+
prDetails,
|
|
11069
|
+
rawOutput
|
|
11070
|
+
);
|
|
10974
11071
|
await sendNotifications(config, _ctx);
|
|
10975
11072
|
} else if (!options.dryRun) {
|
|
10976
11073
|
info("Skipping completion notification (no actionable run result)");
|
|
@@ -11021,7 +11118,9 @@ ${stderr}`);
|
|
|
11021
11118
|
candidate.path,
|
|
11022
11119
|
options,
|
|
11023
11120
|
exitCode,
|
|
11024
|
-
scriptResult
|
|
11121
|
+
scriptResult,
|
|
11122
|
+
`${stdout}
|
|
11123
|
+
${stderr}`
|
|
11025
11124
|
);
|
|
11026
11125
|
}
|
|
11027
11126
|
if (exitCode !== 0) {
|
|
@@ -11363,7 +11462,15 @@ ${stderr}`);
|
|
|
11363
11462
|
});
|
|
11364
11463
|
} catch {
|
|
11365
11464
|
}
|
|
11366
|
-
await sendRunCompletionNotifications(
|
|
11465
|
+
await sendRunCompletionNotifications(
|
|
11466
|
+
config,
|
|
11467
|
+
projectDir,
|
|
11468
|
+
options,
|
|
11469
|
+
exitCode,
|
|
11470
|
+
scriptResult,
|
|
11471
|
+
`${stdout}
|
|
11472
|
+
${stderr}`
|
|
11473
|
+
);
|
|
11367
11474
|
}
|
|
11368
11475
|
if (shouldAttemptCrossProjectFallback(options, scriptResult?.status)) {
|
|
11369
11476
|
const executedFallback = await runCrossProjectFallback(projectDir, options);
|
|
@@ -11973,6 +12080,7 @@ import * as path26 from "path";
|
|
|
11973
12080
|
function buildEnvVars4(config, options) {
|
|
11974
12081
|
const env = buildBaseEnvVars(config, "audit", options.dryRun);
|
|
11975
12082
|
env.NW_AUDIT_MAX_RUNTIME = String(config.audit.maxRuntime);
|
|
12083
|
+
env.NW_AUDIT_CREATE_ISSUES = config.audit.createIssues ? "1" : "0";
|
|
11976
12084
|
env.NW_CLAUDE_MODEL_ID = CLAUDE_MODEL_IDS[config.primaryFallbackModel ?? config.claudeModel ?? "sonnet"];
|
|
11977
12085
|
const telegramWebhooks = getTelegramStatusWebhooks(config);
|
|
11978
12086
|
if (telegramWebhooks.length > 0) {
|
|
@@ -12012,7 +12120,10 @@ function auditCommand(program2) {
|
|
|
12012
12120
|
configTable.push(["Provider", auditProvider]);
|
|
12013
12121
|
configTable.push(["Provider CLI", PROVIDER_COMMANDS[auditProvider]]);
|
|
12014
12122
|
configTable.push(["Max Runtime", `${config.audit.maxRuntime}s`]);
|
|
12015
|
-
configTable.push(["
|
|
12123
|
+
configTable.push(["Create Board Issues", config.audit.createIssues ? "yes" : "no"]);
|
|
12124
|
+
if (config.audit.createIssues) {
|
|
12125
|
+
configTable.push(["Target Column", config.audit.targetColumn]);
|
|
12126
|
+
}
|
|
12016
12127
|
configTable.push(["Report File", path26.join(projectDir, "logs", "audit-report.md")]);
|
|
12017
12128
|
console.log(configTable.toString());
|
|
12018
12129
|
header("Provider Invocation");
|
|
@@ -16626,6 +16737,9 @@ function validateConfigChanges(changes, currentConfig) {
|
|
|
16626
16737
|
if (audit.maxRuntime !== void 0 && (typeof audit.maxRuntime !== "number" || audit.maxRuntime < 60)) {
|
|
16627
16738
|
return "audit.maxRuntime must be a number >= 60";
|
|
16628
16739
|
}
|
|
16740
|
+
if (audit.createIssues !== void 0 && typeof audit.createIssues !== "boolean") {
|
|
16741
|
+
return "audit.createIssues must be a boolean";
|
|
16742
|
+
}
|
|
16629
16743
|
if (audit.targetColumn !== void 0 && !BOARD_COLUMNS.includes(audit.targetColumn)) {
|
|
16630
16744
|
return `audit.targetColumn must be one of: ${BOARD_COLUMNS.join(", ")}`;
|
|
16631
16745
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/commands/audit.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAEL,iBAAiB,EAalB,MAAM,mBAAmB,CAAC;AAU3B,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,aAAa,GACrB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/commands/audit.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAEL,iBAAiB,EAalB,MAAM,mBAAmB,CAAC;AAU3B,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,aAAa,GACrB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAmBxB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA8KnD"}
|
package/dist/commands/audit.js
CHANGED
|
@@ -14,6 +14,7 @@ export function buildEnvVars(config, options) {
|
|
|
14
14
|
const env = buildBaseEnvVars(config, 'audit', options.dryRun);
|
|
15
15
|
// Audit-specific settings
|
|
16
16
|
env.NW_AUDIT_MAX_RUNTIME = String(config.audit.maxRuntime);
|
|
17
|
+
env.NW_AUDIT_CREATE_ISSUES = config.audit.createIssues ? '1' : '0';
|
|
17
18
|
env.NW_CLAUDE_MODEL_ID =
|
|
18
19
|
CLAUDE_MODEL_IDS[config.primaryFallbackModel ?? config.claudeModel ?? 'sonnet'];
|
|
19
20
|
// Telegram status messages from bash scripts (start/progress/final status)
|
|
@@ -66,7 +67,10 @@ export function auditCommand(program) {
|
|
|
66
67
|
configTable.push(['Provider', auditProvider]);
|
|
67
68
|
configTable.push(['Provider CLI', PROVIDER_COMMANDS[auditProvider]]);
|
|
68
69
|
configTable.push(['Max Runtime', `${config.audit.maxRuntime}s`]);
|
|
69
|
-
configTable.push(['
|
|
70
|
+
configTable.push(['Create Board Issues', config.audit.createIssues ? 'yes' : 'no']);
|
|
71
|
+
if (config.audit.createIssues) {
|
|
72
|
+
configTable.push(['Target Column', config.audit.targetColumn]);
|
|
73
|
+
}
|
|
70
74
|
configTable.push(['Report File', path.join(projectDir, 'logs', 'audit-report.md')]);
|
|
71
75
|
console.log(configTable.toString());
|
|
72
76
|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CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;iBACzD,CAAC,CAAC;YACL,CAAC;YAAC,MAAM,CAAC;gBACP,6DAA6D;YAC/D,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,sBAAsB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACvF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/commands/run.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Command } from 'commander';
|
|
5
5
|
import { INightWatchConfig, NotificationEvent, parseScriptResult } from '@night-watch/core';
|
|
6
|
-
import type { JobType } from '@night-watch/core';
|
|
6
|
+
import type { INotificationContext, IPrDetails, JobType } from '@night-watch/core';
|
|
7
7
|
/**
|
|
8
8
|
* Options for the run command
|
|
9
9
|
*/
|
|
@@ -25,15 +25,28 @@ export interface IRunOutcomeRecordInput {
|
|
|
25
25
|
scriptResult?: ReturnType<typeof parseScriptResult>;
|
|
26
26
|
metadata?: Record<string, unknown>;
|
|
27
27
|
}
|
|
28
|
+
export interface IRunPrMetadata {
|
|
29
|
+
prUrl?: string;
|
|
30
|
+
branchName?: string;
|
|
31
|
+
prNumber?: number;
|
|
32
|
+
}
|
|
28
33
|
/**
|
|
29
34
|
* Map executor exit/result state to a notification event.
|
|
30
35
|
* Returns null when the run completed with no actionable work (skip/no-op).
|
|
31
36
|
*/
|
|
32
37
|
export declare function resolveRunNotificationEvent(exitCode: number, scriptStatus?: string): NotificationEvent | null;
|
|
38
|
+
/**
|
|
39
|
+
* Extract the most recent GitHub PR URL from raw executor output.
|
|
40
|
+
* This is a safety net for older/custom scripts that open a PR successfully
|
|
41
|
+
* but do not emit complete NIGHT_WATCH_RESULT metadata.
|
|
42
|
+
*/
|
|
43
|
+
export declare function extractPrUrlFromOutput(output?: string): string | undefined;
|
|
33
44
|
/**
|
|
34
45
|
* Determine if cross-project fallback should run for this executor result.
|
|
35
46
|
*/
|
|
36
47
|
export declare function shouldAttemptCrossProjectFallback(options: IRunOptions, scriptStatus?: string): boolean;
|
|
48
|
+
export declare function parsePrNumberFromUrl(prUrl?: string): number | undefined;
|
|
49
|
+
export declare function buildRunNotificationContext(config: INightWatchConfig, projectDir: string, event: NotificationEvent, exitCode: number, scriptResult: ReturnType<typeof parseScriptResult>, prDetails: IPrDetails | null, rawOutput?: string): INotificationContext;
|
|
37
50
|
/**
|
|
38
51
|
* Resolve valid registered projects excluding the current project.
|
|
39
52
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAGL,iBAAiB,EAEjB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAGL,iBAAiB,EAEjB,iBAAiB,EAmBjB,iBAAiB,EAOlB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAInF;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB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AO,EAAE,YAAY,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,EAAE,CAAA;CAAE,CA8ClD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAuNjD"}
|
package/dist/commands/run.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Run command - executes the PRD cron script
|
|
3
3
|
*/
|
|
4
|
-
import { CLAIM_FILE_EXTENSION, CLAUDE_MODEL_IDS, PROVIDER_COMMANDS, analyzeFeedbackOutcome, buildProjectFeedbackPromptBlock, buildSessionOutcomeInput, createBoardProvider, createSpinner, createTable, dim, executeScriptWithOutput, fetchPrDetails, fetchPrDetailsForBranch, getRepositories, getScriptPath, header, info, isFeedbackPromptEnabled, loadConfig, parseScriptResult, resolveJobProvider, resolvePreset, sendNotifications, error as uiError, validateRegistry, warn, } from '@night-watch/core';
|
|
4
|
+
import { CLAIM_FILE_EXTENSION, CLAUDE_MODEL_IDS, PROVIDER_COMMANDS, analyzeFeedbackOutcome, buildProjectFeedbackPromptBlock, buildSessionOutcomeInput, createBoardProvider, createSpinner, createTable, dim, executeScriptWithOutput, fetchPrDetails, fetchPrDetailsByNumber, fetchPrDetailsForBranch, getRepositories, getScriptPath, header, info, isFeedbackPromptEnabled, loadConfig, parseScriptResult, resolveJobProvider, resolvePreset, sendNotifications, error as uiError, validateRegistry, warn, } from '@night-watch/core';
|
|
5
5
|
import { buildBaseEnvVars, maybeApplyCronSchedulingDelay } from './shared/env-builder.js';
|
|
6
6
|
import { getFeedbackAnalysisOptions, isFeedbackEnabled } from './shared/feedback.js';
|
|
7
7
|
import * as fs from 'fs';
|
|
@@ -25,6 +25,27 @@ export function resolveRunNotificationEvent(exitCode, scriptStatus) {
|
|
|
25
25
|
}
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Extract the most recent GitHub PR URL from raw executor output.
|
|
30
|
+
* This is a safety net for older/custom scripts that open a PR successfully
|
|
31
|
+
* but do not emit complete NIGHT_WATCH_RESULT metadata.
|
|
32
|
+
*/
|
|
33
|
+
export function extractPrUrlFromOutput(output) {
|
|
34
|
+
if (!output) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
const matches = Array.from(output.matchAll(/https:\/\/github\.com\/[^\s)]+\/pull\/\d+/g), (match) => match[0]);
|
|
38
|
+
return matches.at(-1);
|
|
39
|
+
}
|
|
40
|
+
function extractResultValueFromOutput(output, key) {
|
|
41
|
+
if (!output) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const escapedKey = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
45
|
+
const regex = new RegExp(`\\b${escapedKey}=([^\\s|]+)`, 'g');
|
|
46
|
+
const matches = Array.from(output.matchAll(regex), (match) => match[1]).filter((value) => value !== undefined && value.length > 0);
|
|
47
|
+
return matches.at(-1);
|
|
48
|
+
}
|
|
28
49
|
/**
|
|
29
50
|
* Determine if cross-project fallback should run for this executor result.
|
|
30
51
|
*/
|
|
@@ -44,6 +65,76 @@ export function shouldAttemptCrossProjectFallback(options, scriptStatus) {
|
|
|
44
65
|
}
|
|
45
66
|
return scriptStatus === 'skip_no_eligible_prd';
|
|
46
67
|
}
|
|
68
|
+
export function parsePrNumberFromUrl(prUrl) {
|
|
69
|
+
const match = prUrl?.match(/\/pull\/(\d+)(?:\b|[/?#])/);
|
|
70
|
+
if (!match?.[1]) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
const parsed = parseInt(match[1], 10);
|
|
74
|
+
return Number.isNaN(parsed) ? undefined : parsed;
|
|
75
|
+
}
|
|
76
|
+
function getRunPrMetadata(scriptResult, rawOutput) {
|
|
77
|
+
const prUrl = scriptResult?.data.pr_url ?? extractPrUrlFromOutput(rawOutput);
|
|
78
|
+
const branchName = scriptResult?.data.branch ?? extractResultValueFromOutput(rawOutput, 'branch');
|
|
79
|
+
const prNumber = parsePrNumberFromUrl(prUrl) ??
|
|
80
|
+
(scriptResult?.data.pr_number ? parseInt(scriptResult.data.pr_number, 10) : undefined);
|
|
81
|
+
return {
|
|
82
|
+
prUrl,
|
|
83
|
+
branchName,
|
|
84
|
+
prNumber: prNumber !== undefined && !Number.isNaN(prNumber) ? prNumber : undefined,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function fetchRunPrDetails(config, projectDir, metadata) {
|
|
88
|
+
// Prefer number lookup. Some gh versions are less reliable with URL selectors,
|
|
89
|
+
// while PR numbers are unambiguous once parsed from the emitted PR URL.
|
|
90
|
+
if (metadata.prNumber !== undefined) {
|
|
91
|
+
const details = fetchPrDetailsByNumber(metadata.prNumber, projectDir);
|
|
92
|
+
if (details) {
|
|
93
|
+
return details;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (metadata.prUrl) {
|
|
97
|
+
const details = fetchPrDetailsForBranch(metadata.prUrl, projectDir);
|
|
98
|
+
if (details) {
|
|
99
|
+
return details;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (metadata.branchName) {
|
|
103
|
+
const details = fetchPrDetailsForBranch(metadata.branchName, projectDir);
|
|
104
|
+
if (details) {
|
|
105
|
+
return details;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return fetchPrDetails(config.branchPrefix, projectDir);
|
|
109
|
+
}
|
|
110
|
+
export function buildRunNotificationContext(config, projectDir, event, exitCode, scriptResult, prDetails, rawOutput) {
|
|
111
|
+
const metadata = getRunPrMetadata(scriptResult, rawOutput);
|
|
112
|
+
const timeoutDuration = event === 'run_timeout' ? config.maxRuntime : undefined;
|
|
113
|
+
const checkpointValue = scriptResult?.data.checkpoint;
|
|
114
|
+
const checkpointStatus = checkpointValue === 'created' || checkpointValue === 'available' || checkpointValue === 'none'
|
|
115
|
+
? checkpointValue
|
|
116
|
+
: undefined;
|
|
117
|
+
return {
|
|
118
|
+
event,
|
|
119
|
+
projectName: path.basename(projectDir),
|
|
120
|
+
exitCode,
|
|
121
|
+
provider: config.provider,
|
|
122
|
+
prdName: scriptResult?.data.prd ?? extractResultValueFromOutput(rawOutput, 'prd'),
|
|
123
|
+
branchName: metadata.branchName,
|
|
124
|
+
duration: timeoutDuration,
|
|
125
|
+
scriptStatus: scriptResult?.status,
|
|
126
|
+
failureReason: scriptResult?.data.reason,
|
|
127
|
+
failureDetail: scriptResult?.data.detail,
|
|
128
|
+
checkpointStatus,
|
|
129
|
+
prUrl: prDetails?.url || metadata.prUrl,
|
|
130
|
+
prTitle: prDetails?.title,
|
|
131
|
+
prBody: prDetails?.body,
|
|
132
|
+
prNumber: prDetails?.number ?? metadata.prNumber,
|
|
133
|
+
filesChanged: prDetails?.changedFiles,
|
|
134
|
+
additions: prDetails?.additions,
|
|
135
|
+
deletions: prDetails?.deletions,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
47
138
|
/**
|
|
48
139
|
* Resolve valid registered projects excluding the current project.
|
|
49
140
|
*/
|
|
@@ -58,7 +149,7 @@ export function getCrossProjectFallbackCandidates(currentProjectDir) {
|
|
|
58
149
|
/**
|
|
59
150
|
* Run completion notifications for an executor invocation (local or fallback).
|
|
60
151
|
*/
|
|
61
|
-
async function sendRunCompletionNotifications(config, projectDir, options, exitCode, scriptResult) {
|
|
152
|
+
async function sendRunCompletionNotifications(config, projectDir, options, exitCode, scriptResult, rawOutput) {
|
|
62
153
|
// Rate-limit fallback notifications are sent immediately to Telegram in bash.
|
|
63
154
|
// Send this event only to non-Telegram webhooks to avoid duplicate alerts.
|
|
64
155
|
if (isRateLimitFallbackTriggered(scriptResult?.data)) {
|
|
@@ -81,44 +172,10 @@ async function sendRunCompletionNotifications(config, projectDir, options, exitC
|
|
|
81
172
|
// Enrich with PR details on success (graceful — null if gh fails)
|
|
82
173
|
let prDetails = null;
|
|
83
174
|
if (event === 'run_succeeded') {
|
|
84
|
-
|
|
85
|
-
const branch = scriptResult?.data.branch;
|
|
86
|
-
if (prUrl) {
|
|
87
|
-
prDetails = fetchPrDetailsForBranch(prUrl, projectDir);
|
|
88
|
-
}
|
|
89
|
-
if (!prDetails && branch) {
|
|
90
|
-
prDetails = fetchPrDetailsForBranch(branch, projectDir);
|
|
91
|
-
}
|
|
92
|
-
if (!prDetails) {
|
|
93
|
-
prDetails = fetchPrDetails(config.branchPrefix, projectDir);
|
|
94
|
-
}
|
|
175
|
+
prDetails = fetchRunPrDetails(config, projectDir, getRunPrMetadata(scriptResult, rawOutput));
|
|
95
176
|
}
|
|
96
177
|
if (event) {
|
|
97
|
-
const
|
|
98
|
-
const checkpointValue = scriptResult?.data.checkpoint;
|
|
99
|
-
const checkpointStatus = checkpointValue === 'created' || checkpointValue === 'available' || checkpointValue === 'none'
|
|
100
|
-
? checkpointValue
|
|
101
|
-
: undefined;
|
|
102
|
-
const _ctx = {
|
|
103
|
-
event,
|
|
104
|
-
projectName: path.basename(projectDir),
|
|
105
|
-
exitCode,
|
|
106
|
-
provider: config.provider,
|
|
107
|
-
prdName: scriptResult?.data.prd,
|
|
108
|
-
branchName: scriptResult?.data.branch,
|
|
109
|
-
duration: timeoutDuration,
|
|
110
|
-
scriptStatus: scriptResult?.status,
|
|
111
|
-
failureReason: scriptResult?.data.reason,
|
|
112
|
-
failureDetail: scriptResult?.data.detail,
|
|
113
|
-
checkpointStatus,
|
|
114
|
-
prUrl: prDetails?.url,
|
|
115
|
-
prTitle: prDetails?.title,
|
|
116
|
-
prBody: prDetails?.body,
|
|
117
|
-
prNumber: prDetails?.number,
|
|
118
|
-
filesChanged: prDetails?.changedFiles,
|
|
119
|
-
additions: prDetails?.additions,
|
|
120
|
-
deletions: prDetails?.deletions,
|
|
121
|
-
};
|
|
178
|
+
const _ctx = buildRunNotificationContext(config, projectDir, event, exitCode, scriptResult, prDetails, rawOutput);
|
|
122
179
|
await sendNotifications(config, _ctx);
|
|
123
180
|
}
|
|
124
181
|
else if (!options.dryRun) {
|
|
@@ -165,7 +222,7 @@ async function runCrossProjectFallback(currentProjectDir, options) {
|
|
|
165
222
|
// Outcome persistence must not change fallback execution behavior.
|
|
166
223
|
}
|
|
167
224
|
if (!options.dryRun) {
|
|
168
|
-
await sendRunCompletionNotifications(candidateConfig, candidate.path, options, exitCode, scriptResult);
|
|
225
|
+
await sendRunCompletionNotifications(candidateConfig, candidate.path, options, exitCode, scriptResult, `${stdout}\n${stderr}`);
|
|
169
226
|
}
|
|
170
227
|
if (exitCode !== 0) {
|
|
171
228
|
warn(`Cross-project fallback: ${candidate.name} exited with code ${exitCode}; checking next project.`);
|
|
@@ -573,7 +630,7 @@ export function runCommand(program) {
|
|
|
573
630
|
catch {
|
|
574
631
|
// Outcome persistence must not change command exit behavior.
|
|
575
632
|
}
|
|
576
|
-
await sendRunCompletionNotifications(config, projectDir, options, exitCode, scriptResult);
|
|
633
|
+
await sendRunCompletionNotifications(config, projectDir, options, exitCode, scriptResult, `${stdout}\n${stderr}`);
|
|
577
634
|
}
|
|
578
635
|
// Opportunistic cross-project balancing:
|
|
579
636
|
// if this project has no eligible work, try other registered projects.
|