codeant-cli 0.5.1 → 0.5.3

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 CodeAnt AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeant-cli",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Code review CLI tool",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  import React, { useState, useEffect } from 'react';
2
2
  import { Text, Box, useApp } from 'ink';
3
3
  import { getConfigValue, setConfigValue } from '../utils/config.js';
4
- import { getBaseUrl } from '../utils/baseUrl.js';
4
+ import { getBaseUrl, getDashboardUrl } from '../utils/baseUrl.js';
5
5
  import { randomUUID } from 'crypto';
6
6
 
7
7
  const POLL_INTERVAL = 10000; // 10 seconds
@@ -24,49 +24,55 @@ export default function Login() {
24
24
 
25
25
  const token = randomUUID();
26
26
  const baseUrl = getBaseUrl();
27
- const loginUrl = `https://app.codeant.ai?ideLoginToken=${token}`;
28
- setLoginUrl(loginUrl);
29
27
  const pollUrl = `${baseUrl}/extension/login/status?apiKey=${token}`;
30
28
 
31
- // Open browser
32
- import('open').then(({ default: open }) => {
33
- open(loginUrl);
34
- setStatus('waiting');
35
- }).catch(() => {
36
- // Fallback: just show the URL
37
- console.log(`\nOpen this URL in your browser:\n${loginUrl}\n`);
38
- setStatus('waiting');
39
- });
40
-
41
- // Poll for login status
29
+ let intervalId;
42
30
  let timeoutId;
43
- const intervalId = setInterval(async () => {
44
- try {
45
- const response = await fetch(pollUrl);
46
- const data = await response.json();
47
31
 
48
- if (data.status === 'yes') {
49
- clearInterval(intervalId);
50
- clearTimeout(timeoutId);
51
-
52
- // Save the API key
53
- setConfigValue('apiKeyV2', token);
54
-
55
- setStatus('success');
56
- setTimeout(() => exit(), 100);
32
+ (async () => {
33
+ const dashboardUrl = await getDashboardUrl();
34
+ const loginUrl = `${dashboardUrl}?ideLoginToken=${token}`;
35
+ setLoginUrl(loginUrl);
36
+
37
+ // Open browser
38
+ import('open').then(({ default: open }) => {
39
+ open(loginUrl);
40
+ setStatus('waiting');
41
+ }).catch(() => {
42
+ // Fallback: just show the URL
43
+ console.log(`\nOpen this URL in your browser:\n${loginUrl}\n`);
44
+ setStatus('waiting');
45
+ });
46
+
47
+ // Poll for login status
48
+ intervalId = setInterval(async () => {
49
+ try {
50
+ const response = await fetch(pollUrl);
51
+ const data = await response.json();
52
+
53
+ if (data.status === 'yes') {
54
+ clearInterval(intervalId);
55
+ clearTimeout(timeoutId);
56
+
57
+ // Save the API key
58
+ setConfigValue('apiKeyV2', token);
59
+
60
+ setStatus('success');
61
+ setTimeout(() => exit(), 100);
62
+ }
63
+ } catch (err) {
64
+ // Silently continue polling
57
65
  }
58
- } catch (err) {
59
- // Silently continue polling
60
- }
61
- }, POLL_INTERVAL);
62
-
63
- // Timeout after 10 minutes
64
- timeoutId = setTimeout(() => {
65
- clearInterval(intervalId);
66
- setError('Login timed out. Please try again.');
67
- setStatus('error');
68
- setTimeout(() => exit(new Error('Login timed out')), 100);
69
- }, TIMEOUT);
66
+ }, POLL_INTERVAL);
67
+
68
+ // Timeout after 10 minutes
69
+ timeoutId = setTimeout(() => {
70
+ clearInterval(intervalId);
71
+ setError('Login timed out. Please try again.');
72
+ setStatus('error');
73
+ setTimeout(() => exit(new Error('Login timed out')), 100);
74
+ }, TIMEOUT);
75
+ })();
70
76
 
71
77
  // Cleanup
72
78
  return () => {
@@ -81,24 +81,39 @@ export default function Review({ scanType = 'all', lastNCommits = 1, failOn = 'C
81
81
 
82
82
  // ── Split into per-file requests ───────────────────────────────────
83
83
  const perFileRequests = ReviewApiHelper.splitIntoPerFileRequests(requestBody);
84
+ let riskHypotheses = '';
85
+ try {
86
+ setCurrentMessage('Planning review risks...');
87
+ const plannerResult = await runTurnLoop(
88
+ {
89
+ diff_content: requestBody.diff_content,
90
+ prompt_template_name: 'risk_planner',
91
+ },
92
+ gitRoot,
93
+ () => cancelled,
94
+ () => {},
95
+ false
96
+ );
97
+ riskHypotheses = plannerResult.finalOutput?.risk_hypotheses || '';
98
+ } catch (plannerError) {
99
+ console.error(`Risk planner failed; continuing without hypotheses: ${plannerError.message}`);
100
+ }
101
+
102
+ if (cancelled) return;
84
103
 
85
104
  // ── Per-file agent turn loops (parallel) ──────────────────────────
86
105
  setCurrentMessage(`Analyzing ${perFileRequests.length} file${perFileRequests.length !== 1 ? 's' : ''} in parallel...`);
87
106
 
88
107
  const perFileResults = await Promise.all(
89
108
  perFileRequests.map((fileReq) => {
90
- const filename = fileReq._filename;
91
- delete fileReq._filename;
92
-
93
- // Convert file_contents dict → file_content/file_path for API
94
- if (fileReq.file_contents?.[filename]) {
95
- fileReq.file_content = fileReq.file_contents[filename];
96
- fileReq.file_path = filename;
97
- }
98
- delete fileReq.file_contents;
109
+ const payload = {
110
+ ...fileReq,
111
+ extra_variables: { risk_hypotheses: riskHypotheses },
112
+ };
113
+ delete payload._filenames;
99
114
 
100
115
  return runTurnLoop(
101
- fileReq,
116
+ payload,
102
117
  gitRoot,
103
118
  () => cancelled,
104
119
  () => {},
@@ -110,21 +125,23 @@ export default function Review({ scanType = 'all', lastNCommits = 1, failOn = 'C
110
125
  // Pair each file's suggestions with its own diff — skip files with no real suggestions
111
126
  const perFileWithSuggestions = perFileRequests.map((fileReq, i) => ({
112
127
  diff_content: fileReq.diff_content,
113
- suggestions: perFileResults[i].finalMessage?.content,
114
- output: perFileResults[i].finalOutput,
115
- })).filter(r => r.output?.code_suggestions?.length > 0);
128
+ file_contents: fileReq.file_contents,
129
+ generator_output: perFileResults[i].finalOutput,
130
+ rejector_input: perFileResults[i].rejectorInput,
131
+ })).filter(r => r.generator_output?.code_suggestions?.length > 0);
116
132
 
117
133
  if (cancelled) return;
118
134
 
119
- // ── Per-file reflector loops (parallel) ─────────────────────────────
120
- setCurrentMessage('Running reflector...');
121
- const reflectorResults = await Promise.all(
122
- perFileWithSuggestions.map(({ diff_content, suggestions }) =>
135
+ // ── Per-batch rejector loops (parallel) ─────────────────────────────
136
+ setCurrentMessage('Running rejector...');
137
+ const rejectorResults = await Promise.all(
138
+ perFileWithSuggestions.map(({ diff_content, file_contents, rejector_input }) =>
123
139
  runTurnLoop(
124
140
  {
125
141
  diff_content,
126
- prompt_template_name: 'reflector',
127
- extra_variables: { suggestion_str: suggestions },
142
+ file_contents,
143
+ prompt_template_name: 'rejector',
144
+ extra_variables: rejector_input,
128
145
  },
129
146
  gitRoot,
130
147
  () => cancelled,
@@ -136,11 +153,23 @@ export default function Review({ scanType = 'all', lastNCommits = 1, failOn = 'C
136
153
 
137
154
  if (cancelled) return;
138
155
 
139
- const reviewIssues = reflectorResults.flatMap(r =>
140
- (r.finalOutput?.code_suggestions || []).map(issue => ({
141
- issue_content: issue.issue_content || '',
156
+ const finalizedResults = await Promise.all(
157
+ rejectorResults.map((result, i) => fetchApi(
158
+ '/extension/pr-review/agent/finalize',
159
+ 'POST',
160
+ {
161
+ diff_content: perFileWithSuggestions[i].diff_content,
162
+ generator_output: perFileWithSuggestions[i].generator_output,
163
+ rejector_output: result.finalOutput || { code_suggestions: [] },
164
+ }
165
+ ))
166
+ );
167
+
168
+ const reviewIssues = finalizedResults.flatMap(r =>
169
+ (r.output?.code_suggestions || []).map(issue => ({
170
+ issue_content: issue.suggestion_content || issue.one_sentence_summary || '',
142
171
  relevant_file: issue.relevant_file || 'Unknown',
143
- start_line: issue.start_line || 0,
172
+ start_line: issue.relevant_lines_start || 0,
144
173
  label: issue.label || 'Code Quality',
145
174
  }))
146
175
  );
@@ -213,10 +242,11 @@ export default function Review({ scanType = 'all', lastNCommits = 1, failOn = 'C
213
242
 
214
243
  // ── Turn loop ──────────────────────────────────────────────────────────────
215
244
 
216
- async function runTurnLoop(initialPayload, gitRoot, isCancelled, onMessage, isReflectorLoop) {
245
+ async function runTurnLoop(initialPayload, gitRoot, isCancelled, onMessage, isRejectorLoop) {
217
246
  let nextPayload = initialPayload;
218
247
  let finalMessage = null;
219
248
  let finalOutput = null;
249
+ let rejectorInput = null;
220
250
 
221
251
  for (let turn = 0; turn < MAX_TURNS; turn+=1) {
222
252
  if (isCancelled()) break;
@@ -239,10 +269,11 @@ async function runTurnLoop(initialPayload, gitRoot, isCancelled, onMessage, isRe
239
269
 
240
270
  finalMessage = assistantMsg;
241
271
  if (resp.output) finalOutput = resp.output;
272
+ if (resp.rejector_input) rejectorInput = resp.rejector_input;
242
273
 
243
274
  if (done) {
244
- // Handle parsing errors in final message by dumping response content (only on reflector loop)
245
- if (isReflectorLoop && resp.parsing_error) {
275
+ // Preserve malformed rejector output for debugging.
276
+ if (isRejectorLoop && resp.parsing_error) {
246
277
  const dumpDir = path.join(gitRoot, '.codeant', 'codeSuggestions');
247
278
  const dumpFile = path.join(dumpDir, `code_suggestions_${Date.now()}.txt`);
248
279
  let dumpContent = resp.response?.content || JSON.stringify(resp, null, 2);
@@ -289,6 +320,5 @@ async function runTurnLoop(initialPayload, gitRoot, isCancelled, onMessage, isRe
289
320
  nextPayload = { session_id: sessionId, tool_results: toolResults };
290
321
  }
291
322
 
292
- return { finalMessage, finalOutput };
323
+ return { finalMessage, finalOutput, rejectorInput };
293
324
  }
294
-
@@ -180,7 +180,7 @@ export function renderFetchingDiff(startTime) {
180
180
  }
181
181
 
182
182
  export function renderReviewing(currentMessage, startTime, meta) {
183
- const step = currentMessage?.toLowerCase().includes('reflector') ? 3 : 2;
183
+ const step = currentMessage?.toLowerCase().includes('rejector') ? 3 : 2;
184
184
  return React.createElement(ReviewLoading, {
185
185
  message: currentMessage || 'Analyzing code...',
186
186
  step,
package/src/mcp/server.js CHANGED
@@ -390,7 +390,7 @@ export async function startMcpServer() {
390
390
  'codeant_login',
391
391
  {
392
392
  title: 'Sign in to CodeAnt AI',
393
- description: 'Opens app.codeant.ai in the user\'s browser and waits up to 10 minutes for them to complete sign-in. Tell the user to check their browser and finish the flow there. On success the API token is saved to ~/.codeant/config.json (apiKeyV2) and set on the running MCP process, so subsequent tool calls are authenticated without restart. Returns { alreadyLoggedIn: true } immediately if a token is already configured, unless `force` is true.',
393
+ description: 'Opens the configured CodeAnt dashboard in the user\'s browser and waits up to 10 minutes for them to complete sign-in. Tell the user to check their browser and finish the flow there. On success the API token is saved to ~/.codeant/config.json (apiKeyV2) and set on the running MCP process, so subsequent tool calls are authenticated without restart. Returns { alreadyLoggedIn: true } immediately if a token is already configured, unless `force` is true.',
394
394
  inputSchema: {
395
395
  force: z.boolean().optional().describe('Re-authenticate even if a token is already configured. Default false.'),
396
396
  },
@@ -7,12 +7,13 @@ import { track } from './utils/analytics.js';
7
7
  const MAX_TURNS = 5;
8
8
 
9
9
  /**
10
- * Run a single agent turn loop (per-file or reflector).
10
+ * Run a single agent turn loop (planner, generator, or rejector).
11
11
  */
12
- async function runTurnLoop(initialPayload, gitRoot, isReflectorLoop) {
12
+ async function runTurnLoop(initialPayload, gitRoot, isRejectorLoop) {
13
13
  let nextPayload = initialPayload;
14
14
  let finalMessage = null;
15
15
  let finalOutput = null;
16
+ let rejectorInput = null;
16
17
 
17
18
  for (let turn = 0; turn < MAX_TURNS; turn += 1) {
18
19
  const resp = await fetchApi('/extension/pr-review/agent/turn', 'POST', nextPayload);
@@ -31,10 +32,11 @@ async function runTurnLoop(initialPayload, gitRoot, isReflectorLoop) {
31
32
 
32
33
  finalMessage = assistantMsg;
33
34
  if (resp.output) finalOutput = resp.output;
35
+ if (resp.rejector_input) rejectorInput = resp.rejector_input;
34
36
 
35
37
  if (done) {
36
- if (isReflectorLoop && resp.parsing_error) {
37
- console.error('Warning: parsing error in reflector response');
38
+ if (isRejectorLoop && resp.parsing_error) {
39
+ console.error('Warning: parsing error in rejector response');
38
40
  }
39
41
  break;
40
42
  }
@@ -52,7 +54,7 @@ async function runTurnLoop(initialPayload, gitRoot, isReflectorLoop) {
52
54
  nextPayload = { session_id: sessionId, tool_results: toolResults };
53
55
  }
54
56
 
55
- return { finalMessage, finalOutput };
57
+ return { finalMessage, finalOutput, rejectorInput };
56
58
  }
57
59
 
58
60
  /**
@@ -126,29 +128,38 @@ export async function runReviewHeadless(options = {}) {
126
128
  const perFileRequests = ReviewApiHelper.splitIntoPerFileRequests(requestBody);
127
129
 
128
130
  const totalFiles = perFileRequests.reduce((n, r) => n + (r._filenames?.length || 0), 0);
131
+ let riskHypotheses = '';
132
+ try {
133
+ onProgress(`Planning risks across ${totalFiles} file${totalFiles !== 1 ? 's' : ''}...`);
134
+ const plannerResult = await runTurnLoop(
135
+ {
136
+ diff_content: requestBody.diff_content,
137
+ prompt_template_name: 'risk_planner',
138
+ },
139
+ gitRoot,
140
+ false
141
+ );
142
+ riskHypotheses = plannerResult.finalOutput?.risk_hypotheses || '';
143
+ } catch (err) {
144
+ console.error(`[warning] Risk planner failed; continuing without hypotheses: ${err.message}`);
145
+ }
129
146
  onProgress(`Analyzing ${totalFiles} file${totalFiles !== 1 ? 's' : ''}...`);
130
147
 
131
148
  // ── Per-batch agent turn loops (parallel, fault-tolerant) ────────────
132
- // Each batch covers up to 5 files; backend reviews the multi-file diff
133
- // in a single session (matches pragent's FileBatcher).
149
+ // Each review session covers a batch of up to five files.
134
150
  const perFileResults = await Promise.all(
135
151
  perFileRequests.map(async (fileReq) => {
136
152
  const filenames = fileReq._filenames || [];
137
- delete fileReq._filenames;
153
+ const payload = {
154
+ ...fileReq,
155
+ extra_variables: { risk_hypotheses: riskHypotheses },
156
+ };
157
+ delete payload._filenames;
138
158
  const label = filenames.join(', ');
139
159
 
140
- // Single-file batch: still pass file_content/file_path so backend can
141
- // build head_file_str. Multi-file batches drop these (head_file_str
142
- // becomes empty; agent gathers context via tools instead).
143
- if (filenames.length === 1 && fileReq.file_contents?.[filenames[0]]) {
144
- fileReq.file_content = fileReq.file_contents[filenames[0]];
145
- fileReq.file_path = filenames[0];
146
- }
147
- delete fileReq.file_contents;
148
-
149
160
  try {
150
161
  onProgress(`Reviewing ${label}...`);
151
- const result = await runTurnLoop(fileReq, gitRoot, false);
162
+ const result = await runTurnLoop(payload, gitRoot, false);
152
163
  onProgress(`Done reviewing ${label}`);
153
164
  return result;
154
165
  } catch (err) {
@@ -161,65 +172,59 @@ export async function runReviewHeadless(options = {}) {
161
172
  // Pair each file's suggestions with its own diff — skip files with no real suggestions
162
173
  const perFileWithSuggestions = perFileRequests.map((fileReq, i) => ({
163
174
  diff_content: fileReq.diff_content,
164
- suggestions: perFileResults[i].finalMessage?.content,
165
- output: perFileResults[i].finalOutput,
166
- })).filter(r => r.output?.code_suggestions?.length > 0);
175
+ file_contents: fileReq.file_contents,
176
+ generator_output: perFileResults[i].finalOutput,
177
+ rejector_input: perFileResults[i].rejectorInput,
178
+ })).filter(r => r.generator_output?.code_suggestions?.length > 0);
167
179
 
168
180
  const filesWithSuggestions = new Set(
169
181
  perFileWithSuggestions.flatMap(r =>
170
- (r.output?.code_suggestions || []).map(s => (s.relevant_file || '').trim()).filter(Boolean)
182
+ (r.generator_output?.code_suggestions || []).map(s => (s.relevant_file || '').trim()).filter(Boolean)
171
183
  )
172
184
  ).size;
173
- onProgress(`${filesWithSuggestions} file${filesWithSuggestions !== 1 ? 's' : ''} have suggestions, running reflector...`);
185
+ onProgress(`${filesWithSuggestions} file${filesWithSuggestions !== 1 ? 's' : ''} have suggestions, running rejector...`);
174
186
 
175
- // ── Per-file reflector loops (parallel, fault-tolerant) ──────────────
176
- const reflectorResults = await Promise.all(
177
- perFileWithSuggestions.map(async ({ diff_content, suggestions }, i) => {
187
+ // ── Per-batch rejector loops (parallel, fault-tolerant) ──────────────
188
+ const rejectorResults = await Promise.all(
189
+ perFileWithSuggestions.map(async ({ diff_content, file_contents, rejector_input }, i) => {
178
190
  try {
179
191
  return await runTurnLoop(
180
192
  {
181
193
  diff_content,
182
- prompt_template_name: 'reflector',
183
- extra_variables: { suggestion_str: suggestions },
194
+ file_contents,
195
+ prompt_template_name: 'rejector',
196
+ extra_variables: rejector_input,
184
197
  },
185
198
  gitRoot,
186
199
  true
187
200
  );
188
201
  } catch (err) {
189
- console.error(`[error] Reflector failed for file ${i}: ${err.message}`);
202
+ console.error(`[error] Rejector failed for batch ${i}: ${err.message}`);
190
203
  return { finalMessage: null, finalOutput: null };
191
204
  }
192
205
  })
193
206
  );
194
207
 
195
- // ── Parse results, carrying generator labels through reflector ──────
196
- // Pragent's rejector schema drops `label`; preserve it by matching the
197
- // reflector's per-issue (file, start_line) back to the generator's output.
198
- const issues = reflectorResults.flatMap((r, i) => {
199
- const genSuggestions = perFileWithSuggestions[i]?.output?.code_suggestions || [];
200
- const norm = (v) => (typeof v === 'string' ? v.trim() : v);
201
- const labelFor = (issue) => {
202
- if (norm(issue.label)) return norm(issue.label);
203
- // Match by summary (pragent's primary strategy): rejector's
204
- // suggestion_summary (renamed to issue_content server-side) is
205
- // "Repeated from the input" — i.e. the generator's one_sentence_summary.
206
- const summary = norm(issue.issue_content);
207
- if (summary) {
208
- const exact = genSuggestions.find(g => norm(g.one_sentence_summary) === summary);
209
- if (norm(exact?.label)) return norm(exact.label);
208
+ const finalizedResults = await Promise.all(
209
+ rejectorResults.map((result, i) => fetchApi(
210
+ '/extension/pr-review/agent/finalize',
211
+ 'POST',
212
+ {
213
+ diff_content: perFileWithSuggestions[i].diff_content,
214
+ generator_output: perFileWithSuggestions[i].generator_output,
215
+ rejector_output: result.finalOutput || { code_suggestions: [] },
210
216
  }
211
- // Fallback: first generator suggestion in the same file with a label.
212
- const file = norm(issue.relevant_file);
213
- const sameFile = genSuggestions.find(g => norm(g.relevant_file) === file && norm(g.label));
214
- return norm(sameFile?.label) || 'Code Quality';
215
- };
216
- return (r.finalOutput?.code_suggestions || []).map((issue) => ({
217
- issue_content: issue.issue_content || '',
217
+ ))
218
+ );
219
+
220
+ const issues = finalizedResults.flatMap(r =>
221
+ (r.output?.code_suggestions || []).map(issue => ({
222
+ issue_content: issue.suggestion_content || issue.one_sentence_summary || '',
218
223
  relevant_file: issue.relevant_file || 'Unknown',
219
- start_line: issue.start_line || 0,
220
- label: labelFor(issue),
221
- }));
222
- });
224
+ start_line: issue.relevant_lines_start || 0,
225
+ label: issue.label || 'Code Quality',
226
+ }))
227
+ );
223
228
 
224
229
  const labelCounts = {};
225
230
  for (const i of issues) { labelCounts[i.label] = (labelCounts[i.label] || 0) + 1; }
@@ -70,6 +70,7 @@ export async function fetchScanResults(repo, commitId, resultType, opts = {}) {
70
70
  filter_dismissed: filterDismissed,
71
71
  include_false_positives: includeFalsePositives,
72
72
  });
73
+ console.error("dropship: ", JSON.stringify(response, null, 2));
73
74
 
74
75
  if (!response) {
75
76
  return { success: false, error: 'Failed to connect to CodeAnt server' };
@@ -9,4 +9,15 @@ const getBaseUrl = () => {
9
9
  return url;
10
10
  };
11
11
 
12
- export { getBaseUrl };
12
+ const getDashboardUrl = async () => {
13
+ try {
14
+ const response = await fetch(`${getBaseUrl()}/extension/get/dashboard`);
15
+ // console.log('Fetching dashboard URL from:', `${getBaseUrl()}/extension/get/dashboard`);
16
+ const data = await response.json();
17
+ return data.dashboard_url || 'https://app.codeant.ai';
18
+ } catch {
19
+ return 'https://app.codeant.ai';
20
+ }
21
+ };
22
+
23
+ export { getBaseUrl, getDashboardUrl };
@@ -1,6 +1,6 @@
1
1
  import { randomUUID } from 'crypto';
2
2
  import { getConfigValue, setConfigValue } from './config.js';
3
- import { getBaseUrl } from './baseUrl.js';
3
+ import { getBaseUrl, getDashboardUrl } from './baseUrl.js';
4
4
 
5
5
  const DEFAULT_POLL_INTERVAL = 10_000;
6
6
  const DEFAULT_TIMEOUT = 10 * 60 * 1000;
@@ -12,7 +12,8 @@ export function isAlreadyLoggedIn() {
12
12
  export async function startLoginFlow() {
13
13
  const token = randomUUID();
14
14
  const baseUrl = getBaseUrl();
15
- const loginUrl = `https://app.codeant.ai?ideLoginToken=${token}`;
15
+ const dashboardUrl = await getDashboardUrl();
16
+ const loginUrl = `${dashboardUrl}?ideLoginToken=${token}`;
16
17
  const pollUrl = `${baseUrl}/extension/login/status?apiKey=${token}`;
17
18
 
18
19
  let browserOpened = false;
@@ -266,8 +266,8 @@ class ReviewApiHelper extends CommonApiHelper {
266
266
 
267
267
  /**
268
268
  * Split a combined review request into batched payloads.
269
- * Files are grouped in chunks of up to FILES_PER_BATCH so each backend
270
- * session reviews multiple files at once (matches pragent's batching).
269
+ * Files are grouped in chunks of up to FILES_PER_BATCH so each review
270
+ * session can process multiple files together.
271
271
  */
272
272
  static splitIntoPerFileRequests(requestBody, batchSize = 5) {
273
273
  if (!requestBody?.diff_content?.length) return [];
@@ -280,6 +280,7 @@ class ReviewApiHelper extends CommonApiHelper {
280
280
  if (!nameMatch) continue;
281
281
  perFile.push({ section, filename: nameMatch[1] });
282
282
  }
283
+ perFile.sort((a, b) => (a.filename < b.filename ? -1 : a.filename > b.filename ? 1 : 0));
283
284
 
284
285
  const batches = [];
285
286
  for (let i = 0; i < perFile.length; i += batchSize) {