@in-the-loop-labs/pair-review 4.1.1 → 5.0.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.
- 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 +668 -393
- 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/diff-renderer.js +16 -4
- 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 +1614 -158
- 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
|
@@ -198,7 +198,7 @@ async function executeStackAnalysis(params) {
|
|
|
198
198
|
const {
|
|
199
199
|
db, config, owner, repo, repository, triggerPRNumber,
|
|
200
200
|
worktreePath: triggerWorktreePath, prNumbers, analysisConfig,
|
|
201
|
-
stackAnalysisId, _deps
|
|
201
|
+
stackAnalysisId, cliOverrides, _deps
|
|
202
202
|
} = params;
|
|
203
203
|
|
|
204
204
|
const deps = { ...defaults, ..._deps };
|
|
@@ -340,7 +340,7 @@ async function executeStackAnalysis(params) {
|
|
|
340
340
|
worktreePath: worktreePathMap.get(prNum),
|
|
341
341
|
analysisConfig, stackAnalysisId, state,
|
|
342
342
|
githubToken, binding: stackBinding, prData: prDataMap.get(prNum),
|
|
343
|
-
worktreeConfig, checkoutScript,
|
|
343
|
+
worktreeConfig, checkoutScript, cliOverrides,
|
|
344
344
|
onAnalysisIdReady
|
|
345
345
|
}).then(result => {
|
|
346
346
|
state.prStatuses.set(prNum, {
|
|
@@ -376,26 +376,28 @@ async function executeStackAnalysis(params) {
|
|
|
376
376
|
/**
|
|
377
377
|
* Resolve the provider/model pair for a single/executable stack analysis.
|
|
378
378
|
*
|
|
379
|
-
* Precedence (highest first): request body >
|
|
380
|
-
* (
|
|
379
|
+
* Precedence (highest first): request body > CLI override
|
|
380
|
+
* (`--provider`/`--model`, threaded via `cliOverrides`) > saved repo settings >
|
|
381
381
|
* config default > legacy config key > hard default ('claude' / 'opus').
|
|
382
382
|
*
|
|
383
|
-
*
|
|
384
|
-
* `
|
|
385
|
-
*
|
|
386
|
-
*
|
|
383
|
+
* The CLI override is threaded explicitly from the request handler
|
|
384
|
+
* (`app.get('cliOverrides')`) — there is no env-var side channel. Both fields
|
|
385
|
+
* fall through independently so a provider-only override does not force a
|
|
386
|
+
* default Claude model onto it.
|
|
387
387
|
*
|
|
388
388
|
* @param {Object} [args]
|
|
389
389
|
* @param {string} [args.reqProvider] - provider from the analysis request body
|
|
390
390
|
* @param {string} [args.reqModel] - model from the analysis request body
|
|
391
391
|
* @param {Object} [args.repoSettings] - saved repo settings row (may be null)
|
|
392
392
|
* @param {Object} [args.config] - loaded app config
|
|
393
|
+
* @param {{ provider?: string, model?: string }} [args.cliOverrides] - per-run CLI flags
|
|
393
394
|
* @returns {{ provider: string, model: string }}
|
|
394
395
|
*/
|
|
395
|
-
function _resolveStackProviderModel({ reqProvider, reqModel, repoSettings, config } = {}) {
|
|
396
|
+
function _resolveStackProviderModel({ reqProvider, reqModel, repoSettings, config, cliOverrides } = {}) {
|
|
396
397
|
const cfg = config || {};
|
|
397
|
-
const
|
|
398
|
-
const
|
|
398
|
+
const overrides = cliOverrides || {};
|
|
399
|
+
const provider = reqProvider || overrides.provider || repoSettings?.default_provider || cfg.default_provider || cfg.provider || 'claude';
|
|
400
|
+
const model = reqModel || overrides.model || repoSettings?.default_model || cfg.default_model || cfg.model || 'opus';
|
|
399
401
|
return { provider, model };
|
|
400
402
|
}
|
|
401
403
|
|
|
@@ -406,7 +408,7 @@ function _resolveStackProviderModel({ reqProvider, reqModel, repoSettings, confi
|
|
|
406
408
|
async function analyzeStackPR(deps, db, config, {
|
|
407
409
|
owner, repo, repository, bindingRepository, prNum, worktreePath,
|
|
408
410
|
analysisConfig, stackAnalysisId, state, githubToken, binding, prData,
|
|
409
|
-
worktreeConfig, checkoutScript,
|
|
411
|
+
worktreeConfig, checkoutScript, cliOverrides,
|
|
410
412
|
onAnalysisIdReady
|
|
411
413
|
}) {
|
|
412
414
|
// Build a GitHubClient for analyzer-side dedup pre-fetch. The stack
|
|
@@ -472,7 +474,7 @@ async function analyzeStackPR(deps, db, config, {
|
|
|
472
474
|
});
|
|
473
475
|
} else {
|
|
474
476
|
const { provider: selectedProvider, model: selectedModel } = _resolveStackProviderModel({
|
|
475
|
-
reqProvider, reqModel, repoSettings, config
|
|
477
|
+
reqProvider, reqModel, repoSettings, config, cliOverrides
|
|
476
478
|
});
|
|
477
479
|
|
|
478
480
|
// Resolve load_skills across all config tiers
|
|
@@ -867,6 +869,7 @@ router.post('/api/pr/:owner/:repo/:number/analyses/stack', async (req, res) => {
|
|
|
867
869
|
const repository = normalizeRepository(owner, repo);
|
|
868
870
|
const db = req.app.get('db');
|
|
869
871
|
const config = req.app.get('config') || {};
|
|
872
|
+
const cliOverrides = req.app.get('cliOverrides') || {};
|
|
870
873
|
|
|
871
874
|
// Find worktree path from the triggering PR
|
|
872
875
|
const worktreeManager = new GitWorktreeManager(db);
|
|
@@ -901,7 +904,7 @@ router.post('/api/pr/:owner/:repo/:number/analyses/stack', async (req, res) => {
|
|
|
901
904
|
executeStackAnalysis({
|
|
902
905
|
db, config, owner, repo, repository,
|
|
903
906
|
triggerPRNumber: prNumber,
|
|
904
|
-
worktreePath, prNumbers, analysisConfig, stackAnalysisId
|
|
907
|
+
worktreePath, prNumbers, analysisConfig, stackAnalysisId, cliOverrides
|
|
905
908
|
}).catch(error => {
|
|
906
909
|
logger.error(`Stack analysis ${stackAnalysisId} uncaught error: ${error.message}`);
|
|
907
910
|
});
|
package/src/server.js
CHANGED
|
@@ -4,16 +4,37 @@ const path = require('path');
|
|
|
4
4
|
const { loadConfig, getGitHubToken, resolveDbName, warnIfDevModeWithoutDbName, getRepoConfig, resolveBindingRepositoryFromPR, isExclusiveAltHost } = require('./config');
|
|
5
5
|
const { initializeDatabase, getDatabaseStatus, queryOne, run, PRMetadataRepository } = require('./database');
|
|
6
6
|
const { normalizeRepository } = require('./utils/paths');
|
|
7
|
+
const { GlobalSettingsService } = require('./settings/global-settings-service');
|
|
7
8
|
const { applyConfigOverrides, checkAllProviders } = require('./ai');
|
|
8
9
|
const { checkAllChatProviders } = require('./chat/chat-providers');
|
|
9
10
|
const logger = require('./utils/logger');
|
|
10
11
|
const { attachWebSocket, closeAll: closeAllWS } = require('./ws');
|
|
11
12
|
const { WorktreePoolLifecycle } = require('./git/worktree-pool-lifecycle');
|
|
13
|
+
const { resolveDbPath, computeDbId } = require('./utils/db-identity');
|
|
12
14
|
|
|
13
15
|
let db = null;
|
|
14
16
|
let server = null;
|
|
15
17
|
let chatSessionManager = null;
|
|
16
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Assemble the GET /health response body. Kept as a standalone factory so the
|
|
21
|
+
* exact payload the delegation handshake depends on can be unit-tested without
|
|
22
|
+
* booting the whole server. `dbId` is computed once at startup and threaded in
|
|
23
|
+
* (the resolved DB path cannot change without a restart).
|
|
24
|
+
*
|
|
25
|
+
* @param {string} dbId - computeDbId(resolveDbPath(config)) digest
|
|
26
|
+
* @returns {{status: string, service: string, version: string, dbId: string, timestamp: string}}
|
|
27
|
+
*/
|
|
28
|
+
function buildHealthPayload(dbId) {
|
|
29
|
+
return {
|
|
30
|
+
status: 'ok',
|
|
31
|
+
service: 'pair-review',
|
|
32
|
+
version: require('../package.json').version,
|
|
33
|
+
dbId,
|
|
34
|
+
timestamp: new Date().toISOString()
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
17
38
|
/**
|
|
18
39
|
* Apply env var overrides to config after loadConfig().
|
|
19
40
|
* Currently handles PAIR_REVIEW_SINGLE_PORT — a bridge for callers that
|
|
@@ -164,19 +185,20 @@ function findAvailablePort(app, startPort, maxAttempts = 20) {
|
|
|
164
185
|
* Start the Express server
|
|
165
186
|
* @param {sqlite3.Database} [sharedDb] - Optional shared database instance
|
|
166
187
|
* @param {import('./git/worktree-pool-lifecycle').WorktreePoolLifecycle} [sharedPoolLifecycle] - Optional shared pool lifecycle instance
|
|
188
|
+
* @param {Object} [options] - Startup options
|
|
189
|
+
* @param {{ provider?: string, model?: string }} [options.cliOverrides] - Per-run
|
|
190
|
+
* provider/model overrides from the `--provider`/`--model` CLI flags. Threaded
|
|
191
|
+
* in explicitly (there is no env-var side channel) and exposed via
|
|
192
|
+
* `app.get('cliOverrides')` so the web analyze routes can rank them above repo
|
|
193
|
+
* settings without a process-global. Empty object when no flags were given.
|
|
167
194
|
*/
|
|
168
|
-
async function startServer(sharedDb = null, sharedPoolLifecycle = null) {
|
|
195
|
+
async function startServer(sharedDb = null, sharedPoolLifecycle = null, options = {}) {
|
|
196
|
+
const cliOverrides = options.cliOverrides || {};
|
|
169
197
|
try {
|
|
170
198
|
// Load configuration
|
|
171
|
-
const { config } = await loadConfig();
|
|
199
|
+
const { config, layers } = await loadConfig();
|
|
172
200
|
applyEnvOverrides(config);
|
|
173
201
|
|
|
174
|
-
// Apply provider configuration overrides (custom models, commands, etc.)
|
|
175
|
-
applyConfigOverrides(config);
|
|
176
|
-
|
|
177
|
-
// Warn if dev mode is on without a custom database name
|
|
178
|
-
warnIfDevModeWithoutDbName(config);
|
|
179
|
-
|
|
180
202
|
// Get GitHub token (env var takes precedence over config)
|
|
181
203
|
const githubToken = getGitHubToken(config);
|
|
182
204
|
|
|
@@ -184,8 +206,9 @@ async function startServer(sharedDb = null, sharedPoolLifecycle = null) {
|
|
|
184
206
|
if (!githubToken) {
|
|
185
207
|
console.warn('Warning: No GitHub token configured. Set GITHUB_TOKEN environment variable or add github_token to ~/.pair-review/config.json');
|
|
186
208
|
}
|
|
187
|
-
|
|
188
|
-
// Use shared database or initialize new one
|
|
209
|
+
|
|
210
|
+
// Use shared database or initialize new one. The DB must be open before the
|
|
211
|
+
// global-settings overlay below, which reads the in-app overrides table.
|
|
189
212
|
if (sharedDb) {
|
|
190
213
|
console.log('Using shared database instance...');
|
|
191
214
|
db = sharedDb;
|
|
@@ -193,7 +216,32 @@ async function startServer(sharedDb = null, sharedPoolLifecycle = null) {
|
|
|
193
216
|
console.log('Connecting to database...');
|
|
194
217
|
db = await initializeDatabase(resolveDbName(config));
|
|
195
218
|
}
|
|
196
|
-
|
|
219
|
+
|
|
220
|
+
// Build the global-settings service and overlay in-app DB overrides onto the
|
|
221
|
+
// loaded file config. This MUST run BEFORE any consumer that latches a config
|
|
222
|
+
// value, or an in-app override never takes effect even after a restart
|
|
223
|
+
// (contradicting the restartRequired badge): applyConfigOverrides() below
|
|
224
|
+
// snapshots config.yolo into the provider-runtime `yoloMode`,
|
|
225
|
+
// warnIfDevModeWithoutDbName() reads dev_mode, and the `devMode` const further
|
|
226
|
+
// down is captured by the static-file setHeaders closure.
|
|
227
|
+
//
|
|
228
|
+
// `baseConfig` is captured pre-overlay (the service clones it) so future
|
|
229
|
+
// PUT/DELETE recompute from the file layers, not from an already-overlaid
|
|
230
|
+
// object. We mutate `config` in place with Object.assign so downstream
|
|
231
|
+
// closures (pool lifecycle, chat manager, /pr host correction) share the same
|
|
232
|
+
// effective object every per-request `req.app.get('config')` reader sees.
|
|
233
|
+
// Write endpoints later replace app.get('config') with a fresh effective
|
|
234
|
+
// object; only editable settings change, so the closures (which read only
|
|
235
|
+
// read-only settings) stay correct.
|
|
236
|
+
const globalSettings = new GlobalSettingsService({ db, baseConfig: config, layers });
|
|
237
|
+
Object.assign(config, globalSettings.buildEffectiveConfig());
|
|
238
|
+
|
|
239
|
+
// Apply provider configuration overrides (custom models, commands, etc.)
|
|
240
|
+
applyConfigOverrides(config);
|
|
241
|
+
|
|
242
|
+
// Warn if dev mode is on without a custom database name
|
|
243
|
+
warnIfDevModeWithoutDbName(config);
|
|
244
|
+
|
|
197
245
|
// Log database status
|
|
198
246
|
try {
|
|
199
247
|
const dbStatus = await getDatabaseStatus(db);
|
|
@@ -361,6 +409,13 @@ async function startServer(sharedDb = null, sharedPoolLifecycle = null) {
|
|
|
361
409
|
}
|
|
362
410
|
});
|
|
363
411
|
|
|
412
|
+
// Global settings route - serves settings.html. MUST be registered before
|
|
413
|
+
// the two-segment `/settings/:owner/:repo` repo-settings route so the bare
|
|
414
|
+
// `/settings` path is not swallowed by param matching.
|
|
415
|
+
app.get('/settings', (req, res) => {
|
|
416
|
+
res.sendFile(path.join(__dirname, '..', 'public', 'settings.html'));
|
|
417
|
+
});
|
|
418
|
+
|
|
364
419
|
// Repository settings route - serves repo-settings.html
|
|
365
420
|
app.get('/settings/:owner/:repo', (req, res) => {
|
|
366
421
|
res.sendFile(path.join(__dirname, '..', 'public', 'repo-settings.html'));
|
|
@@ -379,20 +434,29 @@ async function startServer(sharedDb = null, sharedPoolLifecycle = null) {
|
|
|
379
434
|
res.sendFile(path.join(__dirname, '..', 'public', 'local.html'));
|
|
380
435
|
});
|
|
381
436
|
|
|
437
|
+
// Database identity digest for the headless delegation handshake. Computed
|
|
438
|
+
// once at startup (the resolved DB path cannot change without a restart) so
|
|
439
|
+
// the /health route stays allocation-free per request. The delegating CLI
|
|
440
|
+
// compares this against its own computeDbId(resolveDbPath(config)) and only
|
|
441
|
+
// delegates when they match — see src/utils/db-identity.js.
|
|
442
|
+
const dbId = computeDbId(resolveDbPath(config));
|
|
443
|
+
|
|
382
444
|
// Health check endpoint (also used by single-port detection)
|
|
383
445
|
app.get('/health', (req, res) => {
|
|
384
|
-
res.json(
|
|
385
|
-
status: 'ok',
|
|
386
|
-
service: 'pair-review',
|
|
387
|
-
version: require('../package.json').version,
|
|
388
|
-
timestamp: new Date().toISOString()
|
|
389
|
-
});
|
|
446
|
+
res.json(buildHealthPayload(dbId));
|
|
390
447
|
});
|
|
391
448
|
|
|
392
449
|
// Store database instance, GitHub token, and config for routes
|
|
450
|
+
// (`globalSettings` was built and overlaid onto `config` above, right after
|
|
451
|
+
// DB init, so latching consumers see the effective values.)
|
|
393
452
|
app.set('db', db);
|
|
394
453
|
app.set('githubToken', githubToken);
|
|
395
454
|
app.set('config', config);
|
|
455
|
+
app.set('globalSettings', globalSettings);
|
|
456
|
+
// Per-run --provider/--model overrides, threaded explicitly from the CLI
|
|
457
|
+
// entry points (main.js / local-review.js). Read per request by the analyze
|
|
458
|
+
// routes; ranks above repo settings but below an explicit request body.
|
|
459
|
+
app.set('cliOverrides', cliOverrides);
|
|
396
460
|
|
|
397
461
|
// Create or reuse the worktree pool lifecycle instance.
|
|
398
462
|
// When called from main.js, the shared instance (already rehydrated) is
|
|
@@ -422,6 +486,8 @@ async function startServer(sharedDb = null, sharedPoolLifecycle = null) {
|
|
|
422
486
|
const bulkAnalysisConfigsRoutes = require('./routes/bulk-analysis-configs');
|
|
423
487
|
const stackAnalysisRoutes = require('./routes/stack-analysis');
|
|
424
488
|
const externalCommentsRoutes = require('./routes/external-comments');
|
|
489
|
+
const settingsRoutes = require('./routes/settings');
|
|
490
|
+
const snippetsRoutes = require('./routes/snippets');
|
|
425
491
|
const { createSoundRouter } = require('./routes/sound');
|
|
426
492
|
|
|
427
493
|
// Initialize chat session manager
|
|
@@ -443,6 +509,8 @@ async function startServer(sharedDb = null, sharedPoolLifecycle = null) {
|
|
|
443
509
|
app.use('/', githubCollectionsRoutes);
|
|
444
510
|
app.use('/', bulkAnalysisConfigsRoutes);
|
|
445
511
|
app.use('/', stackAnalysisRoutes);
|
|
512
|
+
app.use('/', settingsRoutes);
|
|
513
|
+
app.use('/', snippetsRoutes);
|
|
446
514
|
// External-comments routes (GitHub PR review-comment sync + fetch) are
|
|
447
515
|
// gated by the `external_comments` config flag. When disabled, the
|
|
448
516
|
// router is not mounted so any GET/POST against `/api/reviews/*/
|
|
@@ -592,4 +660,4 @@ if (require.main === module) {
|
|
|
592
660
|
startServer();
|
|
593
661
|
}
|
|
594
662
|
|
|
595
|
-
module.exports = { startServer, applyEnvOverrides, applyHostQueryCorrection };
|
|
663
|
+
module.exports = { startServer, applyEnvOverrides, applyHostQueryCorrection, buildHealthPayload };
|