@in-the-loop-labs/pair-review 5.4.3 → 5.5.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.
@@ -2,41 +2,47 @@
2
2
  /**
3
3
  * File ordering utilities for consistent file display across components.
4
4
  *
5
- * This module provides functions to sort files to match the file navigator's
6
- * directory-grouped ordering, ensuring consistency across all panels.
5
+ * This module provides functions to build the file navigator's directory tree
6
+ * and to sort files in the same order, ensuring consistency across all panels.
7
7
  */
8
8
 
9
9
  /**
10
- * Extract the directory path from a file path.
11
- * @param {string} filePath - Full file path
12
- * @returns {string} Directory path (or '.' for root-level files)
10
+ * Compare two file paths in file-navigator tree order.
11
+ *
12
+ * Paths are compared directory segment by directory segment. Within any
13
+ * directory, its own files come before its subdirectories; siblings are
14
+ * sorted alphabetically (numeric-aware, so file2 < file10).
15
+ *
16
+ * @param {string} pathA
17
+ * @param {string} pathB
18
+ * @returns {number} Negative, zero or positive, like Array#sort comparators
13
19
  */
14
- function getDirectoryPath(filePath) {
15
- const lastSlashIndex = filePath.lastIndexOf('/');
16
- return lastSlashIndex === -1 ? '.' : filePath.substring(0, lastSlashIndex);
17
- }
20
+ function compareFilePaths(pathA, pathB) {
21
+ const dirsA = pathA.split('/');
22
+ const dirsB = pathB.split('/');
23
+ const nameA = dirsA.pop();
24
+ const nameB = dirsB.pop();
18
25
 
19
- /**
20
- * Extract the file name from a file path.
21
- * @param {string} filePath - Full file path
22
- * @returns {string} File name
23
- */
24
- function getFileName(filePath) {
25
- const lastSlashIndex = filePath.lastIndexOf('/');
26
- return lastSlashIndex === -1 ? filePath : filePath.substring(lastSlashIndex + 1);
26
+ const shared = Math.min(dirsA.length, dirsB.length);
27
+ for (let i = 0; i < shared; i++) {
28
+ const cmp = dirsA[i].localeCompare(dirsB[i], undefined, { numeric: true });
29
+ if (cmp !== 0) return cmp;
30
+ }
31
+
32
+ // One directory contains the other: the file directly in the shallower
33
+ // directory comes first (files before subdirectories).
34
+ if (dirsA.length !== dirsB.length) return dirsA.length - dirsB.length;
35
+
36
+ return nameA.localeCompare(nameB, undefined, { numeric: true });
27
37
  }
28
38
 
29
39
  /**
30
- * Sort files to match the file navigator's directory-grouped ordering.
40
+ * Sort files to match the file navigator's tree ordering.
31
41
  *
32
- * The file navigator uses groupFilesByDirectory which:
33
- * 1. Groups files by their directory path
34
- * 2. Sorts directory keys alphabetically
35
- * 3. Within each directory group, files are sorted alphabetically by filename
36
- *
37
- * To match this behavior, we sort by:
38
- * 1. Directory path (alphabetically)
39
- * 2. Then by filename (alphabetically, with numeric sorting for numbered files)
42
+ * The file navigator renders a nested directory tree (see buildDirectoryTree)
43
+ * in which each directory lists its files first, then its subdirectories,
44
+ * each alphabetically. Sorting with the same rules keeps every panel in the
45
+ * same order as the navigator.
40
46
  *
41
47
  * @param {Array} files - Array of file objects with a `file` property containing the path
42
48
  * @returns {Array} New array sorted to match file navigator order
@@ -44,21 +50,75 @@ function getFileName(filePath) {
44
50
  function sortFilesByPath(files) {
45
51
  if (!Array.isArray(files)) return [];
46
52
 
47
- return [...files].sort((a, b) => {
48
- const pathA = a.file || '';
49
- const pathB = b.file || '';
53
+ return [...files].sort((a, b) => compareFilePaths(a.file || '', b.file || ''));
54
+ }
50
55
 
51
- // First, compare by directory path
52
- const dirA = getDirectoryPath(pathA);
53
- const dirB = getDirectoryPath(pathB);
54
- const dirCompare = dirA.localeCompare(dirB, undefined, { numeric: true });
55
- if (dirCompare !== 0) return dirCompare;
56
+ /**
57
+ * Build a nested directory tree for the file navigator, collapsing
58
+ * single-child directory chains into one node (like GitHub's sidebar).
59
+ *
60
+ * For `root/foo/bar/xyz/example.rb`, `root/foo/bar/index.md` and
61
+ * `root/foo/README.md` this produces:
62
+ *
63
+ * root/foo
64
+ * README.md
65
+ * bar
66
+ * index.md
67
+ * xyz
68
+ * example.rb
69
+ *
70
+ * A directory is merged into its parent when the parent has no files of its
71
+ * own and exactly one subdirectory. Root-level files stay on the root node.
72
+ *
73
+ * @param {Array<T>} items - Items to place in the tree
74
+ * @param {function(T): string} [getPath] - Returns an item's path (defaults to `item.file`)
75
+ * @returns {{name: string, path: string, files: Array<T>, dirs: Array}} Root node;
76
+ * `name` is the label to display (may contain slashes after collapsing),
77
+ * `path` is the full directory path ('' for the root). Files and dirs are sorted.
78
+ * @template T
79
+ */
80
+ function buildDirectoryTree(items, getPath = item => item.file) {
81
+ const makeNode = (name, path) => ({ name, path, files: [], dirs: [], _children: new Map() });
82
+ const root = makeNode('', '');
56
83
 
57
- // Within same directory, sort by filename (with numeric sorting for files like file2.js, file10.js)
58
- const nameA = getFileName(pathA);
59
- const nameB = getFileName(pathB);
60
- return nameA.localeCompare(nameB, undefined, { numeric: true });
84
+ (Array.isArray(items) ? items : []).forEach(item => {
85
+ const segments = (getPath(item) || '').split('/');
86
+ segments.pop();
87
+ let node = root;
88
+ segments.forEach(segment => {
89
+ if (!node._children.has(segment)) {
90
+ const childPath = node.path ? `${node.path}/${segment}` : segment;
91
+ node._children.set(segment, makeNode(segment, childPath));
92
+ }
93
+ node = node._children.get(segment);
94
+ });
95
+ node.files.push(item);
61
96
  });
97
+
98
+ const fileName = item => (getPath(item) || '').split('/').pop();
99
+ const byName = (a, b) => a.localeCompare(b, undefined, { numeric: true });
100
+
101
+ const finalize = (node, isRoot) => {
102
+ let current = node;
103
+ // Collapse chains of directories that only contain one subdirectory
104
+ while (!isRoot && current.files.length === 0 && current._children.size === 1) {
105
+ const [only] = current._children.values();
106
+ only.name = `${current.name}/${only.name}`;
107
+ current = only;
108
+ }
109
+ // Sort before collapsing: each child's name is still a single path segment
110
+ // here, matching how compareFilePaths orders directories. Sorting collapsed
111
+ // labels like "foo/bar" would put "foo-x" first, since '-' sorts before '/'.
112
+ // Collapsing never reorders siblings: a collapsed node keeps its first segment.
113
+ current.dirs = [...current._children.values()]
114
+ .sort((a, b) => byName(a.name, b.name))
115
+ .map(child => finalize(child, false));
116
+ current.files.sort((a, b) => byName(fileName(a), fileName(b)));
117
+ delete current._children;
118
+ return current;
119
+ };
120
+
121
+ return finalize(root, true);
62
122
  }
63
123
 
64
124
  /**
@@ -82,6 +142,8 @@ function createFileOrderMap(files) {
82
142
 
83
143
  // Export to window for use in other modules
84
144
  window.FileOrderUtils = {
145
+ compareFilePaths,
85
146
  sortFilesByPath,
147
+ buildDirectoryTree,
86
148
  createFileOrderMap
87
149
  };
@@ -0,0 +1,139 @@
1
+ // Copyright 2026 Tim Perkins (tjwp) | SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * Severity sort and filter for AI suggestions in the Review panel.
4
+ *
5
+ * AI suggestions carry `severity` of "critical", "medium" or "minor"; praise
6
+ * and older suggestions have none, which this module treats as "none".
7
+ * The state is plain data: { sort: 'file' | 'severity', hidden: ['minor', 'none', ...] }.
8
+ * AIPanel saves the sort browser-wide and the hidden levels per review.
9
+ * Only AI suggestions are filtered; user comments and external threads always
10
+ * pass, and sort after every AI suggestion when sorting by severity.
11
+ */
12
+ (function () {
13
+ /** Severity levels, most severe first. "none" covers praise and unset. */
14
+ const SEVERITY_LEVELS = ['critical', 'medium', 'minor', 'none'];
15
+
16
+ const SEVERITY_LABELS = {
17
+ critical: 'Critical',
18
+ medium: 'Medium',
19
+ minor: 'Minor',
20
+ none: 'No severity'
21
+ };
22
+
23
+ const SORT_MODES = ['file', 'severity'];
24
+
25
+ /**
26
+ * Other names providers use for the three levels. Severity is free text
27
+ * from the provider (executable providers pass a tool's own value through),
28
+ * so "high" must not fall into "none" with praise.
29
+ */
30
+ const SEVERITY_ALIASES = {
31
+ blocker: 'critical',
32
+ severe: 'critical',
33
+ high: 'critical',
34
+ error: 'critical',
35
+ major: 'medium',
36
+ moderate: 'medium',
37
+ warning: 'medium',
38
+ low: 'minor',
39
+ trivial: 'minor',
40
+ info: 'minor',
41
+ nit: 'minor'
42
+ };
43
+
44
+ /** @returns {'critical'|'medium'|'minor'|'none'} */
45
+ function normalizeSeverity(severity) {
46
+ const value = typeof severity === 'string' ? severity.trim().toLowerCase() : '';
47
+ if (Object.hasOwn(SEVERITY_ALIASES, value)) return SEVERITY_ALIASES[value];
48
+ return SEVERITY_LEVELS.includes(value) && value !== 'none' ? value : 'none';
49
+ }
50
+
51
+ /** @returns {{sort: string, hidden: string[]}} */
52
+ function defaultSeverityState() {
53
+ return { sort: 'file', hidden: [] };
54
+ }
55
+
56
+ /**
57
+ * Validate a state object (e.g. built from storage): unknown sort modes fall
58
+ * back to 'file', unknown or repeated levels are dropped. Anything that is
59
+ * not an object gives the default state.
60
+ * @param {{sort?: string, hidden?: string[]}} value
61
+ * @returns {{sort: string, hidden: string[]}}
62
+ */
63
+ function parseSeverityState(value) {
64
+ if (!value || typeof value !== 'object') return defaultSeverityState();
65
+ const sort = SORT_MODES.includes(value.sort) ? value.sort : 'file';
66
+ const hiddenInput = Array.isArray(value.hidden) ? value.hidden : [];
67
+ // Keep canonical order so equal states serialize the same way
68
+ const hidden = SEVERITY_LEVELS.filter(level => hiddenInput.includes(level));
69
+ return { sort, hidden };
70
+ }
71
+
72
+ function isFinding(item) {
73
+ return item?._itemType === 'finding';
74
+ }
75
+
76
+ /**
77
+ * Drop AI suggestions whose severity is hidden. Other items pass.
78
+ * @param {Array} items - Items with _itemType
79
+ * @param {{hidden: string[]}} state
80
+ * @returns {{items: Array, hiddenCount: number}}
81
+ */
82
+ function filterBySeverity(items, state) {
83
+ const hidden = new Set(parseSeverityState(state).hidden);
84
+ const list = Array.isArray(items) ? items : [];
85
+ if (hidden.size === 0) return { items: [...list], hiddenCount: 0 };
86
+ const kept = list.filter(item => !isFinding(item) || !hidden.has(normalizeSeverity(item.severity)));
87
+ return { items: kept, hiddenCount: list.length - kept.length };
88
+ }
89
+
90
+ /** Sort rank: severity index for AI suggestions, after all of them for anything else. */
91
+ function severityRank(item) {
92
+ if (!isFinding(item)) return SEVERITY_LEVELS.length;
93
+ return SEVERITY_LEVELS.indexOf(normalizeSeverity(item.severity));
94
+ }
95
+
96
+ /**
97
+ * Stable sort by severity, most severe first. Items of equal rank keep
98
+ * their incoming order, so pass items already in file order.
99
+ * @param {Array} items
100
+ * @returns {Array} New array
101
+ */
102
+ function sortBySeverity(items) {
103
+ const list = Array.isArray(items) ? items : [];
104
+ return list
105
+ .map((item, index) => ({ item, index, rank: severityRank(item) }))
106
+ .sort((a, b) => (a.rank - b.rank) || (a.index - b.index))
107
+ .map(entry => entry.item);
108
+ }
109
+
110
+ /**
111
+ * Filter then (when state.sort is 'severity') sort.
112
+ * @returns {{items: Array, hiddenCount: number}}
113
+ */
114
+ function applySeverityState(items, state) {
115
+ const parsed = parseSeverityState(state);
116
+ const result = filterBySeverity(items, parsed);
117
+ if (parsed.sort === 'severity') result.items = sortBySeverity(result.items);
118
+ return result;
119
+ }
120
+
121
+ const SeverityFilter = {
122
+ SEVERITY_LEVELS,
123
+ SEVERITY_LABELS,
124
+ SORT_MODES,
125
+ normalizeSeverity,
126
+ defaultSeverityState,
127
+ parseSeverityState,
128
+ filterBySeverity,
129
+ sortBySeverity,
130
+ applySeverityState
131
+ };
132
+
133
+ if (typeof window !== 'undefined') {
134
+ window.SeverityFilter = SeverityFilter;
135
+ }
136
+ if (typeof module !== 'undefined' && module.exports) {
137
+ module.exports = SeverityFilter;
138
+ }
139
+ })();
package/public/local.html CHANGED
@@ -33,6 +33,7 @@
33
33
  <link rel="stylesheet" href="/css/pr.css">
34
34
  <link rel="stylesheet" href="/css/ai-summary-modal.css">
35
35
  <link rel="stylesheet" href="/css/analysis-config.css">
36
+ <link rel="stylesheet" href="/css/toast.css">
36
37
  <link rel="stylesheet" href="/css/snippet-manager.css">
37
38
  <link rel="stylesheet" href="/css/styles.css">
38
39
 
@@ -598,6 +599,7 @@
598
599
 
599
600
  <!-- File order utility -->
600
601
  <script src="/js/utils/file-order.js"></script>
602
+ <script src="/js/utils/severity-filter.js"></script>
601
603
 
602
604
  <!-- Timestamp parsing utility -->
603
605
  <script src="/js/utils/time.js"></script>
package/public/pr.html CHANGED
@@ -41,6 +41,7 @@
41
41
  <link rel="stylesheet" href="/css/pr.css">
42
42
  <link rel="stylesheet" href="/css/ai-summary-modal.css">
43
43
  <link rel="stylesheet" href="/css/analysis-config.css">
44
+ <link rel="stylesheet" href="/css/toast.css">
44
45
  <link rel="stylesheet" href="/css/snippet-manager.css">
45
46
  <link rel="stylesheet" href="/css/styles.css">
46
47
 
@@ -403,6 +404,7 @@
403
404
 
404
405
  <!-- File order utility -->
405
406
  <script src="/js/utils/file-order.js"></script>
407
+ <script src="/js/utils/severity-filter.js"></script>
406
408
 
407
409
  <!-- Timestamp parsing utility -->
408
410
  <script src="/js/utils/time.js"></script>
@@ -6,7 +6,7 @@
6
6
  * the official successor to the Gemini CLI.
7
7
  *
8
8
  * ============================================================================
9
- * HOW THIS ADAPTER DRIVES `agy` (verified against agy 1.0.16; models re-verified against 1.5.7)
9
+ * HOW THIS ADAPTER DRIVES `agy` (verified against agy 1.0.16; models re-verified against 1.5.12)
10
10
  * ============================================================================
11
11
  * The Antigravity CLI's non-interactive "print" mode (`agy -p`) IS a real
12
12
  * agentic loop — it reads files, searches the tree, and runs shell commands to
@@ -96,7 +96,8 @@ const TIMEOUT_BACKSTOP_GRACE_MS = 15000;
96
96
  * fast, matching the other providers' pickers. Every built-in passes an
97
97
  * effort-suffixed display name (`Gemini 4 Argon (High)`): as of agy 1.5.7 a
98
98
  * bare display name is "not recognized", and a bare slug resolves to the
99
- * server-default effort (Medium for Argon), so effort stays in the `cliName`.
99
+ * server-default effort (Medium for Argon, High for Neon), so effort stays in
100
+ * the `cliName`.
100
101
  *
101
102
  * Gemini 3.8 Flash at high effort stays the default: it is the strongest
102
103
  * Gemini every agy plan can run (DeepSWE v1.1 73.7, Terminal-Bench 2.1 89.4),
@@ -106,6 +107,18 @@ const TIMEOUT_BACKSTOP_GRACE_MS = 15000;
106
107
  * that tier here, and getFastTierModel() picks the first `tier: 'fast'` model
107
108
  * for JSON extraction, so each tier must be LED by a model every plan can run.
108
109
  *
110
+ * Gemini 4 Neon (GA 2026-11-18) is the mid-tier Gemini 4 model, adapted from
111
+ * Carbon: "Carbon tackles your hardest, long-horizon projects and Hydrogen
112
+ * handles fast everyday execution, Neon balances depth and efficiency."
113
+ * Terminal-Bench 4.1 65.2 (Hydrogen 57.0, 3.8 Flash 18.2); default effort
114
+ * High, with XHigh available. It is an explicit choice, not the default or a
115
+ * tier leader: at $3/$15 per 1M tokens it costs four times 3.8 Flash and
116
+ * twice Hydrogen, has no API free tier, and is rolling out to paid Google AI
117
+ * Pro, Ultra, Gemini Enterprise, and `GEMINI_API_KEY` sign-ins only. agy
118
+ * resolves the bare `gemini-4-neon` slug to High, so that id is an alias of
119
+ * the High entry. Antigravity made Neon its own default for new conversations;
120
+ * pair-review keeps 3.8 Flash because every plan can run it.
121
+ *
109
122
  * Gemini 4 Hydrogen (GA 2026-11-12) is the everyday Gemini 4 model and 3.8
110
123
  * Flash's successor (Terminal-Bench 4.1 57.0 vs 18.2; xhigh is a new level).
111
124
  * It is an explicit choice, not the default: at $1.50/$7.50 per 1M tokens it
@@ -119,9 +132,14 @@ const TIMEOUT_BACKSTOP_GRACE_MS = 15000;
119
132
  * High, which is exactly what `gemini-4-argon-high` now runs.
120
133
  *
121
134
  * Gemini 4 Carbon (Ultra / Enterprise only) is not built in: agy offers it
122
- * only to Application Default Credentials sign-ins (`AGY_ADC_AUTH`), and a
123
- * Google-account sign-in reports it as "not recognized". Reach it via a
124
- * `providers.antigravity.models` config override with `cli_model`.
135
+ * only to Application Default Credentials (`AGY_ADC_AUTH`) and `GEMINI_API_KEY`
136
+ * sign-ins, and a Google-account sign-in reports it as "not recognized". Reach
137
+ * it via a `providers.antigravity.models` config override with `cli_model`.
138
+ *
139
+ * The Orchestrator entries (`gemini-pro-orchestrator-neon`, `-g1-pro` for
140
+ * Argon, and Carbon) are not built in either: each pairs a planner with
141
+ * Gemini 4 Hydrogen as the implementer at a fixed effort, a split built for
142
+ * editing code, not for a read-only review pass.
125
143
  *
126
144
  * Deprecated: gemini-3.1-pro-high, gemini-3.1-pro-low (alias gemini-3.1-pro) —
127
145
  * agy no longer offers 3.1 Pro outside Enterprise ("not recognized as a known
@@ -132,7 +150,7 @@ const TIMEOUT_BACKSTOP_GRACE_MS = 15000;
132
150
  * an unknown-model error. Retired 3.5 Flash ids are aliases of their 3.8 Flash
133
151
  * counterparts at the same effort, so saved selections keep working.
134
152
  *
135
- * `agy` also exposes Claude and GPT-OSS models; those remain reachable via a
153
+ * `agy` also exposes Claude (Opus 5.5, Sonnet 5.5) and GPT-OSS models; those remain reachable via a
136
154
  * `providers.antigravity.models` config override but are intentionally left
137
155
  * out of the default picker to keep the cross-provider model-mismatch guard
138
156
  * and the UX unambiguous.
@@ -151,6 +169,28 @@ const ANTIGRAVITY_MODELS = [
151
169
  badgeClass: 'badge-recommended',
152
170
  default: true
153
171
  },
172
+ {
173
+ id: 'gemini-4-neon-xhigh',
174
+ cliName: 'Gemini 4 Neon (XHigh)',
175
+ name: '4 Neon (XHigh)',
176
+ tier: 'thorough',
177
+ tagline: 'Deepest Review — Paid Plan',
178
+ description: 'Gemini 4 Neon (Nov 2026), Google\'s mid-tier model adapted from Gemini 4 Carbon, at extra-high effort — Terminal-Bench 4.1 65.2 vs Hydrogen\'s 57.0. $3/$15 per 1M tokens, four times 3.8 Flash; rolling out to paid Google AI Pro, Ultra, and Gemini Enterprise plans and paid API keys. Uses the thorough prompt set.',
179
+ badge: 'Newest',
180
+ badgeClass: 'badge-power'
181
+ },
182
+ {
183
+ id: 'gemini-4-neon-high',
184
+ cliName: 'Gemini 4 Neon (High)',
185
+ // agy resolves the bare `gemini-4-neon` slug to High.
186
+ aliases: ['gemini-4-neon'],
187
+ name: '4 Neon (High)',
188
+ tier: 'thorough',
189
+ tagline: 'Deep Review — Paid Plan',
190
+ description: 'Gemini 4 Neon at its default high effort, which balances depth and efficiency between Hydrogen and Carbon. $3/$15 per 1M tokens; rolling out to paid Google AI Pro, Ultra, and Gemini Enterprise plans and paid API keys. Uses the thorough prompt set.',
191
+ badge: 'Paid Plan',
192
+ badgeClass: 'badge-power'
193
+ },
154
194
  {
155
195
  id: 'gemini-4-hydrogen-xhigh',
156
196
  cliName: 'Gemini 4 Hydrogen (XHigh)',
@@ -158,7 +198,7 @@ const ANTIGRAVITY_MODELS = [
158
198
  tier: 'thorough',
159
199
  tagline: 'Deepest Everyday Review',
160
200
  description: 'Gemini 4 Hydrogen (Nov 2026), the 3.8 Flash successor, at its new extra-high effort — Terminal-Bench 4.1 57.0 vs 3.8 Flash\'s 18.2. $1.50/$7.50 per 1M tokens, twice 3.8 Flash; rolling out to paid Google AI Pro and Ultra plans first. Uses the thorough prompt set.',
161
- badge: 'Newest',
201
+ badge: 'XHigh Effort',
162
202
  badgeClass: 'badge-power'
163
203
  },
164
204
  {
@@ -204,6 +244,16 @@ const ANTIGRAVITY_MODELS = [
204
244
  badge: 'Medium Effort',
205
245
  badgeClass: 'badge-balanced'
206
246
  },
247
+ {
248
+ id: 'gemini-4-neon-medium',
249
+ cliName: 'Gemini 4 Neon (Medium)',
250
+ name: '4 Neon (Medium)',
251
+ tier: 'balanced',
252
+ tagline: 'Deeper Standard Review',
253
+ description: 'Gemini 4 Neon at medium effort — more depth than Hydrogen for routine PRs. $3/$15 per 1M tokens, four times 3.8 Flash; rolling out to paid Google AI Pro, Ultra, and Gemini Enterprise plans and paid API keys.',
254
+ badge: 'Paid Plan',
255
+ badgeClass: 'badge-balanced'
256
+ },
207
257
  {
208
258
  id: 'gemini-3.8-flash-low',
209
259
  cliName: 'Gemini 3.8 Flash (Low)',