oh-my-magento 0.3.7 → 0.3.8
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 +1370 -295
- package/dist/index.js +12 -12
- package/package.json +12 -12
package/dist/cli/index.js
CHANGED
|
@@ -2145,7 +2145,7 @@ var package_default;
|
|
|
2145
2145
|
var init_package = __esm(() => {
|
|
2146
2146
|
package_default = {
|
|
2147
2147
|
name: "oh-my-magento",
|
|
2148
|
-
version: "0.3.
|
|
2148
|
+
version: "0.3.8",
|
|
2149
2149
|
description: "Magento 2 + Hyv\xE4 Enterprise E-Commerce Intelligent Agent Orchestration System - OpenCode Plugin",
|
|
2150
2150
|
main: "./dist/index.js",
|
|
2151
2151
|
types: "dist/index.d.ts",
|
|
@@ -2226,17 +2226,17 @@ var init_package = __esm(() => {
|
|
|
2226
2226
|
typescript: "^5.7.3"
|
|
2227
2227
|
},
|
|
2228
2228
|
optionalDependencies: {
|
|
2229
|
-
"oh-my-magento-darwin-arm64": "0.3.
|
|
2230
|
-
"oh-my-magento-darwin-x64": "0.3.
|
|
2231
|
-
"oh-my-magento-darwin-x64-baseline": "0.3.
|
|
2232
|
-
"oh-my-magento-linux-arm64": "0.3.
|
|
2233
|
-
"oh-my-magento-linux-arm64-musl": "0.3.
|
|
2234
|
-
"oh-my-magento-linux-x64": "0.3.
|
|
2235
|
-
"oh-my-magento-linux-x64-baseline": "0.3.
|
|
2236
|
-
"oh-my-magento-linux-x64-musl": "0.3.
|
|
2237
|
-
"oh-my-magento-linux-x64-musl-baseline": "0.3.
|
|
2238
|
-
"oh-my-magento-windows-x64": "0.3.
|
|
2239
|
-
"oh-my-magento-windows-x64-baseline": "0.3.
|
|
2229
|
+
"oh-my-magento-darwin-arm64": "0.3.8",
|
|
2230
|
+
"oh-my-magento-darwin-x64": "0.3.8",
|
|
2231
|
+
"oh-my-magento-darwin-x64-baseline": "0.3.8",
|
|
2232
|
+
"oh-my-magento-linux-arm64": "0.3.8",
|
|
2233
|
+
"oh-my-magento-linux-arm64-musl": "0.3.8",
|
|
2234
|
+
"oh-my-magento-linux-x64": "0.3.8",
|
|
2235
|
+
"oh-my-magento-linux-x64-baseline": "0.3.8",
|
|
2236
|
+
"oh-my-magento-linux-x64-musl": "0.3.8",
|
|
2237
|
+
"oh-my-magento-linux-x64-musl-baseline": "0.3.8",
|
|
2238
|
+
"oh-my-magento-windows-x64": "0.3.8",
|
|
2239
|
+
"oh-my-magento-windows-x64-baseline": "0.3.8"
|
|
2240
2240
|
},
|
|
2241
2241
|
overrides: {
|
|
2242
2242
|
"@opencode-ai/sdk": "^1.2.24"
|
|
@@ -50969,6 +50969,7 @@ import { stripVTControlCharacters as S2 } from "util";
|
|
|
50969
50969
|
|
|
50970
50970
|
// node_modules/@clack/core/dist/index.mjs
|
|
50971
50971
|
var import_sisteransi = __toESM(require_src(), 1);
|
|
50972
|
+
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
50972
50973
|
import { stdin as j, stdout as M } from "process";
|
|
50973
50974
|
import * as g from "readline";
|
|
50974
50975
|
import O from "readline";
|
|
@@ -51323,6 +51324,24 @@ class x {
|
|
|
51323
51324
|
}
|
|
51324
51325
|
}
|
|
51325
51326
|
}
|
|
51327
|
+
|
|
51328
|
+
class dD extends x {
|
|
51329
|
+
get cursor() {
|
|
51330
|
+
return this.value ? 0 : 1;
|
|
51331
|
+
}
|
|
51332
|
+
get _value() {
|
|
51333
|
+
return this.cursor === 0;
|
|
51334
|
+
}
|
|
51335
|
+
constructor(u) {
|
|
51336
|
+
super(u, false), this.value = !!u.initialValue, this.on("value", () => {
|
|
51337
|
+
this.value = this._value;
|
|
51338
|
+
}), this.on("confirm", (t) => {
|
|
51339
|
+
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = t, this.state = "submit", this.close();
|
|
51340
|
+
}), this.on("cursor", () => {
|
|
51341
|
+
this.value = !this.value;
|
|
51342
|
+
});
|
|
51343
|
+
}
|
|
51344
|
+
}
|
|
51326
51345
|
var A;
|
|
51327
51346
|
A = new WeakMap;
|
|
51328
51347
|
var OD = Object.defineProperty;
|
|
@@ -51352,9 +51371,27 @@ class LD extends x {
|
|
|
51352
51371
|
this.value = this._value.value;
|
|
51353
51372
|
}
|
|
51354
51373
|
}
|
|
51374
|
+
class RD extends x {
|
|
51375
|
+
get valueWithCursor() {
|
|
51376
|
+
if (this.state === "submit")
|
|
51377
|
+
return this.value;
|
|
51378
|
+
if (this.cursor >= this.value.length)
|
|
51379
|
+
return `${this.value}\u2588`;
|
|
51380
|
+
const u = this.value.slice(0, this.cursor), [t, ...F] = this.value.slice(this.cursor);
|
|
51381
|
+
return `${u}${import_picocolors3.default.inverse(t)}${F.join("")}`;
|
|
51382
|
+
}
|
|
51383
|
+
get cursor() {
|
|
51384
|
+
return this._cursor;
|
|
51385
|
+
}
|
|
51386
|
+
constructor(u) {
|
|
51387
|
+
super(u), this.on("finalize", () => {
|
|
51388
|
+
this.value || (this.value = u.defaultValue);
|
|
51389
|
+
});
|
|
51390
|
+
}
|
|
51391
|
+
}
|
|
51355
51392
|
|
|
51356
51393
|
// node_modules/@clack/prompts/dist/index.mjs
|
|
51357
|
-
var
|
|
51394
|
+
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
51358
51395
|
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
51359
51396
|
import y2 from "process";
|
|
51360
51397
|
function ce() {
|
|
@@ -51387,13 +51424,13 @@ var b2 = (t) => {
|
|
|
51387
51424
|
switch (t) {
|
|
51388
51425
|
case "initial":
|
|
51389
51426
|
case "active":
|
|
51390
|
-
return
|
|
51427
|
+
return import_picocolors4.default.cyan(le);
|
|
51391
51428
|
case "cancel":
|
|
51392
|
-
return
|
|
51429
|
+
return import_picocolors4.default.red(L2);
|
|
51393
51430
|
case "error":
|
|
51394
|
-
return
|
|
51431
|
+
return import_picocolors4.default.yellow(W2);
|
|
51395
51432
|
case "submit":
|
|
51396
|
-
return
|
|
51433
|
+
return import_picocolors4.default.green(C);
|
|
51397
51434
|
}
|
|
51398
51435
|
};
|
|
51399
51436
|
var G2 = (t) => {
|
|
@@ -51401,39 +51438,79 @@ var G2 = (t) => {
|
|
|
51401
51438
|
let l2 = 0;
|
|
51402
51439
|
n >= l2 + a - 3 ? l2 = Math.max(Math.min(n - a + 3, r2.length - a), 0) : n < l2 + 2 && (l2 = Math.max(n - 2, 0));
|
|
51403
51440
|
const $2 = a < r2.length && l2 > 0, g2 = a < r2.length && l2 + a < r2.length;
|
|
51404
|
-
return r2.slice(l2, l2 + a).map((p2,
|
|
51405
|
-
const j2 =
|
|
51406
|
-
return j2 || E ?
|
|
51441
|
+
return r2.slice(l2, l2 + a).map((p2, v2, f) => {
|
|
51442
|
+
const j2 = v2 === 0 && $2, E = v2 === f.length - 1 && g2;
|
|
51443
|
+
return j2 || E ? import_picocolors4.default.dim("...") : i2(p2, v2 + l2 === n);
|
|
51407
51444
|
});
|
|
51408
51445
|
};
|
|
51446
|
+
var he = (t) => new RD({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, render() {
|
|
51447
|
+
const n = `${import_picocolors4.default.gray(o)}
|
|
51448
|
+
${b2(this.state)} ${t.message}
|
|
51449
|
+
`, r2 = t.placeholder ? import_picocolors4.default.inverse(t.placeholder[0]) + import_picocolors4.default.dim(t.placeholder.slice(1)) : import_picocolors4.default.inverse(import_picocolors4.default.hidden("_")), i2 = this.value ? this.valueWithCursor : r2;
|
|
51450
|
+
switch (this.state) {
|
|
51451
|
+
case "error":
|
|
51452
|
+
return `${n.trim()}
|
|
51453
|
+
${import_picocolors4.default.yellow(o)} ${i2}
|
|
51454
|
+
${import_picocolors4.default.yellow(d2)} ${import_picocolors4.default.yellow(this.error)}
|
|
51455
|
+
`;
|
|
51456
|
+
case "submit":
|
|
51457
|
+
return `${n}${import_picocolors4.default.gray(o)} ${import_picocolors4.default.dim(this.value || t.placeholder)}`;
|
|
51458
|
+
case "cancel":
|
|
51459
|
+
return `${n}${import_picocolors4.default.gray(o)} ${import_picocolors4.default.strikethrough(import_picocolors4.default.dim(this.value ?? ""))}${this.value?.trim() ? `
|
|
51460
|
+
${import_picocolors4.default.gray(o)}` : ""}`;
|
|
51461
|
+
default:
|
|
51462
|
+
return `${n}${import_picocolors4.default.cyan(o)} ${i2}
|
|
51463
|
+
${import_picocolors4.default.cyan(d2)}
|
|
51464
|
+
`;
|
|
51465
|
+
}
|
|
51466
|
+
} }).prompt();
|
|
51467
|
+
var ye = (t) => {
|
|
51468
|
+
const n = t.active ?? "Yes", r2 = t.inactive ?? "No";
|
|
51469
|
+
return new dD({ active: n, inactive: r2, initialValue: t.initialValue ?? true, render() {
|
|
51470
|
+
const i2 = `${import_picocolors4.default.gray(o)}
|
|
51471
|
+
${b2(this.state)} ${t.message}
|
|
51472
|
+
`, s = this.value ? n : r2;
|
|
51473
|
+
switch (this.state) {
|
|
51474
|
+
case "submit":
|
|
51475
|
+
return `${i2}${import_picocolors4.default.gray(o)} ${import_picocolors4.default.dim(s)}`;
|
|
51476
|
+
case "cancel":
|
|
51477
|
+
return `${i2}${import_picocolors4.default.gray(o)} ${import_picocolors4.default.strikethrough(import_picocolors4.default.dim(s))}
|
|
51478
|
+
${import_picocolors4.default.gray(o)}`;
|
|
51479
|
+
default:
|
|
51480
|
+
return `${i2}${import_picocolors4.default.cyan(o)} ${this.value ? `${import_picocolors4.default.green(k2)} ${n}` : `${import_picocolors4.default.dim(P2)} ${import_picocolors4.default.dim(n)}`} ${import_picocolors4.default.dim("/")} ${this.value ? `${import_picocolors4.default.dim(P2)} ${import_picocolors4.default.dim(r2)}` : `${import_picocolors4.default.green(k2)} ${r2}`}
|
|
51481
|
+
${import_picocolors4.default.cyan(d2)}
|
|
51482
|
+
`;
|
|
51483
|
+
}
|
|
51484
|
+
} }).prompt();
|
|
51485
|
+
};
|
|
51409
51486
|
var ve = (t) => {
|
|
51410
51487
|
const n = (r2, i2) => {
|
|
51411
51488
|
const s = r2.label ?? String(r2.value);
|
|
51412
51489
|
switch (i2) {
|
|
51413
51490
|
case "selected":
|
|
51414
|
-
return `${
|
|
51491
|
+
return `${import_picocolors4.default.dim(s)}`;
|
|
51415
51492
|
case "active":
|
|
51416
|
-
return `${
|
|
51493
|
+
return `${import_picocolors4.default.green(k2)} ${s} ${r2.hint ? import_picocolors4.default.dim(`(${r2.hint})`) : ""}`;
|
|
51417
51494
|
case "cancelled":
|
|
51418
|
-
return `${
|
|
51495
|
+
return `${import_picocolors4.default.strikethrough(import_picocolors4.default.dim(s))}`;
|
|
51419
51496
|
default:
|
|
51420
|
-
return `${
|
|
51497
|
+
return `${import_picocolors4.default.dim(P2)} ${import_picocolors4.default.dim(s)}`;
|
|
51421
51498
|
}
|
|
51422
51499
|
};
|
|
51423
51500
|
return new LD({ options: t.options, initialValue: t.initialValue, render() {
|
|
51424
|
-
const r2 = `${
|
|
51501
|
+
const r2 = `${import_picocolors4.default.gray(o)}
|
|
51425
51502
|
${b2(this.state)} ${t.message}
|
|
51426
51503
|
`;
|
|
51427
51504
|
switch (this.state) {
|
|
51428
51505
|
case "submit":
|
|
51429
|
-
return `${r2}${
|
|
51506
|
+
return `${r2}${import_picocolors4.default.gray(o)} ${n(this.options[this.cursor], "selected")}`;
|
|
51430
51507
|
case "cancel":
|
|
51431
|
-
return `${r2}${
|
|
51432
|
-
${
|
|
51508
|
+
return `${r2}${import_picocolors4.default.gray(o)} ${n(this.options[this.cursor], "cancelled")}
|
|
51509
|
+
${import_picocolors4.default.gray(o)}`;
|
|
51433
51510
|
default:
|
|
51434
|
-
return `${r2}${
|
|
51435
|
-
${
|
|
51436
|
-
${
|
|
51511
|
+
return `${r2}${import_picocolors4.default.cyan(o)} ${G2({ cursor: this.cursor, options: this.options, maxItems: t.maxItems, style: (i2, s) => n(i2, s ? "active" : "inactive") }).join(`
|
|
51512
|
+
${import_picocolors4.default.cyan(o)} `)}
|
|
51513
|
+
${import_picocolors4.default.cyan(d2)}
|
|
51437
51514
|
`;
|
|
51438
51515
|
}
|
|
51439
51516
|
} }).prompt();
|
|
@@ -51445,63 +51522,63 @@ ${t}
|
|
|
51445
51522
|
`), i2 = S2(n).length, s = Math.max(r2.reduce((a, l2) => {
|
|
51446
51523
|
const $2 = S2(l2);
|
|
51447
51524
|
return $2.length > a ? $2.length : a;
|
|
51448
|
-
}, 0), i2) + 2, c = r2.map((a) => `${
|
|
51525
|
+
}, 0), i2) + 2, c = r2.map((a) => `${import_picocolors4.default.gray(o)} ${import_picocolors4.default.dim(a)}${" ".repeat(s - S2(a).length)}${import_picocolors4.default.gray(o)}`).join(`
|
|
51449
51526
|
`);
|
|
51450
|
-
process.stdout.write(`${
|
|
51451
|
-
${
|
|
51527
|
+
process.stdout.write(`${import_picocolors4.default.gray(o)}
|
|
51528
|
+
${import_picocolors4.default.green(C)} ${import_picocolors4.default.reset(n)} ${import_picocolors4.default.gray(_2.repeat(Math.max(s - i2 - 1, 1)) + me)}
|
|
51452
51529
|
${c}
|
|
51453
|
-
${
|
|
51530
|
+
${import_picocolors4.default.gray(de + _2.repeat(s + 2) + pe)}
|
|
51454
51531
|
`);
|
|
51455
51532
|
};
|
|
51456
51533
|
var xe = (t = "") => {
|
|
51457
|
-
process.stdout.write(`${
|
|
51534
|
+
process.stdout.write(`${import_picocolors4.default.gray(d2)} ${import_picocolors4.default.red(t)}
|
|
51458
51535
|
|
|
51459
51536
|
`);
|
|
51460
51537
|
};
|
|
51461
51538
|
var Ie = (t = "") => {
|
|
51462
|
-
process.stdout.write(`${
|
|
51539
|
+
process.stdout.write(`${import_picocolors4.default.gray(ue)} ${t}
|
|
51463
51540
|
`);
|
|
51464
51541
|
};
|
|
51465
51542
|
var Se = (t = "") => {
|
|
51466
|
-
process.stdout.write(`${
|
|
51467
|
-
${
|
|
51543
|
+
process.stdout.write(`${import_picocolors4.default.gray(o)}
|
|
51544
|
+
${import_picocolors4.default.gray(d2)} ${t}
|
|
51468
51545
|
|
|
51469
51546
|
`);
|
|
51470
51547
|
};
|
|
51471
|
-
var M2 = { message: (t = "", { symbol: n =
|
|
51472
|
-
const r2 = [`${
|
|
51548
|
+
var M2 = { message: (t = "", { symbol: n = import_picocolors4.default.gray(o) } = {}) => {
|
|
51549
|
+
const r2 = [`${import_picocolors4.default.gray(o)}`];
|
|
51473
51550
|
if (t) {
|
|
51474
51551
|
const [i2, ...s] = t.split(`
|
|
51475
51552
|
`);
|
|
51476
|
-
r2.push(`${n} ${i2}`, ...s.map((c) => `${
|
|
51553
|
+
r2.push(`${n} ${i2}`, ...s.map((c) => `${import_picocolors4.default.gray(o)} ${c}`));
|
|
51477
51554
|
}
|
|
51478
51555
|
process.stdout.write(`${r2.join(`
|
|
51479
51556
|
`)}
|
|
51480
51557
|
`);
|
|
51481
51558
|
}, info: (t) => {
|
|
51482
|
-
M2.message(t, { symbol:
|
|
51559
|
+
M2.message(t, { symbol: import_picocolors4.default.blue(q) });
|
|
51483
51560
|
}, success: (t) => {
|
|
51484
|
-
M2.message(t, { symbol:
|
|
51561
|
+
M2.message(t, { symbol: import_picocolors4.default.green(D) });
|
|
51485
51562
|
}, step: (t) => {
|
|
51486
|
-
M2.message(t, { symbol:
|
|
51563
|
+
M2.message(t, { symbol: import_picocolors4.default.green(C) });
|
|
51487
51564
|
}, warn: (t) => {
|
|
51488
|
-
M2.message(t, { symbol:
|
|
51565
|
+
M2.message(t, { symbol: import_picocolors4.default.yellow(U) });
|
|
51489
51566
|
}, warning: (t) => {
|
|
51490
51567
|
M2.warn(t);
|
|
51491
51568
|
}, error: (t) => {
|
|
51492
|
-
M2.message(t, { symbol:
|
|
51569
|
+
M2.message(t, { symbol: import_picocolors4.default.red(K2) });
|
|
51493
51570
|
} };
|
|
51494
|
-
var J2 = `${
|
|
51571
|
+
var J2 = `${import_picocolors4.default.gray(o)} `;
|
|
51495
51572
|
var Y2 = ({ indicator: t = "dots" } = {}) => {
|
|
51496
51573
|
const n = V2 ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], r2 = V2 ? 80 : 120, i2 = process.env.CI === "true";
|
|
51497
51574
|
let s, c, a = false, l2 = "", $2, g2 = performance.now();
|
|
51498
51575
|
const p2 = (m2) => {
|
|
51499
51576
|
const h2 = m2 > 1 ? "Something went wrong" : "Canceled";
|
|
51500
51577
|
a && N2(h2, m2);
|
|
51501
|
-
},
|
|
51502
|
-
process.on("uncaughtExceptionMonitor",
|
|
51578
|
+
}, v2 = () => p2(2), f = () => p2(1), j2 = () => {
|
|
51579
|
+
process.on("uncaughtExceptionMonitor", v2), process.on("unhandledRejection", v2), process.on("SIGINT", f), process.on("SIGTERM", f), process.on("exit", p2);
|
|
51503
51580
|
}, E = () => {
|
|
51504
|
-
process.removeListener("uncaughtExceptionMonitor",
|
|
51581
|
+
process.removeListener("uncaughtExceptionMonitor", v2), process.removeListener("unhandledRejection", v2), process.removeListener("SIGINT", f), process.removeListener("SIGTERM", f), process.removeListener("exit", p2);
|
|
51505
51582
|
}, B2 = () => {
|
|
51506
51583
|
if ($2 === undefined)
|
|
51507
51584
|
return;
|
|
@@ -51514,14 +51591,14 @@ var Y2 = ({ indicator: t = "dots" } = {}) => {
|
|
|
51514
51591
|
const h2 = (performance.now() - m2) / 1000, w2 = Math.floor(h2 / 60), I2 = Math.floor(h2 % 60);
|
|
51515
51592
|
return w2 > 0 ? `[${w2}m ${I2}s]` : `[${I2}s]`;
|
|
51516
51593
|
}, H = (m2 = "") => {
|
|
51517
|
-
a = true, s = fD(), l2 = R2(m2), g2 = performance.now(), process.stdout.write(`${
|
|
51594
|
+
a = true, s = fD(), l2 = R2(m2), g2 = performance.now(), process.stdout.write(`${import_picocolors4.default.gray(o)}
|
|
51518
51595
|
`);
|
|
51519
51596
|
let h2 = 0, w2 = 0;
|
|
51520
51597
|
j2(), c = setInterval(() => {
|
|
51521
51598
|
if (i2 && l2 === $2)
|
|
51522
51599
|
return;
|
|
51523
51600
|
B2(), $2 = l2;
|
|
51524
|
-
const I2 =
|
|
51601
|
+
const I2 = import_picocolors4.default.magenta(n[h2]);
|
|
51525
51602
|
if (i2)
|
|
51526
51603
|
process.stdout.write(`${I2} ${l2}...`);
|
|
51527
51604
|
else if (t === "timer")
|
|
@@ -51534,7 +51611,7 @@ var Y2 = ({ indicator: t = "dots" } = {}) => {
|
|
|
51534
51611
|
}, r2);
|
|
51535
51612
|
}, N2 = (m2 = "", h2 = 0) => {
|
|
51536
51613
|
a = false, clearInterval(c), B2();
|
|
51537
|
-
const w2 = h2 === 0 ?
|
|
51614
|
+
const w2 = h2 === 0 ? import_picocolors4.default.green(C) : h2 === 1 ? import_picocolors4.default.red(L2) : import_picocolors4.default.red(W2);
|
|
51538
51615
|
l2 = R2(m2 ?? l2), t === "timer" ? process.stdout.write(`${w2} ${l2} ${O2(g2)}
|
|
51539
51616
|
`) : process.stdout.write(`${w2} ${l2}
|
|
51540
51617
|
`), E(), s();
|
|
@@ -51547,7 +51624,7 @@ var Y2 = ({ indicator: t = "dots" } = {}) => {
|
|
|
51547
51624
|
// src/cli/tui-installer.ts
|
|
51548
51625
|
init_shared();
|
|
51549
51626
|
init_config_manager();
|
|
51550
|
-
var
|
|
51627
|
+
var import_picocolors5 = __toESM(require_picocolors(), 1);
|
|
51551
51628
|
|
|
51552
51629
|
// src/cli/tui-install-prompts.ts
|
|
51553
51630
|
async function selectOrCancel(params) {
|
|
@@ -51668,7 +51745,7 @@ async function runTuiInstaller(args, version) {
|
|
|
51668
51745
|
}
|
|
51669
51746
|
const detected = detectCurrentConfig();
|
|
51670
51747
|
const isUpdate = detected.isInstalled;
|
|
51671
|
-
Ie(
|
|
51748
|
+
Ie(import_picocolors5.default.bgMagenta(import_picocolors5.default.white(isUpdate ? " oMoMoMoMo... Update " : " oMoMoMoMo... ")));
|
|
51672
51749
|
if (isUpdate) {
|
|
51673
51750
|
const initial = detectedToInitialValues(detected);
|
|
51674
51751
|
M2.info(`Existing configuration detected: Claude=${initial.claude}, Gemini=${initial.gemini}`);
|
|
@@ -51678,11 +51755,11 @@ async function runTuiInstaller(args, version) {
|
|
|
51678
51755
|
const installed = await isOpenCodeInstalled();
|
|
51679
51756
|
const openCodeVersion = await getOpenCodeVersion();
|
|
51680
51757
|
if (!installed) {
|
|
51681
|
-
spinner.stop(`OpenCode binary not found ${
|
|
51758
|
+
spinner.stop(`OpenCode binary not found ${import_picocolors5.default.yellow("[!]")}`);
|
|
51682
51759
|
M2.warn("OpenCode binary not found. Plugin will be configured, but you'll need to install OpenCode to use it.");
|
|
51683
51760
|
Me("Visit https://opencode.ai/docs for installation instructions", "Installation Guide");
|
|
51684
51761
|
} else {
|
|
51685
|
-
spinner.stop(`OpenCode ${openCodeVersion ?? "installed"} ${
|
|
51762
|
+
spinner.stop(`OpenCode ${openCodeVersion ?? "installed"} ${import_picocolors5.default.green("[OK]")}`);
|
|
51686
51763
|
}
|
|
51687
51764
|
const config = await promptInstallConfig(detected);
|
|
51688
51765
|
if (!config)
|
|
@@ -51691,55 +51768,55 @@ async function runTuiInstaller(args, version) {
|
|
|
51691
51768
|
const pluginResult = await addPluginToOpenCodeConfig(version);
|
|
51692
51769
|
if (!pluginResult.success) {
|
|
51693
51770
|
spinner.stop(`Failed to add plugin: ${pluginResult.error}`);
|
|
51694
|
-
Se(
|
|
51771
|
+
Se(import_picocolors5.default.red("Installation failed."));
|
|
51695
51772
|
return 1;
|
|
51696
51773
|
}
|
|
51697
|
-
spinner.stop(`Plugin added to ${
|
|
51774
|
+
spinner.stop(`Plugin added to ${import_picocolors5.default.cyan(pluginResult.configPath)}`);
|
|
51698
51775
|
spinner.start(`Writing ${PLUGIN_NAME} configuration`);
|
|
51699
51776
|
const omoResult = writeOmoConfig(config);
|
|
51700
51777
|
if (!omoResult.success) {
|
|
51701
51778
|
spinner.stop(`Failed to write config: ${omoResult.error}`);
|
|
51702
|
-
Se(
|
|
51779
|
+
Se(import_picocolors5.default.red("Installation failed."));
|
|
51703
51780
|
return 1;
|
|
51704
51781
|
}
|
|
51705
|
-
spinner.stop(`Config written to ${
|
|
51782
|
+
spinner.stop(`Config written to ${import_picocolors5.default.cyan(omoResult.configPath)}`);
|
|
51706
51783
|
if (!config.hasClaude) {
|
|
51707
51784
|
console.log();
|
|
51708
|
-
console.log(
|
|
51785
|
+
console.log(import_picocolors5.default.bgRed(import_picocolors5.default.white(import_picocolors5.default.bold(" CRITICAL WARNING "))));
|
|
51709
51786
|
console.log();
|
|
51710
|
-
console.log(
|
|
51711
|
-
console.log(
|
|
51712
|
-
console.log(
|
|
51713
|
-
console.log(
|
|
51714
|
-
console.log(
|
|
51787
|
+
console.log(import_picocolors5.default.red(import_picocolors5.default.bold(" Sisyphus agent is STRONGLY optimized for Claude Opus 4.5.")));
|
|
51788
|
+
console.log(import_picocolors5.default.red(" Without Claude, you may experience significantly degraded performance:"));
|
|
51789
|
+
console.log(import_picocolors5.default.dim(" \u2022 Reduced orchestration quality"));
|
|
51790
|
+
console.log(import_picocolors5.default.dim(" \u2022 Weaker tool selection and delegation"));
|
|
51791
|
+
console.log(import_picocolors5.default.dim(" \u2022 Less reliable task completion"));
|
|
51715
51792
|
console.log();
|
|
51716
|
-
console.log(
|
|
51793
|
+
console.log(import_picocolors5.default.yellow(" Consider subscribing to Claude Pro/Max for the best experience."));
|
|
51717
51794
|
console.log();
|
|
51718
51795
|
}
|
|
51719
51796
|
if (!config.hasClaude && !config.hasOpenAI && !config.hasGemini && !config.hasCopilot && !config.hasOpencodeZen) {
|
|
51720
51797
|
M2.warn("No model providers configured. Using opencode/big-pickle as fallback.");
|
|
51721
51798
|
}
|
|
51722
51799
|
Me(formatConfigSummary(config), isUpdate ? "Updated Configuration" : "Installation Complete");
|
|
51723
|
-
M2.success(
|
|
51724
|
-
M2.message(`Run ${
|
|
51725
|
-
Me(`Include ${
|
|
51800
|
+
M2.success(import_picocolors5.default.bold(isUpdate ? "Configuration updated!" : "Installation complete!"));
|
|
51801
|
+
M2.message(`Run ${import_picocolors5.default.cyan("opencode")} to start!`);
|
|
51802
|
+
Me(`Include ${import_picocolors5.default.cyan("ultrawork")} (or ${import_picocolors5.default.cyan("ulw")}) in your prompt.
|
|
51726
51803
|
` + `All features work like magic-parallel agents, background tasks,
|
|
51727
51804
|
` + `deep exploration, and relentless execution until completion.`, "The Magic Word");
|
|
51728
|
-
M2.message(`${
|
|
51729
|
-
M2.message(` ${
|
|
51730
|
-
Se(
|
|
51805
|
+
M2.message(`${import_picocolors5.default.yellow("\u2605")} If you found this helpful, consider starring the repo!`);
|
|
51806
|
+
M2.message(` ${import_picocolors5.default.dim("gh api --silent --method PUT /user/starred/caravanglory/oh-my-magento >/dev/null 2>&1 || true")}`);
|
|
51807
|
+
Se(import_picocolors5.default.green("oMoMoMoMo... Enjoy!"));
|
|
51731
51808
|
if ((config.hasClaude || config.hasGemini || config.hasCopilot) && !args.skipAuth) {
|
|
51732
51809
|
const providers = [];
|
|
51733
51810
|
if (config.hasClaude)
|
|
51734
|
-
providers.push(`Anthropic ${
|
|
51811
|
+
providers.push(`Anthropic ${import_picocolors5.default.gray("\u2192 Claude Pro/Max")}`);
|
|
51735
51812
|
if (config.hasGemini)
|
|
51736
|
-
providers.push(`Google ${
|
|
51813
|
+
providers.push(`Google ${import_picocolors5.default.gray("\u2192 Gemini")}`);
|
|
51737
51814
|
if (config.hasCopilot)
|
|
51738
|
-
providers.push(`GitHub ${
|
|
51815
|
+
providers.push(`GitHub ${import_picocolors5.default.gray("\u2192 Copilot")}`);
|
|
51739
51816
|
console.log();
|
|
51740
|
-
console.log(
|
|
51817
|
+
console.log(import_picocolors5.default.bold("Authenticate Your Providers"));
|
|
51741
51818
|
console.log();
|
|
51742
|
-
console.log(` Run ${
|
|
51819
|
+
console.log(` Run ${import_picocolors5.default.cyan("opencode auth login")} and select:`);
|
|
51743
51820
|
for (const provider of providers) {
|
|
51744
51821
|
console.log(` ${SYMBOLS.bullet} ${provider}`);
|
|
51745
51822
|
}
|
|
@@ -51755,7 +51832,7 @@ async function install(args) {
|
|
|
51755
51832
|
}
|
|
51756
51833
|
|
|
51757
51834
|
// src/cli/run/runner.ts
|
|
51758
|
-
var
|
|
51835
|
+
var import_picocolors15 = __toESM(require_picocolors(), 1);
|
|
51759
51836
|
|
|
51760
51837
|
// src/cli/run/event-state.ts
|
|
51761
51838
|
function createEventState() {
|
|
@@ -51789,7 +51866,7 @@ function createEventState() {
|
|
|
51789
51866
|
};
|
|
51790
51867
|
}
|
|
51791
51868
|
// src/cli/run/event-formatting.ts
|
|
51792
|
-
var
|
|
51869
|
+
var import_picocolors6 = __toESM(require_picocolors(), 1);
|
|
51793
51870
|
function serializeError(error) {
|
|
51794
51871
|
if (!error)
|
|
51795
51872
|
return "Unknown error";
|
|
@@ -51833,10 +51910,10 @@ function getSessionTag(ctx, payload) {
|
|
|
51833
51910
|
const sessionID = props?.sessionID ?? props?.sessionId ?? info?.sessionID ?? info?.sessionId ?? part?.sessionID ?? part?.sessionId;
|
|
51834
51911
|
const isMainSession = sessionID === ctx.sessionID;
|
|
51835
51912
|
if (isMainSession)
|
|
51836
|
-
return
|
|
51913
|
+
return import_picocolors6.default.green("[MAIN]");
|
|
51837
51914
|
if (sessionID)
|
|
51838
|
-
return
|
|
51839
|
-
return
|
|
51915
|
+
return import_picocolors6.default.yellow(`[${String(sessionID).slice(0, 8)}]`);
|
|
51916
|
+
return import_picocolors6.default.dim("[system]");
|
|
51840
51917
|
}
|
|
51841
51918
|
function logEventVerbose(ctx, payload) {
|
|
51842
51919
|
const sessionTag = getSessionTag(ctx, payload);
|
|
@@ -51845,7 +51922,7 @@ function logEventVerbose(ctx, payload) {
|
|
|
51845
51922
|
case "session.idle":
|
|
51846
51923
|
case "session.status": {
|
|
51847
51924
|
const status = props?.status?.type ?? "idle";
|
|
51848
|
-
console.error(
|
|
51925
|
+
console.error(import_picocolors6.default.dim(`${sessionTag} ${payload.type}: ${status}`));
|
|
51849
51926
|
break;
|
|
51850
51927
|
}
|
|
51851
51928
|
case "message.part.updated": {
|
|
@@ -51853,10 +51930,10 @@ function logEventVerbose(ctx, payload) {
|
|
|
51853
51930
|
const part = partProps?.part;
|
|
51854
51931
|
if (part?.type === "tool") {
|
|
51855
51932
|
const status = part.state?.status ?? "unknown";
|
|
51856
|
-
console.error(
|
|
51933
|
+
console.error(import_picocolors6.default.dim(`${sessionTag} message.part (tool): ${part.tool ?? part.name ?? "?"} [${status}]`));
|
|
51857
51934
|
} else if (part?.type === "text" && part.text) {
|
|
51858
51935
|
const preview = part.text.slice(0, 80).replace(/\n/g, "\\n");
|
|
51859
|
-
console.error(
|
|
51936
|
+
console.error(import_picocolors6.default.dim(`${sessionTag} message.part (text): "${preview}${part.text.length > 80 ? "..." : ""}"`));
|
|
51860
51937
|
}
|
|
51861
51938
|
break;
|
|
51862
51939
|
}
|
|
@@ -51865,7 +51942,7 @@ function logEventVerbose(ctx, payload) {
|
|
|
51865
51942
|
const field = deltaProps?.field ?? "unknown";
|
|
51866
51943
|
const delta = deltaProps?.delta ?? "";
|
|
51867
51944
|
const preview = delta.slice(0, 80).replace(/\n/g, "\\n");
|
|
51868
|
-
console.error(
|
|
51945
|
+
console.error(import_picocolors6.default.dim(`${sessionTag} message.part.delta (${field}): "${preview}${delta.length > 80 ? "..." : ""}"`));
|
|
51869
51946
|
break;
|
|
51870
51947
|
}
|
|
51871
51948
|
case "message.updated": {
|
|
@@ -51874,7 +51951,7 @@ function logEventVerbose(ctx, payload) {
|
|
|
51874
51951
|
const model = msgProps?.info?.modelID;
|
|
51875
51952
|
const agent = msgProps?.info?.agent;
|
|
51876
51953
|
const details = [role, agent, model].filter(Boolean).join(", ");
|
|
51877
|
-
console.error(
|
|
51954
|
+
console.error(import_picocolors6.default.dim(`${sessionTag} message.updated (${details})`));
|
|
51878
51955
|
break;
|
|
51879
51956
|
}
|
|
51880
51957
|
case "tool.execute": {
|
|
@@ -51892,32 +51969,32 @@ function logEventVerbose(ctx, payload) {
|
|
|
51892
51969
|
}
|
|
51893
51970
|
}
|
|
51894
51971
|
const inputPreview = inputStr.slice(0, 150);
|
|
51895
|
-
console.error(
|
|
51896
|
-
console.error(
|
|
51972
|
+
console.error(import_picocolors6.default.cyan(`${sessionTag} TOOL.EXECUTE: ${import_picocolors6.default.bold(toolName)}`));
|
|
51973
|
+
console.error(import_picocolors6.default.dim(` input: ${inputPreview}${inputStr.length >= 150 ? "..." : ""}`));
|
|
51897
51974
|
break;
|
|
51898
51975
|
}
|
|
51899
51976
|
case "tool.result": {
|
|
51900
51977
|
const resultProps = props;
|
|
51901
51978
|
const output = resultProps?.output ?? "";
|
|
51902
51979
|
const preview = output.slice(0, 200).replace(/\n/g, "\\n");
|
|
51903
|
-
console.error(
|
|
51980
|
+
console.error(import_picocolors6.default.green(`${sessionTag} TOOL.RESULT: "${preview}${output.length > 200 ? "..." : ""}"`));
|
|
51904
51981
|
break;
|
|
51905
51982
|
}
|
|
51906
51983
|
case "session.error": {
|
|
51907
51984
|
const errorProps = props;
|
|
51908
51985
|
const errorMsg = serializeError(errorProps?.error);
|
|
51909
|
-
console.error(
|
|
51986
|
+
console.error(import_picocolors6.default.red(`${sessionTag} SESSION.ERROR: ${errorMsg}`));
|
|
51910
51987
|
break;
|
|
51911
51988
|
}
|
|
51912
51989
|
default:
|
|
51913
|
-
console.error(
|
|
51990
|
+
console.error(import_picocolors6.default.dim(`${sessionTag} ${payload.type}`));
|
|
51914
51991
|
}
|
|
51915
51992
|
}
|
|
51916
51993
|
// src/cli/run/event-stream-processor.ts
|
|
51917
|
-
var
|
|
51994
|
+
var import_picocolors9 = __toESM(require_picocolors(), 1);
|
|
51918
51995
|
|
|
51919
51996
|
// src/cli/run/event-handlers.ts
|
|
51920
|
-
var
|
|
51997
|
+
var import_picocolors8 = __toESM(require_picocolors(), 1);
|
|
51921
51998
|
|
|
51922
51999
|
// src/cli/run/tool-input-preview.ts
|
|
51923
52000
|
function formatToolHeader(toolName, input) {
|
|
@@ -52053,14 +52130,14 @@ var displayChars = {
|
|
|
52053
52130
|
};
|
|
52054
52131
|
|
|
52055
52132
|
// src/cli/run/output-renderer.ts
|
|
52056
|
-
var
|
|
52133
|
+
var import_picocolors7 = __toESM(require_picocolors(), 1);
|
|
52057
52134
|
function renderAgentHeader(agent, model, variant, agentColorsByName) {
|
|
52058
52135
|
if (!agent && !model)
|
|
52059
52136
|
return;
|
|
52060
|
-
const agentLabel = agent ?
|
|
52137
|
+
const agentLabel = agent ? import_picocolors7.default.bold(colorizeWithProfileColor(agent, agentColorsByName[agent])) : "";
|
|
52061
52138
|
const modelBase = model ?? "";
|
|
52062
52139
|
const variantSuffix = variant ? ` (${variant})` : "";
|
|
52063
|
-
const modelLabel = model ?
|
|
52140
|
+
const modelLabel = model ? import_picocolors7.default.dim(`${modelBase}${variantSuffix}`) : "";
|
|
52064
52141
|
process.stdout.write(`
|
|
52065
52142
|
`);
|
|
52066
52143
|
if (modelLabel) {
|
|
@@ -52068,7 +52145,7 @@ function renderAgentHeader(agent, model, variant, agentColorsByName) {
|
|
|
52068
52145
|
`);
|
|
52069
52146
|
}
|
|
52070
52147
|
if (agentLabel) {
|
|
52071
|
-
process.stdout.write(` ${
|
|
52148
|
+
process.stdout.write(` ${import_picocolors7.default.dim("\u2514\u2500")} ${agentLabel}
|
|
52072
52149
|
`);
|
|
52073
52150
|
}
|
|
52074
52151
|
process.stdout.write(`
|
|
@@ -52076,7 +52153,7 @@ function renderAgentHeader(agent, model, variant, agentColorsByName) {
|
|
|
52076
52153
|
}
|
|
52077
52154
|
function openThinkBlock() {
|
|
52078
52155
|
process.stdout.write(`
|
|
52079
|
-
${
|
|
52156
|
+
${import_picocolors7.default.dim("\u2503 Thinking:")} `);
|
|
52080
52157
|
}
|
|
52081
52158
|
function closeThinkBlock() {
|
|
52082
52159
|
process.stdout.write(`
|
|
@@ -52110,10 +52187,10 @@ function writePaddedText(text, atLineStart) {
|
|
|
52110
52187
|
}
|
|
52111
52188
|
function colorizeWithProfileColor(text, hexColor) {
|
|
52112
52189
|
if (!hexColor)
|
|
52113
|
-
return
|
|
52190
|
+
return import_picocolors7.default.magenta(text);
|
|
52114
52191
|
const rgb = parseHexColor(hexColor);
|
|
52115
52192
|
if (!rgb)
|
|
52116
|
-
return
|
|
52193
|
+
return import_picocolors7.default.magenta(text);
|
|
52117
52194
|
const [r2, g2, b3] = rgb;
|
|
52118
52195
|
return `\x1B[38;2;${r2};${g2};${b3}m${text}\x1B[39m`;
|
|
52119
52196
|
}
|
|
@@ -52153,7 +52230,7 @@ function renderCompletionMetaLine(state, messageID) {
|
|
|
52153
52230
|
const agent = state.currentAgent ?? "assistant";
|
|
52154
52231
|
const model = state.currentModel ?? "unknown-model";
|
|
52155
52232
|
const variant = state.currentVariant ? ` (${state.currentVariant})` : "";
|
|
52156
|
-
process.stdout.write(
|
|
52233
|
+
process.stdout.write(import_picocolors8.default.dim(`
|
|
52157
52234
|
${displayChars.treeEnd} ${agent} \xB7 ${model}${variant} \xB7 ${elapsedSec}s
|
|
52158
52235
|
`));
|
|
52159
52236
|
state.completionMetaPrintedByMessageId[messageID] = true;
|
|
@@ -52187,7 +52264,7 @@ function handleSessionError(ctx, payload, state) {
|
|
|
52187
52264
|
if (getSessionId(props) === ctx.sessionID) {
|
|
52188
52265
|
state.mainSessionError = true;
|
|
52189
52266
|
state.lastError = serializeError(props?.error);
|
|
52190
|
-
console.error(
|
|
52267
|
+
console.error(import_picocolors8.default.red(`
|
|
52191
52268
|
[session.error] ${state.lastError}`));
|
|
52192
52269
|
}
|
|
52193
52270
|
}
|
|
@@ -52215,7 +52292,7 @@ function handleMessagePartUpdated(ctx, payload, state) {
|
|
|
52215
52292
|
const newText = reasoningText.slice(state.lastReasoningText.length);
|
|
52216
52293
|
if (newText) {
|
|
52217
52294
|
const padded = writePaddedText(newText, state.thinkingAtLineStart);
|
|
52218
|
-
process.stdout.write(
|
|
52295
|
+
process.stdout.write(import_picocolors8.default.dim(padded.output));
|
|
52219
52296
|
state.thinkingAtLineStart = padded.atLineStart;
|
|
52220
52297
|
state.hasReceivedMeaningfulWork = true;
|
|
52221
52298
|
}
|
|
@@ -52262,7 +52339,7 @@ function handleMessagePartDelta(ctx, payload, state) {
|
|
|
52262
52339
|
if (partType === "reasoning") {
|
|
52263
52340
|
ensureThinkBlockOpen(state);
|
|
52264
52341
|
const padded2 = writePaddedText(delta, state.thinkingAtLineStart);
|
|
52265
|
-
process.stdout.write(
|
|
52342
|
+
process.stdout.write(import_picocolors8.default.dim(padded2.output));
|
|
52266
52343
|
state.thinkingAtLineStart = padded2.atLineStart;
|
|
52267
52344
|
state.lastReasoningText += delta;
|
|
52268
52345
|
state.hasReceivedMeaningfulWork = true;
|
|
@@ -52283,10 +52360,10 @@ function handleToolPart(_ctx, part, state) {
|
|
|
52283
52360
|
return;
|
|
52284
52361
|
state.currentTool = toolName;
|
|
52285
52362
|
const header = formatToolHeader(toolName, part.state?.input ?? {});
|
|
52286
|
-
const suffix = header.description ? ` ${
|
|
52363
|
+
const suffix = header.description ? ` ${import_picocolors8.default.dim(header.description)}` : "";
|
|
52287
52364
|
state.hasReceivedMeaningfulWork = true;
|
|
52288
52365
|
process.stdout.write(`
|
|
52289
|
-
${
|
|
52366
|
+
${import_picocolors8.default.cyan(header.icon)} ${import_picocolors8.default.bold(header.title)}${suffix}
|
|
52290
52367
|
`);
|
|
52291
52368
|
}
|
|
52292
52369
|
if (status === "completed" || status === "error") {
|
|
@@ -52294,10 +52371,10 @@ function handleToolPart(_ctx, part, state) {
|
|
|
52294
52371
|
return;
|
|
52295
52372
|
const output = part.state?.output || "";
|
|
52296
52373
|
if (output.trim()) {
|
|
52297
|
-
process.stdout.write(
|
|
52374
|
+
process.stdout.write(import_picocolors8.default.dim(` ${displayChars.treeEnd} output
|
|
52298
52375
|
`));
|
|
52299
52376
|
const padded = writePaddedText(output, true);
|
|
52300
|
-
process.stdout.write(
|
|
52377
|
+
process.stdout.write(import_picocolors8.default.dim(padded.output + (padded.atLineStart ? "" : " ")));
|
|
52301
52378
|
process.stdout.write(`
|
|
52302
52379
|
`);
|
|
52303
52380
|
}
|
|
@@ -52359,10 +52436,10 @@ function handleToolExecute(ctx, payload, state) {
|
|
|
52359
52436
|
const toolName = props?.name || "unknown";
|
|
52360
52437
|
state.currentTool = toolName;
|
|
52361
52438
|
const header = formatToolHeader(toolName, props?.input ?? {});
|
|
52362
|
-
const suffix = header.description ? ` ${
|
|
52439
|
+
const suffix = header.description ? ` ${import_picocolors8.default.dim(header.description)}` : "";
|
|
52363
52440
|
state.hasReceivedMeaningfulWork = true;
|
|
52364
52441
|
process.stdout.write(`
|
|
52365
|
-
${
|
|
52442
|
+
${import_picocolors8.default.cyan(header.icon)} ${import_picocolors8.default.bold(header.title)}${suffix}
|
|
52366
52443
|
`);
|
|
52367
52444
|
}
|
|
52368
52445
|
function handleToolResult(ctx, payload, state) {
|
|
@@ -52376,10 +52453,10 @@ function handleToolResult(ctx, payload, state) {
|
|
|
52376
52453
|
return;
|
|
52377
52454
|
const output = props?.output || "";
|
|
52378
52455
|
if (output.trim()) {
|
|
52379
|
-
process.stdout.write(
|
|
52456
|
+
process.stdout.write(import_picocolors8.default.dim(` ${displayChars.treeEnd} output
|
|
52380
52457
|
`));
|
|
52381
52458
|
const padded = writePaddedText(output, true);
|
|
52382
|
-
process.stdout.write(
|
|
52459
|
+
process.stdout.write(import_picocolors8.default.dim(padded.output + (padded.atLineStart ? "" : " ")));
|
|
52383
52460
|
process.stdout.write(`
|
|
52384
52461
|
`);
|
|
52385
52462
|
}
|
|
@@ -52428,7 +52505,7 @@ async function processEvents(ctx, stream, state) {
|
|
|
52428
52505
|
const payload = event;
|
|
52429
52506
|
if (!payload?.type) {
|
|
52430
52507
|
if (ctx.verbose) {
|
|
52431
|
-
console.error(
|
|
52508
|
+
console.error(import_picocolors9.default.dim(`[event] no type: ${JSON.stringify(event)}`));
|
|
52432
52509
|
}
|
|
52433
52510
|
continue;
|
|
52434
52511
|
}
|
|
@@ -52446,7 +52523,7 @@ async function processEvents(ctx, stream, state) {
|
|
|
52446
52523
|
handleToolResult(ctx, payload, state);
|
|
52447
52524
|
handleTuiToast(ctx, payload, state);
|
|
52448
52525
|
} catch (err) {
|
|
52449
|
-
console.error(
|
|
52526
|
+
console.error(import_picocolors9.default.red(`[event error] ${err}`));
|
|
52450
52527
|
}
|
|
52451
52528
|
}
|
|
52452
52529
|
}
|
|
@@ -53127,8 +53204,8 @@ function assertNever(_x) {
|
|
|
53127
53204
|
}
|
|
53128
53205
|
function assert(_3) {}
|
|
53129
53206
|
function getEnumValues(entries) {
|
|
53130
|
-
const numericValues = Object.values(entries).filter((
|
|
53131
|
-
const values = Object.entries(entries).filter(([k3, _3]) => numericValues.indexOf(+k3) === -1).map(([_3,
|
|
53207
|
+
const numericValues = Object.values(entries).filter((v2) => typeof v2 === "number");
|
|
53208
|
+
const values = Object.entries(entries).filter(([k3, _3]) => numericValues.indexOf(+k3) === -1).map(([_3, v2]) => v2);
|
|
53132
53209
|
return values;
|
|
53133
53210
|
}
|
|
53134
53211
|
function joinValues(array, separator = "|") {
|
|
@@ -53189,9 +53266,9 @@ function defineLazy(object, key, getter) {
|
|
|
53189
53266
|
}
|
|
53190
53267
|
return value;
|
|
53191
53268
|
},
|
|
53192
|
-
set(
|
|
53269
|
+
set(v2) {
|
|
53193
53270
|
Object.defineProperty(object, key, {
|
|
53194
|
-
value:
|
|
53271
|
+
value: v2
|
|
53195
53272
|
});
|
|
53196
53273
|
},
|
|
53197
53274
|
configurable: true
|
|
@@ -54845,10 +54922,10 @@ var $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
|
|
|
54845
54922
|
v7: 7,
|
|
54846
54923
|
v8: 8
|
|
54847
54924
|
};
|
|
54848
|
-
const
|
|
54849
|
-
if (
|
|
54925
|
+
const v2 = versionMap[def.version];
|
|
54926
|
+
if (v2 === undefined)
|
|
54850
54927
|
throw new Error(`Invalid UUID version: "${def.version}"`);
|
|
54851
|
-
def.pattern ?? (def.pattern = uuid(
|
|
54928
|
+
def.pattern ?? (def.pattern = uuid(v2));
|
|
54852
54929
|
} else
|
|
54853
54930
|
def.pattern ?? (def.pattern = uuid());
|
|
54854
54931
|
$ZodStringFormat.init(inst, def);
|
|
@@ -55421,8 +55498,8 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
55421
55498
|
const field = shape[key]._zod;
|
|
55422
55499
|
if (field.values) {
|
|
55423
55500
|
propValues[key] ?? (propValues[key] = new Set);
|
|
55424
|
-
for (const
|
|
55425
|
-
propValues[key].add(
|
|
55501
|
+
for (const v2 of field.values)
|
|
55502
|
+
propValues[key].add(v2);
|
|
55426
55503
|
}
|
|
55427
55504
|
}
|
|
55428
55505
|
return propValues;
|
|
@@ -55690,10 +55767,10 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
55690
55767
|
const pv = option._zod.propValues;
|
|
55691
55768
|
if (!pv || Object.keys(pv).length === 0)
|
|
55692
55769
|
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
55693
|
-
for (const [k3,
|
|
55770
|
+
for (const [k3, v2] of Object.entries(pv)) {
|
|
55694
55771
|
if (!propValues[k3])
|
|
55695
55772
|
propValues[k3] = new Set;
|
|
55696
|
-
for (const val of
|
|
55773
|
+
for (const val of v2) {
|
|
55697
55774
|
propValues[k3].add(val);
|
|
55698
55775
|
}
|
|
55699
55776
|
}
|
|
@@ -55707,11 +55784,11 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
55707
55784
|
const values = o2._zod.propValues?.[def.discriminator];
|
|
55708
55785
|
if (!values || values.size === 0)
|
|
55709
55786
|
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o2)}"`);
|
|
55710
|
-
for (const
|
|
55711
|
-
if (map2.has(
|
|
55712
|
-
throw new Error(`Duplicate discriminator value "${String(
|
|
55787
|
+
for (const v2 of values) {
|
|
55788
|
+
if (map2.has(v2)) {
|
|
55789
|
+
throw new Error(`Duplicate discriminator value "${String(v2)}"`);
|
|
55713
55790
|
}
|
|
55714
|
-
map2.set(
|
|
55791
|
+
map2.set(v2, o2);
|
|
55715
55792
|
}
|
|
55716
55793
|
}
|
|
55717
55794
|
return map2;
|
|
@@ -56295,8 +56372,8 @@ var $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
|
|
|
56295
56372
|
var $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
|
|
56296
56373
|
$ZodType.init(inst, def);
|
|
56297
56374
|
defineLazy(inst._zod, "values", () => {
|
|
56298
|
-
const
|
|
56299
|
-
return
|
|
56375
|
+
const v2 = def.innerType._zod.values;
|
|
56376
|
+
return v2 ? new Set([...v2].filter((x2) => x2 !== undefined)) : undefined;
|
|
56300
56377
|
});
|
|
56301
56378
|
inst._zod.parse = (payload, ctx) => {
|
|
56302
56379
|
const result = def.innerType._zod.run(payload, ctx);
|
|
@@ -58526,7 +58603,7 @@ var error16 = () => {
|
|
|
58526
58603
|
if (issue2.values.length === 1) {
|
|
58527
58604
|
return `\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${stringifyPrimitive(issue2.values[0])}`;
|
|
58528
58605
|
}
|
|
58529
|
-
const stringified = issue2.values.map((
|
|
58606
|
+
const stringified = issue2.values.map((v2) => stringifyPrimitive(v2));
|
|
58530
58607
|
if (issue2.values.length === 2) {
|
|
58531
58608
|
return `\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${stringified[0]} \u05D0\u05D5 ${stringified[1]}`;
|
|
58532
58609
|
}
|
|
@@ -62912,7 +62989,7 @@ function _set(Class2, valueType, params) {
|
|
|
62912
62989
|
});
|
|
62913
62990
|
}
|
|
62914
62991
|
function _enum(Class2, values, params) {
|
|
62915
|
-
const entries = Array.isArray(values) ? Object.fromEntries(values.map((
|
|
62992
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
|
|
62916
62993
|
return new Class2({
|
|
62917
62994
|
type: "enum",
|
|
62918
62995
|
entries,
|
|
@@ -63093,8 +63170,8 @@ function _stringbool(Classes, _params) {
|
|
|
63093
63170
|
let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
|
|
63094
63171
|
let falsyArray = params.falsy ?? ["false", "0", "no", "off", "n", "disabled"];
|
|
63095
63172
|
if (params.case !== "sensitive") {
|
|
63096
|
-
truthyArray = truthyArray.map((
|
|
63097
|
-
falsyArray = falsyArray.map((
|
|
63173
|
+
truthyArray = truthyArray.map((v2) => typeof v2 === "string" ? v2.toLowerCase() : v2);
|
|
63174
|
+
falsyArray = falsyArray.map((v2) => typeof v2 === "string" ? v2.toLowerCase() : v2);
|
|
63098
63175
|
}
|
|
63099
63176
|
const truthySet = new Set(truthyArray);
|
|
63100
63177
|
const falsySet = new Set(falsyArray);
|
|
@@ -63628,9 +63705,9 @@ var dateProcessor = (_schema, ctx, _json, _params) => {
|
|
|
63628
63705
|
var enumProcessor = (schema2, _ctx, json2, _params) => {
|
|
63629
63706
|
const def = schema2._zod.def;
|
|
63630
63707
|
const values = getEnumValues(def.entries);
|
|
63631
|
-
if (values.every((
|
|
63708
|
+
if (values.every((v2) => typeof v2 === "number"))
|
|
63632
63709
|
json2.type = "number";
|
|
63633
|
-
if (values.every((
|
|
63710
|
+
if (values.every((v2) => typeof v2 === "string"))
|
|
63634
63711
|
json2.type = "string";
|
|
63635
63712
|
json2.enum = values;
|
|
63636
63713
|
};
|
|
@@ -63661,13 +63738,13 @@ var literalProcessor = (schema2, ctx, json2, _params) => {
|
|
|
63661
63738
|
json2.const = val;
|
|
63662
63739
|
}
|
|
63663
63740
|
} else {
|
|
63664
|
-
if (vals.every((
|
|
63741
|
+
if (vals.every((v2) => typeof v2 === "number"))
|
|
63665
63742
|
json2.type = "number";
|
|
63666
|
-
if (vals.every((
|
|
63743
|
+
if (vals.every((v2) => typeof v2 === "string"))
|
|
63667
63744
|
json2.type = "string";
|
|
63668
|
-
if (vals.every((
|
|
63745
|
+
if (vals.every((v2) => typeof v2 === "boolean"))
|
|
63669
63746
|
json2.type = "boolean";
|
|
63670
|
-
if (vals.every((
|
|
63747
|
+
if (vals.every((v2) => v2 === null))
|
|
63671
63748
|
json2.type = "null";
|
|
63672
63749
|
json2.enum = vals;
|
|
63673
63750
|
}
|
|
@@ -63762,11 +63839,11 @@ var objectProcessor = (schema2, ctx, _json, params) => {
|
|
|
63762
63839
|
}
|
|
63763
63840
|
const allKeys = new Set(Object.keys(shape));
|
|
63764
63841
|
const requiredKeys = new Set([...allKeys].filter((key) => {
|
|
63765
|
-
const
|
|
63842
|
+
const v2 = def.shape[key]._zod;
|
|
63766
63843
|
if (ctx.io === "input") {
|
|
63767
|
-
return
|
|
63844
|
+
return v2.optin === undefined;
|
|
63768
63845
|
} else {
|
|
63769
|
-
return
|
|
63846
|
+
return v2.optout === undefined;
|
|
63770
63847
|
}
|
|
63771
63848
|
}));
|
|
63772
63849
|
if (requiredKeys.size > 0) {
|
|
@@ -63886,7 +63963,7 @@ var recordProcessor = (schema2, ctx, _json, params) => {
|
|
|
63886
63963
|
}
|
|
63887
63964
|
const keyValues = keyType._zod.values;
|
|
63888
63965
|
if (keyValues) {
|
|
63889
|
-
const validKeyValues = [...keyValues].filter((
|
|
63966
|
+
const validKeyValues = [...keyValues].filter((v2) => typeof v2 === "string" || typeof v2 === "number");
|
|
63890
63967
|
if (validKeyValues.length > 0) {
|
|
63891
63968
|
json2.required = validKeyValues;
|
|
63892
63969
|
}
|
|
@@ -65127,7 +65204,7 @@ var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
|
65127
65204
|
};
|
|
65128
65205
|
});
|
|
65129
65206
|
function _enum2(values, params) {
|
|
65130
|
-
const entries = Array.isArray(values) ? Object.fromEntries(values.map((
|
|
65207
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
|
|
65131
65208
|
return new ZodEnum({
|
|
65132
65209
|
type: "enum",
|
|
65133
65210
|
entries,
|
|
@@ -65644,10 +65721,10 @@ function convertBaseSchema(schema2, ctx) {
|
|
|
65644
65721
|
if (enumValues.length === 1) {
|
|
65645
65722
|
return z2.literal(enumValues[0]);
|
|
65646
65723
|
}
|
|
65647
|
-
if (enumValues.every((
|
|
65724
|
+
if (enumValues.every((v2) => typeof v2 === "string")) {
|
|
65648
65725
|
return z2.enum(enumValues);
|
|
65649
65726
|
}
|
|
65650
|
-
const literalSchemas = enumValues.map((
|
|
65727
|
+
const literalSchemas = enumValues.map((v2) => z2.literal(v2));
|
|
65651
65728
|
if (literalSchemas.length < 2) {
|
|
65652
65729
|
return literalSchemas[0];
|
|
65653
65730
|
}
|
|
@@ -66943,7 +67020,7 @@ var separatorObjectExplode = (style) => {
|
|
|
66943
67020
|
};
|
|
66944
67021
|
var serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
|
|
66945
67022
|
if (!explode) {
|
|
66946
|
-
const joinedValues2 = (allowReserved ? value : value.map((
|
|
67023
|
+
const joinedValues2 = (allowReserved ? value : value.map((v2) => encodeURIComponent(v2))).join(separatorArrayNoExplode(style));
|
|
66947
67024
|
switch (style) {
|
|
66948
67025
|
case "label":
|
|
66949
67026
|
return `.${joinedValues2}`;
|
|
@@ -66956,14 +67033,14 @@ var serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
|
|
|
66956
67033
|
}
|
|
66957
67034
|
}
|
|
66958
67035
|
const separator = separatorArrayExplode(style);
|
|
66959
|
-
const joinedValues = value.map((
|
|
67036
|
+
const joinedValues = value.map((v2) => {
|
|
66960
67037
|
if (style === "label" || style === "simple") {
|
|
66961
|
-
return allowReserved ?
|
|
67038
|
+
return allowReserved ? v2 : encodeURIComponent(v2);
|
|
66962
67039
|
}
|
|
66963
67040
|
return serializePrimitiveParam({
|
|
66964
67041
|
allowReserved,
|
|
66965
67042
|
name,
|
|
66966
|
-
value:
|
|
67043
|
+
value: v2
|
|
66967
67044
|
});
|
|
66968
67045
|
}).join(separator);
|
|
66969
67046
|
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
@@ -66983,8 +67060,8 @@ var serializeObjectParam = ({ allowReserved, explode, name, style, value, valueO
|
|
|
66983
67060
|
}
|
|
66984
67061
|
if (style !== "deepObject" && !explode) {
|
|
66985
67062
|
let values = [];
|
|
66986
|
-
Object.entries(value).forEach(([key,
|
|
66987
|
-
values = [...values, key, allowReserved ?
|
|
67063
|
+
Object.entries(value).forEach(([key, v2]) => {
|
|
67064
|
+
values = [...values, key, allowReserved ? v2 : encodeURIComponent(v2)];
|
|
66988
67065
|
});
|
|
66989
67066
|
const joinedValues2 = values.join(",");
|
|
66990
67067
|
switch (style) {
|
|
@@ -66999,10 +67076,10 @@ var serializeObjectParam = ({ allowReserved, explode, name, style, value, valueO
|
|
|
66999
67076
|
}
|
|
67000
67077
|
}
|
|
67001
67078
|
const separator = separatorObjectExplode(style);
|
|
67002
|
-
const joinedValues = Object.entries(value).map(([key,
|
|
67079
|
+
const joinedValues = Object.entries(value).map(([key, v2]) => serializePrimitiveParam({
|
|
67003
67080
|
allowReserved,
|
|
67004
67081
|
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
67005
|
-
value:
|
|
67082
|
+
value: v2
|
|
67006
67083
|
})).join(separator);
|
|
67007
67084
|
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
67008
67085
|
};
|
|
@@ -67206,8 +67283,8 @@ var mergeHeaders = (...headers) => {
|
|
|
67206
67283
|
if (value === null) {
|
|
67207
67284
|
mergedHeaders.delete(key);
|
|
67208
67285
|
} else if (Array.isArray(value)) {
|
|
67209
|
-
for (const
|
|
67210
|
-
mergedHeaders.append(key,
|
|
67286
|
+
for (const v2 of value) {
|
|
67287
|
+
mergedHeaders.append(key, v2);
|
|
67211
67288
|
}
|
|
67212
67289
|
} else if (value !== undefined) {
|
|
67213
67290
|
mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
|
|
@@ -68219,7 +68296,7 @@ async function createOpencode(options) {
|
|
|
68219
68296
|
|
|
68220
68297
|
// src/cli/run/server-connection.ts
|
|
68221
68298
|
init_port_utils();
|
|
68222
|
-
var
|
|
68299
|
+
var import_picocolors10 = __toESM(require_picocolors(), 1);
|
|
68223
68300
|
|
|
68224
68301
|
// src/cli/run/opencode-binary-resolver.ts
|
|
68225
68302
|
init_spawn_with_windows_hide();
|
|
@@ -68307,13 +68384,13 @@ function isPortRangeExhausted(error48) {
|
|
|
68307
68384
|
async function startServer(options) {
|
|
68308
68385
|
const { signal, port } = options;
|
|
68309
68386
|
const { client: client3, server: server2 } = await withWorkingOpencodePath(() => createOpencode({ signal, port, hostname: "127.0.0.1" }));
|
|
68310
|
-
console.log(
|
|
68387
|
+
console.log(import_picocolors10.default.dim("Server listening at"), import_picocolors10.default.cyan(server2.url));
|
|
68311
68388
|
return { client: client3, cleanup: () => server2.close() };
|
|
68312
68389
|
}
|
|
68313
68390
|
async function createServerConnection(options) {
|
|
68314
68391
|
const { port, attach, signal } = options;
|
|
68315
68392
|
if (attach !== undefined) {
|
|
68316
|
-
console.log(
|
|
68393
|
+
console.log(import_picocolors10.default.dim("Attaching to existing server at"), import_picocolors10.default.cyan(attach));
|
|
68317
68394
|
const client3 = createOpencodeClient({ baseUrl: attach });
|
|
68318
68395
|
return { client: client3, cleanup: () => {} };
|
|
68319
68396
|
}
|
|
@@ -68323,7 +68400,7 @@ async function createServerConnection(options) {
|
|
|
68323
68400
|
}
|
|
68324
68401
|
const available = await isPortAvailable(port, "127.0.0.1");
|
|
68325
68402
|
if (available) {
|
|
68326
|
-
console.log(
|
|
68403
|
+
console.log(import_picocolors10.default.dim("Starting server on port"), import_picocolors10.default.cyan(port.toString()));
|
|
68327
68404
|
try {
|
|
68328
68405
|
return await startServer({ signal, port });
|
|
68329
68406
|
} catch (error48) {
|
|
@@ -68334,12 +68411,12 @@ async function createServerConnection(options) {
|
|
|
68334
68411
|
if (stillAvailable) {
|
|
68335
68412
|
throw error48;
|
|
68336
68413
|
}
|
|
68337
|
-
console.log(
|
|
68414
|
+
console.log(import_picocolors10.default.dim("Port"), import_picocolors10.default.cyan(port.toString()), import_picocolors10.default.dim("became occupied, attaching to existing server"));
|
|
68338
68415
|
const client4 = createOpencodeClient({ baseUrl: `http://127.0.0.1:${port}` });
|
|
68339
68416
|
return { client: client4, cleanup: () => {} };
|
|
68340
68417
|
}
|
|
68341
68418
|
}
|
|
68342
|
-
console.log(
|
|
68419
|
+
console.log(import_picocolors10.default.dim("Port"), import_picocolors10.default.cyan(port.toString()), import_picocolors10.default.dim("is occupied, attaching to existing server"));
|
|
68343
68420
|
const client3 = createOpencodeClient({ baseUrl: `http://127.0.0.1:${port}` });
|
|
68344
68421
|
return { client: client3, cleanup: () => {} };
|
|
68345
68422
|
}
|
|
@@ -68357,14 +68434,14 @@ async function createServerConnection(options) {
|
|
|
68357
68434
|
if (defaultPortIsAvailable) {
|
|
68358
68435
|
throw error48;
|
|
68359
68436
|
}
|
|
68360
|
-
console.log(
|
|
68437
|
+
console.log(import_picocolors10.default.dim("Port range exhausted, attaching to existing server on"), import_picocolors10.default.cyan(DEFAULT_SERVER_PORT.toString()));
|
|
68361
68438
|
const client3 = createOpencodeClient({ baseUrl: `http://127.0.0.1:${DEFAULT_SERVER_PORT}` });
|
|
68362
68439
|
return { client: client3, cleanup: () => {} };
|
|
68363
68440
|
}
|
|
68364
68441
|
if (wasAutoSelected) {
|
|
68365
|
-
console.log(
|
|
68442
|
+
console.log(import_picocolors10.default.dim("Auto-selected port"), import_picocolors10.default.cyan(selectedPort.toString()));
|
|
68366
68443
|
} else {
|
|
68367
|
-
console.log(
|
|
68444
|
+
console.log(import_picocolors10.default.dim("Starting server on port"), import_picocolors10.default.cyan(selectedPort.toString()));
|
|
68368
68445
|
}
|
|
68369
68446
|
try {
|
|
68370
68447
|
return await startServer({ signal, port: selectedPort });
|
|
@@ -68373,13 +68450,13 @@ async function createServerConnection(options) {
|
|
|
68373
68450
|
throw error48;
|
|
68374
68451
|
}
|
|
68375
68452
|
const { port: retryPort } = await getAvailableServerPort(selectedPort + 1, "127.0.0.1");
|
|
68376
|
-
console.log(
|
|
68453
|
+
console.log(import_picocolors10.default.dim("Retrying server start on port"), import_picocolors10.default.cyan(retryPort.toString()));
|
|
68377
68454
|
return await startServer({ signal, port: retryPort });
|
|
68378
68455
|
}
|
|
68379
68456
|
}
|
|
68380
68457
|
|
|
68381
68458
|
// src/cli/run/session-resolver.ts
|
|
68382
|
-
var
|
|
68459
|
+
var import_picocolors11 = __toESM(require_picocolors(), 1);
|
|
68383
68460
|
var SESSION_CREATE_MAX_RETRIES = 3;
|
|
68384
68461
|
var SESSION_CREATE_RETRY_DELAY_MS = 1000;
|
|
68385
68462
|
async function resolveSession(options) {
|
|
@@ -68405,11 +68482,11 @@ async function resolveSession(options) {
|
|
|
68405
68482
|
query: { directory }
|
|
68406
68483
|
});
|
|
68407
68484
|
if (res.error) {
|
|
68408
|
-
console.error(
|
|
68409
|
-
console.error(
|
|
68485
|
+
console.error(import_picocolors11.default.yellow(`Session create attempt ${attempt}/${SESSION_CREATE_MAX_RETRIES} failed:`));
|
|
68486
|
+
console.error(import_picocolors11.default.dim(` Error: ${serializeError(res.error)}`));
|
|
68410
68487
|
if (attempt < SESSION_CREATE_MAX_RETRIES) {
|
|
68411
68488
|
const delay = SESSION_CREATE_RETRY_DELAY_MS * attempt;
|
|
68412
|
-
console.log(
|
|
68489
|
+
console.log(import_picocolors11.default.dim(` Retrying in ${delay}ms...`));
|
|
68413
68490
|
await new Promise((resolve2) => setTimeout(resolve2, delay));
|
|
68414
68491
|
}
|
|
68415
68492
|
continue;
|
|
@@ -68417,10 +68494,10 @@ async function resolveSession(options) {
|
|
|
68417
68494
|
if (res.data?.id) {
|
|
68418
68495
|
return res.data.id;
|
|
68419
68496
|
}
|
|
68420
|
-
console.error(
|
|
68497
|
+
console.error(import_picocolors11.default.yellow(`Session create attempt ${attempt}/${SESSION_CREATE_MAX_RETRIES}: No session ID returned`));
|
|
68421
68498
|
if (attempt < SESSION_CREATE_MAX_RETRIES) {
|
|
68422
68499
|
const delay = SESSION_CREATE_RETRY_DELAY_MS * attempt;
|
|
68423
|
-
console.log(
|
|
68500
|
+
console.log(import_picocolors11.default.dim(` Retrying in ${delay}ms...`));
|
|
68424
68501
|
await new Promise((resolve2) => setTimeout(resolve2, delay));
|
|
68425
68502
|
}
|
|
68426
68503
|
}
|
|
@@ -68538,7 +68615,7 @@ async function executeOnCompleteHook(options) {
|
|
|
68538
68615
|
|
|
68539
68616
|
// src/cli/run/agent-resolver.ts
|
|
68540
68617
|
init_agent_display_names();
|
|
68541
|
-
var
|
|
68618
|
+
var import_picocolors12 = __toESM(require_picocolors(), 1);
|
|
68542
68619
|
var CORE_AGENT_ORDER = ["sisyphus", "hephaestus", "prometheus", "atlas"];
|
|
68543
68620
|
var DEFAULT_AGENT = "sisyphus";
|
|
68544
68621
|
var normalizeAgentName = (agent) => {
|
|
@@ -68583,10 +68660,10 @@ var resolveRunAgent = (options, pluginConfig, env = process.env) => {
|
|
|
68583
68660
|
const fallbackName = getAgentDisplayName(fallback);
|
|
68584
68661
|
const fallbackDisabled = isAgentDisabled(fallback, pluginConfig);
|
|
68585
68662
|
if (fallbackDisabled) {
|
|
68586
|
-
console.log(
|
|
68663
|
+
console.log(import_picocolors12.default.yellow(`Requested agent "${resolved.resolvedName}" is disabled and no enabled core agent was found. Proceeding with "${fallbackName}".`));
|
|
68587
68664
|
return fallbackName;
|
|
68588
68665
|
}
|
|
68589
|
-
console.log(
|
|
68666
|
+
console.log(import_picocolors12.default.yellow(`Requested agent "${resolved.resolvedName}" is disabled. Falling back to "${fallbackName}".`));
|
|
68590
68667
|
return fallbackName;
|
|
68591
68668
|
}
|
|
68592
68669
|
return resolved.resolvedName;
|
|
@@ -68617,11 +68694,11 @@ function resolveRunModel(modelString) {
|
|
|
68617
68694
|
}
|
|
68618
68695
|
|
|
68619
68696
|
// src/cli/run/poll-for-completion.ts
|
|
68620
|
-
var
|
|
68697
|
+
var import_picocolors14 = __toESM(require_picocolors(), 1);
|
|
68621
68698
|
|
|
68622
68699
|
// src/cli/run/completion.ts
|
|
68623
68700
|
init_shared();
|
|
68624
|
-
var
|
|
68701
|
+
var import_picocolors13 = __toESM(require_picocolors(), 1);
|
|
68625
68702
|
// src/features/boulder-state/constants.ts
|
|
68626
68703
|
var BOULDER_DIR = ".sisyphus";
|
|
68627
68704
|
var BOULDER_FILE = "boulder.json";
|
|
@@ -68822,7 +68899,7 @@ async function checkCompletionConditions(ctx) {
|
|
|
68822
68899
|
}
|
|
68823
68900
|
return true;
|
|
68824
68901
|
} catch (err) {
|
|
68825
|
-
console.error(
|
|
68902
|
+
console.error(import_picocolors13.default.red(`[completion] API error: ${err}`));
|
|
68826
68903
|
return false;
|
|
68827
68904
|
}
|
|
68828
68905
|
}
|
|
@@ -68883,7 +68960,7 @@ function logWaiting(ctx, message) {
|
|
|
68883
68960
|
if (!ctx.verbose) {
|
|
68884
68961
|
return;
|
|
68885
68962
|
}
|
|
68886
|
-
console.log(
|
|
68963
|
+
console.log(import_picocolors13.default.dim(` Waiting: ${message}`));
|
|
68887
68964
|
}
|
|
68888
68965
|
|
|
68889
68966
|
// src/cli/run/poll-for-completion.ts
|
|
@@ -68914,10 +68991,10 @@ async function pollForCompletion(ctx, eventState, abortController, options = {})
|
|
|
68914
68991
|
if (eventState.mainSessionError) {
|
|
68915
68992
|
errorCycleCount++;
|
|
68916
68993
|
if (errorCycleCount >= ERROR_GRACE_CYCLES) {
|
|
68917
|
-
console.error(
|
|
68994
|
+
console.error(import_picocolors14.default.red(`
|
|
68918
68995
|
|
|
68919
68996
|
Session ended with error: ${eventState.lastError}`));
|
|
68920
|
-
console.error(
|
|
68997
|
+
console.error(import_picocolors14.default.yellow("Check if todos were completed before the error."));
|
|
68921
68998
|
return 1;
|
|
68922
68999
|
}
|
|
68923
69000
|
continue;
|
|
@@ -68928,7 +69005,7 @@ Session ended with error: ${eventState.lastError}`));
|
|
|
68928
69005
|
if (eventState.lastEventTimestamp !== null) {
|
|
68929
69006
|
const timeSinceLastEvent = Date.now() - eventState.lastEventTimestamp;
|
|
68930
69007
|
if (timeSinceLastEvent > eventWatchdogMs) {
|
|
68931
|
-
console.log(
|
|
69008
|
+
console.log(import_picocolors14.default.yellow(`
|
|
68932
69009
|
No events for ${Math.round(timeSinceLastEvent / 1000)}s, verifying session status...`));
|
|
68933
69010
|
mainSessionStatus = await getMainSessionStatus(ctx);
|
|
68934
69011
|
if (mainSessionStatus === "idle") {
|
|
@@ -68977,7 +69054,7 @@ Session ended with error: ${eventState.lastError}`));
|
|
|
68977
69054
|
const hasActiveWork = hasActiveChildren || hasActiveTodos;
|
|
68978
69055
|
if (hasActiveWork) {
|
|
68979
69056
|
eventState.hasReceivedMeaningfulWork = true;
|
|
68980
|
-
console.log(
|
|
69057
|
+
console.log(import_picocolors14.default.yellow(`
|
|
68981
69058
|
No meaningful work events for ${Math.round(secondaryMeaningfulWorkTimeoutMs / 1000)}s but session has active work - assuming in progress`));
|
|
68982
69059
|
}
|
|
68983
69060
|
}
|
|
@@ -68997,7 +69074,7 @@ Session ended with error: ${eventState.lastError}`));
|
|
|
68997
69074
|
}
|
|
68998
69075
|
consecutiveCompleteChecks++;
|
|
68999
69076
|
if (consecutiveCompleteChecks >= requiredConsecutive) {
|
|
69000
|
-
console.log(
|
|
69077
|
+
console.log(import_picocolors14.default.green(`
|
|
69001
69078
|
|
|
69002
69079
|
All tasks completed.`));
|
|
69003
69080
|
return 0;
|
|
@@ -69166,7 +69243,7 @@ async function run(options) {
|
|
|
69166
69243
|
};
|
|
69167
69244
|
const restoreInput = suppressRunInput();
|
|
69168
69245
|
const handleSigint = () => {
|
|
69169
|
-
console.log(
|
|
69246
|
+
console.log(import_picocolors15.default.yellow(`
|
|
69170
69247
|
Interrupted. Shutting down...`));
|
|
69171
69248
|
restoreInput();
|
|
69172
69249
|
cleanup();
|
|
@@ -69179,9 +69256,9 @@ Interrupted. Shutting down...`));
|
|
|
69179
69256
|
sessionId: options.sessionId,
|
|
69180
69257
|
directory
|
|
69181
69258
|
});
|
|
69182
|
-
console.log(
|
|
69259
|
+
console.log(import_picocolors15.default.dim(`Session: ${sessionID}`));
|
|
69183
69260
|
if (resolvedModel) {
|
|
69184
|
-
console.log(
|
|
69261
|
+
console.log(import_picocolors15.default.dim(`Model: ${resolvedModel.providerID}/${resolvedModel.modelID}`));
|
|
69185
69262
|
}
|
|
69186
69263
|
const ctx = {
|
|
69187
69264
|
client: client3,
|
|
@@ -69244,7 +69321,7 @@ Interrupted. Shutting down...`));
|
|
|
69244
69321
|
if (err instanceof Error && err.name === "AbortError") {
|
|
69245
69322
|
return 130;
|
|
69246
69323
|
}
|
|
69247
|
-
console.error(
|
|
69324
|
+
console.error(import_picocolors15.default.red(`Error: ${serializeError(err)}`));
|
|
69248
69325
|
return 1;
|
|
69249
69326
|
} finally {
|
|
69250
69327
|
timestampOutput?.restore();
|
|
@@ -69254,53 +69331,53 @@ Interrupted. Shutting down...`));
|
|
|
69254
69331
|
init_checker();
|
|
69255
69332
|
|
|
69256
69333
|
// src/cli/get-local-version/formatter.ts
|
|
69257
|
-
var
|
|
69334
|
+
var import_picocolors16 = __toESM(require_picocolors(), 1);
|
|
69258
69335
|
var SYMBOLS2 = {
|
|
69259
|
-
check:
|
|
69260
|
-
cross:
|
|
69261
|
-
arrow:
|
|
69262
|
-
info:
|
|
69263
|
-
warn:
|
|
69264
|
-
pin:
|
|
69265
|
-
dev:
|
|
69336
|
+
check: import_picocolors16.default.green("[OK]"),
|
|
69337
|
+
cross: import_picocolors16.default.red("[X]"),
|
|
69338
|
+
arrow: import_picocolors16.default.cyan("->"),
|
|
69339
|
+
info: import_picocolors16.default.blue("[i]"),
|
|
69340
|
+
warn: import_picocolors16.default.yellow("[!]"),
|
|
69341
|
+
pin: import_picocolors16.default.magenta("[PINNED]"),
|
|
69342
|
+
dev: import_picocolors16.default.cyan("[DEV]")
|
|
69266
69343
|
};
|
|
69267
69344
|
function formatVersionOutput(info) {
|
|
69268
69345
|
const lines = [];
|
|
69269
69346
|
lines.push("");
|
|
69270
|
-
lines.push(
|
|
69271
|
-
lines.push(
|
|
69347
|
+
lines.push(import_picocolors16.default.bold(import_picocolors16.default.white("oh-my-magento Version Information")));
|
|
69348
|
+
lines.push(import_picocolors16.default.dim("\u2500".repeat(50)));
|
|
69272
69349
|
lines.push("");
|
|
69273
69350
|
if (info.currentVersion) {
|
|
69274
|
-
lines.push(` Current Version: ${
|
|
69351
|
+
lines.push(` Current Version: ${import_picocolors16.default.cyan(info.currentVersion)}`);
|
|
69275
69352
|
} else {
|
|
69276
|
-
lines.push(` Current Version: ${
|
|
69353
|
+
lines.push(` Current Version: ${import_picocolors16.default.dim("unknown")}`);
|
|
69277
69354
|
}
|
|
69278
69355
|
if (!info.isLocalDev && info.latestVersion) {
|
|
69279
|
-
lines.push(` Latest Version: ${
|
|
69356
|
+
lines.push(` Latest Version: ${import_picocolors16.default.cyan(info.latestVersion)}`);
|
|
69280
69357
|
}
|
|
69281
69358
|
lines.push("");
|
|
69282
69359
|
switch (info.status) {
|
|
69283
69360
|
case "up-to-date":
|
|
69284
|
-
lines.push(` ${SYMBOLS2.check} ${
|
|
69361
|
+
lines.push(` ${SYMBOLS2.check} ${import_picocolors16.default.green("You're up to date!")}`);
|
|
69285
69362
|
break;
|
|
69286
69363
|
case "outdated":
|
|
69287
|
-
lines.push(` ${SYMBOLS2.warn} ${
|
|
69288
|
-
lines.push(` ${
|
|
69364
|
+
lines.push(` ${SYMBOLS2.warn} ${import_picocolors16.default.yellow("Update available")}`);
|
|
69365
|
+
lines.push(` ${import_picocolors16.default.dim("Run:")} ${import_picocolors16.default.cyan("cd ~/.config/opencode && bun update oh-my-magento")}`);
|
|
69289
69366
|
break;
|
|
69290
69367
|
case "local-dev":
|
|
69291
|
-
lines.push(` ${SYMBOLS2.dev} ${
|
|
69292
|
-
lines.push(` ${
|
|
69368
|
+
lines.push(` ${SYMBOLS2.dev} ${import_picocolors16.default.cyan("Running in local development mode")}`);
|
|
69369
|
+
lines.push(` ${import_picocolors16.default.dim("Using file:// protocol from config")}`);
|
|
69293
69370
|
break;
|
|
69294
69371
|
case "pinned":
|
|
69295
|
-
lines.push(` ${SYMBOLS2.pin} ${
|
|
69296
|
-
lines.push(` ${
|
|
69372
|
+
lines.push(` ${SYMBOLS2.pin} ${import_picocolors16.default.magenta(`Version pinned to ${info.pinnedVersion}`)}`);
|
|
69373
|
+
lines.push(` ${import_picocolors16.default.dim("Update check skipped for pinned versions")}`);
|
|
69297
69374
|
break;
|
|
69298
69375
|
case "error":
|
|
69299
|
-
lines.push(` ${SYMBOLS2.cross} ${
|
|
69300
|
-
lines.push(` ${
|
|
69376
|
+
lines.push(` ${SYMBOLS2.cross} ${import_picocolors16.default.red("Unable to check for updates")}`);
|
|
69377
|
+
lines.push(` ${import_picocolors16.default.dim("Network error or npm registry unavailable")}`);
|
|
69301
69378
|
break;
|
|
69302
69379
|
case "unknown":
|
|
69303
|
-
lines.push(` ${SYMBOLS2.info} ${
|
|
69380
|
+
lines.push(` ${SYMBOLS2.info} ${import_picocolors16.default.yellow("Version information unavailable")}`);
|
|
69304
69381
|
break;
|
|
69305
69382
|
}
|
|
69306
69383
|
lines.push("");
|
|
@@ -69401,21 +69478,21 @@ async function getLocalVersion(options = {}) {
|
|
|
69401
69478
|
}
|
|
69402
69479
|
// src/cli/doctor/constants.ts
|
|
69403
69480
|
init_shared();
|
|
69404
|
-
var
|
|
69481
|
+
var import_picocolors17 = __toESM(require_picocolors(), 1);
|
|
69405
69482
|
var SYMBOLS3 = {
|
|
69406
|
-
check:
|
|
69407
|
-
cross:
|
|
69408
|
-
warn:
|
|
69409
|
-
info:
|
|
69410
|
-
arrow:
|
|
69411
|
-
bullet:
|
|
69412
|
-
skip:
|
|
69483
|
+
check: import_picocolors17.default.green("\u2713"),
|
|
69484
|
+
cross: import_picocolors17.default.red("\u2717"),
|
|
69485
|
+
warn: import_picocolors17.default.yellow("\u26A0"),
|
|
69486
|
+
info: import_picocolors17.default.blue("\u2139"),
|
|
69487
|
+
arrow: import_picocolors17.default.cyan("\u2192"),
|
|
69488
|
+
bullet: import_picocolors17.default.dim("\u2022"),
|
|
69489
|
+
skip: import_picocolors17.default.dim("\u25CB")
|
|
69413
69490
|
};
|
|
69414
69491
|
var STATUS_COLORS = {
|
|
69415
|
-
pass:
|
|
69416
|
-
fail:
|
|
69417
|
-
warn:
|
|
69418
|
-
skip:
|
|
69492
|
+
pass: import_picocolors17.default.green,
|
|
69493
|
+
fail: import_picocolors17.default.red,
|
|
69494
|
+
warn: import_picocolors17.default.yellow,
|
|
69495
|
+
skip: import_picocolors17.default.dim
|
|
69419
69496
|
};
|
|
69420
69497
|
var CHECK_IDS = {
|
|
69421
69498
|
SYSTEM: "system",
|
|
@@ -71017,10 +71094,10 @@ function getAllCheckDefinitions() {
|
|
|
71017
71094
|
}
|
|
71018
71095
|
|
|
71019
71096
|
// src/cli/doctor/format-default.ts
|
|
71020
|
-
var
|
|
71097
|
+
var import_picocolors19 = __toESM(require_picocolors(), 1);
|
|
71021
71098
|
|
|
71022
71099
|
// src/cli/doctor/format-shared.ts
|
|
71023
|
-
var
|
|
71100
|
+
var import_picocolors18 = __toESM(require_picocolors(), 1);
|
|
71024
71101
|
function formatStatusSymbol(status) {
|
|
71025
71102
|
const colorFn = STATUS_COLORS[status];
|
|
71026
71103
|
switch (status) {
|
|
@@ -71035,23 +71112,23 @@ function formatStatusSymbol(status) {
|
|
|
71035
71112
|
}
|
|
71036
71113
|
}
|
|
71037
71114
|
function formatStatusMark(available) {
|
|
71038
|
-
return available ?
|
|
71115
|
+
return available ? import_picocolors18.default.green(SYMBOLS3.check) : import_picocolors18.default.red(SYMBOLS3.cross);
|
|
71039
71116
|
}
|
|
71040
71117
|
function formatHeader() {
|
|
71041
71118
|
return `
|
|
71042
|
-
${
|
|
71119
|
+
${import_picocolors18.default.bgMagenta(import_picocolors18.default.white(" oMoMoMoMo Doctor "))}
|
|
71043
71120
|
`;
|
|
71044
71121
|
}
|
|
71045
71122
|
function formatIssue(issue2, index) {
|
|
71046
71123
|
const lines = [];
|
|
71047
|
-
const severityColor = issue2.severity === "error" ?
|
|
71124
|
+
const severityColor = issue2.severity === "error" ? import_picocolors18.default.red : import_picocolors18.default.yellow;
|
|
71048
71125
|
lines.push(`${index}. ${severityColor(issue2.title)}`);
|
|
71049
|
-
lines.push(` ${
|
|
71126
|
+
lines.push(` ${import_picocolors18.default.dim(issue2.description)}`);
|
|
71050
71127
|
if (issue2.fix) {
|
|
71051
|
-
lines.push(` ${
|
|
71128
|
+
lines.push(` ${import_picocolors18.default.cyan("Fix:")} ${import_picocolors18.default.dim(issue2.fix)}`);
|
|
71052
71129
|
}
|
|
71053
71130
|
if (issue2.affects && issue2.affects.length > 0) {
|
|
71054
|
-
lines.push(` ${
|
|
71131
|
+
lines.push(` ${import_picocolors18.default.cyan("Affects:")} ${import_picocolors18.default.dim(issue2.affects.join(", "))}`);
|
|
71055
71132
|
}
|
|
71056
71133
|
return lines.join(`
|
|
71057
71134
|
`);
|
|
@@ -71065,12 +71142,12 @@ function formatDefault(result) {
|
|
|
71065
71142
|
if (allIssues.length === 0) {
|
|
71066
71143
|
const opencodeVer = result.systemInfo.opencodeVersion ?? "unknown";
|
|
71067
71144
|
const pluginVer = result.systemInfo.pluginVersion ?? "unknown";
|
|
71068
|
-
lines.push(` ${
|
|
71145
|
+
lines.push(` ${import_picocolors19.default.green(SYMBOLS3.check)} ${import_picocolors19.default.green(`System OK (opencode ${opencodeVer} \xB7 oh-my-magento ${pluginVer})`)}`);
|
|
71069
71146
|
} else {
|
|
71070
71147
|
const issueCount = allIssues.filter((i2) => i2.severity === "error").length;
|
|
71071
71148
|
const warnCount = allIssues.filter((i2) => i2.severity === "warning").length;
|
|
71072
71149
|
const totalStr = `${issueCount + warnCount} ${issueCount + warnCount === 1 ? "issue" : "issues"}`;
|
|
71073
|
-
lines.push(` ${
|
|
71150
|
+
lines.push(` ${import_picocolors19.default.yellow(SYMBOLS3.warn)} ${totalStr} found:
|
|
71074
71151
|
`);
|
|
71075
71152
|
allIssues.forEach((issue2, index) => {
|
|
71076
71153
|
lines.push(formatIssue(issue2, index + 1));
|
|
@@ -71082,7 +71159,7 @@ function formatDefault(result) {
|
|
|
71082
71159
|
}
|
|
71083
71160
|
|
|
71084
71161
|
// src/cli/doctor/format-status.ts
|
|
71085
|
-
var
|
|
71162
|
+
var import_picocolors20 = __toESM(require_picocolors(), 1);
|
|
71086
71163
|
function formatStatus(result) {
|
|
71087
71164
|
const lines = [];
|
|
71088
71165
|
lines.push(formatHeader());
|
|
@@ -71093,7 +71170,7 @@ function formatStatus(result) {
|
|
|
71093
71170
|
const bunVer = systemInfo.bunVersion ?? "unknown";
|
|
71094
71171
|
lines.push(` ${padding}System ${opencodeVer} \xB7 ${pluginVer} \xB7 Bun ${bunVer}`);
|
|
71095
71172
|
const configPath = systemInfo.configPath ?? "unknown";
|
|
71096
|
-
const configStatus = systemInfo.configValid ?
|
|
71173
|
+
const configStatus = systemInfo.configValid ? import_picocolors20.default.green("(valid)") : import_picocolors20.default.red("(invalid)");
|
|
71097
71174
|
lines.push(` ${padding}Config ${configPath} ${configStatus}`);
|
|
71098
71175
|
const serverCount = tools.lspServers.length;
|
|
71099
71176
|
const lspMark = formatStatusMark(serverCount > 0);
|
|
@@ -71112,13 +71189,13 @@ function formatStatus(result) {
|
|
|
71112
71189
|
}
|
|
71113
71190
|
|
|
71114
71191
|
// src/cli/doctor/format-verbose.ts
|
|
71115
|
-
var
|
|
71192
|
+
var import_picocolors21 = __toESM(require_picocolors(), 1);
|
|
71116
71193
|
function formatVerbose(result) {
|
|
71117
71194
|
const lines = [];
|
|
71118
71195
|
lines.push(formatHeader());
|
|
71119
71196
|
const { systemInfo, tools, results, summary } = result;
|
|
71120
|
-
lines.push(`${
|
|
71121
|
-
lines.push(`${
|
|
71197
|
+
lines.push(`${import_picocolors21.default.bold("System Information")}`);
|
|
71198
|
+
lines.push(`${import_picocolors21.default.dim("\u2500".repeat(40))}`);
|
|
71122
71199
|
lines.push(` ${formatStatusSymbol("pass")} opencode ${systemInfo.opencodeVersion ?? "unknown"}`);
|
|
71123
71200
|
lines.push(` ${formatStatusSymbol("pass")} oh-my-magento ${systemInfo.pluginVersion ?? "unknown"}`);
|
|
71124
71201
|
if (systemInfo.loadedVersion) {
|
|
@@ -71129,16 +71206,16 @@ function formatVerbose(result) {
|
|
|
71129
71206
|
}
|
|
71130
71207
|
lines.push(` ${formatStatusSymbol("pass")} path ${systemInfo.opencodePath ?? "unknown"}`);
|
|
71131
71208
|
if (systemInfo.isLocalDev) {
|
|
71132
|
-
lines.push(` ${
|
|
71209
|
+
lines.push(` ${import_picocolors21.default.yellow("*")} ${import_picocolors21.default.dim("(local development mode)")}`);
|
|
71133
71210
|
}
|
|
71134
71211
|
lines.push("");
|
|
71135
|
-
lines.push(`${
|
|
71136
|
-
lines.push(`${
|
|
71137
|
-
const configStatus = systemInfo.configValid ?
|
|
71212
|
+
lines.push(`${import_picocolors21.default.bold("Configuration")}`);
|
|
71213
|
+
lines.push(`${import_picocolors21.default.dim("\u2500".repeat(40))}`);
|
|
71214
|
+
const configStatus = systemInfo.configValid ? import_picocolors21.default.green("valid") : import_picocolors21.default.red("invalid");
|
|
71138
71215
|
lines.push(` ${formatStatusSymbol(systemInfo.configValid ? "pass" : "fail")} ${systemInfo.configPath ?? "unknown"} (${configStatus})`);
|
|
71139
71216
|
lines.push("");
|
|
71140
|
-
lines.push(`${
|
|
71141
|
-
lines.push(`${
|
|
71217
|
+
lines.push(`${import_picocolors21.default.bold("Tools")}`);
|
|
71218
|
+
lines.push(`${import_picocolors21.default.dim("\u2500".repeat(40))}`);
|
|
71142
71219
|
if (tools.lspServers.length === 0) {
|
|
71143
71220
|
lines.push(` ${formatStatusSymbol("warn")} LSP none detected`);
|
|
71144
71221
|
} else {
|
|
@@ -71153,17 +71230,17 @@ function formatVerbose(result) {
|
|
|
71153
71230
|
lines.push(` ${formatStatusSymbol(tools.commentChecker ? "pass" : "fail")} comment-checker ${tools.commentChecker ? "installed" : "not found"}`);
|
|
71154
71231
|
lines.push(` ${formatStatusSymbol(tools.ghCli.installed && tools.ghCli.authenticated ? "pass" : "fail")} gh CLI ${tools.ghCli.installed ? "installed" : "not found"}${tools.ghCli.authenticated && tools.ghCli.username ? ` (${tools.ghCli.username})` : ""}`);
|
|
71155
71232
|
lines.push("");
|
|
71156
|
-
lines.push(`${
|
|
71157
|
-
lines.push(`${
|
|
71233
|
+
lines.push(`${import_picocolors21.default.bold("MCPs")}`);
|
|
71234
|
+
lines.push(`${import_picocolors21.default.dim("\u2500".repeat(40))}`);
|
|
71158
71235
|
if (tools.mcpBuiltin.length === 0) {
|
|
71159
|
-
lines.push(` ${
|
|
71236
|
+
lines.push(` ${import_picocolors21.default.dim("No built-in MCPs")}`);
|
|
71160
71237
|
} else {
|
|
71161
71238
|
for (const mcp of tools.mcpBuiltin) {
|
|
71162
71239
|
lines.push(` ${formatStatusSymbol("pass")} ${mcp}`);
|
|
71163
71240
|
}
|
|
71164
71241
|
}
|
|
71165
71242
|
if (tools.mcpUser.length > 0) {
|
|
71166
|
-
lines.push(` ${
|
|
71243
|
+
lines.push(` ${import_picocolors21.default.cyan("+")} ${tools.mcpUser.length} user MCP(s):`);
|
|
71167
71244
|
for (const mcp of tools.mcpUser) {
|
|
71168
71245
|
lines.push(` ${formatStatusSymbol("pass")} ${mcp}`);
|
|
71169
71246
|
}
|
|
@@ -71173,8 +71250,8 @@ function formatVerbose(result) {
|
|
|
71173
71250
|
if (!check2.details || check2.details.length === 0) {
|
|
71174
71251
|
continue;
|
|
71175
71252
|
}
|
|
71176
|
-
lines.push(`${
|
|
71177
|
-
lines.push(`${
|
|
71253
|
+
lines.push(`${import_picocolors21.default.bold(check2.name)}`);
|
|
71254
|
+
lines.push(`${import_picocolors21.default.dim("\u2500".repeat(40))}`);
|
|
71178
71255
|
for (const detail of check2.details) {
|
|
71179
71256
|
lines.push(detail);
|
|
71180
71257
|
}
|
|
@@ -71182,20 +71259,20 @@ function formatVerbose(result) {
|
|
|
71182
71259
|
}
|
|
71183
71260
|
const allIssues = results.flatMap((r2) => r2.issues);
|
|
71184
71261
|
if (allIssues.length > 0) {
|
|
71185
|
-
lines.push(`${
|
|
71186
|
-
lines.push(`${
|
|
71262
|
+
lines.push(`${import_picocolors21.default.bold("Issues")}`);
|
|
71263
|
+
lines.push(`${import_picocolors21.default.dim("\u2500".repeat(40))}`);
|
|
71187
71264
|
allIssues.forEach((issue2, index) => {
|
|
71188
71265
|
lines.push(formatIssue(issue2, index + 1));
|
|
71189
71266
|
lines.push("");
|
|
71190
71267
|
});
|
|
71191
71268
|
}
|
|
71192
|
-
lines.push(`${
|
|
71193
|
-
lines.push(`${
|
|
71194
|
-
const passText = summary.passed > 0 ?
|
|
71195
|
-
const failText = summary.failed > 0 ?
|
|
71196
|
-
const warnText = summary.warnings > 0 ?
|
|
71269
|
+
lines.push(`${import_picocolors21.default.bold("Summary")}`);
|
|
71270
|
+
lines.push(`${import_picocolors21.default.dim("\u2500".repeat(40))}`);
|
|
71271
|
+
const passText = summary.passed > 0 ? import_picocolors21.default.green(`${summary.passed} passed`) : `${summary.passed} passed`;
|
|
71272
|
+
const failText = summary.failed > 0 ? import_picocolors21.default.red(`${summary.failed} failed`) : `${summary.failed} failed`;
|
|
71273
|
+
const warnText = summary.warnings > 0 ? import_picocolors21.default.yellow(`${summary.warnings} warnings`) : `${summary.warnings} warnings`;
|
|
71197
71274
|
lines.push(` ${passText}, ${failText}, ${warnText}`);
|
|
71198
|
-
lines.push(` ${
|
|
71275
|
+
lines.push(` ${import_picocolors21.default.dim(`Total: ${summary.total} checks in ${summary.duration}ms`)}`);
|
|
71199
71276
|
return lines.join(`
|
|
71200
71277
|
`);
|
|
71201
71278
|
}
|
|
@@ -72179,7 +72256,7 @@ Set OPENCODE_DB env var to override.`);
|
|
|
72179
72256
|
}
|
|
72180
72257
|
|
|
72181
72258
|
// src/cli/usage/render.ts
|
|
72182
|
-
var
|
|
72259
|
+
var import_picocolors22 = __toESM(require_picocolors(), 1);
|
|
72183
72260
|
function formatTokens(n) {
|
|
72184
72261
|
if (n >= 1e9)
|
|
72185
72262
|
return `${(n / 1e9).toFixed(1)}B`;
|
|
@@ -72198,10 +72275,10 @@ function formatCost(c) {
|
|
|
72198
72275
|
}
|
|
72199
72276
|
function formatDelta(pct) {
|
|
72200
72277
|
if (pct > 0)
|
|
72201
|
-
return
|
|
72278
|
+
return import_picocolors22.default.red(`+${pct.toFixed(0)}%`);
|
|
72202
72279
|
if (pct < 0)
|
|
72203
|
-
return
|
|
72204
|
-
return
|
|
72280
|
+
return import_picocolors22.default.green(`${pct.toFixed(0)}%`);
|
|
72281
|
+
return import_picocolors22.default.dim("0%");
|
|
72205
72282
|
}
|
|
72206
72283
|
function sparkBar(value, maxValue, width = 8) {
|
|
72207
72284
|
if (maxValue <= 0 || value <= 0)
|
|
@@ -72230,38 +72307,38 @@ function bottomBorder(widths) {
|
|
|
72230
72307
|
}
|
|
72231
72308
|
function renderSummary(total, period, prevTotal) {
|
|
72232
72309
|
const parts = [];
|
|
72233
|
-
parts.push(` Calls: ${
|
|
72310
|
+
parts.push(` Calls: ${import_picocolors22.default.bold(import_picocolors22.default.magenta(total.calls.toLocaleString()))}`);
|
|
72234
72311
|
if (prevTotal && prevTotal.calls > 0) {
|
|
72235
72312
|
const pct = (total.calls - prevTotal.calls) / prevTotal.calls * 100;
|
|
72236
72313
|
parts.push(` ${formatDelta(pct)}`);
|
|
72237
72314
|
}
|
|
72238
|
-
parts.push(` \u2502 Tokens: ${
|
|
72315
|
+
parts.push(` \u2502 Tokens: ${import_picocolors22.default.bold(formatTokens(total.tokens.total))}`);
|
|
72239
72316
|
if (prevTotal && prevTotal.tokens.total > 0) {
|
|
72240
72317
|
const pct = (total.tokens.total - prevTotal.tokens.total) / prevTotal.tokens.total * 100;
|
|
72241
72318
|
parts.push(` ${formatDelta(pct)}`);
|
|
72242
72319
|
}
|
|
72243
|
-
parts.push(` \u2502 Cost: ${
|
|
72320
|
+
parts.push(` \u2502 Cost: ${import_picocolors22.default.bold(import_picocolors22.default.red(formatCost(total.cost)))}`);
|
|
72244
72321
|
if (prevTotal && prevTotal.cost > 0) {
|
|
72245
72322
|
const pct = (total.cost - prevTotal.cost) / prevTotal.cost * 100;
|
|
72246
72323
|
parts.push(` ${formatDelta(pct)}`);
|
|
72247
72324
|
}
|
|
72248
72325
|
const content = parts.join("");
|
|
72249
72326
|
const title = `OpenCode Usage \u2014 ${period}`;
|
|
72250
|
-
const titleLine = `\u256D${"\u2500".repeat(3)} ${
|
|
72327
|
+
const titleLine = `\u256D${"\u2500".repeat(3)} ${import_picocolors22.default.bold(title)} ${"\u2500".repeat(3)}\u256E`;
|
|
72251
72328
|
console.log();
|
|
72252
72329
|
console.log(titleLine);
|
|
72253
72330
|
console.log(content);
|
|
72254
72331
|
console.log(`\u2570${"\u2500".repeat(titleLine.length - 2)}\u256F`);
|
|
72255
72332
|
}
|
|
72256
72333
|
function renderDaily(rows, period) {
|
|
72257
|
-
const title =
|
|
72334
|
+
const title = import_picocolors22.default.bold(`Daily Usage (${period})`);
|
|
72258
72335
|
console.log();
|
|
72259
72336
|
console.log(` ${title}`);
|
|
72260
72337
|
const widths = [12, 7, 7, 7, 7, 7, 8, 8, 10];
|
|
72261
72338
|
const headers = ["Date", "Calls", "Input", "Output", "Cache R", "Cache W", "Total", "Cost", "Trend"];
|
|
72262
|
-
console.log(
|
|
72263
|
-
console.log(
|
|
72264
|
-
console.log(
|
|
72339
|
+
console.log(import_picocolors22.default.dim(topBorder(widths)));
|
|
72340
|
+
console.log(import_picocolors22.default.cyan(import_picocolors22.default.bold(headerRow(headers, widths))));
|
|
72341
|
+
console.log(import_picocolors22.default.dim(separator(widths)));
|
|
72265
72342
|
const maxTokens = Math.max(...rows.map((r2) => r2.tokens.total), 1);
|
|
72266
72343
|
for (const r2 of rows) {
|
|
72267
72344
|
const cells = [
|
|
@@ -72273,11 +72350,11 @@ function renderDaily(rows, period) {
|
|
|
72273
72350
|
` ${padLeft(formatTokens(r2.tokens.cacheWrite), widths[5])} `,
|
|
72274
72351
|
` ${padLeft(formatTokens(r2.tokens.total), widths[6])} `,
|
|
72275
72352
|
` ${padLeft(formatCost(r2.cost), widths[7])} `,
|
|
72276
|
-
` ${padRight(
|
|
72353
|
+
` ${padRight(import_picocolors22.default.cyan(sparkBar(r2.tokens.total, maxTokens, widths[8])), widths[8])} `
|
|
72277
72354
|
];
|
|
72278
72355
|
console.log("\u2502" + cells.join("\u2502") + "\u2502");
|
|
72279
72356
|
}
|
|
72280
|
-
console.log(
|
|
72357
|
+
console.log(import_picocolors22.default.dim(bottomBorder(widths)));
|
|
72281
72358
|
}
|
|
72282
72359
|
function renderGrouped(rows, groupBy, period, deltas) {
|
|
72283
72360
|
const labelMap = {
|
|
@@ -72289,7 +72366,7 @@ function renderGrouped(rows, groupBy, period, deltas) {
|
|
|
72289
72366
|
const labelHeader = labelMap[groupBy] ?? groupBy;
|
|
72290
72367
|
const showDetail = groupBy === "agent";
|
|
72291
72368
|
const showBreakdown = groupBy !== "session" && groupBy !== "agent";
|
|
72292
|
-
const title =
|
|
72369
|
+
const title = import_picocolors22.default.bold(`Usage by ${labelHeader} (${period})`);
|
|
72293
72370
|
console.log();
|
|
72294
72371
|
console.log(` ${title}`);
|
|
72295
72372
|
const widths = [24];
|
|
@@ -72310,14 +72387,14 @@ function renderGrouped(rows, groupBy, period, deltas) {
|
|
|
72310
72387
|
widths.push(7);
|
|
72311
72388
|
headers.push("Delta");
|
|
72312
72389
|
}
|
|
72313
|
-
console.log(
|
|
72314
|
-
console.log(
|
|
72315
|
-
console.log(
|
|
72390
|
+
console.log(import_picocolors22.default.dim(topBorder(widths)));
|
|
72391
|
+
console.log(import_picocolors22.default.cyan(import_picocolors22.default.bold(headerRow(headers, widths))));
|
|
72392
|
+
console.log(import_picocolors22.default.dim(separator(widths)));
|
|
72316
72393
|
let prevLabel = "";
|
|
72317
72394
|
for (let i2 = 0;i2 < rows.length; i2++) {
|
|
72318
72395
|
const r2 = rows[i2];
|
|
72319
72396
|
if (showDetail && prevLabel && r2.label !== prevLabel) {
|
|
72320
|
-
console.log(
|
|
72397
|
+
console.log(import_picocolors22.default.dim(separator(widths)));
|
|
72321
72398
|
}
|
|
72322
72399
|
const displayLabel = r2.label !== prevLabel ? r2.label : "";
|
|
72323
72400
|
prevLabel = r2.label;
|
|
@@ -72326,38 +72403,38 @@ function renderGrouped(rows, groupBy, period, deltas) {
|
|
|
72326
72403
|
];
|
|
72327
72404
|
let colIdx = 1;
|
|
72328
72405
|
if (showDetail) {
|
|
72329
|
-
cells.push(` ${padRight(
|
|
72406
|
+
cells.push(` ${padRight(import_picocolors22.default.dim(r2.detail ?? ""), widths[colIdx])} `);
|
|
72330
72407
|
colIdx++;
|
|
72331
72408
|
}
|
|
72332
|
-
cells.push(` ${padLeft(
|
|
72409
|
+
cells.push(` ${padLeft(import_picocolors22.default.magenta(String(r2.calls)), widths[colIdx])} `);
|
|
72333
72410
|
colIdx++;
|
|
72334
72411
|
if (showBreakdown) {
|
|
72335
|
-
cells.push(` ${padLeft(
|
|
72412
|
+
cells.push(` ${padLeft(import_picocolors22.default.green(formatTokens(r2.tokens.input)), widths[colIdx])} `);
|
|
72336
72413
|
colIdx++;
|
|
72337
|
-
cells.push(` ${padLeft(
|
|
72414
|
+
cells.push(` ${padLeft(import_picocolors22.default.yellow(formatTokens(r2.tokens.output)), widths[colIdx])} `);
|
|
72338
72415
|
colIdx++;
|
|
72339
|
-
cells.push(` ${padLeft(
|
|
72416
|
+
cells.push(` ${padLeft(import_picocolors22.default.dim(formatTokens(r2.tokens.cacheRead)), widths[colIdx])} `);
|
|
72340
72417
|
colIdx++;
|
|
72341
|
-
cells.push(` ${padLeft(
|
|
72418
|
+
cells.push(` ${padLeft(import_picocolors22.default.dim(formatTokens(r2.tokens.cacheWrite)), widths[colIdx])} `);
|
|
72342
72419
|
colIdx++;
|
|
72343
72420
|
}
|
|
72344
|
-
cells.push(` ${padLeft(
|
|
72421
|
+
cells.push(` ${padLeft(import_picocolors22.default.bold(formatTokens(r2.tokens.total)), widths[colIdx])} `);
|
|
72345
72422
|
colIdx++;
|
|
72346
|
-
cells.push(` ${padLeft(
|
|
72423
|
+
cells.push(` ${padLeft(import_picocolors22.default.red(formatCost(r2.cost)), widths[colIdx])} `);
|
|
72347
72424
|
colIdx++;
|
|
72348
72425
|
if (deltas) {
|
|
72349
72426
|
const d3 = deltas[i2];
|
|
72350
|
-
const deltaStr = d3 !== undefined ? formatDelta(d3) :
|
|
72427
|
+
const deltaStr = d3 !== undefined ? formatDelta(d3) : import_picocolors22.default.dim("-");
|
|
72351
72428
|
cells.push(` ${padLeft(deltaStr, widths[colIdx])} `);
|
|
72352
72429
|
}
|
|
72353
72430
|
console.log("\u2502" + cells.join("\u2502") + "\u2502");
|
|
72354
72431
|
}
|
|
72355
|
-
console.log(
|
|
72432
|
+
console.log(import_picocolors22.default.dim(bottomBorder(widths)));
|
|
72356
72433
|
}
|
|
72357
72434
|
function renderNoData() {
|
|
72358
72435
|
console.log();
|
|
72359
|
-
console.log(
|
|
72360
|
-
console.log(
|
|
72436
|
+
console.log(import_picocolors22.default.yellow("No usage data found for the specified period."));
|
|
72437
|
+
console.log(import_picocolors22.default.dim("Make sure OpenCode has been used and the database exists."));
|
|
72361
72438
|
}
|
|
72362
72439
|
|
|
72363
72440
|
// src/cli/usage/report-generator.ts
|
|
@@ -72634,6 +72711,987 @@ Examples:
|
|
|
72634
72711
|
});
|
|
72635
72712
|
return usage;
|
|
72636
72713
|
}
|
|
72714
|
+
// src/cli/copilot-x.ts
|
|
72715
|
+
var import_picocolors24 = __toESM(require_picocolors(), 1);
|
|
72716
|
+
// src/features/copilot-account-switcher/store.ts
|
|
72717
|
+
import path11 from "path";
|
|
72718
|
+
import os5 from "os";
|
|
72719
|
+
import { promises as fs11 } from "fs";
|
|
72720
|
+
var STORE_FILENAME = "copilot-x.json";
|
|
72721
|
+
var AUTH_FILENAME = "auth.json";
|
|
72722
|
+
function getXdgConfigDir() {
|
|
72723
|
+
return process.env.XDG_CONFIG_HOME ?? path11.join(os5.homedir(), ".config");
|
|
72724
|
+
}
|
|
72725
|
+
function getXdgDataDir() {
|
|
72726
|
+
return process.env.XDG_DATA_HOME ?? path11.join(os5.homedir(), ".local", "share");
|
|
72727
|
+
}
|
|
72728
|
+
function storePath() {
|
|
72729
|
+
return path11.join(getXdgConfigDir(), "opencode", STORE_FILENAME);
|
|
72730
|
+
}
|
|
72731
|
+
function authPath() {
|
|
72732
|
+
return path11.join(getXdgDataDir(), "opencode", AUTH_FILENAME);
|
|
72733
|
+
}
|
|
72734
|
+
function parseStore(raw) {
|
|
72735
|
+
const data = raw ? JSON.parse(raw) : { accounts: {} };
|
|
72736
|
+
if (!data.accounts)
|
|
72737
|
+
data.accounts = {};
|
|
72738
|
+
if (data.loopSafetyEnabled !== true)
|
|
72739
|
+
data.loopSafetyEnabled = false;
|
|
72740
|
+
if (data.networkRetryEnabled !== true)
|
|
72741
|
+
data.networkRetryEnabled = false;
|
|
72742
|
+
for (const [name, entry] of Object.entries(data.accounts)) {
|
|
72743
|
+
if (!entry.name)
|
|
72744
|
+
entry.name = name;
|
|
72745
|
+
}
|
|
72746
|
+
return data;
|
|
72747
|
+
}
|
|
72748
|
+
async function readStore2(filePath = storePath()) {
|
|
72749
|
+
const raw = await fs11.readFile(filePath, "utf-8").catch((error48) => {
|
|
72750
|
+
if (error48.code === "ENOENT")
|
|
72751
|
+
return "";
|
|
72752
|
+
throw error48;
|
|
72753
|
+
});
|
|
72754
|
+
return parseStore(raw);
|
|
72755
|
+
}
|
|
72756
|
+
async function writeStore2(store2, filePath = storePath()) {
|
|
72757
|
+
await fs11.mkdir(path11.dirname(filePath), { recursive: true });
|
|
72758
|
+
await fs11.writeFile(filePath, JSON.stringify(store2, null, 2), { mode: 384 });
|
|
72759
|
+
}
|
|
72760
|
+
async function writeAuthEntry(entry) {
|
|
72761
|
+
const filePath = path11.join(getXdgDataDir(), "opencode", AUTH_FILENAME);
|
|
72762
|
+
let existing = {};
|
|
72763
|
+
try {
|
|
72764
|
+
const raw = await fs11.readFile(filePath, "utf-8");
|
|
72765
|
+
existing = JSON.parse(raw);
|
|
72766
|
+
} catch {
|
|
72767
|
+
existing = {};
|
|
72768
|
+
}
|
|
72769
|
+
const providerId = entry.enterpriseUrl ? "github-copilot-enterprise" : "github-copilot";
|
|
72770
|
+
existing[providerId] = {
|
|
72771
|
+
type: "oauth",
|
|
72772
|
+
refresh: entry.refresh,
|
|
72773
|
+
access: entry.access,
|
|
72774
|
+
expires: entry.expires,
|
|
72775
|
+
...entry.enterpriseUrl ? { enterpriseUrl: entry.enterpriseUrl } : {}
|
|
72776
|
+
};
|
|
72777
|
+
await fs11.mkdir(path11.dirname(filePath), { recursive: true });
|
|
72778
|
+
await fs11.writeFile(filePath, JSON.stringify(existing, null, 2), { mode: 384 });
|
|
72779
|
+
}
|
|
72780
|
+
async function readAuth(filePath) {
|
|
72781
|
+
const dataFile = path11.join(getXdgDataDir(), "opencode", AUTH_FILENAME);
|
|
72782
|
+
const configFile = path11.join(getXdgConfigDir(), "opencode", AUTH_FILENAME);
|
|
72783
|
+
const files = filePath ? [filePath] : [dataFile, configFile];
|
|
72784
|
+
let raw = "";
|
|
72785
|
+
for (const file2 of files) {
|
|
72786
|
+
raw = await fs11.readFile(file2, "utf-8").catch(() => "");
|
|
72787
|
+
if (raw)
|
|
72788
|
+
break;
|
|
72789
|
+
}
|
|
72790
|
+
if (!raw)
|
|
72791
|
+
return {};
|
|
72792
|
+
const parsed = JSON.parse(raw);
|
|
72793
|
+
const copilotKeys = new Set(["github-copilot", "github-copilot-enterprise"]);
|
|
72794
|
+
return Object.entries(parsed).reduce((acc, [key, value]) => {
|
|
72795
|
+
if (!copilotKeys.has(key))
|
|
72796
|
+
return acc;
|
|
72797
|
+
if (!value || typeof value !== "object")
|
|
72798
|
+
return acc;
|
|
72799
|
+
const info = value;
|
|
72800
|
+
if (info.type !== "oauth" || !(info.refresh || info.access))
|
|
72801
|
+
return acc;
|
|
72802
|
+
acc[key] = {
|
|
72803
|
+
name: `auth:${key}`,
|
|
72804
|
+
refresh: info.refresh ?? info.access,
|
|
72805
|
+
access: info.access ?? info.refresh,
|
|
72806
|
+
expires: info.expires ?? 0,
|
|
72807
|
+
enterpriseUrl: info.enterpriseUrl,
|
|
72808
|
+
source: "auth",
|
|
72809
|
+
providerId: key
|
|
72810
|
+
};
|
|
72811
|
+
return acc;
|
|
72812
|
+
}, {});
|
|
72813
|
+
}
|
|
72814
|
+
// src/features/copilot-account-switcher/copilot-auth.ts
|
|
72815
|
+
init_shared();
|
|
72816
|
+
var CLIENT_ID = "Ov23li8tweQw6odWQebz";
|
|
72817
|
+
var OAUTH_POLLING_SAFETY_MARGIN_MS = 3000;
|
|
72818
|
+
var TOKEN_EXPIRY_BUFFER_MS = 5 * 60 * 1000;
|
|
72819
|
+
function getGitHubToken(entry) {
|
|
72820
|
+
const ghPrefixes = ["ghu_", "gho_", "ghp_", "github_pat_"];
|
|
72821
|
+
const isGhToken = (t) => ghPrefixes.some((p2) => t.startsWith(p2));
|
|
72822
|
+
if (entry.access && isGhToken(entry.access))
|
|
72823
|
+
return entry.access;
|
|
72824
|
+
if (entry.refresh && isGhToken(entry.refresh))
|
|
72825
|
+
return entry.refresh;
|
|
72826
|
+
if (entry.refresh?.startsWith("ghr_") && entry.access && !entry.access.startsWith("ghr_")) {
|
|
72827
|
+
return entry.access;
|
|
72828
|
+
}
|
|
72829
|
+
return entry.refresh || entry.access;
|
|
72830
|
+
}
|
|
72831
|
+
function isTokenExpired(entry) {
|
|
72832
|
+
if (!entry.expires || entry.expires <= 0)
|
|
72833
|
+
return false;
|
|
72834
|
+
return entry.expires < Date.now() + TOKEN_EXPIRY_BUFFER_MS;
|
|
72835
|
+
}
|
|
72836
|
+
async function refreshAccessToken(entry) {
|
|
72837
|
+
if (!entry.refresh?.startsWith("ghr_"))
|
|
72838
|
+
return false;
|
|
72839
|
+
const domain2 = entry.enterpriseUrl ? normalizeDomain(entry.enterpriseUrl) : "github.com";
|
|
72840
|
+
const url2 = `https://${domain2}/login/oauth/access_token`;
|
|
72841
|
+
try {
|
|
72842
|
+
const res = await fetch(url2, {
|
|
72843
|
+
method: "POST",
|
|
72844
|
+
headers: {
|
|
72845
|
+
Accept: "application/json",
|
|
72846
|
+
"Content-Type": "application/json"
|
|
72847
|
+
},
|
|
72848
|
+
body: JSON.stringify({
|
|
72849
|
+
client_id: CLIENT_ID,
|
|
72850
|
+
grant_type: "refresh_token",
|
|
72851
|
+
refresh_token: entry.refresh
|
|
72852
|
+
})
|
|
72853
|
+
});
|
|
72854
|
+
if (!res.ok) {
|
|
72855
|
+
log("[copilot-auth] token refresh HTTP error", { status: res.status });
|
|
72856
|
+
return false;
|
|
72857
|
+
}
|
|
72858
|
+
const data = await res.json();
|
|
72859
|
+
if (data.error || !data.access_token) {
|
|
72860
|
+
log("[copilot-auth] token refresh failed", { error: data.error });
|
|
72861
|
+
return false;
|
|
72862
|
+
}
|
|
72863
|
+
entry.access = data.access_token;
|
|
72864
|
+
if (data.refresh_token)
|
|
72865
|
+
entry.refresh = data.refresh_token;
|
|
72866
|
+
entry.expires = data.expires_in ? Date.now() + data.expires_in * 1000 : 0;
|
|
72867
|
+
log("[copilot-auth] token refreshed successfully");
|
|
72868
|
+
return true;
|
|
72869
|
+
} catch (error48) {
|
|
72870
|
+
log("[copilot-auth] token refresh error", { error: String(error48) });
|
|
72871
|
+
return false;
|
|
72872
|
+
}
|
|
72873
|
+
}
|
|
72874
|
+
function hasUnknownExpiry(entry) {
|
|
72875
|
+
return !entry.expires || entry.expires <= 0;
|
|
72876
|
+
}
|
|
72877
|
+
async function getValidToken(entry) {
|
|
72878
|
+
if (entry.refresh?.startsWith("ghr_") && (isTokenExpired(entry) || hasUnknownExpiry(entry))) {
|
|
72879
|
+
await refreshAccessToken(entry);
|
|
72880
|
+
}
|
|
72881
|
+
return getGitHubToken(entry);
|
|
72882
|
+
}
|
|
72883
|
+
function normalizeDomain(url2) {
|
|
72884
|
+
return url2.replace(/^https?:\/\//, "").replace(/\/$/, "");
|
|
72885
|
+
}
|
|
72886
|
+
function getUrls(domain2) {
|
|
72887
|
+
return {
|
|
72888
|
+
DEVICE_CODE_URL: `https://${domain2}/login/device/code`,
|
|
72889
|
+
ACCESS_TOKEN_URL: `https://${domain2}/login/oauth/access_token`
|
|
72890
|
+
};
|
|
72891
|
+
}
|
|
72892
|
+
function sleep(ms) {
|
|
72893
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
72894
|
+
}
|
|
72895
|
+
function buildSnapshot(raw) {
|
|
72896
|
+
if (!raw)
|
|
72897
|
+
return;
|
|
72898
|
+
const entitlement = raw.entitlement;
|
|
72899
|
+
const remaining = raw.remaining;
|
|
72900
|
+
const used = raw.used ?? (entitlement !== undefined && remaining !== undefined ? entitlement - remaining : undefined);
|
|
72901
|
+
return {
|
|
72902
|
+
entitlement,
|
|
72903
|
+
remaining,
|
|
72904
|
+
used,
|
|
72905
|
+
unlimited: raw.unlimited,
|
|
72906
|
+
percentRemaining: raw.percent_remaining
|
|
72907
|
+
};
|
|
72908
|
+
}
|
|
72909
|
+
async function fetchUser(entry) {
|
|
72910
|
+
try {
|
|
72911
|
+
const token = await getValidToken(entry);
|
|
72912
|
+
const base = entry.enterpriseUrl ? `https://api.${normalizeDomain(entry.enterpriseUrl)}` : "https://api.github.com";
|
|
72913
|
+
const headers = {
|
|
72914
|
+
Accept: "application/json",
|
|
72915
|
+
Authorization: `token ${token}`
|
|
72916
|
+
};
|
|
72917
|
+
const userRes = await fetch(`${base}/user`, { headers });
|
|
72918
|
+
if (!userRes.ok)
|
|
72919
|
+
return;
|
|
72920
|
+
const userData = await userRes.json();
|
|
72921
|
+
const login2 = userData.login;
|
|
72922
|
+
let email3 = userData.email;
|
|
72923
|
+
if (!email3) {
|
|
72924
|
+
try {
|
|
72925
|
+
const emailRes = await fetch(`${base}/user/emails`, { headers });
|
|
72926
|
+
if (emailRes.ok) {
|
|
72927
|
+
const items = await emailRes.json();
|
|
72928
|
+
const primary = items.find((item) => item.primary && item.verified);
|
|
72929
|
+
email3 = primary?.email ?? items[0]?.email;
|
|
72930
|
+
}
|
|
72931
|
+
} catch {
|
|
72932
|
+
log("[copilot-auth] failed to fetch emails");
|
|
72933
|
+
}
|
|
72934
|
+
}
|
|
72935
|
+
let orgs = [];
|
|
72936
|
+
try {
|
|
72937
|
+
const orgsRes = await fetch(`${base}/user/orgs`, { headers });
|
|
72938
|
+
if (orgsRes.ok) {
|
|
72939
|
+
const orgsData = await orgsRes.json();
|
|
72940
|
+
orgs = orgsData.map((o2) => o2.login).filter(Boolean);
|
|
72941
|
+
}
|
|
72942
|
+
} catch {
|
|
72943
|
+
log("[copilot-auth] failed to fetch orgs");
|
|
72944
|
+
}
|
|
72945
|
+
return { login: login2, email: email3, orgs };
|
|
72946
|
+
} catch (error48) {
|
|
72947
|
+
log("[copilot-auth] fetchUser failed", { error: String(error48) });
|
|
72948
|
+
return;
|
|
72949
|
+
}
|
|
72950
|
+
}
|
|
72951
|
+
async function fetchQuota(entry) {
|
|
72952
|
+
try {
|
|
72953
|
+
const token = await getValidToken(entry);
|
|
72954
|
+
const headers = {
|
|
72955
|
+
Accept: "application/json",
|
|
72956
|
+
Authorization: `token ${token}`,
|
|
72957
|
+
"User-Agent": "GitHubCopilotChat/0.26.7",
|
|
72958
|
+
"Editor-Version": "vscode/1.96.2",
|
|
72959
|
+
"Copilot-Integration-Id": "vscode-chat",
|
|
72960
|
+
"X-Github-Api-Version": "2025-04-01"
|
|
72961
|
+
};
|
|
72962
|
+
const base = entry.enterpriseUrl ? `https://api.${normalizeDomain(entry.enterpriseUrl)}` : "https://api.github.com";
|
|
72963
|
+
const res = await fetch(`${base}/copilot_internal/user`, { headers });
|
|
72964
|
+
if (!res.ok) {
|
|
72965
|
+
return { error: `quota ${res.status}`, updatedAt: Date.now() };
|
|
72966
|
+
}
|
|
72967
|
+
const data = await res.json();
|
|
72968
|
+
return {
|
|
72969
|
+
sku: data.access_type_sku,
|
|
72970
|
+
plan: data.copilot_plan,
|
|
72971
|
+
reset: data.quota_reset_date,
|
|
72972
|
+
updatedAt: Date.now(),
|
|
72973
|
+
snapshots: {
|
|
72974
|
+
premium: buildSnapshot(data.quota_snapshots?.premium_interactions),
|
|
72975
|
+
chat: buildSnapshot(data.quota_snapshots?.chat),
|
|
72976
|
+
completions: buildSnapshot(data.quota_snapshots?.completions)
|
|
72977
|
+
}
|
|
72978
|
+
};
|
|
72979
|
+
} catch (error48) {
|
|
72980
|
+
log("[copilot-auth] fetchQuota failed", { error: String(error48) });
|
|
72981
|
+
return { error: String(error48), updatedAt: Date.now() };
|
|
72982
|
+
}
|
|
72983
|
+
}
|
|
72984
|
+
function parseModels(modelData) {
|
|
72985
|
+
const available = [];
|
|
72986
|
+
const disabled = [];
|
|
72987
|
+
for (const item of modelData.data ?? []) {
|
|
72988
|
+
if (!item.id)
|
|
72989
|
+
continue;
|
|
72990
|
+
const enabled = item.model_picker_enabled === true && item.policy?.state !== "disabled";
|
|
72991
|
+
if (enabled)
|
|
72992
|
+
available.push(item.id);
|
|
72993
|
+
else
|
|
72994
|
+
disabled.push(item.id);
|
|
72995
|
+
}
|
|
72996
|
+
return { available, disabled };
|
|
72997
|
+
}
|
|
72998
|
+
async function fetchModels(entry) {
|
|
72999
|
+
try {
|
|
73000
|
+
const modelsUrl = entry.enterpriseUrl ? `https://copilot-api.${normalizeDomain(entry.enterpriseUrl)}/models` : "https://api.githubcopilot.com/models";
|
|
73001
|
+
const modelsHeaders = {
|
|
73002
|
+
Accept: "application/json",
|
|
73003
|
+
Authorization: `Bearer ${entry.access}`,
|
|
73004
|
+
"User-Agent": "GitHubCopilotChat/0.26.7",
|
|
73005
|
+
"Editor-Version": "vscode/1.96.2",
|
|
73006
|
+
"Editor-Plugin-Version": "copilot/1.159.0",
|
|
73007
|
+
"Copilot-Integration-Id": "vscode-chat",
|
|
73008
|
+
"X-Github-Api-Version": "2025-04-01"
|
|
73009
|
+
};
|
|
73010
|
+
const modelRes = await fetch(modelsUrl, { headers: modelsHeaders });
|
|
73011
|
+
if (modelRes.ok) {
|
|
73012
|
+
return parseModels(await modelRes.json());
|
|
73013
|
+
}
|
|
73014
|
+
const token = await getValidToken(entry);
|
|
73015
|
+
const base = entry.enterpriseUrl ? `https://api.${normalizeDomain(entry.enterpriseUrl)}` : "https://api.github.com";
|
|
73016
|
+
const tokenRes = await fetch(`${base}/copilot_internal/v2/token`, {
|
|
73017
|
+
headers: {
|
|
73018
|
+
Accept: "application/json",
|
|
73019
|
+
Authorization: `token ${token}`,
|
|
73020
|
+
"User-Agent": "GitHubCopilotChat/0.26.7",
|
|
73021
|
+
"Editor-Version": "vscode/1.96.2",
|
|
73022
|
+
"Editor-Plugin-Version": "copilot/1.159.0",
|
|
73023
|
+
"X-Github-Api-Version": "2025-04-01"
|
|
73024
|
+
}
|
|
73025
|
+
});
|
|
73026
|
+
if (!tokenRes.ok)
|
|
73027
|
+
return { error: `token ${tokenRes.status}` };
|
|
73028
|
+
const tokenData = await tokenRes.json();
|
|
73029
|
+
if (!tokenData.token)
|
|
73030
|
+
return { error: "token missing" };
|
|
73031
|
+
entry.access = tokenData.token;
|
|
73032
|
+
if (tokenData.expires_at)
|
|
73033
|
+
entry.expires = tokenData.expires_at * 1000;
|
|
73034
|
+
const fallbackRes = await fetch(modelsUrl, {
|
|
73035
|
+
headers: {
|
|
73036
|
+
...modelsHeaders,
|
|
73037
|
+
Authorization: `Bearer ${tokenData.token}`
|
|
73038
|
+
}
|
|
73039
|
+
});
|
|
73040
|
+
if (!fallbackRes.ok)
|
|
73041
|
+
return { error: `models ${fallbackRes.status}` };
|
|
73042
|
+
return parseModels(await fallbackRes.json());
|
|
73043
|
+
} catch (error48) {
|
|
73044
|
+
return { error: error48 instanceof Error ? error48.message : String(error48) };
|
|
73045
|
+
}
|
|
73046
|
+
}
|
|
73047
|
+
async function loginOauth(deployment, enterpriseUrl) {
|
|
73048
|
+
const domain2 = deployment === "enterprise" ? normalizeDomain(enterpriseUrl ?? "") : "github.com";
|
|
73049
|
+
const urls = getUrls(domain2);
|
|
73050
|
+
const deviceResponse = await fetch(urls.DEVICE_CODE_URL, {
|
|
73051
|
+
method: "POST",
|
|
73052
|
+
headers: {
|
|
73053
|
+
Accept: "application/json",
|
|
73054
|
+
"Content-Type": "application/json"
|
|
73055
|
+
},
|
|
73056
|
+
body: JSON.stringify({
|
|
73057
|
+
client_id: CLIENT_ID,
|
|
73058
|
+
scope: "read:user user:email"
|
|
73059
|
+
})
|
|
73060
|
+
});
|
|
73061
|
+
if (!deviceResponse.ok)
|
|
73062
|
+
throw new Error("Failed to initiate device authorization");
|
|
73063
|
+
const deviceData = await deviceResponse.json();
|
|
73064
|
+
console.log(`Go to: ${deviceData.verification_uri}`);
|
|
73065
|
+
console.log(`Enter code: ${deviceData.user_code}`);
|
|
73066
|
+
while (true) {
|
|
73067
|
+
const response = await fetch(urls.ACCESS_TOKEN_URL, {
|
|
73068
|
+
method: "POST",
|
|
73069
|
+
headers: {
|
|
73070
|
+
Accept: "application/json",
|
|
73071
|
+
"Content-Type": "application/json"
|
|
73072
|
+
},
|
|
73073
|
+
body: JSON.stringify({
|
|
73074
|
+
client_id: CLIENT_ID,
|
|
73075
|
+
device_code: deviceData.device_code,
|
|
73076
|
+
grant_type: "urn:ietf:params:oauth:grant-type:device_code"
|
|
73077
|
+
})
|
|
73078
|
+
});
|
|
73079
|
+
if (!response.ok)
|
|
73080
|
+
throw new Error("Failed to poll token");
|
|
73081
|
+
const data = await response.json();
|
|
73082
|
+
if (data.access_token) {
|
|
73083
|
+
const entry = {
|
|
73084
|
+
name: deployment === "enterprise" ? `enterprise:${domain2}` : "github.com",
|
|
73085
|
+
refresh: data.access_token,
|
|
73086
|
+
access: data.access_token,
|
|
73087
|
+
expires: 0,
|
|
73088
|
+
enterpriseUrl: deployment === "enterprise" ? domain2 : undefined,
|
|
73089
|
+
addedAt: Date.now(),
|
|
73090
|
+
source: "auth"
|
|
73091
|
+
};
|
|
73092
|
+
const user = await fetchUser(entry);
|
|
73093
|
+
if (user?.login)
|
|
73094
|
+
entry.user = user.login;
|
|
73095
|
+
if (user?.email)
|
|
73096
|
+
entry.email = user.email;
|
|
73097
|
+
if (user?.orgs?.length)
|
|
73098
|
+
entry.orgs = user.orgs;
|
|
73099
|
+
return entry;
|
|
73100
|
+
}
|
|
73101
|
+
if (data.error === "authorization_pending") {
|
|
73102
|
+
await sleep(deviceData.interval * 1000 + OAUTH_POLLING_SAFETY_MARGIN_MS);
|
|
73103
|
+
continue;
|
|
73104
|
+
}
|
|
73105
|
+
if (data.error === "slow_down") {
|
|
73106
|
+
const serverInterval = data.interval;
|
|
73107
|
+
const next = (serverInterval && serverInterval > 0 ? serverInterval : deviceData.interval + 5) * 1000;
|
|
73108
|
+
await sleep(next + OAUTH_POLLING_SAFETY_MARGIN_MS);
|
|
73109
|
+
continue;
|
|
73110
|
+
}
|
|
73111
|
+
throw new Error("Authorization failed");
|
|
73112
|
+
}
|
|
73113
|
+
}
|
|
73114
|
+
// src/features/copilot-account-switcher/copilot-network-retry.ts
|
|
73115
|
+
init_shared();
|
|
73116
|
+
var defaultDebugLogFile = (() => {
|
|
73117
|
+
const tmp = process.env.TEMP || process.env.TMP || "/tmp";
|
|
73118
|
+
return `${tmp}/opencode-copilot-retry-debug.log`;
|
|
73119
|
+
})();
|
|
73120
|
+
// src/features/copilot-account-switcher/copilot-session-repair.ts
|
|
73121
|
+
init_shared();
|
|
73122
|
+
var POST_SWITCH_WINDOW_MS = 5 * 60 * 1000;
|
|
73123
|
+
// src/features/copilot-account-switcher/copilot-auth-hook.ts
|
|
73124
|
+
init_shared();
|
|
73125
|
+
|
|
73126
|
+
// src/features/copilot-account-switcher/copilot-device-flow.ts
|
|
73127
|
+
init_shared();
|
|
73128
|
+
// src/features/copilot-account-switcher/account-manager.ts
|
|
73129
|
+
init_shared();
|
|
73130
|
+
function normalizeDomain2(url2) {
|
|
73131
|
+
return url2.replace(/^https?:\/\//, "").replace(/\/$/, "");
|
|
73132
|
+
}
|
|
73133
|
+
function buildName(entry, login2) {
|
|
73134
|
+
const user = login2 ?? entry.user;
|
|
73135
|
+
if (!user)
|
|
73136
|
+
return entry.name;
|
|
73137
|
+
if (!entry.enterpriseUrl)
|
|
73138
|
+
return user;
|
|
73139
|
+
const host = normalizeDomain2(entry.enterpriseUrl);
|
|
73140
|
+
return `${host}:${user}`;
|
|
73141
|
+
}
|
|
73142
|
+
function score(entry) {
|
|
73143
|
+
return (entry.user ? 2 : 0) + (entry.email ? 2 : 0) + (entry.orgs?.length ? 1 : 0);
|
|
73144
|
+
}
|
|
73145
|
+
function dedupeKey(entry) {
|
|
73146
|
+
if (entry.refresh)
|
|
73147
|
+
return `refresh:${entry.refresh}`;
|
|
73148
|
+
return;
|
|
73149
|
+
}
|
|
73150
|
+
function toAccountInfo(name, entry, index, active) {
|
|
73151
|
+
const status2 = entry.expires && entry.expires > 0 && entry.expires < Date.now() ? "expired" : "active";
|
|
73152
|
+
const labelName = name.startsWith("github.com:") ? name.slice("github.com:".length) : name;
|
|
73153
|
+
const hasUser = entry.user ? labelName.includes(entry.user) : false;
|
|
73154
|
+
const suffix = entry.user ? hasUser ? "" : ` (${entry.user})` : entry.email ? ` (${entry.email})` : "";
|
|
73155
|
+
const label = `${labelName}${suffix}`;
|
|
73156
|
+
return {
|
|
73157
|
+
name: label,
|
|
73158
|
+
index,
|
|
73159
|
+
addedAt: entry.addedAt,
|
|
73160
|
+
lastUsed: entry.lastUsed,
|
|
73161
|
+
status: status2,
|
|
73162
|
+
isCurrent: active === name
|
|
73163
|
+
};
|
|
73164
|
+
}
|
|
73165
|
+
function dedupeAccounts(store2) {
|
|
73166
|
+
const seen = new Map;
|
|
73167
|
+
for (const [name, entry] of Object.entries(store2.accounts)) {
|
|
73168
|
+
const k3 = dedupeKey(entry);
|
|
73169
|
+
if (!k3)
|
|
73170
|
+
continue;
|
|
73171
|
+
const current = seen.get(k3);
|
|
73172
|
+
if (!current) {
|
|
73173
|
+
seen.set(k3, name);
|
|
73174
|
+
continue;
|
|
73175
|
+
}
|
|
73176
|
+
const currentEntry = store2.accounts[current];
|
|
73177
|
+
if (score(entry) > score(currentEntry)) {
|
|
73178
|
+
delete store2.accounts[current];
|
|
73179
|
+
seen.set(k3, name);
|
|
73180
|
+
if (store2.active === current)
|
|
73181
|
+
store2.active = name;
|
|
73182
|
+
continue;
|
|
73183
|
+
}
|
|
73184
|
+
delete store2.accounts[name];
|
|
73185
|
+
if (store2.active === name)
|
|
73186
|
+
store2.active = current;
|
|
73187
|
+
}
|
|
73188
|
+
}
|
|
73189
|
+
function mergeAuthEntries(store2, imported) {
|
|
73190
|
+
dedupeAccounts(store2);
|
|
73191
|
+
const byRefresh = new Map;
|
|
73192
|
+
for (const [name, entry] of Object.entries(store2.accounts)) {
|
|
73193
|
+
if (entry.refresh)
|
|
73194
|
+
byRefresh.set(entry.refresh, name);
|
|
73195
|
+
}
|
|
73196
|
+
for (const [key, entry] of imported) {
|
|
73197
|
+
const match = byRefresh.get(entry.refresh);
|
|
73198
|
+
if (match) {
|
|
73199
|
+
store2.accounts[match] = {
|
|
73200
|
+
...store2.accounts[match],
|
|
73201
|
+
...entry,
|
|
73202
|
+
name: store2.accounts[match].name,
|
|
73203
|
+
source: "auth",
|
|
73204
|
+
providerId: key
|
|
73205
|
+
};
|
|
73206
|
+
if (!store2.active)
|
|
73207
|
+
store2.active = match;
|
|
73208
|
+
continue;
|
|
73209
|
+
}
|
|
73210
|
+
const name = entry.name || `auth:${key}`;
|
|
73211
|
+
store2.accounts[name] = {
|
|
73212
|
+
...entry,
|
|
73213
|
+
name,
|
|
73214
|
+
source: "auth",
|
|
73215
|
+
providerId: key
|
|
73216
|
+
};
|
|
73217
|
+
if (!store2.active)
|
|
73218
|
+
store2.active = name;
|
|
73219
|
+
}
|
|
73220
|
+
}
|
|
73221
|
+
async function importFromAuth(authFilePath) {
|
|
73222
|
+
const store2 = await readStore2();
|
|
73223
|
+
const authEntries = await readAuth(authFilePath);
|
|
73224
|
+
const entries = Object.entries(authEntries);
|
|
73225
|
+
mergeAuthEntries(store2, entries);
|
|
73226
|
+
await writeStore2(store2);
|
|
73227
|
+
return { store: store2, imported: entries.length };
|
|
73228
|
+
}
|
|
73229
|
+
async function switchAccount(accountName, client3) {
|
|
73230
|
+
const store2 = await readStore2();
|
|
73231
|
+
if (!store2.accounts[accountName]) {
|
|
73232
|
+
throw new Error(`Account not found: ${accountName}`);
|
|
73233
|
+
}
|
|
73234
|
+
store2.active = accountName;
|
|
73235
|
+
store2.accounts[accountName].lastUsed = Date.now();
|
|
73236
|
+
store2.lastAccountSwitchAt = Date.now();
|
|
73237
|
+
await writeStore2(store2);
|
|
73238
|
+
await writeAuthEntry(store2.accounts[accountName]);
|
|
73239
|
+
if (client3) {
|
|
73240
|
+
await switchAccountWithClient(client3, store2.accounts[accountName]);
|
|
73241
|
+
}
|
|
73242
|
+
return store2;
|
|
73243
|
+
}
|
|
73244
|
+
async function removeAccount(accountName) {
|
|
73245
|
+
const store2 = await readStore2();
|
|
73246
|
+
delete store2.accounts[accountName];
|
|
73247
|
+
if (store2.active === accountName) {
|
|
73248
|
+
const remaining = Object.keys(store2.accounts);
|
|
73249
|
+
store2.active = remaining.length > 0 ? remaining[0] : undefined;
|
|
73250
|
+
}
|
|
73251
|
+
await writeStore2(store2);
|
|
73252
|
+
return store2;
|
|
73253
|
+
}
|
|
73254
|
+
async function removeAllAccounts() {
|
|
73255
|
+
const store2 = await readStore2();
|
|
73256
|
+
store2.accounts = {};
|
|
73257
|
+
store2.active = undefined;
|
|
73258
|
+
await writeStore2(store2);
|
|
73259
|
+
return store2;
|
|
73260
|
+
}
|
|
73261
|
+
async function addAccount(entry) {
|
|
73262
|
+
const store2 = await readStore2();
|
|
73263
|
+
const name = entry.name || `account-${Object.keys(store2.accounts).length + 1}`;
|
|
73264
|
+
store2.accounts[name] = { ...entry, name };
|
|
73265
|
+
if (!store2.active)
|
|
73266
|
+
store2.active = name;
|
|
73267
|
+
await writeStore2(store2);
|
|
73268
|
+
return store2;
|
|
73269
|
+
}
|
|
73270
|
+
async function checkQuotas() {
|
|
73271
|
+
const store2 = await readStore2();
|
|
73272
|
+
for (const [, entry] of Object.entries(store2.accounts)) {
|
|
73273
|
+
const quota = await fetchQuota(entry);
|
|
73274
|
+
if (quota)
|
|
73275
|
+
entry.quota = quota;
|
|
73276
|
+
}
|
|
73277
|
+
store2.lastQuotaRefresh = Date.now();
|
|
73278
|
+
await writeStore2(store2);
|
|
73279
|
+
return store2;
|
|
73280
|
+
}
|
|
73281
|
+
async function checkModels2() {
|
|
73282
|
+
const store2 = await readStore2();
|
|
73283
|
+
for (const [, entry] of Object.entries(store2.accounts)) {
|
|
73284
|
+
const result = await fetchModels(entry);
|
|
73285
|
+
if ("error" in result) {
|
|
73286
|
+
entry.models = { available: [], disabled: [], error: result.error, updatedAt: Date.now() };
|
|
73287
|
+
} else {
|
|
73288
|
+
entry.models = { ...result, updatedAt: Date.now() };
|
|
73289
|
+
}
|
|
73290
|
+
}
|
|
73291
|
+
await writeStore2(store2);
|
|
73292
|
+
return store2;
|
|
73293
|
+
}
|
|
73294
|
+
async function refreshIdentity() {
|
|
73295
|
+
const store2 = await readStore2();
|
|
73296
|
+
const items = await Promise.all(Object.entries(store2.accounts).map(async ([name, entry]) => {
|
|
73297
|
+
const user = await fetchUser(entry);
|
|
73298
|
+
const base = buildName(entry, user?.login ?? entry.user);
|
|
73299
|
+
return {
|
|
73300
|
+
oldName: name,
|
|
73301
|
+
base,
|
|
73302
|
+
entry: {
|
|
73303
|
+
...entry,
|
|
73304
|
+
user: user?.login ?? entry.user,
|
|
73305
|
+
email: user?.email ?? entry.email,
|
|
73306
|
+
orgs: user?.orgs ?? entry.orgs,
|
|
73307
|
+
name: base
|
|
73308
|
+
}
|
|
73309
|
+
};
|
|
73310
|
+
}));
|
|
73311
|
+
const counts = new Map;
|
|
73312
|
+
const renamed2 = items.map((item) => {
|
|
73313
|
+
const count = (counts.get(item.base) ?? 0) + 1;
|
|
73314
|
+
counts.set(item.base, count);
|
|
73315
|
+
const name = count === 1 ? item.base : `${item.base}#${count}`;
|
|
73316
|
+
return { ...item, name, entry: { ...item.entry, name } };
|
|
73317
|
+
});
|
|
73318
|
+
store2.accounts = renamed2.reduce((acc, item) => {
|
|
73319
|
+
acc[item.name] = item.entry;
|
|
73320
|
+
return acc;
|
|
73321
|
+
}, {});
|
|
73322
|
+
const active = renamed2.find((item) => item.oldName === store2.active);
|
|
73323
|
+
if (active)
|
|
73324
|
+
store2.active = active.name;
|
|
73325
|
+
await writeStore2(store2);
|
|
73326
|
+
return store2;
|
|
73327
|
+
}
|
|
73328
|
+
async function switchAccountWithClient(client3, entry) {
|
|
73329
|
+
const providerId = entry.enterpriseUrl ? "github-copilot-enterprise" : "github-copilot";
|
|
73330
|
+
const payload = {
|
|
73331
|
+
type: "oauth",
|
|
73332
|
+
refresh: entry.refresh,
|
|
73333
|
+
access: entry.access,
|
|
73334
|
+
expires: entry.expires,
|
|
73335
|
+
...entry.enterpriseUrl ? { enterpriseUrl: entry.enterpriseUrl } : {}
|
|
73336
|
+
};
|
|
73337
|
+
try {
|
|
73338
|
+
await client3.auth.set({
|
|
73339
|
+
path: { id: providerId },
|
|
73340
|
+
body: payload
|
|
73341
|
+
});
|
|
73342
|
+
log("[copilot-account-switcher] runtime auth state updated", { provider: providerId });
|
|
73343
|
+
} catch (error48) {
|
|
73344
|
+
log("[copilot-account-switcher] failed to update runtime auth state", { error: String(error48) });
|
|
73345
|
+
}
|
|
73346
|
+
}
|
|
73347
|
+
// src/cli/copilot-account-display.ts
|
|
73348
|
+
var import_picocolors23 = __toESM(require_picocolors(), 1);
|
|
73349
|
+
function formatQuota(s) {
|
|
73350
|
+
if (!s)
|
|
73351
|
+
return import_picocolors23.default.dim("\u2014");
|
|
73352
|
+
if (s.unlimited)
|
|
73353
|
+
return import_picocolors23.default.green("\u267E\uFE0F");
|
|
73354
|
+
if (s.remaining !== undefined && s.entitlement !== undefined) {
|
|
73355
|
+
const pct = s.entitlement > 0 ? s.remaining / s.entitlement : 0;
|
|
73356
|
+
const text = `${s.remaining}/${s.entitlement}`;
|
|
73357
|
+
if (pct > 0.5)
|
|
73358
|
+
return import_picocolors23.default.green(text);
|
|
73359
|
+
if (pct > 0.2)
|
|
73360
|
+
return import_picocolors23.default.yellow(text);
|
|
73361
|
+
return import_picocolors23.default.red(text);
|
|
73362
|
+
}
|
|
73363
|
+
return import_picocolors23.default.dim("\u2014");
|
|
73364
|
+
}
|
|
73365
|
+
function formatRelativeTime(timestamp2) {
|
|
73366
|
+
if (!timestamp2)
|
|
73367
|
+
return import_picocolors23.default.dim("never");
|
|
73368
|
+
const days = Math.floor((Date.now() - timestamp2) / 86400000);
|
|
73369
|
+
if (days === 0)
|
|
73370
|
+
return "today";
|
|
73371
|
+
if (days === 1)
|
|
73372
|
+
return "yesterday";
|
|
73373
|
+
if (days < 7)
|
|
73374
|
+
return `${days}d ago`;
|
|
73375
|
+
if (days < 30)
|
|
73376
|
+
return `${Math.floor(days / 7)}w ago`;
|
|
73377
|
+
return new Date(timestamp2).toLocaleDateString();
|
|
73378
|
+
}
|
|
73379
|
+
function stripAnsi(s) {
|
|
73380
|
+
return s.replace(/\x1b\[[0-9;]*m/g, "");
|
|
73381
|
+
}
|
|
73382
|
+
function padVisual(s, width) {
|
|
73383
|
+
const visible = stripAnsi(s);
|
|
73384
|
+
return s + " ".repeat(Math.max(0, width - visible.length));
|
|
73385
|
+
}
|
|
73386
|
+
function buildAccountRows(store3) {
|
|
73387
|
+
return Object.entries(store3.accounts).map(([name, entry], idx) => {
|
|
73388
|
+
const info = toAccountInfo(name, entry, idx, store3.active);
|
|
73389
|
+
const nameStr = info.isCurrent ? import_picocolors23.default.green(import_picocolors23.default.bold(info.name)) : import_picocolors23.default.white(info.name);
|
|
73390
|
+
const statusStr = info.isCurrent ? import_picocolors23.default.green("active") : (info.status ?? "unknown") === "expired" ? import_picocolors23.default.red("expired") : import_picocolors23.default.dim("\u2014");
|
|
73391
|
+
const lastUsed = entry.lastUsed ? formatRelativeTime(entry.lastUsed) : import_picocolors23.default.dim("\u2014");
|
|
73392
|
+
const { premium, chat, completions } = entry.quota?.snapshots ?? {};
|
|
73393
|
+
return {
|
|
73394
|
+
name: nameStr,
|
|
73395
|
+
status: statusStr,
|
|
73396
|
+
lastUsed,
|
|
73397
|
+
premium: formatQuota(premium),
|
|
73398
|
+
chat: formatQuota(chat),
|
|
73399
|
+
completions: formatQuota(completions)
|
|
73400
|
+
};
|
|
73401
|
+
});
|
|
73402
|
+
}
|
|
73403
|
+
function buildAccountLines(store3) {
|
|
73404
|
+
const entries = Object.entries(store3.accounts);
|
|
73405
|
+
if (entries.length === 0)
|
|
73406
|
+
return import_picocolors23.default.dim(" No accounts configured. Add one to get started.");
|
|
73407
|
+
const rows = buildAccountRows(store3);
|
|
73408
|
+
const headers = { name: "Name", status: "Status", lastUsed: "Last Used", premium: "Premium", chat: "Chat", completions: "Comp" };
|
|
73409
|
+
const keys = ["name", "status", "lastUsed", "premium", "chat", "completions"];
|
|
73410
|
+
const widths = Object.fromEntries(keys.map((k3) => [k3, Math.max(stripAnsi(headers[k3]).length, ...rows.map((r2) => stripAnsi(r2[k3]).length))]));
|
|
73411
|
+
const headerLine = keys.map((k3) => padVisual(import_picocolors23.default.bold(headers[k3]), widths[k3])).join(" ");
|
|
73412
|
+
const separator2 = keys.map((k3) => import_picocolors23.default.dim("\u2500".repeat(widths[k3]))).join(" ");
|
|
73413
|
+
const dataLines = rows.map((row) => keys.map((k3) => padVisual(row[k3], widths[k3])).join(" "));
|
|
73414
|
+
return [headerLine, separator2, ...dataLines].join(`
|
|
73415
|
+
`);
|
|
73416
|
+
}
|
|
73417
|
+
var MODEL_FAMILIES = [
|
|
73418
|
+
{ prefix: "claude-opus", label: "Opus" },
|
|
73419
|
+
{ prefix: "claude-sonnet", label: "Sonnet" },
|
|
73420
|
+
{ prefix: "claude-haiku", label: "Haiku" },
|
|
73421
|
+
{ prefix: "gpt-5", label: "GPT-5" },
|
|
73422
|
+
{ prefix: "gpt-4", label: "GPT-4" },
|
|
73423
|
+
{ prefix: "gemini-3", label: "Gemini 3" },
|
|
73424
|
+
{ prefix: "gemini-2", label: "Gemini 2" },
|
|
73425
|
+
{ prefix: "grok", label: "Grok" }
|
|
73426
|
+
];
|
|
73427
|
+
function groupModelsByFamily(models) {
|
|
73428
|
+
const groups = [];
|
|
73429
|
+
const remaining = [...models];
|
|
73430
|
+
for (const family of MODEL_FAMILIES) {
|
|
73431
|
+
const matched = remaining.filter((m2) => m2.startsWith(family.prefix));
|
|
73432
|
+
if (matched.length > 0) {
|
|
73433
|
+
groups.push({ label: family.label, models: matched });
|
|
73434
|
+
for (const m2 of matched)
|
|
73435
|
+
remaining.splice(remaining.indexOf(m2), 1);
|
|
73436
|
+
}
|
|
73437
|
+
}
|
|
73438
|
+
if (remaining.length > 0) {
|
|
73439
|
+
groups.push({ label: "Other", models: remaining });
|
|
73440
|
+
}
|
|
73441
|
+
return groups;
|
|
73442
|
+
}
|
|
73443
|
+
function buildModelReport(store3) {
|
|
73444
|
+
const entries = Object.entries(store3.accounts);
|
|
73445
|
+
if (entries.length === 0)
|
|
73446
|
+
return import_picocolors23.default.dim("No accounts configured \u2014 add an account first.");
|
|
73447
|
+
const lines = [];
|
|
73448
|
+
for (const [name, entry] of entries) {
|
|
73449
|
+
if (entry.models?.error) {
|
|
73450
|
+
lines.push(` ${import_picocolors23.default.red("x")} ${import_picocolors23.default.white(name)}: ${import_picocolors23.default.red(entry.models.error)}`);
|
|
73451
|
+
} else if (entry.models) {
|
|
73452
|
+
const avail = entry.models.available.length;
|
|
73453
|
+
const disabled = entry.models.disabled.length;
|
|
73454
|
+
lines.push(` ${import_picocolors23.default.green("*")} ${import_picocolors23.default.white(name)}: ${import_picocolors23.default.green(`${avail} available`)}, ${disabled > 0 ? import_picocolors23.default.yellow(`${disabled} disabled`) : import_picocolors23.default.dim(`${disabled} disabled`)}`);
|
|
73455
|
+
if (entry.models.available.length > 0) {
|
|
73456
|
+
const groups = groupModelsByFamily(entry.models.available);
|
|
73457
|
+
for (const group of groups) {
|
|
73458
|
+
lines.push(` ${import_picocolors23.default.cyan(group.label.padEnd(10))} ${import_picocolors23.default.dim(group.models.join(", "))}`);
|
|
73459
|
+
}
|
|
73460
|
+
}
|
|
73461
|
+
} else {
|
|
73462
|
+
lines.push(` ${import_picocolors23.default.dim("?")} ${import_picocolors23.default.white(name)}: ${import_picocolors23.default.dim("no model data")}`);
|
|
73463
|
+
}
|
|
73464
|
+
}
|
|
73465
|
+
return lines.join(`
|
|
73466
|
+
`);
|
|
73467
|
+
}
|
|
73468
|
+
function buildAccountChoices(accounts, active) {
|
|
73469
|
+
return Object.entries(accounts).map(([name, entry]) => {
|
|
73470
|
+
const isCurrent = active === name;
|
|
73471
|
+
const hint = [
|
|
73472
|
+
isCurrent ? "current" : undefined,
|
|
73473
|
+
entry.user ? `@${entry.user}` : undefined,
|
|
73474
|
+
entry.lastUsed ? formatRelativeTime(entry.lastUsed) : undefined
|
|
73475
|
+
].filter(Boolean).join(", ");
|
|
73476
|
+
return { value: name, label: name, hint: hint || undefined };
|
|
73477
|
+
});
|
|
73478
|
+
}
|
|
73479
|
+
|
|
73480
|
+
// src/cli/copilot-account-prompts.ts
|
|
73481
|
+
async function promptManualAccountEntry(existingNames) {
|
|
73482
|
+
const name = await he({
|
|
73483
|
+
message: "Account name",
|
|
73484
|
+
placeholder: "my-github-account",
|
|
73485
|
+
validate(value) {
|
|
73486
|
+
if (!value.trim())
|
|
73487
|
+
return "Name is required";
|
|
73488
|
+
if (existingNames.includes(value.trim()))
|
|
73489
|
+
return `Name already exists: ${value.trim()}`;
|
|
73490
|
+
}
|
|
73491
|
+
});
|
|
73492
|
+
if (pD(name))
|
|
73493
|
+
return null;
|
|
73494
|
+
const refresh = await he({
|
|
73495
|
+
message: "OAuth refresh/access token",
|
|
73496
|
+
placeholder: "gho_xxxx...",
|
|
73497
|
+
validate(value) {
|
|
73498
|
+
if (!value.trim())
|
|
73499
|
+
return "Token is required";
|
|
73500
|
+
}
|
|
73501
|
+
});
|
|
73502
|
+
if (pD(refresh))
|
|
73503
|
+
return null;
|
|
73504
|
+
const access = await he({
|
|
73505
|
+
message: "Copilot access token (optional)",
|
|
73506
|
+
placeholder: "Press Enter to skip",
|
|
73507
|
+
defaultValue: ""
|
|
73508
|
+
});
|
|
73509
|
+
if (pD(access))
|
|
73510
|
+
return null;
|
|
73511
|
+
const expiresRaw = await he({
|
|
73512
|
+
message: "Access token expires (unix ms, optional)",
|
|
73513
|
+
placeholder: "Press Enter to skip",
|
|
73514
|
+
defaultValue: ""
|
|
73515
|
+
});
|
|
73516
|
+
if (pD(expiresRaw))
|
|
73517
|
+
return null;
|
|
73518
|
+
const enterpriseUrl = await he({
|
|
73519
|
+
message: "Enterprise URL (optional)",
|
|
73520
|
+
placeholder: "github.mycompany.com",
|
|
73521
|
+
defaultValue: ""
|
|
73522
|
+
});
|
|
73523
|
+
if (pD(enterpriseUrl))
|
|
73524
|
+
return null;
|
|
73525
|
+
const expires = Number(expiresRaw);
|
|
73526
|
+
const trimmedName = name.trim();
|
|
73527
|
+
const trimmedRefresh = refresh.trim();
|
|
73528
|
+
const trimmedAccess = access.trim();
|
|
73529
|
+
const trimmedEnterprise = enterpriseUrl.trim();
|
|
73530
|
+
const entry = {
|
|
73531
|
+
name: trimmedName,
|
|
73532
|
+
refresh: trimmedRefresh,
|
|
73533
|
+
access: trimmedAccess || trimmedRefresh,
|
|
73534
|
+
expires: Number.isFinite(expires) ? expires : 0,
|
|
73535
|
+
enterpriseUrl: trimmedEnterprise || undefined,
|
|
73536
|
+
addedAt: Date.now(),
|
|
73537
|
+
source: "manual"
|
|
73538
|
+
};
|
|
73539
|
+
return { name: trimmedName, entry };
|
|
73540
|
+
}
|
|
73541
|
+
|
|
73542
|
+
// src/cli/copilot-x.ts
|
|
73543
|
+
async function handleOAuthLogin() {
|
|
73544
|
+
const deployment = await ve({
|
|
73545
|
+
message: "Login target",
|
|
73546
|
+
options: [
|
|
73547
|
+
{ value: "github.com", label: "github.com" },
|
|
73548
|
+
{ value: "enterprise", label: "Enterprise", hint: "Custom GitHub Enterprise Server" }
|
|
73549
|
+
]
|
|
73550
|
+
});
|
|
73551
|
+
if (pD(deployment))
|
|
73552
|
+
return;
|
|
73553
|
+
let enterpriseUrl;
|
|
73554
|
+
if (deployment === "enterprise") {
|
|
73555
|
+
const url2 = await he({
|
|
73556
|
+
message: "Enterprise URL",
|
|
73557
|
+
placeholder: "github.mycompany.com",
|
|
73558
|
+
validate: (v2) => !v2.trim() ? "URL is required" : undefined
|
|
73559
|
+
});
|
|
73560
|
+
if (pD(url2))
|
|
73561
|
+
return;
|
|
73562
|
+
enterpriseUrl = url2.trim();
|
|
73563
|
+
}
|
|
73564
|
+
const spinner = Y2();
|
|
73565
|
+
spinner.start("Authenticating via device flow...");
|
|
73566
|
+
const entry = await loginOauth(deployment, enterpriseUrl);
|
|
73567
|
+
await addAccount(entry);
|
|
73568
|
+
spinner.stop(`Account added: ${import_picocolors24.default.green(entry.name)}`);
|
|
73569
|
+
}
|
|
73570
|
+
async function handleManualAdd() {
|
|
73571
|
+
const store3 = await readStore2();
|
|
73572
|
+
const result = await promptManualAccountEntry(Object.keys(store3.accounts));
|
|
73573
|
+
if (!result)
|
|
73574
|
+
return;
|
|
73575
|
+
await addAccount(result.entry);
|
|
73576
|
+
M2.success(`Account added: ${import_picocolors24.default.green(result.name)}`);
|
|
73577
|
+
}
|
|
73578
|
+
async function handleImport() {
|
|
73579
|
+
const customPath = await he({
|
|
73580
|
+
message: "Import from",
|
|
73581
|
+
placeholder: authPath(),
|
|
73582
|
+
defaultValue: ""
|
|
73583
|
+
});
|
|
73584
|
+
if (pD(customPath))
|
|
73585
|
+
return;
|
|
73586
|
+
const spinner = Y2();
|
|
73587
|
+
spinner.start("Importing accounts...");
|
|
73588
|
+
const result = await importFromAuth(customPath.trim() || undefined);
|
|
73589
|
+
spinner.stop(`Imported ${import_picocolors24.default.green(String(result.imported))} account(s)`);
|
|
73590
|
+
}
|
|
73591
|
+
async function handleCheckQuotas() {
|
|
73592
|
+
const spinner = Y2();
|
|
73593
|
+
spinner.start("Checking quotas for all accounts...");
|
|
73594
|
+
await checkQuotas();
|
|
73595
|
+
spinner.stop("Quotas updated");
|
|
73596
|
+
}
|
|
73597
|
+
async function handleCheckModels() {
|
|
73598
|
+
const spinner = Y2();
|
|
73599
|
+
spinner.start("Checking available models...");
|
|
73600
|
+
const store3 = await checkModels2();
|
|
73601
|
+
spinner.stop("Models checked");
|
|
73602
|
+
Me(buildModelReport(store3), "Model Report");
|
|
73603
|
+
}
|
|
73604
|
+
async function handleRefreshIdentity() {
|
|
73605
|
+
const spinner = Y2();
|
|
73606
|
+
spinner.start("Refreshing identity for all accounts...");
|
|
73607
|
+
await refreshIdentity();
|
|
73608
|
+
spinner.stop("Identity refreshed");
|
|
73609
|
+
}
|
|
73610
|
+
async function handleSwitch() {
|
|
73611
|
+
const store3 = await readStore2();
|
|
73612
|
+
const choices = buildAccountChoices(store3.accounts, store3.active);
|
|
73613
|
+
if (choices.length === 0) {
|
|
73614
|
+
M2.warn("No accounts to switch.");
|
|
73615
|
+
return;
|
|
73616
|
+
}
|
|
73617
|
+
const selected = await ve({ message: "Switch to", options: choices });
|
|
73618
|
+
if (pD(selected))
|
|
73619
|
+
return;
|
|
73620
|
+
await switchAccount(selected);
|
|
73621
|
+
M2.success(`Switched to: ${import_picocolors24.default.green(selected)}`);
|
|
73622
|
+
}
|
|
73623
|
+
async function handleRemove() {
|
|
73624
|
+
const store3 = await readStore2();
|
|
73625
|
+
const choices = buildAccountChoices(store3.accounts, store3.active);
|
|
73626
|
+
if (choices.length === 0) {
|
|
73627
|
+
M2.warn("No accounts to remove.");
|
|
73628
|
+
return;
|
|
73629
|
+
}
|
|
73630
|
+
const selected = await ve({ message: "Remove which account?", options: choices });
|
|
73631
|
+
if (pD(selected))
|
|
73632
|
+
return;
|
|
73633
|
+
const confirmed = await ye({ message: `Remove ${import_picocolors24.default.red(selected)}?`, initialValue: false });
|
|
73634
|
+
if (pD(confirmed) || !confirmed)
|
|
73635
|
+
return;
|
|
73636
|
+
await removeAccount(selected);
|
|
73637
|
+
M2.success(`Removed: ${import_picocolors24.default.red(selected)}`);
|
|
73638
|
+
}
|
|
73639
|
+
async function handleRemoveAll() {
|
|
73640
|
+
const confirmed = await ye({ message: `${import_picocolors24.default.red("Remove ALL accounts?")} This cannot be undone.`, initialValue: false });
|
|
73641
|
+
if (pD(confirmed) || !confirmed)
|
|
73642
|
+
return;
|
|
73643
|
+
await removeAllAccounts();
|
|
73644
|
+
M2.success("All accounts removed.");
|
|
73645
|
+
}
|
|
73646
|
+
function buildMenuOptions() {
|
|
73647
|
+
return [
|
|
73648
|
+
{ value: "add-oauth", label: "Add account (OAuth)", hint: "GitHub device flow" },
|
|
73649
|
+
{ value: "add-manual", label: "Add account (manual)", hint: "Paste token directly" },
|
|
73650
|
+
{ value: "import", label: "Import from auth.json", hint: "Auto-detect from OpenCode" },
|
|
73651
|
+
{ value: "models", label: "Check models", hint: "Available & disabled models" },
|
|
73652
|
+
{ value: "refresh-identity", label: "Refresh identity", hint: "Update usernames & orgs" },
|
|
73653
|
+
{ value: "switch", label: "Switch account" },
|
|
73654
|
+
{ value: "remove", label: "Remove account" },
|
|
73655
|
+
{ value: "remove-all", label: "Remove all accounts", hint: import_picocolors24.default.red("destructive") },
|
|
73656
|
+
{ value: "exit", label: "Exit" }
|
|
73657
|
+
];
|
|
73658
|
+
}
|
|
73659
|
+
var ACTION_HANDLERS = {
|
|
73660
|
+
"add-oauth": handleOAuthLogin,
|
|
73661
|
+
"add-manual": handleManualAdd,
|
|
73662
|
+
import: handleImport,
|
|
73663
|
+
models: handleCheckModels,
|
|
73664
|
+
"refresh-identity": handleRefreshIdentity,
|
|
73665
|
+
switch: handleSwitch,
|
|
73666
|
+
remove: handleRemove,
|
|
73667
|
+
"remove-all": handleRemoveAll
|
|
73668
|
+
};
|
|
73669
|
+
async function copilotXCli() {
|
|
73670
|
+
Ie(import_picocolors24.default.bgCyan(import_picocolors24.default.black(" GitHub Copilot Account Manager ")));
|
|
73671
|
+
await handleCheckQuotas();
|
|
73672
|
+
while (true) {
|
|
73673
|
+
const store3 = await readStore2();
|
|
73674
|
+
const accountDisplay = buildAccountLines(store3);
|
|
73675
|
+
Me(accountDisplay, "Accounts");
|
|
73676
|
+
const action = await ve({ message: "What would you like to do?", options: buildMenuOptions() });
|
|
73677
|
+
if (pD(action)) {
|
|
73678
|
+
Se(import_picocolors24.default.dim("Bye!"));
|
|
73679
|
+
return 0;
|
|
73680
|
+
}
|
|
73681
|
+
if (action === "exit") {
|
|
73682
|
+
Se(import_picocolors24.default.dim("Bye!"));
|
|
73683
|
+
return 0;
|
|
73684
|
+
}
|
|
73685
|
+
try {
|
|
73686
|
+
const handler = ACTION_HANDLERS[action];
|
|
73687
|
+
if (handler)
|
|
73688
|
+
await handler();
|
|
73689
|
+
} catch (error48) {
|
|
73690
|
+
M2.error(`${error48 instanceof Error ? error48.message : String(error48)}`);
|
|
73691
|
+
}
|
|
73692
|
+
}
|
|
73693
|
+
}
|
|
73694
|
+
|
|
72637
73695
|
// src/cli/cli-program.ts
|
|
72638
73696
|
init_version();
|
|
72639
73697
|
var VERSION2 = PLUGIN_VERSION;
|
|
@@ -72747,6 +73805,23 @@ Examples:
|
|
|
72747
73805
|
program2.command("version").description("Show version information").action(() => {
|
|
72748
73806
|
console.log(`oh-my-magento v${VERSION2}`);
|
|
72749
73807
|
});
|
|
73808
|
+
program2.command("copilot-x").description("Manage multiple GitHub Copilot accounts").addHelpText("after", `
|
|
73809
|
+
Examples:
|
|
73810
|
+
$ bunx oh-my-magento copilot-x
|
|
73811
|
+
|
|
73812
|
+
This command provides an interactive CLI for managing GitHub Copilot accounts:
|
|
73813
|
+
- Add account (OAuth) - GitHub device flow authentication
|
|
73814
|
+
- Add account (manual) - Paste token directly
|
|
73815
|
+
- Import from auth.json - Auto-detect from OpenCode
|
|
73816
|
+
- Check models - View available & disabled models
|
|
73817
|
+
- Refresh identity - Update usernames & orgs
|
|
73818
|
+
- Switch account - Change active Copilot account
|
|
73819
|
+
- Remove account - Delete a stored account
|
|
73820
|
+
- Remove all accounts - Destructive cleanup
|
|
73821
|
+
`).action(async () => {
|
|
73822
|
+
const exitCode = await copilotXCli();
|
|
73823
|
+
process.exit(exitCode);
|
|
73824
|
+
});
|
|
72750
73825
|
program2.addCommand(createMcpOAuthCommand());
|
|
72751
73826
|
program2.addCommand(createUsageCommand());
|
|
72752
73827
|
function runCli() {
|