File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env node
2
+
3
+ import { defineCommand } from "citty"
4
+ import consola from "consola"
5
+
6
+ import { PATHS } from "./lib/paths"
7
+ import { setupGitHubToken } from "./lib/token"
8
+
9
+ interface RunAuthOptions {
10
+ verbose : boolean
11
+ }
12
+
13
+ export async function runAuth ( options : RunAuthOptions ) : Promise < void > {
14
+ if ( options . verbose ) {
15
+ consola . level = 5
16
+ consola . info ( "Verbose logging enabled" )
17
+ }
18
+
19
+ await setupGitHubToken ( )
20
+ consola . success ( "GitHub token written to" , PATHS . GITHUB_TOKEN_PATH )
21
+
22
+ process . exit ( 0 )
23
+ }
24
+
25
+ export const auth = defineCommand ( {
26
+ meta : {
27
+ name : "auth" ,
28
+ description : "Run GitHub auth flow without running the server" ,
29
+ } ,
30
+ args : {
31
+ verbose : {
32
+ alias : "v" ,
33
+ type : "boolean" ,
34
+ default : false ,
35
+ description : "Enable verbose logging" ,
36
+ } ,
37
+ } ,
38
+ run ( { args } ) {
39
+ return runAuth ( {
40
+ verbose : args . verbose ,
41
+ } )
42
+ } ,
43
+ } )
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { defineCommand, runMain } from "citty"
4
4
import consola from "consola"
5
5
import { serve , type ServerHandler } from "srvx"
6
6
7
+ import { auth } from "./auth"
7
8
import { cacheModels } from "./lib/models"
8
9
import { ensurePaths } from "./lib/paths"
9
10
import { state } from "./lib/state"
@@ -51,6 +52,12 @@ export async function runServer(options: RunServerOptions): Promise<void> {
51
52
}
52
53
53
54
const main = defineCommand ( {
55
+ meta : {
56
+ name : "copilot-api" ,
57
+ description :
58
+ "A wrapper around GitHub Copilot API to make it OpenAI compatible, making it usable for other tools." ,
59
+ } ,
60
+ subCommands : { auth } ,
54
61
args : {
55
62
port : {
56
63
alias : "p" ,
You can’t perform that action at this time.
0 commit comments