@@ -2,6 +2,7 @@ package detector
22
33import (
44 "context"
5+ "path/filepath"
56 "strings"
67 "time"
78
@@ -41,7 +42,7 @@ func (d *FrameworkDetector) Detect(ctx context.Context) []model.AITool {
4142 }
4243
4344 version := d .getVersion (ctx , binaryPath )
44- isRunning := d . isProcessRunning (ctx , spec .ProcessName )
45+ isRunning := isProcessRunning (ctx , d . exec , spec .ProcessName )
4546
4647 results = append (results , model.AITool {
4748 Name : spec .Name ,
@@ -86,31 +87,32 @@ func (d *FrameworkDetector) getVersion(ctx context.Context, binaryPath string) s
8687 return "unknown"
8788}
8889
89- func (d * FrameworkDetector ) isProcessRunning (ctx context.Context , processName string ) bool {
90- _ , _ , exitCode , _ := d .exec .Run (ctx , "pgrep" , "-x" , processName )
91- return exitCode == 0
92- }
93-
9490func (d * FrameworkDetector ) detectLMStudioApp (ctx context.Context ) (model.AITool , bool ) {
95- appPath := "/Applications/LM Studio.app"
96- if ! d .exec .DirExists (appPath ) {
97- return model.AITool {}, false
98- }
99-
100- version := readPlistVersion (ctx , d .exec , appPath + "/Contents/Info.plist" )
91+ var appPath , version string
10192
102- isRunning := false
103- _ , _ , exitCode , _ := d .exec .Run (ctx , "pgrep" , "-f" , "LM Studio" )
104- if exitCode == 0 {
105- isRunning = true
93+ if d .exec .GOOS () == "windows" {
94+ localAppData := d .exec .Getenv ("LOCALAPPDATA" )
95+ appPath = filepath .Join (localAppData , "Programs" , "LM Studio" )
96+ if ! d .exec .DirExists (appPath ) {
97+ return model.AITool {}, false
98+ }
99+ version = readRegistryVersion (ctx , d .exec , "LM Studio" )
100+ } else {
101+ appPath = "/Applications/LM Studio.app"
102+ if ! d .exec .DirExists (appPath ) {
103+ return model.AITool {}, false
104+ }
105+ version = readPlistVersion (ctx , d .exec , filepath .Join (appPath , "Contents" , "Info.plist" ))
106106 }
107107
108+ running := isProcessRunningFuzzy (ctx , d .exec , "LM Studio" )
109+
108110 return model.AITool {
109111 Name : "lm-studio" ,
110112 Vendor : "LM Studio" ,
111113 Type : "framework" ,
112114 Version : version ,
113115 BinaryPath : appPath ,
114- IsRunning : & isRunning ,
116+ IsRunning : & running ,
115117 }, true
116118}
0 commit comments