@oss-autopilot/core 3.38.0 → 3.39.1

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.
Files changed (62) hide show
  1. package/dist/cli-registry.js +7 -4
  2. package/dist/cli.bundle.cjs +139 -132
  3. package/dist/commands/daily-dismiss-filter.d.ts +37 -0
  4. package/dist/commands/daily-dismiss-filter.js +80 -0
  5. package/dist/commands/daily-merged-pr-notes.d.ts +27 -0
  6. package/dist/commands/daily-merged-pr-notes.js +166 -0
  7. package/dist/commands/daily-reviewed-prs.d.ts +41 -0
  8. package/dist/commands/daily-reviewed-prs.js +270 -0
  9. package/dist/commands/daily-warnings.d.ts +28 -0
  10. package/dist/commands/daily-warnings.js +37 -0
  11. package/dist/commands/daily.d.ts +22 -1
  12. package/dist/commands/daily.js +287 -107
  13. package/dist/commands/dashboard-cache.js +9 -2
  14. package/dist/commands/dashboard-data.js +40 -20
  15. package/dist/commands/dashboard-gist-sync.js +16 -3
  16. package/dist/commands/dismiss.d.ts +25 -5
  17. package/dist/commands/dismiss.js +38 -10
  18. package/dist/commands/overnight.js +14 -1
  19. package/dist/commands/scout-bridge.js +4 -1
  20. package/dist/commands/validation.d.ts +11 -0
  21. package/dist/commands/validation.js +16 -0
  22. package/dist/core/checklist-analysis.js +34 -0
  23. package/dist/core/closed-pr-status.d.ts +73 -0
  24. package/dist/core/closed-pr-status.js +113 -0
  25. package/dist/core/comment-decision.d.ts +10 -3
  26. package/dist/core/comment-decision.js +13 -5
  27. package/dist/core/comment-utils.d.ts +38 -1
  28. package/dist/core/comment-utils.js +124 -1
  29. package/dist/core/concurrency.d.ts +6 -0
  30. package/dist/core/concurrency.js +13 -0
  31. package/dist/core/daily-logic.d.ts +13 -1
  32. package/dist/core/daily-logic.js +59 -2
  33. package/dist/core/engaged-issues.d.ts +93 -0
  34. package/dist/core/engaged-issues.js +183 -0
  35. package/dist/core/errors.d.ts +4 -0
  36. package/dist/core/errors.js +10 -0
  37. package/dist/core/github-stats.d.ts +10 -0
  38. package/dist/core/github-stats.js +35 -0
  39. package/dist/core/index.d.ts +10 -5
  40. package/dist/core/index.js +9 -4
  41. package/dist/core/issue-conversation.d.ts +83 -12
  42. package/dist/core/issue-conversation.js +306 -118
  43. package/dist/core/merged-pr-notes.d.ts +192 -0
  44. package/dist/core/merged-pr-notes.js +340 -0
  45. package/dist/core/pr-assembly.js +3 -0
  46. package/dist/core/pr-monitor.d.ts +62 -0
  47. package/dist/core/pr-monitor.js +113 -3
  48. package/dist/core/reviewed-prs-fetch.d.ts +91 -0
  49. package/dist/core/reviewed-prs-fetch.js +271 -0
  50. package/dist/core/reviewed-prs.d.ts +244 -0
  51. package/dist/core/reviewed-prs.js +380 -0
  52. package/dist/core/state-persistence.js +4 -23
  53. package/dist/core/state-schema.d.ts +6 -0
  54. package/dist/core/state-schema.js +9 -0
  55. package/dist/core/state.d.ts +74 -8
  56. package/dist/core/state.js +107 -10
  57. package/dist/core/types.d.ts +47 -0
  58. package/dist/core/urls.d.ts +13 -0
  59. package/dist/core/urls.js +16 -0
  60. package/dist/formatters/json.d.ts +186 -1
  61. package/dist/formatters/json.js +78 -0
  62. package/package.json +1 -1
