@oss-autopilot/core 3.42.3 → 3.42.5

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.
@@ -14,7 +14,7 @@ const UNCHECKED_REASON_RE = /\((?:not run|skipped)\s*:\s*[^\s)][^)]*\)/i;
14
14
  * Boxes about agreements (CLA, code of conduct, licence, sign-off) are never
15
15
  * exempt, whatever lead-in or annotation surrounds them (#1796).
16
16
  */
17
- const NEVER_EXEMPT_RE = /\b(?:cla|code of conduct|agree\w*|sign|signed|licen[cs]\w*)\b/i;
17
+ const NEVER_EXEMPT_RE = /\b(?:cla|dco|code of conduct|agree\w*|sign|signed|signoff|signed-off|licen[cs]\w*)\b/i;
18
18
  export function isConditionalChecklistItem(line) {
19
19
  const lower = line.toLowerCase();
20
20
  return (CONDITIONAL_CHECKLIST_PATTERN.test(lower) || UNCHECKED_REASON_RE.test(line)) && !NEVER_EXEMPT_RE.test(line);
@@ -38,12 +38,44 @@ const LEAD_IN_OPENER_RE = /^(?:if|when|only if)\s+/i;
38
38
  const LEAD_IN_YOU_VERB_RE = /^(?:you|this change)\s+(?:add|change|modif|updat|remov|introduc|touch)\w*\b/i;
39
39
  const LEAD_IN_SUBJECT_VERB_RE = /^(?:the\s+)?(?:pr|change|code)\s+(?:adds|changes|modifies|updates|removes|introduces|touches)\b/i;
40
40
  const ENDS_WITH_ONLY_COLON_RE = /^[^:]*:\s*$/;
41
- function isConditionalLeadIn(line) {
41
+ /**
42
+ * Template lead-ins that condition on what changed without naming you, the PR,
43
+ * the change or the code as the subject, as in the template from #1796:
44
+ * "If user exposed functionality or configuration variables are added/changed:"
45
+ * (the clause ends in a change verb) and "If the code communicates with ...:"
46
+ * (`the code` plus a verb about what it talks to or depends on).
47
+ * Bare "change"/"changes" is also a noun, so it counts only after a subject:
48
+ * "If the public API changes:" qualifies, "When submitting changes:" and
49
+ * "If you have questions about your changes:" do not. Auxiliaries and review
50
+ * verbs ("the code is complete", "the code looks good") are not in the list.
51
+ */
52
+ const LEAD_IN_ENDS_IN_PARTICIPLE_RE = /\b(?:added|changed|modified|updated|removed|introduced|deleted|renamed)\s*:\s*$/i;
53
+ /** Words before a bare "change(s)" that make it a noun, not the clause's verb. */
54
+ const CHANGE_NOUN_CUES = new Set('your my our their its the these those this that any some no of with about for to in on have has had make made propose proposed request requested'.split(' '));
55
+ const BARE_CHANGE_VERBS = new Set(['change', 'changes']);
56
+ function isBareChangeVerbEnding(rest) {
57
+ const words = rest.replace(/:\s*$/, '').trim().toLowerCase().split(/\s+/);
58
+ const prev = words.at(-2);
59
+ if (prev === undefined || !BARE_CHANGE_VERBS.has(words.at(-1) ?? ''))
60
+ return false;
61
+ return !prev.endsWith('ing') && !CHANGE_NOUN_CUES.has(prev);
62
+ }
63
+ const LEAD_IN_CODE_VERB_RE = /^the\s+code\s+(?:communicates|interacts|calls|uses|depends|talks|connects|accesses|reads|writes|sends|stores|fetches|imports|loads)\b/i;
64
+ /** The clause after "If"/"When"/"Only if" on a lead-in line ending in its only colon. */
65
+ function leadInClause(line) {
42
66
  const opener = LEAD_IN_OPENER_RE.exec(line);
43
67
  if (!opener || !ENDS_WITH_ONLY_COLON_RE.test(line))
44
- return false;
45
- const rest = line.slice(opener[0].length);
46
- return LEAD_IN_YOU_VERB_RE.test(rest) || LEAD_IN_SUBJECT_VERB_RE.test(rest);
68
+ return undefined;
69
+ return line.slice(opener[0].length);
70
+ }
71
+ function isConditionalLeadIn(line) {
72
+ const rest = leadInClause(line);
73
+ return rest !== undefined && (LEAD_IN_YOU_VERB_RE.test(rest) || LEAD_IN_SUBJECT_VERB_RE.test(rest));
74
+ }
75
+ function isTemplateLeadIn(line) {
76
+ const rest = leadInClause(line);
77
+ return (rest !== undefined &&
78
+ (LEAD_IN_ENDS_IN_PARTICIPLE_RE.test(rest) || isBareChangeVerbEnding(rest) || LEAD_IN_CODE_VERB_RE.test(rest)));
47
79
  }
48
80
  /** An unindented checkbox line; nested boxes end a conditional run. */
49
81
  const TOP_LEVEL_CHECKBOX_RE = /^- \[[ x]\]/i;
@@ -126,12 +158,17 @@ function markConditionalRunExempt(lines, runStart, runEnd, exempt) {
126
158
  exempt.add(k);
127
159
  }
128
160
  }
129
- const PICK_ONE_RUN = { skipBlanks: true, inRun: ANY_CHECKBOX_RE, mark: markPickOneRunExempt };
130
- const CONDITIONAL_RUN = { skipBlanks: false, inRun: TOP_LEVEL_CHECKBOX_RE, mark: markConditionalRunExempt };
161
+ const PICK_ONE_RUN = { maxBlanks: Infinity, inRun: ANY_CHECKBOX_RE, mark: markPickOneRunExempt };
162
+ const CONDITIONAL_RUN = { maxBlanks: 0, inRun: TOP_LEVEL_CHECKBOX_RE, mark: markConditionalRunExempt };
163
+ /** Templates with these lead-ins put one blank line before the boxes (#1796). */
164
+ const TEMPLATE_CONDITIONAL_RUN = { ...CONDITIONAL_RUN, maxBlanks: 1 };
131
165
  /** The run rule a line introduces, if any. */
132
166
  function runRuleFor(line) {
133
167
  if (PICK_ONE_COMMENT_RE.test(line))
134
168
  return PICK_ONE_RUN;
169
+ // Template first: "If the code changes:" is both shapes and gets the blank line too.
170
+ if (isTemplateLeadIn(line))
171
+ return TEMPLATE_CONDITIONAL_RUN;
135
172
  if (isConditionalLeadIn(line))
136
173
  return CONDITIONAL_RUN;
137
174
  return undefined;
@@ -141,10 +178,11 @@ function runRuleFor(line) {
141
178
  * are intentionally unchecked because of the line introducing their run:
142
179
  * - a pick-one HTML comment (PICK_ONE_COMMENT_RE) whose run has exactly one box
143
180
  * checked, so the unchecked alternatives are intentional (#1760);
144
- * - a conditional lead-in line ({@link isConditionalLeadIn}), so its run is
145
- * conditional like an "(if ...)" item, except NEVER_EXEMPT_RE boxes (#1796).
181
+ * - a conditional lead-in line ({@link isConditionalLeadIn}, {@link isTemplateLeadIn}),
182
+ * so its run is conditional like an "(if ...)" item, except NEVER_EXEMPT_RE boxes (#1796).
146
183
  * A pick-one run is the contiguous checkbox lines after the comment, past blanks;
147
- * a conditional run is the unindented boxes directly below the lead-in.
184
+ * a conditional run is the unindented boxes directly below the lead-in, or after
185
+ * one blank line for a template lead-in.
148
186
  */
149
187
  function collectRunExemptLineIndices(lines) {
150
188
  const exempt = new Set();
@@ -155,9 +193,9 @@ function collectRunExemptLineIndices(lines) {
155
193
  i++;
156
194
  continue;
157
195
  }
158
- // Advance past the introducing line, skipping any blank lines before the checkbox run
196
+ // Advance past the introducing line and up to maxBlanks blank lines before the checkbox run
159
197
  let j = i + 1;
160
- while (rule.skipBlanks && j < lines.length && lines[j].trim() === '')
198
+ for (let blanks = 0; blanks < rule.maxBlanks && j < lines.length && lines[j].trim() === ''; blanks++)
161
199
  j++;
162
200
  // Collect the contiguous checkbox run
163
201
  const runStart = j;
@@ -14,7 +14,7 @@ export declare function isBotAuthor(author: string, userType?: string | null): b
14
14
  * Detect short acknowledgment comments that don't need code or a status change.
15
15
  * Such a comment does not mark the PR as needing attention, so a thanks-only
16
16
  * comment never reaches pr-responder's `appreciation` rule (#1852 follow-up).
17
- * Returns true only when: no question mark, matches an acknowledgment keyword, and under 100 chars.
17
+ * Returns true only when: no question mark, no request word, matches an acknowledgment keyword, and under 100 chars.
18
18
  * Conservative -- missing a real acknowledgment (false negative) is safer than suppressing a substantive response (false positive).
19
19
  */
20
20
  export declare function isAcknowledgmentComment(body: string): boolean;
@@ -36,7 +36,7 @@ export function isBotAuthor(author, userType) {
36
36
  * Detect short acknowledgment comments that don't need code or a status change.
37
37
  * Such a comment does not mark the PR as needing attention, so a thanks-only
38
38
  * comment never reaches pr-responder's `appreciation` rule (#1852 follow-up).
39
- * Returns true only when: no question mark, matches an acknowledgment keyword, and under 100 chars.
39
+ * Returns true only when: no question mark, no request word, matches an acknowledgment keyword, and under 100 chars.
40
40
  * Conservative -- missing a real acknowledgment (false negative) is safer than suppressing a substantive response (false positive).
41
41
  */
42
42
  export function isAcknowledgmentComment(body) {
@@ -45,6 +45,12 @@ export function isAcknowledgmentComment(body) {
45
45
  if (body.includes('?'))
46
46
  return false;
47
47
  const lower = body.toLowerCase();
48
+ // "Thanks! Please rebase and I'll merge." is a request, not an acknowledgment (#1916).
49
+ // Bare "fix", "update" and "change" are left out: they are nouns in pure thanks
50
+ // ("Thanks for the fix!", "Thanks for the update!").
51
+ if (/\b(?:please|pls|but|however|just|needs?|should|must|rebase|squash|add|remove)\b/.test(lower)) {
52
+ return false;
53
+ }
48
54
  const ackKeywords = [
49
55
  'thanks',
50
56
  'thank you',
@@ -154,9 +154,7 @@ function checkIssueReference(meta, repoContext) {
154
154
  detail: 'issue referenced without a closing keyword',
155
155
  };
156
156
  }
157
- const SECTION_WHAT = /(?:^|\n)#{1,3}\s*(?:summary|overview|what(?:\s+changed)?)\b/i;
158
- const SECTION_WHY = /(?:^|\n)#{1,3}\s*(?:why|motivation|context|background|rationale)\b/i;
159
- const CLOSING_REF = /\b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s+(?:[\w.-]+\/[\w.-]+)?#\d+/gi;
157
+ const DESCRIPTION_REF = /(?<![\w/.-])(?:(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?|relate[sd]?\s+to|refs?|references?|see)\s*(?::\s*)?)?(?:[\w.-]+\/[\w.-]+)?#\d+/gi;
160
158
  // Closed code fences: a line opening with 3+ backticks, closed by a later line
161
159
  // opening with at least as many. An unclosed fence is text.
162
160
  function fenceSpans(body) {
@@ -241,7 +239,10 @@ function proseOf(body) {
241
239
  return (uncommented
242
240
  // A heading is a short title line, not a sentence that starts with "# ".
243
241
  .replaceAll(/^ {0,3}#{1,6}[ \t]+[^\n]{0,60}$/gm, (line) => (/[.!?。]\s*$/.test(line) ? line : ''))
244
- .replaceAll(CLOSING_REF, '')
242
+ .replaceAll(/\[([^\][\n]*)\]\(((?:https?:\/\/|www\.)[^\s<>)]*)\)/gi, '$1 $2')
243
+ // Normalize URLs to a reference token so the same rule removes their prefixes.
244
+ .replaceAll(/<?\b(?:https?:\/\/|www\.)[^\s<>]+>?/gi, '#0')
245
+ .replaceAll(DESCRIPTION_REF, '')
245
246
  .trim());
246
247
  }
247
248
  // Headings are never required: a sentence or two of what and why is a full
@@ -253,11 +254,14 @@ function checkDescription(meta) {
253
254
  return { status: 'fail', weight, detail: 'description is empty' };
254
255
  }
255
256
  const prose = proseOf(meta.body);
256
- const hasHeading = SECTION_WHAT.test(meta.body) || SECTION_WHY.test(meta.body);
257
- if (prose.length >= 80 || (hasHeading && /\p{L}/u.test(prose))) {
257
+ if ((prose.match(/\p{L}/gu)?.length ?? 0) >= 10) {
258
258
  return { status: 'pass', weight, detail: 'describes the change' };
259
259
  }
260
- return { status: 'warn', weight, detail: 'short description; say what changed and why' };
260
+ return {
261
+ status: 'warn',
262
+ weight,
263
+ detail: 'too little description beyond scaffolding or references; say what changed and why',
264
+ };
261
265
  }
262
266
  function checkFocusedChanges(meta) {
263
267
  const weight = WEIGHTS.focusedChanges;
@@ -196,7 +196,6 @@ export function checkUnrespondedComments(comments, reviews, reviewComments, user
196
196
  }
197
197
  // Find maintainer comments after the user's last comment
198
198
  let lastMaintainerComment;
199
- let lastMaintainerReviewId;
200
199
  for (const item of timeline) {
201
200
  if (item.isUser)
202
201
  continue; // Skip user's own comments
@@ -204,6 +203,13 @@ export function checkUnrespondedComments(comments, reviews, reviewComments, user
204
203
  continue; // Skip deleted/null accounts
205
204
  if (isBotAuthor(item.author, item.userType))
206
205
  continue; // Skip bots
206
+ // Skip pure acknowledgments here, not after the loop, so a later "thanks"
207
+ // does not clear an earlier unanswered request (#1916). A review with
208
+ // inline comments is never skipped: those carry feedback beyond the
209
+ // summary body that likely needs a response (#829).
210
+ const hasInlineComments = item.reviewId != null && reviewHasInlineComments(item.reviewId, reviewComments);
211
+ if (isAcknowledgmentComment(item.body) && !hasInlineComments)
212
+ continue;
207
213
  const itemTime = new Date(item.createdAt);
208
214
  if (!lastUserCommentTime || itemTime > lastUserCommentTime) {
209
215
  lastMaintainerComment = {
@@ -211,16 +217,8 @@ export function checkUnrespondedComments(comments, reviews, reviewComments, user
211
217
  body: item.body.slice(0, 200) + (item.body.length > 200 ? '...' : ''),
212
218
  createdAt: item.createdAt,
213
219
  };
214
- lastMaintainerReviewId = item.reviewId;
215
220
  }
216
221
  }
217
- // Filter out pure acknowledgment comments that don't require a response.
218
- // Skip the filter when the review has inline comments — those indicate
219
- // feedback beyond the summary body that likely needs a response (#829).
220
- const lastReviewHasInlineComments = lastMaintainerReviewId != null && reviewHasInlineComments(lastMaintainerReviewId, reviewComments);
221
- if (lastMaintainerComment && isAcknowledgmentComment(lastMaintainerComment.body) && !lastReviewHasInlineComments) {
222
- lastMaintainerComment = undefined;
223
- }
224
222
  return {
225
223
  hasUnrespondedComment: !!lastMaintainerComment,
226
224
  lastMaintainerComment,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oss-autopilot/core",
3
- "version": "3.42.3",
3
+ "version": "3.42.5",
4
4
  "description": "CLI and core library for managing open source contributions",
5
5
  "type": "module",
6
6
  "bin": {
@@ -55,7 +55,7 @@
55
55
  "@octokit/plugin-retry": "^8.1.1",
56
56
  "@octokit/plugin-throttling": "^11.0.5",
57
57
  "@octokit/rest": "^22.0.1",
58
- "@oss-scout/core": "^1.14.1",
58
+ "@oss-scout/core": "^1.14.2",
59
59
  "commander": "^15.0.0",
60
60
  "zod": "^4.6.7"
61
61
  },