Skip to content

Commit ef1e9c9

Browse files
committed
Merge branch 'feature/project-scope-v1' into develop
2 parents 196cdcf + dffdf5f commit ef1e9c9

59 files changed

Lines changed: 1041 additions & 590 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,4 @@ Python/site-packages/*
132132
!Python/site-packages/install.sh
133133

134134
Python/VERSIONS
135+
Copilot for Xcode Plus.xcworkspace

Copilot for Xcode.xcodeproj/project.pbxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@
175175
C861E61F2994F6390056CB02 /* ServiceDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServiceDelegate.swift; sourceTree = "<group>"; };
176176
C8758E6F29F04BFF00D29C1C /* CustomCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomCommand.swift; sourceTree = "<group>"; };
177177
C8758E7129F04CF100D29C1C /* SeparatorCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeparatorCommand.swift; sourceTree = "<group>"; };
178-
C87903302A5D2E6400FE6F42 /* Pro */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Pro; sourceTree = "<group>"; };
179178
C87B03A3293B24AB00C77EAE /* Copilot-for-Xcode-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "Copilot-for-Xcode-Info.plist"; sourceTree = SOURCE_ROOT; };
180179
C87B03A4293B261200C77EAE /* AcceptSuggestionCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AcceptSuggestionCommand.swift; sourceTree = "<group>"; };
181180
C87B03A6293B261900C77EAE /* RejectSuggestionCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RejectSuggestionCommand.swift; sourceTree = "<group>"; };
@@ -273,7 +272,6 @@
273272
C8CD828229B88006008D044D /* TestPlan.xctestplan */,
274273
C81D181E2A1B509B006C1B70 /* Tool */,
275274
C8189B282938979000C9DCDA /* Core */,
276-
C87903302A5D2E6400FE6F42 /* Pro */,
277275
C8189B182938972F00C9DCDA /* Copilot for Xcode */,
278276
C81458922939EFDC00135263 /* EditorExtension */,
279277
C8216B71298036EC00AD38C7 /* Helper */,

Core/.swiftpm/xcode/xcshareddata/xcschemes/CopilotModelTests.xcscheme

Lines changed: 0 additions & 52 deletions
This file was deleted.

Core/.swiftpm/xcode/xcshareddata/xcschemes/CopilotServiceTests.xcscheme

Lines changed: 0 additions & 52 deletions
This file was deleted.

Core/.swiftpm/xcode/xcshareddata/xcschemes/ServiceTests.xcscheme

Lines changed: 0 additions & 52 deletions
This file was deleted.

Core/Package.swift

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ let package = Package(
171171
name: "ChatService",
172172
dependencies: [
173173
"ChatPlugin",
174-
"ChatContextCollector",
175174

176175
// plugins
177176
"MathChatPlugin",
@@ -183,12 +182,15 @@ let package = Package(
183182
"ActiveDocumentChatContextCollector",
184183
"SystemInfoChatContextCollector",
185184

185+
.product(name: "ChatContextCollector", package: "Tool"),
186186
.product(name: "AppMonitoring", package: "Tool"),
187187
.product(name: "Environment", package: "Tool"),
188188
.product(name: "Parsing", package: "swift-parsing"),
189189
.product(name: "OpenAIService", package: "Tool"),
190190
.product(name: "Preferences", package: "Tool"),
191-
]
191+
].pro([
192+
"ProService",
193+
])
192194
),
193195
.testTarget(name: "ChatServiceTests", dependencies: ["ChatService"]),
194196
.target(
@@ -199,16 +201,6 @@ let package = Package(
199201
.product(name: "Terminal", package: "Tool"),
200202
]
201203
),
202-
.target(
203-
name: "ChatContextCollector",
204-
dependencies: [
205-
.product(name: "SuggestionModel", package: "Tool"),
206-
.product(name: "AppMonitoring", package: "Tool"),
207-
.product(name: "Environment", package: "Tool"),
208-
.product(name: "OpenAIService", package: "Tool"),
209-
.product(name: "Preferences", package: "Tool"),
210-
]
211-
),
212204

