@in-the-loop-labs/pair-review 5.1.0 → 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 +14 -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/plugin-pair-loop/skills/loop/SKILL.md +21 -6
- package/public/css/pr.css +2 -2
- package/public/index.html +5 -2
- package/public/js/index.js +106 -9
- package/src/ai/analyzer.js +191 -27
- 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/links/host-names.js +200 -0
- package/src/local-review.js +7 -3
- package/src/main.js +21 -1
- package/src/review-config.js +81 -5
- package/src/routes/analyses.js +6 -2
- package/src/routes/config.js +16 -0
- package/src/routes/local.js +7 -6
- package/src/routes/mcp.js +5 -2
- package/src/routes/pr.js +8 -5
- package/src/routes/setup.js +1 -1
- package/src/routes/shared.js +27 -0
- package/src/routes/stack-analysis.js +4 -1
- package/src/settings/registry.js +1 -1
- package/src/setup/local-setup.js +5 -3
- package/src/single-port.js +1 -1
- package/src/utils/json-extractor.js +162 -41
- package/src/utils/local-path-input.js +64 -8
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// Copyright 2026 Tim Perkins (tjwp) | SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* Known PR Host Names
|
|
4
|
+
*
|
|
5
|
+
* Derives the list of code hosts pair-review will accept a pull request from,
|
|
6
|
+
* for use in copy that is rendered BEFORE any repository has been resolved —
|
|
7
|
+
* the landing-page PR input, the URL validation errors, and the
|
|
8
|
+
* "that's a URL, not a path" local-review error.
|
|
9
|
+
*
|
|
10
|
+
* `resolveHostName()` in ./repo-links.js answers the same question for a
|
|
11
|
+
* KNOWN repo. This module answers it for the whole configuration, which is
|
|
12
|
+
* what the pre-resolution surfaces need: at the point where a user is typing
|
|
13
|
+
* a URL there is no repo to look up yet.
|
|
14
|
+
*
|
|
15
|
+
* The list is derived, never hardcoded:
|
|
16
|
+
*
|
|
17
|
+
* - "GitHub" is always present. Unconfigured repos fall back to github.com
|
|
18
|
+
* with the top-level credentials, so github.com is always reachable.
|
|
19
|
+
* - "Graphite" appears only when `enable_graphite` is true. It defaults to
|
|
20
|
+
* false, so a default install must not advertise it.
|
|
21
|
+
* - Each distinct `repos[*].links.external.name` for a repo that also sets
|
|
22
|
+
* `api_host` — the alt-host display name (e.g. "Meteorite").
|
|
23
|
+
*
|
|
24
|
+
* Alt-host repos with no `links.external.name` resolve to "GitHub" via
|
|
25
|
+
* `resolveHostName` and are therefore de-duplicated away rather than
|
|
26
|
+
* appearing twice.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
const { resolveHostName } = require('./repo-links');
|
|
30
|
+
|
|
31
|
+
const DEFAULT_HOST_NAME = 'GitHub';
|
|
32
|
+
const GRAPHITE_HOST_NAME = 'Graphite';
|
|
33
|
+
|
|
34
|
+
// Hostnames whose PR URLs are recognised even without a scheme. Alt hosts are
|
|
35
|
+
// appended from config by resolveUrlLikeHostnames().
|
|
36
|
+
const BUILTIN_PR_HOSTNAMES = Object.freeze([
|
|
37
|
+
'github.com',
|
|
38
|
+
'app.graphite.dev',
|
|
39
|
+
'app.graphite.com'
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Iterate every configured repo entry.
|
|
44
|
+
*
|
|
45
|
+
* `loadConfig()` lowercases the legacy `monorepos` map, merges it into `repos`,
|
|
46
|
+
* and deletes it, so for any loaded config that branch never fires — it is here
|
|
47
|
+
* only for raw/hand-built configs, mirroring `getRepoConfig`'s equivalent
|
|
48
|
+
* fallback.
|
|
49
|
+
*
|
|
50
|
+
* @param {Object} config
|
|
51
|
+
* @returns {Array<[string, Object]>} `[repoKey, repoEntry]` pairs
|
|
52
|
+
*/
|
|
53
|
+
function configuredRepoEntries(config) {
|
|
54
|
+
const entries = [];
|
|
55
|
+
for (const section of [config.repos, config.monorepos]) {
|
|
56
|
+
if (!section || typeof section !== 'object') continue;
|
|
57
|
+
for (const [repoKey, repoEntry] of Object.entries(section)) {
|
|
58
|
+
if (!repoEntry || typeof repoEntry !== 'object') continue;
|
|
59
|
+
entries.push([repoKey, repoEntry]);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return entries;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* True when a repo entry declares an alt host.
|
|
67
|
+
*
|
|
68
|
+
* @param {Object} repoEntry
|
|
69
|
+
* @returns {boolean}
|
|
70
|
+
*/
|
|
71
|
+
function hasApiHost(repoEntry) {
|
|
72
|
+
return typeof repoEntry.api_host === 'string' && repoEntry.api_host.length > 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Resolve the ordered, de-duplicated list of host display names that
|
|
77
|
+
* pair-review can accept PR URLs for.
|
|
78
|
+
*
|
|
79
|
+
* @param {Object} [config] - Configuration object from loadConfig()
|
|
80
|
+
* @returns {string[]} Non-empty list, always starting with "GitHub"
|
|
81
|
+
*/
|
|
82
|
+
function resolveKnownHostNames(config) {
|
|
83
|
+
const safeConfig = (config && typeof config === 'object') ? config : {};
|
|
84
|
+
|
|
85
|
+
const names = [DEFAULT_HOST_NAME];
|
|
86
|
+
if (safeConfig.enable_graphite === true) names.push(GRAPHITE_HOST_NAME);
|
|
87
|
+
|
|
88
|
+
const seen = new Set(names.map(name => name.toLowerCase()));
|
|
89
|
+
|
|
90
|
+
for (const [repoKey, repoEntry] of configuredRepoEntries(safeConfig)) {
|
|
91
|
+
if (!hasApiHost(repoEntry)) continue;
|
|
92
|
+
// Route through resolveHostName so the global list agrees with the
|
|
93
|
+
// per-repo name used in the submit toast and draft notices — including
|
|
94
|
+
// its validation (a `name` without a usable `label`/`url_template` pair
|
|
95
|
+
// does not register as an external link, and so does not appear here).
|
|
96
|
+
const name = resolveHostName(safeConfig, repoKey);
|
|
97
|
+
const dedupeKey = name.toLowerCase();
|
|
98
|
+
if (seen.has(dedupeKey)) continue;
|
|
99
|
+
seen.add(dedupeKey);
|
|
100
|
+
names.push(name);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return names;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Join host names into a user-facing fragment with an Oxford comma:
|
|
108
|
+
* "GitHub", "GitHub or Graphite", "GitHub, Graphite, or Meteorite".
|
|
109
|
+
*
|
|
110
|
+
* @param {string[]} names
|
|
111
|
+
* @returns {string}
|
|
112
|
+
*/
|
|
113
|
+
function formatHostList(names) {
|
|
114
|
+
const list = Array.isArray(names) ? names.filter(name => typeof name === 'string' && name) : [];
|
|
115
|
+
if (list.length === 0) return DEFAULT_HOST_NAME;
|
|
116
|
+
if (list.length === 1) return list[0];
|
|
117
|
+
if (list.length === 2) return `${list[0]} or ${list[1]}`;
|
|
118
|
+
return `${list.slice(0, -1).join(', ')}, or ${list[list.length - 1]}`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Convenience wrapper: the formatted host fragment for a config.
|
|
123
|
+
*
|
|
124
|
+
* @param {Object} [config]
|
|
125
|
+
* @returns {string}
|
|
126
|
+
*/
|
|
127
|
+
function resolveHostListText(config) {
|
|
128
|
+
return formatHostList(resolveKnownHostNames(config));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Hostnames (lowercased) that belong to configured alt hosts, recorded both
|
|
133
|
+
* with and without an explicit port so either shape of paste is recognised.
|
|
134
|
+
*
|
|
135
|
+
* Derived from each alt-host repo's `api_host` and, when present, the web
|
|
136
|
+
* host in `links.external.url_template` — the API host and the web host are
|
|
137
|
+
* frequently different domains, and a user pastes the latter.
|
|
138
|
+
*
|
|
139
|
+
* @param {Object} [config]
|
|
140
|
+
* @returns {string[]}
|
|
141
|
+
*/
|
|
142
|
+
function resolveAltHostHostnames(config) {
|
|
143
|
+
const safeConfig = (config && typeof config === 'object') ? config : {};
|
|
144
|
+
const hostnames = new Set();
|
|
145
|
+
|
|
146
|
+
const add = (value) => {
|
|
147
|
+
if (typeof value !== 'string' || !value) return;
|
|
148
|
+
// `api_host` is only validated as a non-empty string, so a bare
|
|
149
|
+
// `ghe.example.com` is a legitimate configuration — give it a scheme so
|
|
150
|
+
// `new URL()` can parse it rather than throwing into the catch below.
|
|
151
|
+
const absolute = /^[a-z][a-z0-9+.-]*:\/\//i.test(value) ? value : `https://${value}`;
|
|
152
|
+
let url;
|
|
153
|
+
try {
|
|
154
|
+
url = new URL(absolute);
|
|
155
|
+
} catch {
|
|
156
|
+
// Not parseable even with a scheme — nothing to derive.
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
// A template can carry a placeholder in its authority section
|
|
160
|
+
// (`https://{owner}.example/…` parses, yielding hostname `{owner}.example`);
|
|
161
|
+
// no pasted input can start with that, so drop it rather than ship junk.
|
|
162
|
+
if (!url.hostname || url.hostname.includes('{')) return;
|
|
163
|
+
// `host` keeps a non-default port — what a user actually pastes for
|
|
164
|
+
// `https://ghe.example.com:8443/…`; `hostname` drops it.
|
|
165
|
+
hostnames.add(url.host.toLowerCase());
|
|
166
|
+
hostnames.add(url.hostname.toLowerCase());
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
for (const [, repoEntry] of configuredRepoEntries(safeConfig)) {
|
|
170
|
+
if (!hasApiHost(repoEntry)) continue;
|
|
171
|
+
add(repoEntry.api_host);
|
|
172
|
+
add(repoEntry.links?.external?.url_template);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return Array.from(hostnames);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Every hostname whose PR URLs should be recognised without a scheme —
|
|
180
|
+
* the built-ins plus every configured alt host. De-duplicated, lowercased.
|
|
181
|
+
*
|
|
182
|
+
* @param {Object} [config]
|
|
183
|
+
* @returns {string[]}
|
|
184
|
+
*/
|
|
185
|
+
function resolveUrlLikeHostnames(config) {
|
|
186
|
+
const seen = new Set(BUILTIN_PR_HOSTNAMES);
|
|
187
|
+
for (const hostname of resolveAltHostHostnames(config)) seen.add(hostname);
|
|
188
|
+
return Array.from(seen);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
module.exports = {
|
|
192
|
+
DEFAULT_HOST_NAME,
|
|
193
|
+
GRAPHITE_HOST_NAME,
|
|
194
|
+
BUILTIN_PR_HOSTNAMES,
|
|
195
|
+
resolveKnownHostNames,
|
|
196
|
+
formatHostList,
|
|
197
|
+
resolveHostListText,
|
|
198
|
+
resolveAltHostHostnames,
|
|
199
|
+
resolveUrlLikeHostnames,
|
|
200
|
+
};
|
package/src/local-review.js
CHANGED
|
@@ -1018,7 +1018,13 @@ async function handleLocalReview(targetPath, flags = {}) {
|
|
|
1018
1018
|
let setupComplete = false;
|
|
1019
1019
|
|
|
1020
1020
|
try {
|
|
1021
|
-
|
|
1021
|
+
// Loaded before path validation so the "that's a URL" error can name the
|
|
1022
|
+
// configured hosts (GitHub, Graphite, alt hosts) and so scheme-less
|
|
1023
|
+
// alt-host URLs are recognised. The first-run welcome still waits until
|
|
1024
|
+
// the path has been validated.
|
|
1025
|
+
const { config, isFirstRun } = await loadConfig();
|
|
1026
|
+
|
|
1027
|
+
rejectUrlLikeLocalReviewPath(targetPath, config);
|
|
1022
1028
|
|
|
1023
1029
|
const resolvedPath = path.resolve(targetPath || process.cwd());
|
|
1024
1030
|
|
|
@@ -1032,8 +1038,6 @@ async function handleLocalReview(targetPath, flags = {}) {
|
|
|
1032
1038
|
const repoPath = await module.exports.findGitRoot(resolvedPath);
|
|
1033
1039
|
console.log(`Found git repository at: ${repoPath}`);
|
|
1034
1040
|
|
|
1035
|
-
const { config, isFirstRun } = await loadConfig();
|
|
1036
|
-
|
|
1037
1041
|
if (isFirstRun) {
|
|
1038
1042
|
showWelcomeMessage();
|
|
1039
1043
|
}
|
package/src/main.js
CHANGED
|
@@ -242,7 +242,7 @@ OPTIONS:
|
|
|
242
242
|
--model when the model belongs to a non-default
|
|
243
243
|
provider (e.g. --provider codex --model gpt-5.5).
|
|
244
244
|
Available: claude, antigravity, codex, copilot,
|
|
245
|
-
opencode, cursor-agent, pi, muse
|
|
245
|
+
opencode, cursor-agent, pi, omp, muse
|
|
246
246
|
--council <handle> Run analysis with a saved council (multi-voice). Handle is a
|
|
247
247
|
council name, name-slug, or id (prefix). See --list-councils.
|
|
248
248
|
--list-councils List saved councils (handles to use with --council) and exit
|
|
@@ -277,6 +277,7 @@ ENVIRONMENT VARIABLES:
|
|
|
277
277
|
PAIR_REVIEW_CLAUDE_CMD Custom command to invoke Claude CLI (default: claude)
|
|
278
278
|
PAIR_REVIEW_ANTIGRAVITY_CMD Custom command to invoke Antigravity CLI (default: agy)
|
|
279
279
|
PAIR_REVIEW_CODEX_CMD Custom command to invoke Codex CLI (default: codex)
|
|
280
|
+
PAIR_REVIEW_OMP_CMD Custom command to invoke OMP (Oh My Pi) CLI (default: omp)
|
|
280
281
|
PAIR_REVIEW_MUSE_CMD Custom command to invoke Muse Code CLI (default: muse)
|
|
281
282
|
|
|
282
283
|
CONFIGURATION:
|
|
@@ -566,6 +567,12 @@ function parseArgs(args) {
|
|
|
566
567
|
flags.local = true;
|
|
567
568
|
// Next argument is optional path (if not starting with -)
|
|
568
569
|
if (i + 1 < args.length && !args[i + 1].startsWith('-')) {
|
|
570
|
+
// parseArgs() is deliberately config-free — it is exported and
|
|
571
|
+
// unit-tested as a pure argv parser — so this catches only explicit
|
|
572
|
+
// `scheme://` inputs, with host-neutral copy. A scheme-less alt-host
|
|
573
|
+
// URL needs config and is caught by the re-check in main() right after
|
|
574
|
+
// loadConfig() (and again downstream by handleLocalReview /
|
|
575
|
+
// attemptDelegation / the local routes).
|
|
569
576
|
rejectUrlLikeLocalReviewPath(args[i + 1]);
|
|
570
577
|
flags.localPath = args[i + 1];
|
|
571
578
|
i++; // Skip next argument since we consumed it
|
|
@@ -667,6 +674,7 @@ ENVIRONMENT VARIABLES:
|
|
|
667
674
|
PAIR_REVIEW_CLAUDE_CMD Custom Claude CLI command (default: claude)
|
|
668
675
|
PAIR_REVIEW_ANTIGRAVITY_CMD Custom Antigravity CLI command (default: agy)
|
|
669
676
|
PAIR_REVIEW_CODEX_CMD Custom Codex CLI command (default: codex)
|
|
677
|
+
PAIR_REVIEW_OMP_CMD Custom OMP (Oh My Pi) CLI command (default: omp)
|
|
670
678
|
PAIR_REVIEW_MUSE_CMD Custom Muse Code CLI command (default: muse)
|
|
671
679
|
PAIR_REVIEW_DB_NAME Custom database filename (overrides config)
|
|
672
680
|
|
|
@@ -678,6 +686,7 @@ AI PROVIDERS:
|
|
|
678
686
|
Claude (default): Requires 'claude' CLI installed
|
|
679
687
|
Antigravity: Requires 'agy' CLI installed
|
|
680
688
|
Codex: Requires 'codex' CLI installed
|
|
689
|
+
OMP: Requires 'omp' CLI installed
|
|
681
690
|
Muse: Requires 'muse' CLI installed
|
|
682
691
|
|
|
683
692
|
Select provider per-repository in the web UI settings.
|
|
@@ -739,6 +748,17 @@ AI PROVIDERS:
|
|
|
739
748
|
// single-port delegation can skip DB entirely)
|
|
740
749
|
const { prArgs, flags } = parseArgs(args);
|
|
741
750
|
|
|
751
|
+
// parseArgs() ran config-free, so it could only reject `scheme://` inputs.
|
|
752
|
+
// Re-check now that config is loaded: a configured alt host makes
|
|
753
|
+
// `ghe.example.com/owner/repo/pull/1` a URL too, and the message can name
|
|
754
|
+
// the hosts this install actually accepts. Several branches below resolve
|
|
755
|
+
// flags.localPath directly (the instruction handoff at the delegation
|
|
756
|
+
// check, handleHeadlessDelegated, the headless local path), so the
|
|
757
|
+
// invariant has to hold here rather than only in handleLocalReview().
|
|
758
|
+
if (flags.local && flags.localPath) {
|
|
759
|
+
rejectUrlLikeLocalReviewPath(flags.localPath, config);
|
|
760
|
+
}
|
|
761
|
+
|
|
742
762
|
// Headless-mode flag validation (fail fast, before any DB/server work).
|
|
743
763
|
// --instructions and --instructions-file are mutually exclusive.
|
|
744
764
|
if (flags.instructions && flags.instructionsFile) {
|
package/src/review-config.js
CHANGED
|
@@ -22,6 +22,14 @@
|
|
|
22
22
|
const { RepoSettingsRepository, CouncilRepository } = require('./database');
|
|
23
23
|
const { resolveCouncilHandle } = require('./councils/resolve-council');
|
|
24
24
|
const { normalizeCouncilConfig, validateCouncilConfig } = require('./routes/councils');
|
|
25
|
+
// Require the ./ai index (not ./ai/provider) so the provider registry is
|
|
26
|
+
// populated by the provider files' self-registration before lookups here.
|
|
27
|
+
const {
|
|
28
|
+
getProviderClass,
|
|
29
|
+
getProviderConfigOverrides,
|
|
30
|
+
applyModelOverrides,
|
|
31
|
+
resolveDefaultModel
|
|
32
|
+
} = require('./ai');
|
|
25
33
|
const logger = require('./utils/logger');
|
|
26
34
|
|
|
27
35
|
/**
|
|
@@ -52,7 +60,7 @@ function _buildCouncilSelection(council) {
|
|
|
52
60
|
* Precedence (highest first), per the global-settings design ("specificity
|
|
53
61
|
* first, then in-app > files"):
|
|
54
62
|
* provider: explicit › repo default › global in-app override › config.default_provider › config.provider › 'claude'
|
|
55
|
-
* model: explicit › repo default › global in-app override › config.default_model
|
|
63
|
+
* model: explicit › repo default › global in-app override › config.default_model › provider's own default › 'opus'
|
|
56
64
|
*
|
|
57
65
|
* The global in-app override (from the /settings page, carried on
|
|
58
66
|
* `config._globalOverrides`) sits ABOVE the config files but BELOW the repo
|
|
@@ -78,7 +86,22 @@ function _buildCouncilSelection(council) {
|
|
|
78
86
|
*
|
|
79
87
|
* Each field falls through independently, so supplying only `explicit.model`
|
|
80
88
|
* still resolves the provider from repo/override/config defaults (and vice
|
|
81
|
-
* versa)
|
|
89
|
+
* versa) — BUT a tier's `default_model` is *intended* to pair with that
|
|
90
|
+
* tier's `default_provider`, so a tier's model is only consulted when its
|
|
91
|
+
* provider agrees with the resolved provider. Without that guard, a
|
|
92
|
+
* provider-only pick (`--provider omp`) walks the model ladder down to the
|
|
93
|
+
* global default and hands OMP a foreign model id like 'opus' instead of the
|
|
94
|
+
* provider's own default mode. A tier that names no provider is treated as
|
|
95
|
+
* provider-agnostic and still applies (e.g. a model-only in-app override).
|
|
96
|
+
* Note `cfg` is the FLATTENED effective config, not a single layer:
|
|
97
|
+
* loadConfig() merges DEFAULT_CONFIG and the config files, then
|
|
98
|
+
* buildEffectiveConfig() dot-path-writes in-app overrides into the same flat
|
|
99
|
+
* object, so `cfg.default_provider` and `cfg.default_model` may come from
|
|
100
|
+
* different layers — see the `cfgPairSuspect` guard below for the case where
|
|
101
|
+
* that incoherence is provable. When no compatible tier supplies a model,
|
|
102
|
+
* the provider's own default is used (mirroring what the settings UI derives
|
|
103
|
+
* via `models.find(m => m.default)`), with the global model as the last
|
|
104
|
+
* resort for providers with no built-in default (e.g. OpenCode).
|
|
82
105
|
*
|
|
83
106
|
* @param {Object} explicit - { provider, model } (either may be undefined)
|
|
84
107
|
* @param {Object|null} repoSettings - Row from RepoSettingsRepository.getRepoSettings
|
|
@@ -95,15 +118,67 @@ function _buildSingleSelection(explicit, repoSettings, config) {
|
|
|
95
118
|
|| cfg.default_provider
|
|
96
119
|
|| cfg.provider
|
|
97
120
|
|| 'claude';
|
|
121
|
+
|
|
122
|
+
// A tier's model applies only when that tier's provider matches the
|
|
123
|
+
// resolved provider (or the tier names no provider at all).
|
|
124
|
+
const tierModel = (tierProvider, model) =>
|
|
125
|
+
((!tierProvider || tierProvider === provider) ? model : null);
|
|
126
|
+
|
|
127
|
+
// A provider-only in-app override proves the flattened `cfg` pair is
|
|
128
|
+
// incoherent: buildEffectiveConfig() wrote the new provider into `cfg` via
|
|
129
|
+
// setPath() but left the config-file/default model beneath it. In that
|
|
130
|
+
// case `cfg`'s provider matches the resolved provider by construction, so
|
|
131
|
+
// the tier guard cannot catch the mismatch — skip the `cfg` tier entirely
|
|
132
|
+
// and let the provider's own default supply the model. (A config FILE that
|
|
133
|
+
// sets only default_provider over DEFAULT_CONFIG's model has the same
|
|
134
|
+
// incoherence but is not detectable here; tracked separately.)
|
|
135
|
+
const cfgPairSuspect = Boolean(overrides.default_provider && !overrides.default_model);
|
|
136
|
+
|
|
137
|
+
// An explicit --model passes through verbatim: Pi/OMP fuzzy-match arbitrary
|
|
138
|
+
// ids ('opus', 'gpt-5.2') that are deliberately not in their model list, so
|
|
139
|
+
// it must never be second-guessed against the provider's models. The
|
|
140
|
+
// hardcoded 'claude'/'opus' pair sits BELOW the override-aware provider
|
|
141
|
+
// default as a last-resort rescue (e.g. no provider class registered for
|
|
142
|
+
// 'claude'), so a configured `providers.claude.default_model` or a
|
|
143
|
+
// disabled 'opus' is honored on the provider-default rung first.
|
|
98
144
|
const model = explicit.model
|
|
99
|
-
|| repoSettings?.default_model
|
|
100
|
-
|| overrides.default_model
|
|
145
|
+
|| tierModel(repoSettings?.default_provider, repoSettings?.default_model)
|
|
146
|
+
|| tierModel(overrides.default_provider, overrides.default_model)
|
|
147
|
+
|| (cfgPairSuspect ? null : tierModel(cfg.default_provider || cfg.provider, cfg.default_model || cfg.model))
|
|
148
|
+
|| _resolveProviderDefaultModel(provider)
|
|
149
|
+
|| tierModel('claude', 'opus')
|
|
101
150
|
|| cfg.default_model
|
|
102
151
|
|| cfg.model
|
|
103
152
|
|| 'opus';
|
|
104
153
|
return { type: 'single', provider, model };
|
|
105
154
|
}
|
|
106
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Resolve a provider's own default model, honoring config overrides
|
|
158
|
+
* (`providers.<id>.models` / `default_model` / `disabled_models`) exactly the
|
|
159
|
+
* way `createProvider` does when handed a null model — so a provider-only
|
|
160
|
+
* selection lands on the same model the settings UI shows as that provider's
|
|
161
|
+
* default. Returns null for unknown providers and for providers with no
|
|
162
|
+
* default (e.g. OpenCode), letting the caller fall back to the global model.
|
|
163
|
+
*
|
|
164
|
+
* @param {string} providerId - Provider ID
|
|
165
|
+
* @returns {string|null} Default model id, or null
|
|
166
|
+
* @private
|
|
167
|
+
*/
|
|
168
|
+
function _resolveProviderDefaultModel(providerId) {
|
|
169
|
+
const ProviderClass = getProviderClass(providerId);
|
|
170
|
+
if (!ProviderClass) return null;
|
|
171
|
+
try {
|
|
172
|
+
const overrides = getProviderConfigOverrides(providerId);
|
|
173
|
+
const effectiveModels = applyModelOverrides(ProviderClass.getModels(), overrides);
|
|
174
|
+
return resolveDefaultModel(effectiveModels, overrides?.default_model)
|
|
175
|
+
|| ProviderClass.getDefaultModel();
|
|
176
|
+
} catch (error) {
|
|
177
|
+
logger.warn(`Could not resolve default model for provider "${providerId}": ${error.message}`);
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
107
182
|
/**
|
|
108
183
|
* Resolve the review configuration (council vs single provider/model) for a run.
|
|
109
184
|
*
|
|
@@ -124,7 +199,8 @@ function _buildSingleSelection(explicit, repoSettings, config) {
|
|
|
124
199
|
* single provider/model default.
|
|
125
200
|
* 5. `repo_settings.default_provider` / `default_model`, then global in-app
|
|
126
201
|
* override (`config._globalOverrides`) › global `config` defaults — single
|
|
127
|
-
* selection
|
|
202
|
+
* selection. The final fallback provider is 'claude' with that provider's
|
|
203
|
+
* own default model; 'opus' remains the hardcoded last-resort model floor.
|
|
128
204
|
*
|
|
129
205
|
* @param {Object} db - Database instance.
|
|
130
206
|
* @param {string} repository - Repository in `owner/repo` form (may be null/undefined
|
package/src/routes/analyses.js
CHANGED
|
@@ -31,7 +31,8 @@ const {
|
|
|
31
31
|
localReviewDiffs,
|
|
32
32
|
broadcastProgress,
|
|
33
33
|
killProcesses,
|
|
34
|
-
createProgressCallback
|
|
34
|
+
createProgressCallback,
|
|
35
|
+
finalizeConsolidationLevel
|
|
35
36
|
} = require('./shared');
|
|
36
37
|
const { generateScopedDiff, computeScopedDigest, getCurrentBranch } = require('../local-review');
|
|
37
38
|
const { reviewScope } = require('../local-scope');
|
|
@@ -675,7 +676,10 @@ async function launchCouncilAnalysis(db, modeContext, councilConfig, councilId,
|
|
|
675
676
|
suggestionsCount: result.suggestions.length,
|
|
676
677
|
levels: {
|
|
677
678
|
...currentStatus.levels,
|
|
678
|
-
|
|
679
|
+
// Derive the terminal consolidation state from the authoritative
|
|
680
|
+
// result — the run finishing does not mean consolidation succeeded,
|
|
681
|
+
// and some council paths never emit a terminal orchestration event
|
|
682
|
+
4: finalizeConsolidationLevel(result, currentStatus.levels?.[4])
|
|
679
683
|
}
|
|
680
684
|
};
|
|
681
685
|
for (const levelKey of ['1', '2', '3', 'exec']) {
|
package/src/routes/config.js
CHANGED
|
@@ -34,6 +34,7 @@ const {
|
|
|
34
34
|
getTourAutoGenerate
|
|
35
35
|
} = require('../config');
|
|
36
36
|
const { resolveRepoLinks } = require('../links/repo-links');
|
|
37
|
+
const { resolveKnownHostNames, formatHostList, resolveUrlLikeHostnames } = require('../links/host-names');
|
|
37
38
|
const { version } = require('../../package.json');
|
|
38
39
|
const semver = require('semver');
|
|
39
40
|
const { getAllChatProviders, getAllCachedChatAvailability } = require('../chat/chat-providers');
|
|
@@ -158,6 +159,8 @@ router.get('/api/config', (req, res) => {
|
|
|
158
159
|
hasRepoGithubToken = Boolean(resolvePreflightBinding(repository, config, undefined).token);
|
|
159
160
|
}
|
|
160
161
|
|
|
162
|
+
const hostNames = resolveKnownHostNames(config);
|
|
163
|
+
|
|
161
164
|
// Only return safe configuration values (not secrets like github_token)
|
|
162
165
|
res.json({
|
|
163
166
|
version,
|
|
@@ -190,6 +193,19 @@ router.get('/api/config', (req, res) => {
|
|
|
190
193
|
pi_available: getCachedAvailability('pi')?.available || false,
|
|
191
194
|
assisted_by_url: config.assisted_by_url || 'https://github.com/in-the-loop-labs/pair-review',
|
|
192
195
|
enable_graphite: config.enable_graphite === true,
|
|
196
|
+
// Code hosts pair-review accepts PR URLs from, derived from config
|
|
197
|
+
// (GitHub always; Graphite only when enabled; each alt host's
|
|
198
|
+
// `links.external.name`). Drives the landing-page placeholder, the help
|
|
199
|
+
// copy, and the client-side URL validation errors — surfaces that render
|
|
200
|
+
// before any repo is resolved and so cannot use resolveHostName().
|
|
201
|
+
// Both shapes are shipped so the Oxford-comma formatting has exactly one
|
|
202
|
+
// implementation (server-side) and cannot drift from the server's own copy.
|
|
203
|
+
pr_host_names: hostNames,
|
|
204
|
+
pr_host_list: formatHostList(hostNames),
|
|
205
|
+
// Hostnames the local-path input should recognise as scheme-less PR URLs
|
|
206
|
+
// (github.com, Graphite, and every configured alt host's API and web
|
|
207
|
+
// domains), so the client pre-flight matches the server's own check.
|
|
208
|
+
pr_url_hostnames: resolveUrlLikeHostnames(config),
|
|
193
209
|
external_comments: config.external_comments !== false,
|
|
194
210
|
chat_spinner: config.chat_spinner || 'dots',
|
|
195
211
|
summaries: {
|
package/src/routes/local.js
CHANGED
|
@@ -54,6 +54,7 @@ const {
|
|
|
54
54
|
broadcastProgress,
|
|
55
55
|
CancellationError,
|
|
56
56
|
createProgressCallback,
|
|
57
|
+
finalizeConsolidationLevel,
|
|
57
58
|
parseEnabledLevels,
|
|
58
59
|
registerProcess: registerProcessForCancellation
|
|
59
60
|
} = require('./shared');
|
|
@@ -389,7 +390,7 @@ router.post('/api/local/start', async (req, res) => {
|
|
|
389
390
|
}
|
|
390
391
|
|
|
391
392
|
try {
|
|
392
|
-
rejectUrlLikeLocalReviewPath(inputPath);
|
|
393
|
+
rejectUrlLikeLocalReviewPath(inputPath, req.app.get('config'));
|
|
393
394
|
} catch (err) {
|
|
394
395
|
return res.status(400).json({ error: err.message });
|
|
395
396
|
}
|
|
@@ -1657,11 +1658,11 @@ router.post('/api/local/:reviewId/analyses', async (req, res) => {
|
|
|
1657
1658
|
};
|
|
1658
1659
|
}
|
|
1659
1660
|
|
|
1660
|
-
//
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1661
|
+
// Derive the terminal consolidation (level 4) state from the
|
|
1662
|
+
// authoritative result — the run finishing does not mean the
|
|
1663
|
+
// consolidation step succeeded, and some council paths never emit a
|
|
1664
|
+
// terminal orchestration progress event
|
|
1665
|
+
currentStatus.levels[4] = finalizeConsolidationLevel(result, currentStatus.levels?.[4]);
|
|
1665
1666
|
|
|
1666
1667
|
const completedStatus = {
|
|
1667
1668
|
...currentStatus,
|
package/src/routes/mcp.js
CHANGED
|
@@ -22,7 +22,8 @@ const {
|
|
|
22
22
|
localReviewDiffs,
|
|
23
23
|
determineCompletionInfo,
|
|
24
24
|
broadcastProgress,
|
|
25
|
-
createProgressCallback
|
|
25
|
+
createProgressCallback,
|
|
26
|
+
finalizeConsolidationLevel
|
|
26
27
|
} = require('./shared');
|
|
27
28
|
const { safeParseJson } = require('../utils/safe-parse-json');
|
|
28
29
|
const { resolveLoadSkills, resolveHostBinding } = require('../config');
|
|
@@ -56,7 +57,9 @@ async function handleAnalysisCompletion(analysisId, runId, result, savePersisten
|
|
|
56
57
|
currentStatus.levels[i] = { status: 'completed', progress: `Level ${i} complete` };
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
+
// Derive the terminal consolidation state from the authoritative result —
|
|
61
|
+
// the run finishing does not mean the consolidation step succeeded
|
|
62
|
+
currentStatus.levels[4] = finalizeConsolidationLevel(result, currentStatus.levels?.[4]);
|
|
60
63
|
|
|
61
64
|
const completedStatus = {
|
|
62
65
|
...currentStatus,
|
package/src/routes/pr.js
CHANGED
|
@@ -29,6 +29,7 @@ const path = require('path');
|
|
|
29
29
|
const { resolveHostBinding, resolveBindingRepositoryFromPR, getWorktreeDisplayName, resolveLoadSkills, buildCouncilProviderOverrides, getSummaryEnabled, getTourEnabled } = require('../config');
|
|
30
30
|
const { storedHostToOption, isDualHostRepo } = require('../utils/host-resolution');
|
|
31
31
|
const { resolveHostName } = require('../links/repo-links');
|
|
32
|
+
const { resolveHostListText } = require('../links/host-names');
|
|
32
33
|
const { backgroundQueue } = require('../ai/background-queue');
|
|
33
34
|
const logger = require('../utils/logger');
|
|
34
35
|
const { buildDiffLineSet } = require('../utils/diff-annotator');
|
|
@@ -47,6 +48,7 @@ const {
|
|
|
47
48
|
determineCompletionInfo,
|
|
48
49
|
broadcastProgress,
|
|
49
50
|
createProgressCallback,
|
|
51
|
+
finalizeConsolidationLevel,
|
|
50
52
|
parseEnabledLevels,
|
|
51
53
|
registerProcess: registerProcessForCancellation
|
|
52
54
|
} = require('./shared');
|
|
@@ -1991,7 +1993,7 @@ router.post('/api/parse-pr-url', (req, res) => {
|
|
|
1991
1993
|
}
|
|
1992
1994
|
|
|
1993
1995
|
return res.status(400).json({
|
|
1994
|
-
error:
|
|
1996
|
+
error: `Invalid PR URL. Please enter a ${resolveHostListText(config)} PR URL.`,
|
|
1995
1997
|
valid: false
|
|
1996
1998
|
});
|
|
1997
1999
|
});
|
|
@@ -2481,10 +2483,11 @@ router.post('/api/pr/:owner/:repo/:number/analyses', async (req, res) => {
|
|
|
2481
2483
|
};
|
|
2482
2484
|
}
|
|
2483
2485
|
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2486
|
+
// Derive the terminal consolidation (level 4) state from the
|
|
2487
|
+
// authoritative result — the run finishing does not mean the
|
|
2488
|
+
// consolidation step succeeded, and some council paths never emit a
|
|
2489
|
+
// terminal orchestration progress event
|
|
2490
|
+
currentStatus.levels[4] = finalizeConsolidationLevel(result, currentStatus.levels?.[4]);
|
|
2488
2491
|
|
|
2489
2492
|
const completedStatus = {
|
|
2490
2493
|
...currentStatus,
|
package/src/routes/setup.js
CHANGED
|
@@ -271,7 +271,7 @@ router.post('/api/setup/local', async (req, res) => {
|
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
try {
|
|
274
|
-
rejectUrlLikeLocalReviewPath(rawPath);
|
|
274
|
+
rejectUrlLikeLocalReviewPath(rawPath, req.app.get('config'));
|
|
275
275
|
} catch (err) {
|
|
276
276
|
return res.status(400).json({ error: err.message });
|
|
277
277
|
}
|
package/src/routes/shared.js
CHANGED
|
@@ -521,6 +521,32 @@ function createProgressCallback(analysisId) {
|
|
|
521
521
|
};
|
|
522
522
|
}
|
|
523
523
|
|
|
524
|
+
/**
|
|
525
|
+
* Build the terminal level-4 (consolidation) progress state for a completed
|
|
526
|
+
* analysis. The outcome is driven by the authoritative analyzer result rather
|
|
527
|
+
* than the transient progress state alone — some council paths never emit a
|
|
528
|
+
* terminal voiceId-less orchestration event, so levels[4] can still read
|
|
529
|
+
* 'running' even when consolidation failed (issue #560).
|
|
530
|
+
*
|
|
531
|
+
* @param {Object} result - Analyzer result (may carry levelOutcomes / orchestrationFailed)
|
|
532
|
+
* @param {Object} [level4] - Current levels[4] progress state, if any
|
|
533
|
+
* @returns {Object} Terminal level-4 state (preserves existing steps/voices maps)
|
|
534
|
+
*/
|
|
535
|
+
function finalizeConsolidationLevel(result, level4) {
|
|
536
|
+
const consolidationFailed =
|
|
537
|
+
result?.levelOutcomes?.consolidation === 'failed' ||
|
|
538
|
+
result?.orchestrationFailed === true ||
|
|
539
|
+
level4?.status === 'failed';
|
|
540
|
+
return {
|
|
541
|
+
// Spread keeps the `steps` / `voices` maps a plain
|
|
542
|
+
// `{ status, progress }` replacement would silently drop
|
|
543
|
+
...level4,
|
|
544
|
+
...(consolidationFailed
|
|
545
|
+
? { status: 'failed', progress: 'Consolidation failed — showing unconsolidated results' }
|
|
546
|
+
: { status: 'completed', progress: 'Results finalized' })
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
|
|
524
550
|
/**
|
|
525
551
|
* Parse enabledLevels from a request body into a normalized { 1: bool, 2: bool, 3: bool } object.
|
|
526
552
|
*
|
|
@@ -570,5 +596,6 @@ module.exports = {
|
|
|
570
596
|
killProcesses,
|
|
571
597
|
isAnalysisCancelled,
|
|
572
598
|
createProgressCallback,
|
|
599
|
+
finalizeConsolidationLevel,
|
|
573
600
|
parseEnabledLevels
|
|
574
601
|
};
|
|
@@ -43,6 +43,7 @@ const {
|
|
|
43
43
|
determineCompletionInfo,
|
|
44
44
|
broadcastProgress,
|
|
45
45
|
createProgressCallback,
|
|
46
|
+
finalizeConsolidationLevel,
|
|
46
47
|
parseEnabledLevels,
|
|
47
48
|
registerProcess: registerProcessForCancellation,
|
|
48
49
|
killProcesses
|
|
@@ -586,7 +587,9 @@ async function launchStackSingleAnalysis(deps, db, config, {
|
|
|
586
587
|
for (let lvl = 1; lvl <= completionInfo.completedLevel; lvl++) {
|
|
587
588
|
currentStatus.levels[lvl] = { status: 'completed', progress: `Level ${lvl} complete` };
|
|
588
589
|
}
|
|
589
|
-
|
|
590
|
+
// Derive the terminal consolidation state from the authoritative result —
|
|
591
|
+
// the run finishing does not mean the consolidation step succeeded
|
|
592
|
+
currentStatus.levels[4] = finalizeConsolidationLevel(result, currentStatus.levels?.[4]);
|
|
590
593
|
const completedStatus = {
|
|
591
594
|
...currentStatus,
|
|
592
595
|
status: 'completed',
|
package/src/settings/registry.js
CHANGED
|
@@ -66,7 +66,7 @@ const REGISTRY = [
|
|
|
66
66
|
{
|
|
67
67
|
key: 'enable_graphite',
|
|
68
68
|
label: 'Show Graphite links',
|
|
69
|
-
description: 'Show Graphite links alongside GitHub links in the PR header.',
|
|
69
|
+
description: 'Show Graphite links alongside GitHub links in the PR header, and name Graphite in the PR URL prompts and errors. Graphite PR URLs are accepted either way.',
|
|
70
70
|
group: 'general',
|
|
71
71
|
type: 'boolean',
|
|
72
72
|
default: false,
|