@guanghechen/kit-copilot 0.4.6 → 0.6.0
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 +50 -0
- package/lib/esm/cli.mjs +1 -1
- package/lib/esm/command-juFSLDt2.mjs +1 -0
- package/lib/esm/index.mjs +1 -1
- package/package.json +3 -3
- package/lib/esm/command-BchMPCk5.mjs +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# @guanghechen/kit-copilot
|
|
2
|
+
|
|
3
|
+
GitHub Copilot proxy server for `Claude`, `Codex`, and `Gemini` compatible endpoints.
|
|
4
|
+
|
|
5
|
+
## Environment Model
|
|
6
|
+
|
|
7
|
+
`kit-copilot` follows a strict environment flow:
|
|
8
|
+
|
|
9
|
+
1. CLI entry passes `process.env` to `@guanghechen/commander/node`.
|
|
10
|
+
2. Commander merges user envs with preset envs into `ctx.envs`.
|
|
11
|
+
3. Runtime logic consumes `ctx.envs` only.
|
|
12
|
+
|
|
13
|
+
There is no runtime fallback from business logic to global `process.env` for critical keys such as:
|
|
14
|
+
|
|
15
|
+
- `GH_PRIMARY_TOKEN`
|
|
16
|
+
- `COPILOT_MODEL_REFRESH_SEC`
|
|
17
|
+
|
|
18
|
+
## Preset Root And `.env.local`
|
|
19
|
+
|
|
20
|
+
Preset root:
|
|
21
|
+
|
|
22
|
+
- `$XDG_CONFIG_HOME/kit/copilot` when `XDG_CONFIG_HOME` is set
|
|
23
|
+
- `~/.config/kit/copilot` otherwise
|
|
24
|
+
|
|
25
|
+
Default preset env file:
|
|
26
|
+
|
|
27
|
+
- `<preset-root>/.env.local`
|
|
28
|
+
|
|
29
|
+
The file is loaded by commander preset logic and merged into `ctx.envs`.
|
|
30
|
+
|
|
31
|
+
## Token Persistence
|
|
32
|
+
|
|
33
|
+
`kit-copilot auth` persists `GH_PRIMARY_TOKEN` to preset env storage.
|
|
34
|
+
|
|
35
|
+
- Persist target: `<preset-root>/.env.local`
|
|
36
|
+
- `GH_COPILOT_TOKEN` is not persisted
|
|
37
|
+
|
|
38
|
+
## Examples
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
kit-copilot auth
|
|
42
|
+
kit-copilot start --port=4141
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
With preset env file:
|
|
46
|
+
|
|
47
|
+
```dotenv
|
|
48
|
+
GH_PRIMARY_TOKEN=ghu_xxx
|
|
49
|
+
COPILOT_MODEL_REFRESH_SEC=300
|
|
50
|
+
```
|
package/lib/esm/cli.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
(function(
|
|
2
|
+
(function(_0x3c4acc,_0x39b717){const _0x3c77ae={_0x5d5482:0x2d2,_0xa87c9b:0x2c2,_0x5a96f0:0x2a9,_0x74646f:'CnOY',_0x5a8a66:0x2a3,_0x27e0dd:0x285,_0x243864:'ydqj',_0x1d2aaf:0x285,_0x5110d4:0x2d1,_0x2236f4:'yI(K',_0x497aa2:0x2d8,_0x16420d:0x2c1,_0x231c7d:0x2c6,_0x2fb2a9:0x2ae,_0x52fdb9:')e[V',_0x294d05:0x2bf,_0x45e34a:0x2c3,_0x3b956b:'1ZWo',_0x354ee3:0x2c5,_0x448132:'6[bS',_0x1ce74b:0x29e,_0x3f23c6:'kIc%',_0x53e257:0x2c7,_0x1addd4:0x2c0,_0x115a41:0x2a6,_0x3a577d:'lmOA',_0x3d4443:0x2d6,_0x2ac057:0x2c2,_0x239a82:'WwvD',_0x190147:0x297,_0x3806a2:'1ZWo',_0x3281a9:0x299,_0xbbf1de:0x2ab,_0x42d73c:'k[uo',_0x3178fb:0x2be,_0x3bdcbc:0x2b8},_0x33f58f={_0x41c4a3:0x1f5},_0x1be784={_0xaf87f7:0x390};function _0x2b0f30(_0x4a858f,_0x581425,_0x1a752c,_0x5a6ad8){return _0x2af3(_0x581425- -_0x1be784._0xaf87f7,_0x1a752c);}const _0x216ae4=_0x3c4acc();function _0x46228e(_0x1cd466,_0x24dfef,_0x445296,_0x5a90b8){return _0x2af3(_0x445296-_0x33f58f._0x41c4a3,_0x24dfef);}while(!![]){try{const _0x16be52=-parseInt(_0x46228e(0x2e0,'dnPr',_0x3c77ae._0x5d5482,_0x3c77ae._0xa87c9b))/(-0xc5b*-0x1+-0x116+-0xb44)*(parseInt(_0x2b0f30(-_0x3c77ae._0x5a96f0,-0x2b8,_0x3c77ae._0x74646f,-_0x3c77ae._0x5a8a66))/(0x4b1*0x3+0x973+-0x1784))+-parseInt(_0x2b0f30(-_0x3c77ae._0x27e0dd,-0x299,_0x3c77ae._0x243864,-_0x3c77ae._0x1d2aaf))/(-0x2*-0xe6f+0x1*0x1106+0x195*-0x1d)+parseInt(_0x46228e(_0x3c77ae._0x5110d4,_0x3c77ae._0x2236f4,_0x3c77ae._0x497aa2,_0x3c77ae._0x16420d))/(-0x21fb*0x1+0xc75*0x1+-0x6*-0x397)+parseInt(_0x2b0f30(-_0x3c77ae._0x231c7d,-_0x3c77ae._0x2fb2a9,_0x3c77ae._0x52fdb9,-0x2b8))/(0x1*-0x2503+0x21ac+-0x35c*-0x1)*(parseInt(_0x2b0f30(-_0x3c77ae._0x294d05,-_0x3c77ae._0x45e34a,_0x3c77ae._0x3b956b,-_0x3c77ae._0x354ee3))/(0x1a88+0x2*0x8ff+-0x2c80))+parseInt(_0x2b0f30(-0x28b,-0x2a0,_0x3c77ae._0x448132,-_0x3c77ae._0x1ce74b))/(-0x989+-0xbad+0x153d)*(parseInt(_0x46228e(0x2da,_0x3c77ae._0x3f23c6,_0x3c77ae._0x53e257,_0x3c77ae._0x1addd4))/(0x26b2+-0x17a5*0x1+-0xf05))+-parseInt(_0x2b0f30(-_0x3c77ae._0x115a41,-_0x3c77ae._0x5a8a66,_0x3c77ae._0x3a577d,-0x2a9))/(-0x1*-0x12db+-0xba3+-0x72f)*(parseInt(_0x2b0f30(-_0x3c77ae._0x3d4443,-_0x3c77ae._0x2ac057,_0x3c77ae._0x239a82,-0x2d5))/(0x1cb2+-0x5*0x20b+-0x1271))+parseInt(_0x2b0f30(-_0x3c77ae._0x190147,-_0x3c77ae._0x1ce74b,_0x3c77ae._0x3806a2,-_0x3c77ae._0x3281a9))/(0x276+-0xb53+0x8e8)*(parseInt(_0x46228e(_0x3c77ae._0xbbf1de,_0x3c77ae._0x42d73c,_0x3c77ae._0x3178fb,_0x3c77ae._0x3bdcbc))/(0x4d*0x4b+0x1081+-0x2704));if(_0x16be52===_0x39b717)break;else _0x216ae4['push'](_0x216ae4['shift']());}catch(_0x429c26){_0x216ae4['push'](_0x216ae4['shift']());}}}(_0x2216,0x9fc8a+-0x5*-0x2249b+-0xc4c51));function _0x2af3(_0x228f35,_0x466e0){_0x228f35=_0x228f35-(0x130e+0x17c8+0x1*-0x2a12);const _0x10d638=_0x2216();let _0x5eea47=_0x10d638[_0x228f35];if(_0x2af3['Hbmmxx']===undefined){var _0x12d460=function(_0x46b385){const _0x217bd2='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x55d103='',_0x2d6772='';for(let _0x10435c=0xa*-0x277+-0xbc6*-0x1+0xce0,_0x1b581e,_0x52b5f6,_0x233883=0x2*-0x11a2+0x208+-0x58a*-0x6;_0x52b5f6=_0x46b385['charAt'](_0x233883++);~_0x52b5f6&&(_0x1b581e=_0x10435c%(-0x8*-0x39f+-0x139*0xd+-0x1*0xd0f)?_0x1b581e*(-0x926*0x1+0x2245*-0x1+-0x1*-0x2bab)+_0x52b5f6:_0x52b5f6,_0x10435c++%(0x1cb5+0x542+-0x21f3))?_0x55d103+=String['fromCharCode'](0x11f2+-0x15*-0x2c+-0x115*0x13&_0x1b581e>>(-(-0x1da4+-0x179*-0x14+0x32)*_0x10435c&-0x1*-0x2285+-0xb0*-0xe+-0x2c1f)):0x22d6*-0x1+0x1*0x7bf+0x1b17){_0x52b5f6=_0x217bd2['indexOf'](_0x52b5f6);}for(let _0x2eac0a=-0x4d*-0x1c+-0x43*-0x29+-0x1327,_0x4a7090=_0x55d103['length'];_0x2eac0a<_0x4a7090;_0x2eac0a++){_0x2d6772+='%'+('00'+_0x55d103['charCodeAt'](_0x2eac0a)['toString'](0x200b*-0x1+-0x2*0x3a1+-0xd1f*-0x3))['slice'](-(-0x182*0xd+-0x1e4c+-0x1*-0x31e8));}return decodeURIComponent(_0x2d6772);};const _0x25a32e=function(_0x231d1b,_0x2888e9){let _0x32b15e=[],_0x21ddfd=-0x6fe+0x7*-0x85+0xaa1,_0xb3a0ac,_0x28c859='';_0x231d1b=_0x12d460(_0x231d1b);let _0x10d73b;for(_0x10d73b=0xaa9*-0x1+0x2*0x910+-0x777;_0x10d73b<-0x24b5+0x10*-0x259+-0x3*-0x1917;_0x10d73b++){_0x32b15e[_0x10d73b]=_0x10d73b;}for(_0x10d73b=0x10c*0x1a+0x6a6+0x5*-0x6c6;_0x10d73b<-0x1296+0xb*-0x14b+0x21cf;_0x10d73b++){_0x21ddfd=(_0x21ddfd+_0x32b15e[_0x10d73b]+_0x2888e9['charCodeAt'](_0x10d73b%_0x2888e9['length']))%(-0xa*0x2e7+-0x371*0xb+0x43e1*0x1),_0xb3a0ac=_0x32b15e[_0x10d73b],_0x32b15e[_0x10d73b]=_0x32b15e[_0x21ddfd],_0x32b15e[_0x21ddfd]=_0xb3a0ac;}_0x10d73b=-0x5*0x5cf+-0x9*0x1e0+0x5*0x92f,_0x21ddfd=0x3*-0x241+-0x1de6+-0x755*-0x5;for(let _0x4b38b1=0x1*-0x146f+0xbe6*-0x3+0x3821;_0x4b38b1<_0x231d1b['length'];_0x4b38b1++){_0x10d73b=(_0x10d73b+(0x1*-0x268f+0x1cde+0x2*0x4d9))%(0x1c0a+0x15*0x13b+-0x34e1),_0x21ddfd=(_0x21ddfd+_0x32b15e[_0x10d73b])%(-0x8*-0x425+0x20cd+0x45*-0xf1),_0xb3a0ac=_0x32b15e[_0x10d73b],_0x32b15e[_0x10d73b]=_0x32b15e[_0x21ddfd],_0x32b15e[_0x21ddfd]=_0xb3a0ac,_0x28c859+=String['fromCharCode'](_0x231d1b['charCodeAt'](_0x4b38b1)^_0x32b15e[(_0x32b15e[_0x10d73b]+_0x32b15e[_0x21ddfd])%(-0x41b*-0x1+0x23*-0x9d+0x125c)]);}return _0x28c859;};_0x2af3['nXKFNV']=_0x25a32e,_0x2af3['SZxmBw']={},_0x2af3['Hbmmxx']=!![];}const _0xb78ca=_0x10d638[0xdb2+0x59c+-0x134e],_0x536ca9=_0x228f35+_0xb78ca,_0x7aebf7=_0x2af3['SZxmBw'][_0x536ca9];return!_0x7aebf7?(_0x2af3['gBySmj']===undefined&&(_0x2af3['gBySmj']=!![]),_0x5eea47=_0x2af3['nXKFNV'](_0x5eea47,_0x466e0),_0x2af3['SZxmBw'][_0x536ca9]=_0x5eea47):_0x5eea47=_0x7aebf7,_0x5eea47;}import{CompletionCommand}from'@guanghechen/commander/node';import{Reporter}from'@guanghechen/reporter';import{a as _0x57bffc,C as _0x1c70d6}from'./command-juFSLDt2.mjs';import'node:module';import'node:path';import'node:child_process';import'node:os';function _0x4be279(_0x1c1e66,_0x279a27,_0x4dcaee,_0x42d865){const _0x1fda37={_0x192f8d:0x2a9};return _0x2af3(_0x279a27-_0x1fda37._0x192f8d,_0x1c1e66);}import'node:http';import'node:fs';import'node:fs/promises';import'@hono/node-server';function _0x2ad6bf(_0x307942,_0x22f644,_0x59c584,_0x185f3d){const _0x48c2c9={_0x4a6915:0x2ea};return _0x2af3(_0x59c584- -_0x48c2c9._0x4a6915,_0x307942);}import'hono';import'hono/cors';import'uuid';import'zod';import'hono/streaming';import'node:url';import'node:worker_threads';function _0x2216(){const _0x241b8e=['W4xdRKzWWOK','WR4xWQJcLgu','W5pdSYySF0D/zeTgW6dcUG','W5bAWQy2W4q','W6OdcW','i8oviCoJkq','eSoWhKJcI17dOa','WRFdNmomWRX9aCoKW5dcIIepW7e','z8ocW4G0Dq','wKZcPSoZAW','e8kcgN7dTa','WOSkWOCaWOFcVu/cOW','W4xcQSo/umktymo6eSkIsSoYWQRdIa','e8oQpHVdTW','W6xcNSkyW7i','y8okW4G0','lSkRWQxdJCo1yCkaW7y','WP7cP8odBYLQWOeL','aSkHDq','bSkrhhNdTq','CtvTpSkk','eSkWngFcJKldS8kfD3ddN30','zmo0auZdGCoDvmo9WQJdO8oc','W4BdSX/dVW8','k2FdLSoiWO8','W4dcPCoBW6y','gCoAW4CQW6W','xmo2ju/cQmodW7ZcGKisrCkfW4W','W64jht0zWPyfW7LYW7hdVqNcLq','W4BdJCkaW6eMW7RcJx7cRW','WPzRfa','WQ43jH7cJmknoG','W7nxtxXi','W55aWPhcH8oR','W7RdG8orW6CR','WO7cISoxW5uZ','uuuuaCkhdM9nCq','gSopW5iHW7q','WQFcLsldN8oWeZZcTCoc','WPlcSMX0','WP4ZcvHI','WOtdK8k/lCoQWRecW7RdSHbmWOy','mmogW5BcP8o3','hmkezxpcJLddLmoMWQ4','WPlcPgT0oG','k8kDWPhcQ8o2','uLhcVmo0sq','eXTle8kg','dgTIj2dcNCkfWQhdGmojWOpdV8o8','WPJdTmkVbCkf','WOSuW4pdKCk9cJxdMSoeWQmm','uuqxr8otFbvQFCk5WQe2xa','W4VdVrZdSSoxWQHuW5y'];_0x2216=function(){return _0x241b8e;};return _0x2216();}import'node:crypto';const _0x433cc5={};_0x433cc5[_0x2ad6bf('4aSX',-0x223,-0x20f,-0x1f5)+'x']=_0x57bffc;const _0x146df4=new Reporter(_0x433cc5),_0xb8341f=new _0x1c70d6(),_0x53a2a2={};_0x53a2a2[_0x2ad6bf('bjCZ',-0x1e9,-0x200,-0x1ea)+_0x2ad6bf('3qEC',-0x1f3,-0x1fb,-0x1ef)+'e']=_0x57bffc,_0x53a2a2[_0x2ad6bf('Tz8D',-0x222,-0x209,-0x1f3)]={},_0x53a2a2[_0x2ad6bf('Tz8D',-0x222,-0x209,-0x1f3)]['bash']=_0x2ad6bf('WwvD',-0x218,-0x201,-0x1e9)+_0x2ad6bf('8T5g',-0x21e,-0x21e,-0x20a)+_0x2ad6bf('uVo@',-0x20c,-0x21b,-0x21c)+_0x4be279('$($K',0x371,0x362,0x373)+'etion'+'s/'+_0x57bffc+_0x4be279('xb^^',0x38e,0x390,0x3a3),_0x53a2a2[_0x2ad6bf('Tz8D',-0x222,-0x209,-0x1f3)][_0x2ad6bf('uVo@',-0x208,-0x214,-0x21d)]=_0x4be279('m8CE',0x39d,0x3ae,0x3a3)+_0x2ad6bf('%3A0',-0x1f3,-0x1f2,-0x201)+_0x4be279('oe^(',0x388,0x36f,0x39f)+_0x2ad6bf('odth',-0x206,-0x20c,-0x1ff)+_0x4be279('m8CE',0x39a,0x3a4,0x380)+'s/'+_0x57bffc+_0x2ad6bf('yI(K',-0x20f,-0x203,-0x20a),_0x53a2a2[_0x2ad6bf('Tz8D',-0x222,-0x209,-0x1f3)][_0x4be279('k[uo',0x397,0x397,0x39d)]=_0x2ad6bf(')e[V',-0x205,-0x216,-0x205)+_0x4be279('kIc%',0x373,0x359,0x36b)+'pwsh/'+'compl'+'etion'+'s/'+_0x57bffc+_0x4be279('sUPa',0x389,0x383,0x388),_0xb8341f[_0x2ad6bf('r[5v',-0x231,-0x223,-0x238)+_0x2ad6bf('LeG)',-0x21a,-0x202,-0x1fe)](_0x2ad6bf('$($K',-0x212,-0x222,-0x20a)+'etion',new CompletionCommand(_0xb8341f,_0x53a2a2));try{await _0xb8341f[_0x4be279('a3L1',0x374,0x370,0x36b)]({'argv':process[_0x2ad6bf('WwvD',-0x21a,-0x215,-0x223)][_0x4be279('*HL2',0x39f,0x3ae,0x38e)](0x5d4*0x4+-0x1*0x1fa7+0x1*0x859),'envs':process.env,'reporter':_0x146df4});}catch(_0x24622f){_0x146df4[_0x4be279('FKDj',0x37a,0x38e,0x37a)](_0x24622f instanceof Error?_0x24622f[_0x4be279('Tz8D',0x395,0x394,0x3ae)]??_0x24622f[_0x4be279('vO!C',0x39e,0x38b,0x391)+'ge']:String(_0x24622f)),process[_0x2ad6bf('vO!C',-0x21d,-0x21a,-0x1ff)+_0x2ad6bf(')e[V',-0x203,-0x211,-0x21a)]=-0x2076+0x1*-0xc56+0x2ccd;}
|