opencode-pilot 0.19.0 → 0.19.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.
@@ -0,0 +1,33 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "npm"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ day: "monday"
8
+ # Group updates to reduce PR noise
9
+ groups:
10
+ # Group all dev dependencies together
11
+ dev-dependencies:
12
+ dependency-type: "development"
13
+ update-types:
14
+ - "minor"
15
+ - "patch"
16
+ # Group production dependencies together
17
+ production-dependencies:
18
+ dependency-type: "production"
19
+ update-types:
20
+ - "minor"
21
+ - "patch"
22
+ # Keep major updates separate for careful review
23
+ open-pull-requests-limit: 10
24
+ commit-message:
25
+ prefix: "chore(deps)"
26
+
27
+ - package-ecosystem: "github-actions"
28
+ directory: "/"
29
+ schedule:
30
+ interval: "weekly"
31
+ day: "monday"
32
+ commit-message:
33
+ prefix: "chore(deps)"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-pilot",
3
- "version": "0.19.0",
3
+ "version": "0.19.1",
4
4
  "type": "module",
5
5
  "main": "plugin/index.js",
6
6
  "description": "Automation daemon for OpenCode - polls for work and spawns sessions",
package/service/poller.js CHANGED
@@ -437,21 +437,54 @@ async function fetchPrReviewCommentsViaCli(owner, repo, number, timeout) {
437
437
  }
438
438
  }
439
439
 
440
+ /**
441
+ * Fetch PR reviews using gh CLI
442
+ *
443
+ * Fetches formal PR reviews (APPROVED, CHANGES_REQUESTED, COMMENTED state).
444
+ * These are separate from inline comments and issue comments.
445
+ *
446
+ * @param {string} owner - Repository owner
447
+ * @param {string} repo - Repository name
448
+ * @param {number} number - PR number
449
+ * @param {number} timeout - Timeout in ms
450
+ * @returns {Promise<Array>} Array of review objects with user, state, body
451
+ */
452
+ async function fetchPrReviewsViaCli(owner, repo, number, timeout) {
453
+ const { exec } = await import('child_process');
454
+ const { promisify } = await import('util');
455
+ const execAsync = promisify(exec);
456
+
457
+ try {
458
+ const { stdout } = await Promise.race([
459
+ execAsync(`gh api repos/${owner}/${repo}/pulls/${number}/reviews`),
460
+ createTimeout(timeout, "gh api call for PR reviews"),
461
+ ]);
462
+
463
+ const reviews = JSON.parse(stdout);
464
+ return Array.isArray(reviews) ? reviews : [];
465
+ } catch (err) {
466
+ console.error(`[poller] Error fetching PR reviews via gh: ${err.message}`);
467
+ return [];
468
+ }
469
+ }
470
+
440
471
  /**
441
472
  * Fetch comments for a GitHub issue/PR and enrich the item
442
473
  *
443
- * Fetches BOTH types of comments using gh CLI:
474
+ * Fetches THREE types of feedback using gh CLI:
444
475
  * 1. PR review comments (inline code comments) via gh api pulls/{number}/comments
445
476
  * 2. Issue comments (conversation thread) via gh api issues/{number}/comments
477
+ * 3. PR reviews (formal reviews) via gh api pulls/{number}/reviews
446
478
  *
447
479
  * This is necessary because:
448
480
  * - Bots like Linear post to issue comments, not PR review comments
449
481
  * - Human reviewers post inline feedback as PR review comments
482
+ * - Formal PR reviews (APPROVED, CHANGES_REQUESTED, COMMENTED) are stored separately
450
483
  *
451
484
  * @param {object} item - Item with repository_full_name and number fields
452
485
  * @param {object} [options] - Options
453
486
  * @param {number} [options.timeout] - Timeout in ms (default: 30000)
454
- * @returns {Promise<Array>} Array of comment objects (merged from both endpoints)
487
+ * @returns {Promise<Array>} Array of comment/review objects (merged from all endpoints)
455
488
  */
