Skip to content

Commit fe6b09f

Browse files
committed
Merge branch 'develop'
2 parents 78df628 + ade3d61 commit fe6b09f

174 files changed

Lines changed: 3114 additions & 1799 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.

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "Pro"]
2-
path = Pro
3-
url = git@github.com:intitni/CopilotForXcodePro.git

Config.xcconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ SLASH = /
33

44
HOST_APP_NAME = Copilot for Xcode
55
BUNDLE_IDENTIFIER_BASE = com.intii.CopilotForXcode
6-
SPARKLE_FEED_URL = https:$(SLASH)$(SLASH)raw.githubusercontent.com/intitni/CopilotForXcode/main/appcast.xml
6+
SPARKLE_FEED_URL = https:$(SLASH)$(SLASH)copilotforxcode.intii.com/appcast.xml
77
SPARKLE_PUBLIC_KEY = WDzm5GHnc6c8kjeJEgX5GuGiPpW6Lc/ovGjLnrrZvPY=
88
APPLICATION_SUPPORT_FOLDER = com.intii.CopilotForXcode
99
EXTENSION_BUNDLE_NAME = Copilot

Copilot for Xcode.xcodeproj/project.pbxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@
205205
C8216B772980370100AD38C7 /* ReloadLaunchAgent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReloadLaunchAgent.swift; sourceTree = "<group>"; };
206206
C828B27D2B1F241500E7612A /* ExtensionPoint.appextensionpoint */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = ExtensionPoint.appextensionpoint; sourceTree = "<group>"; };
207207
C82E38492A1F025F00D4EADF /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
208-
C83E5DED2A38CD8C0071506D /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
209208
C8520300293C4D9000460097 /* Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Helpers.swift; sourceTree = "<group>"; };
210209
C8520308293D805800460097 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
211210
C861A6A229E5503F005C41A3 /* PromptToCodeCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PromptToCodeCommand.swift; sourceTree = "<group>"; };
@@ -335,7 +334,6 @@
335334
C887BC832965D96000931567 /* DEVELOPMENT.md */,
336335
C8520308293D805800460097 /* README.md */,
337336
C82E38492A1F025F00D4EADF /* LICENSE */,
338-
C83E5DED2A38CD8C0071506D /* Makefile */,
339337
C8F103292A7A365000D28F4F /* launchAgent.plist */,
340338
C8738B6D2BE4F3E800609E7F /* bridgeLaunchAgent.plist */,
341339
C81E867D296FE4420026E908 /* Version.xcconfig */,

Core/Package.swift

Lines changed: 78 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -4,57 +4,6 @@
44
import Foundation
55
import PackageDescription
66

7-
// MARK: - Pro
8-
9-
extension [Target.Dependency] {
10-
func pro(_ targetNames: [String]) -> [Target.Dependency] {
11-
if isProIncluded {
12-
// include the pro package
13-
return self + targetNames.map { Target.Dependency.product(name: $0, package: "Pro") }
14-
}
15-
return self
16-
}
17-
}
18-
19-
extension [Package.Dependency] {
20-
var pro: [Package.Dependency] {
21-
if isProIncluded {
22-
// include the pro package
23-
return self + [.package(path: "../Pro/Pro")]
24-
}
25-
return self
26-
}
27-
}
28-
29-
let isProIncluded: Bool = {
30-
func isProIncluded(file: StaticString = #file) -> Bool {
31-
let filePath = "\(file)"
32-
let fileURL = URL(fileURLWithPath: filePath)
33-
let rootURL = fileURL
34-
.deletingLastPathComponent()
35-
.deletingLastPathComponent()
36-
let confURL = rootURL.appendingPathComponent("PLUS")
37-
if !FileManager.default.fileExists(atPath: confURL.path) {
38-
return false
39-
}
40-
do {
41-
if let content = try String(
42-
data: Data(contentsOf: confURL),
43-
encoding: .utf8
44-
) {
45-
if content.hasPrefix("YES") {
46-
return true
47-
}
48-
}
49-
return false
50-
} catch {
51-
return false
52-
}
53-
}
54-
55-
return isProIncluded()
56-
}()
57-
587
// MARK: - Package
598

