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
365 lines (285 loc) · 11.4 KB
/
Keys.swift
File metadata and controls
365 lines (285 loc) · 11.4 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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
import Foundation
public protocol UserDefaultPreferenceKey {
associatedtype Value
var defaultValue: Value { get }
var key: String { get }
}
public struct PreferenceKey<T>: UserDefaultPreferenceKey {
public let defaultValue: T
public let key: String
}
public struct FeatureFlag: UserDefaultPreferenceKey {
public let defaultValue: Bool
public let key: String
}
public struct UserDefaultPreferenceKeys {
public init() {}
// MARK: Quit XPC Service On Xcode And App Quit
public let quitXPCServiceOnXcodeAndAppQuit = PreferenceKey(
defaultValue: true,
key: "QuitXPCServiceOnXcodeAndAppQuit"
)
// MARK: Automatically Check For Update
public let automaticallyCheckForUpdate = PreferenceKey(
defaultValue: false,
key: "AutomaticallyCheckForUpdate"
)
// MARK: Suggestion Widget Position Mode
public let suggestionWidgetPositionMode = PreferenceKey(
defaultValue: SuggestionWidgetPositionMode.fixedToBottom,
key: "SuggestionWidgetPositionMode"
)
// MARK: Widget Color Scheme
public let widgetColorScheme = PreferenceKey(
defaultValue: WidgetColorScheme.dark,
key: "WidgetColorScheme"
)
// MARK: Force Order Widget to Front
public let forceOrderWidgetToFront = PreferenceKey(
defaultValue: true,
key: "ForceOrderWidgetToFront"
)
// MARK: Prefer Widget to Stay Inside Editor When Width Greater Than
public let preferWidgetToStayInsideEditorWhenWidthGreaterThan = PreferenceKey(
defaultValue: 1400 as Double,
key: "PreferWidgetToStayInsideEditorWhenWidthGreaterThan"
)
}
// MARK: - OpenAI Account Settings
public extension UserDefaultPreferenceKeys {
var openAIAPIKey: PreferenceKey<String> {
.init(defaultValue: "", key: "OpenAIAPIKey")
}
@available(*, deprecated, message: "Use `openAIBaseURL` instead.")
var chatGPTEndpoint: PreferenceKey<String> {
.init(defaultValue: "", key: "ChatGPTEndpoint")
}
var openAIBaseURL: PreferenceKey<String> {
.init(defaultValue: "", key: "OpenAIBaseURL")
}
var chatGPTModel: PreferenceKey<String> {
.init(defaultValue: Preferences.ChatGPTModel.gpt35Turbo.rawValue, key: "ChatGPTModel")
}
var chatGPTMaxToken: PreferenceKey<Int> {
.init(defaultValue: 4000, key: "ChatGPTMaxToken")
}
var chatGPTLanguage: PreferenceKey<String> {
.init(defaultValue: "", key: "ChatGPTLanguage")
}
var chatGPTMaxMessageCount: PreferenceKey<Int> {
.init(defaultValue: 5, key: "ChatGPTMaxMessageCount")
}
var chatGPTTemperature: PreferenceKey<Double> {
.init(defaultValue: 0.7, key: "ChatGPTTemperature")
}
}
// MARK: - Azure OpenAI Settings
public extension UserDefaultPreferenceKeys {
var azureOpenAIAPIKey: PreferenceKey<String> {
.init(defaultValue: "", key: "AzureOpenAIAPIKey")
}
var azureOpenAIBaseURL: PreferenceKey<String> {
.init(defaultValue: "", key: "AzureOpenAIBaseURL")
}
var azureChatGPTDeployment: PreferenceKey<String> {
.init(defaultValue: "", key: "AzureChatGPTDeployment")
}
}
// MARK: - GitHub Copilot Settings
public extension UserDefaultPreferenceKeys {
var gitHubCopilotVerboseLog: PreferenceKey<Bool> {
.init(defaultValue: false, key: "GitHubCopilotVerboseLog")
}
var gitHubCopilotProxyHost: PreferenceKey<String> {
.init(defaultValue: "", key: "GitHubCopilotProxyHost")
}
var gitHubCopilotProxyPort: PreferenceKey<String> {
.init(defaultValue: "", key: "GitHubCopilotProxyPort")
}
var gitHubCopilotUseStrictSSL: PreferenceKey<Bool> {
.init(defaultValue: true, key: "GitHubCopilotUseStrictSSL")
}
var gitHubCopilotProxyUsername: PreferenceKey<String> {
.init(defaultValue: "", key: "GitHubCopilotProxyUsername")
}
var gitHubCopilotProxyPassword: PreferenceKey<String> {
.init(defaultValue: "", key: "GitHubCopilotProxyPassword")
}
var nodePath: PreferenceKey<String> {
.init(defaultValue: "", key: "NodePath")
}
var runNodeWith: PreferenceKey<NodeRunner> {
.init(defaultValue: .env, key: "RunNodeWith")
}
}
// MARK: - Codeium Settings
public extension UserDefaultPreferenceKeys {
var codeiumVerboseLog: PreferenceKey<Bool> {
.init(defaultValue: false, key: "CodeiumVerboseLog")
}
}
// MARK: - Prompt to Code
public extension UserDefaultPreferenceKeys {
var promptToCodeFeatureProvider: PreferenceKey<PromptToCodeFeatureProvider> {
.init(defaultValue: .openAI, key: "PromptToCodeFeatureProvider")
}
var promptToCodeGenerateDescription: PreferenceKey<Bool> {
.init(defaultValue: true, key: "PromptToCodeGenerateDescription")
}
var promptToCodeGenerateDescriptionInUserPreferredLanguage: PreferenceKey<Bool> {
.init(defaultValue: true, key: "PromptToCodeGenerateDescriptionInUserPreferredLanguage")
}
}
// MARK: - Suggestion
public extension UserDefaultPreferenceKeys {
var suggestionFeatureProvider: PreferenceKey<SuggestionFeatureProvider> {
.init(defaultValue: .gitHubCopilot, key: "SuggestionFeatureProvider")
}
var realtimeSuggestionToggle: PreferenceKey<Bool> {
.init(defaultValue: true, key: "RealtimeSuggestionToggle")
}
var suggestionCodeFontSize: PreferenceKey<Double> {
.init(defaultValue: 13, key: "SuggestionCodeFontSize")
}
var disableSuggestionFeatureGlobally: PreferenceKey<Bool> {
.init(defaultValue: false, key: "DisableSuggestionFeatureGlobally")
}
var suggestionFeatureEnabledProjectList: PreferenceKey<[String]> {
.init(defaultValue: [], key: "SuggestionFeatureEnabledProjectList")
}
var suggestionFeatureDisabledLanguageList: PreferenceKey<[String]> {
.init(defaultValue: [], key: "SuggestionFeatureDisabledLanguageList")
}
var hideCommonPrecedingSpacesInSuggestion: PreferenceKey<Bool> {
.init(defaultValue: true, key: "HideCommonPrecedingSpacesInSuggestion")
}
var acceptSuggestionWithAccessibilityAPI: PreferenceKey<Bool> {
.init(defaultValue: false, key: "AcceptSuggestionWithAccessibilityAPI")
}
var suggestionPresentationMode: PreferenceKey<PresentationMode> {
.init(defaultValue: .floatingWidget, key: "SuggestionPresentationMode")
}
var realtimeSuggestionDebounce: PreferenceKey<Double> {
.init(defaultValue: 0, key: "RealtimeSuggestionDebounce")
}
}
// MARK: - Chat
public extension UserDefaultPreferenceKeys {
var chatFeatureProvider: PreferenceKey<ChatFeatureProvider> {
.init(defaultValue: .openAI, key: "ChatFeatureProvider")
}
var chatFontSize: PreferenceKey<Double> {
.init(defaultValue: 12, key: "ChatFontSize")
}
var chatCodeFontSize: PreferenceKey<Double> {
.init(defaultValue: 12, key: "ChatCodeFontSize")
}
var useGlobalChat: PreferenceKey<Bool> {
.init(defaultValue: true, key: "UseGlobalChat")
}
var embedFileContentInChatContextIfNoSelection: PreferenceKey<Bool> {
.init(defaultValue: false, key: "EmbedFileContentInChatContextIfNoSelection")
}
var maxEmbeddableFileInChatContextLineCount: PreferenceKey<Int> {
.init(defaultValue: 100, key: "MaxEmbeddableFileInChatContextLineCount")
}
var useSelectionScopeByDefaultInChatContext: PreferenceKey<Bool> {
.init(defaultValue: true, key: "UseSelectionScopeByDefaultInChatContext")
}
var defaultChatSystemPrompt: PreferenceKey<String> {
.init(
defaultValue: """
You are an AI programming assistant.
Your reply should be concise, clear, informative and logical.
You MUST reply in the format of markdown.
You MUST embed every code you provide in a markdown code block.
You MUST add the programming language name at the start of the markdown code block.
If you are asked to help perform a task, you MUST think step-by-step, then describe each step concisely.
If you are asked to explain code, you MUST explain it step-by-step in a ordered list.
Make your answer short and structured.
""",
key: "DefaultChatSystemPrompt"
)
}
var chatSearchPluginMaxIterations: PreferenceKey<Int> {
.init(defaultValue: 3, key: "ChatSearchPluginMaxIterations")
}
}
// MARK: - Bing Search
public extension UserDefaultPreferenceKeys {
var bingSearchSubscriptionKey: PreferenceKey<String> {
.init(defaultValue: "", key: "BingSearchSubscriptionKey")
}
var bingSearchEndpoint: PreferenceKey<String> {
.init(
defaultValue: "https://api.bing.microsoft.com/v7.0/search/",
key: "BingSearchEndpoint"
)
}
}
// MARK: - Custom Commands
public extension UserDefaultPreferenceKeys {
var customCommands: PreferenceKey<[CustomCommand]> {
.init(defaultValue: [
.init(
commandId: "BuiltInCustomCommandExplainSelection",
name: "Explain Selection",
feature: .chatWithSelection(
extraSystemPrompt: "",
prompt: "Explain the selected code concisely, step-by-step.",
useExtraSystemPrompt: true
)
),
.init(
commandId: "BuiltInCustomCommandAddDocumentationToSelection",
name: "Add Documentation to Selection",
feature: .promptToCode(
extraSystemPrompt: "",
prompt: "Add documentation on top of the code. Use triple slash if the language supports it.",
continuousMode: false,
generateDescription: true
)
),
.init(
commandId: "BuiltInCustomCommandSendCodeToChat",
name: "Send Selected Code to Chat",
feature: .chatWithSelection(
extraSystemPrompt: "",
prompt: """
```{{active_editor_language}}
{{selected_code}}
```
""",
useExtraSystemPrompt: true
)
),
], key: "CustomCommands")
}
}
// MARK: - Feature Flags
public extension UserDefaultPreferenceKeys {
var disableLazyVStack: FeatureFlag {
.init(defaultValue: false, key: "FeatureFlag-DisableLazyVStack")
}
var preCacheOnFileOpen: FeatureFlag {
.init(defaultValue: true, key: "FeatureFlag-PreCacheOnFileOpen")
}
var runNodeWithInteractiveLoggedInShell: FeatureFlag {
.init(defaultValue: true, key: "FeatureFlag-RunNodeWithInteractiveLoggedInShell")
}
var useCustomScrollViewWorkaround: FeatureFlag {
.init(defaultValue: true, key: "FeatureFlag-UseCustomScrollViewWorkaround")
}
var triggerActionWithAccessibilityAPI: FeatureFlag {
.init(defaultValue: true, key: "FeatureFlag-TriggerActionWithAccessibilityAPI")
}
var animationACrashSuggestion: FeatureFlag {
.init(defaultValue: true, key: "FeatureFlag-AnimationACrashSuggestion")
}
var animationBCrashSuggestion: FeatureFlag {
.init(defaultValue: true, key: "FeatureFlag-AnimationBCrashSuggestion")
}
var animationCCrashSuggestion: FeatureFlag {
.init(defaultValue: true, key: "FeatureFlag-AnimationCCrashSuggestion")
}
}