File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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"
44import consola from "consola"
55import { serve , type ServerHandler } from "srvx"
66
7+ import { auth } from "./auth"
78import { cacheModels } from "./lib/models"
89import { ensurePaths } from "./lib/paths"
910import { state } from "./lib/state"
@@ -51,6 +52,12 @@ export async function runServer(options: RunServerOptions): Promise<void> {
5152}
5253
5354const 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 } ,
5461 args : {
5562 port : {
5663 alias : "p" ,
You can’t perform that action at this time.
0 commit comments