609
let package = Package(
@@ -101,6 +50,8 @@ let package = Package(
10150
// quick hack to support custom UserDefaults
10251
// https://github.com/sindresorhus/KeyboardShortcuts
10352
.package(url: "https://github.com/intitni/KeyboardShortcuts", branch: "main"),
53+
.package(url: "https://github.com/intitni/CGEventOverride", from: "1.2.1"),
54+
.package(url: "https://github.com/intitni/Highlightr", branch: "master"),
10455
].pro,
10556
targets: [
10657
// MARK: - Main
@@ -110,7 +61,7 @@ let package = Package(
11061
dependencies: [
11162
.product(name: "XPCShared", package: "Tool"),
11263
.product(name: "SuggestionProvider", package: "Tool"),
113-
.product(name: "SuggestionModel", package: "Tool"),
64+
.product(name: "SuggestionBasic", package: "Tool"),
11465
.product(name: "Logger", package: "Tool"),
11566
.product(name: "Preferences", package: "Tool"),
11667
].pro([
@@ -127,12 +78,14 @@ let package = Package(
12778
"ServiceUpdateMigration",
12879
"ChatGPTChatTab",
12980
"PlusFeatureFlag",
81+
"KeyBindingManager",
82+
"XcodeThemeController",
13083
.product(name: "XPCShared", package: "Tool"),
13184
.product(name: "SuggestionProvider", package: "Tool"),
13285
.product(name: "Workspace", package: "Tool"),
13386
.product(name: "UserDefaultsObserver", package: "Tool"),
13487
.product(name: "AppMonitoring", package: "Tool"),
135-
.product(name: "SuggestionModel", package: "Tool"),
88+
.product(name: "SuggestionBasic", package: "Tool"),
13689
.product(name: "ChatTab", package: "Tool"),
13790
.product(name: "Logger", package: "Tool"),
13891
.product(name: "OpenAIService", package: "Tool"),
@@ -153,7 +106,7 @@ let package = Package(
153106
"SuggestionInjector",
154107
.product(name: "XPCShared", package: "Tool"),
155108
.product(name: "SuggestionProvider", package: "Tool"),
156-
.product(name: "SuggestionModel", package: "Tool"),
109+
.product(name: "SuggestionBasic", package: "Tool"),
157110
.product(name: "Preferences", package: "Tool"),
158111
]
159112
),
@@ -169,7 +122,7 @@ let package = Package(
169122
.product(name: "SuggestionProvider", package: "Tool"),
170123
.product(name: "Toast", package: "Tool"),
171124
.product(name: "SharedUIComponents", package: "Tool"),
172-
.product(name: "SuggestionModel", package: "Tool"),
125+
.product(name: "SuggestionBasic", package: "Tool"),
173126
.product(name: "MarkdownUI", package: "swift-markdown-ui"),
174127
.product(name: "OpenAIService", package: "Tool"),
175128
.product(name: "Preferences", package: "Tool"),
@@ -187,15 +140,15 @@ let package = Package(
187140
dependencies: [
188141
.product(name: "UserDefaultsObserver", package: "Tool"),
189142
.product(name: "Preferences", package: "Tool"),
190-
.product(name: "SuggestionModel", package: "Tool"),
143+
.product(name: "SuggestionBasic", package: "Tool"),
191144
.product(name: "SuggestionProvider", package: "Tool")
192145
].pro([
193146
"ProExtension",
194147
])
195148
),
196149
.target(
197150
name: "SuggestionInjector",
198-
dependencies: [.product(name: "SuggestionModel", package: "Tool")]
151+
dependencies: [.product(name: "SuggestionBasic", package: "Tool")]
199152
),
200153
.testTarget(
201154
name: "SuggestionInjectorTests",
@@ -208,7 +161,7 @@ let package = Package(
208161
name: "PromptToCodeService",
209162
dependencies: [
210163
.product(name: "FocusedCodeFinder", package: "Tool"),
211-
.product(name: "SuggestionModel", package: "Tool"),
164+
.product(name: "SuggestionBasic", package: "Tool"),
212165
.product(name: "OpenAIService", package: "Tool"),
213166
.product(name: "AppMonitoring", package: "Tool"),
214167
.product(name: "ComposableArchitecture", package: "swift-composable-architecture"),
@@ -377,6 +330,73 @@ let package = Package(
377330
],
378331
path: "Sources/ChatContextCollectors/SystemInfoChatContextCollector"
379332
),
333+
334+
// MARK: Key Binding
335+
336+
.target(
337+
name: "KeyBindingManager",
338+
dependencies: [
339+
.product(name: "Workspace", package: "Tool"),
340+
.product(name: "Preferences", package: "Tool"),
341+
.product(name: "Logger", package: "Tool"),
342+
.product(name: "CGEventOverride", package: "CGEventOverride"),
343+
.product(name: "AppMonitoring", package: "Tool"),
344+
.product(name: "UserDefaultsObserver", package: "Tool"),
345+
]
346+
),
347+
.testTarget(
348+
name: "KeyBindingManagerTests",
349+
dependencies: ["KeyBindingManager"]
350+
),
351+
352+
// MARK: Theming
353+
354+
.target(
355+
name: "XcodeThemeController",
356+
dependencies: [
357+
.product(name: "Preferences", package: "Tool"),
358+
.product(name: "AppMonitoring", package: "Tool"),
359+
.product(name: "Highlightr", package: "Highlightr"),
360+
]
361+
),
362+
380363
]
381364
)
382365

366+
extension [Target.Dependency] {
367+
func pro(_ targetNames: [String]) -> [Target.Dependency] {
368+
if isProIncluded {
369+
// include the pro package
370+
return self + targetNames.map { Target.Dependency.product(name: $0, package: "Pro") }
371+
}
372+
return self
373+
}
374+
}
375+
376+
extension [Package.Dependency] {
377+
var pro: [Package.Dependency] {
378+
if isProIncluded {
379+
// include the pro package
380+
return self + [.package(path: "../../CopilotForXcodePro/Pro")]
381+
}
382+
return self
383+
}
384+
}
385+
386+
let isProIncluded: Bool = {
387+
func isProIncluded(file: StaticString = #file) -> Bool {
388+
let filePath = "\(file)"
389+
let fileURL = URL(fileURLWithPath: filePath)
390+
let rootURL = fileURL
391+
.deletingLastPathComponent()
392+
.deletingLastPathComponent()
393+
.deletingLastPathComponent()
394+
let confURL = rootURL.appendingPathComponent("PLUS")
395+
if !FileManager.default.fileExists(atPath: confURL.path) {
396+
return false
397+
}
398+
return true
399+
}
400+
401+
return isProIncluded()
402+
}()

Core/Sources/ChatContextCollectors/WebChatContextCollector/QueryWebsiteFunction.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import ChatBasic
12
import Foundation
23
import LangChain
34
import OpenAIService

Core/Sources/ChatContextCollectors/WebChatContextCollector/SearchFunction.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import BingSearchService
2+
import ChatBasic
23
import Foundation
34
import OpenAIService
45
import Preferences

Core/Sources/ChatContextCollectors/WebChatContextCollector/WebChatContextCollector.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import ChatBasic
12
import ChatContextCollector
23
import Foundation
34
import OpenAIService

Core/Sources/ChatGPTChatTab/Chat.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import ChatBasic
12
import ChatService
23
import ComposableArchitecture
34
import Foundation
5+
import MarkdownUI
46
import OpenAIService
57
import Preferences
68
import Terminal
@@ -40,12 +42,14 @@ public struct DisplayedChatMessage: Equatable {
4042
public var id: String
4143
public var role: Role
4244
public var text: String
45+
public var markdownContent: MarkdownContent
4346
public var references: [Reference] = []
4447

4548
public init(id: String, role: Role, text: String, references: [Reference]) {
4649
self.id = id
4750
self.role = role
4851
self.text = text
52+
markdownContent = .init(text)
4953
self.references = references
5054
}
5155
}
@@ -151,7 +155,7 @@ struct Chat {
151155
case let .setIsEnabled(isEnabled):
152156
state.isEnabled = isEnabled
153157
return .none
154-
158+
155159
case .sendButtonTapped:
156160
guard !state.typedMessage.isEmpty else { return .none }
157161
let message = state.typedMessage
@@ -213,11 +217,11 @@ struct Chat {
213217
await openURL(url)
214218
}
215219
}
216-
220+
217221
case .manuallyScrolledUp:
218222
state.isPinnedToBottom = false
219223
return .none
220-
224+
221225
case .scrollToBottomButtonTapped:
222226
state.isPinnedToBottom = true
223227
return .none
@@ -248,7 +252,7 @@ struct Chat {
248252
let debouncedHistoryChange = TimedDebounceFunction(duration: 0.2) {
249253
await send(.historyChanged)
250254
}
251-
255+
252256
for await _ in stream {
253257
await debouncedHistoryChange()
254258
}
@@ -502,9 +506,10 @@ private actor TimedDebounceFunction {
502506
}
503507
}
504508
}
505-
509+
506510
func fire() async {
507511
lastFireTime = Date()
508512
await block()
509513
}
510514
}
515+

0 commit comments

Comments
 (0)