Skip to content

Commit e11d290

Browse files
committed
Merge tag '0.26.0' into develop
2 parents c2837ee + cd41739 commit e11d290

8 files changed

Lines changed: 73 additions & 34 deletions

File tree

Core/Sources/ChatService/DynamicContextController.swift

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import ChatContextCollector
22
import Foundation
33
import OpenAIService
4-
import Parsing
54
import Preferences
65
import XcodeInspector
76

@@ -65,17 +64,17 @@ final class DynamicContextController {
6564
}
6665
return contexts
6766
}
68-
67+
6968
let extraSystemPrompt = contexts
7069
.map(\.systemPrompt)
7170
.filter { !$0.isEmpty }
7271
.joined(separator: "\n\n")
73-
72+
7473
let contextPrompts = contexts
7574
.flatMap(\.retrievedContent)
7675
.filter { !$0.content.isEmpty }
7776
.sorted { $0.priority > $1.priority }
78-
77+
7978
let contextualSystemPrompt = """
8079
\(language.isEmpty ? "" : "You must always reply in \(language)")
8180
\(systemPrompt)\(extraSystemPrompt.isEmpty ? "" : "\n\(extraSystemPrompt)")
@@ -88,30 +87,8 @@ final class DynamicContextController {
8887

8988
extension DynamicContextController {
9089
static func parseScopes(_ prompt: inout String) -> Set<String> {
91-
guard !prompt.isEmpty else { return [] }
92-
do {
93-
let parser = Parse {
94-
"@"
95-
Many {
96-
Prefix { $0.isLetter }
97-
} separator: {
98-
"+"
99-
} terminator: {
100-
" "
101-
}
102-
Skip {
103-
Many {
104-
" "
105-
}
106-
}
107-
Rest()
108-
}
109-
let (scopes, rest) = try parser.parse(prompt)
110-
prompt = String(rest)
111-
return Set(scopes.map(String.init))
112-
} catch {
113-
return []
114-
}
90+
let parser = MessageScopeParser()
91+
return parser(&prompt)
11592
}
11693
}
11794

Core/Sources/HostApp/GeneralView.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,12 @@ struct GeneralSettingsView: View {
288288

289289
Text("pt")
290290
}
291-
292-
KeyboardShortcuts.Recorder("Hotkey to Toggle Widgets", name: .showHideWidget)
293-
291+
292+
KeyboardShortcuts.Recorder("Hotkey to Toggle Widgets", name: .showHideWidget) { _ in
293+
// It's not used in this app!
294+
KeyboardShortcuts.disable(.showHideWidget)
295+
}
296+
294297
Toggle(isOn: $settings.showHideWidgetShortcutGlobally) {
295298
Text("Enable the Hotkey Globally")
296299
}

Pro

Submodule Pro updated from 51ea02d to 5feae55

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ These features are included in another repo, and are not open sourced.
332332

333333
The currently available Plus features include:
334334

335+
- Terminal tab in chat panel.
335336
- Unlimited chat/embedding models.
336337
- Tab to accept suggestions.
337338
- Persisted chat panel.

Tool/Sources/ChatContextCollector/ChatContextCollector.swift

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Foundation
22
import OpenAIService
3+
import Parsing
34

45
public struct ChatContext {
56
public struct RetrievedContent {
@@ -39,3 +40,38 @@ public protocol ChatContextCollector {
3940
) async -> ChatContext
4041
}
4142

43+
public struct MessageScopeParser {
44+
public init() {}
45+
46+
public func callAsFunction(_ content: inout String) -> Set<String> {
47+
return parseScopes(&content)
48+
}
49+
50+
func parseScopes(_ prompt: inout String) -> Set<String> {
51+
guard !prompt.isEmpty else { return [] }
52+
do {
53+
let parser = Parse {
54+
"@"
55+
Many {
56+
Prefix { $0.isLetter }
57+
} separator: {
58+
"+"
59+
} terminator: {
60+
" "
61+
}
62+
Skip {
63+
Many {
64+
" "
65+
}
66+
}
67+
Rest()
68+
}
69+
let (scopes, rest) = try parser.parse(prompt)
70+
prompt = String(rest)
71+
return Set(scopes.map(String.init))
72+
} catch {
73+
return []
74+
}
75+
}
76+
}
77+

Tool/Sources/OpenAIService/ChatGPTService.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,9 @@ extension ChatGPTService {
265265
requestBody
266266
)
267267

268+
#if DEBUG
268269
Debugger.didSendRequestBody(body: requestBody)
270+
#endif
269271

270272
return AsyncThrowingStream<StreamContent, Error> { continuation in
271273
Task {
@@ -376,7 +378,9 @@ extension ChatGPTService {
376378
requestBody
377379
)
378380

381+
#if DEBUG
379382
Debugger.didSendRequestBody(body: requestBody)
383+
#endif
380384

381385
let response = try await api()
382386

@@ -418,7 +422,9 @@ extension ChatGPTService {
418422
_ call: ChatMessage.FunctionCall,
419423
messageId: String? = nil
420424
) async -> String {
425+
#if DEBUG
421426
Debugger.didReceiveFunction(name: call.name, arguments: call.arguments)
427+
#endif
422428

423429
let messageId = messageId ?? uuidGenerator()
424430

@@ -445,7 +451,9 @@ extension ChatGPTService {
445451
}
446452
}
447453

454+
#if DEBUG
448455
Debugger.didReceiveFunctionResult(result: result.botReadableContent)
456+
#endif
449457

450458
await memory.updateMessage(id: messageId) { message in
451459
message.content = result.botReadableContent
@@ -456,7 +464,9 @@ extension ChatGPTService {
456464
// For errors, use the error message as the result.
457465
let content = "Error: \(error.localizedDescription)"
458466

467+
#if DEBUG
459468
Debugger.didReceiveFunctionResult(result: content)
469+
#endif
460470

461471
await memory.updateMessage(id: messageId) { message in
462472
message.content = content

Version.xcconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
APP_VERSION = 0.25.0
2-
APP_BUILD = 261
1+
APP_VERSION = 0.26.0
2+
APP_BUILD = 272
33

appcast.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
<channel>
44
<title>Copilot for Xcode</title>
55

6+
<item>
7+
<title>0.26.0</title>
8+
<pubDate>Sun, 22 Oct 2023 18:58:49 +0800</pubDate>
9+
<sparkle:version>272</sparkle:version>
10+
<sparkle:shortVersionString>0.26.0</sparkle:shortVersionString>
11+
<sparkle:minimumSystemVersion>12.0</sparkle:minimumSystemVersion>
12+
<sparkle:releaseNotesLink>
13+
https://github.com/intitni/CopilotForXcode/releases/tag/0.26.0
14+
</sparkle:releaseNotesLink>
15+
<enclosure url="https://github.com/intitni/CopilotForXcode/releases/download/0.26.0/Copilot.for.Xcode.app.zip" length="36274215" type="application/octet-stream" sparkle:edSignature="CB6JDXYugsFfJfokP2yuIrnbse9g+TwUW9rZ6zti+SBSt57YFF7xIKh5KAOdTIUnhqZrm3OffexcsDZqeV+wCQ=="/>
16+
</item>
17+
618
<item>
719
<title>0.25.0</title>
820
<pubDate>Wed, 11 Oct 2023 23:08:08 +0800</pubDate>

0 commit comments

Comments
 (0)