@in-the-loop-labs/pair-review 4.1.1 → 5.0.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.
- package/README.md +81 -13
- package/package.json +6 -2
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin-code-critic/.claude-plugin/plugin.json +1 -1
- package/plugin-pair-loop/.claude-plugin/plugin.json +1 -1
- package/plugin-pair-loop/skills/loop/SKILL.md +17 -8
- package/public/css/ai-summary-modal.css +1 -1
- package/public/css/analysis-config.css +33 -49
- package/public/css/council-card.css +118 -0
- package/public/css/council-dropdown.css +164 -0
- package/public/css/pr.css +666 -394
- package/public/css/repo-settings.css +15 -305
- package/public/css/settings.css +1141 -0
- package/public/css/snippet-manager.css +233 -0
- package/public/index.html +40 -59
- package/public/js/components/AIPanel.js +82 -16
- package/public/js/components/ChatPanel.js +401 -5
- package/public/js/components/CouncilCard.js +202 -0
- package/public/js/components/CouncilDropdown.js +292 -0
- package/public/js/components/DiffOptionsDropdown.js +177 -4
- package/public/js/components/SnippetManager.js +463 -0
- package/public/js/index.js +7 -30
- package/public/js/local.js +20 -2
- package/public/js/modules/comment-manager.js +8 -1
- package/public/js/modules/comment-minimizer.js +249 -190
- package/public/js/modules/external-comment-manager.js +414 -48
- package/public/js/modules/file-comment-manager.js +28 -21
- package/public/js/modules/hunk-summary-renderer.js +155 -29
- package/public/js/modules/pierre-bridge.js +2513 -0
- package/public/js/modules/pierre-context.js +345 -0
- package/public/js/modules/suggestion-manager.js +176 -20
- package/public/js/modules/tour-renderer.js +400 -184
- package/public/js/pr.js +1434 -150
- package/public/js/repo-settings.js +60 -284
- package/public/js/settings.js +1086 -0
- package/public/js/theme-bootstrap.js +40 -0
- package/public/js/theme.js +247 -0
- package/public/js/utils/provider-model.js +3 -3
- package/public/js/utils/suggestion-ui.js +157 -8
- package/public/local.html +20 -31
- package/public/pr.html +14 -23
- package/public/repo-settings.html +24 -14
- package/public/settings.html +138 -0
- package/public/setup.html +8 -13
- package/src/chat/api-reference.js +9 -5
- package/src/chat/prompt-builder.js +8 -1
- package/src/config.js +15 -6
- package/src/database.js +307 -14
- package/src/external/github-adapter.js +39 -5
- package/src/headless/delegate.js +682 -0
- package/src/local-review.js +10 -10
- package/src/local-scope.js +9 -0
- package/src/main.js +276 -157
- package/src/mcp-stdio.js +24 -1
- package/src/review-config.js +93 -25
- package/src/routes/chat.js +2 -2
- package/src/routes/config.js +12 -10
- package/src/routes/external-comments.js +5 -1
- package/src/routes/local.js +2 -4
- package/src/routes/mcp.js +18 -13
- package/src/routes/reviews.js +223 -4
- package/src/routes/settings.js +252 -0
- package/src/routes/setup.js +80 -1
- package/src/routes/shared.js +31 -29
- package/src/routes/snippets.js +154 -0
- package/src/routes/stack-analysis.js +17 -14
- package/src/server.js +86 -18
- package/src/settings/global-settings-service.js +472 -0
- package/src/settings/registry.js +624 -0
- package/src/utils/db-identity.js +44 -0
|
@@ -3,10 +3,17 @@
|
|
|
3
3
|
* HunkSummaryRenderer - Renders inline natural-language hunk summaries.
|
|
4
4
|
*
|
|
5
5
|
* A summary is a short natural-language description of a non-trivial hunk,
|
|
6
|
-
* generated by a background AI job.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* -
|
|
6
|
+
* generated by a background AI job. This renderer supports two rendering
|
|
7
|
+
* backends that share one annotation card body:
|
|
8
|
+
*
|
|
9
|
+
* - Legacy table (`renderInline`): inserts a `<tr class="hunk-summary-row">`
|
|
10
|
+
* immediately ABOVE the hunk's first code row. Used when @pierre/diffs is
|
|
11
|
+
* unavailable and the file rendered through the legacy `renderPatch` path.
|
|
12
|
+
*
|
|
13
|
+
* - @pierre/diffs (`renderPierre`): registers a line annotation with
|
|
14
|
+
* PierreBridge so the same card slots into the light DOM BELOW the hunk's
|
|
15
|
+
* first line. The card carries the `hunk-summary-row` class as a `<div>`
|
|
16
|
+
* so the identical page CSS (styling + visibility toggles) applies.
|
|
10
17
|
*
|
|
11
18
|
* Visibility is controlled outside the renderer via CSS classes:
|
|
12
19
|
* - body.summaries-hidden — review-level toggle
|
|
@@ -18,12 +25,57 @@
|
|
|
18
25
|
|
|
19
26
|
class HunkSummaryRenderer {
|
|
20
27
|
/**
|
|
21
|
-
* @param {Object} prManager - PRManager instance (
|
|
28
|
+
* @param {Object} prManager - PRManager instance (used to reach PierreBridge).
|
|
22
29
|
*/
|
|
23
30
|
constructor(prManager) {
|
|
24
31
|
this.prManager = prManager;
|
|
25
|
-
// Map<contentHash, HTMLTableRowElement> — annotation rows
|
|
32
|
+
// Map<contentHash, HTMLTableRowElement> — legacy annotation rows mounted
|
|
26
33
|
this._mounted = new Map();
|
|
34
|
+
// Map<contentHash, {fileName, id}> — Pierre annotations mounted via the
|
|
35
|
+
// bridge. Kept separate from `_mounted` because Pierre summaries live in
|
|
36
|
+
// PierreBridge's annotation list (not a DOM row we own).
|
|
37
|
+
this._pierreMounted = new Map();
|
|
38
|
+
// Guards one-time registration of the 'hunk-summary' annotation renderer
|
|
39
|
+
// with PierreBridge (the bridge is created after this renderer, so we
|
|
40
|
+
// register lazily on first Pierre mount).
|
|
41
|
+
this._bridgeRendererRegistered = false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Deterministic PierreBridge annotation id for a summary. Deterministic so a
|
|
46
|
+
* re-mount can target (remove/replace) the existing annotation by id.
|
|
47
|
+
* @param {string} contentHash
|
|
48
|
+
* @returns {string}
|
|
49
|
+
*/
|
|
50
|
+
static pierreAnnotationId(contentHash) {
|
|
51
|
+
return `hunk-summary-${contentHash}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Build the inner annotation card (`.hunk-summary-annotation`) shared by the
|
|
56
|
+
* legacy `<tr>` and the Pierre `<div>` wrappers. Contains the icon + text.
|
|
57
|
+
* @param {Object} summary - { summary_text }
|
|
58
|
+
* @returns {HTMLDivElement}
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
_buildAnnotationEl(summary) {
|
|
62
|
+
const annotation = document.createElement('div');
|
|
63
|
+
annotation.className = 'hunk-summary-annotation';
|
|
64
|
+
|
|
65
|
+
const icon = document.createElement('span');
|
|
66
|
+
icon.className = 'hunk-summary-icon';
|
|
67
|
+
icon.setAttribute('aria-hidden', 'true');
|
|
68
|
+
icon.innerHTML = '<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor">' +
|
|
69
|
+
'<path d="M0 3.75C0 2.784.784 2 1.75 2h12.5c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 14H1.75A1.75 1.75 0 0 1 0 12.25Zm1.75-.25a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-8.5a.25.25 0 0 0-.25-.25ZM3.5 6.25a.75.75 0 0 1 .75-.75h7a.75.75 0 0 1 0 1.5h-7a.75.75 0 0 1-.75-.75Zm.75 2.25h4a.75.75 0 0 1 0 1.5h-4a.75.75 0 0 1 0-1.5Z"/>' +
|
|
70
|
+
'</svg>';
|
|
71
|
+
|
|
72
|
+
const text = document.createElement('span');
|
|
73
|
+
text.className = 'hunk-summary-text';
|
|
74
|
+
text.textContent = summary.summary_text;
|
|
75
|
+
|
|
76
|
+
annotation.appendChild(icon);
|
|
77
|
+
annotation.appendChild(text);
|
|
78
|
+
return annotation;
|
|
27
79
|
}
|
|
28
80
|
|
|
29
81
|
/**
|
|
@@ -57,23 +109,7 @@ class HunkSummaryRenderer {
|
|
|
57
109
|
cell.colSpan = 2;
|
|
58
110
|
cell.className = 'hunk-summary-cell';
|
|
59
111
|
|
|
60
|
-
|
|
61
|
-
annotation.className = 'hunk-summary-annotation';
|
|
62
|
-
|
|
63
|
-
const icon = document.createElement('span');
|
|
64
|
-
icon.className = 'hunk-summary-icon';
|
|
65
|
-
icon.setAttribute('aria-hidden', 'true');
|
|
66
|
-
icon.innerHTML = '<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor">' +
|
|
67
|
-
'<path d="M0 3.75C0 2.784.784 2 1.75 2h12.5c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 14H1.75A1.75 1.75 0 0 1 0 12.25Zm1.75-.25a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-8.5a.25.25 0 0 0-.25-.25ZM3.5 6.25a.75.75 0 0 1 .75-.75h7a.75.75 0 0 1 0 1.5h-7a.75.75 0 0 1-.75-.75Zm.75 2.25h4a.75.75 0 0 1 0 1.5h-4a.75.75 0 0 1 0-1.5Z"/>' +
|
|
68
|
-
'</svg>';
|
|
69
|
-
|
|
70
|
-
const text = document.createElement('span');
|
|
71
|
-
text.className = 'hunk-summary-text';
|
|
72
|
-
text.textContent = summary.summary_text;
|
|
73
|
-
|
|
74
|
-
annotation.appendChild(icon);
|
|
75
|
-
annotation.appendChild(text);
|
|
76
|
-
cell.appendChild(annotation);
|
|
112
|
+
cell.appendChild(this._buildAnnotationEl(summary));
|
|
77
113
|
row.appendChild(cell);
|
|
78
114
|
|
|
79
115
|
// Insert IMMEDIATELY ABOVE the hunk's first code line so a reader
|
|
@@ -84,26 +120,116 @@ class HunkSummaryRenderer {
|
|
|
84
120
|
}
|
|
85
121
|
|
|
86
122
|
/**
|
|
87
|
-
*
|
|
123
|
+
* Build the Pierre annotation card wrapper. A `<div class="hunk-summary-row">`
|
|
124
|
+
* so the SAME page CSS that styles/hides the legacy `<tr class="hunk-summary-row">`
|
|
125
|
+
* applies to the slotted light-DOM element. Registered with PierreBridge as
|
|
126
|
+
* the 'hunk-summary' renderer.
|
|
127
|
+
* @param {Object} summary - { content_hash, summary_text }
|
|
128
|
+
* @returns {HTMLDivElement|null}
|
|
129
|
+
* @private
|
|
130
|
+
*/
|
|
131
|
+
_buildPierreCard(summary) {
|
|
132
|
+
if (!summary || !summary.summary_text) return null;
|
|
133
|
+
const card = document.createElement('div');
|
|
134
|
+
card.className = 'hunk-summary-row';
|
|
135
|
+
if (summary.content_hash) card.dataset.contentHash = summary.content_hash;
|
|
136
|
+
card.appendChild(this._buildAnnotationEl(summary));
|
|
137
|
+
return card;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Register the 'hunk-summary' annotation renderer with PierreBridge once.
|
|
142
|
+
* The bridge invokes the callback with the summary data whenever it (re)slots
|
|
143
|
+
* a hunk-summary annotation — including after worker rebuilds / content
|
|
144
|
+
* upgrades, which re-apply `fileState.annotations`.
|
|
145
|
+
* @param {Object} bridge - PierreBridge instance
|
|
146
|
+
* @private
|
|
147
|
+
*/
|
|
148
|
+
_ensureBridgeRenderer(bridge) {
|
|
149
|
+
if (this._bridgeRendererRegistered || !bridge?.registerAnnotationRenderer) return;
|
|
150
|
+
bridge.registerAnnotationRenderer('hunk-summary', (data) => this._buildPierreCard(data));
|
|
151
|
+
this._bridgeRendererRegistered = true;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Mount (or update in place) a summary against a Pierre-rendered file via a
|
|
156
|
+
* line annotation. Idempotent: re-mounting the same hash removes the prior
|
|
157
|
+
* annotation first so the card's text refreshes without stacking duplicates.
|
|
158
|
+
*
|
|
159
|
+
* @param {string} fileName - File the annotation belongs to
|
|
160
|
+
* @param {{lineNumber: number, side: string}} anchor - Anchor position
|
|
161
|
+
* @param {Object} summary - { content_hash, summary_text }
|
|
162
|
+
* @returns {string|null} The annotation id if mounted, else null
|
|
163
|
+
*/
|
|
164
|
+
renderPierre(fileName, anchor, summary) {
|
|
165
|
+
const bridge = this.prManager?.pierreBridge;
|
|
166
|
+
if (!bridge || !fileName || !anchor) return null;
|
|
167
|
+
if (!summary || !summary.summary_text) return null;
|
|
168
|
+
const contentHash = summary.content_hash;
|
|
169
|
+
if (!contentHash) return null;
|
|
170
|
+
|
|
171
|
+
this._ensureBridgeRenderer(bridge);
|
|
172
|
+
|
|
173
|
+
const id = HunkSummaryRenderer.pierreAnnotationId(contentHash);
|
|
174
|
+
// Idempotent update: drop any existing annotation for this hash before
|
|
175
|
+
// re-adding so the text refreshes in place (the bridge appends by id).
|
|
176
|
+
if (this._pierreMounted.has(contentHash)) {
|
|
177
|
+
bridge.removeAnnotation(fileName, id);
|
|
178
|
+
}
|
|
179
|
+
bridge.addAnnotation(fileName, {
|
|
180
|
+
lineNumber: anchor.lineNumber,
|
|
181
|
+
side: anchor.side,
|
|
182
|
+
type: 'hunk-summary',
|
|
183
|
+
id,
|
|
184
|
+
data: summary,
|
|
185
|
+
});
|
|
186
|
+
this._pierreMounted.set(contentHash, { fileName, id });
|
|
187
|
+
return id;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Remove a mounted annotation by its content hash, from whichever backend
|
|
192
|
+
* (legacy `<tr>` or Pierre annotation) it was mounted through.
|
|
88
193
|
* @param {string} contentHash
|
|
89
|
-
* @returns {boolean} true if
|
|
194
|
+
* @returns {boolean} true if an annotation was found and removed
|
|
90
195
|
*/
|
|
91
196
|
removeByHash(contentHash) {
|
|
197
|
+
let removed = false;
|
|
92
198
|
const row = this._mounted.get(contentHash);
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
199
|
+
if (row) {
|
|
200
|
+
if (row.isConnected) row.remove();
|
|
201
|
+
this._mounted.delete(contentHash);
|
|
202
|
+
removed = true;
|
|
203
|
+
}
|
|
204
|
+
const pierre = this._pierreMounted.get(contentHash);
|
|
205
|
+
if (pierre) {
|
|
206
|
+
this.prManager?.pierreBridge?.removeAnnotation(pierre.fileName, pierre.id);
|
|
207
|
+
this._pierreMounted.delete(contentHash);
|
|
208
|
+
removed = true;
|
|
209
|
+
}
|
|
210
|
+
return removed;
|
|
97
211
|
}
|
|
98
212
|
|
|
99
213
|
/**
|
|
100
214
|
* Clear all mounted annotations (e.g. before re-rendering the diff).
|
|
215
|
+
*
|
|
216
|
+
* Pierre annotations are dropped from the bridge too. In practice PRManager
|
|
217
|
+
* calls `pierreBridge.destroyAll()` before this during renderDiff, so those
|
|
218
|
+
* removes are no-ops on already-destroyed files — but doing it here keeps the
|
|
219
|
+
* renderer correct if reset() is ever called on its own.
|
|
101
220
|
*/
|
|
102
221
|
reset() {
|
|
103
222
|
for (const row of this._mounted.values()) {
|
|
104
223
|
if (row.isConnected) row.remove();
|
|
105
224
|
}
|
|
106
225
|
this._mounted.clear();
|
|
226
|
+
const bridge = this.prManager?.pierreBridge;
|
|
227
|
+
if (bridge) {
|
|
228
|
+
for (const { fileName, id } of this._pierreMounted.values()) {
|
|
229
|
+
bridge.removeAnnotation(fileName, id);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
this._pierreMounted.clear();
|
|
107
233
|
}
|
|
108
234
|
}
|
|
109
235
|
|