@in-the-loop-labs/pair-review 5.2.3 → 5.3.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 +11 -3
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin-code-critic/.claude-plugin/plugin.json +1 -1
- package/plugin-code-critic/skills/analyze/references/level1-thorough.md +52 -121
- package/plugin-code-critic/skills/analyze/references/level2-thorough.md +49 -113
- package/plugin-code-critic/skills/analyze/references/level3-thorough.md +46 -195
- package/plugin-code-critic/skills/analyze/references/orchestration-thorough.md +56 -112
- package/plugin-pair-loop/.claude-plugin/plugin.json +1 -1
- package/public/css/analysis-config.css +29 -0
- package/public/css/pr.css +208 -0
- package/public/js/components/AIPanel.js +14 -9
- package/public/js/components/ChatPanel.js +790 -54
- package/public/js/components/ConfirmDialog.js +70 -2
- package/public/js/modules/pierre-bridge.js +58 -97
- package/public/js/modules/suggestion-manager.js +9 -121
- package/public/js/pr.js +15 -28
- package/public/js/utils/scroll-into-view.js +18 -4
- package/src/ai/analyzer.js +30 -5
- package/src/ai/antigravity-provider.js +7 -6
- package/src/ai/claude-provider.js +4 -8
- package/src/ai/codex-provider.js +3 -4
- package/src/ai/index.js +2 -0
- package/src/ai/muse-provider.js +3 -4
- package/src/ai/omp-provider.js +27 -12
- package/src/ai/pi-provider.js +12 -6
- package/src/ai/prompts/baseline/consolidation/thorough.js +56 -43
- package/src/ai/prompts/baseline/level1/thorough.js +76 -138
- package/src/ai/prompts/baseline/level2/thorough.js +76 -129
- package/src/ai/prompts/baseline/level3/thorough.js +67 -212
- package/src/ai/prompts/baseline/orchestration/thorough.js +79 -130
- package/src/ai/prompts/render-for-skill.js +5 -0
- package/src/ai/prompts/shared/adversarial-verification.js +68 -0
- package/src/ai/provider.js +60 -1
- package/src/ai/stream-parser.js +22 -1
- package/src/chat/acp-bridge.js +11 -0
- package/src/chat/chat-models.js +348 -0
- package/src/chat/chat-providers.js +17 -0
- package/src/chat/claude-code-bridge.js +9 -0
- package/src/chat/codex-bridge.js +6 -1
- package/src/chat/omp-bridge.js +5 -0
- package/src/chat/pi-bridge.js +20 -5
- package/src/chat/session-manager.js +158 -63
- package/src/config.js +92 -5
- package/src/git/worktree.js +29 -10
- package/src/github/client.js +30 -10
- package/src/hooks/payloads.js +5 -1
- package/src/routes/chat.js +83 -11
- package/src/setup/pr-setup.js +54 -1
package/src/hooks/payloads.js
CHANGED
|
@@ -87,7 +87,7 @@ function buildAnalysisCompletedPayload({
|
|
|
87
87
|
|
|
88
88
|
// ── Chat payloads ───────────────────────────────────────────────
|
|
89
89
|
|
|
90
|
-
function buildChatPayload(event, { reviewId, sessionId, provider, model, mode, prContext, localContext, user }) {
|
|
90
|
+
function buildChatPayload(event, { reviewId, sessionId, provider, model, cliModel, mode, prContext, localContext, user }) {
|
|
91
91
|
return {
|
|
92
92
|
event,
|
|
93
93
|
timestamp: new Date().toISOString(),
|
|
@@ -95,7 +95,11 @@ function buildChatPayload(event, { reviewId, sessionId, provider, model, mode, p
|
|
|
95
95
|
reviewId,
|
|
96
96
|
sessionId,
|
|
97
97
|
provider: provider ?? null,
|
|
98
|
+
// `model` is the selector stored on the session (a canonical catalog id, or a raw
|
|
99
|
+
// CLI string from chat_providers.<id>.model). `cli_model` is what was actually
|
|
100
|
+
// handed to the CLI; null means the provider's own default was used.
|
|
98
101
|
model: model ?? null,
|
|
102
|
+
cli_model: cliModel ?? null,
|
|
99
103
|
...buildContextFields({ mode, prContext, localContext, user }),
|
|
100
104
|
};
|
|
101
105
|
}
|
package/src/routes/chat.js
CHANGED
|
@@ -21,6 +21,8 @@ const ws = require('../ws');
|
|
|
21
21
|
const { fireHooks, hasHooks } = require('../hooks/hook-runner');
|
|
22
22
|
const { buildChatStartedPayload, buildChatResumedPayload, buildChatHookContext, getCachedUser } = require('../hooks/payloads');
|
|
23
23
|
const { resolveFormat } = require('../utils/comment-formatter');
|
|
24
|
+
const { getAllChatProviders, getAllCachedChatAvailability } = require('../chat/chat-providers');
|
|
25
|
+
const { getChatModelCatalog, canonicalChatModel } = require('../chat/chat-models');
|
|
24
26
|
const { resolveLoadSkills } = require('../config');
|
|
25
27
|
|
|
26
28
|
/**
|
|
@@ -31,16 +33,17 @@ const { resolveLoadSkills } = require('../config');
|
|
|
31
33
|
* @param {Object} opts.review - Review record
|
|
32
34
|
* @param {number} opts.sessionId - Chat session ID
|
|
33
35
|
* @param {string} opts.provider - AI provider
|
|
34
|
-
* @param {string} opts.model -
|
|
36
|
+
* @param {string} opts.model - Model selector stored on the session
|
|
37
|
+
* @param {string|null} [opts.cliModel] - Model string actually passed to the CLI
|
|
35
38
|
*/
|
|
36
|
-
function fireChatHook(event, { req, review, sessionId, provider, model }) {
|
|
39
|
+
function fireChatHook(event, { req, review, sessionId, provider, model, cliModel }) {
|
|
37
40
|
const config = req.app.get('config') || {};
|
|
38
41
|
if (!hasHooks(event, config)) return;
|
|
39
42
|
|
|
40
43
|
const buildPayload = event === 'chat.started' ? buildChatStartedPayload : buildChatResumedPayload;
|
|
41
44
|
getCachedUser(config).then(user => {
|
|
42
45
|
const payload = buildPayload({
|
|
43
|
-
reviewId: review.id, sessionId, provider, model,
|
|
46
|
+
reviewId: review.id, sessionId, provider, model, cliModel,
|
|
44
47
|
...buildChatHookContext(review), user,
|
|
45
48
|
});
|
|
46
49
|
fireHooks(event, payload, config);
|
|
@@ -243,6 +246,38 @@ async function getRepoLoadSkillsForChat(db, review, config, provider) {
|
|
|
243
246
|
return resolveLoadSkills(config, review.repository, repoSettings, providerLoadSkills);
|
|
244
247
|
}
|
|
245
248
|
|
|
249
|
+
/**
|
|
250
|
+
* List chat providers with their model catalogs.
|
|
251
|
+
*
|
|
252
|
+
* Kept separate from GET /api/config (which is fetched inline in the page head and
|
|
253
|
+
* should stay light). The response is picker-facing only: catalog entries are built by
|
|
254
|
+
* getChatModelCatalog, which whitelists display fields, so cli_model / env / extra_args
|
|
255
|
+
* never reach the browser.
|
|
256
|
+
*/
|
|
257
|
+
router.get('/api/chat/providers', (req, res) => {
|
|
258
|
+
try {
|
|
259
|
+
const availability = getAllCachedChatAvailability();
|
|
260
|
+
const providers = getAllChatProviders().map((def) => {
|
|
261
|
+
const { models, configuredModel, hasCatalog } = getChatModelCatalog(def.id, def);
|
|
262
|
+
return {
|
|
263
|
+
id: def.id,
|
|
264
|
+
name: def.name,
|
|
265
|
+
type: def.type,
|
|
266
|
+
available: availability[def.id]?.available || false,
|
|
267
|
+
models,
|
|
268
|
+
configuredModel,
|
|
269
|
+
// Defined at the source as "there is something to pick from" (models.length > 0),
|
|
270
|
+
// so a provider that maps to a review provider with an empty list reports false.
|
|
271
|
+
hasCatalog,
|
|
272
|
+
};
|
|
273
|
+
});
|
|
274
|
+
res.json({ data: { providers } });
|
|
275
|
+
} catch (error) {
|
|
276
|
+
logger.error(`Error listing chat providers: ${error.message}`);
|
|
277
|
+
res.status(500).json({ error: 'Failed to list chat providers' });
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
|
|
246
281
|
/**
|
|
247
282
|
* Create a new chat session
|
|
248
283
|
*/
|
|
@@ -258,6 +293,15 @@ router.post('/api/chat/session', async (req, res) => {
|
|
|
258
293
|
});
|
|
259
294
|
}
|
|
260
295
|
|
|
296
|
+
// `model` is optional. Absent/null both mean "provider default"; anything else must
|
|
297
|
+
// be a string. Unknown ids are allowed on purpose — chat_providers.<id>.model has
|
|
298
|
+
// always accepted raw CLI strings, and the resolver passes them through.
|
|
299
|
+
if (model !== undefined && model !== null && typeof model !== 'string') {
|
|
300
|
+
return res.status(400).json({
|
|
301
|
+
error: 'Invalid model: must be a string or null'
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
|
|
261
305
|
const chatSessionManager = req.app.chatSessionManager;
|
|
262
306
|
const db = req.app.get('db');
|
|
263
307
|
|
|
@@ -353,9 +397,19 @@ router.post('/api/chat/session', async (req, res) => {
|
|
|
353
397
|
// Register broadcast listeners so events reach all connected clients
|
|
354
398
|
registerChatBroadcast(chatSessionManager, session.id, serverPort);
|
|
355
399
|
|
|
356
|
-
fireChatHook('chat.started', {
|
|
400
|
+
fireChatHook('chat.started', {
|
|
401
|
+
req, review, sessionId: session.id, provider,
|
|
402
|
+
// The manager resolved the effective selector (request model > provider config
|
|
403
|
+
// default); fall back to the request value if a caller returns the legacy shape.
|
|
404
|
+
model: session.model !== undefined ? session.model : (model ?? null),
|
|
405
|
+
cliModel: session.cliModel ?? null,
|
|
406
|
+
});
|
|
357
407
|
|
|
358
|
-
|
|
408
|
+
// `model` is the canonicalised selector the session actually runs (an alias resolves
|
|
409
|
+
// to its catalog id, and a "Provider default" pick that config pinned to a concrete
|
|
410
|
+
// model comes back as that model). The client adopts it so its tab state matches the
|
|
411
|
+
// DB without waiting for a reload. Contract: string | null (null = provider default).
|
|
412
|
+
const responseData = { id: session.id, status: session.status, model: session.model ?? null };
|
|
359
413
|
|
|
360
414
|
// Include analysis context metadata so the frontend can show a context indicator
|
|
361
415
|
if (initialContext && suggestions && suggestions.length > 0) {
|
|
@@ -423,12 +477,16 @@ router.post('/api/chat/session/:id/message', async (req, res) => {
|
|
|
423
477
|
const loadSkills = await getRepoLoadSkillsForChat(db, review, config, session.provider);
|
|
424
478
|
|
|
425
479
|
try {
|
|
426
|
-
await chatSessionManager.resumeSession(sessionId, { systemPrompt, cwd, loadSkills });
|
|
480
|
+
const resumed = await chatSessionManager.resumeSession(sessionId, { systemPrompt, cwd, loadSkills });
|
|
427
481
|
unregisterChatBroadcast(sessionId);
|
|
428
482
|
registerChatBroadcast(chatSessionManager, sessionId, req.socket.localPort);
|
|
429
483
|
logger.info(`[ChatRoute] Auto-resumed session ${sessionId} for message delivery`);
|
|
430
484
|
|
|
431
|
-
fireChatHook('chat.resumed', {
|
|
485
|
+
fireChatHook('chat.resumed', {
|
|
486
|
+
req, review, sessionId, provider: session.provider,
|
|
487
|
+
model: resumed?.model !== undefined ? resumed.model : session.model,
|
|
488
|
+
cliModel: resumed?.cliModel ?? null,
|
|
489
|
+
});
|
|
432
490
|
|
|
433
491
|
// Inject port correction so the agent knows the current server address,
|
|
434
492
|
// even if the conversational history has a stale port from session creation.
|
|
@@ -535,7 +593,14 @@ router.post('/api/chat/session/:id/resume', async (req, res) => {
|
|
|
535
593
|
|
|
536
594
|
// Already active
|
|
537
595
|
if (chatSessionManager.isSessionActive(sessionId)) {
|
|
538
|
-
|
|
596
|
+
const active = chatSessionManager.getSession(sessionId);
|
|
597
|
+
return res.json({
|
|
598
|
+
data: {
|
|
599
|
+
id: sessionId,
|
|
600
|
+
status: 'active',
|
|
601
|
+
model: active ? canonicalChatModel(active.provider, active.model) : null,
|
|
602
|
+
},
|
|
603
|
+
});
|
|
539
604
|
}
|
|
540
605
|
|
|
541
606
|
const session = chatSessionManager.getSession(sessionId);
|
|
@@ -565,7 +630,7 @@ router.post('/api/chat/session/:id/resume', async (req, res) => {
|
|
|
565
630
|
const cwd = await resolveReviewCwd(db, review);
|
|
566
631
|
const loadSkills = await getRepoLoadSkillsForChat(db, review, config, session.provider);
|
|
567
632
|
|
|
568
|
-
await chatSessionManager.resumeSession(sessionId, { systemPrompt, cwd, loadSkills });
|
|
633
|
+
const resumed = await chatSessionManager.resumeSession(sessionId, { systemPrompt, cwd, loadSkills });
|
|
569
634
|
unregisterChatBroadcast(sessionId);
|
|
570
635
|
const serverPort = req.socket.localPort;
|
|
571
636
|
registerChatBroadcast(chatSessionManager, sessionId, serverPort);
|
|
@@ -580,9 +645,13 @@ router.post('/api/chat/session/:id/resume', async (req, res) => {
|
|
|
580
645
|
|
|
581
646
|
logger.info(`[ChatRoute] Explicitly resumed session ${sessionId}`);
|
|
582
647
|
|
|
583
|
-
fireChatHook('chat.resumed', {
|
|
648
|
+
fireChatHook('chat.resumed', {
|
|
649
|
+
req, review, sessionId, provider: session.provider,
|
|
650
|
+
model: resumed?.model !== undefined ? resumed.model : session.model,
|
|
651
|
+
cliModel: resumed?.cliModel ?? null,
|
|
652
|
+
});
|
|
584
653
|
|
|
585
|
-
res.json({ data: { id: sessionId, status: 'active' } });
|
|
654
|
+
res.json({ data: { id: sessionId, status: 'active', model: resumed?.model ?? null } });
|
|
586
655
|
} catch (error) {
|
|
587
656
|
logger.error(`Error resuming chat session: ${error.message}`);
|
|
588
657
|
res.status(500).json({ error: 'Failed to resume session: ' + error.message });
|
|
@@ -620,8 +689,11 @@ router.get('/api/review/:reviewId/chat/sessions', (req, res) => {
|
|
|
620
689
|
const sessions = chatSessionManager.getSessionsWithMessageCount(parseInt(reviewId, 10));
|
|
621
690
|
|
|
622
691
|
// Annotate each session with live state
|
|
692
|
+
// `model` is canonicalised on read (rows are never rewritten): a session stored
|
|
693
|
+
// under an alias by an older build must report the id the picker renders.
|
|
623
694
|
const annotated = sessions.map((s) => ({
|
|
624
695
|
...s,
|
|
696
|
+
model: canonicalChatModel(s.provider, s.model),
|
|
625
697
|
isActive: chatSessionManager.isSessionActive(s.id),
|
|
626
698
|
isResumable: !chatSessionManager.isSessionActive(s.id) && !!s.agent_session_id
|
|
627
699
|
}));
|
package/src/setup/pr-setup.js
CHANGED
|
@@ -17,7 +17,7 @@ const { WorktreePoolLifecycle } = require('../git/worktree-pool-lifecycle');
|
|
|
17
17
|
const { GitHubClient } = require('../github/client');
|
|
18
18
|
const { normalizeRepository } = require('../utils/paths');
|
|
19
19
|
const { findMainGitRoot } = require('../local-review');
|
|
20
|
-
const { getConfigDir, getRepoPath, resolveRepoOptions, resolvePoolConfig, getRepoResetScript, resolveHostBinding, resolveBindingRepositoryFromPR, getRepoConfig, DEFAULT_CHECKOUT_TIMEOUT_MS } = require('../config');
|
|
20
|
+
const { getConfigDir, getRepoPath, resolveRepoOptions, resolvePoolConfig, getRepoResetScript, resolveHostBinding, resolveBindingRepositoryFromPR, getRepoConfig, getRepoCloneUrlForHost, DEFAULT_CHECKOUT_TIMEOUT_MS } = require('../config');
|
|
21
21
|
const { storedHostToOption, isDualHostRepoConfig, resolveRecordedHost, bindingRepositoryForHost } = require('../utils/host-resolution');
|
|
22
22
|
const logger = require('../utils/logger');
|
|
23
23
|
const { fireReviewStartedHook } = require('../hooks/payloads');
|
|
@@ -373,6 +373,37 @@ async function resolvePrHostBinding({ db, config, bindingRepository, owner, repo
|
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
375
|
|
|
376
|
+
/**
|
|
377
|
+
* Resolve which host a RESTORED PR lives on, without contacting any API.
|
|
378
|
+
*
|
|
379
|
+
* Restore mode replays a stored snapshot, so `resolvePrHostBinding` (which
|
|
380
|
+
* fetches) never runs. This applies the same host precedence minus the probe:
|
|
381
|
+
*
|
|
382
|
+
* 1. the explicit `host` parameter when defined (URL paste / dashboard row);
|
|
383
|
+
* 2. otherwise the stored `pr_metadata` row, read through the SAME
|
|
384
|
+
* `getPRHostWithRecordedUrl` + `resolveRecordedHost` pair that
|
|
385
|
+
* `resolvePrHostBinding` uses, so a pre-stamping NULL row is interpreted
|
|
386
|
+
* identically;
|
|
387
|
+
* 3. otherwise `undefined` — host unknown, leaving the caller's ambiguity
|
|
388
|
+
* rule to decide.
|
|
389
|
+
*
|
|
390
|
+
* @param {Object} params
|
|
391
|
+
* @param {Object} params.db
|
|
392
|
+
* @param {Object} params.config
|
|
393
|
+
* @param {string} params.bindingRepository - `repos[...]` config-lookup key
|
|
394
|
+
* @param {string} params.repository - normalized "owner/repo"
|
|
395
|
+
* @param {number} params.prNumber
|
|
396
|
+
* @param {string|null|undefined} params.host - explicit host override
|
|
397
|
+
* @returns {Promise<string|null|undefined>} The host, or `undefined` if unknown
|
|
398
|
+
*/
|
|
399
|
+
async function resolveRestoreHost({ db, config, bindingRepository, repository, prNumber, host }) {
|
|
400
|
+
if (host !== undefined) return host;
|
|
401
|
+
if (!db) return undefined;
|
|
402
|
+
const recorded = await new PRMetadataRepository(db).getPRHostWithRecordedUrl(repository, prNumber);
|
|
403
|
+
if (recorded === undefined) return undefined;
|
|
404
|
+
return resolveRecordedHost(config, bindingRepository, recorded.host, recorded.recordedUrl);
|
|
405
|
+
}
|
|
406
|
+
|
|
376
407
|
/**
|
|
377
408
|
* Register the known location of a GitHub repository in the database.
|
|
378
409
|
* This allows the web UI to find the repo without cloning when reviewing PRs.
|
|
@@ -646,6 +677,28 @@ async function setupPRReview({ db, owner, repo, prNumber, githubToken, bindingRe
|
|
|
646
677
|
|
|
647
678
|
if (isRestore) {
|
|
648
679
|
prData = restoreMetadata;
|
|
680
|
+
// Restore mode replays a stored snapshot and never calls the API, so
|
|
681
|
+
// `fetchPullRequest` never gets to substitute the repo's configured
|
|
682
|
+
// `clone_url`. Snapshots taken before the option existed (or from a host
|
|
683
|
+
// that omits `base.repo.clone_url` entirely) therefore carry no clone URL
|
|
684
|
+
// at all, and restore also skips `storePRData` — so the gap never heals.
|
|
685
|
+
// Hydrate a copy here so EVERY downstream consumer sees it: the clone in
|
|
686
|
+
// `findRepositoryPath` AND the `resolveRemoteForPR` calls reached via
|
|
687
|
+
// `acquireForPR` / `createWorktreeForPR`. Never mutate `restoreMetadata`
|
|
688
|
+
// itself — the caller may reuse that object.
|
|
689
|
+
if (config && !prData?.repository?.clone_url) {
|
|
690
|
+
const configuredCloneUrl = getRepoCloneUrlForHost(
|
|
691
|
+
config,
|
|
692
|
+
bindingRepository,
|
|
693
|
+
await resolveRestoreHost({ db, config, bindingRepository, repository, prNumber, host })
|
|
694
|
+
);
|
|
695
|
+
if (configuredCloneUrl) {
|
|
696
|
+
prData = {
|
|
697
|
+
...restoreMetadata,
|
|
698
|
+
repository: { ...(restoreMetadata.repository || {}), clone_url: configuredCloneUrl }
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
}
|
|
649
702
|
progress({ step: 'verify', status: 'completed', message: 'Restoring previous review state.' });
|
|
650
703
|
progress({ step: 'fetch', status: 'completed', message: 'Using stored PR data.' });
|
|
651
704
|
} else {
|