@oss-autopilot/core 3.38.0 → 3.39.0

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 (63) 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.d.ts +4 -0
  16. package/dist/commands/dashboard-gist-sync.js +5 -1
  17. package/dist/commands/dismiss.d.ts +25 -5
  18. package/dist/commands/dismiss.js +38 -10
  19. package/dist/commands/overnight.js +14 -1
  20. package/dist/commands/scout-bridge.js +4 -1
  21. package/dist/commands/validation.d.ts +11 -0
  22. package/dist/commands/validation.js +16 -0
  23. package/dist/core/checklist-analysis.js +34 -0
  24. package/dist/core/closed-pr-status.d.ts +73 -0
  25. package/dist/core/closed-pr-status.js +113 -0
  26. package/dist/core/comment-decision.d.ts +10 -3
  27. package/dist/core/comment-decision.js +13 -5
  28. package/dist/core/comment-utils.d.ts +38 -1
  29. package/dist/core/comment-utils.js +124 -1
  30. package/dist/core/concurrency.d.ts +6 -0
  31. package/dist/core/concurrency.js +13 -0
  32. package/dist/core/daily-logic.d.ts +13 -1
  33. package/dist/core/daily-logic.js +59 -2
  34. package/dist/core/engaged-issues.d.ts +93 -0
  35. package/dist/core/engaged-issues.js +183 -0
  36. package/dist/core/errors.d.ts +4 -0
  37. package/dist/core/errors.js +10 -0
  38. package/dist/core/github-stats.d.ts +10 -0
  39. package/dist/core/github-stats.js +35 -0
  40. package/dist/core/index.d.ts +10 -5
  41. package/dist/core/index.js +9 -4
  42. package/dist/core/issue-conversation.d.ts +83 -12
  43. package/dist/core/issue-conversation.js +306 -118
  44. package/dist/core/merged-pr-notes.d.ts +192 -0
  45. package/dist/core/merged-pr-notes.js +340 -0
  46. package/dist/core/pr-assembly.js +3 -0
  47. package/dist/core/pr-monitor.d.ts +62 -0
  48. package/dist/core/pr-monitor.js +113 -3
  49. package/dist/core/reviewed-prs-fetch.d.ts +91 -0
  50. package/dist/core/reviewed-prs-fetch.js +271 -0
  51. package/dist/core/reviewed-prs.d.ts +244 -0
  52. package/dist/core/reviewed-prs.js +380 -0
  53. package/dist/core/state-persistence.js +4 -23
  54. package/dist/core/state-schema.d.ts +6 -0
  55. package/dist/core/state-schema.js +9 -0
  56. package/dist/core/state.d.ts +70 -8
  57. package/dist/core/state.js +101 -10
  58. package/dist/core/types.d.ts +47 -0
  59. package/dist/core/urls.d.ts +13 -0
  60. package/dist/core/urls.js +16 -0
  61. package/dist/formatters/json.d.ts +186 -1
  62. package/dist/formatters/json.js +78 -0
  63. 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
  /**
@@ -344,10 +350,44 @@ export declare class StateManager {
344
350
  */
345
351
  updateConfig(config: Partial<AgentState['config']>): void;
346
352
  /**
347
- * Track a new issue. No-op if the issue URL is already tracked.
353
+ * Track a new issue, or refresh the claim on one already tracked.
354
+ *
355
+ * Matching uses {@link issueRefKey} (same normalization as
356
+ * {@link releaseIssue}), so a re-claim through a differently cased or
357
+ * suffixed URL updates the existing entry instead of adding a duplicate.
358
+ * On a match only `status` and `updatedAt` are taken from `issue`:
359
+ * `updatedAt` is the claim stamp `releaseIssue` compares against the PR's
360
+ * close time (#1863), so a re-claim after the close must move it forward
361
+ * or the daily run would release the new claim as if it were the old one.
362
+ *
348
363
  * @param issue - The issue to track
349
364
  */
350
365
  addIssue(issue: TrackedIssue): void;
