@oss-autopilot/core 3.42.5 → 3.43.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 (168) hide show
  1. package/dist/cli-pre-action.js +8 -3
  2. package/dist/cli-registry.js +272 -25
  3. package/dist/cli.bundle.cjs +183 -154
  4. package/dist/commands/check-integration.js +1 -0
  5. package/dist/commands/cleanup.d.ts +76 -0
  6. package/dist/commands/cleanup.js +269 -0
  7. package/dist/commands/comments.d.ts +6 -0
  8. package/dist/commands/comments.js +6 -2
  9. package/dist/commands/config.js +37 -5
  10. package/dist/commands/daily-dismiss-filter.d.ts +7 -0
  11. package/dist/commands/daily-dismiss-filter.js +17 -1
  12. package/dist/commands/daily-ledger.d.ts +122 -0
  13. package/dist/commands/daily-ledger.js +225 -0
  14. package/dist/commands/daily-recent-prs.d.ts +26 -0
  15. package/dist/commands/daily-recent-prs.js +55 -0
  16. package/dist/commands/daily.d.ts +2 -1
  17. package/dist/commands/daily.js +59 -89
  18. package/dist/commands/dashboard-cache.d.ts +2 -0
  19. package/dist/commands/dashboard-cache.js +33 -8
  20. package/dist/commands/dashboard-data.js +71 -36
  21. package/dist/commands/dashboard-gist-sync.js +3 -1
  22. package/dist/commands/dashboard-lifecycle.js +1 -1
  23. package/dist/commands/dashboard-process.d.ts +14 -1
  24. package/dist/commands/dashboard-process.js +46 -7
  25. package/dist/commands/dashboard-server.js +89 -23
  26. package/dist/commands/detect-formatters.js +1 -0
  27. package/dist/commands/dismiss.js +5 -2
  28. package/dist/commands/doctor.d.ts +15 -1
  29. package/dist/commands/doctor.js +73 -5
  30. package/dist/commands/draft.d.ts +77 -0
  31. package/dist/commands/draft.js +218 -0
  32. package/dist/commands/eval.js +1 -0
  33. package/dist/commands/guidelines.d.ts +23 -1
  34. package/dist/commands/guidelines.js +49 -4
  35. package/dist/commands/index.d.ts +24 -4
  36. package/dist/commands/index.js +15 -3
  37. package/dist/commands/issue-thread.d.ts +46 -0
  38. package/dist/commands/issue-thread.js +123 -0
  39. package/dist/commands/ledger-backfill.d.ts +9 -0
  40. package/dist/commands/ledger-backfill.js +44 -1
  41. package/dist/commands/list-mark-done.d.ts +2 -1
  42. package/dist/commands/list-mark-done.js +3 -1
  43. package/dist/commands/list-move-tier.d.ts +2 -1
  44. package/dist/commands/list-move-tier.js +3 -1
  45. package/dist/commands/local-repos.js +10 -5
  46. package/dist/commands/locate-issue-list.d.ts +40 -17
  47. package/dist/commands/locate-issue-list.js +148 -88
  48. package/dist/commands/move.js +7 -1
  49. package/dist/commands/overnight-handoff.d.ts +17 -7
  50. package/dist/commands/overnight-handoff.js +36 -14
  51. package/dist/commands/overnight-push-prep.d.ts +13 -8
  52. package/dist/commands/overnight-push-prep.js +106 -34
  53. package/dist/commands/overnight-tool-rules.d.ts +54 -0
  54. package/dist/commands/overnight-tool-rules.js +217 -0
  55. package/dist/commands/overnight.d.ts +5 -6
  56. package/dist/commands/overnight.js +61 -140
  57. package/dist/commands/parse-list.js +7 -1
  58. package/dist/commands/policy.d.ts +86 -0
  59. package/dist/commands/policy.js +263 -0
  60. package/dist/commands/pr-preflight.d.ts +43 -0
  61. package/dist/commands/pr-preflight.js +294 -0
  62. package/dist/commands/repo-vet.d.ts +9 -0
  63. package/dist/commands/repo-vet.js +36 -11
  64. package/dist/commands/scout-bridge.js +18 -8
  65. package/dist/commands/search.js +7 -0
  66. package/dist/commands/setup.d.ts +3 -3
  67. package/dist/commands/setup.js +46 -18
  68. package/dist/commands/skip-add.js +10 -1
  69. package/dist/commands/startup.d.ts +5 -3
  70. package/dist/commands/startup.js +65 -49
  71. package/dist/commands/state-cmd.d.ts +2 -0
  72. package/dist/commands/state-cmd.js +5 -1
  73. package/dist/commands/stats.js +1 -0
  74. package/dist/commands/status.js +1 -0
  75. package/dist/commands/strategy.js +1 -0
  76. package/dist/commands/vet-list.d.ts +6 -0
  77. package/dist/commands/vet-list.js +25 -0
  78. package/dist/commands/vet.d.ts +12 -0
  79. package/dist/commands/vet.js +118 -1
  80. package/dist/core/__fixtures__/prompt-injection-payloads.js +31 -0
  81. package/dist/core/anti-llm-policy.d.ts +3 -0
  82. package/dist/core/anti-llm-policy.js +3 -0
  83. package/dist/core/auth.js +2 -0
  84. package/dist/core/ci-analysis.d.ts +7 -2
  85. package/dist/core/ci-analysis.js +76 -21
  86. package/dist/core/commit-date.d.ts +19 -0
  87. package/dist/core/commit-date.js +17 -0
  88. package/dist/core/config-registry.js +11 -5
  89. package/dist/core/contributing.d.ts +2 -3
  90. package/dist/core/contributing.js +2 -3
  91. package/dist/core/daily-logic.d.ts +27 -5
  92. package/dist/core/daily-logic.js +57 -19
  93. package/dist/core/errors.d.ts +37 -3
  94. package/dist/core/errors.js +54 -5
  95. package/dist/core/gist-health.d.ts +15 -3
  96. package/dist/core/gist-health.js +8 -0
  97. package/dist/core/gist-state-store.d.ts +24 -4
  98. package/dist/core/gist-state-store.js +97 -46
  99. package/dist/core/github-stats.d.ts +104 -16
  100. package/dist/core/github-stats.js +282 -97
  101. package/dist/core/http-cache.d.ts +0 -10
  102. package/dist/core/http-cache.js +0 -19
  103. package/dist/core/index.d.ts +12 -5
  104. package/dist/core/index.js +15 -5
  105. package/dist/core/issue-conversation.d.ts +8 -2
  106. package/dist/core/issue-conversation.js +31 -12
  107. package/dist/core/local-config.d.ts +95 -0
  108. package/dist/core/local-config.js +271 -0
  109. package/dist/core/merged-pr-notes.d.ts +2 -2
  110. package/dist/core/pagination.d.ts +55 -0
  111. package/dist/core/pagination.js +59 -0
  112. package/dist/core/paths.d.ts +7 -0
  113. package/dist/core/paths.js +9 -0
  114. package/dist/core/pr-assembly.js +6 -2
  115. package/dist/core/pr-graphql.d.ts +37 -3
  116. package/dist/core/pr-graphql.js +73 -12
  117. package/dist/core/pr-monitor.d.ts +29 -12
  118. package/dist/core/pr-monitor.js +71 -23
  119. package/dist/core/pr-preflight.d.ts +113 -0
  120. package/dist/core/pr-preflight.js +364 -0
  121. package/dist/core/pr-quality-rubric.d.ts +0 -6
  122. package/dist/core/pr-quality-rubric.js +0 -8
  123. package/dist/core/pr-template.d.ts +2 -0
  124. package/dist/core/pr-template.js +5 -1
  125. package/dist/core/repo-policy.d.ts +105 -0
  126. package/dist/core/repo-policy.js +400 -0
  127. package/dist/core/repo-score-manager.d.ts +48 -0
  128. package/dist/core/repo-score-manager.js +111 -1
  129. package/dist/core/review-analysis.d.ts +34 -19
  130. package/dist/core/review-analysis.js +67 -10
  131. package/dist/core/reviewed-prs-fetch.js +11 -29
  132. package/dist/core/reviewed-prs.js +8 -15
  133. package/dist/core/stale-data.d.ts +41 -0
  134. package/dist/core/stale-data.js +115 -0
  135. package/dist/core/state-persistence.d.ts +62 -27
  136. package/dist/core/state-persistence.js +338 -117
  137. package/dist/core/state-schema.d.ts +113 -210
  138. package/dist/core/state-schema.js +165 -80
  139. package/dist/core/state.d.ts +60 -8
  140. package/dist/core/state.js +192 -46
  141. package/dist/core/status-determination.js +26 -8
  142. package/dist/core/strategy.js +3 -1
  143. package/dist/core/types.d.ts +22 -1
  144. package/dist/core/types.js +1 -0
  145. package/dist/core/untrusted-content.d.ts +30 -11
  146. package/dist/core/untrusted-content.js +77 -42
  147. package/dist/core/urls.d.ts +9 -0
  148. package/dist/core/urls.js +18 -0
  149. package/dist/dashboard/assets/{chart-panel-DPKNBUts.js → chart-panel-C_C1lFTI.js} +1 -1
  150. package/dist/dashboard/assets/{index-B25bZOYX.js → index-B--H66Jk.js} +1 -1
  151. package/dist/dashboard/index.html +1 -1
  152. package/dist/formatters/json.d.ts +262 -6
  153. package/dist/formatters/json.js +77 -1
  154. package/package.json +1 -1
  155. package/dist/core/ci-enforced-tools.d.ts +0 -35
  156. package/dist/core/ci-enforced-tools.js +0 -109
  157. package/dist/core/comment-decision.d.ts +0 -79
  158. package/dist/core/comment-decision.js +0 -82
  159. package/dist/core/extraction-categories.d.ts +0 -55
  160. package/dist/core/extraction-categories.js +0 -108
  161. package/dist/core/follow-up-history.d.ts +0 -40
  162. package/dist/core/follow-up-history.js +0 -71
  163. package/dist/core/issue-effort.d.ts +0 -29
  164. package/dist/core/issue-effort.js +0 -47
  165. package/dist/core/maintainer-hints.d.ts +0 -23
  166. package/dist/core/maintainer-hints.js +0 -36
  167. package/dist/core/workflow-state.d.ts +0 -56
  168. package/dist/core/workflow-state.js +0 -101
