@in-the-loop-labs/pair-review 5.1.1 → 5.2.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 +12 -4
- package/package.json +3 -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/public/index.html +6 -2
- package/public/js/index.js +251 -73
- package/public/js/repo-links.js +60 -11
- package/src/ai/index.js +1 -0
- package/src/ai/omp/review-config.yml +13 -0
- package/src/ai/omp-provider.js +279 -0
- package/src/ai/pi-format.js +535 -0
- package/src/ai/pi-provider.js +38 -963
- package/src/ai/pi-style-provider.js +526 -0
- package/src/ai/provider.js +2 -0
- package/src/chat/chat-providers.js +34 -11
- package/src/chat/omp-bridge.js +111 -0
- package/src/chat/pi-bridge.js +42 -34
- package/src/chat/session-manager.js +30 -4
- package/src/config.js +32 -3
- package/src/database.js +24 -0
- package/src/external/github-adapter.js +8 -10
- package/src/links/host-names.js +200 -0
- package/src/local-review.js +7 -3
- package/src/main.js +72 -23
- package/src/review-config.js +81 -5
- package/src/routes/config.js +42 -12
- package/src/routes/external-comments.js +18 -6
- package/src/routes/github-collections.js +32 -5
- package/src/routes/local.js +1 -1
- package/src/routes/pr.js +47 -28
- package/src/routes/setup.js +15 -8
- package/src/routes/stack-analysis.js +22 -9
- package/src/routes/worktrees.js +36 -0
- package/src/server.js +8 -3
- package/src/settings/registry.js +1 -1
- package/src/setup/local-setup.js +5 -3
- package/src/setup/pr-setup.js +49 -26
- package/src/single-port.js +7 -7
- package/src/utils/host-resolution.js +177 -27
- package/src/utils/local-path-input.js +64 -8
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Copyright 2026 Tim Perkins (tjwp) | SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* OMP (Oh My Pi) RPC Bridge
|
|
4
|
+
*
|
|
5
|
+
* Manages a long-lived OMP process in RPC mode for interactive chat sessions.
|
|
6
|
+
* OMP is a fork of the Pi coding agent and speaks the same JSONL RPC protocol
|
|
7
|
+
* (`--mode rpc`, prompt/abort/get_state commands, message_update/agent_end
|
|
8
|
+
* events, and a get_state response containing `sessionFile`), so all process
|
|
9
|
+
* lifecycle and event handling is inherited from PiBridge.
|
|
10
|
+
*
|
|
11
|
+
* This subclass covers OMP's CLI surface differences:
|
|
12
|
+
* - Default command is `omp` (override via PAIR_REVIEW_OMP_CMD or config).
|
|
13
|
+
* - Session resumption uses `--resume <path>` — OMP has no `--session` flag.
|
|
14
|
+
* - Default tool set is read,grep,glob: OMP's file-listing tool is `glob`
|
|
15
|
+
* (no find/ls), and OMP errors on unknown tool names in --tools.
|
|
16
|
+
* - No per-file `--skill` flag (OMP's `--skills` is a glob filter with
|
|
17
|
+
* different semantics), so the skills option is not supported.
|
|
18
|
+
* - OMP's `autoResume` setting reopens the most recent session in the cwd
|
|
19
|
+
* when no session flag is passed, so new chats must explicitly request a
|
|
20
|
+
* fresh session via the `new_session` RPC command before session discovery.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const PiBridge = require('./pi-bridge');
|
|
24
|
+
const logger = require('../utils/logger');
|
|
25
|
+
|
|
26
|
+
class OmpBridge extends PiBridge {
|
|
27
|
+
/**
|
|
28
|
+
* @param {Object} options - Same options as PiBridge, except:
|
|
29
|
+
* @param {string} [options.piCommand] - Override OMP command (default: 'omp')
|
|
30
|
+
* @param {string} [options.tools] - Comma-separated tool list (default: 'read,grep,glob')
|
|
31
|
+
* @param {string[]} [options.skills] - Not supported by OMP; ignored with a warning
|
|
32
|
+
*/
|
|
33
|
+
constructor(options = {}) {
|
|
34
|
+
// OMP has no per-file --skill flag; drop skills so the inherited
|
|
35
|
+
// _buildArgs never emits an unsupported flag.
|
|
36
|
+
if (options.skills?.length) {
|
|
37
|
+
logger.warn('[OmpBridge] OMP does not support per-file skill loading; ignoring skills option');
|
|
38
|
+
}
|
|
39
|
+
super({ ...options, skills: [] });
|
|
40
|
+
|
|
41
|
+
// Command precedence mirrors PiBridge: explicit option > env > default.
|
|
42
|
+
// The PiBridge constructor already consulted PAIR_REVIEW_PI_CMD, so an
|
|
43
|
+
// absent option must be re-resolved against the OMP equivalents here.
|
|
44
|
+
this.piCommand = options.piCommand || process.env.PAIR_REVIEW_OMP_CMD || 'omp';
|
|
45
|
+
this.useShell = options.useShell || this.piCommand.includes(' ');
|
|
46
|
+
this.tools = options.tools || 'read,grep,glob';
|
|
47
|
+
|
|
48
|
+
this.logName = 'OmpBridge';
|
|
49
|
+
this.cliName = 'OMP';
|
|
50
|
+
this.sessionFlag = '--resume';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* No sessionPath means this is a new chat. Launching OMP without a session
|
|
55
|
+
* flag would let its `autoResume` setting reopen the user's most recent
|
|
56
|
+
* transcript in this cwd — and pair-review would then persist that file as
|
|
57
|
+
* the chat's session, appending unrelated history. Request a fresh session
|
|
58
|
+
* explicitly before discovering the file to persist.
|
|
59
|
+
* @returns {Promise<void>}
|
|
60
|
+
*/
|
|
61
|
+
async _querySessionFile() {
|
|
62
|
+
if (!this.sessionPath) {
|
|
63
|
+
await this._requestNewSession();
|
|
64
|
+
}
|
|
65
|
+
return super._querySessionFile();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Send the `new_session` RPC command and wait for its response.
|
|
70
|
+
* Resolves regardless of outcome — a timeout or write failure must never
|
|
71
|
+
* wedge chat startup; the worst case is falling back to OMP's default
|
|
72
|
+
* session behavior.
|
|
73
|
+
* @returns {Promise<void>}
|
|
74
|
+
*/
|
|
75
|
+
_requestNewSession() {
|
|
76
|
+
if (!this.isReady()) return Promise.resolve();
|
|
77
|
+
|
|
78
|
+
return new Promise((resolve) => {
|
|
79
|
+
let timeout;
|
|
80
|
+
this._pendingCallbacks.set('new_session', (event) => {
|
|
81
|
+
clearTimeout(timeout);
|
|
82
|
+
if (event.success) {
|
|
83
|
+
logger.debug(`[${this.logName}] Started fresh session via new_session`);
|
|
84
|
+
} else {
|
|
85
|
+
logger.warn(`[${this.logName}] new_session failed: ${event.error || 'unknown error'}`);
|
|
86
|
+
}
|
|
87
|
+
resolve();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
timeout = setTimeout(() => {
|
|
91
|
+
if (this._pendingCallbacks.has('new_session')) {
|
|
92
|
+
this._pendingCallbacks.delete('new_session');
|
|
93
|
+
logger.debug(`[${this.logName}] new_session timed out`);
|
|
94
|
+
resolve();
|
|
95
|
+
}
|
|
96
|
+
}, 5000);
|
|
97
|
+
if (timeout.unref) timeout.unref();
|
|
98
|
+
|
|
99
|
+
try {
|
|
100
|
+
this._write(JSON.stringify({ type: 'new_session' }));
|
|
101
|
+
} catch (err) {
|
|
102
|
+
clearTimeout(timeout);
|
|
103
|
+
this._pendingCallbacks.delete('new_session');
|
|
104
|
+
logger.debug(`[${this.logName}] Failed to send new_session: ${err.message}`);
|
|
105
|
+
resolve();
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
module.exports = OmpBridge;
|
package/src/chat/pi-bridge.js
CHANGED
|
@@ -55,6 +55,14 @@ class PiBridge extends EventEmitter {
|
|
|
55
55
|
this.sessionPath = options.sessionPath || null;
|
|
56
56
|
this.loadSkills = options.loadSkills !== false;
|
|
57
57
|
|
|
58
|
+
// Subclass hooks (see OmpBridge): log prefix, human-readable CLI name for
|
|
59
|
+
// error messages, and the flag used to resume from a session file. OMP is
|
|
60
|
+
// a Pi fork that speaks the same RPC protocol but resumes via --resume
|
|
61
|
+
// (it has no --session flag).
|
|
62
|
+
this.logName = 'PiBridge';
|
|
63
|
+
this.cliName = 'Pi';
|
|
64
|
+
this.sessionFlag = '--session';
|
|
65
|
+
|
|
58
66
|
this._process = null;
|
|
59
67
|
this._readline = null;
|
|
60
68
|
this._ready = false;
|
|
@@ -73,7 +81,7 @@ class PiBridge extends EventEmitter {
|
|
|
73
81
|
*/
|
|
74
82
|
async start() {
|
|
75
83
|
if (this._process) {
|
|
76
|
-
throw new Error(
|
|
84
|
+
throw new Error(`${this.logName} already started`);
|
|
77
85
|
}
|
|
78
86
|
|
|
79
87
|
const args = this._buildArgs();
|
|
@@ -84,7 +92,7 @@ class PiBridge extends EventEmitter {
|
|
|
84
92
|
const spawnCmd = useShell ? `${command} ${quoteShellArgs(args).join(' ')}` : command;
|
|
85
93
|
const spawnArgs = useShell ? [] : args;
|
|
86
94
|
|
|
87
|
-
logger.info(`[
|
|
95
|
+
logger.info(`[${this.logName}] Starting ${this.cliName} RPC: ${command} ${args.join(' ')}`);
|
|
88
96
|
|
|
89
97
|
return new Promise((resolve, reject) => {
|
|
90
98
|
const proc = spawn(spawnCmd, spawnArgs, {
|
|
@@ -100,9 +108,9 @@ class PiBridge extends EventEmitter {
|
|
|
100
108
|
proc.on('error', (err) => {
|
|
101
109
|
if (!this._ready) {
|
|
102
110
|
this._ready = false;
|
|
103
|
-
reject(new Error(`Failed to start
|
|
111
|
+
reject(new Error(`Failed to start ${this.cliName} RPC: ${err.message}`));
|
|
104
112
|
} else {
|
|
105
|
-
logger.error(`[
|
|
113
|
+
logger.error(`[${this.logName}] Process error: ${err.message}`);
|
|
106
114
|
this.emit('error', { error: err });
|
|
107
115
|
}
|
|
108
116
|
});
|
|
@@ -114,14 +122,14 @@ class PiBridge extends EventEmitter {
|
|
|
114
122
|
this._process = null;
|
|
115
123
|
|
|
116
124
|
if (!wasReady && !this._closing) {
|
|
117
|
-
reject(new Error(
|
|
125
|
+
reject(new Error(`${this.cliName} RPC exited before ready (code=${code}, signal=${signal})`));
|
|
118
126
|
}
|
|
119
127
|
|
|
120
128
|
if (!this._closing) {
|
|
121
|
-
logger.warn(`[
|
|
122
|
-
this.emit('error', { error: new Error(
|
|
129
|
+
logger.warn(`[${this.logName}] Process exited unexpectedly (code=${code}, signal=${signal})`);
|
|
130
|
+
this.emit('error', { error: new Error(`${this.cliName} process exited (code=${code}, signal=${signal})`) });
|
|
123
131
|
} else {
|
|
124
|
-
logger.info(`[
|
|
132
|
+
logger.info(`[${this.logName}] Process exited (code=${code}, signal=${signal})`);
|
|
125
133
|
}
|
|
126
134
|
|
|
127
135
|
this.emit('close');
|
|
@@ -131,7 +139,7 @@ class PiBridge extends EventEmitter {
|
|
|
131
139
|
proc.stderr.on('data', (data) => {
|
|
132
140
|
const text = data.toString().trim();
|
|
133
141
|
if (text) {
|
|
134
|
-
logger.debug(`[
|
|
142
|
+
logger.debug(`[${this.logName}] stderr: ${text}`);
|
|
135
143
|
}
|
|
136
144
|
});
|
|
137
145
|
|
|
@@ -147,7 +155,7 @@ class PiBridge extends EventEmitter {
|
|
|
147
155
|
|
|
148
156
|
// Handle stdin errors (e.g., EPIPE if process dies)
|
|
149
157
|
proc.stdin.on('error', (err) => {
|
|
150
|
-
logger.error(`[
|
|
158
|
+
logger.error(`[${this.logName}] stdin error: ${err.message}`);
|
|
151
159
|
});
|
|
152
160
|
|
|
153
161
|
// Pi RPC doesn't emit a specific "ready" event, so we consider it ready
|
|
@@ -156,7 +164,7 @@ class PiBridge extends EventEmitter {
|
|
|
156
164
|
setImmediate(() => {
|
|
157
165
|
if (this._process && !this._ready) {
|
|
158
166
|
this._ready = true;
|
|
159
|
-
logger.info(`[
|
|
167
|
+
logger.info(`[${this.logName}] Ready (PID ${proc.pid})`);
|
|
160
168
|
this.emit('ready');
|
|
161
169
|
resolve();
|
|
162
170
|
}
|
|
@@ -171,7 +179,7 @@ class PiBridge extends EventEmitter {
|
|
|
171
179
|
*/
|
|
172
180
|
async sendMessage(content) {
|
|
173
181
|
if (!this.isReady()) {
|
|
174
|
-
throw new Error(
|
|
182
|
+
throw new Error(`${this.logName} is not ready`);
|
|
175
183
|
}
|
|
176
184
|
|
|
177
185
|
// Reset accumulated text for this new turn
|
|
@@ -179,9 +187,9 @@ class PiBridge extends EventEmitter {
|
|
|
179
187
|
this._inMessage = false;
|
|
180
188
|
|
|
181
189
|
const command = JSON.stringify({ type: 'prompt', message: content });
|
|
182
|
-
logger.debug(`[
|
|
190
|
+
logger.debug(`[${this.logName}] Sending prompt (${content.length} chars): ${content.substring(0, 100)}${content.length > 100 ? '...' : ''}`);
|
|
183
191
|
this._write(command);
|
|
184
|
-
logger.debug(`[
|
|
192
|
+
logger.debug(`[${this.logName}] Prompt written to stdin (${command.length} bytes)`);
|
|
185
193
|
}
|
|
186
194
|
|
|
187
195
|
/**
|
|
@@ -190,7 +198,7 @@ class PiBridge extends EventEmitter {
|
|
|
190
198
|
abort() {
|
|
191
199
|
if (!this.isReady()) return;
|
|
192
200
|
const command = JSON.stringify({ type: 'abort' });
|
|
193
|
-
logger.debug(
|
|
201
|
+
logger.debug(`[${this.logName}] Sending abort`);
|
|
194
202
|
this._write(command);
|
|
195
203
|
}
|
|
196
204
|
|
|
@@ -222,7 +230,7 @@ class PiBridge extends EventEmitter {
|
|
|
222
230
|
// Give the process a moment to exit gracefully, then force kill
|
|
223
231
|
const killTimeout = setTimeout(() => {
|
|
224
232
|
if (this._process) {
|
|
225
|
-
logger.warn(
|
|
233
|
+
logger.warn(`[${this.logName}] Force killing process`);
|
|
226
234
|
this._process.kill('SIGKILL');
|
|
227
235
|
}
|
|
228
236
|
}, 3000);
|
|
@@ -267,7 +275,7 @@ class PiBridge extends EventEmitter {
|
|
|
267
275
|
const args = ['--mode', 'rpc', '--tools', this.tools];
|
|
268
276
|
|
|
269
277
|
if (this.sessionPath) {
|
|
270
|
-
args.push(
|
|
278
|
+
args.push(this.sessionFlag, this.sessionPath);
|
|
271
279
|
}
|
|
272
280
|
|
|
273
281
|
if (this.provider) {
|
|
@@ -326,9 +334,9 @@ class PiBridge extends EventEmitter {
|
|
|
326
334
|
if (event.success && event.data && event.data.sessionFile) {
|
|
327
335
|
this.sessionPath = event.data.sessionFile;
|
|
328
336
|
this.emit('session', { sessionFile: event.data.sessionFile });
|
|
329
|
-
logger.info(`[
|
|
337
|
+
logger.info(`[${this.logName}] Discovered session file: ${event.data.sessionFile}`);
|
|
330
338
|
} else {
|
|
331
|
-
logger.debug(
|
|
339
|
+
logger.debug(`[${this.logName}] get_state did not return a sessionFile`);
|
|
332
340
|
}
|
|
333
341
|
resolve();
|
|
334
342
|
});
|
|
@@ -337,7 +345,7 @@ class PiBridge extends EventEmitter {
|
|
|
337
345
|
timeout = setTimeout(() => {
|
|
338
346
|
if (this._pendingCallbacks.has('get_state')) {
|
|
339
347
|
this._pendingCallbacks.delete('get_state');
|
|
340
|
-
logger.debug(
|
|
348
|
+
logger.debug(`[${this.logName}] get_state timed out`);
|
|
341
349
|
resolve();
|
|
342
350
|
}
|
|
343
351
|
}, 5000);
|
|
@@ -348,7 +356,7 @@ class PiBridge extends EventEmitter {
|
|
|
348
356
|
this._write(JSON.stringify({ type: 'get_state' }));
|
|
349
357
|
} catch (err) {
|
|
350
358
|
this._pendingCallbacks.delete('get_state');
|
|
351
|
-
logger.debug(`[
|
|
359
|
+
logger.debug(`[${this.logName}] Failed to send get_state: ${err.message}`);
|
|
352
360
|
resolve();
|
|
353
361
|
}
|
|
354
362
|
});
|
|
@@ -360,7 +368,7 @@ class PiBridge extends EventEmitter {
|
|
|
360
368
|
*/
|
|
361
369
|
_write(jsonLine) {
|
|
362
370
|
if (!this._process || !this._process.stdin.writable) {
|
|
363
|
-
throw new Error(
|
|
371
|
+
throw new Error(`${this.cliName} RPC process stdin is not writable`);
|
|
364
372
|
}
|
|
365
373
|
this._process.stdin.write(jsonLine + '\n');
|
|
366
374
|
}
|
|
@@ -376,7 +384,7 @@ class PiBridge extends EventEmitter {
|
|
|
376
384
|
try {
|
|
377
385
|
event = JSON.parse(line);
|
|
378
386
|
} catch {
|
|
379
|
-
logger.debug(`[
|
|
387
|
+
logger.debug(`[${this.logName}] Ignoring unparseable line: ${line.substring(0, 100)}`);
|
|
380
388
|
return;
|
|
381
389
|
}
|
|
382
390
|
|
|
@@ -438,24 +446,24 @@ class PiBridge extends EventEmitter {
|
|
|
438
446
|
this._pendingCallbacks.delete(event.command);
|
|
439
447
|
callback(event);
|
|
440
448
|
} else if (!event.success) {
|
|
441
|
-
logger.error(`[
|
|
449
|
+
logger.error(`[${this.logName}] Command failed: ${event.error}`);
|
|
442
450
|
this.emit('error', { error: new Error(event.error || 'Unknown command error') });
|
|
443
451
|
} else {
|
|
444
|
-
logger.debug(`[
|
|
452
|
+
logger.debug(`[${this.logName}] Command acknowledged: ${JSON.stringify(event).substring(0, 200)}`);
|
|
445
453
|
}
|
|
446
454
|
break;
|
|
447
455
|
|
|
448
456
|
case 'agent_start':
|
|
449
457
|
case 'turn_start':
|
|
450
|
-
logger.debug(`[
|
|
458
|
+
logger.debug(`[${this.logName}] ${type}`);
|
|
451
459
|
this.emit('status', { status: 'working' });
|
|
452
460
|
break;
|
|
453
461
|
case 'turn_end':
|
|
454
|
-
logger.debug(`[
|
|
462
|
+
logger.debug(`[${this.logName}] ${type}`);
|
|
455
463
|
this.emit('status', { status: 'turn_complete' });
|
|
456
464
|
break;
|
|
457
465
|
case 'session':
|
|
458
|
-
logger.debug(`[
|
|
466
|
+
logger.debug(`[${this.logName}] ${type}: ${JSON.stringify(event).substring(0, 200)}`);
|
|
459
467
|
if (event.sessionFile) {
|
|
460
468
|
this.sessionPath = event.sessionFile;
|
|
461
469
|
}
|
|
@@ -463,7 +471,7 @@ class PiBridge extends EventEmitter {
|
|
|
463
471
|
break;
|
|
464
472
|
|
|
465
473
|
default:
|
|
466
|
-
logger.debug(`[
|
|
474
|
+
logger.debug(`[${this.logName}] Unhandled event type: ${type}`);
|
|
467
475
|
}
|
|
468
476
|
}
|
|
469
477
|
|
|
@@ -512,12 +520,12 @@ class PiBridge extends EventEmitter {
|
|
|
512
520
|
break;
|
|
513
521
|
case 'error': {
|
|
514
522
|
const errorMsg = assistantEvent.error || assistantEvent.delta || 'Unknown streaming error';
|
|
515
|
-
logger.error(`[
|
|
523
|
+
logger.error(`[${this.logName}] Streaming error: ${errorMsg}`);
|
|
516
524
|
this.emit('error', { error: new Error(errorMsg) });
|
|
517
525
|
break;
|
|
518
526
|
}
|
|
519
527
|
default:
|
|
520
|
-
logger.debug(`[
|
|
528
|
+
logger.debug(`[${this.logName}] Unhandled assistantMessageEvent type: ${assistantEvent.type}`);
|
|
521
529
|
}
|
|
522
530
|
}
|
|
523
531
|
|
|
@@ -531,7 +539,7 @@ class PiBridge extends EventEmitter {
|
|
|
531
539
|
this._accumulatedText = '';
|
|
532
540
|
this._inMessage = false;
|
|
533
541
|
|
|
534
|
-
logger.debug(`[
|
|
542
|
+
logger.debug(`[${this.logName}] Agent ended, accumulated ${fullText.length} chars`);
|
|
535
543
|
this.emit('complete', { fullText });
|
|
536
544
|
}
|
|
537
545
|
|
|
@@ -546,7 +554,7 @@ class PiBridge extends EventEmitter {
|
|
|
546
554
|
const id = event.id;
|
|
547
555
|
|
|
548
556
|
if (DIALOG_METHODS.has(method) && id) {
|
|
549
|
-
logger.debug(`[
|
|
557
|
+
logger.debug(`[${this.logName}] Auto-cancelling dialog: ${method} (${id})`);
|
|
550
558
|
// Respond with cancellation
|
|
551
559
|
const response = JSON.stringify({
|
|
552
560
|
type: 'extension_ui_response',
|
|
@@ -559,7 +567,7 @@ class PiBridge extends EventEmitter {
|
|
|
559
567
|
// Process may be dead
|
|
560
568
|
}
|
|
561
569
|
} else {
|
|
562
|
-
logger.debug(`[
|
|
570
|
+
logger.debug(`[${this.logName}] Ignoring extension_ui_request: ${method}`);
|
|
563
571
|
}
|
|
564
572
|
}
|
|
565
573
|
}
|
|
@@ -10,16 +10,21 @@
|
|
|
10
10
|
const fs = require('fs');
|
|
11
11
|
const path = require('path');
|
|
12
12
|
const PiBridge = require('./pi-bridge');
|
|
13
|
+
const OmpBridge = require('./omp-bridge');
|
|
13
14
|
const AcpBridge = require('./acp-bridge');
|
|
14
15
|
const ClaudeCodeBridge = require('./claude-code-bridge');
|
|
15
16
|
const CodexBridge = require('./codex-bridge');
|
|
16
|
-
const { getChatProvider, isAcpProvider, isClaudeCodeProvider, isCodexProvider, applyConfigOverrides: applyChatConfigOverrides } = require('./chat-providers');
|
|
17
|
+
const { getChatProvider, isAcpProvider, isOmpProvider, isClaudeCodeProvider, isCodexProvider, applyConfigOverrides: applyChatConfigOverrides } = require('./chat-providers');
|
|
17
18
|
const logger = require('../utils/logger');
|
|
18
19
|
|
|
19
20
|
const taskExtensionDir = path.resolve(__dirname, '../../.pi/extensions/task');
|
|
20
21
|
|
|
21
22
|
const CHAT_TOOLS = 'read,bash,grep,find,ls';
|
|
22
23
|
|
|
24
|
+
// OMP's tool names differ from Pi's: file listing is `glob` (no find/ls), and
|
|
25
|
+
// OMP errors on unknown tool names in --tools, so the Pi list cannot be reused.
|
|
26
|
+
const OMP_CHAT_TOOLS = 'read,bash,grep,glob';
|
|
27
|
+
|
|
23
28
|
class ChatSessionManager {
|
|
24
29
|
/**
|
|
25
30
|
* @param {Database} db - better-sqlite3 database instance
|
|
@@ -435,7 +440,7 @@ class ChatSessionManager {
|
|
|
435
440
|
const usesOpaqueSessionId = isAcp || isClaudeCode;
|
|
436
441
|
|
|
437
442
|
if (!usesOpaqueSessionId && !isCodex) {
|
|
438
|
-
// Pi sessions require a session file on disk
|
|
443
|
+
// Pi/OMP sessions require a session file on disk
|
|
439
444
|
if (!row.agent_session_id) {
|
|
440
445
|
throw new Error(`Session ${sessionId} has no session file — cannot resume`);
|
|
441
446
|
}
|
|
@@ -536,11 +541,13 @@ class ChatSessionManager {
|
|
|
536
541
|
|
|
537
542
|
/**
|
|
538
543
|
* Create the appropriate bridge instance for a provider.
|
|
539
|
-
* ACP providers get an AcpBridge
|
|
544
|
+
* ACP providers get an AcpBridge, Claude gets a ClaudeCodeBridge, Codex gets
|
|
545
|
+
* a CodexBridge, OMP gets an OmpBridge; everything else gets a PiBridge with
|
|
546
|
+
* tools/skills.
|
|
540
547
|
* @param {string} provider
|
|
541
548
|
* @param {Object} options - Bridge constructor options
|
|
542
549
|
* @param {Object} [providerDef] - Pre-resolved provider definition (avoids redundant getChatProvider calls)
|
|
543
|
-
* @returns {PiBridge|AcpBridge}
|
|
550
|
+
* @returns {PiBridge|OmpBridge|AcpBridge|ClaudeCodeBridge|CodexBridge}
|
|
544
551
|
*/
|
|
545
552
|
_createBridge(provider, options, providerDef) {
|
|
546
553
|
const def = providerDef || getChatProvider(provider);
|
|
@@ -574,6 +581,25 @@ class ChatSessionManager {
|
|
|
574
581
|
sandbox: def?.sandbox,
|
|
575
582
|
});
|
|
576
583
|
}
|
|
584
|
+
if (isOmpProvider(provider)) {
|
|
585
|
+
// OMP — same RPC protocol as Pi, so the option mapping below mirrors the
|
|
586
|
+
// Pi branch (see its comments), with two OMP-specific differences:
|
|
587
|
+
// - Tools: OMP_CHAT_TOOLS (OMP rejects Pi's find/ls tool names).
|
|
588
|
+
// - No task extension: pair-review's bundled extension is Pi-specific
|
|
589
|
+
// (it spawns `pi` subagents via PI_CMD), matching the AI provider,
|
|
590
|
+
// which also omits it for OMP.
|
|
591
|
+
return new OmpBridge({
|
|
592
|
+
...options,
|
|
593
|
+
provider: def?.provider || null,
|
|
594
|
+
model: options.model || def?.model,
|
|
595
|
+
piCommand: def?.command,
|
|
596
|
+
extraArgs: def?.args,
|
|
597
|
+
env: def?.env,
|
|
598
|
+
useShell: def?.useShell,
|
|
599
|
+
tools: OMP_CHAT_TOOLS,
|
|
600
|
+
loadSkills: options.loadSkills ?? def?.load_skills,
|
|
601
|
+
});
|
|
602
|
+
}
|
|
577
603
|
// Pi provider — resolve config overrides (command, model, env) from provider def.
|
|
578
604
|
// options.provider is the chat provider ID (e.g. "pi") — do NOT pass it to PiBridge,
|
|
579
605
|
// which would forward it as `--provider pi` to the Pi CLI. The CLI's --provider flag
|
package/src/config.js
CHANGED
|
@@ -67,7 +67,7 @@ const DEFAULT_CONFIG = {
|
|
|
67
67
|
port: 7247,
|
|
68
68
|
single_port: true, // When true, reuse a single server on the configured port; new invocations delegate to the running server
|
|
69
69
|
theme: "light",
|
|
70
|
-
default_provider: "claude", // AI provider: 'claude', 'antigravity', 'codex', 'copilot', 'opencode', 'cursor-agent', 'pi', 'muse'
|
|
70
|
+
default_provider: "claude", // AI provider: 'claude', 'antigravity', 'codex', 'copilot', 'opencode', 'cursor-agent', 'pi', 'omp', 'muse'
|
|
71
71
|
default_model: "opus", // Model within the provider (e.g., 'opus' for Claude, 'gemini-3.1-pro-low' for Antigravity)
|
|
72
72
|
tours: {
|
|
73
73
|
enabled: false, // When true, the guided-tour feature is available (toolbar button visible, etc.)
|
|
@@ -98,7 +98,7 @@ const DEFAULT_CONFIG = {
|
|
|
98
98
|
repos: {}, // Repository configurations: { "owner/repo": { path: "~/path/to/clone" } }
|
|
99
99
|
assisted_by_url: "https://github.com/in-the-loop-labs/pair-review", // URL for "Review assisted by" footer link
|
|
100
100
|
hooks: {}, // Hook commands per event: { "review.started": { "my_hook": { "command": "..." } } }
|
|
101
|
-
enable_graphite: false, // When true, shows Graphite links alongside GitHub links
|
|
101
|
+
enable_graphite: false, // When true, shows Graphite links alongside GitHub links and names Graphite in the PR URL prompts/errors (Graphite URLs are accepted either way)
|
|
102
102
|
skip_update_notifier: false, // When true, suppresses the "update available" notification on exit
|
|
103
103
|
external_comments: false // Opt-in: set to true to enable GitHub PR review-comment sync (External segment, refresh button, /api/reviews/*/external-comments routes)
|
|
104
104
|
};
|
|
@@ -234,7 +234,29 @@ function getSummaryProvider(config) {
|
|
|
234
234
|
|
|
235
235
|
/**
|
|
236
236
|
* Gets the summary model for summary/tour generation
|
|
237
|
-
* Resolution order: summaries.model → providerClass fast-tier →
|
|
237
|
+
* Resolution order: summaries.model → providerClass fast-tier → provider
|
|
238
|
+
* default (when the summary provider differs from the global default
|
|
239
|
+
* provider) → default_model
|
|
240
|
+
*
|
|
241
|
+
* The provider-default rung guards against handing the summary provider a
|
|
242
|
+
* foreign model id: the global `default_model` is *intended* to pair with
|
|
243
|
+
* `default_provider` (the effective config is flattened from independent
|
|
244
|
+
* layers, so the pairing is not guaranteed), so when `summaries.provider`
|
|
245
|
+
* selects a DIFFERENT provider with no fast tier (e.g. OMP, whose single
|
|
246
|
+
* model is 'balanced'), that provider's own default is used instead of the
|
|
247
|
+
* global model. When the summary provider IS the global default provider,
|
|
248
|
+
* the configured `default_model` still wins. Providers with no built-in
|
|
249
|
+
* default (e.g. OpenCode returns null) fall through to default_model.
|
|
250
|
+
*
|
|
251
|
+
* Known limitation: this rung (and the fast-tier rung above it) reads the
|
|
252
|
+
* provider class's STATIC built-in model table, so per-provider config
|
|
253
|
+
* overrides (`providers.<id>.models` / `default_model` / `disabled_models`)
|
|
254
|
+
* are not applied here, unlike `createProvider(id, null)`. Acceptable
|
|
255
|
+
* because the result is always a valid id for *that* provider (the bug this
|
|
256
|
+
* rung fixes), just not necessarily the configured one; an override-aware
|
|
257
|
+
* fix would need this module to import from src/ai, which it deliberately
|
|
258
|
+
* does not.
|
|
259
|
+
*
|
|
238
260
|
* @param {Object} config - Configuration object
|
|
239
261
|
* @param {Function} [providerClass] - Optional provider class with static getModels()
|
|
240
262
|
* @returns {string} - Model name
|
|
@@ -246,6 +268,13 @@ function getSummaryModel(config, providerClass = null) {
|
|
|
246
268
|
const fast = providerClass.getModels().find(m => m.tier === 'fast');
|
|
247
269
|
if (fast) return fast.id;
|
|
248
270
|
}
|
|
271
|
+
if (providerClass
|
|
272
|
+
&& typeof providerClass.getProviderId === 'function'
|
|
273
|
+
&& typeof providerClass.getDefaultModel === 'function'
|
|
274
|
+
&& providerClass.getProviderId() !== getDefaultProvider(config)) {
|
|
275
|
+
const providerDefault = providerClass.getDefaultModel();
|
|
276
|
+
if (providerDefault) return providerDefault;
|
|
277
|
+
}
|
|
249
278
|
return getDefaultModel(config);
|
|
250
279
|
}
|
|
251
280
|
|
package/src/database.js
CHANGED
|
@@ -5336,6 +5336,30 @@ class PRMetadataRepository {
|
|
|
5336
5336
|
return row.host;
|
|
5337
5337
|
}
|
|
5338
5338
|
|
|
5339
|
+
/**
|
|
5340
|
+
* Get the stored host binding for a PR together with its recorded web URL.
|
|
5341
|
+
*
|
|
5342
|
+
* A stored `NULL` is ambiguous on its own: it means github.com for anything
|
|
5343
|
+
* stamped since schema v50, but "never stamped" for older rows. The recorded
|
|
5344
|
+
* `html_url` is the evidence that settles it, so host resolution can read
|
|
5345
|
+
* both in one query instead of guessing (see `resolveRecordedHost`).
|
|
5346
|
+
*
|
|
5347
|
+
* @param {string} repository - Repository in owner/repo format
|
|
5348
|
+
* @param {number} prNumber - Pull request number
|
|
5349
|
+
* @returns {Promise<{host: string|null, recordedUrl: string|null}|undefined>}
|
|
5350
|
+
* `undefined` when no pr_metadata row exists for the PR.
|
|
5351
|
+
*/
|
|
5352
|
+
async getPRHostWithRecordedUrl(repository, prNumber) {
|
|
5353
|
+
const row = await queryOne(this.db, `
|
|
5354
|
+
SELECT host, json_extract(pr_data, '$.html_url') AS recorded_url
|
|
5355
|
+
FROM pr_metadata
|
|
5356
|
+
WHERE pr_number = ? AND repository = ? COLLATE NOCASE
|
|
5357
|
+
`, [prNumber, repository]);
|
|
5358
|
+
|
|
5359
|
+
if (!row) return undefined;
|
|
5360
|
+
return { host: row.host, recordedUrl: row.recorded_url || null };
|
|
5361
|
+
}
|
|
5362
|
+
|
|
5339
5363
|
/**
|
|
5340
5364
|
* Update ONLY the host binding for a PR's metadata row.
|
|
5341
5365
|
*
|
|
@@ -19,12 +19,8 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
const { GitHubClient, GitHubApiError } = require('../github/client');
|
|
22
|
-
const {
|
|
23
|
-
|
|
24
|
-
resolveHostBinding,
|
|
25
|
-
resolveBindingRepositoryFromPR
|
|
26
|
-
} = require('../config');
|
|
27
|
-
const { storedHostToOption } = require('../utils/host-resolution');
|
|
22
|
+
const { getGitHubToken, resolveHostBinding } = require('../config');
|
|
23
|
+
const { storedHostToOption, resolveBindingRepositoryForHost } = require('../utils/host-resolution');
|
|
28
24
|
|
|
29
25
|
const name = 'github';
|
|
30
26
|
|
|
@@ -88,17 +84,19 @@ function resolveCredentials(config, repository, _deps, options = {}) {
|
|
|
88
84
|
GitHubClient,
|
|
89
85
|
getGitHubToken,
|
|
90
86
|
resolveHostBinding,
|
|
91
|
-
|
|
87
|
+
resolveBindingRepositoryForHost,
|
|
92
88
|
..._deps
|
|
93
89
|
};
|
|
94
90
|
const safeConfig = config || {};
|
|
95
91
|
|
|
96
92
|
if (repository) {
|
|
97
93
|
// Binding-aware path. Mirrors resolveBindingForRequest in routes/pr.js:
|
|
98
|
-
// resolve the PR identity to a binding key
|
|
99
|
-
//
|
|
94
|
+
// resolve the PR identity to a binding key for the host it is recorded on,
|
|
95
|
+
// then to a host binding — pinned to that host for dual repos. Passing the
|
|
96
|
+
// host into the key lookup keeps an exclusive alt entry that merely
|
|
97
|
+
// `url_pattern`-claimed this owner/repo from serving a github.com PR.
|
|
100
98
|
const [owner, repo] = String(repository).split('/');
|
|
101
|
-
const bindingRepository = deps.
|
|
99
|
+
const bindingRepository = deps.resolveBindingRepositoryForHost(owner, repo, safeConfig, options.storedHost);
|
|
102
100
|
const hostOption = storedHostToOption(safeConfig, bindingRepository, options.storedHost);
|
|
103
101
|
const binding = deps.resolveHostBinding(bindingRepository, safeConfig, hostOption || {});
|
|
104
102
|
if (!binding || !binding.token) {
|