@@ -2,8 +2,8 @@ import CopilotModel
22import Foundation
33import LanguageClient
44import LanguageServerProtocol
5- import XPCShared
65import Preferences
6+ import XPCShared
77
88public protocol CopilotAuthServiceType {
99 func checkStatus( ) async throws -> CopilotStatus
@@ -55,25 +55,43 @@ public class CopilotBaseService {
5555 if userEnvPath. isEmpty {
5656 userEnvPath = " /usr/bin:/usr/local/bin " // fallback
5757 }
58- let executionParams = {
58+ let executionParams : Process . ExecutionParameters
59+ if UserDefaults . shared. value ( for: \. runNodeWithInteractiveLoggedInShell) {
5960 let nodePath = UserDefaults . shared. value ( for: \. nodePath)
60- return Process . ExecutionParameters (
61- path: " /usr/bin/env " ,
62- arguments: [
63- nodePath. isEmpty ? " node " : nodePath,
64- Bundle . main. url (
65- forResource: " agent " ,
66- withExtension: " js " ,
67- subdirectory: " copilot/dist "
68- ) !. path,
69- " --stdio " ,
70- ] ,
71- environment: [
72- " PATH " : userEnvPath,
73- ] ,
74- currentDirectoryURL: supportURL
75- )
76- } ( )
61+ let command = [
62+ nodePath. isEmpty ? " node " : nodePath,
63+ " \" \( Bundle . main. url ( forResource: " agent " , withExtension: " js " , subdirectory: " copilot/dist " ) !. path) \" " ,
64+ " --stdio " ,
65+ ] . joined ( separator: " " )
66+ executionParams = {
67+ Process . ExecutionParameters (
68+ path: " /bin/bash " ,
69+ arguments: [ " -i " , " -l " , " -c " , command] ,
70+ environment: [ : ] ,
71+ currentDirectoryURL: supportURL
72+ )
73+ } ( )
74+ } else {
75+ executionParams = {
76+ let nodePath = UserDefaults . shared. value ( for: \. nodePath)
77+ return Process . ExecutionParameters (
78+ path: " /usr/bin/env " ,
79+ arguments: [
80+ nodePath. isEmpty ? " node " : nodePath,
81+ Bundle . main. url (
82+ forResource: " agent " ,
83+ withExtension: " js " ,
84+ subdirectory: " copilot/dist "
85+ ) !. path,
86+ " --stdio " ,
87+ ] ,
88+ environment: [
89+ " PATH " : userEnvPath,
90+ ] ,
91+ currentDirectoryURL: supportURL
92+ )
93+ } ( )
94+ }
7795 let localServer = CopilotLocalProcessServer ( executionParameters: executionParams)
7896 localServer. logMessages = false
7997 localServer. notificationHandler = { _, respond in
@@ -161,7 +179,7 @@ public final class CopilotSuggestionService: CopilotBaseService, CopilotSuggesti
161179 ignoreSpaceOnlySuggestions: Bool
162180 ) async throws -> [ CopilotCompletion ] {
163181 let languageId = languageIdentifierFromFileURL ( fileURL)
164-
182+
165183 let relativePath = {
166184 let filePath = fileURL. path
167185 let rootPath = projectRootURL. path
0 commit comments