pierre-review 0.1.85 → 0.1.87

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/LICENSE CHANGED
@@ -1,13 +1,102 @@
1
- MIT License
1
+ # Functional Source License, Version 1.1, MIT Future License
2
2
 
3
- Copyright (c) 2026 Alex Wakeman
3
+ ## Abbreviation
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
5
+ FSL-1.1-MIT
6
+
7
+ ## Notice
8
+
9
+ Copyright 2026 Alex Wakeman
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the MIT license that is effective on the second anniversary of the date we make
91
+ the Software available. On or after that date, you may use the Software under
92
+ the MIT license, in which case the following will apply:
93
+
94
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
95
+ this software and associated documentation files (the "Software"), to deal in
96
+ the Software without restriction, including without limitation the rights to
97
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
98
+ of the Software, and to permit persons to whom the Software is furnished to do
99
+ so, subject to the following conditions:
11
100
 
12
101
  The above copyright notice and this permission notice shall be included in all
13
102
  copies or substantial portions of the Software.
package/README.md CHANGED
@@ -92,4 +92,7 @@ locally instead — a larger database, but PR detail then works fully offline.
92
92
 
93
93
  ## License
94
94
 
95
- MIT
95
+ Source-available under the **Functional Source License (FSL-1.1-MIT)** — see
96
+ [LICENSE](./LICENSE). You may use, self-host, and modify Pierre freely; you may
97
+ **not** offer it as a competing commercial or hosted product. Each release
98
+ automatically converts to the **MIT License** two years after its publication.
@@ -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.
@@ -1,4 +1,4 @@
1
- import { getInsights, getRepoAnalytics } from '../../db/queries.js';
1
+ import { getInsights, getRepoAnalytics, getTeamMetricsDetail, getTeamMetricsForScope, resolveScopeRepoIds, } from '../../db/queries.js';
2
2
  import { accountIdOf } from '../plugins/auth.js';
3
3
  function parseIntList(raw) {
4
4
  if (!raw)
@@ -19,6 +19,25 @@ export async function insightsRoutes(app) {
19
19
  repoIds: parseIntList(q.repoIds),
20
20
  });
21
21
  });
22
+ // Team flow-metric header (DORA-ish tiles + trend charts) — CORE/free (moved out of the Pro
23
+ // Insights pane into the Feed). `scope` ('all'|'none'|'teams'|'<teamId>') resolves to repo ids
24
+ // like the rest of the app; null/'all' → the watched set.
25
+ app.get('/api/team-metrics', async (req) => {
26
+ const q = req.query;
27
+ const accountId = accountIdOf(req);
28
+ const scopeRepoIds = q.scope ? await resolveScopeRepoIds(accountId, q.scope) : null;
29
+ return { metrics: await getTeamMetricsForScope(accountId, scopeRepoIds) };
30
+ });
31
+ // The PR lists behind each flow-metric tile (the tile drill-down) — also CORE/free now, so a
32
+ // Feed tile opens the same drill-down for everyone. Mirrors the Pro route's `{enabled, detail}`
33
+ // shape (enabled always true here).
34
+ app.get('/api/team-metrics/detail', async (req) => {
35
+ const q = req.query;
36
+ const accountId = accountIdOf(req);
37
+ const scopeRepoIds = q.scope ? await resolveScopeRepoIds(accountId, q.scope) : null;
38
+ const detail = await getTeamMetricsDetail(accountId, undefined, scopeRepoIds);
39
+ return { enabled: true, detail };
40
+ });
22
41
  // Heavier per-repo analytics for the drill-down chart panel — loaded on demand.
23
42
  // Ownership-scoped: a repo not owned by the account 404s.
24
43
  app.get('/api/insights/:repoId/analytics', async (req, reply) => {
@@ -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
@@ -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 { getCodeownersMatch } from '../../github/codeowners.js';
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
- let merged = suggestions;
175
- try {
176
- const token = await getAccessToken(accountId);
177
- const emptyMatch = { logins: [], teams: [] };
178
- const [match, historyTeams] = await Promise.all([
179
- paths.length > 0
180
- ? getCodeownersMatch(token, owner, name, accountId, paths)
181
- : Promise.resolve(emptyMatch),
182
- suggestTeamsFromHistory(token, owner, name, accountId),
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);