Skip to content

Commit 92a58b4

Browse files
committed
Restructure the Shared package to Core package
1 parent a965277 commit 92a58b4

Some content is hidden

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

45 files changed

+124
-89
lines changed
File renamed without changes.

Shared/.swiftpm/xcode/xcshareddata/xcschemes/Shared.xcscheme renamed to Core/.swiftpm/xcode/xcshareddata/xcschemes/Core-Package.xcscheme

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
buildForAnalyzing = "YES">
1515
<BuildableReference
1616
BuildableIdentifier = "primary"
17-
BlueprintIdentifier = "Shared"
18-
BuildableName = "Shared"
19-
BlueprintName = "Shared"
17+
BlueprintIdentifier = "Core"
18+
BuildableName = "Core"
19+
BlueprintName = "Core"
2020
ReferencedContainer = "container:">
2121
</BuildableReference>
2222
</BuildActionEntry>
@@ -49,9 +49,9 @@
4949
<MacroExpansion>
5050
<BuildableReference
5151
BuildableIdentifier = "primary"
52-
BlueprintIdentifier = "Shared"
53-
BuildableName = "Shared"
54-
BlueprintName = "Shared"
52+
BlueprintIdentifier = "Core"
53+
BuildableName = "Core"
54+
BlueprintName = "Core"
5555
ReferencedContainer = "container:">
5656
</BuildableReference>
5757
</MacroExpansion>
Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
import PackageDescription
55