456
489
  export async function fetchGitHubComments(item, options = {}) {
457
490
  const timeout = options.timeout || DEFAULT_MCP_TIMEOUT;
@@ -473,16 +506,18 @@ export async function fetchGitHubComments(item, options = {}) {
473
506
  }
474
507
 
475
508
  try {
476
- // Fetch both PR review comments AND issue comments in parallel via gh CLI
477
- const [prComments, issueComments] = await Promise.all([
509
+ // Fetch PR review comments, issue comments, AND PR reviews in parallel via gh CLI
510
+ const [prComments, issueComments, prReviews] = await Promise.all([
478
511
  // PR review comments (inline code comments from reviewers)
479
512
  fetchPrReviewCommentsViaCli(owner, repo, number, timeout),
480
513
  // Issue comments (conversation thread where Linear bot posts)
481
514
  fetchIssueCommentsViaCli(owner, repo, number, timeout),
515
+ // PR reviews (formal reviews: APPROVED, CHANGES_REQUESTED, COMMENTED)
516
+ fetchPrReviewsViaCli(owner, repo, number, timeout),
482
517
  ]);
483
518
 
484
- // Return merged comments from both sources
485
- return [...prComments, ...issueComments];
519
+ // Return merged feedback from all sources
520
+ return [...prComments, ...issueComments, ...prReviews];
486
521
  } catch (err) {
487
522
  console.error(`[poller] Error fetching comments: ${err.message}`);
488
523
  return [];
package/service/utils.js CHANGED
@@ -70,17 +70,64 @@ export function isBot(username, type) {
70
70
  }
71
71
 
72
72
  /**
73
- * Check if a PR/issue has non-bot feedback (comments from humans other than the author)
73
+ * Check if feedback is a PR review (has state field from /pulls/{number}/reviews)
74
+ *
75
+ * PR reviews have a state field: APPROVED, CHANGES_REQUESTED, COMMENTED, PENDING, DISMISSED
76
+ * Regular comments (from /issues/{number}/comments or /pulls/{number}/comments) don't have state.
77
+ *
78
+ * @param {object} feedback - Comment or review object
79
+ * @returns {boolean} True if this is a PR review (not a regular comment)
80
+ */
81
+ export function isPrReview(feedback) {
82
+ return feedback && typeof feedback.state === 'string';
83
+ }
84
+
85
+ /**
86
+ * Check if feedback is an inline PR comment (from /pulls/{number}/comments)
87
+ *
88
+ * Inline comments have path, position, or diff_hunk fields that top-level comments don't have.
89
+ * They may also have in_reply_to_id if they're replies to other inline comments.
90
+ *
91
+ * @param {object} feedback - Comment or review object
92
+ * @returns {boolean} True if this is an inline PR comment
93
+ */
94
+ export function isInlineComment(feedback) {
95
+ if (!feedback) return false;
96
+ // Inline comments have path (file path) and usually diff_hunk or position
97
+ return typeof feedback.path === 'string' || typeof feedback.diff_hunk === 'string';
98
+ }
99
+
100
+ /**
101
+ * Check if feedback is a reply to another comment
102
+ *
103
+ * @param {object} feedback - Comment or review object
104
+ * @returns {boolean} True if this is a reply
105
+ */
106
+ export function isReply(feedback) {
107
+ if (!feedback) return false;
108
+ // PR review comments use in_reply_to_id for replies
109
+ return feedback.in_reply_to_id !== undefined && feedback.in_reply_to_id !== null;
110
+ }
111
+
112
+ /**
113
+ * Check if a PR/issue has actionable feedback
74
114
  *
75
115
  * Used to filter out PRs where only bots have commented, since those don't
76
- * require the author's attention for human feedback.
116
+ * require the author's attention.
117
+ *
118
+ * Logic for author's own feedback:
119
+ * - Author's inline comments (standalone) → trigger (self-review on code)
120
+ * - Author's inline comments (replies) → ignore (responding to reviewer)
121
+ * - Author's PR reviews → trigger (formal self-review)
122
+ * - Author's top-level comments → ignore (conversation noise)
77
123
  *
78
- * Also skips approval-only reviews (APPROVED state with no body text) since
79
- * approvals don't require action from the author.
124
+ * Logic for others' feedback:
125
+ * - Bot comments ignore
126
+ * - Human comments/reviews → trigger (except approval-only with no body)
80
127
  *
81
- * @param {Array} comments - Array of comment objects with user.login and user.type
128
+ * @param {Array} comments - Array of comment/review objects with user.login and user.type
82
129
  * @param {string} authorUsername - Username of the PR/issue author
83
- * @returns {boolean} True if there's at least one non-bot, non-author, actionable comment
130
+ * @returns {boolean} True if there's at least one actionable feedback item
84
131
  */
85
132
  export function hasNonBotFeedback(comments, authorUsername) {
86
133
  // Handle null/undefined/empty
@@ -97,16 +144,30 @@ export function hasNonBotFeedback(comments, authorUsername) {
97
144
  const username = user.login;
98
145
  const userType = user.type;
99
146
 
100
- // Skip if it's a bot
147
+ // Skip if it's a bot (but Copilot is NOT in bot list, so Copilot reviews are kept)
101
148
  if (isBot(username, userType)) continue;
102
149
 
103
- // Skip if it's the author themselves
104
- if (authorLower && username?.toLowerCase() === authorLower) continue;
150
+ // For author's own feedback, apply special rules
151
+ if (authorLower && username?.toLowerCase() === authorLower) {
152
+ // Author's PR reviews → trigger
153
+ if (isPrReview(comment)) {
154
+ // Continue to check if it's actionable (not approval-only)
155
+ }
156
+ // Author's inline comments (standalone only) → trigger
157
+ else if (isInlineComment(comment)) {
158
+ if (isReply(comment)) continue; // Skip replies
159
+ // Standalone inline comment - continue to actionable check
160
+ }
161
+ // Author's top-level comments → ignore
162
+ else {
163
+ continue;
164
+ }
165
+ }
105
166
 
106
167
  // Skip approval-only reviews (no actionable feedback)
107
168
  if (isApprovalOnly(comment)) continue;
108
169
 
109
- // Found a non-bot, non-author, actionable comment
170
+ // Found actionable feedback
110
171
  return true;
111
172
  }
112
173
 
@@ -71,9 +71,10 @@ describe('utils.js', () => {
71
71
  assert.strictEqual(hasNonBotFeedback(comments, 'athal7'), false);
72
72
  });
73
73
 
74
- test('returns false when only author has commented', async () => {
74
+ test('returns false when only author has top-level comments', async () => {
75
75
  const { hasNonBotFeedback } = await import('../../service/utils.js');
76
76
 
77
+ // Top-level comments from author (no state, no path) are ignored
77
78
  const comments = [
78
79
  { user: { login: 'github-actions[bot]', type: 'Bot' }, body: 'CI passed' },
79
80
  { user: { login: 'athal7', type: 'User' }, body: 'Added screenshots' },
@@ -82,6 +83,62 @@ describe('utils.js', () => {
82
83
  assert.strictEqual(hasNonBotFeedback(comments, 'athal7'), false);
83
84
  });
84
85
 
86
+ test('returns true when author has submitted a PR review (self-review)', async () => {
87
+ const { hasNonBotFeedback } = await import('../../service/utils.js');
88
+
89
+ // PR reviews from author (have state field) ARE actionable - self-review feedback
90
+ const comments = [
91
+ { user: { login: 'github-actions[bot]', type: 'Bot' }, body: 'CI passed' },
92
+ { user: { login: 'athal7', type: 'User' }, state: 'COMMENTED', body: 'TODO: add tests' },
93
+ ];
94
+
95
+ assert.strictEqual(hasNonBotFeedback(comments, 'athal7'), true);
96
+ });
97
+
98
+ test('returns true when author has standalone inline comment', async () => {
99
+ const { hasNonBotFeedback } = await import('../../service/utils.js');
100
+
101
+ // Standalone inline comments from author (have path, no in_reply_to_id) ARE actionable
102
+ const comments = [
103
+ {
104
+ user: { login: 'athal7', type: 'User' },
105
+ body: 'Need to refactor this',
106
+ path: 'src/index.js',
107
+ diff_hunk: '@@ -1,3 +1,4 @@',
108
+ },
109
+ ];
110
+
111
+ assert.strictEqual(hasNonBotFeedback(comments, 'athal7'), true);
112
+ });
113
+
114
+ test('returns false when author has reply inline comment', async () => {
115
+ const { hasNonBotFeedback } = await import('../../service/utils.js');
116
+
117
+ // Reply inline comments from author (have in_reply_to_id) are ignored
118
+ const comments = [
119
+ {
120
+ user: { login: 'athal7', type: 'User' },
121
+ body: 'Fixed!',
122
+ path: 'src/index.js',
123
+ diff_hunk: '@@ -1,3 +1,4 @@',
124
+ in_reply_to_id: 12345,
125
+ },
126
+ ];
127
+
128
+ assert.strictEqual(hasNonBotFeedback(comments, 'athal7'), false);
129
+ });
130
+
131
+ test('returns false when author self-approves with no feedback', async () => {
132
+ const { hasNonBotFeedback } = await import('../../service/utils.js');
133
+
134
+ // Author's approval-only (no body) should not trigger
135
+ const comments = [
136
+ { user: { login: 'athal7', type: 'User' }, state: 'APPROVED', body: '' },
137
+ ];
138
+
139
+ assert.strictEqual(hasNonBotFeedback(comments, 'athal7'), false);
140
+ });
141
+
85
142
  test('returns false for empty comments array', async () => {
86
143
  const { hasNonBotFeedback } = await import('../../service/utils.js');
87
144
 
@@ -173,6 +230,66 @@ describe('utils.js', () => {
173
230
  });
174
231
  });
175
232
 
233
+ describe('isPrReview', () => {
234
+ test('returns true for objects with state field', async () => {
235
+ const { isPrReview } = await import('../../service/utils.js');
236
+
237
+ assert.strictEqual(isPrReview({ state: 'APPROVED' }), true);
238
+ assert.strictEqual(isPrReview({ state: 'CHANGES_REQUESTED' }), true);
239
+ assert.strictEqual(isPrReview({ state: 'COMMENTED' }), true);
240
+ });
241
+
242
+ test('returns false for objects without state field', async () => {
243
+ const { isPrReview } = await import('../../service/utils.js');
244
+
245
+ assert.strictEqual(isPrReview({ body: 'Comment' }), false);
246
+ assert.strictEqual(isPrReview({}), false);
247
+ // null/undefined returns falsy (null), which is fine for boolean checks
248
+ assert.ok(!isPrReview(null));
249
+ assert.ok(!isPrReview(undefined));
250
+ });
251
+ });
252
+
253
+ describe('isInlineComment', () => {
254
+ test('returns true for comments with path field', async () => {
255
+ const { isInlineComment } = await import('../../service/utils.js');
256
+
257
+ assert.strictEqual(isInlineComment({ path: 'src/index.js', body: 'Fix this' }), true);
258
+ });
259
+
260
+ test('returns true for comments with diff_hunk field', async () => {
261
+ const { isInlineComment } = await import('../../service/utils.js');
262
+
263
+ assert.strictEqual(isInlineComment({ diff_hunk: '@@ -1,3 +1,4 @@', body: 'Nice' }), true);
264
+ });
265
+
266
+ test('returns false for top-level comments', async () => {
267
+ const { isInlineComment } = await import('../../service/utils.js');
268
+
269
+ assert.strictEqual(isInlineComment({ body: 'Great work!' }), false);
270
+ assert.strictEqual(isInlineComment({}), false);
271
+ assert.strictEqual(isInlineComment(null), false);
272
+ });
273
+ });
274
+
275
+ describe('isReply', () => {
276
+ test('returns true for comments with in_reply_to_id', async () => {
277
+ const { isReply } = await import('../../service/utils.js');
278
+
279
+ assert.strictEqual(isReply({ in_reply_to_id: 12345 }), true);
280
+ assert.strictEqual(isReply({ in_reply_to_id: 0 }), true);
281
+ });
282
+
283
+ test('returns false for standalone comments', async () => {
284
+ const { isReply } = await import('../../service/utils.js');
285
+
286
+ assert.strictEqual(isReply({ body: 'Standalone' }), false);
287
+ assert.strictEqual(isReply({ in_reply_to_id: null }), false);
288
+ assert.strictEqual(isReply({ in_reply_to_id: undefined }), false);
289
+ assert.strictEqual(isReply(null), false);
290
+ });
291
+ });
292
+
176
293
  describe('getNestedValue', () => {
177
294
  test('gets top-level value', async () => {
178
295
  const { getNestedValue } = await import('../../service/utils.js');