xcode-copilot-server 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -5
- package/config.json5 +12 -1
- package/dist/copilot-service.d.ts +2 -1
- package/dist/copilot-service.js +3 -0
- package/dist/copilot-service.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/prompt.d.ts +8 -3
- package/dist/utils/prompt.js +8 -3
- package/dist/utils/prompt.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,19 +6,25 @@ An OpenAI-compatible proxy API server that lets you use GitHub Copilot in Xcode.
|
|
|
6
6
|
|
|
7
7
|
Xcode 26 added support for third-party LLM providers, but it only supports ChatGPT and Claude out of the box. If you have a GitHub Copilot subscription and want to use it in Xcode, that's not possible as there's no built-in option for it.
|
|
8
8
|
|
|
9
|
-
However, Xcode does let you add a custom model provider, as long as it exposes an OpenAI-compatible API. GitHub Copilot doesn't do that, but this server helps bridges the gap by wrapping the [GitHub Copilot SDK](https://
|
|
9
|
+
However, Xcode does let you add a custom model provider, as long as it exposes an OpenAI-compatible API. GitHub Copilot doesn't do that, but this server helps bridges the gap by wrapping the [GitHub Copilot SDK](https://github.com/github/copilot-sdk) and exposing it as an OpenAI-compatible API that Xcode can talk to.
|
|
10
10
|
|
|
11
11
|
It also connects to Xcode's built-in MCP tools (via `xcrun mcpbridge`), giving Copilot access to your project's build logs, indexes and other context that Xcode provides. This requires Xcode 26.3 or later.
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
15
|
-
You need [Node.js](https://nodejs.org) 25.6.0 or later.
|
|
15
|
+
You need [Node.js](https://nodejs.org) 25.6.0 or later and a GitHub Copilot subscription. Before starting the server, authenticate using one of the following methods (the Copilot CLI is bundled with the SDK, so you only need one of these for initial sign-in):
|
|
16
|
+
|
|
17
|
+
- [Install the Copilot CLI](https://docs.github.com/en/copilot/how-tos/copilot-cli/install-copilot-cli) and run `copilot login`
|
|
18
|
+
- [Install the GitHub CLI](https://cli.github.com/) and run `gh auth login`
|
|
19
|
+
- Set a `GITHUB_TOKEN` environment variable with a valid fine-grained Copilot access token
|
|
20
|
+
|
|
21
|
+
Then install the server via:
|
|
16
22
|
|
|
17
23
|
```bash
|
|
18
24
|
npm install -g xcode-copilot-server
|
|
19
25
|
```
|
|
20
26
|
|
|
21
|
-
Or run it
|
|
27
|
+
Or run it without installing globally:
|
|
22
28
|
|
|
23
29
|
```bash
|
|
24
30
|
npx xcode-copilot-server
|
|
@@ -42,8 +48,6 @@ The server listens on `http://localhost:8080` by default and exposes two routes:
|
|
|
42
48
|
- `GET /v1/models` — lists available models from your Copilot subscription
|
|
43
49
|
- `POST /v1/chat/completions` — handles chat completion requests (streaming)
|
|
44
50
|
|
|
45
|
-
You will need to be signed in to GitHub Copilot through the [Copilot CLI](https://docs.github.com/en/copilot/using-github-copilot/using-github-copilot-in-the-command-line).
|
|
46
|
-
|
|
47
51
|
## Xcode integration
|
|
48
52
|
|
|
49
53
|
1. Start the server: `xcode-copilot-server`
|
|
@@ -98,12 +102,19 @@ The config file uses [JSON5](https://json5.org/) format, which supports comments
|
|
|
98
102
|
|
|
99
103
|
// Built-in CLI tools allowlist.
|
|
100
104
|
// ["*"] to allow all, [] to deny all, or a list of specific tool names.
|
|
105
|
+
//
|
|
106
|
+
// Empty by default so Xcode can handle all operations (search, read, edit)
|
|
107
|
+
// through its UI. Enabling CLI tools lets the Copilot session perform
|
|
108
|
+
// those operations directly, bypassing Xcode.
|
|
101
109
|
allowedCliTools: [],
|
|
102
110
|
|
|
103
111
|
// Maximum request body size in MiB.
|
|
104
112
|
bodyLimitMiB: 4,
|
|
105
113
|
|
|
106
114
|
// Filename patterns to filter out from search results in the prompt.
|
|
115
|
+
//
|
|
116
|
+
// Xcode can include full file contents for every search match, so add patterns
|
|
117
|
+
// here to strip files that bloat the prompt (e.g. ["mock", "generated"]).
|
|
107
118
|
excludedFilePatterns: [],
|
|
108
119
|
|
|
109
120
|
// Reasoning effort for models that support it: "low", "medium", "high", "xhigh"
|
package/config.json5
CHANGED
|
@@ -24,10 +24,17 @@
|
|
|
24
24
|
// },
|
|
25
25
|
},
|
|
26
26
|
|
|
27
|
-
// Built-in CLI tools allowlist (glob, grep, bash, etc)
|
|
27
|
+
// Built-in CLI tools allowlist (glob, grep, bash, etc).
|
|
28
28
|
// - ["*"]: allow all CLI tools
|
|
29
29
|
// - []: deny all CLI tools
|
|
30
30
|
// - ["glob", "grep"]: allow only specific CLI tools
|
|
31
|
+
//
|
|
32
|
+
// This is empty by default because Xcode should be the one handling operations
|
|
33
|
+
// like searching, reading, and editing files. The model tells Xcode what to
|
|
34
|
+
// change and Xcode applies those changes through its own UI, keeping everything
|
|
35
|
+
// in sync. If CLI tools are enabled, the Copilot session may perform those
|
|
36
|
+
// operations itself (e.g. writing files via bash), bypassing Xcode and leaving
|
|
37
|
+
// its UI out of sync with what actually happened on disk.
|
|
31
38
|
allowedCliTools: [],
|
|
32
39
|
|
|
33
40
|
// Maximum request body size in MiB.
|
|
@@ -35,6 +42,10 @@
|
|
|
35
42
|
|
|
36
43
|
// Filename patterns to filter out from search results in the prompt.
|
|
37
44
|
// Code blocks whose filename contains any of these (case-insensitive) are stripped.
|
|
45
|
+
//
|
|
46
|
+
// Xcode's search results can include full file contents for every match, which can
|
|
47
|
+
// bloat the prompt with irrelevant code. Add patterns here to strip those files
|
|
48
|
+
// before they reach the model (e.g. ["mock", "generated"]).
|
|
38
49
|
excludedFilePatterns: [],
|
|
39
50
|
|
|
40
51
|
// Reasoning effort for models that support it.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CopilotSession, type SessionConfig, type ModelInfo } from "@github/copilot-sdk";
|
|
1
|
+
import { type CopilotSession, type SessionConfig, type ModelInfo, type GetAuthStatusResponse } from "@github/copilot-sdk";
|
|
2
2
|
import type { LogLevel, Logger } from "./logger.js";
|
|
3
3
|
export interface CopilotServiceOptions {
|
|
4
4
|
logLevel?: LogLevel | undefined;
|
|
@@ -14,6 +14,7 @@ export declare class CopilotService {
|
|
|
14
14
|
constructor(options?: CopilotServiceOptions);
|
|
15
15
|
start(): Promise<void>;
|
|
16
16
|
stop(): Promise<void>;
|
|
17
|
+
getAuthStatus(): Promise<GetAuthStatusResponse>;
|
|
17
18
|
listModels(): Promise<ModelInfo[]>;
|
|
18
19
|
getSession(config: SessionConfig): Promise<CopilotSession>;
|
|
19
20
|
}
|
package/dist/copilot-service.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copilot-service.js","sourceRoot":"","sources":["../src/copilot-service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,
|
|
1
|
+
{"version":3,"file":"copilot-service.js","sourceRoot":"","sources":["../src/copilot-service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,GAKd,MAAM,qBAAqB,CAAC;AAS7B,MAAM,OAAO,cAAc;IAChB,GAAG,CAAS;IACb,MAAM,CAAgB;IACtB,OAAO,GAA0B,IAAI,CAAC;IACtC,cAAc,GAAmC,IAAI,CAAC;IACtD,MAAM,CAAqB;IAEnC,YAAY,UAAiC,EAAE;QAC7C,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QACxC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,aAAa,CAAC;YAC9B,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,OAAO;YACrC,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,GAAG,EAAE,MAAM,CAAC,WAAW,CACrB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAyB,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAC/E;SACF,CAAC,CAAC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
package/dist/index.js
CHANGED
|
@@ -67,6 +67,13 @@ async function main() {
|
|
|
67
67
|
logger.info("Booting up Copilot CLI...");
|
|
68
68
|
await service.start();
|
|
69
69
|
logger.info("Copilot CLI is up");
|
|
70
|
+
const auth = await service.getAuthStatus();
|
|
71
|
+
if (!auth.isAuthenticated) {
|
|
72
|
+
logger.error("Not authenticated. Sign in with the Copilot CLI (copilot login) or GitHub CLI (gh auth login), or set a GITHUB_TOKEN environment variable.");
|
|
73
|
+
await service.stop();
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
logger.info(`Authenticated as ${auth.login ?? "unknown"} (${auth.authType ?? "unknown"})`);
|
|
70
77
|
const ctx = { service, logger, config };
|
|
71
78
|
const app = await createServer(ctx);
|
|
72
79
|
await app.listen({ port, host: "127.0.0.1" });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,cAAc,EAAiB,MAAM,aAAa,CAAC;AAGpE,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAClD,MAAM,mBAAmB,GAAG,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;AAE/D,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,CAAe,CAAC;AAEnE,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,KAAK,IAAI,cAAc,CAAC;AACjC,C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ks whose header contains any of the given patterns
|
|
4
|
+
* (case-insensitive). Xcode formats search results as fenced blocks with a
|
|
5
|
+
* header like ` ```swift:/path/to/File.swift `, so the patterns are matched
|
|
6
|
+
* against the file path in that header.
|
|
4
7
|
*
|
|
5
|
-
* Xcode search
|
|
6
|
-
* can be thousands of lines and add nothing useful to the prompt.
|
|
8
|
+
* Xcode's search results can include full file contents for every match, so
|
|
9
|
+
* some files can be thousands of lines and add nothing useful to the prompt.
|
|
10
|
+
* For example, a mock data file might match the search query but its contents
|
|
11
|
+
* aren't helpful for generating a useful response.
|
|
7
12
|
*/
|
|
8
13
|
export declare function filterExcludedFiles(s: string, patterns: string[]): string;
|
|
9
14
|
/** System/developer messages are skipped — they're passed via `SessionConfig.systemMessage`. */
|
package/dist/utils/prompt.js
CHANGED
|
@@ -3,10 +3,15 @@ function escapeRegex(s) {
|
|
|
3
3
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
|
-
* Strips fenced code blocks whose
|
|
6
|
+
* Strips fenced code blocks whose header contains any of the given patterns
|
|
7
|
+
* (case-insensitive). Xcode formats search results as fenced blocks with a
|
|
8
|
+
* header like ` ```swift:/path/to/File.swift `, so the patterns are matched
|
|
9
|
+
* against the file path in that header.
|
|
7
10
|
*
|
|
8
|
-
* Xcode search
|
|
9
|
-
* can be thousands of lines and add nothing useful to the prompt.
|
|
11
|
+
* Xcode's search results can include full file contents for every match, so
|
|
12
|
+
* some files can be thousands of lines and add nothing useful to the prompt.
|
|
13
|
+
* For example, a mock data file might match the search query but its contents
|
|
14
|
+
* aren't helpful for generating a useful response.
|
|
10
15
|
*/
|
|
11
16
|
export function filterExcludedFiles(s, patterns) {
|
|
12
17
|
if (patterns.length === 0)
|
package/dist/utils/prompt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/utils/prompt.ts"],"names":[],"mappings":"AAAA,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