Skip to content

Commit 44f5614

Browse files
committed
Merge branch 'release/0.22.0'
2 parents 54faa15 + 5cf302b commit 44f5614

File tree

76 files changed

+2237
-1290
lines changed

Some content is hidden

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

76 files changed

+2237
-1290
lines changed

Copilot for Xcode.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Core/Package.swift

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ let package = Package(
1515
"FileChangeChecker",
1616
"LaunchAgentManager",
1717
"UpdateChecker",
18-
"UserDefaultsObserver",
1918
]
2019
),
2120
.library(
@@ -72,14 +71,15 @@ let package = Package(
7271
"SuggestionService",
7372
"GitHubCopilotService",
7473
"XPCShared",
75-
"CGEventObserver",
7674
"DisplayLink",
7775
"SuggestionWidget",
7876
"ChatService",
7977
"PromptToCodeService",
8078
"ServiceUpdateMigration",
81-
"UserDefaultsObserver",
8279
"ChatGPTChatTab",
80+
.product(name: "CGEventObserver", package: "Tool"),
81+
.product(name: "Workspace", package: "Tool"),
82+
.product(name: "UserDefaultsObserver", package: "Tool"),
8383
.product(name: "AppMonitoring", package: "Tool"),
8484
.product(name: "Environment", package: "Tool"),
8585
.product(name: "SuggestionModel", package: "Tool"),
@@ -91,7 +91,7 @@ let package = Package(
9191
.product(name: "ComposableArchitecture", package: "swift-composable-architecture"),
9292
.product(name: "Dependencies", package: "swift-dependencies"),
9393
].pro([
94-
"ProChatTabs",
94+
"ProService",
9595
])
9696
),
9797
.testTarget(
@@ -149,7 +149,7 @@ let package = Package(
149149
.target(name: "SuggestionService", dependencies: [
150150
"GitHubCopilotService",
151151
"CodeiumService",
152-
"UserDefaultsObserver",
152+
.product(name: "UserDefaultsObserver", package: "Tool"),
153153
]),
154154

155155
// MARK: - Prompt To Code
@@ -180,6 +180,7 @@ let package = Package(
180180
// context collectors
181181
"WebChatContextCollector",
182182
"ActiveDocumentChatContextCollector",
183+
"SystemInfoChatContextCollector",
183184

184185
.product(name: "AppMonitoring", package: "Tool"),
185186
.product(name: "Environment", package: "Tool"),
@@ -226,7 +227,7 @@ let package = Package(
226227
name: "SuggestionWidget",
227228
dependencies: [
228229
"ChatGPTChatTab",
229-
"UserDefaultsObserver",
230+
.product(name: "UserDefaultsObserver", package: "Tool"),
230231
.product(name: "SharedUIComponents", package: "Tool"),
231232
.product(name: "AppMonitoring", package: "Tool"),
232233
.product(name: "Environment", package: "Tool"),
@@ -241,12 +242,6 @@ let package = Package(
241242

242243
// MARK: - Helpers
243244

244-
.target(
245-
name: "CGEventObserver",
246-
dependencies: [
247-
.product(name: "Logger", package: "Tool"),
248-
]
249-
),
250245
.target(name: "FileChangeChecker"),
251246
.target(name: "LaunchAgentManager"),
252247
.target(name: "DisplayLink"),
@@ -264,7 +259,6 @@ let package = Package(
264259
.product(name: "Preferences", package: "Tool"),
265260
]
266261
),
267-
.target(name: "UserDefaultsObserver"),
268262
.target(
269263
name: "PlusFeatureFlag",
270264
dependencies: [
@@ -353,6 +347,15 @@ let package = Package(
353347
path: "Sources/ChatContextCollectors/WebChatContextCollector"
354348
),
355349

350+
.target(
351+
name: "SystemInfoChatContextCollector",
352+
dependencies: [
353+
"ChatContextCollector",
354+
.product(name: "OpenAIService", package: "Tool"),
355+
],
356+
path: "Sources/ChatContextCollectors/SystemInfoChatContextCollector"
357+
),
358+
356359
.target(
357360
name: "ActiveDocumentChatContextCollector",
358361
dependencies: [

Core/Sources/ChatContextCollectors/ActiveDocumentChatContextCollector/ActiveDocumentChatContextCollector.swift

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,15 @@ public final class ActiveDocumentChatContextCollector: ChatContextCollector {
8989
let start = """
9090
## File and Code Scope
9191
92-
You can use the following context to answer user's questions about the editing document or code. The context shows only a part of the code in the editing document, and will change during the conversation, so it may not match our conversation.
92+
You can use the following context to answer my questions about the editing document or code. The context shows only a part of the code in the editing document, and will change during the conversation, so it may not match our conversation.
9393
94-
User Editing Document Context: ###
94+
\(
95+
context.focusedContext == nil
96+
? ""
97+
: "When you don't known what I am asking, I am probably referring to the code."
98+
)
99+
100+
Editing Document Context: ###
95101
"""
96102
let end = "###"
97103
let relativePath = "Document Relative Path: \(context.relativePath)"
@@ -110,10 +116,7 @@ public final class ActiveDocumentChatContextCollector: ChatContextCollector {
110116
let codeRange = "Focused Range [line, character]: \(focusedContext.codeRange)"
111117

112118
let code = """
113-
Focused Code (start from line \(
114-
focusedContext.codeRange.start
115-
.line
116-
)):
119+
Focused Code (start from line \(focusedContext.codeRange.start.line + 1)):
117120
```\(context.language.rawValue)
118121
\(focusedContext.code)
119122
```
@@ -282,7 +285,7 @@ struct ActiveDocumentContext {
282285
selectionRange = info.editorContent?.selections.first ?? .zero
283286
lineAnnotations = info.editorContent?.lineAnnotations ?? []
284287
imports = []
285-
288+
286289
if changed {
287290
moveToFocusedCode()
288291
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct ExpandFocusRangeFunction: ChatGPTFunction {
1010
var range: CursorRange
1111

1212
var botReadableContent: String {
13-
"User Editing Document Context is updated to display code at \(range)."
13+
"Editing Document Context is updated to display code at \(range)."
1414
}
1515
}
1616

@@ -25,7 +25,7 @@ struct ExpandFocusRangeFunction: ChatGPTFunction {
2525
}
2626

2727
var description: String {
28-
"Call when User Editing Document Context provides too little context to answer a question."
28+
"Call when Editing Document Context provides too little context to answer a question."
2929
}
3030

3131
var argumentSchema: JSONSchemaValue { [

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct MoveToCodeAroundLineFunction: ChatGPTFunction {
1212
var range: CursorRange
1313

1414
var botReadableContent: String {
15-
"User Editing Document Context is updated to display code at \(range)."
15+
"Editing Document Context is updated to display code at \(range)."
1616
}
1717
}
1818

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct MoveToFocusedCodeFunction: ChatGPTFunction {
1010
var range: CursorRange
1111

1212
var botReadableContent: String {
13-
"User Editing Document Context is updated to display code at \(range)."
13+
"Editing Document Context is updated to display code at \(range)."
1414
}
1515
}
1616

@@ -25,7 +25,7 @@ struct MoveToFocusedCodeFunction: ChatGPTFunction {
2525
}
2626

2727
var description: String {
28-
"Move user editing document context to the selected or focused code"
28+
"Move editing document context to the selected or focused code"
2929
}
3030

3131
var argumentSchema: JSONSchemaValue { [

Core/Sources/ChatContextCollectors/ActiveDocumentChatContextCollector/LegacyActiveDocumentChatContextCollector.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public struct LegacyActiveDocumentChatContextCollector: ChatContextCollector {
6868

6969
return """
7070
Selected Code Not Available: '''
71-
User has disabled default scope. \
72-
You MUST not answer the user about the selected code because you don't have it.\
73-
Ask user to prepend message with `@selection` to enable selected code to be \
71+
I have disabled default scope. \
72+
You MUST not answer about the selected code because you don't have it.\
73+
Ask me to prepend message with `@selection` to enable selected code to be \
7474
visible by you.
7575
'''
7676
"""
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import ChatContextCollector
2+
import Foundation
3+
import OpenAIService
4+
5+
public final class SystemInfoChatContextCollector: ChatContextCollector {
6+
static let dateFormatter: DateFormatter = {
7+
let formatter = DateFormatter()
8+
formatter.dateFormat = "EEEE, yyyy-MM-dd HH:mm:ssZ"
9+
return formatter
10+
}()
11+
12+
public init() {}
13+
14+
public func generateContext(
15+
history: [ChatMessage],
16+
scopes: Set<String>,
17+
content: String
18+
) -> ChatContext? {
19+
return .init(
20+
systemPrompt: """
21+
Current Time: \(Self.dateFormatter.string(from: Date())) (You can use it to calculate time in another time zone)
22+
""",
23+
functions: []
24+
)
25+
}
26+
}
27+

Core/Sources/ChatContextCollectors/WebChatContextCollector/SearchFunction.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ struct SearchFunction: ChatGPTFunction {
5151
"freshness": [
5252
.type: "string",
5353
.description: .string(
54-
"limit the search result to a specific range, use only when user ask the question about current events. Today is \(today). Format: yyyy-MM-dd..yyyy-MM-dd"
54+
"limit the search result to a specific range, use only when I ask the question about current events. Today is \(today). Format: yyyy-MM-dd..yyyy-MM-dd"
5555
),
5656
.examples: ["1919-10-20..1988-10-20"],
5757
],

Core/Sources/ChatGPTChatTab/ChatContextMenu.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import SharedUIComponents
33
import SwiftUI
44

55
struct ChatContextMenu: View {
6-
let chat: ChatProvider
6+
@ObservedObject var chat: ChatProvider
77
@AppStorage(\.customCommands) var customCommands
88

99
var body: some View {

0 commit comments

Comments
 (0)