-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathCurrentEditorSkill.swift
More file actions
33 lines (29 loc) · 1022 Bytes
/
CurrentEditorSkill.swift
File metadata and controls
33 lines (29 loc) · 1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import ConversationServiceProvider
import Foundation
import GitHubCopilotService
import JSONRPC
public class CurrentEditorSkill: ConversationSkill {
public static let ID = "current-editor"
private var currentFile: FileReference
public var id: String {
return CurrentEditorSkill.ID
}
public init(
currentFile: FileReference
) {
self.currentFile = currentFile
}
public func applies(params: ConversationContextParams) -> Bool {
return params.skillId == self.id
}
public func resolveSkill(request: ConversationContextRequest, completion: (AnyJSONRPCResponse) -> Void){
let uri: String? = self.currentFile.url.absoluteString
completion(
AnyJSONRPCResponse(id: request.id,
result: JSONValue.array([
JSONValue.hash(["uri" : .string(uri ?? "")]),
JSONValue.null
]))
)
}
}