@codevector/cli 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -22
- package/dist/index.js +543 -1285
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -5004,13 +5004,13 @@ var init_schemas = __esm({
|
|
|
5004
5004
|
}
|
|
5005
5005
|
return propValues;
|
|
5006
5006
|
});
|
|
5007
|
-
const
|
|
5007
|
+
const isObject4 = isObject2;
|
|
5008
5008
|
const catchall = def.catchall;
|
|
5009
5009
|
let value;
|
|
5010
5010
|
inst._zod.parse = (payload, ctx) => {
|
|
5011
5011
|
value ?? (value = _normalized.value);
|
|
5012
5012
|
const input = payload.value;
|
|
5013
|
-
if (!
|
|
5013
|
+
if (!isObject4(input)) {
|
|
5014
5014
|
payload.issues.push({
|
|
5015
5015
|
expected: "object",
|
|
5016
5016
|
code: "invalid_type",
|
|
@@ -5137,7 +5137,7 @@ var init_schemas = __esm({
|
|
|
5137
5137
|
return (payload, ctx) => fn(shape, payload, ctx);
|
|
5138
5138
|
};
|
|
5139
5139
|
let fastpass;
|
|
5140
|
-
const
|
|
5140
|
+
const isObject4 = isObject2;
|
|
5141
5141
|
const jit = !globalConfig.jitless;
|
|
5142
5142
|
const allowsEval2 = allowsEval;
|
|
5143
5143
|
const fastEnabled = jit && allowsEval2.value;
|
|
@@ -5146,7 +5146,7 @@ var init_schemas = __esm({
|
|
|
5146
5146
|
inst._zod.parse = (payload, ctx) => {
|
|
5147
5147
|
value ?? (value = _normalized.value);
|
|
5148
5148
|
const input = payload.value;
|
|
5149
|
-
if (!
|
|
5149
|
+
if (!isObject4(input)) {
|
|
5150
5150
|
payload.issues.push({
|
|
5151
5151
|
expected: "object",
|
|
5152
5152
|
code: "invalid_type",
|
|
@@ -18075,1053 +18075,17 @@ var init_prompt = __esm({
|
|
|
18075
18075
|
}
|
|
18076
18076
|
});
|
|
18077
18077
|
|
|
18078
|
-
// ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/error.js
|
|
18079
|
-
function getLineColFromPtr(string4, ptr) {
|
|
18080
|
-
let lines = string4.slice(0, ptr).split(/\r\n|\n|\r/g);
|
|
18081
|
-
return [lines.length, lines.pop().length + 1];
|
|
18082
|
-
}
|
|
18083
|
-
function makeCodeBlock(string4, line, column) {
|
|
18084
|
-
let lines = string4.split(/\r\n|\n|\r/g);
|
|
18085
|
-
let codeblock = "";
|
|
18086
|
-
let numberLen = (Math.log10(line + 1) | 0) + 1;
|
|
18087
|
-
for (let i = line - 1; i <= line + 1; i++) {
|
|
18088
|
-
let l = lines[i - 1];
|
|
18089
|
-
if (!l)
|
|
18090
|
-
continue;
|
|
18091
|
-
codeblock += i.toString().padEnd(numberLen, " ");
|
|
18092
|
-
codeblock += ": ";
|
|
18093
|
-
codeblock += l;
|
|
18094
|
-
codeblock += "\n";
|
|
18095
|
-
if (i === line) {
|
|
18096
|
-
codeblock += " ".repeat(numberLen + column + 2);
|
|
18097
|
-
codeblock += "^\n";
|
|
18098
|
-
}
|
|
18099
|
-
}
|
|
18100
|
-
return codeblock;
|
|
18101
|
-
}
|
|
18102
|
-
var TomlError;
|
|
18103
|
-
var init_error = __esm({
|
|
18104
|
-
"../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/error.js"() {
|
|
18105
|
-
"use strict";
|
|
18106
|
-
TomlError = class extends Error {
|
|
18107
|
-
line;
|
|
18108
|
-
column;
|
|
18109
|
-
codeblock;
|
|
18110
|
-
constructor(message, options) {
|
|
18111
|
-
const [line, column] = getLineColFromPtr(options.toml, options.ptr);
|
|
18112
|
-
const codeblock = makeCodeBlock(options.toml, line, column);
|
|
18113
|
-
super(`Invalid TOML document: ${message}
|
|
18114
|
-
|
|
18115
|
-
${codeblock}`, options);
|
|
18116
|
-
this.line = line;
|
|
18117
|
-
this.column = column;
|
|
18118
|
-
this.codeblock = codeblock;
|
|
18119
|
-
}
|
|
18120
|
-
};
|
|
18121
|
-
}
|
|
18122
|
-
});
|
|
18123
|
-
|
|
18124
|
-
// ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/util.js
|
|
18125
|
-
function isEscaped(str, ptr) {
|
|
18126
|
-
let i = 0;
|
|
18127
|
-
while (str[ptr - ++i] === "\\")
|
|
18128
|
-
;
|
|
18129
|
-
return --i && i % 2;
|
|
18130
|
-
}
|
|
18131
|
-
function indexOfNewline(str, start = 0, end = str.length) {
|
|
18132
|
-
let idx = str.indexOf("\n", start);
|
|
18133
|
-
if (str[idx - 1] === "\r")
|
|
18134
|
-
idx--;
|
|
18135
|
-
return idx <= end ? idx : -1;
|
|
18136
|
-
}
|
|
18137
|
-
function skipComment(str, ptr) {
|
|
18138
|
-
for (let i = ptr; i < str.length; i++) {
|
|
18139
|
-
let c = str[i];
|
|
18140
|
-
if (c === "\n")
|
|
18141
|
-
return i;
|
|
18142
|
-
if (c === "\r" && str[i + 1] === "\n")
|
|
18143
|
-
return i + 1;
|
|
18144
|
-
if (c < " " && c !== " " || c === "\x7F") {
|
|
18145
|
-
throw new TomlError("control characters are not allowed in comments", {
|
|
18146
|
-
toml: str,
|
|
18147
|
-
ptr
|
|
18148
|
-
});
|
|
18149
|
-
}
|
|
18150
|
-
}
|
|
18151
|
-
return str.length;
|
|
18152
|
-
}
|
|
18153
|
-
function skipVoid(str, ptr, banNewLines, banComments) {
|
|
18154
|
-
let c;
|
|
18155
|
-
while (1) {
|
|
18156
|
-
while ((c = str[ptr]) === " " || c === " " || !banNewLines && (c === "\n" || c === "\r" && str[ptr + 1] === "\n"))
|
|
18157
|
-
ptr++;
|
|
18158
|
-
if (banComments || c !== "#")
|
|
18159
|
-
break;
|
|
18160
|
-
ptr = skipComment(str, ptr);
|
|
18161
|
-
}
|
|
18162
|
-
return ptr;
|
|
18163
|
-
}
|
|
18164
|
-
function skipUntil(str, ptr, sep2, end, banNewLines = false) {
|
|
18165
|
-
if (!end) {
|
|
18166
|
-
ptr = indexOfNewline(str, ptr);
|
|
18167
|
-
return ptr < 0 ? str.length : ptr;
|
|
18168
|
-
}
|
|
18169
|
-
for (let i = ptr; i < str.length; i++) {
|
|
18170
|
-
let c = str[i];
|
|
18171
|
-
if (c === "#") {
|
|
18172
|
-
i = indexOfNewline(str, i);
|
|
18173
|
-
} else if (c === sep2) {
|
|
18174
|
-
return i + 1;
|
|
18175
|
-
} else if (c === end || banNewLines && (c === "\n" || c === "\r" && str[i + 1] === "\n")) {
|
|
18176
|
-
return i;
|
|
18177
|
-
}
|
|
18178
|
-
}
|
|
18179
|
-
throw new TomlError("cannot find end of structure", {
|
|
18180
|
-
toml: str,
|
|
18181
|
-
ptr
|
|
18182
|
-
});
|
|
18183
|
-
}
|
|
18184
|
-
function getStringEnd(str, seek) {
|
|
18185
|
-
let first = str[seek];
|
|
18186
|
-
let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2] ? str.slice(seek, seek + 3) : first;
|
|
18187
|
-
seek += target.length - 1;
|
|
18188
|
-
do
|
|
18189
|
-
seek = str.indexOf(target, ++seek);
|
|
18190
|
-
while (seek > -1 && first !== "'" && isEscaped(str, seek));
|
|
18191
|
-
if (seek > -1) {
|
|
18192
|
-
seek += target.length;
|
|
18193
|
-
if (target.length > 1) {
|
|
18194
|
-
if (str[seek] === first)
|
|
18195
|
-
seek++;
|
|
18196
|
-
if (str[seek] === first)
|
|
18197
|
-
seek++;
|
|
18198
|
-
}
|
|
18199
|
-
}
|
|
18200
|
-
return seek;
|
|
18201
|
-
}
|
|
18202
|
-
var init_util2 = __esm({
|
|
18203
|
-
"../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/util.js"() {
|
|
18204
|
-
"use strict";
|
|
18205
|
-
init_error();
|
|
18206
|
-
}
|
|
18207
|
-
});
|
|
18208
|
-
|
|
18209
|
-
// ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/date.js
|
|
18210
|
-
var DATE_TIME_RE, TomlDate;
|
|
18211
|
-
var init_date = __esm({
|
|
18212
|
-
"../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/date.js"() {
|
|
18213
|
-
"use strict";
|
|
18214
|
-
DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
18215
|
-
TomlDate = class _TomlDate extends Date {
|
|
18216
|
-
#hasDate = false;
|
|
18217
|
-
#hasTime = false;
|
|
18218
|
-
#offset = null;
|
|
18219
|
-
constructor(date5) {
|
|
18220
|
-
let hasDate = true;
|
|
18221
|
-
let hasTime = true;
|
|
18222
|
-
let offset = "Z";
|
|
18223
|
-
if (typeof date5 === "string") {
|
|
18224
|
-
let match = date5.match(DATE_TIME_RE);
|
|
18225
|
-
if (match) {
|
|
18226
|
-
if (!match[1]) {
|
|
18227
|
-
hasDate = false;
|
|
18228
|
-
date5 = `0000-01-01T${date5}`;
|
|
18229
|
-
}
|
|
18230
|
-
hasTime = !!match[2];
|
|
18231
|
-
hasTime && date5[10] === " " && (date5 = date5.replace(" ", "T"));
|
|
18232
|
-
if (match[2] && +match[2] > 23) {
|
|
18233
|
-
date5 = "";
|
|
18234
|
-
} else {
|
|
18235
|
-
offset = match[3] || null;
|
|
18236
|
-
date5 = date5.toUpperCase();
|
|
18237
|
-
if (!offset && hasTime)
|
|
18238
|
-
date5 += "Z";
|
|
18239
|
-
}
|
|
18240
|
-
} else {
|
|
18241
|
-
date5 = "";
|
|
18242
|
-
}
|
|
18243
|
-
}
|
|
18244
|
-
super(date5);
|
|
18245
|
-
if (!isNaN(this.getTime())) {
|
|
18246
|
-
this.#hasDate = hasDate;
|
|
18247
|
-
this.#hasTime = hasTime;
|
|
18248
|
-
this.#offset = offset;
|
|
18249
|
-
}
|
|
18250
|
-
}
|
|
18251
|
-
isDateTime() {
|
|
18252
|
-
return this.#hasDate && this.#hasTime;
|
|
18253
|
-
}
|
|
18254
|
-
isLocal() {
|
|
18255
|
-
return !this.#hasDate || !this.#hasTime || !this.#offset;
|
|
18256
|
-
}
|
|
18257
|
-
isDate() {
|
|
18258
|
-
return this.#hasDate && !this.#hasTime;
|
|
18259
|
-
}
|
|
18260
|
-
isTime() {
|
|
18261
|
-
return this.#hasTime && !this.#hasDate;
|
|
18262
|
-
}
|
|
18263
|
-
isValid() {
|
|
18264
|
-
return this.#hasDate || this.#hasTime;
|
|
18265
|
-
}
|
|
18266
|
-
toISOString() {
|
|
18267
|
-
let iso = super.toISOString();
|
|
18268
|
-
if (this.isDate())
|
|
18269
|
-
return iso.slice(0, 10);
|
|
18270
|
-
if (this.isTime())
|
|
18271
|
-
return iso.slice(11, 23);
|
|
18272
|
-
if (this.#offset === null)
|
|
18273
|
-
return iso.slice(0, -1);
|
|
18274
|
-
if (this.#offset === "Z")
|
|
18275
|
-
return iso;
|
|
18276
|
-
let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
|
|
18277
|
-
offset = this.#offset[0] === "-" ? offset : -offset;
|
|
18278
|
-
let offsetDate = new Date(this.getTime() - offset * 6e4);
|
|
18279
|
-
return offsetDate.toISOString().slice(0, -1) + this.#offset;
|
|
18280
|
-
}
|
|
18281
|
-
static wrapAsOffsetDateTime(jsDate, offset = "Z") {
|
|
18282
|
-
let date5 = new _TomlDate(jsDate);
|
|
18283
|
-
date5.#offset = offset;
|
|
18284
|
-
return date5;
|
|
18285
|
-
}
|
|
18286
|
-
static wrapAsLocalDateTime(jsDate) {
|
|
18287
|
-
let date5 = new _TomlDate(jsDate);
|
|
18288
|
-
date5.#offset = null;
|
|
18289
|
-
return date5;
|
|
18290
|
-
}
|
|
18291
|
-
static wrapAsLocalDate(jsDate) {
|
|
18292
|
-
let date5 = new _TomlDate(jsDate);
|
|
18293
|
-
date5.#hasTime = false;
|
|
18294
|
-
date5.#offset = null;
|
|
18295
|
-
return date5;
|
|
18296
|
-
}
|
|
18297
|
-
static wrapAsLocalTime(jsDate) {
|
|
18298
|
-
let date5 = new _TomlDate(jsDate);
|
|
18299
|
-
date5.#hasDate = false;
|
|
18300
|
-
date5.#offset = null;
|
|
18301
|
-
return date5;
|
|
18302
|
-
}
|
|
18303
|
-
};
|
|
18304
|
-
}
|
|
18305
|
-
});
|
|
18306
|
-
|
|
18307
|
-
// ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/primitive.js
|
|
18308
|
-
function parseString(str, ptr = 0, endPtr = str.length) {
|
|
18309
|
-
let isLiteral = str[ptr] === "'";
|
|
18310
|
-
let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
|
|
18311
|
-
if (isMultiline) {
|
|
18312
|
-
endPtr -= 2;
|
|
18313
|
-
if (str[ptr += 2] === "\r")
|
|
18314
|
-
ptr++;
|
|
18315
|
-
if (str[ptr] === "\n")
|
|
18316
|
-
ptr++;
|
|
18317
|
-
}
|
|
18318
|
-
let tmp = 0;
|
|
18319
|
-
let isEscape;
|
|
18320
|
-
let parsed = "";
|
|
18321
|
-
let sliceStart = ptr;
|
|
18322
|
-
while (ptr < endPtr - 1) {
|
|
18323
|
-
let c = str[ptr++];
|
|
18324
|
-
if (c === "\n" || c === "\r" && str[ptr] === "\n") {
|
|
18325
|
-
if (!isMultiline) {
|
|
18326
|
-
throw new TomlError("newlines are not allowed in strings", {
|
|
18327
|
-
toml: str,
|
|
18328
|
-
ptr: ptr - 1
|
|
18329
|
-
});
|
|
18330
|
-
}
|
|
18331
|
-
} else if (c < " " && c !== " " || c === "\x7F") {
|
|
18332
|
-
throw new TomlError("control characters are not allowed in strings", {
|
|
18333
|
-
toml: str,
|
|
18334
|
-
ptr: ptr - 1
|
|
18335
|
-
});
|
|
18336
|
-
}
|
|
18337
|
-
if (isEscape) {
|
|
18338
|
-
isEscape = false;
|
|
18339
|
-
if (c === "x" || c === "u" || c === "U") {
|
|
18340
|
-
let code = str.slice(ptr, ptr += c === "x" ? 2 : c === "u" ? 4 : 8);
|
|
18341
|
-
if (!ESCAPE_REGEX.test(code)) {
|
|
18342
|
-
throw new TomlError("invalid unicode escape", {
|
|
18343
|
-
toml: str,
|
|
18344
|
-
ptr: tmp
|
|
18345
|
-
});
|
|
18346
|
-
}
|
|
18347
|
-
try {
|
|
18348
|
-
parsed += String.fromCodePoint(parseInt(code, 16));
|
|
18349
|
-
} catch {
|
|
18350
|
-
throw new TomlError("invalid unicode escape", {
|
|
18351
|
-
toml: str,
|
|
18352
|
-
ptr: tmp
|
|
18353
|
-
});
|
|
18354
|
-
}
|
|
18355
|
-
} else if (isMultiline && (c === "\n" || c === " " || c === " " || c === "\r")) {
|
|
18356
|
-
ptr = skipVoid(str, ptr - 1, true);
|
|
18357
|
-
if (str[ptr] !== "\n" && str[ptr] !== "\r") {
|
|
18358
|
-
throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
|
|
18359
|
-
toml: str,
|
|
18360
|
-
ptr: tmp
|
|
18361
|
-
});
|
|
18362
|
-
}
|
|
18363
|
-
ptr = skipVoid(str, ptr);
|
|
18364
|
-
} else if (c in ESC_MAP) {
|
|
18365
|
-
parsed += ESC_MAP[c];
|
|
18366
|
-
} else {
|
|
18367
|
-
throw new TomlError("unrecognized escape sequence", {
|
|
18368
|
-
toml: str,
|
|
18369
|
-
ptr: tmp
|
|
18370
|
-
});
|
|
18371
|
-
}
|
|
18372
|
-
sliceStart = ptr;
|
|
18373
|
-
} else if (!isLiteral && c === "\\") {
|
|
18374
|
-
tmp = ptr - 1;
|
|
18375
|
-
isEscape = true;
|
|
18376
|
-
parsed += str.slice(sliceStart, tmp);
|
|
18377
|
-
}
|
|
18378
|
-
}
|
|
18379
|
-
return parsed + str.slice(sliceStart, endPtr - 1);
|
|
18380
|
-
}
|
|
18381
|
-
function parseValue(value, toml, ptr, integersAsBigInt) {
|
|
18382
|
-
if (value === "true")
|
|
18383
|
-
return true;
|
|
18384
|
-
if (value === "false")
|
|
18385
|
-
return false;
|
|
18386
|
-
if (value === "-inf")
|
|
18387
|
-
return -Infinity;
|
|
18388
|
-
if (value === "inf" || value === "+inf")
|
|
18389
|
-
return Infinity;
|
|
18390
|
-
if (value === "nan" || value === "+nan" || value === "-nan")
|
|
18391
|
-
return NaN;
|
|
18392
|
-
if (value === "-0")
|
|
18393
|
-
return integersAsBigInt ? 0n : 0;
|
|
18394
|
-
let isInt = INT_REGEX.test(value);
|
|
18395
|
-
if (isInt || FLOAT_REGEX.test(value)) {
|
|
18396
|
-
if (LEADING_ZERO.test(value)) {
|
|
18397
|
-
throw new TomlError("leading zeroes are not allowed", {
|
|
18398
|
-
toml,
|
|
18399
|
-
ptr
|
|
18400
|
-
});
|
|
18401
|
-
}
|
|
18402
|
-
value = value.replace(/_/g, "");
|
|
18403
|
-
let numeric = +value;
|
|
18404
|
-
if (isNaN(numeric)) {
|
|
18405
|
-
throw new TomlError("invalid number", {
|
|
18406
|
-
toml,
|
|
18407
|
-
ptr
|
|
18408
|
-
});
|
|
18409
|
-
}
|
|
18410
|
-
if (isInt) {
|
|
18411
|
-
if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
|
|
18412
|
-
throw new TomlError("integer value cannot be represented losslessly", {
|
|
18413
|
-
toml,
|
|
18414
|
-
ptr
|
|
18415
|
-
});
|
|
18416
|
-
}
|
|
18417
|
-
if (isInt || integersAsBigInt === true)
|
|
18418
|
-
numeric = BigInt(value);
|
|
18419
|
-
}
|
|
18420
|
-
return numeric;
|
|
18421
|
-
}
|
|
18422
|
-
const date5 = new TomlDate(value);
|
|
18423
|
-
if (!date5.isValid()) {
|
|
18424
|
-
throw new TomlError("invalid value", {
|
|
18425
|
-
toml,
|
|
18426
|
-
ptr
|
|
18427
|
-
});
|
|
18428
|
-
}
|
|
18429
|
-
return date5;
|
|
18430
|
-
}
|
|
18431
|
-
var INT_REGEX, FLOAT_REGEX, LEADING_ZERO, ESCAPE_REGEX, ESC_MAP;
|
|
18432
|
-
var init_primitive = __esm({
|
|
18433
|
-
"../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/primitive.js"() {
|
|
18434
|
-
"use strict";
|
|
18435
|
-
init_util2();
|
|
18436
|
-
init_date();
|
|
18437
|
-
init_error();
|
|
18438
|
-
INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
|
|
18439
|
-
FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
|
|
18440
|
-
LEADING_ZERO = /^[+-]?0[0-9_]/;
|
|
18441
|
-
ESCAPE_REGEX = /^[0-9a-f]{2,8}$/i;
|
|
18442
|
-
ESC_MAP = {
|
|
18443
|
-
b: "\b",
|
|
18444
|
-
t: " ",
|
|
18445
|
-
n: "\n",
|
|
18446
|
-
f: "\f",
|
|
18447
|
-
r: "\r",
|
|
18448
|
-
e: "\x1B",
|
|
18449
|
-
'"': '"',
|
|
18450
|
-
"\\": "\\"
|
|
18451
|
-
};
|
|
18452
|
-
}
|
|
18453
|
-
});
|
|
18454
|
-
|
|
18455
|
-
// ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/extract.js
|
|
18456
|
-
function sliceAndTrimEndOf(str, startPtr, endPtr) {
|
|
18457
|
-
let value = str.slice(startPtr, endPtr);
|
|
18458
|
-
let commentIdx = value.indexOf("#");
|
|
18459
|
-
if (commentIdx > -1) {
|
|
18460
|
-
skipComment(str, commentIdx);
|
|
18461
|
-
value = value.slice(0, commentIdx);
|
|
18462
|
-
}
|
|
18463
|
-
return [value.trimEnd(), commentIdx];
|
|
18464
|
-
}
|
|
18465
|
-
function extractValue(str, ptr, end, depth, integersAsBigInt) {
|
|
18466
|
-
if (depth === 0) {
|
|
18467
|
-
throw new TomlError("document contains excessively nested structures. aborting.", {
|
|
18468
|
-
toml: str,
|
|
18469
|
-
ptr
|
|
18470
|
-
});
|
|
18471
|
-
}
|
|
18472
|
-
let c = str[ptr];
|
|
18473
|
-
if (c === "[" || c === "{") {
|
|
18474
|
-
let [value, endPtr2] = c === "[" ? parseArray(str, ptr, depth, integersAsBigInt) : parseInlineTable(str, ptr, depth, integersAsBigInt);
|
|
18475
|
-
if (end) {
|
|
18476
|
-
endPtr2 = skipVoid(str, endPtr2);
|
|
18477
|
-
if (str[endPtr2] === ",")
|
|
18478
|
-
endPtr2++;
|
|
18479
|
-
else if (str[endPtr2] !== end) {
|
|
18480
|
-
throw new TomlError("expected comma or end of structure", {
|
|
18481
|
-
toml: str,
|
|
18482
|
-
ptr: endPtr2
|
|
18483
|
-
});
|
|
18484
|
-
}
|
|
18485
|
-
}
|
|
18486
|
-
return [value, endPtr2];
|
|
18487
|
-
}
|
|
18488
|
-
let endPtr;
|
|
18489
|
-
if (c === '"' || c === "'") {
|
|
18490
|
-
endPtr = getStringEnd(str, ptr);
|
|
18491
|
-
let parsed = parseString(str, ptr, endPtr);
|
|
18492
|
-
if (end) {
|
|
18493
|
-
endPtr = skipVoid(str, endPtr);
|
|
18494
|
-
if (str[endPtr] && str[endPtr] !== "," && str[endPtr] !== end && str[endPtr] !== "\n" && str[endPtr] !== "\r") {
|
|
18495
|
-
throw new TomlError("unexpected character encountered", {
|
|
18496
|
-
toml: str,
|
|
18497
|
-
ptr: endPtr
|
|
18498
|
-
});
|
|
18499
|
-
}
|
|
18500
|
-
endPtr += +(str[endPtr] === ",");
|
|
18501
|
-
}
|
|
18502
|
-
return [parsed, endPtr];
|
|
18503
|
-
}
|
|
18504
|
-
endPtr = skipUntil(str, ptr, ",", end);
|
|
18505
|
-
let slice = sliceAndTrimEndOf(str, ptr, endPtr - +(str[endPtr - 1] === ","));
|
|
18506
|
-
if (!slice[0]) {
|
|
18507
|
-
throw new TomlError("incomplete key-value declaration: no value specified", {
|
|
18508
|
-
toml: str,
|
|
18509
|
-
ptr
|
|
18510
|
-
});
|
|
18511
|
-
}
|
|
18512
|
-
if (end && slice[1] > -1) {
|
|
18513
|
-
endPtr = skipVoid(str, ptr + slice[1]);
|
|
18514
|
-
endPtr += +(str[endPtr] === ",");
|
|
18515
|
-
}
|
|
18516
|
-
return [
|
|
18517
|
-
parseValue(slice[0], str, ptr, integersAsBigInt),
|
|
18518
|
-
endPtr
|
|
18519
|
-
];
|
|
18520
|
-
}
|
|
18521
|
-
var init_extract = __esm({
|
|
18522
|
-
"../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/extract.js"() {
|
|
18523
|
-
"use strict";
|
|
18524
|
-
init_primitive();
|
|
18525
|
-
init_struct();
|
|
18526
|
-
init_util2();
|
|
18527
|
-
init_error();
|
|
18528
|
-
}
|
|
18529
|
-
});
|
|
18530
|
-
|
|
18531
|
-
// ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/struct.js
|
|
18532
|
-
function parseKey(str, ptr, end = "=") {
|
|
18533
|
-
let dot = ptr - 1;
|
|
18534
|
-
let parsed = [];
|
|
18535
|
-
let endPtr = str.indexOf(end, ptr);
|
|
18536
|
-
if (endPtr < 0) {
|
|
18537
|
-
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
18538
|
-
toml: str,
|
|
18539
|
-
ptr
|
|
18540
|
-
});
|
|
18541
|
-
}
|
|
18542
|
-
do {
|
|
18543
|
-
let c = str[ptr = ++dot];
|
|
18544
|
-
if (c !== " " && c !== " ") {
|
|
18545
|
-
if (c === '"' || c === "'") {
|
|
18546
|
-
if (c === str[ptr + 1] && c === str[ptr + 2]) {
|
|
18547
|
-
throw new TomlError("multiline strings are not allowed in keys", {
|
|
18548
|
-
toml: str,
|
|
18549
|
-
ptr
|
|
18550
|
-
});
|
|
18551
|
-
}
|
|
18552
|
-
let eos = getStringEnd(str, ptr);
|
|
18553
|
-
if (eos < 0) {
|
|
18554
|
-
throw new TomlError("unfinished string encountered", {
|
|
18555
|
-
toml: str,
|
|
18556
|
-
ptr
|
|
18557
|
-
});
|
|
18558
|
-
}
|
|
18559
|
-
dot = str.indexOf(".", eos);
|
|
18560
|
-
let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
18561
|
-
let newLine = indexOfNewline(strEnd);
|
|
18562
|
-
if (newLine > -1) {
|
|
18563
|
-
throw new TomlError("newlines are not allowed in keys", {
|
|
18564
|
-
toml: str,
|
|
18565
|
-
ptr: ptr + dot + newLine
|
|
18566
|
-
});
|
|
18567
|
-
}
|
|
18568
|
-
if (strEnd.trimStart()) {
|
|
18569
|
-
throw new TomlError("found extra tokens after the string part", {
|
|
18570
|
-
toml: str,
|
|
18571
|
-
ptr: eos
|
|
18572
|
-
});
|
|
18573
|
-
}
|
|
18574
|
-
if (endPtr < eos) {
|
|
18575
|
-
endPtr = str.indexOf(end, eos);
|
|
18576
|
-
if (endPtr < 0) {
|
|
18577
|
-
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
18578
|
-
toml: str,
|
|
18579
|
-
ptr
|
|
18580
|
-
});
|
|
18581
|
-
}
|
|
18582
|
-
}
|
|
18583
|
-
parsed.push(parseString(str, ptr, eos));
|
|
18584
|
-
} else {
|
|
18585
|
-
dot = str.indexOf(".", ptr);
|
|
18586
|
-
let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
18587
|
-
if (!KEY_PART_RE.test(part)) {
|
|
18588
|
-
throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
|
|
18589
|
-
toml: str,
|
|
18590
|
-
ptr
|
|
18591
|
-
});
|
|
18592
|
-
}
|
|
18593
|
-
parsed.push(part.trimEnd());
|
|
18594
|
-
}
|
|
18595
|
-
}
|
|
18596
|
-
} while (dot + 1 && dot < endPtr);
|
|
18597
|
-
return [parsed, skipVoid(str, endPtr + 1, true, true)];
|
|
18598
|
-
}
|
|
18599
|
-
function parseInlineTable(str, ptr, depth, integersAsBigInt) {
|
|
18600
|
-
let res = {};
|
|
18601
|
-
let seen = /* @__PURE__ */ new Set();
|
|
18602
|
-
let c;
|
|
18603
|
-
ptr++;
|
|
18604
|
-
while ((c = str[ptr++]) !== "}" && c) {
|
|
18605
|
-
if (c === ",") {
|
|
18606
|
-
throw new TomlError("expected value, found comma", {
|
|
18607
|
-
toml: str,
|
|
18608
|
-
ptr: ptr - 1
|
|
18609
|
-
});
|
|
18610
|
-
} else if (c === "#")
|
|
18611
|
-
ptr = skipComment(str, ptr);
|
|
18612
|
-
else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
|
|
18613
|
-
let k2;
|
|
18614
|
-
let t = res;
|
|
18615
|
-
let hasOwn = false;
|
|
18616
|
-
let [key, keyEndPtr] = parseKey(str, ptr - 1);
|
|
18617
|
-
for (let i = 0; i < key.length; i++) {
|
|
18618
|
-
if (i)
|
|
18619
|
-
t = hasOwn ? t[k2] : t[k2] = {};
|
|
18620
|
-
k2 = key[i];
|
|
18621
|
-
if ((hasOwn = Object.hasOwn(t, k2)) && (typeof t[k2] !== "object" || seen.has(t[k2]))) {
|
|
18622
|
-
throw new TomlError("trying to redefine an already defined value", {
|
|
18623
|
-
toml: str,
|
|
18624
|
-
ptr
|
|
18625
|
-
});
|
|
18626
|
-
}
|
|
18627
|
-
if (!hasOwn && k2 === "__proto__") {
|
|
18628
|
-
Object.defineProperty(t, k2, { enumerable: true, configurable: true, writable: true });
|
|
18629
|
-
}
|
|
18630
|
-
}
|
|
18631
|
-
if (hasOwn) {
|
|
18632
|
-
throw new TomlError("trying to redefine an already defined value", {
|
|
18633
|
-
toml: str,
|
|
18634
|
-
ptr
|
|
18635
|
-
});
|
|
18636
|
-
}
|
|
18637
|
-
let [value, valueEndPtr] = extractValue(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
|
|
18638
|
-
seen.add(value);
|
|
18639
|
-
t[k2] = value;
|
|
18640
|
-
ptr = valueEndPtr;
|
|
18641
|
-
}
|
|
18642
|
-
}
|
|
18643
|
-
if (!c) {
|
|
18644
|
-
throw new TomlError("unfinished table encountered", {
|
|
18645
|
-
toml: str,
|
|
18646
|
-
ptr
|
|
18647
|
-
});
|
|
18648
|
-
}
|
|
18649
|
-
return [res, ptr];
|
|
18650
|
-
}
|
|
18651
|
-
function parseArray(str, ptr, depth, integersAsBigInt) {
|
|
18652
|
-
let res = [];
|
|
18653
|
-
let c;
|
|
18654
|
-
ptr++;
|
|
18655
|
-
while ((c = str[ptr++]) !== "]" && c) {
|
|
18656
|
-
if (c === ",") {
|
|
18657
|
-
throw new TomlError("expected value, found comma", {
|
|
18658
|
-
toml: str,
|
|
18659
|
-
ptr: ptr - 1
|
|
18660
|
-
});
|
|
18661
|
-
} else if (c === "#")
|
|
18662
|
-
ptr = skipComment(str, ptr);
|
|
18663
|
-
else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
|
|
18664
|
-
let e2 = extractValue(str, ptr - 1, "]", depth - 1, integersAsBigInt);
|
|
18665
|
-
res.push(e2[0]);
|
|
18666
|
-
ptr = e2[1];
|
|
18667
|
-
}
|
|
18668
|
-
}
|
|
18669
|
-
if (!c) {
|
|
18670
|
-
throw new TomlError("unfinished array encountered", {
|
|
18671
|
-
toml: str,
|
|
18672
|
-
ptr
|
|
18673
|
-
});
|
|
18674
|
-
}
|
|
18675
|
-
return [res, ptr];
|
|
18676
|
-
}
|
|
18677
|
-
var KEY_PART_RE;
|
|
18678
|
-
var init_struct = __esm({
|
|
18679
|
-
"../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/struct.js"() {
|
|
18680
|
-
"use strict";
|
|
18681
|
-
init_primitive();
|
|
18682
|
-
init_extract();
|
|
18683
|
-
init_util2();
|
|
18684
|
-
init_error();
|
|
18685
|
-
KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
18686
|
-
}
|
|
18687
|
-
});
|
|
18688
|
-
|
|
18689
|
-
// ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/parse.js
|
|
18690
|
-
function peekTable(key, table, meta3, type) {
|
|
18691
|
-
let t = table;
|
|
18692
|
-
let m2 = meta3;
|
|
18693
|
-
let k2;
|
|
18694
|
-
let hasOwn = false;
|
|
18695
|
-
let state;
|
|
18696
|
-
for (let i = 0; i < key.length; i++) {
|
|
18697
|
-
if (i) {
|
|
18698
|
-
t = hasOwn ? t[k2] : t[k2] = {};
|
|
18699
|
-
m2 = (state = m2[k2]).c;
|
|
18700
|
-
if (type === 0 && (state.t === 1 || state.t === 2)) {
|
|
18701
|
-
return null;
|
|
18702
|
-
}
|
|
18703
|
-
if (state.t === 2) {
|
|
18704
|
-
let l = t.length - 1;
|
|
18705
|
-
t = t[l];
|
|
18706
|
-
m2 = m2[l].c;
|
|
18707
|
-
}
|
|
18708
|
-
}
|
|
18709
|
-
k2 = key[i];
|
|
18710
|
-
if ((hasOwn = Object.hasOwn(t, k2)) && m2[k2]?.t === 0 && m2[k2]?.d) {
|
|
18711
|
-
return null;
|
|
18712
|
-
}
|
|
18713
|
-
if (!hasOwn) {
|
|
18714
|
-
if (k2 === "__proto__") {
|
|
18715
|
-
Object.defineProperty(t, k2, { enumerable: true, configurable: true, writable: true });
|
|
18716
|
-
Object.defineProperty(m2, k2, { enumerable: true, configurable: true, writable: true });
|
|
18717
|
-
}
|
|
18718
|
-
m2[k2] = {
|
|
18719
|
-
t: i < key.length - 1 && type === 2 ? 3 : type,
|
|
18720
|
-
d: false,
|
|
18721
|
-
i: 0,
|
|
18722
|
-
c: {}
|
|
18723
|
-
};
|
|
18724
|
-
}
|
|
18725
|
-
}
|
|
18726
|
-
state = m2[k2];
|
|
18727
|
-
if (state.t !== type && !(type === 1 && state.t === 3)) {
|
|
18728
|
-
return null;
|
|
18729
|
-
}
|
|
18730
|
-
if (type === 2) {
|
|
18731
|
-
if (!state.d) {
|
|
18732
|
-
state.d = true;
|
|
18733
|
-
t[k2] = [];
|
|
18734
|
-
}
|
|
18735
|
-
t[k2].push(t = {});
|
|
18736
|
-
state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
|
|
18737
|
-
}
|
|
18738
|
-
if (state.d) {
|
|
18739
|
-
return null;
|
|
18740
|
-
}
|
|
18741
|
-
state.d = true;
|
|
18742
|
-
if (type === 1) {
|
|
18743
|
-
t = hasOwn ? t[k2] : t[k2] = {};
|
|
18744
|
-
} else if (type === 0 && hasOwn) {
|
|
18745
|
-
return null;
|
|
18746
|
-
}
|
|
18747
|
-
return [k2, t, state.c];
|
|
18748
|
-
}
|
|
18749
|
-
function parse3(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
18750
|
-
let res = {};
|
|
18751
|
-
let meta3 = {};
|
|
18752
|
-
let tbl = res;
|
|
18753
|
-
let m2 = meta3;
|
|
18754
|
-
for (let ptr = skipVoid(toml, 0); ptr < toml.length; ) {
|
|
18755
|
-
if (toml[ptr] === "[") {
|
|
18756
|
-
let isTableArray = toml[++ptr] === "[";
|
|
18757
|
-
let k2 = parseKey(toml, ptr += +isTableArray, "]");
|
|
18758
|
-
if (isTableArray) {
|
|
18759
|
-
if (toml[k2[1] - 1] !== "]") {
|
|
18760
|
-
throw new TomlError("expected end of table declaration", {
|
|
18761
|
-
toml,
|
|
18762
|
-
ptr: k2[1] - 1
|
|
18763
|
-
});
|
|
18764
|
-
}
|
|
18765
|
-
k2[1]++;
|
|
18766
|
-
}
|
|
18767
|
-
let p2 = peekTable(
|
|
18768
|
-
k2[0],
|
|
18769
|
-
res,
|
|
18770
|
-
meta3,
|
|
18771
|
-
isTableArray ? 2 : 1
|
|
18772
|
-
/* Type.EXPLICIT */
|
|
18773
|
-
);
|
|
18774
|
-
if (!p2) {
|
|
18775
|
-
throw new TomlError("trying to redefine an already defined table or value", {
|
|
18776
|
-
toml,
|
|
18777
|
-
ptr
|
|
18778
|
-
});
|
|
18779
|
-
}
|
|
18780
|
-
m2 = p2[2];
|
|
18781
|
-
tbl = p2[1];
|
|
18782
|
-
ptr = k2[1];
|
|
18783
|
-
} else {
|
|
18784
|
-
let k2 = parseKey(toml, ptr);
|
|
18785
|
-
let p2 = peekTable(
|
|
18786
|
-
k2[0],
|
|
18787
|
-
tbl,
|
|
18788
|
-
m2,
|
|
18789
|
-
0
|
|
18790
|
-
/* Type.DOTTED */
|
|
18791
|
-
);
|
|
18792
|
-
if (!p2) {
|
|
18793
|
-
throw new TomlError("trying to redefine an already defined table or value", {
|
|
18794
|
-
toml,
|
|
18795
|
-
ptr
|
|
18796
|
-
});
|
|
18797
|
-
}
|
|
18798
|
-
let v2 = extractValue(toml, k2[1], void 0, maxDepth, integersAsBigInt);
|
|
18799
|
-
p2[1][p2[0]] = v2[0];
|
|
18800
|
-
ptr = v2[1];
|
|
18801
|
-
}
|
|
18802
|
-
ptr = skipVoid(toml, ptr, true);
|
|
18803
|
-
if (toml[ptr] && toml[ptr] !== "\n" && toml[ptr] !== "\r") {
|
|
18804
|
-
throw new TomlError("each key-value declaration must be followed by an end-of-line", {
|
|
18805
|
-
toml,
|
|
18806
|
-
ptr
|
|
18807
|
-
});
|
|
18808
|
-
}
|
|
18809
|
-
ptr = skipVoid(toml, ptr);
|
|
18810
|
-
}
|
|
18811
|
-
return res;
|
|
18812
|
-
}
|
|
18813
|
-
var init_parse3 = __esm({
|
|
18814
|
-
"../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/parse.js"() {
|
|
18815
|
-
"use strict";
|
|
18816
|
-
init_struct();
|
|
18817
|
-
init_extract();
|
|
18818
|
-
init_util2();
|
|
18819
|
-
init_error();
|
|
18820
|
-
}
|
|
18821
|
-
});
|
|
18822
|
-
|
|
18823
|
-
// ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/stringify.js
|
|
18824
|
-
function extendedTypeOf(obj) {
|
|
18825
|
-
let type = typeof obj;
|
|
18826
|
-
if (type === "object") {
|
|
18827
|
-
if (Array.isArray(obj))
|
|
18828
|
-
return "array";
|
|
18829
|
-
if (obj instanceof Date)
|
|
18830
|
-
return "date";
|
|
18831
|
-
}
|
|
18832
|
-
return type;
|
|
18833
|
-
}
|
|
18834
|
-
function isArrayOfTables(obj) {
|
|
18835
|
-
for (let i = 0; i < obj.length; i++) {
|
|
18836
|
-
if (extendedTypeOf(obj[i]) !== "object")
|
|
18837
|
-
return false;
|
|
18838
|
-
}
|
|
18839
|
-
return obj.length != 0;
|
|
18840
|
-
}
|
|
18841
|
-
function formatString(s) {
|
|
18842
|
-
return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
|
|
18843
|
-
}
|
|
18844
|
-
function stringifyValue(val, type, depth, numberAsFloat) {
|
|
18845
|
-
if (depth === 0) {
|
|
18846
|
-
throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
18847
|
-
}
|
|
18848
|
-
if (type === "number") {
|
|
18849
|
-
if (isNaN(val))
|
|
18850
|
-
return "nan";
|
|
18851
|
-
if (val === Infinity)
|
|
18852
|
-
return "inf";
|
|
18853
|
-
if (val === -Infinity)
|
|
18854
|
-
return "-inf";
|
|
18855
|
-
if (numberAsFloat && Number.isInteger(val))
|
|
18856
|
-
return val.toFixed(1);
|
|
18857
|
-
return val.toString();
|
|
18858
|
-
}
|
|
18859
|
-
if (type === "bigint" || type === "boolean") {
|
|
18860
|
-
return val.toString();
|
|
18861
|
-
}
|
|
18862
|
-
if (type === "string") {
|
|
18863
|
-
return formatString(val);
|
|
18864
|
-
}
|
|
18865
|
-
if (type === "date") {
|
|
18866
|
-
if (isNaN(val.getTime())) {
|
|
18867
|
-
throw new TypeError("cannot serialize invalid date");
|
|
18868
|
-
}
|
|
18869
|
-
return val.toISOString();
|
|
18870
|
-
}
|
|
18871
|
-
if (type === "object") {
|
|
18872
|
-
return stringifyInlineTable(val, depth, numberAsFloat);
|
|
18873
|
-
}
|
|
18874
|
-
if (type === "array") {
|
|
18875
|
-
return stringifyArray(val, depth, numberAsFloat);
|
|
18876
|
-
}
|
|
18877
|
-
}
|
|
18878
|
-
function stringifyInlineTable(obj, depth, numberAsFloat) {
|
|
18879
|
-
let keys = Object.keys(obj);
|
|
18880
|
-
if (keys.length === 0)
|
|
18881
|
-
return "{}";
|
|
18882
|
-
let res = "{ ";
|
|
18883
|
-
for (let i = 0; i < keys.length; i++) {
|
|
18884
|
-
let k2 = keys[i];
|
|
18885
|
-
if (i)
|
|
18886
|
-
res += ", ";
|
|
18887
|
-
res += BARE_KEY.test(k2) ? k2 : formatString(k2);
|
|
18888
|
-
res += " = ";
|
|
18889
|
-
res += stringifyValue(obj[k2], extendedTypeOf(obj[k2]), depth - 1, numberAsFloat);
|
|
18890
|
-
}
|
|
18891
|
-
return res + " }";
|
|
18892
|
-
}
|
|
18893
|
-
function stringifyArray(array2, depth, numberAsFloat) {
|
|
18894
|
-
if (array2.length === 0)
|
|
18895
|
-
return "[]";
|
|
18896
|
-
let res = "[ ";
|
|
18897
|
-
for (let i = 0; i < array2.length; i++) {
|
|
18898
|
-
if (i)
|
|
18899
|
-
res += ", ";
|
|
18900
|
-
if (array2[i] === null || array2[i] === void 0) {
|
|
18901
|
-
throw new TypeError("arrays cannot contain null or undefined values");
|
|
18902
|
-
}
|
|
18903
|
-
res += stringifyValue(array2[i], extendedTypeOf(array2[i]), depth - 1, numberAsFloat);
|
|
18904
|
-
}
|
|
18905
|
-
return res + " ]";
|
|
18906
|
-
}
|
|
18907
|
-
function stringifyArrayTable(array2, key, depth, numberAsFloat) {
|
|
18908
|
-
if (depth === 0) {
|
|
18909
|
-
throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
18910
|
-
}
|
|
18911
|
-
let res = "";
|
|
18912
|
-
for (let i = 0; i < array2.length; i++) {
|
|
18913
|
-
res += `${res && "\n"}[[${key}]]
|
|
18914
|
-
`;
|
|
18915
|
-
res += stringifyTable(0, array2[i], key, depth, numberAsFloat);
|
|
18916
|
-
}
|
|
18917
|
-
return res;
|
|
18918
|
-
}
|
|
18919
|
-
function stringifyTable(tableKey, obj, prefix, depth, numberAsFloat) {
|
|
18920
|
-
if (depth === 0) {
|
|
18921
|
-
throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
18922
|
-
}
|
|
18923
|
-
let preamble = "";
|
|
18924
|
-
let tables = "";
|
|
18925
|
-
let keys = Object.keys(obj);
|
|
18926
|
-
for (let i = 0; i < keys.length; i++) {
|
|
18927
|
-
let k2 = keys[i];
|
|
18928
|
-
if (obj[k2] !== null && obj[k2] !== void 0) {
|
|
18929
|
-
let type = extendedTypeOf(obj[k2]);
|
|
18930
|
-
if (type === "symbol" || type === "function") {
|
|
18931
|
-
throw new TypeError(`cannot serialize values of type '${type}'`);
|
|
18932
|
-
}
|
|
18933
|
-
let key = BARE_KEY.test(k2) ? k2 : formatString(k2);
|
|
18934
|
-
if (type === "array" && isArrayOfTables(obj[k2])) {
|
|
18935
|
-
tables += (tables && "\n") + stringifyArrayTable(obj[k2], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
|
|
18936
|
-
} else if (type === "object") {
|
|
18937
|
-
let tblKey = prefix ? `${prefix}.${key}` : key;
|
|
18938
|
-
tables += (tables && "\n") + stringifyTable(tblKey, obj[k2], tblKey, depth - 1, numberAsFloat);
|
|
18939
|
-
} else {
|
|
18940
|
-
preamble += key;
|
|
18941
|
-
preamble += " = ";
|
|
18942
|
-
preamble += stringifyValue(obj[k2], type, depth, numberAsFloat);
|
|
18943
|
-
preamble += "\n";
|
|
18944
|
-
}
|
|
18945
|
-
}
|
|
18946
|
-
}
|
|
18947
|
-
if (tableKey && (preamble || !tables))
|
|
18948
|
-
preamble = preamble ? `[${tableKey}]
|
|
18949
|
-
${preamble}` : `[${tableKey}]`;
|
|
18950
|
-
return preamble && tables ? `${preamble}
|
|
18951
|
-
${tables}` : preamble || tables;
|
|
18952
|
-
}
|
|
18953
|
-
function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
|
|
18954
|
-
if (extendedTypeOf(obj) !== "object") {
|
|
18955
|
-
throw new TypeError("stringify can only be called with an object");
|
|
18956
|
-
}
|
|
18957
|
-
let str = stringifyTable(0, obj, "", maxDepth, numbersAsFloat);
|
|
18958
|
-
if (str[str.length - 1] !== "\n")
|
|
18959
|
-
return str + "\n";
|
|
18960
|
-
return str;
|
|
18961
|
-
}
|
|
18962
|
-
var BARE_KEY;
|
|
18963
|
-
var init_stringify = __esm({
|
|
18964
|
-
"../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/stringify.js"() {
|
|
18965
|
-
"use strict";
|
|
18966
|
-
BARE_KEY = /^[a-z0-9-_]+$/i;
|
|
18967
|
-
}
|
|
18968
|
-
});
|
|
18969
|
-
|
|
18970
|
-
// ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/index.js
|
|
18971
|
-
var init_dist6 = __esm({
|
|
18972
|
-
"../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/index.js"() {
|
|
18973
|
-
"use strict";
|
|
18974
|
-
init_parse3();
|
|
18975
|
-
init_stringify();
|
|
18976
|
-
init_date();
|
|
18977
|
-
init_error();
|
|
18978
|
-
}
|
|
18979
|
-
});
|
|
18980
|
-
|
|
18981
|
-
// src/config-writers/codex.ts
|
|
18982
|
-
import {
|
|
18983
|
-
chmodSync as chmodSync3,
|
|
18984
|
-
existsSync as existsSync4,
|
|
18985
|
-
mkdirSync as mkdirSync4,
|
|
18986
|
-
readFileSync as readFileSync6,
|
|
18987
|
-
renameSync as renameSync3,
|
|
18988
|
-
statSync as statSync4,
|
|
18989
|
-
writeFileSync as writeFileSync5
|
|
18990
|
-
} from "fs";
|
|
18991
|
-
import { dirname as dirname4, join as join5 } from "path";
|
|
18992
|
-
import { homedir as homedir4 } from "os";
|
|
18993
|
-
function codexConfigPath(scope = "user") {
|
|
18994
|
-
switch (scope) {
|
|
18995
|
-
case "user":
|
|
18996
|
-
return join5(homedir4(), ".codex", "config.toml");
|
|
18997
|
-
case "project":
|
|
18998
|
-
case "local":
|
|
18999
|
-
return join5(userCwd(), ".codex", "config.toml");
|
|
19000
|
-
}
|
|
19001
|
-
}
|
|
19002
|
-
function readTomlOrEmpty(path) {
|
|
19003
|
-
if (!existsSync4(path)) return {};
|
|
19004
|
-
const raw = readFileSync6(path, "utf8");
|
|
19005
|
-
if (raw.trim().length === 0) return {};
|
|
19006
|
-
const parsed = parse3(raw);
|
|
19007
|
-
if (!isObject4(parsed)) {
|
|
19008
|
-
throw new Error(`${path} is not a TOML table. Refusing to overwrite.`);
|
|
19009
|
-
}
|
|
19010
|
-
return parsed;
|
|
19011
|
-
}
|
|
19012
|
-
function writeTomlAtomic(path, value) {
|
|
19013
|
-
const dir = dirname4(path);
|
|
19014
|
-
mkdirSync4(dir, { recursive: true, mode: 448 });
|
|
19015
|
-
let mode;
|
|
19016
|
-
if (existsSync4(path)) {
|
|
19017
|
-
mode = statSync4(path).mode & 511;
|
|
19018
|
-
}
|
|
19019
|
-
const tmp = `${path}.${process.pid}.tmp`;
|
|
19020
|
-
writeFileSync5(tmp, `${stringify(value)}
|
|
19021
|
-
`);
|
|
19022
|
-
if (mode !== void 0) {
|
|
19023
|
-
try {
|
|
19024
|
-
chmodSync3(tmp, mode);
|
|
19025
|
-
} catch {
|
|
19026
|
-
}
|
|
19027
|
-
}
|
|
19028
|
-
renameSync3(tmp, path);
|
|
19029
|
-
}
|
|
19030
|
-
function isObject4(v2) {
|
|
19031
|
-
return typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
|
|
19032
|
-
}
|
|
19033
|
-
function trimRightSlash4(url2) {
|
|
19034
|
-
return url2.endsWith("/") ? url2.slice(0, -1) : url2;
|
|
19035
|
-
}
|
|
19036
|
-
function buildHttpHeaders(scope, project) {
|
|
19037
|
-
const safe = (v2) => v2.replace(/[\r\n]/g, "").trim();
|
|
19038
|
-
const headers = {
|
|
19039
|
-
"x-client-app": "codex"
|
|
19040
|
-
};
|
|
19041
|
-
if (scope !== "user" && project) {
|
|
19042
|
-
const slug = safe(project);
|
|
19043
|
-
if (slug) {
|
|
19044
|
-
headers["x-project"] = slug;
|
|
19045
|
-
}
|
|
19046
|
-
}
|
|
19047
|
-
return headers;
|
|
19048
|
-
}
|
|
19049
|
-
var ENV_VAR_NAME2, PROVIDER_ID, writeCodexConfig;
|
|
19050
|
-
var init_codex = __esm({
|
|
19051
|
-
"src/config-writers/codex.ts"() {
|
|
19052
|
-
"use strict";
|
|
19053
|
-
init_dist6();
|
|
19054
|
-
init_gitignore();
|
|
19055
|
-
init_paths();
|
|
19056
|
-
ENV_VAR_NAME2 = "CODEVECTOR_GATEWAY_KEY";
|
|
19057
|
-
PROVIDER_ID = "codevector";
|
|
19058
|
-
writeCodexConfig = ({
|
|
19059
|
-
gatewayUrl,
|
|
19060
|
-
scope,
|
|
19061
|
-
project,
|
|
19062
|
-
model,
|
|
19063
|
-
availableModels = []
|
|
19064
|
-
}) => {
|
|
19065
|
-
const path = codexConfigPath(scope);
|
|
19066
|
-
const gateway = trimRightSlash4(gatewayUrl);
|
|
19067
|
-
const existing = readTomlOrEmpty(path);
|
|
19068
|
-
const merged = { ...existing };
|
|
19069
|
-
merged.model_provider = PROVIDER_ID;
|
|
19070
|
-
const providers = isObject4(merged.model_providers) ? { ...merged.model_providers } : {};
|
|
19071
|
-
providers[PROVIDER_ID] = {
|
|
19072
|
-
name: "CodeVector Gateway",
|
|
19073
|
-
base_url: `${gateway}/gateway/openai/v1`,
|
|
19074
|
-
env_key: ENV_VAR_NAME2,
|
|
19075
|
-
wire_api: "responses",
|
|
19076
|
-
http_headers: buildHttpHeaders(scope, project)
|
|
19077
|
-
};
|
|
19078
|
-
merged.model_providers = providers;
|
|
19079
|
-
if (model) {
|
|
19080
|
-
merged.model = model.slug;
|
|
19081
|
-
const meta3 = availableModels.find((m2) => m2.slug === model.slug);
|
|
19082
|
-
if (meta3?.supportsReasoning === true) {
|
|
19083
|
-
merged.model_reasoning_summary = "auto";
|
|
19084
|
-
merged.model_supports_reasoning_summaries = true;
|
|
19085
|
-
} else {
|
|
19086
|
-
delete merged.model_reasoning_summary;
|
|
19087
|
-
delete merged.model_supports_reasoning_summaries;
|
|
19088
|
-
}
|
|
19089
|
-
} else {
|
|
19090
|
-
delete merged.model;
|
|
19091
|
-
delete merged.model_reasoning_summary;
|
|
19092
|
-
delete merged.model_supports_reasoning_summaries;
|
|
19093
|
-
}
|
|
19094
|
-
writeTomlAtomic(path, merged);
|
|
19095
|
-
const notes = [
|
|
19096
|
-
`codex does not auto-load .env files. Add to your shell rc: export ${ENV_VAR_NAME2}=<your key>`
|
|
19097
|
-
];
|
|
19098
|
-
if (scope === "local") {
|
|
19099
|
-
if (ensureGitignored(".codex/config.toml")) {
|
|
19100
|
-
notes.push("Added `.codex/config.toml` to .gitignore.");
|
|
19101
|
-
}
|
|
19102
|
-
}
|
|
19103
|
-
return {
|
|
19104
|
-
tool: "codex",
|
|
19105
|
-
status: "configured",
|
|
19106
|
-
path,
|
|
19107
|
-
scope,
|
|
19108
|
-
notes: notes.join(" ")
|
|
19109
|
-
};
|
|
19110
|
-
};
|
|
19111
|
-
}
|
|
19112
|
-
});
|
|
19113
|
-
|
|
19114
18078
|
// src/lib/project-config.ts
|
|
19115
|
-
import { existsSync as
|
|
19116
|
-
import { dirname as
|
|
18079
|
+
import { existsSync as existsSync4, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "fs";
|
|
18080
|
+
import { dirname as dirname4, join as join5, parse as parsePath, resolve } from "path";
|
|
19117
18081
|
function findProjectConfigPath(startDir) {
|
|
19118
18082
|
let dir = resolve(startDir);
|
|
19119
18083
|
const root = parsePath(dir).root;
|
|
19120
18084
|
while (true) {
|
|
19121
|
-
const candidate =
|
|
19122
|
-
if (
|
|
18085
|
+
const candidate = join5(dir, PROJECT_CONFIG_FILENAME);
|
|
18086
|
+
if (existsSync4(candidate)) return candidate;
|
|
19123
18087
|
if (dir === root) return null;
|
|
19124
|
-
const parent =
|
|
18088
|
+
const parent = dirname4(dir);
|
|
19125
18089
|
if (parent === dir) return null;
|
|
19126
18090
|
dir = parent;
|
|
19127
18091
|
}
|
|
@@ -19129,7 +18093,7 @@ function findProjectConfigPath(startDir) {
|
|
|
19129
18093
|
function readProjectConfigAt(path) {
|
|
19130
18094
|
let raw;
|
|
19131
18095
|
try {
|
|
19132
|
-
raw =
|
|
18096
|
+
raw = readFileSync6(path, "utf8");
|
|
19133
18097
|
} catch {
|
|
19134
18098
|
return null;
|
|
19135
18099
|
}
|
|
@@ -19151,7 +18115,7 @@ function readProjectConfig(startDir) {
|
|
|
19151
18115
|
}
|
|
19152
18116
|
function writeProjectConfig(path, config2) {
|
|
19153
18117
|
const parsed = ProjectConfigSchema.parse(config2);
|
|
19154
|
-
|
|
18118
|
+
writeFileSync5(path, `${JSON.stringify(parsed, null, 2)}
|
|
19155
18119
|
`, { mode: 420 });
|
|
19156
18120
|
}
|
|
19157
18121
|
var PROJECT_CONFIG_FILENAME, ProjectConfigSchema;
|
|
@@ -19172,7 +18136,7 @@ var init_project_config = __esm({
|
|
|
19172
18136
|
|
|
19173
18137
|
// src/lib/project-context.ts
|
|
19174
18138
|
import { execFileSync } from "child_process";
|
|
19175
|
-
import { join as
|
|
18139
|
+
import { join as join6 } from "path";
|
|
19176
18140
|
function safeGit(args, cwd) {
|
|
19177
18141
|
try {
|
|
19178
18142
|
const out = execFileSync("git", args, {
|
|
@@ -19210,7 +18174,7 @@ function resolveProjectContext(cwd = process.cwd(), ticketPattern = DEFAULT_TICK
|
|
|
19210
18174
|
return { project, ticket };
|
|
19211
18175
|
}
|
|
19212
18176
|
function readLocalConfig(cwd) {
|
|
19213
|
-
const config2 = readProjectConfigAt(
|
|
18177
|
+
const config2 = readProjectConfigAt(join6(cwd, PROJECT_CONFIG_FILENAME));
|
|
19214
18178
|
if (!config2) return null;
|
|
19215
18179
|
const result = {};
|
|
19216
18180
|
if (config2.projectName) result.projectName = config2.projectName;
|
|
@@ -19235,31 +18199,32 @@ var init_project_context = __esm({
|
|
|
19235
18199
|
});
|
|
19236
18200
|
|
|
19237
18201
|
// src/lib/shell.ts
|
|
19238
|
-
function detectShell() {
|
|
18202
|
+
function detectShell(platform = process.platform) {
|
|
19239
18203
|
const shellPath = process.env.SHELL ?? "";
|
|
19240
18204
|
if (shellPath.endsWith("/fish")) return "fish";
|
|
19241
18205
|
if (shellPath.endsWith("/zsh")) return "zsh";
|
|
19242
18206
|
if (shellPath.endsWith("/bash")) return "bash";
|
|
18207
|
+
if (shellPath === "" && platform === "win32") return "powershell";
|
|
19243
18208
|
return null;
|
|
19244
18209
|
}
|
|
19245
18210
|
var SHELLS;
|
|
19246
18211
|
var init_shell = __esm({
|
|
19247
18212
|
"src/lib/shell.ts"() {
|
|
19248
18213
|
"use strict";
|
|
19249
|
-
SHELLS = ["bash", "zsh", "fish"];
|
|
18214
|
+
SHELLS = ["bash", "zsh", "fish", "powershell"];
|
|
19250
18215
|
}
|
|
19251
18216
|
});
|
|
19252
18217
|
|
|
19253
18218
|
// src/lib/shell-hook.ts
|
|
19254
|
-
import { existsSync as
|
|
19255
|
-
import { homedir as
|
|
19256
|
-
import { join as
|
|
18219
|
+
import { existsSync as existsSync5, readFileSync as readFileSync7 } from "fs";
|
|
18220
|
+
import { homedir as homedir4 } from "os";
|
|
18221
|
+
import { join as join7 } from "path";
|
|
19257
18222
|
function shellHookRecipe(shell) {
|
|
19258
18223
|
return RECIPES[shell];
|
|
19259
18224
|
}
|
|
19260
18225
|
function shellHookInstructions(shell = detectShell(), platform = process.platform) {
|
|
19261
18226
|
if (!shell) {
|
|
19262
|
-
const rows = Object.keys(RECIPES).map((s) => ` ${s.padEnd(
|
|
18227
|
+
const rows = Object.keys(RECIPES).map((s) => ` ${s.padEnd(10)} ${RECIPES[s].rc.padEnd(26)} ${RECIPES[s].line}`).join("\n");
|
|
19263
18228
|
return `Add the line for your shell to its rc file, then restart your shell (credentials auto-activate on cd):
|
|
19264
18229
|
|
|
19265
18230
|
${rows}`;
|
|
@@ -19273,6 +18238,9 @@ ${rows}`;
|
|
|
19273
18238
|
if (shell === "bash" && platform === "darwin") {
|
|
19274
18239
|
lines.push("", "On macOS, login shells read ~/.bash_profile instead of ~/.bashrc.");
|
|
19275
18240
|
}
|
|
18241
|
+
if (shell === "powershell") {
|
|
18242
|
+
lines.push("", "If $PROFILE doesn't exist yet, create it: New-Item -ItemType File -Path $PROFILE -Force.");
|
|
18243
|
+
}
|
|
19276
18244
|
return lines.join("\n");
|
|
19277
18245
|
}
|
|
19278
18246
|
function shellHookOneLiner(shell = detectShell()) {
|
|
@@ -19283,20 +18251,27 @@ function shellHookOneLiner(shell = detectShell()) {
|
|
|
19283
18251
|
return `Optional: add \`${line}\` to ${rc} so credentials auto-activate on cd.`;
|
|
19284
18252
|
}
|
|
19285
18253
|
function rcCandidates(shell, platform = process.platform) {
|
|
19286
|
-
const home =
|
|
18254
|
+
const home = homedir4();
|
|
19287
18255
|
switch (shell) {
|
|
19288
18256
|
case "bash":
|
|
19289
|
-
return platform === "darwin" ? [
|
|
18257
|
+
return platform === "darwin" ? [join7(home, ".bash_profile"), join7(home, ".bashrc")] : [join7(home, ".bashrc")];
|
|
19290
18258
|
case "zsh":
|
|
19291
|
-
return [
|
|
18259
|
+
return [join7(home, ".zshrc")];
|
|
19292
18260
|
case "fish":
|
|
19293
|
-
return [
|
|
18261
|
+
return [join7(home, ".config", "fish", "config.fish")];
|
|
18262
|
+
case "powershell": {
|
|
18263
|
+
const docs = join7(home, "Documents");
|
|
18264
|
+
return [
|
|
18265
|
+
join7(docs, "PowerShell", "Microsoft.PowerShell_profile.ps1"),
|
|
18266
|
+
join7(docs, "WindowsPowerShell", "Microsoft.PowerShell_profile.ps1")
|
|
18267
|
+
];
|
|
18268
|
+
}
|
|
19294
18269
|
}
|
|
19295
18270
|
}
|
|
19296
18271
|
function isHookInstalled(shell, platform = process.platform) {
|
|
19297
18272
|
for (const path of rcCandidates(shell, platform)) {
|
|
19298
18273
|
try {
|
|
19299
|
-
if (
|
|
18274
|
+
if (existsSync5(path) && /codevector hook/.test(readFileSync7(path, "utf8"))) return true;
|
|
19300
18275
|
} catch {
|
|
19301
18276
|
}
|
|
19302
18277
|
}
|
|
@@ -19310,7 +18285,8 @@ var init_shell_hook = __esm({
|
|
|
19310
18285
|
RECIPES = {
|
|
19311
18286
|
bash: { rc: "~/.bashrc", line: `eval "$(codevector hook bash)"` },
|
|
19312
18287
|
zsh: { rc: "~/.zshrc", line: `eval "$(codevector hook zsh)"` },
|
|
19313
|
-
fish: { rc: "~/.config/fish/config.fish", line: "codevector hook fish | source" }
|
|
18288
|
+
fish: { rc: "~/.config/fish/config.fish", line: "codevector hook fish | source" },
|
|
18289
|
+
powershell: { rc: "$PROFILE", line: "codevector hook powershell | Out-String | Invoke-Expression" }
|
|
19314
18290
|
};
|
|
19315
18291
|
}
|
|
19316
18292
|
});
|
|
@@ -19321,8 +18297,8 @@ __export(init_exports, {
|
|
|
19321
18297
|
initCommand: () => initCommand
|
|
19322
18298
|
});
|
|
19323
18299
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
19324
|
-
import { existsSync as
|
|
19325
|
-
import { join as
|
|
18300
|
+
import { existsSync as existsSync6 } from "fs";
|
|
18301
|
+
import { join as join8 } from "path";
|
|
19326
18302
|
function isInteractive(args) {
|
|
19327
18303
|
if (!process.stdout.isTTY) return false;
|
|
19328
18304
|
return !args.gateway;
|
|
@@ -19453,8 +18429,8 @@ var init_init = __esm({
|
|
|
19453
18429
|
},
|
|
19454
18430
|
async run({ args }) {
|
|
19455
18431
|
const cwd = userCwd();
|
|
19456
|
-
const target =
|
|
19457
|
-
const existing =
|
|
18432
|
+
const target = join8(cwd, PROJECT_CONFIG_FILENAME);
|
|
18433
|
+
const existing = existsSync6(target) ? readProjectConfigAt(target) : null;
|
|
19458
18434
|
const interactive = isInteractive(args);
|
|
19459
18435
|
if (existing && !args.force && !interactive) {
|
|
19460
18436
|
throw new Error(
|
|
@@ -19486,7 +18462,7 @@ var init_init = __esm({
|
|
|
19486
18462
|
if (!args["skip-configure"] && interactive && gateway) {
|
|
19487
18463
|
const run = unwrap(
|
|
19488
18464
|
await ue({
|
|
19489
|
-
message: "Configure coding tools (Claude Code,
|
|
18465
|
+
message: "Configure coding tools (Claude Code, OpenCode) for this repo now?",
|
|
19490
18466
|
initialValue: true
|
|
19491
18467
|
})
|
|
19492
18468
|
);
|
|
@@ -19506,9 +18482,9 @@ var init_init = __esm({
|
|
|
19506
18482
|
});
|
|
19507
18483
|
|
|
19508
18484
|
// src/commands/configure.ts
|
|
19509
|
-
import { homedir as
|
|
19510
|
-
import { existsSync as
|
|
19511
|
-
import { join as
|
|
18485
|
+
import { homedir as homedir5 } from "os";
|
|
18486
|
+
import { existsSync as existsSync7 } from "fs";
|
|
18487
|
+
import { join as join9, sep } from "path";
|
|
19512
18488
|
async function resolveTools(args) {
|
|
19513
18489
|
if (args.all) return [...ALL_TOOLS];
|
|
19514
18490
|
if (args.tool) {
|
|
@@ -19571,18 +18547,16 @@ function pathHint(tools, scope) {
|
|
|
19571
18547
|
return relativizeHomeAndCwd(claudeSettingsPath(scope));
|
|
19572
18548
|
case "opencode":
|
|
19573
18549
|
return relativizeHomeAndCwd(opencodeSettingsPath(scope));
|
|
19574
|
-
case "codex":
|
|
19575
|
-
return relativizeHomeAndCwd(codexConfigPath(scope));
|
|
19576
18550
|
}
|
|
19577
18551
|
}
|
|
19578
18552
|
function relativizeHomeAndCwd(absolutePath) {
|
|
19579
|
-
const home =
|
|
18553
|
+
const home = homedir5();
|
|
19580
18554
|
const cwd = userCwd();
|
|
19581
|
-
if (home && absolutePath.startsWith(`${home}
|
|
18555
|
+
if (home && absolutePath.startsWith(`${home}${sep}`)) {
|
|
19582
18556
|
return `~${absolutePath.slice(home.length)}`;
|
|
19583
18557
|
}
|
|
19584
|
-
if (absolutePath.startsWith(`${cwd}
|
|
19585
|
-
return
|
|
18558
|
+
if (absolutePath.startsWith(`${cwd}${sep}`)) {
|
|
18559
|
+
return `.${absolutePath.slice(cwd.length)}`;
|
|
19586
18560
|
}
|
|
19587
18561
|
return absolutePath;
|
|
19588
18562
|
}
|
|
@@ -19590,7 +18564,7 @@ function isTool(value) {
|
|
|
19590
18564
|
return ALL_TOOLS.includes(value);
|
|
19591
18565
|
}
|
|
19592
18566
|
function mergeToolsIntoProjectConfig(cwd, tools, gatewayUrl) {
|
|
19593
|
-
const path =
|
|
18567
|
+
const path = join9(cwd, PROJECT_CONFIG_FILENAME);
|
|
19594
18568
|
const existing = readProjectConfigAt(path) ?? {};
|
|
19595
18569
|
const byTool = new Map((existing.tools ?? []).map((c) => [c.tool, c]));
|
|
19596
18570
|
for (const cfg of tools) byTool.set(cfg.tool, cfg);
|
|
@@ -19684,14 +18658,12 @@ var init_configure = __esm({
|
|
|
19684
18658
|
init_project_config();
|
|
19685
18659
|
init_shell_hook();
|
|
19686
18660
|
init_claude_code();
|
|
19687
|
-
init_codex();
|
|
19688
18661
|
init_opencode();
|
|
19689
18662
|
WRITERS2 = {
|
|
19690
18663
|
"claude-code": writeClaudeCodeConfig,
|
|
19691
|
-
opencode: writeOpencodeConfig
|
|
19692
|
-
codex: writeCodexConfig
|
|
18664
|
+
opencode: writeOpencodeConfig
|
|
19693
18665
|
};
|
|
19694
|
-
ALL_TOOLS = ["claude-code", "opencode"
|
|
18666
|
+
ALL_TOOLS = ["claude-code", "opencode"];
|
|
19695
18667
|
SCOPES = ["local", "project"];
|
|
19696
18668
|
configureCommand = defineCommand({
|
|
19697
18669
|
meta: {
|
|
@@ -19702,7 +18674,7 @@ var init_configure = __esm({
|
|
|
19702
18674
|
tool: {
|
|
19703
18675
|
type: "positional",
|
|
19704
18676
|
required: false,
|
|
19705
|
-
description: "Tool to configure. Prompted if omitted. One of: claude-code, opencode,
|
|
18677
|
+
description: "Tool to configure. Prompted if omitted. One of: claude-code, opencode, all."
|
|
19706
18678
|
},
|
|
19707
18679
|
scope: {
|
|
19708
18680
|
type: "string",
|
|
@@ -19727,7 +18699,7 @@ var init_configure = __esm({
|
|
|
19727
18699
|
);
|
|
19728
18700
|
}
|
|
19729
18701
|
const cwd = userCwd();
|
|
19730
|
-
if (process.stdout.isTTY && !
|
|
18702
|
+
if (process.stdout.isTTY && !existsSync7(join9(cwd, PROJECT_CONFIG_FILENAME))) {
|
|
19731
18703
|
const runInit = unwrap(
|
|
19732
18704
|
await ue({
|
|
19733
18705
|
message: `No ${PROJECT_CONFIG_FILENAME} in this repo yet. Run \`codevector init\` first to set it up (project name, ticket pattern, gateway)?`,
|
|
@@ -20085,15 +19057,13 @@ init_dist();
|
|
|
20085
19057
|
init_dist5();
|
|
20086
19058
|
init_api_client();
|
|
20087
19059
|
init_claude_code();
|
|
20088
|
-
init_codex();
|
|
20089
19060
|
init_opencode();
|
|
20090
19061
|
init_credentials();
|
|
20091
19062
|
init_paths();
|
|
20092
19063
|
init_project_config();
|
|
20093
19064
|
var WRITERS = {
|
|
20094
19065
|
"claude-code": writeClaudeCodeConfig,
|
|
20095
|
-
opencode: writeOpencodeConfig
|
|
20096
|
-
codex: writeCodexConfig
|
|
19066
|
+
opencode: writeOpencodeConfig
|
|
20097
19067
|
};
|
|
20098
19068
|
var configSyncCommand = defineCommand({
|
|
20099
19069
|
meta: {
|
|
@@ -20128,7 +19098,7 @@ var configSyncCommand = defineCommand({
|
|
|
20128
19098
|
`Active profile "${profiles.activeProfile}" is missing from credentials. Run \`codevector auth login\`.`
|
|
20129
19099
|
);
|
|
20130
19100
|
}
|
|
20131
|
-
if (config2.gateway &&
|
|
19101
|
+
if (config2.gateway && trimRightSlash4(creds.gatewayUrl) !== trimRightSlash4(config2.gateway)) {
|
|
20132
19102
|
R2.warn(
|
|
20133
19103
|
`Active profile points at ${creds.gatewayUrl} but manifest pins ${config2.gateway}. Sync will use the active profile.`
|
|
20134
19104
|
);
|
|
@@ -20244,7 +19214,7 @@ async function fetchReachableChatModels(creds) {
|
|
|
20244
19214
|
return [];
|
|
20245
19215
|
}
|
|
20246
19216
|
}
|
|
20247
|
-
function
|
|
19217
|
+
function trimRightSlash4(url2) {
|
|
20248
19218
|
return url2.endsWith("/") ? url2.slice(0, -1) : url2;
|
|
20249
19219
|
}
|
|
20250
19220
|
|
|
@@ -20267,26 +19237,25 @@ init_dist();
|
|
|
20267
19237
|
init_dist5();
|
|
20268
19238
|
init_api_client();
|
|
20269
19239
|
init_claude_code();
|
|
20270
|
-
init_codex();
|
|
20271
19240
|
init_opencode();
|
|
20272
19241
|
init_credentials();
|
|
20273
|
-
import { existsSync as
|
|
20274
|
-
import { join as
|
|
19242
|
+
import { existsSync as existsSync9, readFileSync as readFileSync9, rmSync as rmSync2, writeFileSync as writeFileSync7 } from "fs";
|
|
19243
|
+
import { join as join11 } from "path";
|
|
20275
19244
|
|
|
20276
19245
|
// src/lib/install-pref.ts
|
|
20277
19246
|
init_paths();
|
|
20278
|
-
import { existsSync as
|
|
20279
|
-
import { join as
|
|
19247
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync4, readFileSync as readFileSync8, realpathSync, renameSync as renameSync3, writeFileSync as writeFileSync6 } from "fs";
|
|
19248
|
+
import { join as join10, sep as sep2 } from "path";
|
|
20280
19249
|
import { fileURLToPath } from "url";
|
|
20281
|
-
var INSTALL_PREF_FILE =
|
|
19250
|
+
var INSTALL_PREF_FILE = join10(CODEVECTOR_CONFIG_DIR, "install.json");
|
|
20282
19251
|
var PACKAGE_MANAGERS = ["npm", "pnpm", "yarn"];
|
|
20283
19252
|
function isPackageManager(v2) {
|
|
20284
19253
|
return typeof v2 === "string" && PACKAGE_MANAGERS.includes(v2);
|
|
20285
19254
|
}
|
|
20286
19255
|
function readInstallPref() {
|
|
20287
|
-
if (!
|
|
19256
|
+
if (!existsSync8(INSTALL_PREF_FILE)) return void 0;
|
|
20288
19257
|
try {
|
|
20289
|
-
const raw =
|
|
19258
|
+
const raw = readFileSync8(INSTALL_PREF_FILE, "utf8");
|
|
20290
19259
|
const parsed = JSON.parse(raw);
|
|
20291
19260
|
if (!isPackageManager(parsed.packageManager)) return void 0;
|
|
20292
19261
|
const source = parsed.source === "user" ? "user" : "auto";
|
|
@@ -20300,17 +19269,17 @@ function readInstallPref() {
|
|
|
20300
19269
|
}
|
|
20301
19270
|
}
|
|
20302
19271
|
function writeInstallPref(pref) {
|
|
20303
|
-
|
|
19272
|
+
mkdirSync4(CODEVECTOR_CONFIG_DIR, { recursive: true, mode: 448 });
|
|
20304
19273
|
const tmp = `${INSTALL_PREF_FILE}.${process.pid}.tmp`;
|
|
20305
|
-
|
|
20306
|
-
|
|
19274
|
+
writeFileSync6(tmp, JSON.stringify(pref, null, 2));
|
|
19275
|
+
renameSync3(tmp, INSTALL_PREF_FILE);
|
|
20307
19276
|
}
|
|
20308
19277
|
function packageManagerFromPath(installPath) {
|
|
20309
|
-
if (installPath.includes(`${
|
|
20310
|
-
if (installPath.includes(`${
|
|
19278
|
+
if (installPath.includes(`${sep2}.pnpm${sep2}`)) return "pnpm";
|
|
19279
|
+
if (installPath.includes(`${sep2}.config${sep2}yarn${sep2}global${sep2}`) || installPath.includes(`${sep2}.yarn${sep2}`)) {
|
|
20311
19280
|
return "yarn";
|
|
20312
19281
|
}
|
|
20313
|
-
if (installPath.includes(`${
|
|
19282
|
+
if (installPath.includes(`${sep2}lib${sep2}node_modules${sep2}`)) return "npm";
|
|
20314
19283
|
return void 0;
|
|
20315
19284
|
}
|
|
20316
19285
|
function detectPackageManagerFromInstallPath() {
|
|
@@ -20366,13 +19335,15 @@ var doctorCommand = defineCommand({
|
|
|
20366
19335
|
label: "credentials",
|
|
20367
19336
|
detail: `${creds.email} @ ${creds.gatewayUrl} (${maskApiKey(creds.apiKey)})`
|
|
20368
19337
|
});
|
|
20369
|
-
|
|
20370
|
-
|
|
20371
|
-
level: "
|
|
20372
|
-
|
|
20373
|
-
|
|
20374
|
-
|
|
20375
|
-
|
|
19338
|
+
if (process.platform !== "win32") {
|
|
19339
|
+
checks.push(
|
|
19340
|
+
credentialsFileModeOk() ? { level: "ok", label: "credentials permissions", detail: "chmod 600" } : {
|
|
19341
|
+
level: "warn",
|
|
19342
|
+
label: "credentials permissions",
|
|
19343
|
+
detail: `expected 0600 on ${CREDENTIALS_FILE}`
|
|
19344
|
+
}
|
|
19345
|
+
);
|
|
19346
|
+
}
|
|
20376
19347
|
const client = gatewayClient(creds.gatewayUrl, creds.apiKey, 1e4);
|
|
20377
19348
|
try {
|
|
20378
19349
|
const me2 = await call(parseResponse(client.me.$get()));
|
|
@@ -20420,9 +19391,9 @@ function inspectUpdateManager() {
|
|
|
20420
19391
|
function inspectClaudeSettings() {
|
|
20421
19392
|
for (const scope of CLAUDE_SCOPE_ORDER) {
|
|
20422
19393
|
const path = claudeSettingsPath(scope);
|
|
20423
|
-
if (!
|
|
19394
|
+
if (!existsSync9(path)) continue;
|
|
20424
19395
|
try {
|
|
20425
|
-
const raw = JSON.parse(
|
|
19396
|
+
const raw = JSON.parse(readFileSync9(path, "utf8"));
|
|
20426
19397
|
if (typeof raw.env?.ANTHROPIC_BASE_URL === "string") {
|
|
20427
19398
|
return {
|
|
20428
19399
|
level: "ok",
|
|
@@ -20490,7 +19461,7 @@ function inspectManifestDrift() {
|
|
|
20490
19461
|
});
|
|
20491
19462
|
continue;
|
|
20492
19463
|
}
|
|
20493
|
-
if (!
|
|
19464
|
+
if (!existsSync9(path)) {
|
|
20494
19465
|
checks.push({
|
|
20495
19466
|
level: "fail",
|
|
20496
19467
|
label: `manifest drift: ${tool.tool}`,
|
|
@@ -20500,7 +19471,7 @@ function inspectManifestDrift() {
|
|
|
20500
19471
|
}
|
|
20501
19472
|
let raw;
|
|
20502
19473
|
try {
|
|
20503
|
-
raw =
|
|
19474
|
+
raw = readFileSync9(path, "utf8");
|
|
20504
19475
|
} catch (err) {
|
|
20505
19476
|
checks.push({
|
|
20506
19477
|
level: "fail",
|
|
@@ -20530,7 +19501,7 @@ function pruneAcceptanceHook() {
|
|
|
20530
19501
|
const cleaned = [];
|
|
20531
19502
|
for (const scope of CLAUDE_SCOPE_ORDER) {
|
|
20532
19503
|
const path = claudeSettingsPath(scope);
|
|
20533
|
-
if (!
|
|
19504
|
+
if (!existsSync9(path)) continue;
|
|
20534
19505
|
try {
|
|
20535
19506
|
if (removeAcceptanceHookFromSettings(path)) cleaned.push(scope);
|
|
20536
19507
|
} catch {
|
|
@@ -20543,8 +19514,8 @@ function pruneAcceptanceHook() {
|
|
|
20543
19514
|
detail: `cleared stale hook from claude-code settings [${cleaned.join(", ")}]`
|
|
20544
19515
|
});
|
|
20545
19516
|
}
|
|
20546
|
-
const legacyHooksDir =
|
|
20547
|
-
if (
|
|
19517
|
+
const legacyHooksDir = join11(CODEVECTOR_CONFIG_DIR, "hooks");
|
|
19518
|
+
if (existsSync9(legacyHooksDir)) {
|
|
20548
19519
|
try {
|
|
20549
19520
|
rmSync2(legacyHooksDir, { recursive: true, force: true });
|
|
20550
19521
|
checks.push({
|
|
@@ -20558,7 +19529,7 @@ function pruneAcceptanceHook() {
|
|
|
20558
19529
|
return checks;
|
|
20559
19530
|
}
|
|
20560
19531
|
function removeAcceptanceHookFromSettings(path) {
|
|
20561
|
-
const parsed = JSON.parse(
|
|
19532
|
+
const parsed = JSON.parse(readFileSync9(path, "utf8"));
|
|
20562
19533
|
const hooks = parsed.hooks;
|
|
20563
19534
|
if (!isPlainObject3(hooks)) return false;
|
|
20564
19535
|
let mutated = false;
|
|
@@ -20572,7 +19543,7 @@ function removeAcceptanceHookFromSettings(path) {
|
|
|
20572
19543
|
else hooks[event] = entries;
|
|
20573
19544
|
}
|
|
20574
19545
|
if (Object.keys(hooks).length === 0) delete parsed.hooks;
|
|
20575
|
-
if (mutated)
|
|
19546
|
+
if (mutated) writeFileSync7(path, `${JSON.stringify(parsed, null, 2)}
|
|
20576
19547
|
`);
|
|
20577
19548
|
return mutated;
|
|
20578
19549
|
}
|
|
@@ -20615,8 +19586,6 @@ function manifestToolPath(tool, scope) {
|
|
|
20615
19586
|
return claudeSettingsPath(scope);
|
|
20616
19587
|
case "opencode":
|
|
20617
19588
|
return opencodeSettingsPath(scope);
|
|
20618
|
-
case "codex":
|
|
20619
|
-
return codexConfigPath(scope);
|
|
20620
19589
|
default:
|
|
20621
19590
|
return null;
|
|
20622
19591
|
}
|
|
@@ -20642,6 +19611,7 @@ init_credentials();
|
|
|
20642
19611
|
init_paths();
|
|
20643
19612
|
init_project_config();
|
|
20644
19613
|
init_shell();
|
|
19614
|
+
import { dirname as dirname5 } from "path";
|
|
20645
19615
|
var envCommand = defineCommand({
|
|
20646
19616
|
meta: {
|
|
20647
19617
|
name: "env",
|
|
@@ -20650,8 +19620,8 @@ var envCommand = defineCommand({
|
|
|
20650
19620
|
args: {
|
|
20651
19621
|
shell: {
|
|
20652
19622
|
type: "string",
|
|
20653
|
-
description: "Output dialect: bash, zsh, or
|
|
20654
|
-
valueHint: "bash|zsh|fish"
|
|
19623
|
+
description: "Output dialect: bash, zsh, fish, or powershell.",
|
|
19624
|
+
valueHint: "bash|zsh|fish|powershell"
|
|
20655
19625
|
}
|
|
20656
19626
|
},
|
|
20657
19627
|
async run({ args }) {
|
|
@@ -20659,7 +19629,7 @@ var envCommand = defineCommand({
|
|
|
20659
19629
|
const cwd = userCwd();
|
|
20660
19630
|
const previousDir = process.env.CODEVECTOR_ACTIVE_DIR ?? null;
|
|
20661
19631
|
const found = readProjectConfig(cwd);
|
|
20662
|
-
const repoDir = found?.path ?
|
|
19632
|
+
const repoDir = found?.path ? dirname5(found.path) : null;
|
|
20663
19633
|
const gateway = found?.config.gateway ?? null;
|
|
20664
19634
|
const projectName = found?.config.projectName ?? null;
|
|
20665
19635
|
const lines = [];
|
|
@@ -20689,10 +19659,10 @@ var envCommand = defineCommand({
|
|
|
20689
19659
|
}
|
|
20690
19660
|
const { name: profileName, profile } = match;
|
|
20691
19661
|
const headers = buildAnthropicCustomHeaders(projectName);
|
|
20692
|
-
emitExport(lines, shell, "ANTHROPIC_BASE_URL", `${
|
|
19662
|
+
emitExport(lines, shell, "ANTHROPIC_BASE_URL", `${trimRightSlash5(profile.gatewayUrl)}/gateway/anthropic`);
|
|
20693
19663
|
emitExport(lines, shell, "ANTHROPIC_API_KEY", profile.apiKey);
|
|
20694
19664
|
if (headers) emitExport(lines, shell, "ANTHROPIC_CUSTOM_HEADERS", headers);
|
|
20695
|
-
emitExport(lines, shell, "OPENAI_BASE_URL", `${
|
|
19665
|
+
emitExport(lines, shell, "OPENAI_BASE_URL", `${trimRightSlash5(profile.gatewayUrl)}/gateway/openai/v1`);
|
|
20696
19666
|
emitExport(lines, shell, "OPENAI_API_KEY", profile.apiKey);
|
|
20697
19667
|
emitExport(lines, shell, "CODEVECTOR_ACTIVE_DIR", repoDir);
|
|
20698
19668
|
emitExport(lines, shell, "CODEVECTOR_ACTIVE_PROFILE", profileName);
|
|
@@ -20700,7 +19670,7 @@ var envCommand = defineCommand({
|
|
|
20700
19670
|
emitEcho(
|
|
20701
19671
|
lines,
|
|
20702
19672
|
shell,
|
|
20703
|
-
`codevector: ${profileName} -> ${
|
|
19673
|
+
`codevector: ${profileName} -> ${trimRightSlash5(profile.gatewayUrl)}${projectSuffix}`
|
|
20704
19674
|
);
|
|
20705
19675
|
process.stdout.write(lines.join("\n") + "\n");
|
|
20706
19676
|
}
|
|
@@ -20713,22 +19683,30 @@ function resolveShell(raw) {
|
|
|
20713
19683
|
return raw;
|
|
20714
19684
|
}
|
|
20715
19685
|
function emitExport(lines, shell, name, value) {
|
|
20716
|
-
const quoted =
|
|
20717
|
-
if (shell === "
|
|
19686
|
+
const quoted = quoteForShell(shell, value);
|
|
19687
|
+
if (shell === "powershell") {
|
|
19688
|
+
lines.push(`$env:${name} = ${quoted}`);
|
|
19689
|
+
} else if (shell === "fish") {
|
|
20718
19690
|
lines.push(`set -gx ${name} ${quoted}`);
|
|
20719
19691
|
} else {
|
|
20720
19692
|
lines.push(`export ${name}=${quoted}`);
|
|
20721
19693
|
}
|
|
20722
19694
|
}
|
|
20723
19695
|
function emitUnset(lines, shell, name) {
|
|
20724
|
-
if (shell === "
|
|
19696
|
+
if (shell === "powershell") {
|
|
19697
|
+
lines.push(`Remove-Item -ErrorAction SilentlyContinue Env:\\${name}`);
|
|
19698
|
+
} else if (shell === "fish") {
|
|
20725
19699
|
lines.push(`set -e ${name}`);
|
|
20726
19700
|
} else {
|
|
20727
19701
|
lines.push(`unset ${name}`);
|
|
20728
19702
|
}
|
|
20729
19703
|
}
|
|
20730
|
-
function emitEcho(lines,
|
|
20731
|
-
|
|
19704
|
+
function emitEcho(lines, shell, message) {
|
|
19705
|
+
if (shell === "powershell") {
|
|
19706
|
+
lines.push(`[Console]::Error.WriteLine(${quoteForShell(shell, message)})`);
|
|
19707
|
+
} else {
|
|
19708
|
+
lines.push(`echo ${quoteForShell(shell, message)} 1>&2`);
|
|
19709
|
+
}
|
|
20732
19710
|
}
|
|
20733
19711
|
function emitDeactivate(lines, shell, previousDir) {
|
|
20734
19712
|
for (const name of [
|
|
@@ -20744,16 +19722,15 @@ function emitDeactivate(lines, shell, previousDir) {
|
|
|
20744
19722
|
}
|
|
20745
19723
|
emitEcho(lines, shell, `codevector: left ${previousDir}, credentials cleared.`);
|
|
20746
19724
|
}
|
|
20747
|
-
function
|
|
19725
|
+
function quoteForShell(shell, value) {
|
|
19726
|
+
if (shell === "powershell") {
|
|
19727
|
+
return `'${value.replace(/'/g, "''")}'`;
|
|
19728
|
+
}
|
|
20748
19729
|
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
20749
19730
|
}
|
|
20750
|
-
function
|
|
19731
|
+
function trimRightSlash5(url2) {
|
|
20751
19732
|
return url2.endsWith("/") ? url2.slice(0, -1) : url2;
|
|
20752
19733
|
}
|
|
20753
|
-
function dirOf(filePath) {
|
|
20754
|
-
const idx = filePath.lastIndexOf("/");
|
|
20755
|
-
return idx === -1 ? filePath : filePath.slice(0, idx);
|
|
20756
|
-
}
|
|
20757
19734
|
function buildAnthropicCustomHeaders(projectName) {
|
|
20758
19735
|
if (!projectName) return null;
|
|
20759
19736
|
const safe = projectName.replace(/[\r\n]/g, "").trim();
|
|
@@ -20761,9 +19738,9 @@ function buildAnthropicCustomHeaders(projectName) {
|
|
|
20761
19738
|
return `x-project: ${safe}`;
|
|
20762
19739
|
}
|
|
20763
19740
|
function pickProfileForGateway(profiles, activeProfile, gateway) {
|
|
20764
|
-
const target =
|
|
19741
|
+
const target = trimRightSlash5(gateway);
|
|
20765
19742
|
const matches = Object.entries(profiles).filter(
|
|
20766
|
-
([, p2]) =>
|
|
19743
|
+
([, p2]) => trimRightSlash5(p2.gatewayUrl) === target
|
|
20767
19744
|
);
|
|
20768
19745
|
if (matches.length === 0) return null;
|
|
20769
19746
|
if (activeProfile) {
|
|
@@ -20775,6 +19752,378 @@ function pickProfileForGateway(profiles, activeProfile, gateway) {
|
|
|
20775
19752
|
return { name: picked[0], profile: picked[1] };
|
|
20776
19753
|
}
|
|
20777
19754
|
|
|
19755
|
+
// src/commands/github/index.ts
|
|
19756
|
+
init_dist();
|
|
19757
|
+
|
|
19758
|
+
// src/commands/github/init.ts
|
|
19759
|
+
init_dist();
|
|
19760
|
+
init_dist5();
|
|
19761
|
+
init_api_client();
|
|
19762
|
+
init_credentials();
|
|
19763
|
+
init_paths();
|
|
19764
|
+
init_prompt();
|
|
19765
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync5, writeFileSync as writeFileSync8 } from "fs";
|
|
19766
|
+
import { join as join12 } from "path";
|
|
19767
|
+
|
|
19768
|
+
// src/commands/github/workflow-yaml.ts
|
|
19769
|
+
function generateWorkflowYaml(opts) {
|
|
19770
|
+
const baseUrl = opts.gatewayUrl.replace(/\/$/, "");
|
|
19771
|
+
const sanitized = { ...opts, gatewayUrl: baseUrl };
|
|
19772
|
+
return sanitized.tool === "claude-code" ? claudeCodeWorkflow(sanitized) : opencodeWorkflow(sanitized);
|
|
19773
|
+
}
|
|
19774
|
+
function claudeCodeWorkflow(opts) {
|
|
19775
|
+
const modelEnv = opts.model ? ` ANTHROPIC_MODEL: ${opts.model}
|
|
19776
|
+
` : "";
|
|
19777
|
+
return [
|
|
19778
|
+
`# Generated by codevector github init. Do not edit manually.`,
|
|
19779
|
+
`# Routes all PR review requests through the CodeVector gateway.`,
|
|
19780
|
+
`name: CodeVector PR Review (Claude Code)`,
|
|
19781
|
+
``,
|
|
19782
|
+
`on:`,
|
|
19783
|
+
` pull_request:`,
|
|
19784
|
+
` types: [opened, synchronize]`,
|
|
19785
|
+
` issue_comment:`,
|
|
19786
|
+
` types: [created]`,
|
|
19787
|
+
` pull_request_review_comment:`,
|
|
19788
|
+
` types: [created]`,
|
|
19789
|
+
``,
|
|
19790
|
+
`concurrency:`,
|
|
19791
|
+
` group: codevector-pr-review-claude-code-\${{ github.event.pull_request.number || github.event.issue.number }}`,
|
|
19792
|
+
` cancel-in-progress: true`,
|
|
19793
|
+
``,
|
|
19794
|
+
`permissions:`,
|
|
19795
|
+
` contents: read`,
|
|
19796
|
+
` pull-requests: write`,
|
|
19797
|
+
``,
|
|
19798
|
+
`jobs:`,
|
|
19799
|
+
` review:`,
|
|
19800
|
+
` if: |`,
|
|
19801
|
+
` github.event_name == 'pull_request' ||`,
|
|
19802
|
+
` (github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '@claude')) ||`,
|
|
19803
|
+
` (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude'))`,
|
|
19804
|
+
` runs-on: ubuntu-latest`,
|
|
19805
|
+
` steps:`,
|
|
19806
|
+
` - uses: actions/checkout@v4`,
|
|
19807
|
+
` - uses: actions/setup-node@v4`,
|
|
19808
|
+
` with:`,
|
|
19809
|
+
` node-version: '24'`,
|
|
19810
|
+
` - run: npm install -g @anthropic-ai/claude-code`,
|
|
19811
|
+
` - name: Review PR`,
|
|
19812
|
+
` env:`,
|
|
19813
|
+
` ANTHROPIC_API_KEY: \${{ secrets.${opts.secretName} }}`,
|
|
19814
|
+
` ANTHROPIC_BASE_URL: ${opts.gatewayUrl}/gateway/anthropic`,
|
|
19815
|
+
`${modelEnv}`,
|
|
19816
|
+
` run: |`,
|
|
19817
|
+
` claude --dangerously-skip-permissions -p "Review this PR and provide concise, actionable feedback. Focus on bugs, security issues, and code quality." \\`,
|
|
19818
|
+
` --output-format text \\`,
|
|
19819
|
+
` --allowedTools "Bash(git diff origin/\${{ github.base_ref }}...HEAD),Bash(git log origin/\${{ github.base_ref }}..HEAD),Read" \\`,
|
|
19820
|
+
` > review.md`,
|
|
19821
|
+
` - name: Post review comment`,
|
|
19822
|
+
` env:`,
|
|
19823
|
+
` GH_TOKEN: \${{ github.token }}`,
|
|
19824
|
+
` run: |`,
|
|
19825
|
+
` gh pr comment \${{ github.event.pull_request.number || github.event.issue.number }} --body-file review.md`
|
|
19826
|
+
].join("\n").trimEnd() + "\n";
|
|
19827
|
+
}
|
|
19828
|
+
function opencodeModelEntryLines(model) {
|
|
19829
|
+
const name = model.split("-").map((w3) => w3.charAt(0).toUpperCase() + w3.slice(1)).join(" ");
|
|
19830
|
+
return [
|
|
19831
|
+
` "models": {`,
|
|
19832
|
+
` "${model}": {`,
|
|
19833
|
+
` "name": "${name}"`,
|
|
19834
|
+
` }`,
|
|
19835
|
+
` }`
|
|
19836
|
+
];
|
|
19837
|
+
}
|
|
19838
|
+
function opencodeWorkflow(opts) {
|
|
19839
|
+
const model = opts.model || "deepseek-pro";
|
|
19840
|
+
return [
|
|
19841
|
+
`# Generated by codevector github init. Do not edit manually.`,
|
|
19842
|
+
`# Routes all PR review requests through the CodeVector gateway via OpenCode CLI.`,
|
|
19843
|
+
`name: CodeVector PR Review (OpenCode)`,
|
|
19844
|
+
``,
|
|
19845
|
+
`on:`,
|
|
19846
|
+
` pull_request:`,
|
|
19847
|
+
` types: [opened, synchronize]`,
|
|
19848
|
+
` issue_comment:`,
|
|
19849
|
+
` types: [created]`,
|
|
19850
|
+
` pull_request_review_comment:`,
|
|
19851
|
+
` types: [created]`,
|
|
19852
|
+
``,
|
|
19853
|
+
`concurrency:`,
|
|
19854
|
+
` group: codevector-pr-review-opencode-\${{ github.event.pull_request.number || github.event.issue.number }}`,
|
|
19855
|
+
` cancel-in-progress: true`,
|
|
19856
|
+
``,
|
|
19857
|
+
`permissions:`,
|
|
19858
|
+
` contents: read`,
|
|
19859
|
+
` pull-requests: write`,
|
|
19860
|
+
``,
|
|
19861
|
+
`jobs:`,
|
|
19862
|
+
` review:`,
|
|
19863
|
+
` if: |`,
|
|
19864
|
+
` github.event_name == 'pull_request' ||`,
|
|
19865
|
+
` (github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '@opencode')) ||`,
|
|
19866
|
+
` (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@opencode'))`,
|
|
19867
|
+
` runs-on: ubuntu-latest`,
|
|
19868
|
+
` steps:`,
|
|
19869
|
+
` - uses: actions/checkout@v4`,
|
|
19870
|
+
` - name: Install OpenCode CLI`,
|
|
19871
|
+
` run: curl -fsSL https://opencode.ai/install | bash`,
|
|
19872
|
+
` - name: Configure OpenCode`,
|
|
19873
|
+
` run: |`,
|
|
19874
|
+
` cat > opencode.json << 'OPEOF'`,
|
|
19875
|
+
` {`,
|
|
19876
|
+
` "$schema": "https://opencode.ai/config.json",`,
|
|
19877
|
+
` "provider": {`,
|
|
19878
|
+
` "codevector": {`,
|
|
19879
|
+
` "options": {`,
|
|
19880
|
+
` "apiKey": "{env:CODEVECTOR_API_KEY}",`,
|
|
19881
|
+
` "baseURL": "${opts.gatewayUrl}/gateway/openai/v1",`,
|
|
19882
|
+
` "headers": {`,
|
|
19883
|
+
` "x-client-app": "opencode",`,
|
|
19884
|
+
` "x-project": "codevector"`,
|
|
19885
|
+
` }`,
|
|
19886
|
+
` },`,
|
|
19887
|
+
...opencodeModelEntryLines(model),
|
|
19888
|
+
` }`,
|
|
19889
|
+
` },`,
|
|
19890
|
+
` "model": "codevector/${model}"`,
|
|
19891
|
+
` }`,
|
|
19892
|
+
` OPEOF`,
|
|
19893
|
+
` - name: Generate PR Diff`,
|
|
19894
|
+
` env:`,
|
|
19895
|
+
` GH_TOKEN: \${{ github.token }}`,
|
|
19896
|
+
` run: |`,
|
|
19897
|
+
` PR_NUMBER=\${{ github.event.pull_request.number || github.event.issue.number }}`,
|
|
19898
|
+
` gh pr diff $PR_NUMBER > pr_diff.txt`,
|
|
19899
|
+
` - name: Fetch AI Review`,
|
|
19900
|
+
` env:`,
|
|
19901
|
+
` CODEVECTOR_API_KEY: \${{ secrets.${opts.secretName} }}`,
|
|
19902
|
+
` run: |`,
|
|
19903
|
+
` export PATH="$HOME/.opencode/bin:$PATH"`,
|
|
19904
|
+
` opencode run --model codevector/${model} \\`,
|
|
19905
|
+
` --dangerously-skip-permissions \\`,
|
|
19906
|
+
` "Review this PR and provide concise, actionable feedback. Focus on bugs, security issues, and code quality." \\`,
|
|
19907
|
+
` -f pr_diff.txt \\`,
|
|
19908
|
+
` > review.md`,
|
|
19909
|
+
` - name: Post review comment`,
|
|
19910
|
+
` env:`,
|
|
19911
|
+
` GH_TOKEN: \${{ github.token }}`,
|
|
19912
|
+
` run: |`,
|
|
19913
|
+
` PR_NUMBER=\${{ github.event.pull_request.number || github.event.issue.number }}`,
|
|
19914
|
+
` gh pr comment $PR_NUMBER --body-file review.md`
|
|
19915
|
+
].join("\n").trimEnd() + "\n";
|
|
19916
|
+
}
|
|
19917
|
+
|
|
19918
|
+
// src/commands/github/init.ts
|
|
19919
|
+
var ALL_TOOLS2 = ["claude-code", "opencode"];
|
|
19920
|
+
var WORKFLOW_FILENAMES = {
|
|
19921
|
+
"claude-code": "codevector-pr-review-claude-code.yml",
|
|
19922
|
+
opencode: "codevector-pr-review-opencode.yml"
|
|
19923
|
+
};
|
|
19924
|
+
var githubInitCommand = defineCommand({
|
|
19925
|
+
meta: {
|
|
19926
|
+
name: "init",
|
|
19927
|
+
description: "Generate a GitHub Actions workflow that routes PR review through the CodeVector gateway."
|
|
19928
|
+
},
|
|
19929
|
+
args: {
|
|
19930
|
+
tool: {
|
|
19931
|
+
type: "string",
|
|
19932
|
+
description: "Tool: claude-code or opencode. Prompted if omitted.",
|
|
19933
|
+
valueHint: "claude-code|opencode"
|
|
19934
|
+
},
|
|
19935
|
+
model: {
|
|
19936
|
+
type: "string",
|
|
19937
|
+
description: "Model slug to pin for PR review. Prompted if interactive and --tool is set."
|
|
19938
|
+
},
|
|
19939
|
+
"secret-name": {
|
|
19940
|
+
type: "string",
|
|
19941
|
+
default: "CODEVECTOR_API_KEY",
|
|
19942
|
+
description: "GitHub secret name for the API key."
|
|
19943
|
+
},
|
|
19944
|
+
"gateway-url": {
|
|
19945
|
+
type: "string",
|
|
19946
|
+
description: "Gateway base URL. Uses the active profile if omitted."
|
|
19947
|
+
},
|
|
19948
|
+
force: {
|
|
19949
|
+
type: "boolean",
|
|
19950
|
+
default: false,
|
|
19951
|
+
description: "Overwrite existing workflow file without prompting."
|
|
19952
|
+
},
|
|
19953
|
+
"dry-run": {
|
|
19954
|
+
type: "boolean",
|
|
19955
|
+
default: false,
|
|
19956
|
+
description: "Print the workflow to stdout instead of writing to disk."
|
|
19957
|
+
}
|
|
19958
|
+
},
|
|
19959
|
+
async run({ args }) {
|
|
19960
|
+
const interactive = isInteractive2(args);
|
|
19961
|
+
if (interactive) ge("codevector github init");
|
|
19962
|
+
const profile = await getActiveProfile();
|
|
19963
|
+
const gatewayUrl = resolveGatewayUrl(args, profile, interactive);
|
|
19964
|
+
const tool = await resolveTool(args, interactive);
|
|
19965
|
+
const model = await resolveModel(args, tool, gatewayUrl, profile, interactive);
|
|
19966
|
+
const secretName = args["secret-name"] ?? "CODEVECTOR_API_KEY";
|
|
19967
|
+
const yaml = generateWorkflowYaml({
|
|
19968
|
+
tool,
|
|
19969
|
+
gatewayUrl: gatewayUrl.replace(/\/$/, ""),
|
|
19970
|
+
secretName,
|
|
19971
|
+
...model ? { model } : {}
|
|
19972
|
+
});
|
|
19973
|
+
if (args["dry-run"]) {
|
|
19974
|
+
process.stdout.write(yaml);
|
|
19975
|
+
if (interactive) {
|
|
19976
|
+
Se(
|
|
19977
|
+
`Run without --dry-run to write .github/workflows/${WORKFLOW_FILENAMES[tool]}.`,
|
|
19978
|
+
"Dry run"
|
|
19979
|
+
);
|
|
19980
|
+
ye("Done.");
|
|
19981
|
+
}
|
|
19982
|
+
return;
|
|
19983
|
+
}
|
|
19984
|
+
const cwd = userCwd();
|
|
19985
|
+
const workflowsDir = join12(cwd, ".github", "workflows");
|
|
19986
|
+
const filePath = join12(workflowsDir, WORKFLOW_FILENAMES[tool]);
|
|
19987
|
+
if (existsSync10(filePath) && !args.force) {
|
|
19988
|
+
if (!interactive) {
|
|
19989
|
+
throw new Error(
|
|
19990
|
+
`${filePath} already exists. Pass --force to overwrite.`
|
|
19991
|
+
);
|
|
19992
|
+
}
|
|
19993
|
+
const overwrite = unwrap(
|
|
19994
|
+
await ue({
|
|
19995
|
+
message: `${WORKFLOW_FILENAMES[tool]} already exists. Overwrite?`,
|
|
19996
|
+
initialValue: false
|
|
19997
|
+
})
|
|
19998
|
+
);
|
|
19999
|
+
if (!overwrite) {
|
|
20000
|
+
ye("Cancelled.");
|
|
20001
|
+
return;
|
|
20002
|
+
}
|
|
20003
|
+
}
|
|
20004
|
+
mkdirSync5(workflowsDir, { recursive: true });
|
|
20005
|
+
writeFileSync8(filePath, yaml, { mode: 420 });
|
|
20006
|
+
if (interactive) {
|
|
20007
|
+
R2.success(`Wrote ${filePath}`);
|
|
20008
|
+
Se(
|
|
20009
|
+
`Run this to activate:
|
|
20010
|
+
gh secret set ${secretName} --body "cv_xxxx"`,
|
|
20011
|
+
"Next step"
|
|
20012
|
+
);
|
|
20013
|
+
ye("Done.");
|
|
20014
|
+
} else {
|
|
20015
|
+
R2.success(`Wrote ${filePath}`);
|
|
20016
|
+
}
|
|
20017
|
+
}
|
|
20018
|
+
});
|
|
20019
|
+
function isInteractive2(args) {
|
|
20020
|
+
if (!process.stdout.isTTY) return false;
|
|
20021
|
+
return !args.tool || !args["gateway-url"];
|
|
20022
|
+
}
|
|
20023
|
+
function resolveGatewayUrl(args, profile, interactive) {
|
|
20024
|
+
if (args["gateway-url"]) {
|
|
20025
|
+
const url2 = args["gateway-url"];
|
|
20026
|
+
try {
|
|
20027
|
+
new URL(url2);
|
|
20028
|
+
} catch {
|
|
20029
|
+
throw new Error(`Invalid --gateway-url: "${url2}" is not a valid URL.`);
|
|
20030
|
+
}
|
|
20031
|
+
return url2;
|
|
20032
|
+
}
|
|
20033
|
+
if (profile) return profile.gatewayUrl;
|
|
20034
|
+
if (!interactive) {
|
|
20035
|
+
throw new Error(
|
|
20036
|
+
"No active profile and --gateway-url not provided. Run `codevector auth login` or pass --gateway-url."
|
|
20037
|
+
);
|
|
20038
|
+
}
|
|
20039
|
+
throw new Error(
|
|
20040
|
+
"Not signed in and --gateway-url not provided. Run `codevector auth login` first, or pass --gateway-url."
|
|
20041
|
+
);
|
|
20042
|
+
}
|
|
20043
|
+
async function resolveTool(args, interactive) {
|
|
20044
|
+
if (args.tool) {
|
|
20045
|
+
if (!isTool2(args.tool)) {
|
|
20046
|
+
throw new Error(
|
|
20047
|
+
`Unsupported tool "${args.tool}". Use one of: ${ALL_TOOLS2.join(", ")}.`
|
|
20048
|
+
);
|
|
20049
|
+
}
|
|
20050
|
+
return args.tool;
|
|
20051
|
+
}
|
|
20052
|
+
if (!interactive) {
|
|
20053
|
+
throw new Error("--tool is required in non-interactive mode.");
|
|
20054
|
+
}
|
|
20055
|
+
return unwrap(
|
|
20056
|
+
await xe({
|
|
20057
|
+
message: "Which tool should the workflow use for PR review?",
|
|
20058
|
+
options: [
|
|
20059
|
+
{ value: "claude-code", label: "Claude Code", hint: "uses the @anthropic-ai/claude-code CLI" },
|
|
20060
|
+
{ value: "opencode", label: "OpenCode", hint: "uses the OpenCode CLI" }
|
|
20061
|
+
],
|
|
20062
|
+
initialValue: "claude-code"
|
|
20063
|
+
})
|
|
20064
|
+
);
|
|
20065
|
+
}
|
|
20066
|
+
async function resolveModel(args, _tool, gatewayUrl, profile, interactive) {
|
|
20067
|
+
if (args.model) return args.model;
|
|
20068
|
+
if (!interactive) return void 0;
|
|
20069
|
+
const models = profile ? await fetchReachableChatModels3(gatewayUrl, profile.apiKey) : [];
|
|
20070
|
+
if (models.length === 0) {
|
|
20071
|
+
R2.info("No chat models reachable \u2014 skipping model pin.");
|
|
20072
|
+
return void 0;
|
|
20073
|
+
}
|
|
20074
|
+
const SKIP = "__skip__";
|
|
20075
|
+
const picked = unwrap(
|
|
20076
|
+
await xe({
|
|
20077
|
+
message: "Pin a default model for PR review? (optional)",
|
|
20078
|
+
options: [
|
|
20079
|
+
{ value: SKIP, label: "Skip (recommended)", hint: "let the tool pick per request" },
|
|
20080
|
+
...models.map((m2) => ({
|
|
20081
|
+
value: m2.slug,
|
|
20082
|
+
label: m2.slug,
|
|
20083
|
+
hint: `${m2.displayName}${m2.providerKind ? ` \xB7 ${m2.providerKind}` : ""}`
|
|
20084
|
+
}))
|
|
20085
|
+
],
|
|
20086
|
+
initialValue: SKIP
|
|
20087
|
+
})
|
|
20088
|
+
);
|
|
20089
|
+
return picked === SKIP ? void 0 : picked;
|
|
20090
|
+
}
|
|
20091
|
+
async function fetchReachableChatModels3(gatewayUrl, apiKey) {
|
|
20092
|
+
const client = gatewayClient(gatewayUrl, apiKey, 1e4);
|
|
20093
|
+
const s = ft();
|
|
20094
|
+
s.start("Loading reachable models\u2026");
|
|
20095
|
+
try {
|
|
20096
|
+
const res = await call(parseResponse(client.models.$get()));
|
|
20097
|
+
const models = res.data.filter((m2) => m2.kind === "chat").map((m2) => ({
|
|
20098
|
+
slug: m2.slug,
|
|
20099
|
+
providerKind: m2.providerKind,
|
|
20100
|
+
displayName: m2.displayName
|
|
20101
|
+
}));
|
|
20102
|
+
s.stop(`${models.length} model${models.length === 1 ? "" : "s"} reachable`);
|
|
20103
|
+
return models;
|
|
20104
|
+
} catch (err) {
|
|
20105
|
+
s.stop("Could not load models");
|
|
20106
|
+
R2.warn(
|
|
20107
|
+
`Continuing without model list \u2014 ${err instanceof ApiClientError ? err.message : String(err)}.`
|
|
20108
|
+
);
|
|
20109
|
+
return [];
|
|
20110
|
+
}
|
|
20111
|
+
}
|
|
20112
|
+
function isTool2(value) {
|
|
20113
|
+
return ALL_TOOLS2.includes(value);
|
|
20114
|
+
}
|
|
20115
|
+
|
|
20116
|
+
// src/commands/github/index.ts
|
|
20117
|
+
var githubCommand = defineCommand({
|
|
20118
|
+
meta: {
|
|
20119
|
+
name: "github",
|
|
20120
|
+
description: "Generate GitHub Actions workflows that route PR review through the CodeVector gateway."
|
|
20121
|
+
},
|
|
20122
|
+
subCommands: {
|
|
20123
|
+
init: githubInitCommand
|
|
20124
|
+
}
|
|
20125
|
+
});
|
|
20126
|
+
|
|
20778
20127
|
// src/commands/hook.ts
|
|
20779
20128
|
init_dist();
|
|
20780
20129
|
init_shell();
|
|
@@ -20787,8 +20136,8 @@ var hookCommand = defineCommand({
|
|
|
20787
20136
|
shell: {
|
|
20788
20137
|
type: "positional",
|
|
20789
20138
|
required: false,
|
|
20790
|
-
description: "Target shell: bash, zsh, or
|
|
20791
|
-
valueHint: "bash|zsh|fish"
|
|
20139
|
+
description: "Target shell: bash, zsh, fish, or powershell.",
|
|
20140
|
+
valueHint: "bash|zsh|fish|powershell"
|
|
20792
20141
|
}
|
|
20793
20142
|
},
|
|
20794
20143
|
run({ args }) {
|
|
@@ -20819,6 +20168,8 @@ function snippetFor(shell) {
|
|
|
20819
20168
|
return ZSH_SNIPPET;
|
|
20820
20169
|
case "fish":
|
|
20821
20170
|
return FISH_SNIPPET;
|
|
20171
|
+
case "powershell":
|
|
20172
|
+
return POWERSHELL_SNIPPET;
|
|
20822
20173
|
}
|
|
20823
20174
|
}
|
|
20824
20175
|
var BASH_SNIPPET = `# codevector shell hook (bash) \u2014 auto-activates credentials on cd
|
|
@@ -20856,6 +20207,22 @@ end
|
|
|
20856
20207
|
# Run once for the current directory at shell startup.
|
|
20857
20208
|
_codevector_on_pwd
|
|
20858
20209
|
`;
|
|
20210
|
+
var POWERSHELL_SNIPPET = `# codevector shell hook (powershell) \u2014 auto-activates credentials on cd
|
|
20211
|
+
function global:_codevector_on_prompt {
|
|
20212
|
+
if ($PWD.Path -eq $global:_CODEVECTOR_LAST_PWD) { return }
|
|
20213
|
+
$global:_CODEVECTOR_LAST_PWD = $PWD.Path
|
|
20214
|
+
$out = (& codevector env --shell powershell 2>$null | Out-String)
|
|
20215
|
+
if ($out.Trim().Length -gt 0) { Invoke-Expression $out }
|
|
20216
|
+
}
|
|
20217
|
+
if (-not $global:_CODEVECTOR_PROMPT_WRAPPED) {
|
|
20218
|
+
$global:_CODEVECTOR_PROMPT_WRAPPED = $true
|
|
20219
|
+
$global:_CODEVECTOR_ORIG_PROMPT = $function:prompt
|
|
20220
|
+
function global:prompt {
|
|
20221
|
+
_codevector_on_prompt
|
|
20222
|
+
if ($global:_CODEVECTOR_ORIG_PROMPT) { & $global:_CODEVECTOR_ORIG_PROMPT } else { "PS $($PWD.Path)> " }
|
|
20223
|
+
}
|
|
20224
|
+
}
|
|
20225
|
+
`;
|
|
20859
20226
|
|
|
20860
20227
|
// src/index.ts
|
|
20861
20228
|
init_init();
|
|
@@ -21067,20 +20434,16 @@ var modelsCommand = defineCommand({
|
|
|
21067
20434
|
// src/commands/profile.ts
|
|
21068
20435
|
init_dist();
|
|
21069
20436
|
init_dist5();
|
|
21070
|
-
init_dist6();
|
|
21071
20437
|
init_claude_code();
|
|
21072
|
-
init_codex();
|
|
21073
20438
|
init_opencode();
|
|
21074
20439
|
init_api_client();
|
|
21075
20440
|
init_credentials();
|
|
21076
20441
|
init_paths();
|
|
21077
20442
|
init_prompt();
|
|
21078
20443
|
init_project_context();
|
|
21079
|
-
import { existsSync as existsSync11, readFileSync as readFileSync11 } from "fs";
|
|
21080
20444
|
var WRITERS3 = {
|
|
21081
20445
|
"claude-code": writeClaudeCodeConfig,
|
|
21082
|
-
opencode: writeOpencodeConfig
|
|
21083
|
-
codex: writeCodexConfig
|
|
20446
|
+
opencode: writeOpencodeConfig
|
|
21084
20447
|
};
|
|
21085
20448
|
var profileListCommand = defineCommand({
|
|
21086
20449
|
meta: {
|
|
@@ -21148,14 +20511,9 @@ Gateway: ${active.gatewayUrl}
|
|
|
21148
20511
|
Key: ${maskApiKey(active.apiKey)}`,
|
|
21149
20512
|
`Profile: ${selected}`
|
|
21150
20513
|
);
|
|
21151
|
-
const
|
|
21152
|
-
|
|
21153
|
-
|
|
21154
|
-
const toolConfigs = hasCodexUserConfig ? storedToolConfigs : [...storedToolConfigs, defaultCodexConfig];
|
|
21155
|
-
if (!hasCodexUserConfig) {
|
|
21156
|
-
R2.info(
|
|
21157
|
-
storedToolConfigs.length === 0 ? "No stored tool configurations for this profile; applying codex user-scope config." : "No stored codex configuration for this profile; applying codex user-scope config."
|
|
21158
|
-
);
|
|
20514
|
+
const toolConfigs = active.toolConfigs ?? [];
|
|
20515
|
+
if (toolConfigs.length === 0) {
|
|
20516
|
+
R2.info("No stored tool configurations for this profile; nothing to reapply.");
|
|
21159
20517
|
}
|
|
21160
20518
|
const fetched = await fetchReachableModels(active.gatewayUrl, active.apiKey);
|
|
21161
20519
|
if (!fetched.ok) {
|
|
@@ -21184,28 +20542,12 @@ Key: ${maskApiKey(active.apiKey)}`,
|
|
|
21184
20542
|
});
|
|
21185
20543
|
continue;
|
|
21186
20544
|
}
|
|
21187
|
-
const storedModelSlug =
|
|
20545
|
+
const storedModelSlug = tc.modelSlug;
|
|
21188
20546
|
const reachableModel = storedModelSlug ? reachable.find((m2) => m2.slug === storedModelSlug) : void 0;
|
|
21189
|
-
const
|
|
21190
|
-
let modelArg = storedModelSlug && pinAllowed ? { slug: reachableModel.slug, providerKind: reachableModel.providerKind } : void 0;
|
|
20547
|
+
const modelArg = reachableModel ? { slug: reachableModel.slug, providerKind: reachableModel.providerKind } : void 0;
|
|
21191
20548
|
let extraNote;
|
|
21192
|
-
if (
|
|
21193
|
-
extraNote = `Pinned model "codex" is an alias; selecting a concrete reachable model for this profile.`;
|
|
21194
|
-
} else if (storedModelSlug && !reachableModel) {
|
|
20549
|
+
if (storedModelSlug && !reachableModel) {
|
|
21195
20550
|
extraNote = `Pinned model "${tc.modelSlug}" is not reachable with this profile; model pin removed.`;
|
|
21196
|
-
} else if (storedModelSlug && reachableModel && !pinAllowed) {
|
|
21197
|
-
extraNote = `Pinned model "${tc.modelSlug}" is incompatible with Codex Responses; model pin removed.`;
|
|
21198
|
-
}
|
|
21199
|
-
if (tool === "codex" && !modelArg) {
|
|
21200
|
-
const fallback = pickCodexFallbackModel(reachable);
|
|
21201
|
-
if (fallback) {
|
|
21202
|
-
modelArg = { slug: fallback.slug, providerKind: fallback.providerKind };
|
|
21203
|
-
if (tc.modelSlug) {
|
|
21204
|
-
extraNote = `Pinned model "${tc.modelSlug}" unavailable for this profile; defaulting Codex to "${fallback.slug}".`;
|
|
21205
|
-
} else {
|
|
21206
|
-
extraNote = `No stored Codex model pin for this profile; defaulting to "${fallback.slug}".`;
|
|
21207
|
-
}
|
|
21208
|
-
}
|
|
21209
20551
|
}
|
|
21210
20552
|
try {
|
|
21211
20553
|
const result = writer({
|
|
@@ -21249,18 +20591,6 @@ Key: ${maskApiKey(active.apiKey)}`,
|
|
|
21249
20591
|
return ` ! ${r.tool}: skipped \u2014 ${r.notes ?? "unknown reason"}`;
|
|
21250
20592
|
});
|
|
21251
20593
|
Se(lines.join("\n"), "Tool configurations updated");
|
|
21252
|
-
const codexConfigured = results.some(
|
|
21253
|
-
(r) => r.tool === "codex" && r.status === "configured"
|
|
21254
|
-
);
|
|
21255
|
-
if (codexConfigured) {
|
|
21256
|
-
Se(
|
|
21257
|
-
`codex reads its API key from $CODEVECTOR_GATEWAY_KEY in your shell, not from codevector's credentials file.
|
|
21258
|
-
Update your shell to use this profile's key:
|
|
21259
|
-
export CODEVECTOR_GATEWAY_KEY=${active.apiKey}
|
|
21260
|
-
Or add it to your shell rc to persist across sessions.`,
|
|
21261
|
-
"codex requires env var update"
|
|
21262
|
-
);
|
|
21263
|
-
}
|
|
21264
20594
|
}
|
|
21265
20595
|
});
|
|
21266
20596
|
var profileCommand = defineCommand({
|
|
@@ -21303,42 +20633,6 @@ async function fetchReachableModels(gatewayUrl, apiKey) {
|
|
|
21303
20633
|
return { ok: false, reason: err instanceof ApiClientError ? err.message : String(err) };
|
|
21304
20634
|
}
|
|
21305
20635
|
}
|
|
21306
|
-
function isResponsesCompatibleProviderKind(providerKind) {
|
|
21307
|
-
return providerKind === "openai" || providerKind === "openai_compatible";
|
|
21308
|
-
}
|
|
21309
|
-
function pickCodexFallbackModel(reachable) {
|
|
21310
|
-
const candidates = reachable.filter((m2) => isResponsesCompatibleProviderKind(m2.providerKind));
|
|
21311
|
-
if (candidates.length === 0) {
|
|
21312
|
-
return void 0;
|
|
21313
|
-
}
|
|
21314
|
-
const ranked = readCodexNuxRankedModels();
|
|
21315
|
-
for (const slug of ranked) {
|
|
21316
|
-
const match = candidates.find((m2) => m2.slug === slug);
|
|
21317
|
-
if (match) return match;
|
|
21318
|
-
}
|
|
21319
|
-
return candidates[0];
|
|
21320
|
-
}
|
|
21321
|
-
function readCodexNuxRankedModels() {
|
|
21322
|
-
const path = codexConfigPath();
|
|
21323
|
-
if (!existsSync11(path)) return [];
|
|
21324
|
-
let parsed;
|
|
21325
|
-
try {
|
|
21326
|
-
parsed = parse3(readFileSync11(path, "utf8"));
|
|
21327
|
-
} catch {
|
|
21328
|
-
return [];
|
|
21329
|
-
}
|
|
21330
|
-
if (!isObject5(parsed)) return [];
|
|
21331
|
-
const tui = asObject(parsed.tui);
|
|
21332
|
-
const availability = asObject(tui?.model_availability_nux);
|
|
21333
|
-
if (!availability) return [];
|
|
21334
|
-
return Object.entries(availability).filter((entry) => typeof entry[1] === "number" && Number.isFinite(entry[1])).sort((a, b2) => b2[1] - a[1] || a[0].localeCompare(b2[0])).map(([slug]) => slug);
|
|
21335
|
-
}
|
|
21336
|
-
function isObject5(value) {
|
|
21337
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21338
|
-
}
|
|
21339
|
-
function asObject(value) {
|
|
21340
|
-
return isObject5(value) ? value : void 0;
|
|
21341
|
-
}
|
|
21342
20636
|
|
|
21343
20637
|
// src/commands/skills.ts
|
|
21344
20638
|
init_dist();
|
|
@@ -21560,24 +20854,24 @@ Last saved: ${creds.savedAt}`,
|
|
|
21560
20854
|
init_dist();
|
|
21561
20855
|
init_dist5();
|
|
21562
20856
|
init_api_client();
|
|
21563
|
-
import { existsSync as
|
|
20857
|
+
import { existsSync as existsSync12 } from "fs";
|
|
21564
20858
|
|
|
21565
20859
|
// src/lib/backup.ts
|
|
21566
20860
|
import {
|
|
21567
20861
|
copyFileSync,
|
|
21568
|
-
existsSync as
|
|
20862
|
+
existsSync as existsSync11,
|
|
21569
20863
|
mkdirSync as mkdirSync6,
|
|
21570
20864
|
readdirSync,
|
|
21571
|
-
statSync as
|
|
20865
|
+
statSync as statSync4
|
|
21572
20866
|
} from "fs";
|
|
21573
20867
|
import { basename, dirname as dirname6, join as join13 } from "path";
|
|
21574
|
-
import { homedir as
|
|
21575
|
-
var BACKUP_ROOT = process.env.CODEVECTOR_BACKUP_ROOT ?? join13(
|
|
20868
|
+
import { homedir as homedir6 } from "os";
|
|
20869
|
+
var BACKUP_ROOT = process.env.CODEVECTOR_BACKUP_ROOT ?? join13(homedir6(), ".codevector", "backups");
|
|
21576
20870
|
function backupTimestamp(d = /* @__PURE__ */ new Date()) {
|
|
21577
20871
|
return d.toISOString().replace(/:/g, "-");
|
|
21578
20872
|
}
|
|
21579
20873
|
function backupFile(sourcePath, tool, timestamp) {
|
|
21580
|
-
if (!
|
|
20874
|
+
if (!existsSync11(sourcePath)) return void 0;
|
|
21581
20875
|
const destDir = join13(BACKUP_ROOT, timestamp, tool);
|
|
21582
20876
|
mkdirSync6(destDir, { recursive: true, mode: 448 });
|
|
21583
20877
|
const dest = join13(destDir, basename(sourcePath));
|
|
@@ -21585,7 +20879,7 @@ function backupFile(sourcePath, tool, timestamp) {
|
|
|
21585
20879
|
return dest;
|
|
21586
20880
|
}
|
|
21587
20881
|
function listBackupRuns() {
|
|
21588
|
-
if (!
|
|
20882
|
+
if (!existsSync11(BACKUP_ROOT)) return [];
|
|
21589
20883
|
const entries = readdirSync(BACKUP_ROOT, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort().reverse();
|
|
21590
20884
|
const runs = [];
|
|
21591
20885
|
for (const ts of entries) {
|
|
@@ -21610,14 +20904,14 @@ function listBackupRuns() {
|
|
|
21610
20904
|
return runs;
|
|
21611
20905
|
}
|
|
21612
20906
|
function restoreBackup(backupPath, originalPath) {
|
|
21613
|
-
if (!
|
|
20907
|
+
if (!existsSync11(backupPath)) {
|
|
21614
20908
|
throw new Error(`Backup file missing: ${backupPath}`);
|
|
21615
20909
|
}
|
|
21616
20910
|
mkdirSync6(dirname6(originalPath), { recursive: true });
|
|
21617
20911
|
copyFileSync(backupPath, originalPath);
|
|
21618
20912
|
}
|
|
21619
20913
|
function backupRunMtime(dir) {
|
|
21620
|
-
return
|
|
20914
|
+
return statSync4(dir).mtime;
|
|
21621
20915
|
}
|
|
21622
20916
|
|
|
21623
20917
|
// src/commands/system.ts
|
|
@@ -21625,13 +20919,11 @@ init_credentials();
|
|
|
21625
20919
|
init_prompt();
|
|
21626
20920
|
init_shell_hook();
|
|
21627
20921
|
init_claude_code();
|
|
21628
|
-
init_codex();
|
|
21629
20922
|
init_opencode();
|
|
21630
|
-
var TOOLS = ["claude-code", "opencode"
|
|
20923
|
+
var TOOLS = ["claude-code", "opencode"];
|
|
21631
20924
|
var WRITERS4 = {
|
|
21632
20925
|
"claude-code": writeClaudeCodeConfig,
|
|
21633
|
-
opencode: writeOpencodeConfig
|
|
21634
|
-
codex: writeCodexConfig
|
|
20926
|
+
opencode: writeOpencodeConfig
|
|
21635
20927
|
};
|
|
21636
20928
|
function userPathFor(tool) {
|
|
21637
20929
|
switch (tool) {
|
|
@@ -21639,8 +20931,6 @@ function userPathFor(tool) {
|
|
|
21639
20931
|
return claudeSettingsPath("user");
|
|
21640
20932
|
case "opencode":
|
|
21641
20933
|
return opencodeSettingsPath("user");
|
|
21642
|
-
case "codex":
|
|
21643
|
-
return codexConfigPath("user");
|
|
21644
20934
|
}
|
|
21645
20935
|
}
|
|
21646
20936
|
var systemConfigureCommand = defineCommand({
|
|
@@ -21675,7 +20965,7 @@ var systemConfigureCommand = defineCommand({
|
|
|
21675
20965
|
} else {
|
|
21676
20966
|
R2.info("No pre-existing user-scope config files to back up.");
|
|
21677
20967
|
}
|
|
21678
|
-
const reachable = await
|
|
20968
|
+
const reachable = await fetchReachableChatModels4(creds);
|
|
21679
20969
|
const results = [];
|
|
21680
20970
|
for (const tool of TOOLS) {
|
|
21681
20971
|
const writer = WRITERS4[tool];
|
|
@@ -21771,13 +21061,13 @@ var systemRestoreCommand = defineCommand({
|
|
|
21771
21061
|
R2.info(`Backup ${chosen.timestamp} \u2014 ${chosen.entries.length} file(s):`);
|
|
21772
21062
|
const plan = [];
|
|
21773
21063
|
for (const e2 of chosen.entries) {
|
|
21774
|
-
if (!
|
|
21064
|
+
if (!isTool3(e2.tool)) {
|
|
21775
21065
|
R2.warn(` skip ${e2.tool} (unknown tool in backup)`);
|
|
21776
21066
|
continue;
|
|
21777
21067
|
}
|
|
21778
21068
|
const target = userPathFor(e2.tool);
|
|
21779
21069
|
plan.push({ tool: e2.tool, backup: e2.backup, target });
|
|
21780
|
-
R2.info(` ${e2.tool} \u2192 ${target}${
|
|
21070
|
+
R2.info(` ${e2.tool} \u2192 ${target}${existsSync12(target) ? " (will overwrite)" : " (new)"}`);
|
|
21781
21071
|
}
|
|
21782
21072
|
if (plan.length === 0) {
|
|
21783
21073
|
ye("Nothing to restore.");
|
|
@@ -21810,10 +21100,10 @@ async function confirmRestore() {
|
|
|
21810
21100
|
if (q(v2)) return false;
|
|
21811
21101
|
return v2 === true;
|
|
21812
21102
|
}
|
|
21813
|
-
function
|
|
21103
|
+
function isTool3(value) {
|
|
21814
21104
|
return TOOLS.includes(value);
|
|
21815
21105
|
}
|
|
21816
|
-
async function
|
|
21106
|
+
async function fetchReachableChatModels4(creds) {
|
|
21817
21107
|
const client = gatewayClient(creds.gatewayUrl, creds.apiKey, 1e4);
|
|
21818
21108
|
const s = ft();
|
|
21819
21109
|
s.start("Loading reachable models\u2026");
|
|
@@ -21868,7 +21158,7 @@ import { spawnSync } from "child_process";
|
|
|
21868
21158
|
// package.json
|
|
21869
21159
|
var package_default = {
|
|
21870
21160
|
name: "@codevector/cli",
|
|
21871
|
-
version: "0.
|
|
21161
|
+
version: "0.8.0",
|
|
21872
21162
|
description: "CodeVector CLI \u2014 installs and configures first-party coding-tool integrations.",
|
|
21873
21163
|
license: "UNLICENSED",
|
|
21874
21164
|
bin: {
|
|
@@ -21918,7 +21208,7 @@ init_prompt();
|
|
|
21918
21208
|
|
|
21919
21209
|
// src/lib/update-notifier.ts
|
|
21920
21210
|
init_paths();
|
|
21921
|
-
import { existsSync as
|
|
21211
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync7, readFileSync as readFileSync10, writeFileSync as writeFileSync9 } from "fs";
|
|
21922
21212
|
import { join as join14 } from "path";
|
|
21923
21213
|
var PKG_NAME = "@codevector/cli";
|
|
21924
21214
|
var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
|
|
@@ -21926,9 +21216,9 @@ var CHECK_CACHE_FILE = join14(CODEVECTOR_CONFIG_DIR, "update-check.json");
|
|
|
21926
21216
|
var CHECK_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
21927
21217
|
var FETCH_TIMEOUT_MS = 2e3;
|
|
21928
21218
|
function readCache() {
|
|
21929
|
-
if (!
|
|
21219
|
+
if (!existsSync13(CHECK_CACHE_FILE)) return void 0;
|
|
21930
21220
|
try {
|
|
21931
|
-
const raw =
|
|
21221
|
+
const raw = readFileSync10(CHECK_CACHE_FILE, "utf8");
|
|
21932
21222
|
const parsed = JSON.parse(raw);
|
|
21933
21223
|
if (typeof parsed.checkedAt !== "number") return void 0;
|
|
21934
21224
|
return {
|
|
@@ -22023,7 +21313,10 @@ var updateCommand = defineCommand({
|
|
|
22023
21313
|
const manager = await resolvePackageManager(args.with);
|
|
22024
21314
|
const command = installCommand(manager);
|
|
22025
21315
|
R2.info(`Using ${manager}: ${command.cmd} ${command.args.join(" ")}`);
|
|
22026
|
-
const result = spawnSync(command.cmd, command.args, {
|
|
21316
|
+
const result = spawnSync(command.cmd, command.args, {
|
|
21317
|
+
stdio: "inherit",
|
|
21318
|
+
shell: process.platform === "win32"
|
|
21319
|
+
});
|
|
22027
21320
|
if (result.error) {
|
|
22028
21321
|
throw new Error(
|
|
22029
21322
|
`Failed to invoke ${command.cmd}: ${result.error.message}. Is ${command.cmd} on your PATH?`
|
|
@@ -22058,7 +21351,10 @@ function verifyOnPathVersion(previousVersion, manager) {
|
|
|
22058
21351
|
R2.success(`Already on the latest version (${previousVersion}).`);
|
|
22059
21352
|
}
|
|
22060
21353
|
function readOnPathVersion() {
|
|
22061
|
-
const probe = spawnSync("codevector", ["version"], {
|
|
21354
|
+
const probe = spawnSync("codevector", ["version"], {
|
|
21355
|
+
encoding: "utf8",
|
|
21356
|
+
shell: process.platform === "win32"
|
|
21357
|
+
});
|
|
22062
21358
|
if (probe.error || probe.status !== 0) return void 0;
|
|
22063
21359
|
const out = probe.stdout?.trim();
|
|
22064
21360
|
return out && /^\d+\.\d+\.\d+/.test(out) ? out : void 0;
|
|
@@ -22232,6 +21528,7 @@ var main = defineCommand({
|
|
|
22232
21528
|
config: configCommand,
|
|
22233
21529
|
configure: configureCommand,
|
|
22234
21530
|
init: initCommand,
|
|
21531
|
+
github: githubCommand,
|
|
22235
21532
|
doctor: doctorCommand,
|
|
22236
21533
|
env: envCommand,
|
|
22237
21534
|
hook: hookCommand,
|
|
@@ -22248,43 +21545,4 @@ var main = defineCommand({
|
|
|
22248
21545
|
printUpdateNoticeIfCached(package_default.version);
|
|
22249
21546
|
scheduleUpdateCheck();
|
|
22250
21547
|
runMain(main);
|
|
22251
|
-
/*! Bundled license information:
|
|
22252
|
-
|
|
22253
|
-
smol-toml/dist/error.js:
|
|
22254
|
-
smol-toml/dist/util.js:
|
|
22255
|
-
smol-toml/dist/date.js:
|
|
22256
|
-
smol-toml/dist/primitive.js:
|
|
22257
|
-
smol-toml/dist/extract.js:
|
|
22258
|
-
smol-toml/dist/struct.js:
|
|
22259
|
-
smol-toml/dist/parse.js:
|
|
22260
|
-
smol-toml/dist/stringify.js:
|
|
22261
|
-
smol-toml/dist/index.js:
|
|
22262
|
-
(*!
|
|
22263
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
22264
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
22265
|
-
*
|
|
22266
|
-
* Redistribution and use in source and binary forms, with or without
|
|
22267
|
-
* modification, are permitted provided that the following conditions are met:
|
|
22268
|
-
*
|
|
22269
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
22270
|
-
* list of conditions and the following disclaimer.
|
|
22271
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
22272
|
-
* this list of conditions and the following disclaimer in the
|
|
22273
|
-
* documentation and/or other materials provided with the distribution.
|
|
22274
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
22275
|
-
* may be used to endorse or promote products derived from this software without
|
|
22276
|
-
* specific prior written permission.
|
|
22277
|
-
*
|
|
22278
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
22279
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
22280
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22281
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22282
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22283
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
22284
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22285
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22286
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
22287
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22288
|
-
*)
|
|
22289
|
-
*/
|
|
22290
21548
|
//# sourceMappingURL=index.js.map
|