Skip to content

Commit d864a22

Browse files
committed
Merge branch 'feature/langchain-service' into develop
2 parents 4f338f8 + 386bddf commit d864a22

46 files changed

Lines changed: 672 additions & 38 deletions

Some content is hidden

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

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,12 @@ iOSInjectionProject/
123123

124124
# End of
125125
https://www.toptal.com/developers/gitignore/api/xcode,macos,swift,swiftpackagemanager
126+
126127
Secrets.xcconfig
128+
Python/Python.xcframework
129+
Python/python-stdlib
130+
Python/site-packages/*
131+
!Python/site-packages/requirements.txt
132+
!Python/site-packages/install.sh
133+
134+
Python/VERSIONS

Copilot for Xcode.xcodeproj/project.pbxproj

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
C87B03AC293B2CF300C77EAE /* XcodeKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C81458902939EFDC00135263 /* XcodeKit.framework */; };
3939
C87B03AD293B2CF300C77EAE /* XcodeKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C81458902939EFDC00135263 /* XcodeKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
4040
C882175C294187EF00A22FD3 /* Client in Frameworks */ = {isa = PBXBuildFile; productRef = C882175B294187EF00A22FD3 /* Client */; };
41+
C8A3AE522A2884DA0046E809 /* Python.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = C8A3AE512A2883430046E809 /* Python.xcframework */; };
42+
C8A3AE592A2885A70046E809 /* InitializePython.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8A3AE582A2885A70046E809 /* InitializePython.swift */; };
43+
C8A3AE5B2A288AF90046E809 /* site-packages in Resources */ = {isa = PBXBuildFile; fileRef = C8A3AE5A2A288AF90046E809 /* site-packages */; };
44+
C8A3B1772A288FA90046E809 /* python-stdlib in Resources */ = {isa = PBXBuildFile; fileRef = C8A3B1762A288FA90046E809 /* python-stdlib */; };
4145
C8C8B60929AFA35F00034BEE /* CopilotForXcodeExtensionService.app in Embed XPCService */ = {isa = PBXBuildFile; fileRef = C861E60E2994F6070056CB02 /* CopilotForXcodeExtensionService.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
4246
C8DCF00029CE11D500FDDDD7 /* ChatWithSelection.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8DCEFFF29CE11D500FDDDD7 /* ChatWithSelection.swift */; };
4347
/* End PBXBuildFile section */
@@ -143,6 +147,7 @@
143147
C8189B202938973000C9DCDA /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
144148
C8189B222938973000C9DCDA /* Copilot_for_Xcode.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Copilot_for_Xcode.entitlements; sourceTree = "<group>"; };
145149
C8189B282938979000C9DCDA /* Core */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Core; sourceTree = "<group>"; };
150+
C81D181E2A1B509B006C1B70 /* Tool */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Tool; sourceTree = "<group>"; };
146151
C81E867D296FE4420026E908 /* Version.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
147152
C8216B70298036EC00AD38C7 /* Helper */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Helper; sourceTree = BUILT_PRODUCTS_DIR; };
148153
C8216B72298036EC00AD38C7 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
@@ -164,6 +169,10 @@
164169
C87B03A8293B262600C77EAE /* NextSuggestionCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextSuggestionCommand.swift; sourceTree = "<group>"; };
165170
C87B03AA293B262E00C77EAE /* PreviousSuggestionCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviousSuggestionCommand.swift; sourceTree = "<group>"; };
166171
C887BC832965D96000931567 /* DEVELOPMENT.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = DEVELOPMENT.md; sourceTree = "<group>"; };
172+
C8A3AE512A2883430046E809 /* Python.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = Python.xcframework; sourceTree = "<group>"; };
173+
C8A3AE582A2885A70046E809 /* InitializePython.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InitializePython.swift; sourceTree = "<group>"; };
174+
C8A3AE5A2A288AF90046E809 /* site-packages */ = {isa = PBXFileReference; lastKnownFileType = folder; path = "site-packages"; sourceTree = "<group>"; };
175+
C8A3B1762A288FA90046E809 /* python-stdlib */ = {isa = PBXFileReference; lastKnownFileType = folder; path = "python-stdlib"; sourceTree = "<group>"; };
167176
C8CD828229B88006008D044D /* TestPlan.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = TestPlan.xctestplan; sourceTree = "<group>"; };
168177
C8DCEFFF29CE11D500FDDDD7 /* ChatWithSelection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatWithSelection.swift; sourceTree = "<group>"; };
169178
/* End PBXFileReference section */
@@ -200,6 +209,7 @@
200209
buildActionMask = 2147483647;
201210
files = (
202211
C861E61E2994F6150056CB02 /* Service in Frameworks */,
212+
C8A3AE522A2884DA0046E809 /* Python.xcframework in Frameworks */,
203213
);
204214
runOnlyForDeploymentPostprocessing = 0;
205215
};
@@ -248,11 +258,13 @@
248258
C81458AD293A009600135263 /* Config.xcconfig */,
249259
C81458AE293A009800135263 /* Config.debug.xcconfig */,
250260
C8CD828229B88006008D044D /* TestPlan.xctestplan */,
261+
C81D181E2A1B509B006C1B70 /* Tool */,
251262
C8189B282938979000C9DCDA /* Core */,
252263
C8189B182938972F00C9DCDA /* Copilot for Xcode */,
253264
C81458922939EFDC00135263 /* EditorExtension */,
254265
C8216B71298036EC00AD38C7 /* Helper */,
255266
C861E60F2994F6070056CB02 /* ExtensionService */,
267+
C81BBF5A2A2CA0B8000B4F61 /* Python */,
256268
C814588D2939EFDC00135263 /* Frameworks */,
257269
C8189B172938972F00C9DCDA /* Products */,
258270
);
@@ -289,6 +301,16 @@
289301
path = "Preview Content";
290302
sourceTree = "<group>";
291303
};
304+
C81BBF5A2A2CA0B8000B4F61 /* Python */ = {
305+
isa = PBXGroup;
306+
children = (
307+
C8A3AE512A2883430046E809 /* Python.xcframework */,
308+
C8A3B1762A288FA90046E809 /* python-stdlib */,
309+
C8A3AE5A2A288AF90046E809 /* site-packages */,
310+
);
311+
path = Python;
312+
sourceTree = "<group>";
313+
};
292314
C8216B71298036EC00AD38C7 /* Helper */ = {
293315
isa = PBXGroup;
294316
children = (
@@ -304,6 +326,7 @@
304326
C81291D92994FE7900196E12 /* Info.plist */,
305327
C861E61F2994F6390056CB02 /* ServiceDelegate.swift */,
306328
C861E6102994F6070056CB02 /* AppDelegate.swift */,
329+
C8A3AE582A2885A70046E809 /* InitializePython.swift */,
307330
C81291D52994FE6900196E12 /* Main.storyboard */,
308331
C861E6142994F6080056CB02 /* Assets.xcassets */,
309332
C861E6192994F6080056CB02 /* ExtensionService.entitlements */,
@@ -388,6 +411,8 @@
388411
C861E60A2994F6070056CB02 /* Sources */,
389412
C861E60B2994F6070056CB02 /* Frameworks */,
390413
C861E60C2994F6070056CB02 /* Resources */,
414+
C8A3AE572A28852D0046E809 /* Sign Python STD */,
415+
C8A3B1782A2894E10046E809 /* Sign Python Site Packages */,
391416
);
392417
buildRules = (
393418
);
@@ -472,11 +497,54 @@
472497
files = (
473498
C861E6152994F6080056CB02 /* Assets.xcassets in Resources */,
474499
C81291D72994FE6900196E12 /* Main.storyboard in Resources */,
500+
C8A3B1772A288FA90046E809 /* python-stdlib in Resources */,
501+
C8A3AE5B2A288AF90046E809 /* site-packages in Resources */,
475502
);
476503
runOnlyForDeploymentPostprocessing = 0;
477504
};
478505
/* End PBXResourcesBuildPhase section */
479506

