@corbat-tech/coco 2.28.4 → 2.29.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/dist/cli/index.js +122 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +43 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
package/dist/cli/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { setGlobalDispatcher, EnvHttpProxyAgent } from 'undici';
|
|
2
3
|
import * as fs5 from 'fs';
|
|
3
4
|
import fs5__default, { accessSync, readFileSync, constants as constants$1 } from 'fs';
|
|
4
5
|
import * as path39 from 'path';
|
|
@@ -62,6 +63,69 @@ var __export = (target, all) => {
|
|
|
62
63
|
for (var name in all)
|
|
63
64
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
64
65
|
};
|
|
66
|
+
function getProxyFromEnv() {
|
|
67
|
+
for (const key of PROXY_ENV_VARS) {
|
|
68
|
+
const value = process.env[key];
|
|
69
|
+
if (value && value.trim().length > 0) {
|
|
70
|
+
return value.trim();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
function maskProxyUrl(url) {
|
|
76
|
+
try {
|
|
77
|
+
const parsed = new URL(url);
|
|
78
|
+
if (parsed.password) {
|
|
79
|
+
parsed.password = "***";
|
|
80
|
+
}
|
|
81
|
+
return parsed.toString();
|
|
82
|
+
} catch {
|
|
83
|
+
return "[invalid proxy URL]";
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function installProxyDispatcher() {
|
|
87
|
+
if (installed) return getProxyFromEnv() ? maskProxyUrl(getProxyFromEnv()) : null;
|
|
88
|
+
const proxy = getProxyFromEnv();
|
|
89
|
+
if (!proxy) return null;
|
|
90
|
+
try {
|
|
91
|
+
setGlobalDispatcher(new EnvHttpProxyAgent());
|
|
92
|
+
installed = true;
|
|
93
|
+
return maskProxyUrl(proxy);
|
|
94
|
+
} catch {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function describeFetchError(error) {
|
|
99
|
+
if (!(error instanceof Error)) {
|
|
100
|
+
return {};
|
|
101
|
+
}
|
|
102
|
+
const cause = unwrapCause(error);
|
|
103
|
+
return {
|
|
104
|
+
code: cause?.code,
|
|
105
|
+
hostname: cause?.hostname
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function unwrapCause(error) {
|
|
109
|
+
let current = error;
|
|
110
|
+
let depth = 0;
|
|
111
|
+
while (current && depth < 5) {
|
|
112
|
+
const next = current.cause;
|
|
113
|
+
if (!next) break;
|
|
114
|
+
current = next;
|
|
115
|
+
depth++;
|
|
116
|
+
}
|
|
117
|
+
if (current && typeof current === "object") {
|
|
118
|
+
return current;
|
|
119
|
+
}
|
|
120
|
+
return void 0;
|
|
121
|
+
}
|
|
122
|
+
var PROXY_ENV_VARS, installed;
|
|
123
|
+
var init_proxy = __esm({
|
|
124
|
+
"src/utils/proxy.ts"() {
|
|
125
|
+
PROXY_ENV_VARS = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy"];
|
|
126
|
+
installed = false;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
65
129
|
function findPackageJson() {
|
|
66
130
|
let dir = dirname(fileURLToPath(import.meta.url));
|
|
67
131
|
for (let i = 0; i < 10; i++) {
|
|
@@ -1944,8 +2008,15 @@ async function runBrowserOAuthFlow(provider) {
|
|
|
1944
2008
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
1945
2009
|
console.log();
|
|
1946
2010
|
console.log(chalk.yellow(" \u26A0 Browser authentication failed"));
|
|
1947
|
-
const
|
|
1948
|
-
|
|
2011
|
+
const isNetwork = errorMsg.includes("fetch failed") || errorMsg.toLowerCase().includes("network error") || errorMsg.includes("ECONNREFUSED") || errorMsg.includes("ENOTFOUND") || errorMsg.includes("ETIMEDOUT");
|
|
2012
|
+
if (isNetwork) {
|
|
2013
|
+
const { code } = describeFetchError(error);
|
|
2014
|
+
console.log(chalk.dim(" Error: Network error"));
|
|
2015
|
+
printNetworkTroubleshooting(code);
|
|
2016
|
+
} else {
|
|
2017
|
+
const errorCategory = errorMsg.includes("timeout") || errorMsg.includes("Timeout") ? "Request timed out" : errorMsg.includes("401") || errorMsg.includes("403") ? "Authorization denied" : errorMsg.includes("invalid_grant") || errorMsg.includes("invalid_client") ? "Invalid credentials" : "Authentication error (see debug logs for details)";
|
|
2018
|
+
console.log(chalk.dim(` Error: ${errorCategory}`));
|
|
2019
|
+
}
|
|
1949
2020
|
console.log();
|
|
1950
2021
|
const fallbackOptions = [];
|
|
1951
2022
|
if (config?.deviceAuthEndpoint) {
|
|
@@ -2235,14 +2306,38 @@ async function runCopilotDeviceFlow() {
|
|
|
2235
2306
|
console.log(chalk.yellow(" \u26A0 Authentication timed out. Please try again."));
|
|
2236
2307
|
} else if (errorMsg.includes("denied")) {
|
|
2237
2308
|
console.log(chalk.yellow(" \u26A0 Access was denied."));
|
|
2309
|
+
} else if (errorMsg.includes("fetch failed") || errorMsg.toLowerCase().includes("network")) {
|
|
2310
|
+
const { code } = describeFetchError(error);
|
|
2311
|
+
console.log(chalk.red(" \u2717 Network error reaching GitHub"));
|
|
2312
|
+
printNetworkTroubleshooting(code);
|
|
2238
2313
|
} else {
|
|
2239
|
-
|
|
2240
|
-
console.log(chalk.red(` \u2717 ${category}`));
|
|
2314
|
+
console.log(chalk.red(" \u2717 Authentication error \u2014 see debug logs for details"));
|
|
2241
2315
|
}
|
|
2242
2316
|
console.log();
|
|
2243
2317
|
return null;
|
|
2244
2318
|
}
|
|
2245
2319
|
}
|
|
2320
|
+
function printNetworkTroubleshooting(code) {
|
|
2321
|
+
const proxy = getProxyFromEnv();
|
|
2322
|
+
if (proxy) {
|
|
2323
|
+
console.log(chalk.dim(` Proxy in use: ${maskProxyUrl(proxy)}`));
|
|
2324
|
+
console.log(chalk.dim(" \u2192 Verify the proxy allows github.com and api.github.com."));
|
|
2325
|
+
} else {
|
|
2326
|
+
console.log(chalk.dim(" No HTTPS_PROXY / HTTP_PROXY env vars detected."));
|
|
2327
|
+
console.log(chalk.dim(" \u2192 If you're behind a corporate proxy, set HTTPS_PROXY and retry."));
|
|
2328
|
+
}
|
|
2329
|
+
if (code === "SELF_SIGNED_CERT_IN_CHAIN" || code === "UNABLE_TO_VERIFY_LEAF_SIGNATURE") {
|
|
2330
|
+
console.log(
|
|
2331
|
+
chalk.dim(
|
|
2332
|
+
" \u2192 A TLS interceptor is rewriting certificates. Add your corp root CA to NODE_EXTRA_CA_CERTS."
|
|
2333
|
+
)
|
|
2334
|
+
);
|
|
2335
|
+
} else if (code === "ENOTFOUND") {
|
|
2336
|
+
console.log(chalk.dim(" \u2192 Check DNS: `nslookup github.com`"));
|
|
2337
|
+
} else if (code === "ETIMEDOUT" || code === "UND_ERR_CONNECT_TIMEOUT") {
|
|
2338
|
+
console.log(chalk.dim(" \u2192 A firewall may be dropping the connection silently."));
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2246
2341
|
async function getOrRefreshOAuthToken(provider) {
|
|
2247
2342
|
if (provider === "copilot") {
|
|
2248
2343
|
const tokenResult = await getValidCopilotToken();
|
|
@@ -2273,6 +2368,7 @@ var init_flow = __esm({
|
|
|
2273
2368
|
init_pkce();
|
|
2274
2369
|
init_callback_server();
|
|
2275
2370
|
init_platform();
|
|
2371
|
+
init_proxy();
|
|
2276
2372
|
init_copilot();
|
|
2277
2373
|
execFileAsync2 = promisify(execFile);
|
|
2278
2374
|
}
|
|
@@ -19280,6 +19376,24 @@ async function writeVersion(cwd, versionFile, newVersion) {
|
|
|
19280
19376
|
return;
|
|
19281
19377
|
}
|
|
19282
19378
|
await writeFile(fullPath, updated, "utf-8");
|
|
19379
|
+
if (versionFile.stack === "node" && versionFile.path === "package.json") {
|
|
19380
|
+
await syncCompanionNodeVersions(cwd, newVersion);
|
|
19381
|
+
}
|
|
19382
|
+
}
|
|
19383
|
+
async function syncCompanionNodeVersions(cwd, newVersion) {
|
|
19384
|
+
for (const relativePath of NODE_VERSION_SYNC_TARGETS) {
|
|
19385
|
+
const fullPath = path39__default.join(cwd, relativePath);
|
|
19386
|
+
if (!await fileExists3(fullPath)) {
|
|
19387
|
+
continue;
|
|
19388
|
+
}
|
|
19389
|
+
const content = await readFile(fullPath, "utf-8");
|
|
19390
|
+
const pkg = JSON.parse(content);
|
|
19391
|
+
if (typeof pkg["version"] !== "string") {
|
|
19392
|
+
continue;
|
|
19393
|
+
}
|
|
19394
|
+
pkg["version"] = newVersion;
|
|
19395
|
+
await writeFile(fullPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
|
|
19396
|
+
}
|
|
19283
19397
|
}
|
|
19284
19398
|
function detectBumpFromCommits(commitMessages) {
|
|
19285
19399
|
let bump = "patch";
|
|
@@ -19294,7 +19408,7 @@ function detectBumpFromCommits(commitMessages) {
|
|
|
19294
19408
|
}
|
|
19295
19409
|
return bump;
|
|
19296
19410
|
}
|
|
19297
|
-
var VERSION_FILES;
|
|
19411
|
+
var VERSION_FILES, NODE_VERSION_SYNC_TARGETS;
|
|
19298
19412
|
var init_version_detector = __esm({
|
|
19299
19413
|
"src/cli/repl/skills/builtin/ship/version-detector.ts"() {
|
|
19300
19414
|
init_files();
|
|
@@ -19304,6 +19418,7 @@ var init_version_detector = __esm({
|
|
|
19304
19418
|
{ file: "pyproject.toml", stack: "python", field: "version" },
|
|
19305
19419
|
{ file: "pom.xml", stack: "java", field: "version" }
|
|
19306
19420
|
];
|
|
19421
|
+
NODE_VERSION_SYNC_TARGETS = ["vscode-extension/package.json"];
|
|
19307
19422
|
}
|
|
19308
19423
|
});
|
|
19309
19424
|
async function detectChangelog(cwd) {
|
|
@@ -24918,6 +25033,7 @@ var init_input_echo = __esm({
|
|
|
24918
25033
|
});
|
|
24919
25034
|
|
|
24920
25035
|
// src/cli/index.ts
|
|
25036
|
+
init_proxy();
|
|
24921
25037
|
init_version();
|
|
24922
25038
|
|
|
24923
25039
|
// src/orchestrator/project.ts
|
|
@@ -56239,6 +56355,7 @@ ${stdinContent}
|
|
|
56239
56355
|
// src/cli/index.ts
|
|
56240
56356
|
init_env();
|
|
56241
56357
|
init_errors();
|
|
56358
|
+
installProxyDispatcher();
|
|
56242
56359
|
var program = new Command();
|
|
56243
56360
|
program.name("coco").description("Corbat-Coco: Autonomous Coding Agent with Self-Review and Quality Convergence").version(VERSION, "-v, --version", "Output the current version");
|
|
56244
56361
|
registerInitCommand(program);
|