366
+ /**
367
+ * Release a claim: drop the issue from `activeIssues` (#1863). Called by
368
+ * the daily run when the user closed their own PR for the issue unmerged.
369
+ *
370
+ * What changes: the issue leaves the tracked set that
371
+ * `IssueConversationMonitor.fetchCommentedIssues` excludes, so from the
372
+ * next run it re-enters the commented-issue monitor like any other issue
373
+ * the user has commented on, and it stops reading as in progress wherever
374
+ * `activeIssues` is listed. Capacity is NOT affected: `assessCapacity`
375
+ * counts open PRs only, never tracked issues.
376
+ *
377
+ * Matching uses {@link issueRefKey} (case-insensitive owner/repo, trailing
378
+ * slash and fragment ignored), falling back to the exact string for a URL
379
+ * that does not parse. The removal cannot be undone, so with
380
+ * `claimedBefore` set the entry is kept when its `updatedAt` is at or after
381
+ * that instant: `updatedAt` is the claim stamp the `claim` command writes
382
+ * (`createdAt` there is the issue's GitHub creation date), so a claim made
383
+ * after the PR closed is a deliberate re-claim that must survive.
384
+ * Unparseable timestamps keep the entry for the same reason.
385
+ *
386
+ * @param issueUrl - URL of the issue to release
387
+ * @param claimedBefore - ISO instant (the PR's close time); only a claim
388
+ * recorded strictly before it is released
389
+ */
390
+ releaseIssue(issueUrl: string, claimedBefore?: string): ReleaseIssueResult;
351
391
  /**
352
392
  * Add a repository to the trusted projects list. No-op if already trusted.
353
393
  * @param repo - Repository in "owner/repo" format
@@ -388,14 +428,27 @@ export declare class StateManager {
388
428
  */
389
429
  isPRShelved(url: string): boolean;
390
430
  /**
391
- * Dismiss an issue's notifications. Auto-resurfaces on new activity.
392
- * @param url - The issue URL to dismiss
431
+ * Dismiss an issue's (or merged PR's, #1861) notifications. Auto-resurfaces
432
+ * on new activity.
433
+ * @param url - The issue or PR URL to dismiss
393
434
  * @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.
435
+ * @param options.refresh - When set, an existing dismissal is re-stamped with
436
+ * `timestamp` instead of being left alone, so a second "skip" after newer
437
+ * activity moves the cutoff forward. Default keeps the original stamp.
438
+ * @param options.headSha - For a reviewed PR (#1857): the head SHA the PR
439
+ * had when it was dismissed, recorded in `config.dismissedPRHeads` so the
440
+ * follow-up stays hidden until the head moves. Any head recorded earlier
441
+ * is replaced, or dropped when this dismiss names none.
442
+ * @returns true if newly dismissed (or re-stamped under `refresh`), false if
443
+ * already dismissed
444
+ */
445
+ dismissIssue(url: string, timestamp: string, options?: {
446
+ refresh?: boolean;
447
+ headSha?: string;
448
+ }): boolean;
449
+ /**
450
+ * Restore a dismissed issue to notifications. A recorded dismiss head
451
+ * (#1857) goes with it.
399
452
  * @param url - The issue URL to undismiss
400
453
  * @returns true if undismissed, false if not currently dismissed
401
454
  */
