Skip to content

Commit 28cf55b

Browse files
committed
Merge tag '0.28.0' into develop
2 parents a00c478 + bd0f17d commit 28cf55b

11 files changed

Lines changed: 66 additions & 29 deletions

File tree

.github/ISSUE_TEMPLATE/feature_reqeust.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ body:
88
- type: markdown
99
attributes:
1010
value: |
11-
Thanks for taking the time to fill out this feature request!
11+
Thanks for taking the time to fill out this feature request! But please firstly [post your idea in discussion](https://github.com/intitni/CopilotForXcode/discussions/new?category=ideas) so that we can discuss about it in advance.
1212
- type: checkboxes
1313
id: before-reporting
1414
attributes:
@@ -25,4 +25,4 @@ body:
2525
placeholder: Tell us what you want!
2626
value: "I want a feature!"
2727
validations:
28-
required: true
28+
required: true

Core/Sources/ChatService/DynamicContextController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ final class DynamicContextController {
101101
.flatMap(\.retrievedContent)
102102
.filter { !$0.document.content.isEmpty }
103103
.sorted { $0.priority > $1.priority }
104+
.prefix(15)
104105

105106
let contextualSystemPrompt = """
106107
\(language.isEmpty ? "" : "You must always reply in \(language)")

Core/Sources/HostApp/DebugView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct DebugSettingsView: View {
4242
Text("Use custom scroll view workaround for smooth scrolling")
4343
}
4444
Toggle(isOn: $settings.triggerActionWithAccessibilityAPI) {
45-
Text("Trigger command with AccessibilityAPI")
45+
Text("Trigger command with Accessibility API")
4646
}
4747
Group {
4848
Toggle(isOn: $settings.alwaysAcceptSuggestionWithAccessibilityAPI) {
@@ -62,14 +62,14 @@ struct DebugSettingsView: View {
6262
}
6363

6464
Toggle(isOn: $settings.disableEnhancedWorkspace) {
65-
Text("Disable Enhanced Workspace")
65+
Text("Disable enhanced workspace")
6666
}
6767

6868
Toggle(isOn: $settings.disableGitIgnoreCheck) {
69-
Text("Disable Git Ignore Check")
69+
Text("Disable git ignore check")
7070
}
7171

72-
Button("Reset Migration Version to 0") {
72+
Button("Reset migration version to 0") {
7373
UserDefaults.shared.set(nil, forKey: "OldMigrationVersion")
7474
}
7575

Pro

Submodule Pro updated from 3800388 to 465473e

README.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ For chat and prompt to code features:
6767
6868
## Installation and Setup
6969

70+
> The installation process is a bit complicated. Here is a quick overview:
71+
>
72+
> 1. Install the app into the Applications folder, open it once.
73+
> 2. Enable the source editor extension.
74+
> 3. Grant Accessibility API permission to the extension app.
75+
> 4. Setup accounts and models in the host app.
76+
> 5. Optionally, update the settings of each feature in the host app, and setup keybindings.
77+
7078
### Install
7179

7280
You can install it via [Homebrew](http://brew.sh/):
@@ -172,20 +180,16 @@ You can also set it to quit automatically when the above 2 apps are closed.
172180

173181
## Update
174182

175-
If the app was installed via Homebrew, you can update it by running:
176-
177-
```bash
178-
brew upgrade --cask copilot-for-xcode
179-
```
180-
181-
Alternatively, You can use the in-app updater or download the latest version manually from the latest [release](https://github.com/intitni/CopilotForXcode/releases).
183+
You can use the in-app updater or download the latest version manually from the latest [release](https://github.com/intitni/CopilotForXcode/releases).
182184

183185
After updating, please open Copilot for Xcode.app once and restart Xcode to allow the extension to reload.
184186

185187
If you find that some of the features are no longer working, please first try regranting permissions to the app.
186188

187189
## Feature
188190

191+
> Files in gitignore will not receive suggestion. Both chat and prompt to code feature will not have access to them unless you manually select code from them.
192+
189193
### Suggestion
190194

191195
The app can provide real-time code suggestions based on the files you have opened. It's powered by GitHub Copilot and Codeium.
@@ -302,6 +306,18 @@ This feature is recommended when you need to update a specific piece of code. So
302306
- Polishing and correcting grammar and spelling errors in the documentation.
303307
- Translating a localizable strings file.
304308

309+
#### Prompt to Code Scope
310+
311+
The chat panel allows for chat scope to temporarily control the context of the conversation for the latest message. To use a scope, simply prefix the message with `@scope`.
312+
313+
| Scope | Description |
314+
| :--------: | ---------------------------------------------------------------------------------------- |
315+
| `@sense` | Experimental. Read the relevant information of the focused code |
316+
317+
To use scopes, you can prefix a message with `@sense`.
318+
319+
You can use shorthand to represent a scope, such as `@sense`, and enable multiple scopes with `@c+web`.
320+
305321
#### Commands
306322

307323
- Prompt to Code: Open a prompt to code window, where you can use natural language to write or edit selected code.
@@ -334,6 +350,9 @@ These features are included in another repo, and are not open sourced.
334350

335351
The currently available Plus features include:
336352

353+
- `@project` scope in chat.
354+
- Suggestion Cheatsheet that provides relevant content to the suggestion service.
355+
- `@sense` scope in chat and prompt to code.
337356
- Terminal tab in chat panel.
338357
- Unlimited chat/embedding models.
339358
- Tab to accept suggestions.

Tool/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ let package = Package(
105105
name: "Environment",
106106
dependencies: [
107107
"ActiveApplicationMonitor",
108+
"XcodeInspector",
108109
"AXExtension",
109110
"Preferences",
110111
]
@@ -173,7 +174,6 @@ let package = Package(
173174
dependencies: [
174175
"AXExtension",
175176
"SuggestionModel",
176-
"Environment",
177177
"AXNotificationStream",
178178
"Logger",
179179
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms"),

Tool/Sources/Environment/Environment.swift

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import AXExtension
44
import Foundation
55
import Logger
66
import Preferences
7+
import XcodeInspector
78

89
public struct NoAccessToAccessibilityAPIError: Error, LocalizedError {
910
public var errorDescription: String? {
@@ -149,9 +150,16 @@ public enum Environment {
149150
}
150151

151152
public static var triggerAction: (_ name: String) async throws -> Void = { name in
152-
guard let activeXcode = ActiveApplicationMonitor.shared.activeXcode
153-
?? ActiveApplicationMonitor.shared.latestXcode
154-
else { return }
153+
struct CantRunCommand: Error, LocalizedError {
154+
let name: String
155+
var errorDescription: String? {
156+
"Can't run command \(name)."
157+
}
158+
}
159+
160+
guard let activeXcode = XcodeInspector.shared.latestActiveXcode?.runningApplication
161+
else { throw CantRunCommand(name: name) }
162+
155163
let bundleName = Bundle.main
156164
.object(forInfoDictionaryKey: "EXTENSION_BUNDLE_NAME") as! String
157165

@@ -186,12 +194,6 @@ public enum Environment {
186194
return
187195
}
188196
}
189-
struct CantRunCommand: Error, LocalizedError {
190-
let name: String
191-
var errorDescription: String? {
192-
"Can't run command \(name)."
193-
}
194-
}
195197

196198
throw CantRunCommand(name: name)
197199
} else {

Tool/Sources/OpenAIService/CompletionAPI.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ struct OpenAICompletionAPI: CompletionAPI {
112112
return try JSONDecoder().decode(CompletionResponseBody.self, from: result)
113113
} catch {
114114
dump(error)
115-
fatalError()
115+
throw error
116116
}
117117
}
118118
}

Tool/Sources/OpenAIService/Memory/AutoManagedChatGPTMemory.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public actor AutoManagedChatGPTMemory: ChatGPTMemory {
3030
static let encoder: TokenEncoder = TiktokenCl100kBaseTokenEncoder()
3131

3232
var onHistoryChange: () -> Void = {}
33-
33+
3434
let composeHistory: HistoryComposer
3535

3636
public init(
@@ -251,14 +251,17 @@ extension AutoManagedChatGPTMemory {
251251
usage: Int,
252252
references: [ChatMessage.Reference]
253253
) {
254+
/// the available tokens count for retrieved content
255+
let thresholdMaxTokenCount = min(maxTokenCount, configuration.maxTokens / 2)
256+
254257
var retrievedContentTokenCount = 0
255258
let separator = String(repeating: "=", count: 32) // only 1 token
256259
var message = ""
257260
var references = [ChatMessage.Reference]()
258261

259262
func appendToMessage(_ text: String) -> Bool {
260263
let tokensCount = encoder.countToken(text: text)
261-
if tokensCount + retrievedContentTokenCount > maxTokenCount { return false }
264+
if tokensCount + retrievedContentTokenCount > thresholdMaxTokenCount { return false }
262265
retrievedContentTokenCount += tokensCount
263266
message += text
264267
return true

Version.xcconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
APP_VERSION = 0.27.1
2-
APP_BUILD = 281
1+
APP_VERSION = 0.28.0
2+
APP_BUILD = 290
33

0 commit comments

Comments
 (0)