213205
.target(
214206
name: "ChatGPTChatTab",
@@ -346,7 +338,7 @@ let package = Package(
346338
.target(
347339
name: "WebChatContextCollector",
348340
dependencies: [
349-
"ChatContextCollector",
341+
.product(name: "ChatContextCollector", package: "Tool"),
350342
.product(name: "LangChain", package: "Tool"),
351343
.product(name: "OpenAIService", package: "Tool"),
352344
.product(name: "ExternalServices", package: "Tool"),
@@ -358,7 +350,7 @@ let package = Package(
358350
.target(
359351
name: "SystemInfoChatContextCollector",
360352
dependencies: [
361-
"ChatContextCollector",
353+
.product(name: "ChatContextCollector", package: "Tool"),
362354
.product(name: "OpenAIService", package: "Tool"),
363355
],
364356
path: "Sources/ChatContextCollectors/SystemInfoChatContextCollector"
@@ -367,7 +359,7 @@ let package = Package(
367359
.target(
368360
name: "ActiveDocumentChatContextCollector",
369361
dependencies: [
370-
"ChatContextCollector",
362+
.product(name: "ChatContextCollector", package: "Tool"),
371363
.product(name: "OpenAIService", package: "Tool"),
372364
.product(name: "Preferences", package: "Tool"),
373365
.product(name: "FocusedCodeFinder", package: "Tool"),

Core/Sources/ChatContextCollectors/ActiveDocumentChatContextCollector/Functions/ExpandFocusRangeFunction.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ struct ExpandFocusRangeFunction: ChatGPTFunction {
1313
"Editing Document Context is updated to display code at \(range)."
1414
}
1515
}
16-
16+
1717
struct E: Error, LocalizedError {
1818
var errorDescription: String?
1919
}
2020

21-
var reportProgress: (String) async -> Void = { _ in }
22-
2321
var name: String {
2422
"expandFocusRange"
2523
}
@@ -32,18 +30,21 @@ struct ExpandFocusRangeFunction: ChatGPTFunction {
3230
.type: "object",
3331
.properties: [:],
3432
] }
35-
33+
3634
weak var contextCollector: ActiveDocumentChatContextCollector?
37-
35+
3836
init(contextCollector: ActiveDocumentChatContextCollector) {
3937
self.contextCollector = contextCollector
4038
}
4139

42-
func prepare() async {
40+
func prepare(reportProgress: @escaping (String) async -> Void) async {
4341
await reportProgress("Finding the focused code..")
4442
}
4543

46-
func call(arguments: Arguments) async throws -> Result {
44+
func call(
45+
arguments: Arguments,
46+
reportProgress: @escaping (String) async -> Void
47+
) async throws -> Result {
4748
await reportProgress("Finding the focused code..")
4849
contextCollector?.activeDocumentContext?.expandFocusedRangeToContextRange()
4950
guard let newContext = contextCollector?.activeDocumentContext?.focusedContext else {
@@ -56,3 +57,4 @@ struct ExpandFocusRangeFunction: ChatGPTFunction {
5657
return .init(range: newContext.codeRange)
5758
}
5859
}
60+

Core/Sources/ChatContextCollectors/ActiveDocumentChatContextCollector/Functions/MoveToCodeAroundLineFunction.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ struct MoveToCodeAroundLineFunction: ChatGPTFunction {
1515
"Editing Document Context is updated to display code at \(range)."
1616
}
1717
}
18-
18+
1919
struct E: Error, LocalizedError {
2020
var errorDescription: String?
2121
}
2222

23-
var reportProgress: (String) async -> Void = { _ in }
24-
2523
var name: String {
2624
"getCodeAtLine"
2725
}
@@ -36,7 +34,7 @@ struct MoveToCodeAroundLineFunction: ChatGPTFunction {
3634
"line": [
3735
.type: "number",
3836
.description: "The line number in the file",
39-
]
37+
],
4038
],
4139
.required: ["line"],
4240
] }
@@ -47,11 +45,14 @@ struct MoveToCodeAroundLineFunction: ChatGPTFunction {
4745
self.contextCollector = contextCollector
4846
}
4947

50-
func prepare() async {
48+
func prepare(reportProgress: @escaping (String) async -> Void) async {
5149
await reportProgress("Finding code around..")
5250
}
5351

54-
func call(arguments: Arguments) async throws -> Result {
52+
func call(
53+
arguments: Arguments,
54+
reportProgress: @escaping (String) async -> Void
55+
) async throws -> Result {
5556
await reportProgress("Finding code around line \(arguments.line)..")
5657
contextCollector?.activeDocumentContext?.moveToCodeAroundLine(arguments.line)
5758
guard let newContext = contextCollector?.activeDocumentContext?.focusedContext else {

Core/Sources/ChatContextCollectors/ActiveDocumentChatContextCollector/Functions/MoveToFocusedCodeFunction.swift

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import OpenAIService
44
import SuggestionModel
55

66
struct MoveToFocusedCodeFunction: ChatGPTFunction {
7-
struct Arguments: Codable {}
7+
typealias Arguments = NoArguments
88

99
struct Result: ChatGPTFunctionResult {
1010
var range: CursorRange
@@ -13,13 +13,11 @@ struct MoveToFocusedCodeFunction: ChatGPTFunction {
1313
"Editing Document Context is updated to display code at \(range)."
1414
}
1515
}
16-
16+
1717
struct E: Error, LocalizedError {
1818
var errorDescription: String?
1919
}
2020

21-
var reportProgress: (String) async -> Void = { _ in }
22-
2321
var name: String {
2422
"moveToFocusedCode"
2523
}
@@ -28,22 +26,20 @@ struct MoveToFocusedCodeFunction: ChatGPTFunction {
2826
"Move editing document context to the selected or focused code"
2927
}
3028

31-
var argumentSchema: JSONSchemaValue { [
32-
.type: "object",
33-
.properties: [:],
34-
] }
35-
3629
weak var contextCollector: ActiveDocumentChatContextCollector?
37-
30+
3831
init(contextCollector: ActiveDocumentChatContextCollector) {
3932
self.contextCollector = contextCollector
4033
}
4134

42-
func prepare() async {
35+
func prepare(reportProgress: @escaping (String) async -> Void) async {
4336
await reportProgress("Finding the focused code..")
4437
}
4538

46-
func call(arguments: Arguments) async throws -> Result {
39+
func call(
40+
arguments: Arguments,
41+
reportProgress: @escaping (String) async -> Void
42+
) async throws -> Result {
4743
await reportProgress("Finding the focused code..")
4844
contextCollector?.activeDocumentContext?.moveToFocusedCode()
4945
guard let newContext = contextCollector?.activeDocumentContext?.focusedContext else {
@@ -56,3 +52,4 @@ struct MoveToFocusedCodeFunction: ChatGPTFunction {
5652
return .init(range: newContext.codeRange)
5753
}
5854
}
55+

0 commit comments

Comments
 (0)