507+
/* Begin PBXShellScriptBuildPhase section */
508+
C8A3AE572A28852D0046E809 /* Sign Python STD */ = {
509+
isa = PBXShellScriptBuildPhase;
510+
alwaysOutOfDate = 1;
511+
buildActionMask = 2147483647;
512+
files = (
513+
);
514+
inputFileListPaths = (
515+
);
516+
inputPaths = (
517+
);
518+
name = "Sign Python STD";
519+
outputFileListPaths = (
520+
);
521+
outputPaths = (
522+
);
523+
runOnlyForDeploymentPostprocessing = 0;
524+
shellPath = /bin/sh;
525+
shellScript = "set -e\necho \"Signing as $EXPANDED_CODE_SIGN_IDENTITY_NAME ($EXPANDED_CODE_SIGN_IDENTITY)\"\nfind \"$CODESIGNING_FOLDER_PATH/Contents/Resources/python-stdlib/lib-dynload\" -name \"*.so\" -exec /usr/bin/codesign --force --sign \"$EXPANDED_CODE_SIGN_IDENTITY\" -o runtime --timestamp=none --preserve-metadata=identifier,entitlements,flags --generate-entitlement-der {} \\;\n";
526+
};
527+
C8A3B1782A2894E10046E809 /* Sign Python Site Packages */ = {
528+
isa = PBXShellScriptBuildPhase;
529+
alwaysOutOfDate = 1;
530+
buildActionMask = 2147483647;
531+
files = (
532+
);
533+
inputFileListPaths = (
534+
);
535+
inputPaths = (
536+
);
537+
name = "Sign Python Site Packages";
538+
outputFileListPaths = (
539+
);
540+
outputPaths = (
541+
);
542+
runOnlyForDeploymentPostprocessing = 0;
543+
shellPath = /bin/sh;
544+
shellScript = "set -e\necho \"Signing as $EXPANDED_CODE_SIGN_IDENTITY_NAME ($EXPANDED_CODE_SIGN_IDENTITY)\"\nfind \"$CODESIGNING_FOLDER_PATH/Contents/Resources/site-packages\" -type f \\( -name \"*.so\" -o -name \"*.dylib\" \\) -exec /usr/bin/codesign --force --sign \"$EXPANDED_CODE_SIGN_IDENTITY\" -o runtime --timestamp=none --preserve-metadata=identifier,entitlements,flags --generate-entitlement-der {} \\;\n";
545+
};
546+
/* End PBXShellScriptBuildPhase section */
547+
480548
/* Begin PBXSourcesBuildPhase section */
481549
C81458882939EFDC00135263 /* Sources */ = {
482550
isa = PBXSourcesBuildPhase;
@@ -520,6 +588,7 @@
520588
isa = PBXSourcesBuildPhase;
521589
buildActionMask = 2147483647;
522590
files = (
591+
C8A3AE592A2885A70046E809 /* InitializePython.swift in Sources */,
523592
C861E6202994F63A0056CB02 /* ServiceDelegate.swift in Sources */,
524593
C861E6112994F6070056CB02 /* AppDelegate.swift in Sources */,
525594
);

Copilot for Xcode.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Core/Package.swift

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ let package = Package(
2626
"SuggestionModel",
2727
"Client",
2828
"XPCShared",
29-
"Preferences",
3029
"Logger",
3130
]
3231
),
@@ -38,7 +37,6 @@ let package = Package(
3837
"GitHubCopilotService",
3938
"Client",
4039
"XPCShared",
41-
"Preferences",
4240
"LaunchAgentManager",
4341
"Logger",
4442
"UpdateChecker",
@@ -47,6 +45,7 @@ let package = Package(
4745
),
4846
],
4947
dependencies: [
48+
.package(path: "../Tool"),
5049
.package(url: "https://github.com/ChimeHQ/LanguageClient", from: "0.3.1"),
5150
.package(url: "https://github.com/apple/swift-async-algorithms", from: "0.1.0"),
5251
.package(url: "https://github.com/raspu/Highlightr", from: "2.1.0"),
@@ -55,6 +54,7 @@ let package = Package(
5554
.package(url: "https://github.com/sparkle-project/Sparkle", from: "2.0.0"),
5655
.package(url: "https://github.com/alfianlosari/GPTEncoder", from: "1.0.4"),
5756
.package(url: "https://github.com/kishikawakatsumi/KeychainAccess", from: "4.2.2"),
57+
.package(url: "https://github.com/pvieito/PythonKit.git", branch: "master"),
5858
],
5959
targets: [
6060
// MARK: - Main
@@ -63,10 +63,10 @@ let package = Package(
6363
name: "Client",
6464
dependencies: [
6565
"SuggestionModel",
66-
"Preferences",
6766
"XPCShared",
6867
"Logger",
6968
"GitHubCopilotService",
69+
.product(name: "Preferences", package: "Tool"),
7070
]
7171
),
7272
.target(
@@ -76,7 +76,6 @@ let package = Package(
7676
"SuggestionService",
7777
"GitHubCopilotService",
7878
"OpenAIService",
79-
"Preferences",
8079
"XPCShared",
8180
"CGEventObserver",
8281
"DisplayLink",
@@ -90,7 +89,9 @@ let package = Package(
9089
"PromptToCodeService",
9190
"ServiceUpdateMigration",
9291
"UserDefaultsObserver",
92+
.product(name: "Preferences", package: "Tool"),
9393
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms"),
94+
.product(name: "PythonKit", package: "PythonKit"),
9495
]
9596
),
9697
.testTarget(
@@ -100,9 +101,9 @@ let package = Package(
100101
"Client",
101102
"GitHubCopilotService",
102103
"SuggestionInjector",
103-
"Preferences",
104104
"XPCShared",
105105
"Environment",
106+
.product(name: "Preferences", package: "Tool"),
106107
]
107108
),
108109
.target(
@@ -113,19 +114,18 @@ let package = Package(
113114
"SuggestionService",
114115
]
115116
),
116-
.target(name: "Preferences", dependencies: ["Configs"]),
117117

118118
// MARK: - Host App
119119

120120
.target(
121121
name: "HostApp",
122122
dependencies: [
123-
"Preferences",
124123
"Client",
125124
"GitHubCopilotService",
126125
"CodeiumService",
127126
"SuggestionModel",
128127
"LaunchAgentManager",
128+
.product(name: "Preferences", package: "Tool"),
129129
]
130130
),
131131

@@ -174,26 +174,35 @@ let package = Package(
174174
.target(
175175
name: "ChatService",
176176
dependencies: [
177-
"ChatPlugins",
177+
"ChatPlugin",
178178
"ChatContextCollector",
179179
"OpenAIService",
180180
"Environment",
181181
"XcodeInspector",
182-
"Preferences",
182+
183+
// plugins
184+
"MathChatPlugin",
185+
186+
.product(name: "Preferences", package: "Tool"),
183187
]
184188
),
185189
.target(
186-
name: "ChatPlugins",
187-
dependencies: ["OpenAIService", "Environment", "Terminal"]
190+
name: "ChatPlugin",
191+
dependencies: [
192+
"OpenAIService",
193+
"Environment",
194+
.product(name: "Terminal", package: "Tool"),
195+
.product(name: "PythonKit", package: "PythonKit"),
196+
]
188197
),
189198
.target(
190199
name: "ChatContextCollector",
191200
dependencies: [
192201
"OpenAIService",
193202
"Environment",
194-
"Preferences",
195203
"SuggestionModel",
196204
"XcodeInspector",
205+
.product(name: "Preferences", package: "Tool"),
197206
]
198207
),
199208

@@ -218,26 +227,27 @@ let package = Package(
218227

219228
// MARK: - Helpers
220229

221-
.target(name: "Configs"),
222230
.target(name: "CGEventObserver"),
223231
.target(name: "Logger"),
224232
.target(name: "FileChangeChecker"),
225233
.target(name: "LaunchAgentManager"),
226234
.target(name: "DisplayLink"),
227235
.target(name: "ActiveApplicationMonitor"),
228236
.target(name: "AXNotificationStream"),
229-
.target(name: "Terminal"),
230237
.target(
231238
name: "UpdateChecker",
232239
dependencies: [
233240
"Logger",
234-
"Sparkle"
241+
"Sparkle",
235242
]
236243
),
237244
.target(name: "AXExtension"),
238245
.target(
239246
name: "ServiceUpdateMigration",
240-
dependencies: ["Preferences", "GitHubCopilotService"]
247+
dependencies: [
248+
"GitHubCopilotService",
249+
.product(name: "Preferences", package: "Tool"),
250+
]
241251
),
242252
.target(name: "UserDefaultsObserver"),
243253
.target(
@@ -259,8 +269,8 @@ let package = Package(
259269
"LanguageClient",
260270
"SuggestionModel",
261271
"XPCShared",
262-
"Preferences",
263-
"Terminal",
272+
.product(name: "Preferences", package: "Tool"),
273+
.product(name: "Terminal", package: "Tool"),
264274
]
265275
),
266276
.testTarget(
@@ -274,8 +284,8 @@ let package = Package(
274284
name: "OpenAIService",
275285
dependencies: [
276286
"Logger",
277-
"Preferences",
278287
"GPTEncoder",
288+
.product(name: "Preferences", package: "Tool"),
279289
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms"),
280290
]
281291
),
@@ -291,12 +301,24 @@ let package = Package(
291301
dependencies: [
292302
"LanguageClient",
293303
"SuggestionModel",
294-
"Preferences",
295304
"KeychainAccess",
296-
"Terminal",
297-
"Configs",
305+
.product(name: "Preferences", package: "Tool"),
306+
.product(name: "Terminal", package: "Tool"),
298307
]
299308
),
309+
310+
// MARK: - Chat Plugins
311+
312+
.target(
313+
name: "MathChatPlugin",
314+
dependencies: [
315+
"ChatPlugin",
316+
"OpenAIService",
317+
.product(name: "LangChain", package: "Tool"),
318+
.product(name: "PythonKit", package: "PythonKit"),
319+
],
320+
path: "Sources/ChatPlugins/MathChatPlugin"
321+
),
300322
]
301323
)
302324

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)