@in-the-loop-labs/pair-review 5.1.1 → 5.2.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 CHANGED
@@ -516,7 +516,7 @@ For advanced configuration with custom providers and models, see [AI Provider Co
516
516
  |-----|---------|-------------|
517
517
  | `external_comments` | `false` | Opt-in: set to `true` to fetch and display GitHub PR review comments inline. Enables the **External** segment, the refresh button, and `/api/reviews/*/external-comments*` routes. |
518
518
  | `enable_chat` | `true` | Enables the chat panel feature (uses `chat_provider`). |
519
- | `enable_graphite` | `false` | Show Graphite links alongside GitHub links. |
519
+ | `enable_graphite` | `false` | Show Graphite links alongside GitHub links, and name Graphite in the PR URL prompts and errors. Graphite PR URLs are accepted either way. |
520
520
  | `skip_update_notifier` | `false` | Suppress the "update available" notification on exit. |
521
521
 
522
522
  ### Configuration Files
@@ -578,6 +578,7 @@ pair-review supports several environment variables for customizing behavior:
578
578
  | `PAIR_REVIEW_OPENCODE_CMD` | Custom command to invoke OpenCode CLI | `opencode` |
579
579
  | `PAIR_REVIEW_CURSOR_AGENT_CMD` | Custom command to invoke Cursor Agent CLI | `agent` |
580
580
  | `PAIR_REVIEW_PI_CMD` | Custom command to invoke Pi CLI | `pi` |
581
+ | `PAIR_REVIEW_OMP_CMD` | Custom command to invoke OMP (Oh My Pi) CLI | `omp` |
581
582
  | `PAIR_REVIEW_MUSE_CMD` | Custom command to invoke Muse Code CLI | `muse` |
582
583
 
583
584
  **Note:** `GITHUB_TOKEN` is the standard environment variable used by many GitHub tools (gh CLI, GitHub Actions, etc.). When set, it takes precedence over the `github_token` field in the config file.
@@ -636,13 +637,14 @@ pair-review integrates with AI providers via their CLI tools:
636
637
  - **OpenCode**: Uses OpenCode CLI (requires model configuration)
637
638
  - **Cursor**: Uses Cursor Agent CLI (streaming output with sandbox mode)
638
639
  - **Pi**: Uses Pi coding agent CLI (requires model configuration)
640
+ - **OMP**: Uses the [Oh My Pi](https://github.com/can1357/oh-my-pi) CLI (`omp`), a fork of the Pi coding agent. Install it with `npm install -g @oh-my-pi/pi-coding-agent`. Works out of the box: the built-in `default` mode uses whatever model your OMP configuration selects, and you can add specific models via `providers.omp.models` (run `omp models` to list the catalog). OMP's advisor runtime — which passively reviews each turn and injects notes — is disabled during reviews by default for deterministic, lower-cost analysis; set `"advisor": true` in `providers.omp` to opt back in.
639
641
  - **Muse**: Uses Meta's Muse Code CLI (`muse`), a terminal coding agent released in beta in August 2026 and powered by the Muse Spark 1.2 model. Install it with the single shell command from Meta's Muse Code install instructions (macOS/Linux), then authenticate once with `muse login` (credentials are stored in `~/.config/muse/auth.json`). pair-review drives it headlessly via `muse exec --json`. Within pair-review, Muse is analysis-only: the CLI exposes no ACP server mode, so there is no Muse chat provider.
640
642
 
641
643
  You can select your preferred provider and model in the repository settings UI.
642
644
 
643
645
  #### Built-in vs. Configurable Providers
644
646
 
645
- Most providers (Claude, Antigravity, Codex, Copilot, Muse) come with built-in model definitions. **OpenCode and Pi are different** - they have no built-in models and require you to configure which models to use.
647
+ Most providers (Claude, Antigravity, Codex, Copilot, Muse) come with built-in model definitions. **OpenCode and Pi are different** - they have no built-in models and require you to configure which models to use. **OMP** sits in between: it ships a single `default` mode that delegates to your OMP configuration (`~/.omp/agent/config.yml`), so it works without any pair-review model configuration, and you can add specific models via `providers.omp.models`. OMP model `id`s are passed to `omp --model` verbatim, which fuzzy-matches (`"opus"`, `"gpt-5.2"`) and accepts full `provider/model` strings (`"anthropic/claude-opus-5"`).
646
648
 
647
649
  ##### Muse models and the contributor tradeoff
648
650
 
@@ -718,7 +720,8 @@ You can override provider settings and define custom models in your config file.
718
720
  | `env` | Environment variables to set when running the CLI |
719
721
  | `installInstructions` | Custom installation instructions shown in UI |
720
722
  | `availability_timeout_seconds` | Seconds to allow for the startup availability probe before the provider is reported unavailable (default `10`). Raise it for providers whose check runs a slow build/compile step. Also supported per chat provider under `chat_providers.<id>`. |
721
- | `availability_command` | Command run to decide availability. Executable providers default to always-available when omitted; chat providers fall back to `<command> --version` (or, for the built-in Pi, the cached AI-provider status). Pair with `availability_timeout_seconds` when the probe runs a slow build. |
723
+ | `availability_command` | Command run to decide availability. Executable providers default to always-available when omitted; chat providers fall back to `<command> --version` (or, for the built-in Pi and OMP, the cached AI-provider status). Pair with `availability_timeout_seconds` when the probe runs a slow build. |
724
+ | `advisor` | OMP only. Set to `true` to enable OMP's advisor runtime during analysis (`--advisor`). Defaults to `false`: pair-review disables the advisor via a bundled config overlay, even when it is enabled in your global OMP configuration. |
722
725
  | `models` | Array of model definitions (see below) |
723
726
  | `default_model` | Model `id` to use as the provider's default (in the picker and when no model is specified). Preferred over the per-model `default: true` flag. If it names an unknown or disabled model, the provider falls back to automatic selection. |
724
727
  | `disabled_models` | Array of model selectors to hide, matched by model `id` or alias. Disabled models disappear from the model picker for that provider. Works on built-in models too, so you can remove a built-in option without redefining the rest. A list that would hide *every* model is ignored. |
@@ -831,6 +834,8 @@ npm install -g @mariozechner/pi-coding-agent
831
834
 
832
835
  Configure your preferred models in `providers.pi.models` — see [AI Provider Configuration](#ai-provider-configuration) for details. Everything else in pair-review works without Pi installed.
833
836
 
837
+ [OMP (Oh My Pi)](https://github.com/can1357/oh-my-pi), a fork of Pi, is also available as a chat provider (`omp`) — it speaks the same RPC protocol through the `omp` CLI (`npm install -g @oh-my-pi/pi-coding-agent`) and uses whatever model your OMP configuration selects (set a chat model via `chat_providers.omp.model`; values are passed to `omp --model`, which fuzzy-matches). Unlike Pi chat, OMP chat does not load pair-review's task extension for subagent delegation.
838
+
834
839
  **Chat provider command overrides:** To customize CLI commands for chat providers (e.g., to use a wrapper script), use the `chat_providers` config key:
835
840
 
836
841
  ```json
@@ -843,7 +848,7 @@ Configure your preferred models in `providers.pi.models` — see [AI Provider Co
843
848
  }
844
849
  ```
845
850
 
846
- Available chat provider IDs: `pi`, `claude`, `codex`, `copilot-acp`, `opencode-acp`, `cursor-acp`. Each supports `command`, `args` (replaces defaults), `extra_args` (appends), and `env` overrides. Codex chat also supports `sandbox`: use `workspace-write` by default, or `read-only` for discussion-only sessions. (Antigravity and Muse are analysis-only providers — neither CLI has an ACP mode, so there are no Antigravity or Muse chat providers.)
851
+ Available chat provider IDs: `pi`, `omp`, `claude`, `codex`, `copilot-acp`, `opencode-acp`, `cursor-acp`. Each supports `command`, `args` (replaces defaults; for `pi` and `omp` there are no default args — supplied args are appended after the generated RPC flags, so use a multi-word `command` like `"devx omp"` for wrappers rather than `args`), `extra_args` (appends), and `env` overrides. Codex chat also supports `sandbox`: use `workspace-write` by default, or `read-only` for discussion-only sessions. (Antigravity and Muse are analysis-only providers — neither CLI has an ACP mode, so there are no Antigravity or Muse chat providers.)
847
852
 
848
853
  **Keyboard shortcut:** Press `p` then `c` to toggle the chat panel.
849
854
 
@@ -1205,6 +1210,9 @@ A: OpenCode has no built-in models, so you must configure them in your `~/.pair-
1205
1210
  **Q: How do I use Pi as my AI provider?**
1206
1211
  A: Like OpenCode, Pi has no built-in models. Configure them in your `~/.pair-review/config.json` by adding a `providers.pi.models` array with at least one model definition. Pi supports many providers (Google, Anthropic, OpenAI, etc.) via its `--provider` and `--model` flags. See the [AI Provider Configuration](#ai-provider-configuration) section and `config.example.json` for examples.
1207
1212
 
1213
+ **Q: How do I use OMP (Oh My Pi) as my AI provider?**
1214
+ A: OMP works out of the box: the built-in `default` mode uses whatever model your OMP configuration (`~/.omp/agent/config.yml`) selects. To pin specific models, add a `providers.omp.models` array — each model's `cli_model` is passed to `omp --model` verbatim, which fuzzy-matches and accepts `provider/model` strings (run `omp models` to list the catalog). During reviews pair-review disables OMP's advisor runtime by default (it injects notes into each turn, adding cost and nondeterminism); set `"advisor": true` under `providers.omp` to enable it.
1215
+
1208
1216
  **Q: Why does chat use Pi instead of Claude or other providers?**
1209
1217
  A: Pi provides persistent interactive sessions with a full agent — it can read files and run commands in the context of the codebase. Pi is model-agnostic and uses your existing provider subscriptions — no separate API keys needed.
1210
1218
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@in-the-loop-labs/pair-review",
3
- "version": "5.1.1",
3
+ "version": "5.2.0",
4
4
  "description": "Your AI-powered code review partner - Close the feedback loop with AI coding agents",
5
5
  "main": "src/server.js",
6
6
  "bin": {
@@ -52,7 +52,8 @@
52
52
  "copilot",
53
53
  "codex",
54
54
  "antigravity",
55
- "muse"
55
+ "muse",
56
+ "oh-my-pi"
56
57
  ],
57
58
  "author": "Tim Perkins",
58
59
  "license": "Apache-2.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pair-review",
3
- "version": "5.1.1",
3
+ "version": "5.2.0",
4
4
  "description": "pair-review app integration — Open PRs and local changes in the pair-review web UI, run server-side AI analysis, and address review feedback. Requires the pair-review MCP server.",
5
5
  "author": {
6
6
  "name": "in-the-loop-labs",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-critic",
3
- "version": "5.1.1",
3
+ "version": "5.2.0",
4
4
  "description": "AI-powered code review analysis — Run three-level AI analysis directly in your coding agent. Works standalone, no server required.",
5
5
  "author": {
6
6
  "name": "in-the-loop-labs",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pair-loop",
3
- "version": "5.1.1",
3
+ "version": "5.2.0",
4
4
  "description": "Agent-orchestrated review loop — implement, review with pair-review multi-model councils via the headless CLI, triage, fix, and repeat until a final review returns no blockers. MCP-independent.",
5
5
  "author": {
6
6
  "name": "in-the-loop-labs",
package/public/index.html CHANGED
@@ -1394,11 +1394,14 @@
1394
1394
  <div class="tab-pane active" id="pr-tab">
1395
1395
  <div class="start-review-section">
1396
1396
  <form class="start-review-form" id="start-review-form">
1397
+ <!-- The placeholder is host-neutral until /api/config
1398
+ resolves; index.js rewrites it to name the configured
1399
+ hosts (GitHub, Graphite when enabled, any alt hosts). -->
1397
1400
  <input
1398
1401
  type="text"
1399
1402
  class="start-review-input"
1400
1403
  id="pr-url-input"
1401
- placeholder="Enter GitHub or Graphite PR URL"
1404
+ placeholder="Enter PR URL"
1402
1405
  autocomplete="off"
1403
1406
  spellcheck="false"
1404
1407
  >
@@ -1532,7 +1535,7 @@
1532
1535
  <pre><code class="cmd-example" data-args="123"></code></pre>
1533
1536
 
1534
1537
  <h3>Review a PR by URL</h3>
1535
- <p>From anywhere, using a full GitHub or Graphite URL:</p>
1538
+ <p>From anywhere, using a full <span data-pr-host-list>GitHub</span> URL:</p>
1536
1539
  <pre><code class="cmd-example" data-args="https://github.com/owner/repo/pull/123"></code></pre>
1537
1540
 
1538
1541
  <h3>Review Local Changes</h3>
@@ -116,14 +116,94 @@
116
116
  // (window.encodeBase64Utf8 / window.getRepoStorageKey), shared with pr.js so the
117
117
  // per-repo keys this page writes stay byte-identical to those the PR page reads.
118
118
 
119
- const LOCAL_REVIEW_PATH_URL_ERROR = 'Local reviews require a filesystem path, not a URL. Pass GitHub or Graphite URLs as PR review inputs instead.';
119
+ // Hosts named in URL copy, from /api/config's `pr_host_list`, which the
120
+ // SERVER formats (GitHub always; Graphite only when enable_graphite; each alt
121
+ // host's links.external.name). Taking the pre-joined string rather than the
122
+ // array keeps the Oxford-comma formatting in exactly one place —
123
+ // src/links/host-names.js — so this copy cannot drift from the
124
+ // identically-worded server-side errors.
125
+ //
126
+ // null until /api/config resolves. The copy then reads host-neutral rather
127
+ // than naming the built-ins, which would claim an alt host's URLs are
128
+ // unsupported when they are accepted (matching localReviewPathUrlError() in
129
+ // src/utils/local-path-input.js for its config-free callers).
130
+ let prHostList = null;
131
+
132
+ // Hostnames recognised as scheme-less PR URLs. Seeded with the built-ins and
133
+ // replaced from /api/config's `pr_url_hostnames`, which adds every
134
+ // configured alt host. Mirrors resolveUrlLikeHostnames() server-side.
135
+ let prUrlHostnames = ['github.com', 'app.graphite.dev', 'app.graphite.com'];
136
+
137
+ /** "GitHub " / "GitHub or Graphite " while the host list is known, else "". */
138
+ function prHostPrefix() {
139
+ return prHostList ? prHostList + ' ' : '';
140
+ }
141
+
142
+ function localReviewPathUrlError() {
143
+ return 'Local reviews require a filesystem path, not a URL. '
144
+ + 'Pass ' + (prHostList ? prHostList + ' URLs' : 'PR URLs')
145
+ + ' as PR review inputs instead.';
146
+ }
147
+
148
+ /**
149
+ * Adopt the server-formatted host list and refresh the copy that names it.
150
+ *
151
+ * Called once /api/config resolves. The static markup ships host-neutral
152
+ * ("Enter PR URL", "a GitHub URL") so nothing flashes a host list that the
153
+ * installation does not actually support.
154
+ *
155
+ * @param {Object} config - /api/config payload
156
+ */
157
+ function applyPrHostList(config) {
158
+ if (!config) return;
159
+ if (Array.isArray(config.pr_url_hostnames) && config.pr_url_hostnames.length > 0) {
160
+ prUrlHostnames = config.pr_url_hostnames;
161
+ }
162
+ if (typeof config.pr_host_list !== 'string' || !config.pr_host_list) return;
163
+ prHostList = config.pr_host_list;
164
+
165
+ const urlInput = document.getElementById('pr-url-input');
166
+ if (urlInput) urlInput.placeholder = 'Enter ' + prHostList + ' PR URL';
167
+
168
+ document.querySelectorAll('[data-pr-host-list]').forEach(el => {
169
+ el.textContent = prHostList;
170
+ });
171
+ }
172
+
173
+ /**
174
+ * Drop the "this element is showing the URL error" marker.
175
+ *
176
+ * Called from every writer that replaces or hides the message, so the flag
177
+ * cannot outlive the message it describes — otherwise an unrelated error
178
+ * (e.g. a failed directory picker) would be dismissed by the next keystroke.
179
+ *
180
+ * @param {HTMLElement} errorEl
181
+ */
182
+ function clearLocalPathUrlErrorFlag(errorEl) {
183
+ if (errorEl) delete errorEl.dataset.localPathUrlError;
184
+ }
185
+
186
+ /**
187
+ * Show the "that's a URL, not a path" error and mark the element so
188
+ * handleLocalPathInput can clear it without comparing message text.
189
+ */
190
+ function showLocalPathUrlError() {
191
+ // showError() clears the flag first, so setting it AFTER is what makes it
192
+ // describe THIS message rather than a previous one.
193
+ showError('local', localReviewPathUrlError());
194
+ const errorEl = document.getElementById('start-review-error-local');
195
+ if (errorEl) errorEl.dataset.localPathUrlError = 'true';
196
+ }
120
197
 
121
198
  function isUrlLikeLocalReviewPath(value) {
122
199
  if (!value || typeof value !== 'string') return false;
123
200
  const trimmed = value.trim();
124
201
  if (!trimmed) return false;
125
202
  if (/^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed)) return true;
126
- if (/^(?:github\.com|app\.graphite\.(?:dev|com))\//i.test(trimmed)) return true;
203
+ // Require a path separator so a bare hostname-shaped directory name is
204
+ // not mistaken for a URL.
205
+ const lower = trimmed.toLowerCase();
206
+ if (prUrlHostnames.some(hostname => lower.startsWith(hostname + '/'))) return true;
127
207
  // Keep this aligned with src/utils/local-path-input.js: only a leading
128
208
  // user@host:path token is treated as an SSH-style remote.
129
209
  if (/^[^@/\\\s]+@[^:/\\\s]+:[^\s]+$/.test(trimmed)) return true;
@@ -172,6 +252,7 @@
172
252
  const elId = tab === 'pr' ? 'start-review-error-pr' : 'start-review-error-local';
173
253
  const errorEl = document.getElementById(elId);
174
254
  if (errorEl) {
255
+ clearLocalPathUrlErrorFlag(errorEl);
175
256
  errorEl.textContent = message;
176
257
  errorEl.classList.remove('info');
177
258
  errorEl.classList.add('visible');
@@ -188,6 +269,7 @@
188
269
  const elId = tab === 'pr' ? 'start-review-error-pr' : 'start-review-error-local';
189
270
  const errorEl = document.getElementById(elId);
190
271
  if (errorEl) {
272
+ clearLocalPathUrlErrorFlag(errorEl);
191
273
  errorEl.textContent = message;
192
274
  errorEl.classList.add('visible', 'info');
193
275
  }
@@ -885,7 +967,10 @@
885
967
 
886
968
  // Clear previous errors/info messages
887
969
  const errorEl = document.getElementById('start-review-error-local');
888
- if (errorEl) errorEl.classList.remove('visible', 'info');
970
+ if (errorEl) {
971
+ errorEl.classList.remove('visible', 'info');
972
+ clearLocalPathUrlErrorFlag(errorEl);
973
+ }
889
974
 
890
975
  if (!pathValue) {
891
976
  showError('local', 'Please enter a directory path');
@@ -894,7 +979,7 @@
894
979
  }
895
980
 
896
981
  if (isUrlLikeLocalReviewPath(pathValue)) {
897
- showError('local', LOCAL_REVIEW_PATH_URL_ERROR);
982
+ showLocalPathUrlError();
898
983
  input.focus();
899
984
  return;
900
985
  }
@@ -912,12 +997,16 @@
912
997
  if (!input || !errorEl) return;
913
998
 
914
999
  if (isUrlLikeLocalReviewPath(input.value)) {
915
- showError('local', LOCAL_REVIEW_PATH_URL_ERROR);
1000
+ showLocalPathUrlError();
916
1001
  return;
917
1002
  }
918
1003
 
919
- if (errorEl.textContent === LOCAL_REVIEW_PATH_URL_ERROR) {
1004
+ // Flagged rather than text-compared: the message names the configured
1005
+ // hosts, so it can change between being shown and being cleared (the
1006
+ // host list arrives asynchronously from /api/config).
1007
+ if (errorEl.dataset.localPathUrlError === 'true') {
920
1008
  errorEl.classList.remove('visible', 'info');
1009
+ clearLocalPathUrlErrorFlag(errorEl);
921
1010
  }
922
1011
  }
923
1012
 
@@ -1313,7 +1402,7 @@
1313
1402
 
1314
1403
  // Validate input
1315
1404
  if (!url) {
1316
- showError('pr', 'Please enter a GitHub PR URL');
1405
+ showError('pr', 'Please enter a ' + prHostPrefix() + 'PR URL');
1317
1406
  input.focus();
1318
1407
  return;
1319
1408
  }
@@ -1325,7 +1414,7 @@
1325
1414
  const parsed = await parsePRUrl(url);
1326
1415
  if (!parsed) {
1327
1416
  setFormLoading('pr', false);
1328
- showError('pr', 'Invalid PR URL. Please enter a GitHub or Graphite PR URL (e.g., https://github.com/owner/repo/pull/123)');
1417
+ showError('pr', 'Invalid PR URL. Please enter a ' + prHostPrefix() + 'PR URL (e.g., https://github.com/owner/repo/pull/123)');
1329
1418
  input.focus();
1330
1419
  return;
1331
1420
  }
@@ -1397,6 +1486,7 @@
1397
1486
  window.__pairReview.modelOverride = config.model_override || null;
1398
1487
  window.__pairReview.hasGithubToken = Boolean(config.has_github_token);
1399
1488
  window.__pairReview.enableGraphite = config.enable_graphite === true;
1489
+ applyPrHostList(config);
1400
1490
  window.__pairReview.chatSpinner = config.chat_spinner || 'dots';
1401
1491
  window.__pairReview.chatEnterToSend = config.chat_enter_to_send !== false;
1402
1492
 
@@ -2592,7 +2682,14 @@
2592
2682
  if (typeof module !== 'undefined' && module.exports) {
2593
2683
  module.exports = {
2594
2684
  buildReviewUrlsFromRows: buildReviewUrlsFromRows,
2595
- getSelectedCollectionRows: getSelectedCollectionRows
2685
+ getSelectedCollectionRows: getSelectedCollectionRows,
2686
+ applyPrHostList: applyPrHostList,
2687
+ isUrlLikeLocalReviewPath: isUrlLikeLocalReviewPath,
2688
+ localReviewPathUrlError: localReviewPathUrlError,
2689
+ showError: showError,
2690
+ showInfo: showInfo,
2691
+ showLocalPathUrlError: showLocalPathUrlError,
2692
+ handleLocalPathInput: handleLocalPathInput
2596
2693
  };
2597
2694
  }
2598
2695
 
package/src/ai/index.js CHANGED
@@ -55,6 +55,7 @@ require('./copilot-provider');
55
55
  require('./opencode-provider');
56
56
  require('./cursor-agent-provider');
57
57
  require('./pi-provider');
58
+ require('./omp-provider');
58
59
  require('./muse-provider');
59
60
 
60
61
  // Export the unified API
@@ -0,0 +1,13 @@
1
+ # Copyright 2026 Tim Perkins (tjwp) | SPDX-License-Identifier: Apache-2.0
2
+ #
3
+ # OMP config overlay loaded via `omp --config` for every pair-review analysis
4
+ # run. Review runs must not depend on the user's global ~/.omp/agent/config.yml
5
+ # for these settings.
6
+ #
7
+ # advisor.enabled: the advisor runtime passively reviews each turn and injects
8
+ # notes into the conversation. That adds cost and nondeterminism to analysis
9
+ # runs, so it is disabled by default. Set `"advisor": true` in
10
+ # config.json providers.omp to opt back in (pair-review then passes --advisor
11
+ # instead of this overlay).
12
+ advisor:
13
+ enabled: false
@@ -0,0 +1,279 @@
1
+ // Copyright 2026 Tim Perkins (tjwp) | SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * OMP (Oh My Pi) AI Provider
4
+ *
5
+ * Implements the AI provider interface for the OMP coding agent CLI, a fork
6
+ * of the Pi coding agent. Uses `omp -p --mode json` for non-interactive
7
+ * execution with structured output.
8
+ *
9
+ * OMP emits the same JSONL event stream as Pi (session, turn_start,
10
+ * message_start, message_update, message_end, tool_execution_start/update/end,
11
+ * agent_end, etc.), so parsing is shared with the Pi provider via pi-format.js
12
+ * and the process lifecycle (spawn/parse/abort/timeout) via PiStyleProvider
13
+ * (pi-style-provider.js). This file defines OMP's CLI surface: argv
14
+ * construction, model resolution, and env merging.
15
+ *
16
+ * Differences from the Pi provider:
17
+ * - Model selection: OMP's --model accepts fuzzy matches and full
18
+ * `provider/model` strings directly (--provider is legacy), so cli_model
19
+ * values are passed to --model verbatim instead of being split.
20
+ * - Advisor runtime: OMP can passively review each turn and inject notes
21
+ * (advisor.enabled in ~/.omp/agent/config.yml). Reviews disable it by
22
+ * default via a bundled --config overlay; set `"advisor": true` in
23
+ * config.json providers.omp to opt in (passes --advisor instead).
24
+ * - Tools: OMP's read-only tool set is read,bash,grep,glob (no find/ls).
25
+ * - No bundled task extension or --no-prompt-templates flag (Pi-specific).
26
+ *
27
+ * OMP provides a 'default' analysis mode and supports additional models via
28
+ * config.providers.omp.models in ~/.pair-review/config.json.
29
+ */
30
+
31
+ const path = require('path');
32
+ const { registerProvider } = require('./provider');
33
+ const { PiStyleProvider } = require('./pi-style-provider');
34
+
35
+ // Config overlay that disables the advisor runtime for review runs.
36
+ // Loaded with `--config`, which merges on top of ~/.omp/agent/config.yml,
37
+ // so reviews stay deterministic even when the user enables the advisor
38
+ // globally. There is no --no-advisor flag, so the overlay is the only
39
+ // per-run off switch.
40
+ const REVIEW_CONFIG_OVERLAY_PATH = path.join(__dirname, 'omp', 'review-config.yml');
41
+
42
+ /**
43
+ * OMP model definitions
44
+ *
45
+ * OMP delegates model selection to the user's OMP configuration
46
+ * (~/.omp/agent/config.yml). The built-in 'default' entry uses whatever model
47
+ * the user has configured as their OMP default.
48
+ *
49
+ * Users can add specific models via config.json providers.omp.models.
50
+ * cli_model values are passed verbatim to --model, which fuzzy-matches
51
+ * ("opus", "gpt-5.2") and accepts full `provider/model` strings
52
+ * (e.g., 'anthropic/claude-opus-5'). Run `omp models` to list the catalog.
53
+ */
54
+ const OMP_MODELS = [
55
+ {
56
+ id: 'default',
57
+ cli_model: null,
58
+ name: 'Default',
59
+ tier: 'balanced',
60
+ tagline: 'Your OMP Default',
61
+ description: 'Uses your configured OMP default model',
62
+ badge: 'Default',
63
+ badgeClass: 'badge-recommended',
64
+ default: true
65
+ }
66
+ ];
67
+
68
+ class OmpProvider extends PiStyleProvider {
69
+ /**
70
+ * @param {string|null} [model='default'] - Model identifier or null/undefined for default mode
71
+ * @param {Object} configOverrides - Config overrides from providers config
72
+ * @param {string} configOverrides.command - Custom CLI command
73
+ * @param {string[]} configOverrides.extra_args - Additional CLI arguments
74
+ * @param {Object} configOverrides.env - Additional environment variables
75
+ * @param {Object[]} configOverrides.models - Custom model definitions
76
+ * @param {boolean} [configOverrides.load_skills=true] - When false, adds --no-skills to suppress skill auto-discovery
77
+ * @param {boolean} [configOverrides.advisor=false] - When true, enables OMP's advisor runtime
78
+ * (--advisor) instead of disabling it via the bundled config overlay
79
+ */
80
+ constructor(model, configOverrides = {}) {
81
+ super(model || 'default');
82
+
83
+ // Store config overrides early so _resolveCliModelArgs can use them
84
+ this.configOverrides = configOverrides;
85
+
86
+ // Resolve model configuration from built-in definitions and config overrides
87
+ const resolvedModel = model || 'default';
88
+ const builtIn = OMP_MODELS.find(m => m.id === resolvedModel);
89
+ const configModel = configOverrides.models?.find(m => m.id === resolvedModel);
90
+
91
+ // Conditionally include --model (null = suppress, let OMP use its default)
92
+ const cliModelArgs = this._resolveCliModelArgs(resolvedModel);
93
+
94
+ // Command precedence: ENV > config > default
95
+ const envCmd = process.env.PAIR_REVIEW_OMP_CMD;
96
+ const configCmd = configOverrides.command;
97
+ const ompCmd = envCmd || configCmd || 'omp';
98
+
99
+ // For multi-word commands, use shell mode
100
+ this.useShell = ompCmd.includes(' ');
101
+
102
+ // ============================================================================
103
+ // SECURITY: OMP CLI tool permissions
104
+ // ============================================================================
105
+ //
106
+ // OMP's --tools flag controls which built-in tools are available to the model.
107
+ // When --tools is specified, ONLY the listed tools are loaded; unlisted tools
108
+ // (edit, write) are not available at all — they cannot be requested or executed.
109
+ // MCP tools configured in the user's OMP setup are likewise excluded because
110
+ // they are not on the allowlist.
111
+ //
112
+ // Enabled tools: read, bash, grep, glob
113
+ // Excluded tools: edit, write (file modification), task, MCP tools
114
+ //
115
+ // LIMITATION: The `bash` tool grants arbitrary shell command execution.
116
+ // Unlike Claude (Bash(git diff*) prefixes) or Copilot (shell(git diff) prefixes),
117
+ // OMP does not support fine-grained bash command restrictions. The model could
118
+ // theoretically execute destructive commands (rm, git push, etc.).
119
+ //
120
+ // MITIGATION STRATEGY:
121
+ // 1. Prompt engineering: Analysis prompts explicitly instruct the AI to only
122
+ // use read-only operations and never modify files
123
+ // 2. Worktree isolation: Analysis runs in a git worktree, limiting blast radius
124
+ // 3. Tool exclusion: edit and write tools are not loaded at all
125
+ //
126
+ // If OMP CLI adds prefix-based bash restrictions in the future, they should
127
+ // be adopted here to match the granularity of other providers.
128
+ // ============================================================================
129
+
130
+ // omp -p --mode json --model <model> --tools read,bash,grep,glob <prompt-via-@file>
131
+ // -p: Non-interactive mode (process prompt and exit)
132
+ // --mode json: Output JSONL events
133
+ // --model: Specify the model (omitted when cli_model is null to use OMP's default)
134
+ // --tools: Enable read-only tools for Level 2/3 analysis (excludes edit,write for safety)
135
+ // --no-session: Each omp invocation is an ephemeral analysis — there's no need to
136
+ // persist session state between runs. Set PAIR_REVIEW_OMP_SESSION=1
137
+ // to enable session saving for debugging (sessions saved under ~/.omp/).
138
+ // Advisor: disabled by default via the bundled --config overlay (see
139
+ // REVIEW_CONFIG_OVERLAY_PATH); configOverrides.advisor === true opts in via --advisor.
140
+ // Build args: base args + built-in extra_args + provider extra_args + model extra_args
141
+ // In yolo mode, omit --tools entirely to allow all tools (including edit, write)
142
+ // load_skills (default true): when false, adds --no-skills to suppress skill
143
+ // auto-discovery.
144
+ const loadSkills = configOverrides.load_skills !== false;
145
+ const sessionArgs = process.env.PAIR_REVIEW_OMP_SESSION ? [] : ['--no-session'];
146
+ const skillArgs = loadSkills ? [] : ['--no-skills'];
147
+ const advisorArgs = configOverrides.advisor === true
148
+ ? ['--advisor']
149
+ : ['--config', REVIEW_CONFIG_OVERLAY_PATH];
150
+ let baseArgs;
151
+ if (configOverrides.yolo) {
152
+ baseArgs = ['-p', '--mode', 'json', ...cliModelArgs, ...sessionArgs,
153
+ ...advisorArgs, ...skillArgs];
154
+ } else {
155
+ baseArgs = ['-p', '--mode', 'json', ...cliModelArgs, '--tools', 'read,bash,grep,glob',
156
+ ...sessionArgs, ...advisorArgs, ...skillArgs];
157
+ }
158
+ const builtInArgs = builtIn?.extra_args || [];
159
+ const providerArgs = configOverrides.extra_args || [];
160
+ const modelArgs = configModel?.extra_args || [];
161
+
162
+ // Store base command (used by the shared execute/extraction/availability
163
+ // paths in PiStyleProvider) and args (prompt added in execute)
164
+ this.cliCmd = ompCmd;
165
+ this.cliName = 'OMP';
166
+ this.extraEnv = this._resolveEnvForModel(resolvedModel);
167
+ this.baseArgs = [...baseArgs, ...builtInArgs, ...providerArgs, ...modelArgs];
168
+ }
169
+
170
+ /**
171
+ * Resolve the extra env vars for a given model.
172
+ * Merge order: built-in model → provider config → per-model config.
173
+ * Later entries override earlier ones, so model-specific settings take
174
+ * precedence over provider-level ones. Unlike Pi, no task-extension env
175
+ * vars (PI_CMD, PI_TASK_MAX_DEPTH) are set — OMP has no bundled extension.
176
+ *
177
+ * Used both by the constructor (analysis model) and by the shared
178
+ * getExtractionConfig() (extraction model), so the extraction fallback picks
179
+ * up env configured on its own (possibly fast-tier) model.
180
+ *
181
+ * @param {string} modelId - Model identifier
182
+ * @returns {Object} Env vars to merge into the child environment
183
+ */
184
+ _resolveEnvForModel(modelId) {
185
+ const builtIn = OMP_MODELS.find(m => m.id === modelId);
186
+ const configModel = this.configOverrides?.models?.find(m => m.id === modelId);
187
+ return {
188
+ ...(builtIn?.env || {}),
189
+ ...(this.configOverrides?.env || {}),
190
+ ...(configModel?.env || {})
191
+ };
192
+ }
193
+
194
+ /**
195
+ * Resolve the --model CLI arguments for a given model ID.
196
+ * Checks config model overrides, then built-in definitions, then falls back
197
+ * to the raw ID. Returns an empty array when cli_model is null (OMP uses its
198
+ * configured default).
199
+ *
200
+ * Unlike Pi, `provider/model` strings are passed to --model verbatim: OMP's
201
+ * --model fuzzy-matches and accepts full provider-qualified names directly
202
+ * (its --provider flag is legacy).
203
+ *
204
+ * @param {string|null} modelId - Model identifier
205
+ * @returns {string[]} CLI arguments (e.g., ['--model', 'x'] or [])
206
+ */
207
+ _resolveCliModelArgs(modelId) {
208
+ const builtIn = OMP_MODELS.find(m => m.id === modelId);
209
+ const configModel = this.configOverrides?.models?.find(m => m.id === modelId);
210
+ const resolvedCliModel = configModel?.cli_model !== undefined
211
+ ? configModel.cli_model
212
+ : (builtIn?.cli_model !== undefined ? builtIn.cli_model : modelId);
213
+ if (resolvedCliModel === null) return [];
214
+ return ['--model', resolvedCliModel];
215
+ }
216
+
217
+ /**
218
+ * Build args for OMP CLI execution, applying provider and model extra_args.
219
+ * This ensures consistent arg construction for both execute() and getExtractionConfig().
220
+ *
221
+ * @param {string} model - The model identifier to use
222
+ * @returns {string[]} Complete args array for the CLI
223
+ */
224
+ buildArgsForModel(model) {
225
+ const cliModelArgs = this._resolveCliModelArgs(model);
226
+
227
+ // Note: built-in extra_args are intentionally excluded for extraction.
228
+ // Extraction is a simple JSON-parsing task that doesn't need
229
+ // analysis-specific configuration.
230
+
231
+ // Base args for omp non-interactive JSON mode (extraction only — no tools needed).
232
+ // The advisor overlay is always applied here: advisor notes cannot help a
233
+ // JSON-parsing task, they only add cost, so extraction never opts in even
234
+ // when configOverrides.advisor is true.
235
+ // load_skills: mirror the analysis run — when the user disabled skill
236
+ // auto-discovery, the extraction fallback must not re-enable it.
237
+ const sessionArgs = process.env.PAIR_REVIEW_OMP_SESSION ? [] : ['--no-session'];
238
+ const skillArgs = this.configOverrides?.load_skills === false ? ['--no-skills'] : [];
239
+ const baseArgs = ['-p', '--mode', 'json', ...cliModelArgs, '--no-tools', ...sessionArgs,
240
+ '--config', REVIEW_CONFIG_OVERLAY_PATH, ...skillArgs];
241
+ const configModel = this.configOverrides?.models?.find(m => m.id === model);
242
+ const providerArgs = this.configOverrides?.extra_args || [];
243
+ const modelArgs = configModel?.extra_args || [];
244
+ return [...baseArgs, ...providerArgs, ...modelArgs];
245
+ }
246
+
247
+ static getProviderName() {
248
+ return 'OMP';
249
+ }
250
+
251
+ static getProviderId() {
252
+ return 'omp';
253
+ }
254
+
255
+ static getModels() {
256
+ return OMP_MODELS;
257
+ }
258
+
259
+ static getDefaultModel() {
260
+ const defaultModel = OMP_MODELS.find(m => m.default);
261
+ return defaultModel ? defaultModel.id : null;
262
+ }
263
+
264
+ static getInstallInstructions() {
265
+ return 'Install OMP (Oh My Pi): npm install -g @oh-my-pi/pi-coding-agent\n' +
266
+ 'Or visit: https://github.com/can1357/oh-my-pi';
267
+ }
268
+
269
+ /** Default timeout in ms (15 minutes) — matches Pi, which OMP is a fork of */
270
+ static defaultTimeout = 900000;
271
+ }
272
+
273
+ // Register this provider
274
+ registerProvider('omp', OmpProvider);
275
+
276
+ module.exports = OmpProvider;
277
+ // Test-only export. Underscore prefix signals an internal constant that should
278
+ // not be consumed from production code paths.
279
+ module.exports._REVIEW_CONFIG_OVERLAY_PATH = REVIEW_CONFIG_OVERLAY_PATH;