openkitt 0.3.4 → 0.3.5
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/dist/cli.js +27 -20
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2789,22 +2789,30 @@ async function decryptCopilotStored(stored) {
|
|
|
2789
2789
|
}
|
|
2790
2790
|
}
|
|
2791
2791
|
async function refreshCopilotToken(githubToken) {
|
|
2792
|
+
let res;
|
|
2792
2793
|
try {
|
|
2793
|
-
|
|
2794
|
+
res = await fetch(COPILOT_TOKEN_URL, {
|
|
2794
2795
|
headers: {
|
|
2795
|
-
Authorization: `
|
|
2796
|
-
"User-Agent": "
|
|
2796
|
+
Authorization: `token ${githubToken}`,
|
|
2797
|
+
"User-Agent": "GithubCopilot/1.250.0",
|
|
2798
|
+
"Editor-Version": "vscode/1.95.0",
|
|
2799
|
+
"Editor-Plugin-Version": "copilot/1.250.0",
|
|
2800
|
+
"X-GitHub-Api-Version": "2025-04-01",
|
|
2801
|
+
Accept: "application/json"
|
|
2797
2802
|
}
|
|
2798
2803
|
});
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
} catch {
|
|
2806
|
-
return null;
|
|
2804
|
+
} catch (err) {
|
|
2805
|
+
throw new Error(`Copilot token exchange failed: network error — ${err instanceof Error ? err.message : String(err)}`);
|
|
2806
|
+
}
|
|
2807
|
+
if (!res.ok) {
|
|
2808
|
+
const body = await res.text().catch(() => "");
|
|
2809
|
+
throw new Error(`Copilot token exchange failed (HTTP ${res.status}): ${body.slice(0, 300)}`);
|
|
2807
2810
|
}
|
|
2811
|
+
const data = await res.json();
|
|
2812
|
+
if (typeof data.token !== "string" || typeof data.expires_at !== "number") {
|
|
2813
|
+
throw new Error("Copilot token exchange failed: unexpected response shape");
|
|
2814
|
+
}
|
|
2815
|
+
return { token: data.token, expiresAt: data.expires_at * 1000 };
|
|
2808
2816
|
}
|
|
2809
2817
|
async function getCopilotToken() {
|
|
2810
2818
|
const config = readConfig();
|
|
@@ -2819,9 +2827,12 @@ async function getCopilotToken() {
|
|
|
2819
2827
|
if (Date.now() < stored.copilotTokenExpiresAt - 60000) {
|
|
2820
2828
|
return decrypted.copilotToken;
|
|
2821
2829
|
}
|
|
2822
|
-
|
|
2823
|
-
|
|
2830
|
+
let refreshed;
|
|
2831
|
+
try {
|
|
2832
|
+
refreshed = await refreshCopilotToken(decrypted.githubToken);
|
|
2833
|
+
} catch {
|
|
2824
2834
|
return null;
|
|
2835
|
+
}
|
|
2825
2836
|
const encCopilot = await encrypt(refreshed.token);
|
|
2826
2837
|
writeConfig({
|
|
2827
2838
|
llm: {
|
|
@@ -2836,11 +2847,7 @@ async function getCopilotToken() {
|
|
|
2836
2847
|
return refreshed.token;
|
|
2837
2848
|
}
|
|
2838
2849
|
async function exchangeCopilotToken(githubToken) {
|
|
2839
|
-
|
|
2840
|
-
if (!result) {
|
|
2841
|
-
throw new Error("Failed to exchange GitHub token for Copilot bearer token. Check your Copilot subscription is active.");
|
|
2842
|
-
}
|
|
2843
|
-
return result;
|
|
2850
|
+
return refreshCopilotToken(githubToken);
|
|
2844
2851
|
}
|
|
2845
2852
|
async function getLlmConfig() {
|
|
2846
2853
|
const config = readConfig();
|
|
@@ -265101,7 +265108,7 @@ var COPILOT_MODEL_OPTIONS = [
|
|
|
265101
265108
|
{ value: "o4-mini", label: "o4-mini (o4-mini via Copilot)" },
|
|
265102
265109
|
{ value: "gemini-2.5-pro", label: "gemini-2.5-pro (Gemini 2.5 Pro via Copilot)" }
|
|
265103
265110
|
];
|
|
265104
|
-
var GITHUB_DEVICE_CLIENT_ID = "
|
|
265111
|
+
var GITHUB_DEVICE_CLIENT_ID = "Iv1.b507a08c87ecfe98";
|
|
265105
265112
|
function cancelled() {
|
|
265106
265113
|
console.log(import_picocolors8.default.yellow("Cancelled."));
|
|
265107
265114
|
return true;
|
|
@@ -265947,7 +265954,7 @@ async function helpCommand(_context, _args) {
|
|
|
265947
265954
|
// package.json
|
|
265948
265955
|
var package_default = {
|
|
265949
265956
|
name: "openkitt",
|
|
265950
|
-
version: "0.3.
|
|
265957
|
+
version: "0.3.5",
|
|
265951
265958
|
description: "AI-powered monorepo scaffolding CLI",
|
|
265952
265959
|
keywords: [
|
|
265953
265960
|
"cli",
|