pierre-review 0.1.86 → 0.1.88
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.
- package/dist/api/routes/activity.js +1 -0
- package/dist/api/routes/bot-triage.js +13 -1
- package/dist/api/routes/mentions.js +17 -0
- package/dist/api/routes/prs.js +26 -74
- package/dist/app.js +2 -0
- package/dist/db/migrations/0034_thread_resolved_at.sql +6 -0
- package/dist/db/migrations/0035_pr_first_review_requested_at.sql +5 -0
- package/dist/db/migrations/meta/_journal.json +14 -0
- package/dist/db/migrations-pg/0021_green_salo.sql +1 -0
- package/dist/db/migrations-pg/0022_wise_baron_strucker.sql +1 -0
- package/dist/db/migrations-pg/meta/0021_snapshot.json +3234 -0
- package/dist/db/migrations-pg/meta/0022_snapshot.json +3240 -0
- package/dist/db/migrations-pg/meta/_journal.json +14 -0
- package/dist/db/queries.js +1180 -91
- package/dist/db/schema.pg.js +10 -0
- package/dist/db/schema.sqlite.js +8 -0
- package/dist/github/queries.js +9 -0
- package/dist/github/reviewer-suggest.js +104 -0
- package/dist/pro/bind.js +1 -0
- package/dist/sync/bot-detection.js +4 -0
- package/dist/sync/reviewer-classify.js +5 -0
- package/dist/sync/upsert.js +37 -0
- package/package.json +1 -1
- package/public/assets/{AiFixTab-Bp5xF_mL.js → AiFixTab-xunM4Dcn.js} +3 -3
- package/public/assets/{ClaudeReviewTab-DXa3ezD6.js → ClaudeReviewTab-BSbuovsJ.js} +5 -5
- package/public/assets/PrBotBehaviourTab-DiMPFSk-.js +1 -0
- package/public/assets/index-FNWDcDl6.js +54 -0
- package/public/assets/index-eMcv5bjI.css +1 -0
- package/public/index.html +2 -2
- package/public/assets/index-CON2wK2v.css +0 -1
- package/public/assets/index-DWK0bIXY.js +0 -54
|
@@ -42,6 +42,7 @@ export async function activityRoutes(app) {
|
|
|
42
42
|
allowBotIds: parseIntList(q.allowBotIds),
|
|
43
43
|
botsOnly: q.botsOnly === 'true',
|
|
44
44
|
botWindowDays,
|
|
45
|
+
includeAllCommits: q.includeAllCommits === 'true',
|
|
45
46
|
});
|
|
46
47
|
});
|
|
47
48
|
// Mark the Activity Feed as seen (bumps the account's server-side "seen" marker to
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addBotMuteRule, deleteBotMuteRule, getBotAnalytics, getBotOnlyPrs, getBotVendorPrs, getBotDedupClusters, getResolvableBotThreadPrs, getResolvableBotThreadsForScope, listBotMuteRules, listDetectedReviewers, resolveScopeRepoIds, setReviewerOverride, SCOPE_RESOLVE_THREAD_CAP, } from '../../db/queries.js';
|
|
1
|
+
import { addBotMuteRule, deleteBotMuteRule, getBotAnalytics, getBotBehaviourAnalytics, getBotOnlyPrs, getBotVendorPrs, getBotDedupClusters, getResolvableBotThreadPrs, getResolvableBotThreadsForScope, listBotMuteRules, listDetectedReviewers, resolveScopeRepoIds, setReviewerOverride, SCOPE_RESOLVE_THREAD_CAP, } from '../../db/queries.js';
|
|
2
2
|
import { resolveThreadsOnGitHub } from '../../bot-triage/resolve.js';
|
|
3
3
|
import { accountIdOf } from '../plugins/auth.js';
|
|
4
4
|
// Parse a comma-separated id list into a positive-int array, or null when empty/absent (so
|
|
@@ -173,6 +173,18 @@ export async function botTriageRoutes(app) {
|
|
|
173
173
|
const resp = await getBotAnalytics(accountId, window, scopeRepoIds);
|
|
174
174
|
return resp;
|
|
175
175
|
});
|
|
176
|
+
// EXPERIMENTAL bot BEHAVIOUR analytics (CORE, deterministic — no AI). Per bot, over the same
|
|
177
|
+
// window/scope resolution as /api/bot-analytics: time-to-first-review, LoC-to-comments ratio,
|
|
178
|
+
// the week×hour activity heatmap (coverage / rate-limit inference), and post-first-review
|
|
179
|
+
// follow-up behaviour. Powers the Bots "Behaviour" sub-tab, kept separate from the ROI panel.
|
|
180
|
+
app.get('/api/bot-behaviour', { schema: analyticsSchema }, async (req) => {
|
|
181
|
+
const { window, scope, repoIds } = req.query;
|
|
182
|
+
const accountId = accountIdOf(req);
|
|
183
|
+
const explicit = parseIntList(repoIds);
|
|
184
|
+
const scopeRepoIds = explicit ?? (scope ? await resolveScopeRepoIds(accountId, scope) : null);
|
|
185
|
+
const resp = await getBotBehaviourAnalytics(accountId, window, scopeRepoIds);
|
|
186
|
+
return resp;
|
|
187
|
+
});
|
|
176
188
|
// The exact PR list behind the analytics totals.botOnlyPrs count — "only a bot reviewed these".
|
|
177
189
|
// Same window/scope resolution as /api/bot-analytics (a specific `repoIds` wins over `scope`) so
|
|
178
190
|
// the amber caption's number and this expandable list are computed identically and can't drift.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getScopeMentionCandidates, resolveScopeRepoIds } from '../../db/queries.js';
|
|
2
|
+
import { accountIdOf } from '../plugins/auth.js';
|
|
3
|
+
// Scope-wide @mention candidates (CORE) — the team/repo-scoped sibling of
|
|
4
|
+
// GET /api/prs/:id/mention-candidates. Powers the ad-hoc Insights "Ask about the sprint" box,
|
|
5
|
+
// whose questions span the whole selected scope rather than one PR. `scope` mirrors the Insights
|
|
6
|
+
// scope string ('all' | 'none' | 'teams' | '<teamId>'); it's resolved to the account's repo set
|
|
7
|
+
// server-side (resolveScopeRepoIds), so a caller can't widen it. Self + bots excluded. Returns a
|
|
8
|
+
// bare User[] exactly like the PR route so MentionTextarea can consume it directly.
|
|
9
|
+
export async function mentionsRoutes(app) {
|
|
10
|
+
app.get('/api/mention-candidates', async (req) => {
|
|
11
|
+
const q = req.query;
|
|
12
|
+
const accountId = accountIdOf(req);
|
|
13
|
+
const repoIds = await resolveScopeRepoIds(accountId, q.scope ?? 'all');
|
|
14
|
+
return getScopeMentionCandidates(accountId, repoIds);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=mentions.js.map
|
package/dist/api/routes/prs.js
CHANGED
|
@@ -2,9 +2,8 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
import { config } from '../../config.js';
|
|
3
3
|
import { getAccessToken, getAccountUserId } from '../../auth/account.js';
|
|
4
4
|
import { fetchActionsJobLog } from '../../github/actions-logs.js';
|
|
5
|
-
import { getMentionCandidates, getPrDetail, getPrFilesContext, getPrWriteContext, getReviewerLogins, getResolvableBotThreads, getSuggestedReviewersBasis, getUsersByLogins, markAllViewed, markPrMergedLocally, markPrViewed, stampReviewRequests, upsertLocalPrComment, upsertLocalReview, } from '../../db/queries.js';
|
|
6
|
-
import {
|
|
7
|
-
import { suggestTeamsFromHistory } from '../../github/team-reviewers.js';
|
|
5
|
+
import { getMentionCandidates, getPrDetail, getPrBotBehaviour, getPrFilesContext, getPrWriteContext, getReviewerLogins, getResolvableBotThreads, getSuggestedReviewersBasis, getUsersByLogins, markAllViewed, markPrMergedLocally, markPrViewed, stampReviewRequests, upsertLocalPrComment, upsertLocalReview, } from '../../db/queries.js';
|
|
6
|
+
import { enrichReviewerSuggestions } from '../../github/reviewer-suggest.js';
|
|
8
7
|
import { buildFileAnchors, fallbackAnchor, isFindingAnchored, } from '../../github/diff-anchor.js';
|
|
9
8
|
import { addIssueComment, fetchHeadShaFor, fetchMergeability, fetchPrFilesWithPatch, fetchPrHeadInfo, fetchRepoMergeConfig, mergePullRequest, postInlineComment, requestReviewers, rerunWorkflowRun, submitPrReview, updatePullRequestBranch, } from '../../github/mutations.js';
|
|
10
9
|
import { hydratePrDetail } from '../../sync/hydrate-detail.js';
|
|
@@ -170,77 +169,17 @@ async function buildSuggestedReviewers(basis, accountId) {
|
|
|
170
169
|
if (!basis.wants)
|
|
171
170
|
return { suggestedReviewers: [], users: [] };
|
|
172
171
|
const { owner, name, authorLogin, paths, suggestions, users } = basis;
|
|
173
|
-
const extraUsers =
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
// Resolve @user owners to synced users (avatar/link); unsynced owners show login-only.
|
|
185
|
-
// Exclude the PR author (GitHub rejects self-review requests).
|
|
186
|
-
const uniqueLogins = [...new Set(match.logins)].filter((l) => l !== authorLogin);
|
|
187
|
-
const resolved = await getUsersByLogins(uniqueLogins);
|
|
188
|
-
const byLogin = new Map(resolved.map((u) => [u.githubLogin, u]));
|
|
189
|
-
const codeownerUsers = uniqueLogins.map((login) => ({
|
|
190
|
-
kind: 'user',
|
|
191
|
-
login,
|
|
192
|
-
userId: byLogin.get(login)?.id ?? null,
|
|
193
|
-
teamSlug: null,
|
|
194
|
-
teamName: null,
|
|
195
|
-
reason: 'owns this path (CODEOWNERS)',
|
|
196
|
-
source: 'codeowners',
|
|
197
|
-
}));
|
|
198
|
-
const codeownerTeams = match.teams.map((t) => ({
|
|
199
|
-
kind: 'team',
|
|
200
|
-
login: null,
|
|
201
|
-
userId: null,
|
|
202
|
-
teamSlug: t.slug,
|
|
203
|
-
teamName: t.name,
|
|
204
|
-
reason: 'owns this path (CODEOWNERS)',
|
|
205
|
-
source: 'codeowners',
|
|
206
|
-
}));
|
|
207
|
-
const historyTeamSuggestions = historyTeams.map((t) => ({
|
|
208
|
-
kind: 'team',
|
|
209
|
-
login: null,
|
|
210
|
-
userId: null,
|
|
211
|
-
teamSlug: t.slug,
|
|
212
|
-
teamName: t.name,
|
|
213
|
-
reason: `usually requested here (${t.count} recent PR${t.count === 1 ? '' : 's'})`,
|
|
214
|
-
source: 'history',
|
|
215
|
-
}));
|
|
216
|
-
// Merge = precedence: CODEOWNERS users, CODEOWNERS teams (declared), inferred teams, then
|
|
217
|
-
// the history-user suggestions. Dedup users by login and teams by slug (so a team that's
|
|
218
|
-
// both a CODEOWNER and historically requested shows once, as the CODEOWNER).
|
|
219
|
-
const seenLogins = new Set();
|
|
220
|
-
const seenTeams = new Set();
|
|
221
|
-
merged = [];
|
|
222
|
-
for (const s of [...codeownerUsers, ...codeownerTeams, ...historyTeamSuggestions, ...suggestions]) {
|
|
223
|
-
if (s.kind === 'team') {
|
|
224
|
-
if (s.teamSlug && !seenTeams.has(s.teamSlug)) {
|
|
225
|
-
seenTeams.add(s.teamSlug);
|
|
226
|
-
merged.push(s);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
else if (s.login && !seenLogins.has(s.login)) {
|
|
230
|
-
seenLogins.add(s.login);
|
|
231
|
-
merged.push(s);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
// The newly-resolved codeowner users the basis didn't already carry.
|
|
235
|
-
const known = new Set(users.map((u) => u.id));
|
|
236
|
-
for (const u of resolved)
|
|
237
|
-
if (!known.has(u.id))
|
|
238
|
-
extraUsers.push(u);
|
|
239
|
-
}
|
|
240
|
-
catch {
|
|
241
|
-
/* best-effort: fall back to the history-user suggestions */
|
|
242
|
-
}
|
|
243
|
-
return { suggestedReviewers: merged.slice(0, 5), users: [...users, ...extraUsers] };
|
|
172
|
+
const { suggestions: merged, extraUsers } = await enrichReviewerSuggestions({
|
|
173
|
+
accountId,
|
|
174
|
+
owner,
|
|
175
|
+
name,
|
|
176
|
+
authorLogin,
|
|
177
|
+
paths,
|
|
178
|
+
userSuggestions: suggestions,
|
|
179
|
+
knownUserIds: new Set(users.map((u) => u.id)),
|
|
180
|
+
resolveUsers: getUsersByLogins,
|
|
181
|
+
});
|
|
182
|
+
return { suggestedReviewers: merged, users: [...users, ...extraUsers] };
|
|
244
183
|
}
|
|
245
184
|
export async function prRoutes(app) {
|
|
246
185
|
// Bulk "mark all seen": stamp every open PR (optionally scoped to repoIds) viewed
|
|
@@ -265,6 +204,19 @@ export async function prRoutes(app) {
|
|
|
265
204
|
// cached detail never freezes a stale suggestion.)
|
|
266
205
|
return hydratePrDetail(pr, accountId);
|
|
267
206
|
});
|
|
207
|
+
// PR-scoped bot behaviour (EXPERIMENTAL, CORE, deterministic — no AI): each automated reviewer's
|
|
208
|
+
// touch timeline ON THIS PR + how it compares to that bot's OWN typical (an 84-day account-wide
|
|
209
|
+
// robust baseline). Powers the PrDetail "Bot activity" tab + the Overview chip warn badge.
|
|
210
|
+
// Account-scoped: 404 when the PR isn't the caller's; empty `bots` when no bot touched it.
|
|
211
|
+
app.get('/api/prs/:id/bot-behaviour', { schema: idParamSchema }, async (req, reply) => {
|
|
212
|
+
const { id } = req.params;
|
|
213
|
+
const resp = await getPrBotBehaviour(id, accountIdOf(req));
|
|
214
|
+
if (!resp) {
|
|
215
|
+
reply.status(404);
|
|
216
|
+
return { error: 'NotFound', message: `PR ${id} not found` };
|
|
217
|
+
}
|
|
218
|
+
return resp;
|
|
219
|
+
});
|
|
268
220
|
// Suggested reviewers — its OWN live query (not embedded in the cached PR detail) so it
|
|
269
221
|
// always reflects current state: it empties the instant a reviewer is requested (the assign
|
|
270
222
|
// route stamps review_requests locally), rather than staying frozen until the PR's updatedAt
|
package/dist/app.js
CHANGED
|
@@ -20,6 +20,7 @@ import { feedRoutes } from './api/routes/feed.js';
|
|
|
20
20
|
import { mergersRoutes } from './api/routes/mergers.js';
|
|
21
21
|
import { insightsRoutes } from './api/routes/insights.js';
|
|
22
22
|
import { activityRoutes } from './api/routes/activity.js';
|
|
23
|
+
import { mentionsRoutes } from './api/routes/mentions.js';
|
|
23
24
|
import { billingRoutes } from './api/routes/billing.js';
|
|
24
25
|
import { botTriageRoutes } from './api/routes/bot-triage.js';
|
|
25
26
|
import { webhookRoutes } from './api/routes/webhooks.js';
|
|
@@ -137,6 +138,7 @@ export async function buildApp() {
|
|
|
137
138
|
await app.register(mergersRoutes);
|
|
138
139
|
await app.register(insightsRoutes);
|
|
139
140
|
await app.register(activityRoutes);
|
|
141
|
+
await app.register(mentionsRoutes);
|
|
140
142
|
// Bot-triage platform (CORE, always registered): detection/override, ROI analytics,
|
|
141
143
|
// cross-bot dedup, mute / auto-triage rules. Account-scoped; no AI.
|
|
142
144
|
await app.register(botTriageRoutes);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-- Resolution-latency support: record WHEN a review thread was first observed resolved. Nullable
|
|
2
|
+
-- (unknown for threads already resolved at first sight); stamped by sync only on a witnessed
|
|
3
|
+
-- unresolved→resolved transition. Additive — the backfill is a no-op (existing resolved threads
|
|
4
|
+
-- keep a null resolvedAt; the metric only counts resolves observed going forward).
|
|
5
|
+
-- The Postgres baseline is regenerated separately via `pnpm db:generate:pg`.
|
|
6
|
+
ALTER TABLE `review_threads` ADD `resolved_at` integer;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
-- Review-pickup support: store the earliest review-request time (first ReviewRequestedEvent) so
|
|
2
|
+
-- we can trend request→first-review latency. Nullable (null = never requested / pre-existing PRs
|
|
3
|
+
-- until the next sync backfills it from the timeline). Additive.
|
|
4
|
+
-- The Postgres baseline is regenerated separately via `pnpm db:generate:pg`.
|
|
5
|
+
ALTER TABLE `pull_requests` ADD `first_review_requested_at` integer;
|
|
@@ -239,6 +239,20 @@
|
|
|
239
239
|
"when": 1784200000000,
|
|
240
240
|
"tag": "0033_thread_addressed_confidence",
|
|
241
241
|
"breakpoints": true
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
"idx": 34,
|
|
245
|
+
"version": "6",
|
|
246
|
+
"when": 1784300000000,
|
|
247
|
+
"tag": "0034_thread_resolved_at",
|
|
248
|
+
"breakpoints": true
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"idx": 35,
|
|
252
|
+
"version": "6",
|
|
253
|
+
"when": 1784400000000,
|
|
254
|
+
"tag": "0035_pr_first_review_requested_at",
|
|
255
|
+
"breakpoints": true
|
|
242
256
|
}
|
|
243
257
|
]
|
|
244
258
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE "review_threads" ADD COLUMN "resolved_at" timestamp with time zone;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE "pull_requests" ADD COLUMN "first_review_requested_at" timestamp with time zone;
|