Skip to content

Commit 37d2246

Browse files
committed
Merge tag '0.13.3' into develop
2 parents 5021f4f + 70feae2 commit 37d2246

10 files changed

Lines changed: 69 additions & 24 deletions

File tree

Copilot for Xcode/OpenAIView.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ struct OpenAIView: View {
6262
Image(systemName: "questionmark.circle.fill")
6363
}.buttonStyle(.plain)
6464
}
65-
.onChange(of: settings.chatGPTModel) { newValue in
66-
if let model = ChatGPTModel(rawValue: newValue) {
67-
settings.chatGPTEndpoint = model.endpoint
68-
}
69-
}
7065

7166
TextField(
7267
text: $settings.chatGPTEndpoint,

Core/Sources/ChatPlugins/AITerminalChatPlugin.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public actor AITerminalChatPlugin: ChatPlugin {
1919
self.delegate = delegate
2020
}
2121

22-
public func send(content: String) async {
22+
public func send(content: String, originalMessage: String) async {
2323
if !isStarted {
2424
isStarted = true
2525
delegate?.pluginDidStart(self)
@@ -69,7 +69,11 @@ public actor AITerminalChatPlugin: ChatPlugin {
6969
}
7070
} else {
7171
await chatGPTService.mutateHistory { history in
72-
history.append(.init(role: .user, content: "Run a command to \(content)"))
72+
history.append(.init(
73+
role: .user,
74+
content: originalMessage,
75+
summary: "Run a command to \(content)")
76+
)
7377
}
7478
delegate?.pluginDidStartResponding(self)
7579
let result = try await generateCommand(task: content)

Core/Sources/ChatPlugins/ChatPlugin.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public protocol ChatPlugin: AnyObject {
77
var name: String { get }
88

99
init(inside chatGPTService: any ChatGPTServiceType, delegate: ChatPluginDelegate)
10-
func send(content: String) async
10+
func send(content: String, originalMessage: String) async
1111
func cancel() async
1212
func stopResponding() async
1313
}

Core/Sources/ChatPlugins/TerminalChatPlugin.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public actor TerminalChatPlugin: ChatPlugin {
1717
self.delegate = delegate
1818
}
1919

20-
public func send(content: String) async {
20+
public func send(content: String, originalMessage: String) async {
2121
delegate?.pluginDidStart(self)
2222
delegate?.pluginDidStartResponding(self)
2323

@@ -38,7 +38,11 @@ public actor TerminalChatPlugin: ChatPlugin {
3838
let projectURL = try await Environment.fetchCurrentProjectRootURL(fileURL)
3939

4040
await chatGPTService.mutateHistory { history in
41-
history.append(.init(role: .user, content: "Run command: \(content)"))
41+
history.append(.init(
42+
role: .user,
43+
content: originalMessage,
44+
summary: "Run command: \(content)")
45+
)
4246
}
4347

4448
if isCancelled { throw CancellationError() }

Core/Sources/ChatService/ChatService.swift

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,28 @@ public final class ChatService: ObservableObject {
5353
}
5454
}
5555
} else if let runningPlugin {
56-
await runningPlugin.send(content: content)
56+
await runningPlugin.send(content: content, originalMessage: content)
5757
} else if let pluginType = plugins[command] {
5858
let plugin = pluginType.init(inside: chatGPTService, delegate: self)
5959
if #available(macOS 13.0, *) {
6060
await plugin.send(
6161
content: String(
6262
content.dropFirst(command.count + 1)
6363
.trimmingPrefix(while: { $0 == " " })
64-
)
64+
),
65+
originalMessage: content
6566
)
6667
} else {
67-
await plugin.send(content: String(content.dropFirst(command.count + 1)))
68+
await plugin.send(
69+
content: String(content.dropFirst(command.count + 1)),
70+
originalMessage: content
71+
)
6872
}
6973
} else {
7074
_ = try await chatGPTService.send(content: content, summary: nil)
7175
}
7276
} else if let runningPlugin {
73-
await runningPlugin.send(content: content)
77+
await runningPlugin.send(content: content, originalMessage: content)
7478
} else {
7579
_ = try await chatGPTService.send(content: content, summary: nil)
7680
}
@@ -89,13 +93,13 @@ public final class ChatService: ObservableObject {
8993
}
9094
await chatGPTService.clearHistory()
9195
}
92-
96+
9397
public func deleteMessage(id: String) async {
9498
await chatGPTService.mutateHistory { messages in
9599
messages.removeAll(where: { $0.id == id })
96100
}
97101
}
98-
102+
99103
public func resendMessage(id: String) async throws {
100104
if let message = (await chatGPTService.history).first(where: { $0.id == id }) {
101105
try await send(content: message.content)
@@ -133,7 +137,7 @@ extension ChatService: ChatPluginDelegate {
133137
public func shouldStartAnotherPlugin(_ type: ChatPlugin.Type, withContent content: String) {
134138
let plugin = type.init(inside: chatGPTService, delegate: self)
135139
Task {
136-
await plugin.send(content: content)
140+
await plugin.send(content: content, originalMessage: content)
137141
}
138142
}
139143
}

Core/Sources/Service/SuggestionCommandHandler/WindowBaseCommandHandler.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,8 @@ extension WindowBaseCommandHandler {
410410
return """
411411
\(language.isEmpty ? "" : "You must always reply in \(language)")
412412
You are a senior programmer, you will answer my questions concisely. If you are replying with code, embed the code in a code block in markdown.
413+
414+
You don't have any code in advance, ask me to provide it when needed.
413415
"""
414416
}
415417
return """
@@ -451,6 +453,14 @@ extension WindowBaseCommandHandler {
451453
summary: "\(customCommandPrefix) Chatting about selected code in `\(fileURL.lastPathComponent)` from `\(selection.start.line + 1):\(selection.start.character + 1)` to `\(selection.end.line + 1):\(selection.end.character)`.\nThe code will persist in the conversation."
452454
))
453455
}
456+
} else if !customCommandPrefix.isEmpty {
457+
await chat.chatGPTService.mutateHistory { history in
458+
history.append(.init(
459+
role: .assistant,
460+
content: "",
461+
summary: "\(customCommandPrefix) System prompt is updated."
462+
))
463+
}
454464
}
455465

456466
if let sendingMessageImmediately, !sendingMessageImmediately.isEmpty {

Core/Sources/SuggestionWidget/Styles.swift

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,21 @@ extension MarkdownUI.Theme {
6868
FontSize(.em(0.85))
6969
}
7070
.padding(16)
71+
.padding(.top, 14)
7172
.background(Color(nsColor: .textBackgroundColor).opacity(0.7))
7273
.clipShape(RoundedRectangle(cornerRadius: 6))
73-
.overlay(alignment: .topTrailing) {
74-
CopyButton {
75-
NSPasteboard.general.clearContents()
76-
NSPasteboard.general.setString(configuration.content, forType: .string)
74+
.overlay(alignment: .top) {
75+
HStack(alignment: .center) {
76+
Text(configuration.language ?? "code")
77+
.foregroundStyle(.tertiary)
78+
.font(.callout)
79+
.padding(.leading, 8)
80+
.lineLimit(1)
81+
Spacer()
82+
CopyButton {
83+
NSPasteboard.general.clearContents()
84+
NSPasteboard.general.setString(configuration.content, forType: .string)
85+
}
7786
}
7887
}
7988
.markdownMargin(top: 0, bottom: 16)

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ Thanks to [LSP-copilot](https://github.com/TerminalFi/LSP-copilot) for showing t
88

99
<a href="https://www.buymeacoffee.com/intitni" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
1010

11+
## Features
12+
13+
- Code Suggestions (powered by GitHub Copilot).
14+
- Chat (powered by OpenAI ChatGPT).
15+
- Prompt to Code (powered by OpenAI ChatGPT).
16+
- Custom Commands to extend Chat and Prompt to Code.
17+
1118
## Table of Contents
1219

1320
- [Prerequisites](#prerequisites)
@@ -63,7 +70,7 @@ Or install it manually, by downloading the `Copilot for Xcode.app` from the late
6370
Then set it up with the following steps:
6471

6572
1. Open the app, the app will create a launch agent to setup a background running Service that does the real job.
66-
2. Optionally setup the path to Node. The default value is just `node`, Copilot for Xcode.app will try to find the Node from the PATH available in a login shell. If your Node is installed somewhere else, you can run `which node` from terminal to get the path.
73+
2. Optionally setup the path to Node. The default value is just `node`, Copilot for Xcode.app will try to find the Node from the PATH available in a login shell. If your Node is installed somewhere else, you can run `which node` from terminal to get the path.
6774

6875
### Enable the Extension
6976

Version.xcconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
APP_VERSION = 0.13.2
2-
APP_BUILD = 106
1+
APP_VERSION = 0.13.3
2+
APP_BUILD = 108

appcast.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
<channel>
44
<title>Copilot for Xcode</title>
55

6+
<item>
7+
<title>0.13.3</title>
8+
<pubDate>Wed, 26 Apr 2023 21:44:25 +0800</pubDate>
9+
<sparkle:version>108</sparkle:version>
10+
<sparkle:shortVersionString>0.13.3</sparkle:shortVersionString>
11+
<sparkle:minimumSystemVersion>12.0</sparkle:minimumSystemVersion>
12+
<sparkle:releaseNotesLink>
13+
https://github.com/intitni/CopilotForXcode/releases/tag/0.13.3
14+
</sparkle:releaseNotesLink>
15+
<enclosure url="https://github.com/intitni/CopilotForXcode/releases/download/0.13.3/Copilot.for.Xcode.app.zip" length="20125782" type="application/octet-stream" sparkle:edSignature="h55M7+/0Xv2OcxdUtbxycsKlP3K0xXF66VlbsBP2dsLFx1MTS2nYm2lW4ENV2DTJ4H+A4AG0vTZ+9Qi3zms5DA=="/>
16+
</item>
17+
618
<item>
719
<title>0.13.2</title>
820
<pubDate>Sun, 23 Apr 2023 18:03:30 +0800</pubDate>

0 commit comments

Comments
 (0)