@@ -405,6 +458,15 @@ export declare class StateManager {
405
458
  * @param url - The issue URL to check
406
459
  */
407
460
  getIssueDismissedAt(url: string): string | undefined;
461
+ /**
462
+ * The head SHA recorded when a reviewed PR's follow-up was dismissed
463
+ * (#1857), or undefined when the PR is not dismissed or was dismissed
464
+ * without one.
465
+ * @param url - The PR URL to check
466
+ */
467
+ getDismissedPRHead(url: string): string | undefined;
468
+ /** Record or (with `undefined`) drop the dismiss head for `url`; no save. */
469
+ private setDismissedPRHead;
408
470
  /**
409
471
  * Set a manual status override for a PR. Auto-clears when the PR has new activity.
410
472
  * @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
  /**
@@ -891,19 +891,77 @@ export class StateManager {
891
891
  }
892
892
  // === Issue Management ===
893
893
  /**
894
- * Track a new issue. No-op if the issue URL is already tracked.
894
+ * Track a new issue, or refresh the claim on one already tracked.
895
+ *
896
+ * Matching uses {@link issueRefKey} (same normalization as
897
+ * {@link releaseIssue}), so a re-claim through a differently cased or
898
+ * suffixed URL updates the existing entry instead of adding a duplicate.
899
+ * On a match only `status` and `updatedAt` are taken from `issue`:
900
+ * `updatedAt` is the claim stamp `releaseIssue` compares against the PR's
901
+ * close time (#1863), so a re-claim after the close must move it forward
902
+ * or the daily run would release the new claim as if it were the old one.
903
+ *
895
904
  * @param issue - The issue to track
896
905
  */
897
906
  addIssue(issue) {
898
- const existing = this.state.activeIssues.find((i) => i.url === issue.url);
907
+ const key = issueRefKey(issue.url);
908
+ const existing = this.state.activeIssues.find((i) => (key ? issueRefKey(i.url) === key : i.url === issue.url));
899
909
  if (existing) {
900
- debug(MODULE, `Issue ${issue.url} already tracked`);
910
+ existing.status = issue.status;
911
+ existing.updatedAt = issue.updatedAt;
912
+ debug(MODULE, `Issue ${issue.url} already tracked; refreshed claim stamp to ${issue.updatedAt}`);
913
+ this.autoSave();
901
914
  return;
902
915
  }
903
916
  this.state.activeIssues.push(issue);
904
917
  debug(MODULE, `Added issue: ${issue.repo}#${issue.number}`);
905
918
  this.autoSave();
906
919
  }
920
+ /**
921
+ * Release a claim: drop the issue from `activeIssues` (#1863). Called by
922
+ * the daily run when the user closed their own PR for the issue unmerged.
923
+ *
924
+ * What changes: the issue leaves the tracked set that
925
+ * `IssueConversationMonitor.fetchCommentedIssues` excludes, so from the
926
+ * next run it re-enters the commented-issue monitor like any other issue
927
+ * the user has commented on, and it stops reading as in progress wherever
928
+ * `activeIssues` is listed. Capacity is NOT affected: `assessCapacity`
929
+ * counts open PRs only, never tracked issues.
930
+ *
931
+ * Matching uses {@link issueRefKey} (case-insensitive owner/repo, trailing
932
+ * slash and fragment ignored), falling back to the exact string for a URL
933
+ * that does not parse. The removal cannot be undone, so with
934
+ * `claimedBefore` set the entry is kept when its `updatedAt` is at or after
935
+ * that instant: `updatedAt` is the claim stamp the `claim` command writes
936
+ * (`createdAt` there is the issue's GitHub creation date), so a claim made
937
+ * after the PR closed is a deliberate re-claim that must survive.
938
+ * Unparseable timestamps keep the entry for the same reason.
939
+ *
940
+ * @param issueUrl - URL of the issue to release
941
+ * @param claimedBefore - ISO instant (the PR's close time); only a claim
942
+ * recorded strictly before it is released
943
+ */
944
+ releaseIssue(issueUrl, claimedBefore) {
945
+ const key = issueRefKey(issueUrl);
946
+ const index = this.state.activeIssues.findIndex((i) => (key ? issueRefKey(i.url) === key : i.url === issueUrl));
947
+ if (index === -1) {
948
+ debug(MODULE, `releaseIssue: ${issueUrl} is not tracked; nothing to release`);
949
+ return 'not_tracked';
950
+ }
951
+ const entry = this.state.activeIssues[index];
952
+ if (claimedBefore !== undefined) {
953
+ const claimedMs = Date.parse(entry.updatedAt);
954
+ const cutoffMs = Date.parse(claimedBefore);
955
+ if (Number.isNaN(claimedMs) || Number.isNaN(cutoffMs) || claimedMs >= cutoffMs) {
956
+ debug(MODULE, `releaseIssue: keeping ${entry.repo}#${entry.number}; claim stamp ${entry.updatedAt} is not before ${claimedBefore}`);
957
+ return 'newer_claim';
958
+ }
959
+ }
960
+ this.state.activeIssues.splice(index, 1);
961
+ debug(MODULE, `Released issue claim: ${entry.repo}#${entry.number}`);
962
+ this.autoSave();
963
+ return 'released';
964
+ }
907
965
  // === Trusted Projects ===
908
966
  /**
909
967
  * Add a repository to the trusted projects list. No-op if already trusted.
@@ -1009,24 +1067,35 @@ export class StateManager {
1009
1067
  }
1010
1068
  // === Dismiss / Undismiss Issues ===
1011
1069
  /**
1012
- * Dismiss an issue's notifications. Auto-resurfaces on new activity.
1013
- * @param url - The issue URL to dismiss
1070
+ * Dismiss an issue's (or merged PR's, #1861) notifications. Auto-resurfaces
1071
+ * on new activity.
1072
+ * @param url - The issue or PR URL to dismiss
1014
1073
  * @param timestamp - ISO timestamp of dismissal
1015
- * @returns true if newly dismissed, false if already dismissed
1074
+ * @param options.refresh - When set, an existing dismissal is re-stamped with
1075
+ * `timestamp` instead of being left alone, so a second "skip" after newer
1076
+ * activity moves the cutoff forward. Default keeps the original stamp.
1077
+ * @param options.headSha - For a reviewed PR (#1857): the head SHA the PR
1078
+ * had when it was dismissed, recorded in `config.dismissedPRHeads` so the
1079
+ * follow-up stays hidden until the head moves. Any head recorded earlier
1080
+ * is replaced, or dropped when this dismiss names none.
1081
+ * @returns true if newly dismissed (or re-stamped under `refresh`), false if
1082
+ * already dismissed
1016
1083
  */
1017
- dismissIssue(url, timestamp) {
1084
+ dismissIssue(url, timestamp, options = {}) {
1018
1085
  if (!this.state.config.dismissedIssues) {
1019
1086
  this.state.config.dismissedIssues = {};
1020
1087
  }
1021
- if (url in this.state.config.dismissedIssues) {
1088
+ if (url in this.state.config.dismissedIssues && !options.refresh) {
1022
1089
  return false;
1023
1090
  }
1024
1091
  this.state.config.dismissedIssues[url] = timestamp;
1092
+ this.setDismissedPRHead(url, options.headSha);
1025
1093
  this.autoSave();
1026
1094
  return true;
1027
1095
  }
1028
1096
  /**
1029
- * Restore a dismissed issue to notifications.
1097
+ * Restore a dismissed issue to notifications. A recorded dismiss head
1098
+ * (#1857) goes with it.
1030
1099
  * @param url - The issue URL to undismiss
1031
1100
  * @returns true if undismissed, false if not currently dismissed
1032
1101
  */
@@ -1035,6 +1104,7 @@ export class StateManager {
1035
1104
  return false;
1036
1105
  }
1037
1106
  delete this.state.config.dismissedIssues[url];
1107
+ this.setDismissedPRHead(url, undefined);
1038
1108
  this.autoSave();
1039
1109
  return true;
1040
1110
  }
@@ -1045,6 +1115,27 @@ export class StateManager {
1045
1115
  getIssueDismissedAt(url) {
1046
1116
  return this.state.config.dismissedIssues?.[url];
1047
1117
  }
1118
+ /**
1119
+ * The head SHA recorded when a reviewed PR's follow-up was dismissed
1120
+ * (#1857), or undefined when the PR is not dismissed or was dismissed
1121
+ * without one.
1122
+ * @param url - The PR URL to check
1123
+ */
1124
+ getDismissedPRHead(url) {
1125
+ return this.state.config.dismissedPRHeads?.[url];
1126
+ }
1127
+ /** Record or (with `undefined`) drop the dismiss head for `url`; no save. */
1128
+ setDismissedPRHead(url, headSha) {
1129
+ if (!this.state.config.dismissedPRHeads) {
1130
+ this.state.config.dismissedPRHeads = {};
1131
+ }
1132
+ if (headSha === undefined) {
1133
+ delete this.state.config.dismissedPRHeads[url];
1134
+ }
1135
+ else {
1136
+ this.state.config.dismissedPRHeads[url] = headSha;
1137
+ }
1138
+ }
1048
1139
  // === Status Overrides ===
1049
1140
  /**
1050
1141
  * 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/`).