@@ -342,6 +342,7 @@ export declare const AgentConfigSchema: z.ZodPipe<z.ZodObject<{
342
342
  aiPolicyBlocklist: z.ZodDefault<z.ZodArray<z.ZodString>>;
343
343
  shelvedPRUrls: z.ZodDefault<z.ZodArray<z.ZodString>>;
344
344
  dismissedIssues: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
345
+ dismissedPRHeads: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
345
346
  statusOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
346
347
  status: z.ZodEnum<{
347
348
  needs_addressing: "needs_addressing";
@@ -402,6 +403,7 @@ export declare const AgentConfigSchema: z.ZodPipe<z.ZodObject<{
402
403
  aiPolicyBlocklist: string[];
403
404
  shelvedPRUrls: string[];
404
405
  dismissedIssues: Record<string, string>;
406
+ dismissedPRHeads: Record<string, string>;
405
407
  projectCategories: ("nonprofit" | "devtools" | "infrastructure" | "web-frameworks" | "data-ml" | "education")[];
406
408
  preferredOrgs: string[];
407
409
  diffTool: "inline" | "custom" | "sourcetree" | "vscode";
@@ -452,6 +454,7 @@ export declare const AgentConfigSchema: z.ZodPipe<z.ZodObject<{
452
454
  aiPolicyBlocklist: string[];
453
455
  shelvedPRUrls: string[];
454
456
  dismissedIssues: Record<string, string>;
457
+ dismissedPRHeads: Record<string, string>;
455
458
  projectCategories: ("nonprofit" | "devtools" | "infrastructure" | "web-frameworks" | "data-ml" | "education")[];
456
459
  preferredOrgs: string[];
457
460
  diffTool: "inline" | "custom" | "sourcetree" | "vscode";
@@ -736,6 +739,7 @@ export declare const AgentStateSchema: z.ZodObject<{
736
739
  aiPolicyBlocklist: z.ZodDefault<z.ZodArray<z.ZodString>>;
737
740
  shelvedPRUrls: z.ZodDefault<z.ZodArray<z.ZodString>>;
738
741
  dismissedIssues: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
742
+ dismissedPRHeads: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
739
743
  statusOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
740
744
  status: z.ZodEnum<{
741
745
  needs_addressing: "needs_addressing";
@@ -796,6 +800,7 @@ export declare const AgentStateSchema: z.ZodObject<{
796
800
  aiPolicyBlocklist: string[];
797
801
  shelvedPRUrls: string[];
798
802
  dismissedIssues: Record<string, string>;
803
+ dismissedPRHeads: Record<string, string>;
799
804
  projectCategories: ("nonprofit" | "devtools" | "infrastructure" | "web-frameworks" | "data-ml" | "education")[];
800
805
  preferredOrgs: string[];
801
806
  diffTool: "inline" | "custom" | "sourcetree" | "vscode";
@@ -846,6 +851,7 @@ export declare const AgentStateSchema: z.ZodObject<{
846
851
  aiPolicyBlocklist: string[];
847
852
  shelvedPRUrls: string[];
848
853
  dismissedIssues: Record<string, string>;
854
+ dismissedPRHeads: Record<string, string>;
849
855
  projectCategories: ("nonprofit" | "devtools" | "infrastructure" | "web-frameworks" | "data-ml" | "education")[];
850
856
  preferredOrgs: string[];
851
857
  diffTool: "inline" | "custom" | "sourcetree" | "vscode";
@@ -329,6 +329,15 @@ export const AgentConfigSchema = z
329
329
  aiPolicyBlocklist: z.array(z.string()).default(['matplotlib/matplotlib']),
330
330
  shelvedPRUrls: z.array(z.string()).default([]),
331
331
  dismissedIssues: z.record(z.string(), z.string()).default({}),
332
+ /**
333
+ * PR URL -> head SHA the PR had when its review follow-up was dismissed
334
+ * (#1857). Set by `dismiss <pr-url> --head <sha>`; the follow-up stays
335
+ * hidden while the head is unchanged and no comment newer than the
336
+ * dismiss stamp in `dismissedIssues` qualifies, and a different head
337
+ * resurfaces it. Cleared by `undismiss` and by a dismiss without `--head`
338
+ * (that one goes back to the stamp-only rule). Older states lack the key.
339
+ */
340
+ dismissedPRHeads: z.record(z.string(), z.string()).default({}),
332
341
  statusOverrides: z.record(z.string(), StatusOverrideSchema).optional(),
333
342
  issueListPath: z.string().optional(),
334
343
  skippedIssuesPath: z.string().optional(),
@@ -13,6 +13,12 @@ import { type GistHealth } from './gist-health.js';
13
13
  export { acquireLock, releaseLock, atomicWriteFileSync } from './state-persistence.js';
14
14
  export type { LoadRecoveryInfo } from './state-persistence.js';
15
15
  export type { Stats } from './repo-score-manager.js';
16
+ /**
17
+ * Outcome of {@link StateManager.releaseIssue} (#1863): the claim was
18
+ * removed, the issue was never tracked, or a claim recorded at/after the
19
+ * cutoff was deliberately kept.
20
+ */
21
+ export type ReleaseIssueResult = 'released' | 'not_tracked' | 'newer_claim';
16
22
  /** Cap on `state.pickSnapshots` (#1824): ~180 bytes each, so ~55 KB at the cap. */
17
23
  export declare const MAX_PICK_SNAPSHOTS = 300;
18
24
  /**
@@ -223,6 +229,10 @@ export declare class StateManager {
223
229
  get refreshGeneration(): number;
224
230
  /** Gist mode: whether a saved mutation has not reached the Gist yet. */
225
231
  hasUnpushedChanges(): boolean;
232
+ /** Gist mode: treat the current un-pushed saves as disposable, so the next
233
+ * refresh replaces them without raising the lost-changes staleness marker.
234
+ * Only for re-derivable data (the dashboard's GitHub fetch caches). */
235
+ forgetUnpushedChanges(): void;
226
236
  /**
227
237
  * Re-fetch state from the backing Gist (if in Gist mode).
228
238
  * Throttled to once per 30 seconds by GistStateStore unless `force` is set.
@@ -344,10 +354,44 @@ export declare class StateManager {
344
354
  */
345
355
  updateConfig(config: Partial<AgentState['config']>): void;
346
356
  /**
347
- * Track a new issue. No-op if the issue URL is already tracked.
357
+ * Track a new issue, or refresh the claim on one already tracked.
358
+ *
359
+ * Matching uses {@link issueRefKey} (same normalization as
360
+ * {@link releaseIssue}), so a re-claim through a differently cased or
361
+ * suffixed URL updates the existing entry instead of adding a duplicate.
362
+ * On a match only `status` and `updatedAt` are taken from `issue`:
363
+ * `updatedAt` is the claim stamp `releaseIssue` compares against the PR's
364
+ * close time (#1863), so a re-claim after the close must move it forward
365
+ * or the daily run would release the new claim as if it were the old one.
366
+ *
348
367
  * @param issue - The issue to track
349
368
  */
350
369
  addIssue(issue: TrackedIssue): void;
370
+ /**
371
+ * Release a claim: drop the issue from `activeIssues` (#1863). Called by
372
+ * the daily run when the user closed their own PR for the issue unmerged.
373
+ *
374
+ * What changes: the issue leaves the tracked set that
375
+ * `IssueConversationMonitor.fetchCommentedIssues` excludes, so from the
376
+ * next run it re-enters the commented-issue monitor like any other issue
377
+ * the user has commented on, and it stops reading as in progress wherever
378
+ * `activeIssues` is listed. Capacity is NOT affected: `assessCapacity`
379
+ * counts open PRs only, never tracked issues.
380
+ *
381
+ * Matching uses {@link issueRefKey} (case-insensitive owner/repo, trailing
382
+ * slash and fragment ignored), falling back to the exact string for a URL
383
+ * that does not parse. The removal cannot be undone, so with
384
+ * `claimedBefore` set the entry is kept when its `updatedAt` is at or after
385
+ * that instant: `updatedAt` is the claim stamp the `claim` command writes
386
+ * (`createdAt` there is the issue's GitHub creation date), so a claim made
387
+ * after the PR closed is a deliberate re-claim that must survive.
388
+ * Unparseable timestamps keep the entry for the same reason.
389
+ *
390
+ * @param issueUrl - URL of the issue to release
391
+ * @param claimedBefore - ISO instant (the PR's close time); only a claim
392
+ * recorded strictly before it is released
393
+ */
394
+ releaseIssue(issueUrl: string, claimedBefore?: string): ReleaseIssueResult;
351
395
  /**
352
396
  * Add a repository to the trusted projects list. No-op if already trusted.
353
397
  * @param repo - Repository in "owner/repo" format
@@ -388,14 +432,27 @@ export declare class StateManager {
388
432
  */
389
433
  isPRShelved(url: string): boolean;
390
434
  /**
391
- * Dismiss an issue's notifications. Auto-resurfaces on new activity.
392
- * @param url - The issue URL to dismiss
435
+ * Dismiss an issue's (or merged PR's, #1861) notifications. Auto-resurfaces
436
+ * on new activity.
437
+ * @param url - The issue or PR URL to dismiss
393
438
  * @param timestamp - ISO timestamp of dismissal
394
- * @returns true if newly dismissed, false if already dismissed
395
- */
396
- dismissIssue(url: string, timestamp: string): boolean;
397
- /**
398
- * Restore a dismissed issue to notifications.
439
+ * @param options.refresh - When set, an existing dismissal is re-stamped with
440
+ * `timestamp` instead of being left alone, so a second "skip" after newer
441
+ * activity moves the cutoff forward. Default keeps the original stamp.
442
+ * @param options.headSha - For a reviewed PR (#1857): the head SHA the PR
443
+ * had when it was dismissed, recorded in `config.dismissedPRHeads` so the
444
+ * follow-up stays hidden until the head moves. Any head recorded earlier
445
+ * is replaced, or dropped when this dismiss names none.
446
+ * @returns true if newly dismissed (or re-stamped under `refresh`), false if
447
+ * already dismissed
448
+ */
449
+ dismissIssue(url: string, timestamp: string, options?: {
450
+ refresh?: boolean;
451
+ headSha?: string;
452
+ }): boolean;
453
+ /**
454
+ * Restore a dismissed issue to notifications. A recorded dismiss head
455
+ * (#1857) goes with it.
399
456
  * @param url - The issue URL to undismiss
400
457
  * @returns true if undismissed, false if not currently dismissed
401
458
  */
@@ -405,6 +462,15 @@ export declare class StateManager {
405
462
  * @param url - The issue URL to check
406
463
  */
407
464
  getIssueDismissedAt(url: string): string | undefined;
465
+ /**
466
+ * The head SHA recorded when a reviewed PR's follow-up was dismissed
467
+ * (#1857), or undefined when the PR is not dismissed or was dismissed
468
+ * without one.
469
+ * @param url - The PR URL to check
470
+ */
471
+ getDismissedPRHead(url: string): string | undefined;
472
+ /** Record or (with `undefined`) drop the dismiss head for `url`; no save. */
473
+ private setDismissedPRHead;
408
474
  /**
409
475
  * Set a manual status override for a PR. Auto-clears when the PR has new activity.
410
476
  * @param url - The PR URL
@@ -16,7 +16,7 @@ import * as guidelinesStoreModule from './guidelines-store.js';
16
16
  export const OVERNIGHT_REPORT_DOCUMENT = 'overnight-report.md';
17
17
  import { renderGistWarning } from './gist-health.js';
18
18
  import { getStatePath, getStateCachePath, getGistIdPath } from './paths.js';
19
- import { parseGitHubUrl } from './urls.js';
19
+ import { parseGitHubUrl, issueRefKey } from './urls.js';
20
20
  export { acquireLock, releaseLock, atomicWriteFileSync } from './state-persistence.js';
21
21
  const MODULE = 'state';
22
22
  /**
@@ -554,6 +554,12 @@ export class StateManager {
554
554
  hasUnpushedChanges() {
555
555
  return this.unpushed;
556
556
  }
557
+ /** Gist mode: treat the current un-pushed saves as disposable, so the next
558
+ * refresh replaces them without raising the lost-changes staleness marker.
559
+ * Only for re-derivable data (the dashboard's GitHub fetch caches). */
560
+ forgetUnpushedChanges() {
561
+ this.unpushed = false;
562
+ }
557
563
  /**
558
564
  * Re-fetch state from the backing Gist (if in Gist mode).
559
565
  * Throttled to once per 30 seconds by GistStateStore unless `force` is set.
@@ -891,19 +897,77 @@ export class StateManager {
891
897
  }
892
898
  // === Issue Management ===
893
899
  /**
894
- * Track a new issue. No-op if the issue URL is already tracked.
900
+ * Track a new issue, or refresh the claim on one already tracked.
901
+ *
902
+ * Matching uses {@link issueRefKey} (same normalization as
903
+ * {@link releaseIssue}), so a re-claim through a differently cased or
904
+ * suffixed URL updates the existing entry instead of adding a duplicate.
905
+ * On a match only `status` and `updatedAt` are taken from `issue`:
906
+ * `updatedAt` is the claim stamp `releaseIssue` compares against the PR's
907
+ * close time (#1863), so a re-claim after the close must move it forward
908
+ * or the daily run would release the new claim as if it were the old one.
909
+ *
895
910
  * @param issue - The issue to track
896
911
  */
897
912
  addIssue(issue) {
898
- const existing = this.state.activeIssues.find((i) => i.url === issue.url);
913
+ const key = issueRefKey(issue.url);
914
+ const existing = this.state.activeIssues.find((i) => (key ? issueRefKey(i.url) === key : i.url === issue.url));
899
915
  if (existing) {
900
- debug(MODULE, `Issue ${issue.url} already tracked`);
916
+ existing.status = issue.status;
917
+ existing.updatedAt = issue.updatedAt;
918
+ debug(MODULE, `Issue ${issue.url} already tracked; refreshed claim stamp to ${issue.updatedAt}`);
919
+ this.autoSave();
901
920
  return;
902
921
  }
903
922
  this.state.activeIssues.push(issue);
904
923
  debug(MODULE, `Added issue: ${issue.repo}#${issue.number}`);
905
924
  this.autoSave();
906
925
  }
926
+ /**
927
+ * Release a claim: drop the issue from `activeIssues` (#1863). Called by
928
+ * the daily run when the user closed their own PR for the issue unmerged.
929
+ *
930
+ * What changes: the issue leaves the tracked set that
931
+ * `IssueConversationMonitor.fetchCommentedIssues` excludes, so from the
932
+ * next run it re-enters the commented-issue monitor like any other issue
933
+ * the user has commented on, and it stops reading as in progress wherever
934
+ * `activeIssues` is listed. Capacity is NOT affected: `assessCapacity`
935
+ * counts open PRs only, never tracked issues.
936
+ *
937
+ * Matching uses {@link issueRefKey} (case-insensitive owner/repo, trailing
938
+ * slash and fragment ignored), falling back to the exact string for a URL
939
+ * that does not parse. The removal cannot be undone, so with
940
+ * `claimedBefore` set the entry is kept when its `updatedAt` is at or after
941
+ * that instant: `updatedAt` is the claim stamp the `claim` command writes
942
+ * (`createdAt` there is the issue's GitHub creation date), so a claim made
943
+ * after the PR closed is a deliberate re-claim that must survive.
944
+ * Unparseable timestamps keep the entry for the same reason.
945
+ *
946
+ * @param issueUrl - URL of the issue to release
947
+ * @param claimedBefore - ISO instant (the PR's close time); only a claim
948
+ * recorded strictly before it is released
949
+ */
950
+ releaseIssue(issueUrl, claimedBefore) {
951
+ const key = issueRefKey(issueUrl);
952
+ const index = this.state.activeIssues.findIndex((i) => (key ? issueRefKey(i.url) === key : i.url === issueUrl));
953
+ if (index === -1) {
954
+ debug(MODULE, `releaseIssue: ${issueUrl} is not tracked; nothing to release`);
955
+ return 'not_tracked';
956
+ }
957
+ const entry = this.state.activeIssues[index];
958
+ if (claimedBefore !== undefined) {
959
+ const claimedMs = Date.parse(entry.updatedAt);
960
+ const cutoffMs = Date.parse(claimedBefore);
961
+ if (Number.isNaN(claimedMs) || Number.isNaN(cutoffMs) || claimedMs >= cutoffMs) {
962
+ debug(MODULE, `releaseIssue: keeping ${entry.repo}#${entry.number}; claim stamp ${entry.updatedAt} is not before ${claimedBefore}`);
963
+ return 'newer_claim';
964
+ }
965
+ }
966
+ this.state.activeIssues.splice(index, 1);
967
+ debug(MODULE, `Released issue claim: ${entry.repo}#${entry.number}`);
968
+ this.autoSave();
969
+ return 'released';
970
+ }
907
971
  // === Trusted Projects ===
908
972
  /**
909
973
  * Add a repository to the trusted projects list. No-op if already trusted.
@@ -1009,24 +1073,35 @@ export class StateManager {
1009
1073
  }
1010
1074
  // === Dismiss / Undismiss Issues ===
1011
1075
  /**
1012
- * Dismiss an issue's notifications. Auto-resurfaces on new activity.
1013
- * @param url - The issue URL to dismiss
1076
+ * Dismiss an issue's (or merged PR's, #1861) notifications. Auto-resurfaces
1077
+ * on new activity.
1078
+ * @param url - The issue or PR URL to dismiss
1014
1079
  * @param timestamp - ISO timestamp of dismissal
1015
- * @returns true if newly dismissed, false if already dismissed
1080
+ * @param options.refresh - When set, an existing dismissal is re-stamped with
1081
+ * `timestamp` instead of being left alone, so a second "skip" after newer
1082
+ * activity moves the cutoff forward. Default keeps the original stamp.
1083
+ * @param options.headSha - For a reviewed PR (#1857): the head SHA the PR
1084
+ * had when it was dismissed, recorded in `config.dismissedPRHeads` so the
1085
+ * follow-up stays hidden until the head moves. Any head recorded earlier
1086
+ * is replaced, or dropped when this dismiss names none.
1087
+ * @returns true if newly dismissed (or re-stamped under `refresh`), false if
1088
+ * already dismissed
1016
1089
  */
1017
- dismissIssue(url, timestamp) {
1090
+ dismissIssue(url, timestamp, options = {}) {
1018
1091
  if (!this.state.config.dismissedIssues) {
1019
1092
  this.state.config.dismissedIssues = {};
1020
1093
  }
1021
- if (url in this.state.config.dismissedIssues) {
1094
+ if (url in this.state.config.dismissedIssues && !options.refresh) {
1022
1095
  return false;
1023
1096
  }
1024
1097
  this.state.config.dismissedIssues[url] = timestamp;
1098
+ this.setDismissedPRHead(url, options.headSha);
1025
1099
  this.autoSave();
1026
1100
  return true;
1027
1101
  }
1028
1102
  /**
1029
- * Restore a dismissed issue to notifications.
1103
+ * Restore a dismissed issue to notifications. A recorded dismiss head
1104
+ * (#1857) goes with it.
1030
1105
  * @param url - The issue URL to undismiss
1031
1106
  * @returns true if undismissed, false if not currently dismissed
1032
1107
  */
@@ -1035,6 +1110,7 @@ export class StateManager {
1035
1110
  return false;
1036
1111
  }
1037
1112
  delete this.state.config.dismissedIssues[url];
1113
+ this.setDismissedPRHead(url, undefined);
1038
1114
  this.autoSave();
1039
1115
  return true;
1040
1116
  }
@@ -1045,6 +1121,27 @@ export class StateManager {
1045
1121
  getIssueDismissedAt(url) {
1046
1122
  return this.state.config.dismissedIssues?.[url];
1047
1123
  }
1124
+ /**
1125
+ * The head SHA recorded when a reviewed PR's follow-up was dismissed
1126
+ * (#1857), or undefined when the PR is not dismissed or was dismissed
1127
+ * without one.
1128
+ * @param url - The PR URL to check
1129
+ */
1130
+ getDismissedPRHead(url) {
1131
+ return this.state.config.dismissedPRHeads?.[url];
1132
+ }
1133
+ /** Record or (with `undefined`) drop the dismiss head for `url`; no save. */
1134
+ setDismissedPRHead(url, headSha) {
1135
+ if (!this.state.config.dismissedPRHeads) {
1136
+ this.state.config.dismissedPRHeads = {};
1137
+ }
1138
+ if (headSha === undefined) {
1139
+ delete this.state.config.dismissedPRHeads[url];
1140
+ }
1141
+ else {
1142
+ this.state.config.dismissedPRHeads[url] = headSha;
1143
+ }
1144
+ }
1048
1145
  // === Status Overrides ===
1049
1146
  /**
1050
1147
  * Set a manual status override for a PR. Auto-clears when the PR has new activity.
@@ -140,6 +140,24 @@ export interface FetchedPR {
140
140
  repo: string;
141
141
  number: number;
142
142
  title: string;
143
+ /**
144
+ * Issue the PR closes, parsed from the first closing keyword in its body
145
+ * (same `closingIssueUrl` the merged/closed ledger uses, #1824). Lets the
146
+ * daily run tell a closed PR that was superseded by a still-open PR on the
147
+ * same issue from one whose work really ended (#1863). Undefined when the
148
+ * body has no closing keyword.
149
+ */
150
+ issueUrl?: string;
151
+ /**
152
+ * Every issue or PR the title and body mention, closing keyword or not
153
+ * (`#12`, `owner/repo#12`, issue or pull URL), as canonical issue URLs
154
+ * (`mentionedIssueUrls`, #1863). Widens the supersede check: a follow-up
155
+ * PR that says "supersedes #8" or "another take on #12" counts as the
156
+ * successor of a closed PR even without `Fixes #12`. Parsed at assembly
157
+ * time so the daily run needs no extra API calls; empty when nothing is
158
+ * mentioned.
159
+ */
160
+ mentionedIssueUrls?: string[];
143
161
  /** Computed by `determineStatus()` based on the fields below. */
144
162
  status: FetchedPRStatus;
145
163
  /** Granular reason for needs_addressing status. Undefined when waiting_on_maintainer. */
@@ -294,17 +312,46 @@ export interface StarFilter {
294
312
  export declare function isBelowMinStars(stargazersCount: number | undefined, minStars: number): boolean;
295
313
  /** Status of a user's comment thread on a GitHub issue. */
296
314
  export type IssueConversationStatus = 'new_response' | 'waiting' | 'acknowledged';
315
+ /** How the user is engaged on an issue (#1862), strongest first. */
316
+ export type EngagementReason = 'open_pr' | 'claim' | 'closed_pr' | 'merged_pr';
317
+ /** Why a commented-issue entry was scanned under the engaged rule (#1862). */
318
+ export interface IssueEngagement {
319
+ /** Strongest reason when several apply (open PR, then claim, closed PR, merged PR). */
320
+ reason: EngagementReason;
321
+ /** The PR behind `reason`, for the PR reasons. */
322
+ prUrl?: string;
323
+ /**
324
+ * ISO time of the user's latest engagement step: the claim stamp, or when
325
+ * the PR was opened. Comments at or before it were answered by the
326
+ * engagement itself, so only later ones can be replies to the user. Absent
327
+ * when the PR's opening time is not known (older ledger entries); the
328
+ * user's last comment is the baseline then.
329
+ */
330
+ since?: string;
331
+ }
297
332
  /** Base fields shared by all issue conversation states. */
298
333
  interface CommentedIssueBase {
299
334
  repo: string;
300
335
  number: number;
301
336
  title: string;
302
337
  url: string;
338
+ /**
339
+ * When the user last spoke on the thread. For an engaged issue the user
340
+ * never commented on, the engagement time (`engagement.since`: the claim
341
+ * or the PR opening) with an empty `userLastCommentBody`.
342
+ */
303
343
  userLastCommentedAt: string;
304
344
  /** User's most recent comment body, truncated to 200 chars (+ "..." suffix when truncated). #1290 */
305
345
  userLastCommentBody: string;
306
346
  labels: string[];
307
347
  daysSinceUserComment: number;
348
+ /**
349
+ * Set when the issue was scanned under the engaged rule (#1862): the user
350
+ * claimed it or one of their PRs links it, so any substantive non-bot
351
+ * comment after their last word counts as a reply, not only maintainer or
352
+ * @mention ones. Absent for issues the user only commented on in passing.
353
+ */
354
+ engagement?: IssueEngagement;
308
355
  }
309
356
  /** Issue where someone responded after the user's last comment. */
310
357
  export interface CommentedIssueWithResponse extends CommentedIssueBase {
@@ -33,6 +33,19 @@ export interface ParsedGitHubUrl {
33
33
  * // null
34
34
  */
35
35
  export declare function parseGitHubUrl(url: string): ParsedGitHubUrl | null;
36
+ /**
37
+ * Case-insensitive identity of a GitHub issue or PR URL: `owner/repo#number`,
38
+ * lowercased. Trailing slashes, `#fragment`s and `?query`s fall away because
39
+ * only the path segments are read, and `/issues/N` and `/pull/N` map to the
40
+ * same key: a repo has one number space, so a bare `#N` mention names the
41
+ * same object whichever kind it is. Returns null when the URL does not
42
+ * parse (see {@link parseGitHubUrl}).
43
+ *
44
+ * @example
45
+ * issueRefKey('https://github.com/Org/Repo/issues/5/')
46
+ * // "org/repo#5"
47
+ */
48
+ export declare function issueRefKey(url: string): string | null;
36
49
  /**
37
50
  * Extracts the owner and repo from a GitHub web URL
38
51
  * (e.g. `https://github.com/owner/repo/pull/42`, `https://github.com/owner/repo/`).
package/dist/core/urls.js CHANGED
@@ -58,6 +58,22 @@ export function parseGitHubUrl(url) {
58
58
  }
59
59
  return null;
60
60
  }
61
+ /**
62
+ * Case-insensitive identity of a GitHub issue or PR URL: `owner/repo#number`,
63
+ * lowercased. Trailing slashes, `#fragment`s and `?query`s fall away because
64
+ * only the path segments are read, and `/issues/N` and `/pull/N` map to the
65
+ * same key: a repo has one number space, so a bare `#N` mention names the
66
+ * same object whichever kind it is. Returns null when the URL does not
67
+ * parse (see {@link parseGitHubUrl}).
68
+ *
69
+ * @example
70
+ * issueRefKey('https://github.com/Org/Repo/issues/5/')
71
+ * // "org/repo#5"
72
+ */
73
+ export function issueRefKey(url) {
74
+ const parsed = parseGitHubUrl(url);
75
+ return parsed ? `${parsed.owner.toLowerCase()}/${parsed.repo.toLowerCase()}#${parsed.number}` : null;
76
+ }
61
77
  /**
62
78
  * Extracts the owner and repo from a GitHub web URL
63
79
  * (e.g. `https://github.com/owner/repo/pull/42`, `https://github.com/owner/repo/`).