forked from intitni/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeys.swift
More file actions
334 lines (246 loc) · 10.5 KB
/
Keys.swift
File metadata and controls
334 lines (246 loc) · 10.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
import Foundation
public protocol UserDefaultPreferenceKey {
associatedtype Value
var defaultValue: Value { get }
var key: String { get }
}
public struct UserDefaultPreferenceKeys {
public init() {}
// MARK: - Node Path
public struct NodePath: UserDefaultPreferenceKey {
public let defaultValue: String = ""
public let key = "NodePath"
}
public var nodePath: NodePath { .init() }
// MARK: - Run Node With
public struct RunNodeWithKey: UserDefaultPreferenceKey {
public let defaultValue = NodeRunner.bash
public let key = "RunNodeWith"
}
public var runNodeWith: RunNodeWithKey { .init() }
// MARK: - Realtime Suggestion
public struct RealtimeSuggestionToggle: UserDefaultPreferenceKey {
public let defaultValue: Bool = false
public let key = "RealtimeSuggestionToggle"
}
public var realtimeSuggestionToggle: RealtimeSuggestionToggle { .init() }
// MARK: - Realtime Suggestion Debounce
public struct RealtimeSuggestionDebounce: UserDefaultPreferenceKey {
public let defaultValue: Double = 1
public let key = "RealtimeSuggestionDebounce"
}
public var realtimeSuggestionDebounce: RealtimeSuggestionDebounce { .init() }
// MARK: - Quit XPC Service On Xcode And App Quit
public struct QuitXPCServiceOnXcodeAndAppQuit: UserDefaultPreferenceKey {
public let defaultValue = true
public let key = "QuitXPCServiceOnXcodeAndAppQuit"
}
public var quitXPCServiceOnXcodeAndAppQuit: QuitXPCServiceOnXcodeAndAppQuit { .init() }
// MARK: - Suggestion Presentation Mode
public struct SuggestionPresentationMode: UserDefaultPreferenceKey {
public let defaultValue = PresentationMode.floatingWidget
public let key = "SuggestionPresentationMode"
}
public var suggestionPresentationMode: SuggestionPresentationMode { .init() }
// MARK: - Automatically Check For Update
public struct AutomaticallyCheckForUpdate: UserDefaultPreferenceKey {
public let defaultValue = false
public let key = "AutomaticallyCheckForUpdate"
}
public var automaticallyCheckForUpdate: AutomaticallyCheckForUpdate { .init() }
// MARK: - Suggestion Widget Position Mode
public struct SuggestionWidgetPositionModeKey: UserDefaultPreferenceKey {
public let defaultValue = SuggestionWidgetPositionMode.fixedToBottom
public let key = "SuggestionWidgetPositionMode"
}
public var suggestionWidgetPositionMode: SuggestionWidgetPositionModeKey { .init() }
// MARK: - Widget Color Scheme
public struct WidgetColorSchemeKey: UserDefaultPreferenceKey {
public let defaultValue = WidgetColorScheme.dark
public let key = "WidgetColorScheme"
}
public var widgetColorScheme: WidgetColorSchemeKey { .init() }
// MARK: - Accept Suggestion with Accessibility API
public struct AcceptSuggestionWithAccessibilityAPI: UserDefaultPreferenceKey {
public let defaultValue = false
public let key = "AcceptSuggestionWithAccessibilityAPI"
}
public var acceptSuggestionWithAccessibilityAPI: AcceptSuggestionWithAccessibilityAPI {
.init()
}
// MARK: - Use Global Chat
public struct UseGlobalChat: UserDefaultPreferenceKey {
public let defaultValue = false
public let key = "UseGlobalChat"
}
public var useGlobalChat: UseGlobalChat { .init() }
// MARK: - Hide Common Preceding Spaces in Suggestion
public struct HideCommonPrecedingSpacesInSuggestion: UserDefaultPreferenceKey {
public let defaultValue = false
public let key = "HideCommonPrecedingSpacesInSuggestion"
}
public var hideCommonPrecedingSpacesInSuggestion: HideCommonPrecedingSpacesInSuggestion {
.init()
}
// MARK: - Force Order Widget to Front
public struct ForceOrderWidgetToFront: UserDefaultPreferenceKey {
public let defaultValue = true
public let key = "ForceOrderWidgetToFront"
}
public var forceOrderWidgetToFront: HideCommonPrecedingSpacesInSuggestion {
.init()
}
// MARK: - Disable Suggestion Feature Globally
public struct DisableSuggestionFeatureGlobally: UserDefaultPreferenceKey {
public let defaultValue = false
public let key = "DisableSuggestionFeatureGlobally"
}
public var disableSuggestionFeatureGlobally: DisableSuggestionFeatureGlobally {
.init()
}
// MARK: - Suggestion Feature Enabled Project List
public struct SuggestionFeatureEnabledProjectList: UserDefaultPreferenceKey {
public let defaultValue: [String] = []
public let key = "SuggestionFeatureEnabledProjectList"
}
public var suggestionFeatureEnabledProjectList: SuggestionFeatureEnabledProjectList {
.init()
}
// MARK: - Prompt to Code Feature Provider
public struct PromptToCodeFeatureProviderKey: UserDefaultPreferenceKey {
public let defaultValue: PromptToCodeFeatureProvider = .openAI
public let key = "PromptToCodeFeatureProvider"
}
public var promptToCodeFeatureProvider: PromptToCodeFeatureProviderKey {
.init()
}
// MARK: - Prefer Widget to Stay Inside Editor When Width Greater Than
public struct PreferWidgetToStayInsideEditorWhenWidthGreaterThan: UserDefaultPreferenceKey {
public let defaultValue = 1400 as Double
public let key = "PreferWidgetToStayInsideEditorWhenWidthGreaterThan"
}
public var preferWidgetToStayInsideEditorWhenWidthGreaterThan: PreferWidgetToStayInsideEditorWhenWidthGreaterThan {
.init()
}
// MARK: - Chat Panel in a Separate Window
public struct ChatPanelInASeparateWindow: UserDefaultPreferenceKey {
public let defaultValue = true
public let key = "ChatPanelInASeparateWindow"
}
public var chatPanelInASeparateWindow: ChatPanelInASeparateWindow {
.init()
}
}
// MARK: - OpenAI Account Settings
public extension UserDefaultPreferenceKeys {
struct OpenAIAPIKey: UserDefaultPreferenceKey {
public let defaultValue = ""
public let key = "OpenAIAPIKey"
}
var openAIAPIKey: OpenAIAPIKey { .init() }
struct ChatGPTEndpoint: UserDefaultPreferenceKey {
public let defaultValue = ""
public let key = "ChatGPTEndpoint"
}
var chatGPTEndpoint: ChatGPTEndpoint { .init() }
struct ChatGPTModel: UserDefaultPreferenceKey {
public let defaultValue = Preferences.ChatGPTModel.gpt35Turbo.rawValue
public let key = "ChatGPTModel"
}
var chatGPTModel: ChatGPTModel { .init() }
struct ChatGPTMaxToken: UserDefaultPreferenceKey {
public let defaultValue = 4000
public let key = "ChatGPTMaxToken"
}
var chatGPTMaxToken: ChatGPTMaxToken { .init() }
struct ChatGPTLanguage: UserDefaultPreferenceKey {
public let defaultValue = ""
public let key = "ChatGPTLanguage"
}
var chatGPTLanguage: ChatGPTLanguage { .init() }
struct ChatGPTMaxMessageCount: UserDefaultPreferenceKey {
public let defaultValue = 5
public let key = "ChatGPTMaxMessageCount"
}
var chatGPTMaxMessageCount: ChatGPTMaxMessageCount { .init() }
struct ChatGPTTemperature: UserDefaultPreferenceKey {
public let defaultValue = 0.7
public let key = "ChatGPTTemperature"
}
var chatGPTTemperature: ChatGPTTemperature { .init() }
}
// MARK: - UI
public extension UserDefaultPreferenceKeys {
struct SuggestionCodeFontSize: UserDefaultPreferenceKey {
public let defaultValue = 13 as Double
public let key = "SuggestionCodeFontSize"
}
var suggestionCodeFontSize: SuggestionCodeFontSize { .init() }
struct ChatFontSize: UserDefaultPreferenceKey {
public let defaultValue = 12 as Double
public let key = "ChatFontSize"
}
var chatFontSize: ChatFontSize { .init() }
struct ChatCodeFontSize: UserDefaultPreferenceKey {
public let defaultValue = 12 as Double
public let key = "ChatCodeFontSize"
}
var chatCodeFontSize: ChatCodeFontSize { .init() }
}
// MARK: - Custom Commands
public extension UserDefaultPreferenceKeys {
struct CustomCommandsKey: UserDefaultPreferenceKey {
public let defaultValue: [CustomCommand] = [
.init(
commandId: "BuiltInCustomCommandExplainSelection",
name: "Explain Selection",
feature: .chatWithSelection(
extraSystemPrompt: nil,
prompt: "Explain the code concisely, do not interpret or translate it."
)
),
.init(
commandId: "BuiltInCustomCommandAddDocumentationToSelection",
name: "Add Documentation to Selection",
feature: .promptToCode(
extraSystemPrompt: nil,
prompt: "Add documentation on top of the code. Use triple slash if the language supports it.",
continuousMode: false
)
),
]
public let key = "CustomCommands"
}
var customCommands: CustomCommandsKey { .init() }
}
// MARK: - Feature Flags
public enum FeatureFlags {
public struct DisableLazyVStack: UserDefaultPreferenceKey {
public let defaultValue = false
public let key = "FeatureFlag-DisableLazyVStack"
}
public struct PreCacheOnFileOpen: UserDefaultPreferenceKey {
public let defaultValue = true
public let key = "FeatureFlag-PreCacheOnFileOpen"
}
public struct RunNodeWithInteractiveLoggedInShell: UserDefaultPreferenceKey {
public let defaultValue = true
public let key = "FeatureFlag-RunNodeWithInteractiveLoggedInShell"
}
public struct UseCustomScrollViewWorkaround: UserDefaultPreferenceKey {
public let defaultValue = true
public let key = "FeatureFlag-UseCustomScrollViewWorkaround"
}
public struct TriggerActionWithAccessibilityAPI: UserDefaultPreferenceKey {
public let defaultValue = true
public let key = "FeatureFlag-TriggerActionWithAccessibilityAPI"
}
}
public extension UserDefaultPreferenceKeys {
var disableLazyVStack: FeatureFlags.DisableLazyVStack { .init() }
var preCacheOnFileOpen: FeatureFlags.PreCacheOnFileOpen { .init() }
var runNodeWithInteractiveLoggedInShell: FeatureFlags
.RunNodeWithInteractiveLoggedInShell { .init() }
var useCustomScrollViewWorkaround: FeatureFlags.UseCustomScrollViewWorkaround { .init() }
var triggerActionWithAccessibilityAPI: FeatureFlags.TriggerActionWithAccessibilityAPI { .init() }
}