@@ -7,9 +7,11 @@
7
7
  * and the prompt-injection corpus:
8
8
  *
9
9
  * 1. Output starts with the open tag and ends with the close tag.
10
- * 2. The close-tag literal NEVER appears inside the wrapped body — any
11
- * occurrence in the input is escaped to a sentinel so an attacker
12
- * cannot close the fence early and inject instructions after it.
10
+ * 2. No `<` appears inside the wrapped body: every one is escaped to
11
+ * `&lt;` (#1931), so no tag of any spelling (letter case, inner
12
+ * whitespace, attributes, zero-width or lookalike letters) can exist
13
+ * there and an attacker cannot close the fence early and inject
14
+ * instructions after it.
13
15
  * 3. `extractFromFence(wrapUntrustedContent(x, label))` returns `x`
14
16
  * unchanged for any input — the wrapping is lossless.
15
17
  *
@@ -29,6 +31,8 @@
29
31
  * CLI text renderers consume the same objects.
30
32
  * - MCP-only surfaces (#1455): PR titles and branch-ref names via
31
33
  * {@link fenceFetchedPRTitles} (mcp-server resources.ts / prompts.ts),
34
+ * every title and branch-ref string in MCP tool results via
35
+ * {@link fenceTitlesDeep} (mcp-server tools.ts `wrapTool`, #1931),
32
36
  * and stored guidelines provenance via {@link labelGuidelinesContent}.
33
37
  * These do NOT apply on the CLI envelope — see the helpers' docs.
34
38
  *
@@ -54,14 +58,15 @@ export interface UntrustedContentMeta {
54
58
  }
55
59
  /**
56
60
  * Wrap `text` in a `<github-content>` fence labeled with `label` and the
57
- * optional metadata. Any occurrence of the close-tag literal inside `text`
58
- * is replaced with a zero-width-joined sentinel that round-trips losslessly
59
- * via {@link extractFromFence}.
61
+ * optional metadata. Every `&` and `<` inside `text` is entity-escaped,
62
+ * which round-trips losslessly via {@link extractFromFence}. Wrapping
63
+ * already-fenced text escapes the inner fence's tags like any other.
64
+ * Fullwidth `<` (U+FF1C) is not ASCII `<` and stays as is.
60
65
  */
61
66
  export declare function wrapUntrustedContent(text: string, label: string, meta?: UntrustedContentMeta): string;
62
67
  /**
63
68
  * Reverse of {@link wrapUntrustedContent}. Extracts the original body text
64
- * (un-escaping any sentinel-encoded close tags). Throws if the input is not
69
+ * (un-escaping `&lt;` and `&amp;`). Throws if the input is not
65
70
  * a single well-formed fence — callers shouldn't be parsing arbitrary
66
71
  * markdown with this; it's for tests + symmetric reasoning only.
67
72
  */
@@ -98,12 +103,26 @@ export declare function fenceFetchedPR<T extends FenceablePR>(pr: T): T;
98
103
  *
99
104
  * Composes safely with {@link fenceFetchedPR} (disjoint fields), and is
100
105
  * applied to already-body-fenced digest PRs without double-wrapping.
101
- * `VerifiedLinkedPR.title` (verify-issue) stays raw: the same producer
102
- * feeds the CLI `--json` contract (pinned by verify-issue contract
103
- * snapshots) and the consuming issue-scout agent carries the awareness
104
- * block. Returns a copy; never mutates.
106
+ * `VerifiedLinkedPR.title` (verify-issue) stays raw at the producer and on
107
+ * the CLI: the same producer feeds the CLI `--json` contract (pinned by
108
+ * verify-issue contract snapshots) and the consuming issue-scout agent
109
+ * carries the awareness block. On the MCP `verify-issue` tool result it is
110
+ * fenced by {@link fenceTitlesDeep} like every other title (#1931).
111
+ * Returns a copy; never mutates.
105
112
  */
106
113
  export declare function fenceFetchedPRTitles<T extends FenceableTitledPR>(pr: T): T;
114
+ /**
115
+ * Fence every non-empty PR/issue title and branch-ref string anywhere in an
116
+ * MCP tool result (#1931). Tool results reach an arbitrary MCP host LLM
117
+ * that never sees the "Prompt Injection Awareness" block, the same reason
118
+ * {@link fenceFetchedPRTitles} exists for resources and prompts, but tool
119
+ * payloads have no single shape, so this walks the whole value and matches
120
+ * by key. Field names and types are unchanged; only the string values gain
121
+ * the fence. Never skips a value that already looks fenced: an attacker can
122
+ * write a title that looks pre-fenced. Returns a copy; never mutates.
123
+ * MCP-only: the CLI `--json` envelope keeps these raw.
124
+ */
125
+ export declare function fenceTitlesDeep<T>(value: T): T;
107
126
  /**
108
127
  * Provenance preamble for stored per-repo guidelines (#1455). Guidelines are
109
128
  * LLM-distilled from a corpus of public PR comments — an untrusted source —
@@ -7,9 +7,11 @@
7
7
  * and the prompt-injection corpus:
8
8
  *
9
9
  * 1. Output starts with the open tag and ends with the close tag.
10
- * 2. The close-tag literal NEVER appears inside the wrapped body — any
11
- * occurrence in the input is escaped to a sentinel so an attacker
12
- * cannot close the fence early and inject instructions after it.
10
+ * 2. No `<` appears inside the wrapped body: every one is escaped to
11
+ * `&lt;` (#1931), so no tag of any spelling (letter case, inner
12
+ * whitespace, attributes, zero-width or lookalike letters) can exist
13
+ * there and an attacker cannot close the fence early and inject
14
+ * instructions after it.
13
15
  * 3. `extractFromFence(wrapUntrustedContent(x, label))` returns `x`
14
16
  * unchanged for any input — the wrapping is lossless.
15
17
  *
@@ -29,6 +31,8 @@
29
31
  * CLI text renderers consume the same objects.
30
32
  * - MCP-only surfaces (#1455): PR titles and branch-ref names via
31
33
  * {@link fenceFetchedPRTitles} (mcp-server resources.ts / prompts.ts),
34
+ * every title and branch-ref string in MCP tool results via
35
+ * {@link fenceTitlesDeep} (mcp-server tools.ts `wrapTool`, #1931),
32
36
  * and stored guidelines provenance via {@link labelGuidelinesContent}.
33
37
  * These do NOT apply on the CLI envelope — see the helpers' docs.
34
38
  *
@@ -44,18 +48,6 @@
44
48
  */
45
49
  export const UNTRUSTED_OPEN_TAG_NAME = 'github-content';
46
50
  export const UNTRUSTED_CLOSE_TAG = `</${UNTRUSTED_OPEN_TAG_NAME}>`;
47
- /**
48
- * Sentinels used to neutralize any literal open- or close-tag substring
49
- * inside the wrapped body. We use HTML entity escapes (`&lt;` / `&gt;`) so
50
- * the result is pure ASCII, lints cleanly, and round-trips losslessly. The
51
- * `&` itself is escaped first so an input containing the literal text
52
- * `&lt;/github-content&gt;` survives the wrap/unwrap round-trip without
53
- * collision.
54
- */
55
- const AMP_ESCAPE = '&amp;';
56
- const CLOSE_TAG_ESCAPE = `&lt;/${UNTRUSTED_OPEN_TAG_NAME}&gt;`;
57
- const OPEN_TAG_PATTERN = new RegExp(String.raw `<${UNTRUSTED_OPEN_TAG_NAME}\b`, 'g');
58
- const OPEN_TAG_ESCAPE = `&lt;${UNTRUSTED_OPEN_TAG_NAME}`;
59
51
  function escapeAttr(value) {
60
52
  // Newlines/carriage returns can't break out of a quoted attribute (no `"`)
61
53
  // but they visually fragment the open tag in the prompt text the LLM
@@ -70,23 +62,18 @@ function escapeAttr(value) {
70
62
  }
71
63
  /**
72
64
  * Wrap `text` in a `<github-content>` fence labeled with `label` and the
73
- * optional metadata. Any occurrence of the close-tag literal inside `text`
74
- * is replaced with a zero-width-joined sentinel that round-trips losslessly
75
- * via {@link extractFromFence}.
65
+ * optional metadata. Every `&` and `<` inside `text` is entity-escaped,
66
+ * which round-trips losslessly via {@link extractFromFence}. Wrapping
67
+ * already-fenced text escapes the inner fence's tags like any other.
68
+ * Fullwidth `<` (U+FF1C) is not ASCII `<` and stays as is.
76
69
  */
77
70
  export function wrapUntrustedContent(text, label, meta = {}) {
78
71
  // Escape order matters for round-trip correctness:
79
72
  // 1. `&` first — so any pre-existing entity in the input gets a literal
80
73
  // `&amp;` that survives the unwrap pass below.
81
- // 2. Close-tag literals — replaced with the entity-escaped form.
82
- // 3. Open-tag literals (matched only at boundaries via OPEN_TAG_PATTERN
83
- // so we don't accidentally rewrite the close-tag's `</github-content`).
84
- const escapedBody = text
85
- .split('&')
86
- .join(AMP_ESCAPE)
87
- .split(UNTRUSTED_CLOSE_TAG)
88
- .join(CLOSE_TAG_ESCAPE)
89
- .replaceAll(OPEN_TAG_PATTERN, OPEN_TAG_ESCAPE);
74
+ // 2. Every `<`. After pass 1 every `&lt;` in the body is one written
75
+ // here, so an input holding the literal text `&lt;` does not collide.
76
+ const escapedBody = text.replaceAll('&', '&amp;').replaceAll('<', '&lt;');
90
77
  const attrs = [`label="${escapeAttr(label)}"`];
91
78
  if (meta.author !== undefined)
92
79
  attrs.push(`author="${escapeAttr(meta.author)}"`);
@@ -98,7 +85,7 @@ export function wrapUntrustedContent(text, label, meta = {}) {
98
85
  }
99
86
  /**
100
87
  * Reverse of {@link wrapUntrustedContent}. Extracts the original body text
101
- * (un-escaping any sentinel-encoded close tags). Throws if the input is not
88
+ * (un-escaping `&lt;` and `&amp;`). Throws if the input is not
102
89
  * a single well-formed fence — callers shouldn't be parsing arbitrary
103
90
  * markdown with this; it's for tests + symmetric reasoning only.
104
91
  */
@@ -111,18 +98,13 @@ export function extractFromFence(fenced) {
111
98
  throw new Error('extractFromFence: input does not end with </github-content>');
112
99
  }
113
100
  const inner = fenced.slice(openMatch[0].length, fenced.length - UNTRUSTED_CLOSE_TAG.length);
114
- if (inner.includes(UNTRUSTED_CLOSE_TAG)) {
115
- throw new Error('extractFromFence: nested </github-content> found in body — fence escaping is broken');
101
+ // wrapUntrustedContent never leaves a raw `<` in the body.
102
+ if (inner.includes('<')) {
103
+ throw new Error('extractFromFence: raw < found in body (nested tag?) — fence escaping is broken');
116
104
  }
117
- // Reverse the escapes in opposite order: tag entities first (so an
105
+ // Reverse the escapes in opposite order: `&lt;` first (so an
118
106
  // already-`&amp;`-prefixed entity survives), then unescape `&amp;`.
119
- return inner
120
- .split(CLOSE_TAG_ESCAPE)
121
- .join(UNTRUSTED_CLOSE_TAG)
122
- .split(OPEN_TAG_ESCAPE)
123
- .join(`<${UNTRUSTED_OPEN_TAG_NAME}`)
124
- .split(AMP_ESCAPE)
125
- .join('&');
107
+ return inner.replaceAll('&lt;', '<').replaceAll('&amp;', '&');
126
108
  }
127
109
  /**
128
110
  * Tolerant unwrap for human-facing display paths (CLI text mode). Returns
@@ -176,10 +158,12 @@ export function fenceFetchedPR(pr) {
176
158
  *
177
159
  * Composes safely with {@link fenceFetchedPR} (disjoint fields), and is
178
160
  * applied to already-body-fenced digest PRs without double-wrapping.
179
- * `VerifiedLinkedPR.title` (verify-issue) stays raw: the same producer
180
- * feeds the CLI `--json` contract (pinned by verify-issue contract
181
- * snapshots) and the consuming issue-scout agent carries the awareness
182
- * block. Returns a copy; never mutates.
161
+ * `VerifiedLinkedPR.title` (verify-issue) stays raw at the producer and on
162
+ * the CLI: the same producer feeds the CLI `--json` contract (pinned by
163
+ * verify-issue contract snapshots) and the consuming issue-scout agent
164
+ * carries the awareness block. On the MCP `verify-issue` tool result it is
165
+ * fenced by {@link fenceTitlesDeep} like every other title (#1931).
166
+ * Returns a copy; never mutates.
183
167
  */
184
168
  export function fenceFetchedPRTitles(pr) {
185
169
  const label = `${pr.repo}#${pr.number}`;
@@ -195,6 +179,57 @@ export function fenceFetchedPRTitles(pr) {
195
179
  }
196
180
  return fenced;
197
181
  }
182
+ /** Result keys {@link fenceTitlesDeep} fences, mapped to the fence `source`. */
183
+ const TITLE_KEY_SOURCES = new Map([
184
+ ['title', 'title'],
185
+ ['prTitle', 'pr-title'],
186
+ ['headRefName', 'pr-head-ref'],
187
+ ['baseRefName', 'pr-base-ref'],
188
+ ]);
189
+ /** Best provenance label available on an arbitrary result object. */
190
+ function titleLabel(obj) {
191
+ if (typeof obj.repo === 'string' && typeof obj.number === 'number')
192
+ return `${obj.repo}#${obj.number}`;
193
+ for (const key of ['url', 'prUrl', 'repo']) {
194
+ const value = obj[key];
195
+ if (typeof value === 'string' && value !== '')
196
+ return value;
197
+ }
198
+ return 'github';
199
+ }
200
+ /**
201
+ * Fence every non-empty PR/issue title and branch-ref string anywhere in an
202
+ * MCP tool result (#1931). Tool results reach an arbitrary MCP host LLM
203
+ * that never sees the "Prompt Injection Awareness" block, the same reason
204
+ * {@link fenceFetchedPRTitles} exists for resources and prompts, but tool
205
+ * payloads have no single shape, so this walks the whole value and matches
206
+ * by key. Field names and types are unchanged; only the string values gain
207
+ * the fence. Never skips a value that already looks fenced: an attacker can
208
+ * write a title that looks pre-fenced. Returns a copy; never mutates.
209
+ * MCP-only: the CLI `--json` envelope keeps these raw.
210
+ */
211
+ export function fenceTitlesDeep(value) {
212
+ if (Array.isArray(value))
213
+ return value.map((item) => fenceTitlesDeep(item));
214
+ if (value === null || typeof value !== 'object')
215
+ return value;
216
+ // Plain objects only: a Date or a class with toJSON must reach
217
+ // JSON.stringify intact, not as a copy of its own enumerable fields.
218
+ const proto = Object.getPrototypeOf(value);
219
+ if (proto !== null && proto !== Object.prototype)
220
+ return value;
221
+ const obj = value;
222
+ const label = titleLabel(obj);
223
+ const out = {};
224
+ for (const [key, field] of Object.entries(obj)) {
225
+ const source = TITLE_KEY_SOURCES.get(key);
226
+ out[key] =
227
+ source !== undefined && typeof field === 'string' && field !== ''
228
+ ? wrapUntrustedContent(field, label, { source })
229
+ : fenceTitlesDeep(field);
230
+ }
231
+ return out;
232
+ }
198
233
  /**
199
234
  * Provenance preamble for stored per-repo guidelines (#1455). Guidelines are
200
235
  * LLM-distilled from a corpus of public PR comments — an untrusted source —
@@ -46,6 +46,15 @@ export declare function parseGitHubUrl(url: string): ParsedGitHubUrl | null;
46
46
  * // "org/repo#5"
47
47
  */
48
48
  export declare function issueRefKey(url: string): string | null;
49
+ /**
50
+ * The key of a URL-keyed state map (`dismissedIssues`, `dismissedPRHeads`,
51
+ * `statusOverrides`) that names the same issue or PR as `url` (#2001): `url`
52
+ * itself when present, else the key with the same {@link issueRefKey}, so a
53
+ * mixed-case owner/repo or the `/issues/N` form of a PR still finds the entry.
54
+ * Keys stay URLs because older clients sharing the Gist look them up by exact
55
+ * URL. undefined when there is no such key.
56
+ */
57
+ export declare function findRefKey(map: Readonly<Record<string, unknown>> | undefined, url: string): string | undefined;
49
58
  /**
50
59
  * Extracts the owner and repo from a GitHub web URL
51
60
  * (e.g. `https://github.com/owner/repo/pull/42`, `https://github.com/owner/repo/`).
package/dist/core/urls.js CHANGED
@@ -74,6 +74,24 @@ export function issueRefKey(url) {
74
74
  const parsed = parseGitHubUrl(url);
75
75
  return parsed ? `${parsed.owner.toLowerCase()}/${parsed.repo.toLowerCase()}#${parsed.number}` : null;
76
76
  }
77
+ /**
78
+ * The key of a URL-keyed state map (`dismissedIssues`, `dismissedPRHeads`,
79
+ * `statusOverrides`) that names the same issue or PR as `url` (#2001): `url`
80
+ * itself when present, else the key with the same {@link issueRefKey}, so a
81
+ * mixed-case owner/repo or the `/issues/N` form of a PR still finds the entry.
82
+ * Keys stay URLs because older clients sharing the Gist look them up by exact
83
+ * URL. undefined when there is no such key.
84
+ */
85
+ export function findRefKey(map, url) {
86
+ if (!map)
87
+ return undefined;
88
+ if (Object.hasOwn(map, url))
89
+ return url;
90
+ const key = issueRefKey(url);
91
+ // ponytail: linear scan per miss, and these maps are never pruned, so cost grows with every
92
+ // dismiss/override ever made. Upgrade: build a ref -> key index once per daily/dashboard pass.
93
+ return key === null ? undefined : Object.keys(map).find((k) => issueRefKey(k) === key);
94
+ }
77
95
  /**
78
96
  * Extracts the owner and repo from a GitHub web URL
79
97
  * (e.g. `https://github.com/owner/repo/pull/42`, `https://github.com/owner/repo/`).