11import AppKit
22import enum CopilotForXcodeKit. SuggestionServiceError
33import Foundation
4+ import JSONRPC
45import LanguageClient
56import LanguageServerProtocol
67import Logger
@@ -133,6 +134,9 @@ public class GitHubCopilotBaseService {
133134 let urls = try GitHubCopilotBaseService . createFoldersIfNeeded ( )
134135 let executionParams : Process . ExecutionParameters
135136 let runner = UserDefaults . shared. value ( for: \. runNodeWith)
137+ let watchedFiles = JSONValue (
138+ booleanLiteral: projectRootURL. path == " / " ? false : true
139+ )
136140
137141 guard let agentJSURL = { ( ) -> URL ? in
138142 let languageServerDotJS = urls. executableURL
@@ -148,7 +152,7 @@ public class GitHubCopilotBaseService {
148152 } ( ) else {
149153 throw GitHubCopilotError . languageServerNotInstalled
150154 }
151-
155+
152156 let indexJSURL : URL = try {
153157 if UserDefaults . shared. value ( for: \. gitHubCopilotLoadKeyChainCertificates) {
154158 let url = urls. executableURL
@@ -244,6 +248,8 @@ public class GitHubCopilotBaseService {
244248 experimental: nil
245249 )
246250
251+ let pretendToBeVSCode = UserDefaults . shared
252+ . value ( for: \. gitHubCopilotPretendIDEToBeVSCode)
247253 return InitializeParams (
248254 processId: Int ( ProcessInfo . processInfo. processIdentifier) ,
249255 clientInfo: . init(
@@ -254,7 +260,24 @@ public class GitHubCopilotBaseService {
254260 locale: nil ,
255261 rootPath: projectRootURL. path,
256262 rootUri: projectRootURL. path,
257- initializationOptions: nil ,
263+ initializationOptions: [
264+ " editorInfo " : pretendToBeVSCode ? . hash( [
265+ " name " : " vscode " ,
266+ " version " : " 1.99.3 " ,
267+ ] ) : . hash( [
268+ " name " : " Xcode " ,
269+ " version " : . string( xcodeVersion ( ) ?? " 16.0 " ) ,
270+ ] ) ,
271+ " editorPluginInfo " : . hash( [
272+ " name " : " Copilot for Xcode " ,
273+ " version " : . string( Bundle . main
274+ . infoDictionary ? [ " CFBundleShortVersionString " ] as? String ?? " " ) ,
275+ ] ) ,
276+ " copilotCapabilities " : [
277+ /// The editor has support for watching files over LSP
278+ " watchedFiles " : watchedFiles,
279+ ]
280+ ] ,
258281 capabilities: capabilities,
259282 trace: . off,
260283 workspaceFolders: [ WorkspaceFolder (
@@ -632,7 +655,7 @@ extension InitializingServer: GitHubCopilotLSP {
632655 }
633656}
634657
635- private func xcodeVersion( ) async -> String ? {
658+ private func xcodeVersion( ) -> String ? {
636659 let process = Process ( )
637660 process. executableURL = URL ( fileURLWithPath: " /usr/bin/xcrun " )
638661 process. arguments = [ " xcodebuild " , " -version " ]
0 commit comments