Skip to content

Commit 77fa566

Browse files
committed
Update README.md
1 parent 503e5ed commit 77fa566

File tree

1 file changed

+67
-51
lines changed

1 file changed

+67
-51
lines changed

README.md

Lines changed: 67 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![Screenshot](/Screenshot.png)
44

5-
Copilot for Xcode is an Xcode Source Editor Extension that provides GitHub Copilot, Codeium and ChatGPT support for Xcode.
5+
Copilot for Xcode is an Xcode Source Editor Extension that provides GitHub Copilot, Codeium and ChatGPT support for Xcode.
66

77
<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>
88

@@ -20,10 +20,10 @@ Copilot for Xcode is an Xcode Source Editor Extension that provides GitHub Copil
2020
- [Installation and Setup](#installation-and-setup)
2121
- [Install](#install)
2222
- [Enable the Extension](#enable-the-extension)
23+
- [Granting Permissions to the App](#granting-permissions-to-the-app)
2324
- [Setting Up GitHub Copilot](#setting-up-github-copilot)
2425
- [Setting Up Codeium](#setting-up-codeium)
2526
- [Setting Up OpenAI API Key](#setting-up-openai-api-key)
26-
- [Granting Permissions to the App](#granting-permissions-to-the-app)
2727
- [Managing `CopilotForXcodeExtensionService.app`](#managing-copilotforxcodeextensionserviceapp)
2828
- [Update](#update)
2929
- [Feature](#feature)
@@ -41,14 +41,16 @@ For development instruction, check [Development.md](DEVELOPMENT.md).
4141
- Public network connection.
4242

4343
For suggestion features:
44-
- For GitHub Copilot users:
44+
45+
- For GitHub Copilot users:
4546
- [Node](https://nodejs.org/) installed to run the Copilot LSP.
4647
- Active GitHub Copilot subscription.
4748
- For Codeium users:
4849
- Active Codeium account.
4950

5051
For chat and prompt to code features:
51-
- Valid OpenAI API key.
52+
53+
- Valid OpenAI API key.
5254

5355
## Permissions Required
5456

@@ -73,17 +75,29 @@ Open the app, the app will create a launch agent to setup a background running S
7375

7476
### Enable the Extension
7577

76-
Enable the extension in `System Settings.app`.
78+
Enable the extension in `System Settings.app`.
7779

7880
From the Apple menu located in the top-left corner of your screen click `System Settings`. Navigate to `Privacy & Security` then toward the bottom click `Extensions`. Click `Xcode Source Editor` and tick `Copilot`.
79-
81+
8082
If you are using macOS Monterey, enter the `Extensions` menu in `System Preferences.app` with its dedicated icon.
8183

84+
### Granting Permissions to the App
85+
86+
The first time the app is open and command run, the extension will ask for the necessary permissions.
87+
88+
Alternatively, you may manually grant the required permissions by navigating to the `Privacy & Security` tab in the `System Settings.app`.
89+
90+
- To grant permissions for the Accessibility API, click `Accessibility`, and drag `CopilotForXcodeExtensionService.app` to the list. You can locate the extension app by clicking `Reveal Extension App in Finder` in the host app.
91+
92+
<img alt="Accessibility API" src="/accessibility_api_permission.png" width="500px">
93+
94+
If you encounter an alert requesting permission that you have previously granted, please remove the permission from the list and add it again to re-grant the necessary permissions.
95+
8296
### Setting Up GitHub Copilot
83-
97+
8498
1. In the host app, switch to the service tab and click on GitHub Copilot to access your GitHub Copilot account settings.
8599
2. Click "Install" to install the language server.
86-
3. 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.
100+
3. 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.
87101
4. Click "Sign In", and you will be directed to a verification website provided by GitHub, and a user code will be pasted into your clipboard.
88102
5. After signing in, go back to the app and click "Confirm Sign-in" to finish.
89103
6. Go to "Feature - Suggestion" and update the feature provider to "GitHub Copilot".
@@ -106,33 +120,21 @@ The installed language server is located at `~/Library/Application Support/com.i
106120
1. In the host app, click OpenAI to enter the OpenAI account settings.
107121
2. Enter your api key to the text field.
108122

109-
### Granting Permissions to the App
110-
111-
The first time the app is open and command run, the extension will ask for the necessary permissions.
112-
113-
Alternatively, you may manually grant the required permissions by navigating to the `Privacy & Security` tab in the `System Settings.app`.
114-
115-
- To grant permissions for the Accessibility API, click `Accessibility`, and drag `CopilotForXcodeExtensionService.app` to the list. You can locate the extension app by clicking `Reveal Extension App in Finder` in the host app.
116-
117-
<img alt="Accessibility API" src="/accessibility_api_permission.png" width="500px">
118-
119-
If you encounter an alert requesting permission that you have previously granted, please remove the permission from the list and add it again to re-grant the necessary permissions.
120-
121123
### Managing `CopilotForXcodeExtensionService.app`
122124

123125
This app runs whenever you open `Copilot for Xcode.app` or `Xcode.app`. You can quit it with its menu bar item that looks like a steering wheel.
124126

125127
You can also set it to quit automatically when the above 2 apps are closed.
126128

127-
## Update
129+
## Update
128130

129131
If the app was installed via Homebrew, you can update it by running:
130132

131133
```bash
132134
brew upgrade --cask copilot-for-xcode
133135
```
134136

135-
Alternatively, You can use the in-app updater or download the latest version manually from the latest [release](https://github.com/intitni/CopilotForXcode/releases).
137+
Alternatively, You can use the in-app updater or download the latest version manually from the latest [release](https://github.com/intitni/CopilotForXcode/releases).
136138

137139
After updating, please restart Xcode to allow the extension to reload.
138140

@@ -144,13 +146,13 @@ If you find that some of the features are no longer working, please first try re
144146

145147
### Suggestion
146148

147-
The app can provide real-time code suggestions based on the files you have opened. It's powered by GitHub Copilot and Codeium.
149+
The app can provide real-time code suggestions based on the files you have opened. It's powered by GitHub Copilot and Codeium.
148150

149-
If you're working on a company project and don't want the suggestion feature to be triggered, you can globally disable it and choose to enable it only for specific projects.
151+
If you're working on a company project and don't want the suggestion feature to be triggered, you can globally disable it and choose to enable it only for specific projects.
150152

151153
Whenever your code is updated, the app will automatically fetch suggestions for you, you can cancel this by pressing **Escape**.
152154

153-
*: If a file is already open before the helper app launches, you will need to switch to those files in order to send the open file notification.
155+
\*: If a file is already open before the helper app launches, you will need to switch to those files in order to send the open file notification.
154156

155157
#### Commands
156158

@@ -167,6 +169,7 @@ Whenever your code is updated, the app will automatically fetch suggestions for
167169
This feature is powered by ChatGPT. Please ensure that you have set up your OpenAI account before using it.
168170

169171
The chat knows the following information:
172+
170173
- The selected code in the active editor.
171174
- The relative path of the file.
172175
- The error and warning labels in the active editor.
@@ -182,45 +185,48 @@ You can detach the chat panel by simply dragging it away. Once detached, the cha
182185

183186
#### Keyboard Shortcuts
184187

185-
| Shortcut | Description |
186-
|:---:|---|
187-
| `⌘W` | Close the chat. |
188-
| `⌘M` | Minimize the chat, you can bring it back with any chat commands or by clicking the circular widget. |
189-
| `⇧↩︎` | Add new line. |
188+
| Shortcut | Description |
189+
| :------: | --------------------------------------------------------------------------------------------------- |
190+
| `⌘W` | Close the chat. |
191+
| `⌘M` | Minimize the chat, you can bring it back with any chat commands or by clicking the circular widget. |
192+
| `⇧↩︎` | Add new line. |
190193

191194
#### Chat Scope
192195

193196
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`.
194197

195-
| Scope | Description |
196-
|:---:|---|
198+
| Scope | Description |
199+
| :----------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
197200
| `@selection` | Inject the selected code from the active editor into the conversation. This scope will be applied to any message automatically. If you don't want this to be the default behavior, you can turn off the option `Use selection scope by default in chat context.`. |
198-
| `@file` | Inject the content of the file into the conversation. Keep in mind that you may not have enough tokens to inject large files. |
201+
| `@file` | Inject the content of the file into the conversation. Keep in mind that you may not have enough tokens to inject large files. |
199202

200203
#### Chat Plugins
201204

202-
The chat panel supports chat plugins that may not require an OpenAI API key. For example, if you need to use the `/run` plugin, you just type
205+
The chat panel supports chat plugins that may not require an OpenAI API key. For example, if you need to use the `/run` plugin, you just type
206+
203207
```
204208
/run echo hello
205209
```
206210

207-
If you need to end a plugin, you can just type
211+
If you need to end a plugin, you can just type
212+
208213
```
209214
/exit
210215
```
211216

212-
| Command | Description |
213-
|:---:|---|
214-
| `/run` | Runs the command under the project root. You can also use environment variable `PROJECT_ROOT` to get the project root and `FILE_PATH` to get the editing file path.|
215-
| `/airun` | Creates a command with natural language. You can ask to modify the command if it is not what you want. After confirming, the command will be executed by calling the `/run` plugin. |
216-
| `/math` | Solves a math problem in natural language |
217-
| `/search` | Search on Bing and summarize the results. You have to setup the Bing Search API in the host app before using it. |
217+
| Command | Description |
218+
| :-------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
219+
| `/run` | Runs the command under the project root. You can also use environment variable `PROJECT_ROOT` to get the project root and `FILE_PATH` to get the editing file path. |
220+
| `/airun` | Creates a command with natural language. You can ask to modify the command if it is not what you want. After confirming, the command will be executed by calling the `/run` plugin. |
221+
| `/math` | Solves a math problem in natural language |
222+
| `/search` | Search on Bing and summarize the results. You have to setup the Bing Search API in the host app before using it. |
218223

219224
### Prompt to Code
220225

221226
Refactor existing code or write new code using natural language.
222227

223228
This feature is recommended when you need to update a specific piece of code. Some example use cases include:
229+
224230
- Improving the code's readability.
225231
- Correcting bugs in the code.
226232
- Adding documentation to the code.
@@ -241,21 +247,30 @@ You can create custom commands that run Chat and Prompt to Code with personalize
241247
- Open Chat: Open the chat window and immediately send a message, if provided. You can provide more information through the extra system prompt field.
242248
- Custom Chat: Open the chat window and immediately send a message, if provided. You can overwrite the entire system prompt through the system prompt field.
243249

250+
For Open Chat and Custom Chat commands, you can use the following template arguments:
251+
252+
| Argument | Description |
253+
| ----------------------------- | ---------------------------------------------- |
254+
| `{{selected_code}}` | The currently selected code in the editor. |
255+
| `{{active_editor_language}}` | The programming language of the active editor. |
256+
| `{{active_editor_file_url}}` | The URL of the active file in the editor. |
257+
| `{{active_editor_file_name}}` | The name of the active file in the editor. |
258+
244259
## Key Bindings
245260

246261
It looks like there is no way to add default key bindings to commands, but you can set them up in `Xcode settings > Key Bindings`. You can filter the list by typing `copilot` in the search bar.
247262

248263
A [recommended setup](https://github.com/intitni/CopilotForXcode/issues/14) that should cause no conflict is
249264

250-
| Command | Key Binding |
251-
| --- | --- |
252-
| Get Suggestions | `⌥?` |
253-
| Accept Suggestions | `⌥}` |
254-
| Reject Suggestion | `⌥{` |
255-
| Next Suggestion | `⌥>` |
256-
| Previous Suggestion | `⌥<` |
257-
| Open Chat | `⌥"` |
258-
| Explain Selection | `⌥\|` |
265+
| Command | Key Binding |
266+
| ------------------- | ----------- |
267+
| Get Suggestions | `⌥?` |
268+
| Accept Suggestions | `⌥}` |
269+
| Reject Suggestion | `⌥{` |
270+
| Next Suggestion | `⌥>` |
271+
| Previous Suggestion | `⌥<` |
272+
| Open Chat | `⌥"` |
273+
| Explain Selection | `⌥\|` |
259274

260275
Essentially using `⌥⇧` as the "access" key combination for all bindings.
261276

@@ -281,6 +296,7 @@ fi
281296
- The extension uses some dirty tricks to get the file and project/workspace paths. It may fail, it may be incorrect, especially when you have multiple Xcode windows running, and maybe even worse when they are in different displays. I am not sure about that though.
282297
- The suggestions are presented as C-style comments in comment mode, they may break your code if you are editing a JSON file or something.
283298

284-
## License
299+
## License
285300

286301
Please check [LICENSE](LICENSE) for details.
302+

0 commit comments

Comments
 (0)