1
1
import * as cp from "child_process" ;
2
2
import * as vscode from "vscode" ;
3
3
import * as os from "os" ;
4
- import { execSync } from "child_process" ;
4
+ import { execSync , exec } from "child_process" ;
5
5
import { AiderState } from "./types/aiderTypes" ;
6
6
import { PearAICredentials } from "core/pearaiServer/PearAICredentials" ;
7
7
import {
@@ -28,20 +28,52 @@ export const AIDER_QUESTION_MARKER = "[Yes]\\:";
28
28
export const AIDER_END_MARKER = "─────────────────────────────────────" ;
29
29
export const COMPLETION_DELAY = 1500 ; // 1.5 seconds wait time
30
30
31
+ function getAiderVersion ( ) : string {
32
+ try {
33
+ const versionOutput = execSync ( 'aider --version' ) . toString ( ) . trim ( ) ;
34
+ // Extract version number from output (e.g., "aider v0.64.2" -> "0.64.2")
35
+ const match = versionOutput . match ( / v ? ( \d + \. \d + \. \d + ) / ) ;
36
+ return match ? match [ 1 ] : "0.0.0" ;
37
+ } catch ( error ) {
38
+ console . error ( "Error getting aider version:" , error ) ;
39
+ return "0.0.0" ;
40
+ }
41
+ }
42
+
43
+ function compareVersions ( v1 : string , v2 : string ) : number {
44
+ const parts1 = v1 . split ( '.' ) . map ( Number ) ;
45
+ const parts2 = v2 . split ( '.' ) . map ( Number ) ;
46
+
47
+ for ( let i = 0 ; i < 3 ; i ++ ) {
48
+ if ( parts1 [ i ] > parts2 [ i ] ) return 1 ;
49
+ if ( parts1 [ i ] < parts2 [ i ] ) return - 1 ;
50
+ }
51
+ return 0 ;
52
+ }
53
+
31
54
export function buildAiderCommand ( model : string , accessToken : string | undefined , apiKey : string | undefined ) : string [ ] {
32
55
const aiderCommand = [ "aider" ] ;
33
56
57
+ const currentVersion = getAiderVersion ( ) ;
58
+ console . dir ( "CURRENT VERSION" )
59
+ console . dir ( currentVersion )
60
+ const minVersionForNoDetectUrls = "0.64.2" ;
61
+
34
62
let aiderFlags = [
35
63
"--no-pretty" ,
36
64
"--yes-always" ,
37
65
"--no-auto-commits" ,
38
66
"--no-suggest-shell-commands" ,
39
- "--no-check-update" ,
40
67
"--no-auto-lint" ,
41
68
"--map-tokens" , "2048" ,
42
- "--subtree-only"
69
+ "--subtree-only" ,
43
70
] ;
44
71
72
+ // Add --no-detect-urls flag if version is >= 0.64.2
73
+ if ( compareVersions ( currentVersion , minVersionForNoDetectUrls ) >= 0 ) {
74
+ aiderFlags . push ( "--no-detect-urls" ) ;
75
+ }
76
+
45
77
aiderCommand . push ( ...aiderFlags ) ;
46
78
47
79
if ( model === "pearai_model" ) {
0 commit comments