66
let package = Package(
7-
name: "Shared",
7+
name: "Core",
88
platforms: [.macOS(.v13)],
99
products: [
1010
.library(
11-
name: "Shared",
12-
targets: ["Shared", "SuggestionService"]
11+
name: "Core",
12+
targets: ["Storage", "SuggestionService", "Fundamental"]
1313
),
1414
],
1515
dependencies: [
@@ -27,7 +27,7 @@ let package = Package(
2727
],
2828
targets: [
2929
.target(
30-
name: "Shared",
30+
name: "Fundamental",
3131
dependencies: [
3232
.product(name: "CodableWrappers", package: "CodableWrappers"),
3333
.product(name: "CopilotForXcodeKit", package: "CopilotForXcodeKit"),
@@ -36,14 +36,31 @@ let package = Package(
3636
.product(name: "Parsing", package: "swift-parsing"),
3737
]
3838
),
39-
.testTarget(
40-
name: "SharedTests",
41-
dependencies: ["Shared"]
39+
.target(
40+
name: "Storage",
41+
dependencies: [
42+
"Fundamental",
43+
.product(name: "CodableWrappers", package: "CodableWrappers"),
44+
.product(name: "Dependencies", package: "swift-dependencies"),
45+
]
46+
),
47+
.target(
48+
name: "CodeCompletionService",
49+
dependencies: [
50+
"Storage",
51+
"Fundamental",
52+
.product(name: "CodableWrappers", package: "CodableWrappers"),
53+
.product(name: "CopilotForXcodeKit", package: "CopilotForXcodeKit"),
54+
.product(name: "Dependencies", package: "swift-dependencies"),
55+
.product(name: "GoogleGenerativeAI", package: "generative-ai-swift"),
56+
]
4257
),
4358
.target(
4459
name: "SuggestionService",
4560
dependencies: [
46-
"Shared",
61+
"Fundamental",
62+
"CodeCompletionService",
63+
"Storage",
4764
.product(name: "CopilotForXcodeKit", package: "CopilotForXcodeKit"),
4865
.product(name: "Parsing", package: "swift-parsing"),
4966
]

Shared/Sources/Shared/CodeCompletionService/AzureOpenAIService.swift renamed to Core/Sources/CodeCompletionService/AzureOpenAIService.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import CopilotForXcodeKit
22
import Foundation
3+
import Fundamental
34

45
public actor AzureOpenAIService {
56
let url: URL
@@ -10,7 +11,7 @@ public actor AzureOpenAIService {
1011
let apiKey: String
1112
let stopWords: [String]
1213

13-
public init(
14+
init(
1415
url: String? = nil,
1516
endpoint: OpenAIService.Endpoint,
1617
modelName: String,

Shared/Sources/Shared/CodeCompletionService/CodeCompletionLogger.swift renamed to Core/Sources/CodeCompletionService/CodeCompletionLogger.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import CopilotForXcodeKit
22
import Foundation
3+
import Fundamental
34

45
public final class CodeCompletionLogger {
56
struct Model {
@@ -19,15 +20,15 @@ public final class CodeCompletionLogger {
1920
indentSize: 0,
2021
usesTabsForIndentation: false,
2122
relevantCodeSnippets: []
22-
))
23+
))
2324

2425
let request: SuggestionRequest
2526
var model = Model(type: "", format: "", modelName: "", baseURL: "")
2627
var prompt: [(message: String, role: String)] = []
2728
var responses: [String] = []
2829
let startTime = Date()
2930
let id = UUID()
30-
31+
3132
var shouldLogToConsole: Bool {
3233
#if DEBUG
3334
return true
@@ -57,7 +58,7 @@ public final class CodeCompletionLogger {
5758
baseURL: completionModel.info.baseURL
5859
)
5960
}
60-
61+
6162
public func logModel(_ tabbyModel: TabbyModel) {
6263
model = .init(
6364
type: "Tabby",
@@ -77,14 +78,14 @@ public final class CodeCompletionLogger {
7778

7879
public func error(_ error: Error) {
7980
guard shouldLogToConsole else { return }
80-
81+
8182
let now = Date()
8283
let duration = now.timeIntervalSince(startTime)
8384
let formattedDuration = String(format: "%.2f", duration)
84-
85+
8586
Logger.service.info("""
8687
[Request] \(id)
87-
88+
8889
Duration: \(formattedDuration)
8990
Error: \(error.localizedDescription).
9091
""")
@@ -109,13 +110,13 @@ public final class CodeCompletionLogger {
109110
Code Snippets: \(request.relevantCodeSnippets.count) snippets
110111
CursorPosition: \(request.cursorPosition)
111112
""")
112-
113+
113114
Logger.service.info("""
114115
[Prompt] \(id)
115116
116117
\(prompt.map { "\($0.role): \($0.message)" }.joined(separator: "\n\n"))
117118
""")
118-
119+
119120
Logger.service.info("""
120121
[Response] \(id)
121122

Shared/Sources/Shared/CodeCompletionService/CodeCompletionService.swift renamed to Core/Sources/CodeCompletionService/CodeCompletionService.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import Foundation
2+
import Fundamental
3+
import Storage
24

35
protocol CodeCompletionServiceType {
46
func getCompletion(
@@ -63,7 +65,7 @@ public struct CodeCompletionService {
6365
return .customHeaderField(name: model.authorizationHeaderName, value: apiKey)
6466
}
6567
}())
66-
68+
6769
let result = try await service.getCompletions(prompt, count: count)
6870
try Task.checkCancellation()
6971
return result

Shared/Sources/Shared/CodeCompletionService/GoogleGeminiService.swift renamed to Core/Sources/CodeCompletionService/GoogleGeminiService.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Foundation
2+
import Fundamental
23
import GoogleGenerativeAI
34

45
public struct GoogleGeminiService {
@@ -8,7 +9,7 @@ public struct GoogleGeminiService {
89
let stopWords: [String]
910
let apiKey: String
1011

11-
public init(
12+
init(
1213
modelName: String,
1314
maxToken: Int? = nil,
1415
temperature: Double = 0.2,

Shared/Sources/Shared/CodeCompletionService/OpenAIService.swift renamed to Core/Sources/CodeCompletionService/OpenAIService.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import CopilotForXcodeKit
22
import Foundation
3+
import Fundamental
34

45
public actor OpenAIService {
56
let url: URL
@@ -15,7 +16,7 @@ public actor OpenAIService {
1516
case chatCompletion
1617
}
1718

18-
public init(
19+
init(
1920
url: String? = nil,
2021
endpoint: Endpoint,
2122
modelName: String,
@@ -112,7 +113,7 @@ extension OpenAIService {
112113
))
113114
let prompts = strategy.createTruncatedPrompt(promptStrategy: request)
114115
return [
115-
.init(role: .system, content: request.systemPrompt)
116+
.init(role: .system, content: request.systemPrompt),
116117
] + prompts.map { prompt in
117118
switch prompt.role {
118119
case .user:

Shared/Sources/Shared/CodeCompletionService/TabbyService.swift renamed to Core/Sources/CodeCompletionService/TabbyService.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import CopilotForXcodeKit
22
import Foundation
3+
import Fundamental
34

45
actor TabbyService {
56
enum AuthorizationMode {
@@ -122,7 +123,7 @@ extension TabbyService {
122123
return body.choices.first?.text ?? ""
123124
} catch {
124125
dump(error)
125-
throw Error.decodeError(error)
126+
throw Error.decodeError(error)
126127
}
127128
}
128129
}

0 commit comments

Comments
 (0)