@oss-autopilot/core 3.26.0 → 3.28.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.
@@ -11,31 +11,107 @@ const CONDITIONAL_CHECKLIST_PATTERN = /\(if\s|\bif applicable\b|\bif needed\b|\b
11
11
  export function isConditionalChecklistItem(line) {
12
12
  return CONDITIONAL_CHECKLIST_PATTERN.test(line.toLowerCase());
13
13
  }
14
+ // Matches markdown headings; `\S` after whitespace prevents backtracking with `.*` (#1718)
15
+ const HEADING_RE = /^#{1,6}\s+(\S.*)/;
16
+ /**
17
+ * Matches headings that indicate a mutually-exclusive "type of change" radio group
18
+ * where exactly one option should be selected. (#1718)
19
+ */
20
+ const TYPE_OF_CHANGE_RE = /type\s+of\s+change|kind\s+of\s+change|category/i;
21
+ /**
22
+ * Split a PR body into sections delimited by markdown headings.
23
+ * Content before the first heading is returned as a section with heading = null.
24
+ */
25
+ function parseSections(body) {
26
+ const lines = body.split('\n');
27
+ const sections = [];
28
+ let currentHeading = null;
29
+ let currentLines = [];
30
+ for (const line of lines) {
31
+ const headingMatch = HEADING_RE.exec(line);
32
+ if (headingMatch) {
33
+ if (currentHeading !== null || currentLines.length > 0) {
34
+ sections.push({ heading: currentHeading, lines: currentLines });
35
+ }
36
+ currentHeading = headingMatch[1].trim();
37
+ currentLines = [];
38
+ }
39
+ else {
40
+ currentLines.push(line);
41
+ }
42
+ }
43
+ // Flush the final section
44
+ if (currentHeading !== null || currentLines.length > 0) {
45
+ sections.push({ heading: currentHeading, lines: currentLines });
46
+ }
47
+ return sections;
48
+ }
49
+ /**
50
+ * Return true if a section contains a "leave unchecked where/if not applicable" note
51
+ * in the first few non-checkbox lines, signalling that unchecked boxes are intentional.
52
+ * (#1718)
53
+ */
54
+ function hasLeaveUncheckedNote(section) {
55
+ const nonCheckboxLines = section.lines.filter((l) => !/- \[x\]/i.test(l));
56
+ // Only inspect the first 5 non-checkbox lines — the note is always near the top
57
+ return nonCheckboxLines.slice(0, 5).some((l) => {
58
+ const lower = l.toLowerCase();
59
+ return lower.includes('leave unchecked') && (lower.includes('not applicable') || lower.includes('n/a'));
60
+ });
61
+ }
62
+ /**
63
+ * Analyze a single checkbox section and return its effective counts.
64
+ * Returns null if the section should be entirely skipped.
65
+ */
66
+ function analyzeSectionItems(section) {
67
+ const sectionText = section.lines.join('\n');
68
+ const checked = (sectionText.match(/- \[x\]/gi) ?? []).length;
69
+ const uncheckedLines = section.lines.filter((l) => /^.*- \[ \].*$/.test(l));
70
+ if (checked === 0 && uncheckedLines.length === 0)
71
+ return null;
72
+ if (hasLeaveUncheckedNote(section))
73
+ return null;
74
+ // Type-of-change radio group: when ≥1 box is checked, remaining unchecked boxes are
75
+ // intentional (single-select) and must not be counted as incomplete. (#1718)
76
+ const isTypeOfChange = section.heading !== null && TYPE_OF_CHANGE_RE.test(section.heading);
77
+ if (isTypeOfChange && checked >= 1)
78
+ return { checked, nonConditionalUnchecked: 0 };
79
+ const nonConditionalUnchecked = uncheckedLines.filter((l) => !isConditionalChecklistItem(l));
80
+ return { checked, nonConditionalUnchecked: nonConditionalUnchecked.length };
81
+ }
14
82
  /**
15
83
  * Analyze PR body for incomplete checklists (unchecked markdown checkboxes).
16
84
  * Looks for patterns like "- [ ]" (unchecked) vs "- [x]" (checked).
17
85
  * Only flags if there ARE checkboxes and some are unchecked.
18
86
  * Conditional items (containing "if applicable", "(if ...)", etc.) are
19
87
  * excluded from the incomplete count (#152).
88
+ *
89
+ * Checkbox groups are parsed by markdown headings. Special handling applies (#1718):
90
+ * - Sections containing "leave unchecked where/if not applicable" are skipped entirely.
91
+ * - Sections whose heading matches "type of change" / "kind of change" / "category"
92
+ * are treated as single-select radio groups: satisfied when at least one box is
93
+ * checked, so the remaining unchecked boxes are not counted as incomplete.
20
94
  */
21
95
  export function analyzeChecklist(body) {
22
96
  if (!body)
23
97
  return { hasIncompleteChecklist: false };
24
- const checkedPattern = /- \[x\]/gi;
25
- const uncheckedLinePattern = /^.*- \[ \].*$/gm;
26
- const checkedMatches = body.match(checkedPattern) || [];
27
- const uncheckedLines = body.match(uncheckedLinePattern) || [];
28
- const checked = checkedMatches.length;
29
- const total = checked + uncheckedLines.length;
30
- // No checkboxes at all - not a checklist PR
31
- if (total === 0)
98
+ const sections = parseSections(body);
99
+ let totalChecked = 0;
100
+ let totalNonConditionalUnchecked = 0;
101
+ for (const section of sections) {
102
+ // null means no checkboxes or section is intentionally skipped
103
+ const result = analyzeSectionItems(section);
104
+ if (result === null)
105
+ continue;
106
+ totalChecked += result.checked;
107
+ totalNonConditionalUnchecked += result.nonConditionalUnchecked;
108
+ }
109
+ const effectiveTotal = totalChecked + totalNonConditionalUnchecked;
110
+ // No checkboxes, or every section was skipped (leave-unchecked) or fully conditional
111
+ if (effectiveTotal === 0)
32
112
  return { hasIncompleteChecklist: false };
33
- // Filter out conditional checklist items that are intentionally unchecked
34
- const nonConditionalUnchecked = uncheckedLines.filter((line) => !isConditionalChecklistItem(line));
35
- // Use consistent total that excludes conditional items (matches hasIncompleteChecklist logic)
36
- const effectiveTotal = checked + nonConditionalUnchecked.length;
37
113
  return {
38
- hasIncompleteChecklist: nonConditionalUnchecked.length > 0,
39
- checklistStats: { checked, total: effectiveTotal },
114
+ hasIncompleteChecklist: totalNonConditionalUnchecked > 0,
115
+ checklistStats: { checked: totalChecked, total: effectiveTotal },
40
116
  };
41
117
  }
@@ -27,9 +27,9 @@ export const CONFIG_KEY_REGISTRY = [
27
27
  // ── Capacity / dormancy ──────────────────────────────────────────────
28
28
  {
29
29
  key: 'maxActivePRs',
30
- description: 'Soft cap on how many active PRs you want to juggle at once.',
30
+ description: 'Soft cap on how many active PRs you want to juggle at once. 0 disables the cap.',
31
31
  settableVia: 'setup',
32
- valueHint: 'positive integer',
32
+ valueHint: 'non-negative integer (0 = no limit)',
33
33
  },
34
34
  {
35
35
  key: 'dormantDays',
@@ -232,15 +232,19 @@ export function computeRepoSignals(prs) {
232
232
  export function assessCapacity(activePRs, maxActivePRs, shelvedPRCount) {
233
233
  const activePRCount = activePRs.length;
234
234
  const criticalIssueCount = activePRs.filter((pr) => pr.status === 'needs_addressing' && pr.actionReason && CRITICAL_ACTION_REASONS.has(pr.actionReason)).length;
235
- // Has capacity if: under PR limit AND no critical issues
236
- const underPRLimit = activePRCount < maxActivePRs;
235
+ // Has capacity if: under PR limit AND no critical issues. A limit of 0 means no limit.
236
+ const unlimited = maxActivePRs <= 0;
237
+ const underPRLimit = unlimited || activePRCount < maxActivePRs;
237
238
  const noCriticalIssues = criticalIssueCount === 0;
238
239
  const hasCapacity = underPRLimit && noCriticalIssues;
239
240
  // Generate reason
240
241
  let reason;
241
242
  const shelvedNote = shelvedPRCount > 0 ? ` + ${shelvedPRCount} shelved` : '';
243
+ const countLabel = unlimited
244
+ ? `${activePRCount} active PRs (no limit)`
245
+ : `${activePRCount}/${maxActivePRs} active PRs`;
242
246
  if (hasCapacity) {
243
- reason = `You have capacity: ${activePRCount}/${maxActivePRs} active PRs${shelvedNote}, no critical issues`;
247
+ reason = `You have capacity: ${countLabel}${shelvedNote}, no critical issues`;
244
248
  }
245
249
  else {
246
250
  const reasons = [];
@@ -437,7 +441,7 @@ export function computeActionMenu(actionableIssues, capacity, commentedIssues =
437
441
  description: 'Look for new contribution opportunities',
438
442
  };
439
443
  if (!capacity.hasCapacity) {
440
- const atLimit = capacity.activePRCount >= capacity.maxActivePRs;
444
+ const atLimit = capacity.maxActivePRs > 0 && capacity.activePRCount >= capacity.maxActivePRs;
441
445
  const hasCritical = capacity.criticalIssueCount > 0;
442
446
  if (atLimit && hasCritical) {
443
447
  searchItem.capacityWarning = `You're at ${capacity.activePRCount}/${capacity.maxActivePRs} active PRs and have ${capacity.criticalIssueCount} critical issue(s). Resolve existing work before claiming new issues.`;
@@ -75,7 +75,15 @@ export declare function getStateCachePath(): string;
75
75
  */
76
76
  export declare function stateFileExists(): boolean;
77
77
  /**
78
- * Read the CLI package version from package.json relative to the running CLI bundle.
78
+ * Return the @oss-autopilot/core version.
79
+ *
80
+ * Bundled builds (the CLI bundle and the MCP server bundle, which inlines core)
81
+ * get it injected at bundle time. That matters for the MCP server: its argv[1]
82
+ * is the mcp-server bundle, so the package.json lookup below would return the
83
+ * mcp-server version, never equal to the core version the dashboard server
84
+ * records in its PID file (#1732).
85
+ *
86
+ * Unbundled runs fall back to package.json relative to the running entry point.
79
87
  * Resolves `../package.json` from the real path of `process.argv[1]` (the bundle
80
88
  * entry point). An npm install runs the CLI through the `node_modules/.bin/oss-autopilot`
81
89
  * symlink, and Node leaves `process.argv[1]` as the symlink, so without `realpathSync`
@@ -115,7 +115,15 @@ export function stateFileExists() {
115
115
  return fs.existsSync(stateFile);
116
116
  }
117
117
  /**
118
- * Read the CLI package version from package.json relative to the running CLI bundle.
118
+ * Return the @oss-autopilot/core version.
119
+ *
120
+ * Bundled builds (the CLI bundle and the MCP server bundle, which inlines core)
121
+ * get it injected at bundle time. That matters for the MCP server: its argv[1]
122
+ * is the mcp-server bundle, so the package.json lookup below would return the
123
+ * mcp-server version, never equal to the core version the dashboard server
124
+ * records in its PID file (#1732).
125
+ *
126
+ * Unbundled runs fall back to package.json relative to the running entry point.
119
127
  * Resolves `../package.json` from the real path of `process.argv[1]` (the bundle
120
128
  * entry point). An npm install runs the CLI through the `node_modules/.bin/oss-autopilot`
121
129
  * symlink, and Node leaves `process.argv[1]` as the symlink, so without `realpathSync`
@@ -123,6 +131,8 @@ export function stateFileExists() {
123
131
  * Falls back to '0.0.0' if the file is unreadable.
124
132
  */
125
133
  export function getCLIVersion() {
134
+ if (typeof __OSS_AUTOPILOT_CORE_VERSION__ === 'string')
135
+ return __OSS_AUTOPILOT_CORE_VERSION__;
126
136
  try {
127
137
  const entry = fs.realpathSync(process.argv[1]);
128
138
  const pkgPath = path.join(path.dirname(entry), '..', 'package.json');
@@ -1155,6 +1155,7 @@ export declare const ParseIssueListOutputSchema: z.ZodObject<{
1155
1155
  number: z.ZodNumber;
1156
1156
  title: z.ZodString;
1157
1157
  tier: z.ZodString;
1158
+ group: z.ZodOptional<z.ZodString>;
1158
1159
  url: z.ZodString;
1159
1160
  score: z.ZodOptional<z.ZodNumber>;
1160
1161
  }, z.core.$strip>>;
@@ -1163,11 +1164,22 @@ export declare const ParseIssueListOutputSchema: z.ZodObject<{
1163
1164
  number: z.ZodNumber;
1164
1165
  title: z.ZodString;
1165
1166
  tier: z.ZodString;
1167
+ group: z.ZodOptional<z.ZodString>;
1168
+ url: z.ZodString;
1169
+ score: z.ZodOptional<z.ZodNumber>;
1170
+ }, z.core.$strip>>;
1171
+ blocked: z.ZodArray<z.ZodObject<{
1172
+ repo: z.ZodString;
1173
+ number: z.ZodNumber;
1174
+ title: z.ZodString;
1175
+ tier: z.ZodString;
1176
+ group: z.ZodOptional<z.ZodString>;
1166
1177
  url: z.ZodString;
1167
1178
  score: z.ZodOptional<z.ZodNumber>;
1168
1179
  }, z.core.$strip>>;
1169
1180
  availableCount: z.ZodNumber;
1170
1181
  completedCount: z.ZodNumber;
1182
+ blockedCount: z.ZodNumber;
1171
1183
  }, z.core.$strip>;
1172
1184
  export declare const CheckIntegrationOutputSchema: z.ZodObject<{
1173
1185
  newFiles: z.ZodArray<z.ZodObject<{
@@ -1391,6 +1403,8 @@ export interface IssueListInfo {
1391
1403
  source: 'configured' | 'auto-detected';
1392
1404
  availableCount: number;
1393
1405
  completedCount: number;
1406
+ /** Vetted items blocked on an outside condition; not counted in `availableCount` (#1730). */
1407
+ blockedCount: number;
1394
1408
  skippedIssuesPath?: string;
1395
1409
  /**
1396
1410
  * Set when the issue list file was detected but could not be read (#1448).
@@ -1470,6 +1484,8 @@ export interface ParsedIssueItem {
1470
1484
  number: number;
1471
1485
  title: string;
1472
1486
  tier: string;
1487
+ /** Text of a `###` heading nested under the `##` tier (repo heading, blocker note) (#1730). */
1488
+ group?: string;
1473
1489
  url: string;
1474
1490
  score?: number;
1475
1491
  }
@@ -1477,8 +1493,11 @@ export interface ParsedIssueItem {
1477
1493
  export interface ParseIssueListOutput {
1478
1494
  available: ParsedIssueItem[];
1479
1495
  completed: ParsedIssueItem[];
1496
+ /** Vetted but blocked on an outside condition; excluded from `availableCount` (#1730). */
1497
+ blocked: ParsedIssueItem[];
1480
1498
  availableCount: number;
1481
1499
  completedCount: number;
1500
+ blockedCount: number;
1482
1501
  }
1483
1502
  /** Info about a new file's integration status (#83) */
1484
1503
  export interface NewFileInfo {
@@ -700,14 +700,17 @@ const ParsedIssueItemSchema = z.object({
700
700
  number: z.number(),
701
701
  title: z.string(),
702
702
  tier: z.string(),
703
+ group: z.string().optional(),
703
704
  url: z.string(),
704
705
  score: z.number().optional(),
705
706
  });
706
707
  export const ParseIssueListOutputSchema = z.object({
707
708
  available: z.array(ParsedIssueItemSchema),
708
709
  completed: z.array(ParsedIssueItemSchema),
710
+ blocked: z.array(ParsedIssueItemSchema),
709
711
  availableCount: z.number().int().nonnegative(),
710
712
  completedCount: z.number().int().nonnegative(),
713
+ blockedCount: z.number().int().nonnegative(),
711
714
  });
712
715
  const NewFileInfoSchema = z.object({
713
716
  path: z.string(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oss-autopilot/core",
3
- "version": "3.26.0",
3
+ "version": "3.28.0",
4
4
  "description": "CLI and core library for managing open source contributions",
5
5
  "type": "module",
6
6
  "bin": {