ziopencommit
Version:
GPT CLI to auto-generate impressive commits in 1 second. Killing lame commits with AI
1,537 lines (1,512 loc) • 1.83 MB
JavaScript
#!/usr/bin/env node
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
// node_modules/ini/lib/ini.js
var require_ini = __commonJS({
"node_modules/ini/lib/ini.js"(exports, module2) {
var { hasOwnProperty: hasOwnProperty2 } = Object.prototype;
var eol = typeof process !== "undefined" && process.platform === "win32" ? "\r\n" : "\n";
var encode3 = (obj, opt) => {
const children = [];
let out = "";
if (typeof opt === "string") {
opt = {
section: opt,
whitespace: false
};
} else {
opt = opt || /* @__PURE__ */ Object.create(null);
opt.whitespace = opt.whitespace === true;
}
const separator = opt.whitespace ? " = " : "=";
for (const k6 of Object.keys(obj)) {
const val = obj[k6];
if (val && Array.isArray(val)) {
for (const item of val) {
out += safe(k6 + "[]") + separator + safe(item) + eol;
}
} else if (val && typeof val === "object") {
children.push(k6);
} else {
out += safe(k6) + separator + safe(val) + eol;
}
}
if (opt.section && out.length) {
out = "[" + safe(opt.section) + "]" + eol + out;
}
for (const k6 of children) {
const nk = dotSplit(k6).join("\\.");
const section = (opt.section ? opt.section + "." : "") + nk;
const { whitespace } = opt;
const child = encode3(obj[k6], {
section,
whitespace
});
if (out.length && child.length) {
out += eol;
}
out += child;
}
return out;
};
var dotSplit = (str) => str.replace(/\1/g, "LITERAL\\1LITERAL").replace(/\\\./g, "").split(/\./).map((part) => part.replace(/\1/g, "\\.").replace(/\2LITERAL\\1LITERAL\2/g, ""));
var decode = (str) => {
const out = /* @__PURE__ */ Object.create(null);
let p4 = out;
let section = null;
const re2 = /^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i;
const lines = str.split(/[\r\n]+/g);
for (const line of lines) {
if (!line || line.match(/^\s*[;#]/)) {
continue;
}
const match = line.match(re2);
if (!match) {
continue;
}
if (match[1] !== void 0) {
section = unsafe(match[1]);
if (section === "__proto__") {
p4 = /* @__PURE__ */ Object.create(null);
continue;
}
p4 = out[section] = out[section] || /* @__PURE__ */ Object.create(null);
continue;
}
const keyRaw = unsafe(match[2]);
const isArray2 = keyRaw.length > 2 && keyRaw.slice(-2) === "[]";
const key = isArray2 ? keyRaw.slice(0, -2) : keyRaw;
if (key === "__proto__") {
continue;
}
const valueRaw = match[3] ? unsafe(match[4]) : true;
const value = valueRaw === "true" || valueRaw === "false" || valueRaw === "null" ? JSON.parse(valueRaw) : valueRaw;
if (isArray2) {
if (!hasOwnProperty2.call(p4, key)) {
p4[key] = [];
} else if (!Array.isArray(p4[key])) {
p4[key] = [p4[key]];
}
}
if (Array.isArray(p4[key])) {
p4[key].push(value);
} else {
p4[key] = value;
}
}
const remove = [];
for (const k6 of Object.keys(out)) {
if (!hasOwnProperty2.call(out, k6) || typeof out[k6] !== "object" || Array.isArray(out[k6])) {
continue;
}
const parts = dotSplit(k6);
p4 = out;
const l = parts.pop();
const nl = l.replace(/\\\./g, ".");
for (const part of parts) {
if (part === "__proto__") {
continue;
}
if (!hasOwnProperty2.call(p4, part) || typeof p4[part] !== "object") {
p4[part] = /* @__PURE__ */ Object.create(null);
}
p4 = p4[part];
}
if (p4 === out && nl === l) {
continue;
}
p4[nl] = out[k6];
remove.push(k6);
}
for (const del of remove) {
delete out[del];
}
return out;
};
var isQuoted = (val) => {
return val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'");
};
var safe = (val) => {
if (typeof val !== "string" || val.match(/[=\r\n]/) || val.match(/^\[/) || val.length > 1 && isQuoted(val) || val !== val.trim()) {
return JSON.stringify(val);
}
return val.split(";").join("\\;").split("#").join("\\#");
};
var unsafe = (val, doUnesc) => {
val = (val || "").trim();
if (isQuoted(val)) {
if (val.charAt(0) === "'") {
val = val.slice(1, -1);
}
try {
val = JSON.parse(val);
} catch {
}
} else {
let esc = false;
let unesc = "";
for (let i2 = 0, l = val.length; i2 < l; i2++) {
const c3 = val.charAt(i2);
if (esc) {
if ("\\;#".indexOf(c3) !== -1) {
unesc += c3;
} else {
unesc += "\\" + c3;
}
esc = false;
} else if (";#".indexOf(c3) !== -1) {
break;
} else if (c3 === "\\") {
esc = true;
} else {
unesc += c3;
}
}
if (esc) {
unesc += "\\";
}
return unesc.trim();
}
return val;
};
module2.exports = {
parse: decode,
decode,
stringify: encode3,
encode: encode3,
safe,
unsafe
};
}
});
// node_modules/sisteransi/src/index.js
var require_src = __commonJS({
"node_modules/sisteransi/src/index.js"(exports, module2) {
"use strict";
var ESC = "\x1B";
var CSI = `${ESC}[`;
var beep = "\x07";
var cursor = {
to(x4, y5) {
if (!y5)
return `${CSI}${x4 + 1}G`;
return `${CSI}${y5 + 1};${x4 + 1}H`;
},
move(x4, y5) {
let ret = "";
if (x4 < 0)
ret += `${CSI}${-x4}D`;
else if (x4 > 0)
ret += `${CSI}${x4}C`;
if (y5 < 0)
ret += `${CSI}${-y5}A`;
else if (y5 > 0)
ret += `${CSI}${y5}B`;
return ret;
},
up: (count = 1) => `${CSI}${count}A`,
down: (count = 1) => `${CSI}${count}B`,
forward: (count = 1) => `${CSI}${count}C`,
backward: (count = 1) => `${CSI}${count}D`,
nextLine: (count = 1) => `${CSI}E`.repeat(count),
prevLine: (count = 1) => `${CSI}F`.repeat(count),
left: `${CSI}G`,
hide: `${CSI}?25l`,
show: `${CSI}?25h`,
save: `${ESC}7`,
restore: `${ESC}8`
};
var scroll = {
up: (count = 1) => `${CSI}S`.repeat(count),
down: (count = 1) => `${CSI}T`.repeat(count)
};
var erase = {
screen: `${CSI}2J`,
up: (count = 1) => `${CSI}1J`.repeat(count),
down: (count = 1) => `${CSI}J`.repeat(count),
line: `${CSI}2K`,
lineEnd: `${CSI}K`,
lineStart: `${CSI}1K`,
lines(count) {
let clear = "";
for (let i2 = 0; i2 < count; i2++)
clear += this.line + (i2 < count - 1 ? cursor.up() : "");
if (count)
clear += cursor.left;
return clear;
}
};
module2.exports = { cursor, scroll, erase, beep };
}
});
// node_modules/picocolors/picocolors.js
var require_picocolors = __commonJS({
"node_modules/picocolors/picocolors.js"(exports, module2) {
var tty2 = require("tty");
var isColorSupported = !("NO_COLOR" in process.env || process.argv.includes("--no-color")) && ("FORCE_COLOR" in process.env || process.argv.includes("--color") || process.platform === "win32" || tty2.isatty(1) && process.env.TERM !== "dumb" || "CI" in process.env);
var formatter = (open, close, replace = open) => (input) => {
let string = "" + input;
let index = string.indexOf(close, open.length);
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
};
var replaceClose = (string, close, replace, index) => {
let start = string.substring(0, index) + replace;
let end = string.substring(index + close.length);
let nextIndex = end.indexOf(close);
return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end;
};
var createColors = (enabled = isColorSupported) => ({
isColorSupported: enabled,
reset: enabled ? (s) => `\x1B[0m${s}\x1B[0m` : String,
bold: enabled ? formatter("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m") : String,
dim: enabled ? formatter("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m") : String,
italic: enabled ? formatter("\x1B[3m", "\x1B[23m") : String,
underline: enabled ? formatter("\x1B[4m", "\x1B[24m") : String,
inverse: enabled ? formatter("\x1B[7m", "\x1B[27m") : String,
hidden: enabled ? formatter("\x1B[8m", "\x1B[28m") : String,
strikethrough: enabled ? formatter("\x1B[9m", "\x1B[29m") : String,
black: enabled ? formatter("\x1B[30m", "\x1B[39m") : String,
red: enabled ? formatter("\x1B[31m", "\x1B[39m") : String,
green: enabled ? formatter("\x1B[32m", "\x1B[39m") : String,
yellow: enabled ? formatter("\x1B[33m", "\x1B[39m") : String,
blue: enabled ? formatter("\x1B[34m", "\x1B[39m") : String,
magenta: enabled ? formatter("\x1B[35m", "\x1B[39m") : String,
cyan: enabled ? formatter("\x1B[36m", "\x1B[39m") : String,
white: enabled ? formatter("\x1B[37m", "\x1B[39m") : String,
gray: enabled ? formatter("\x1B[90m", "\x1B[39m") : String,
bgBlack: enabled ? formatter("\x1B[40m", "\x1B[49m") : String,
bgRed: enabled ? formatter("\x1B[41m", "\x1B[49m") : String,
bgGreen: enabled ? formatter("\x1B[42m", "\x1B[49m") : String,
bgYellow: enabled ? formatter("\x1B[43m", "\x1B[49m") : String,
bgBlue: enabled ? formatter("\x1B[44m", "\x1B[49m") : String,
bgMagenta: enabled ? formatter("\x1B[45m", "\x1B[49m") : String,
bgCyan: enabled ? formatter("\x1B[46m", "\x1B[49m") : String,
bgWhite: enabled ? formatter("\x1B[47m", "\x1B[49m") : String
});
module2.exports = createColors();
module2.exports.createColors = createColors;
}
});
// node_modules/isexe/windows.js
var require_windows = __commonJS({
"node_modules/isexe/windows.js"(exports, module2) {
module2.exports = isexe;
isexe.sync = sync;
var fs3 = require("fs");
function checkPathExt(path4, options) {
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
if (!pathext) {
return true;
}
pathext = pathext.split(";");
if (pathext.indexOf("") !== -1) {
return true;
}
for (var i2 = 0; i2 < pathext.length; i2++) {
var p4 = pathext[i2].toLowerCase();
if (p4 && path4.substr(-p4.length).toLowerCase() === p4) {
return true;
}
}
return false;
}
function checkStat(stat, path4, options) {
if (!stat.isSymbolicLink() && !stat.isFile()) {
return false;
}
return checkPathExt(path4, options);
}
function isexe(path4, options, cb) {
fs3.stat(path4, function(er, stat) {
cb(er, er ? false : checkStat(stat, path4, options));
});
}
function sync(path4, options) {
return checkStat(fs3.statSync(path4), path4, options);
}
}
});
// node_modules/isexe/mode.js
var require_mode = __commonJS({
"node_modules/isexe/mode.js"(exports, module2) {
module2.exports = isexe;
isexe.sync = sync;
var fs3 = require("fs");
function isexe(path4, options, cb) {
fs3.stat(path4, function(er, stat) {
cb(er, er ? false : checkStat(stat, options));
});
}
function sync(path4, options) {
return checkStat(fs3.statSync(path4), options);
}
function checkStat(stat, options) {
return stat.isFile() && checkMode(stat, options);
}
function checkMode(stat, options) {
var mod = stat.mode;
var uid = stat.uid;
var gid = stat.gid;
var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
var u2 = parseInt("100", 8);
var g3 = parseInt("010", 8);
var o2 = parseInt("001", 8);
var ug = u2 | g3;
var ret = mod & o2 || mod & g3 && gid === myGid || mod & u2 && uid === myUid || mod & ug && myUid === 0;
return ret;
}
}
});
// node_modules/isexe/index.js
var require_isexe = __commonJS({
"node_modules/isexe/index.js"(exports, module2) {
var fs3 = require("fs");
var core;
if (process.platform === "win32" || global.TESTING_WINDOWS) {
core = require_windows();
} else {
core = require_mode();
}
module2.exports = isexe;
isexe.sync = sync;
function isexe(path4, options, cb) {
if (typeof options === "function") {
cb = options;
options = {};
}
if (!cb) {
if (typeof Promise !== "function") {
throw new TypeError("callback not provided");
}
return new Promise(function(resolve, reject) {
isexe(path4, options || {}, function(er, is) {
if (er) {
reject(er);
} else {
resolve(is);
}
});
});
}
core(path4, options || {}, function(er, is) {
if (er) {
if (er.code === "EACCES" || options && options.ignoreErrors) {
er = null;
is = false;
}
}
cb(er, is);
});
}
function sync(path4, options) {
try {
return core.sync(path4, options || {});
} catch (er) {
if (options && options.ignoreErrors || er.code === "EACCES") {
return false;
} else {
throw er;
}
}
}
}
});
// node_modules/which/which.js
var require_which = __commonJS({
"node_modules/which/which.js"(exports, module2) {
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
var path4 = require("path");
var COLON = isWindows ? ";" : ":";
var isexe = require_isexe();
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
var getPathInfo = (cmd, opt) => {
const colon = opt.colon || COLON;
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
...isWindows ? [process.cwd()] : [],
...(opt.path || process.env.PATH || "").split(colon)
];
const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
const pathExt = isWindows ? pathExtExe.split(colon) : [""];
if (isWindows) {
if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
pathExt.unshift("");
}
return {
pathEnv,
pathExt,
pathExtExe
};
};
var which = (cmd, opt, cb) => {
if (typeof opt === "function") {
cb = opt;
opt = {};
}
if (!opt)
opt = {};
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
const found = [];
const step = (i2) => new Promise((resolve, reject) => {
if (i2 === pathEnv.length)
return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
const ppRaw = pathEnv[i2];
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
const pCmd = path4.join(pathPart, cmd);
const p4 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
resolve(subStep(p4, i2, 0));
});
const subStep = (p4, i2, ii) => new Promise((resolve, reject) => {
if (ii === pathExt.length)
return resolve(step(i2 + 1));
const ext = pathExt[ii];
isexe(p4 + ext, { pathExt: pathExtExe }, (er, is) => {
if (!er && is) {
if (opt.all)
found.push(p4 + ext);
else
return resolve(p4 + ext);
}
return resolve(subStep(p4, i2, ii + 1));
});
});
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
};
var whichSync = (cmd, opt) => {
opt = opt || {};
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
const found = [];
for (let i2 = 0; i2 < pathEnv.length; i2++) {
const ppRaw = pathEnv[i2];
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
const pCmd = path4.join(pathPart, cmd);
const p4 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
for (let j3 = 0; j3 < pathExt.length; j3++) {
const cur = p4 + pathExt[j3];
try {
const is = isexe.sync(cur, { pathExt: pathExtExe });
if (is) {
if (opt.all)
found.push(cur);
else
return cur;
}
} catch (ex) {
}
}
}
if (opt.all && found.length)
return found;
if (opt.nothrow)
return null;
throw getNotFoundError(cmd);
};
module2.exports = which;
which.sync = whichSync;
}
});
// node_modules/path-key/index.js
var require_path_key = __commonJS({
"node_modules/path-key/index.js"(exports, module2) {
"use strict";
var pathKey2 = (options = {}) => {
const environment = options.env || process.env;
const platform = options.platform || process.platform;
if (platform !== "win32") {
return "PATH";
}
return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
};
module2.exports = pathKey2;
module2.exports.default = pathKey2;
}
});
// node_modules/cross-spawn/lib/util/resolveCommand.js
var require_resolveCommand = __commonJS({
"node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module2) {
"use strict";
var path4 = require("path");
var which = require_which();
var getPathKey = require_path_key();
function resolveCommandAttempt(parsed, withoutPathExt) {
const env2 = parsed.options.env || process.env;
const cwd = process.cwd();
const hasCustomCwd = parsed.options.cwd != null;
const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
if (shouldSwitchCwd) {
try {
process.chdir(parsed.options.cwd);
} catch (err) {
}
}
let resolved;
try {
resolved = which.sync(parsed.command, {
path: env2[getPathKey({ env: env2 })],
pathExt: withoutPathExt ? path4.delimiter : void 0
});
} catch (e2) {
} finally {
if (shouldSwitchCwd) {
process.chdir(cwd);
}
}
if (resolved) {
resolved = path4.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
}
return resolved;
}
function resolveCommand(parsed) {
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
}
module2.exports = resolveCommand;
}
});
// node_modules/cross-spawn/lib/util/escape.js
var require_escape = __commonJS({
"node_modules/cross-spawn/lib/util/escape.js"(exports, module2) {
"use strict";
var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
function escapeCommand(arg) {
arg = arg.replace(metaCharsRegExp, "^$1");
return arg;
}
function escapeArgument(arg, doubleEscapeMetaChars) {
arg = `${arg}`;
arg = arg.replace(/(\\*)"/g, '$1$1\\"');
arg = arg.replace(/(\\*)$/, "$1$1");
arg = `"${arg}"`;
arg = arg.replace(metaCharsRegExp, "^$1");
if (doubleEscapeMetaChars) {
arg = arg.replace(metaCharsRegExp, "^$1");
}
return arg;
}
module2.exports.command = escapeCommand;
module2.exports.argument = escapeArgument;
}
});
// node_modules/shebang-regex/index.js
var require_shebang_regex = __commonJS({
"node_modules/shebang-regex/index.js"(exports, module2) {
"use strict";
module2.exports = /^#!(.*)/;
}
});
// node_modules/shebang-command/index.js
var require_shebang_command = __commonJS({
"node_modules/shebang-command/index.js"(exports, module2) {
"use strict";
var shebangRegex = require_shebang_regex();
module2.exports = (string = "") => {
const match = string.match(shebangRegex);
if (!match) {
return null;
}
const [path4, argument] = match[0].replace(/#! ?/, "").split(" ");
const binary = path4.split("/").pop();
if (binary === "env") {
return argument;
}
return argument ? `${binary} ${argument}` : binary;
};
}
});
// node_modules/cross-spawn/lib/util/readShebang.js
var require_readShebang = __commonJS({
"node_modules/cross-spawn/lib/util/readShebang.js"(exports, module2) {
"use strict";
var fs3 = require("fs");
var shebangCommand = require_shebang_command();
function readShebang(command2) {
const size = 150;
const buffer = Buffer.alloc(size);
let fd;
try {
fd = fs3.openSync(command2, "r");
fs3.readSync(fd, buffer, 0, size, 0);
fs3.closeSync(fd);
} catch (e2) {
}
return shebangCommand(buffer.toString());
}
module2.exports = readShebang;
}
});
// node_modules/cross-spawn/lib/parse.js
var require_parse = __commonJS({
"node_modules/cross-spawn/lib/parse.js"(exports, module2) {
"use strict";
var path4 = require("path");
var resolveCommand = require_resolveCommand();
var escape = require_escape();
var readShebang = require_readShebang();
var isWin = process.platform === "win32";
var isExecutableRegExp = /\.(?:com|exe)$/i;
var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
function detectShebang(parsed) {
parsed.file = resolveCommand(parsed);
const shebang = parsed.file && readShebang(parsed.file);
if (shebang) {
parsed.args.unshift(parsed.file);
parsed.command = shebang;
return resolveCommand(parsed);
}
return parsed.file;
}
function parseNonShell(parsed) {
if (!isWin) {
return parsed;
}
const commandFile = detectShebang(parsed);
const needsShell = !isExecutableRegExp.test(commandFile);
if (parsed.options.forceShell || needsShell) {
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
parsed.command = path4.normalize(parsed.command);
parsed.command = escape.command(parsed.command);
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
parsed.command = process.env.comspec || "cmd.exe";
parsed.options.windowsVerbatimArguments = true;
}
return parsed;
}
function parse(command2, args, options) {
if (args && !Array.isArray(args)) {
options = args;
args = null;
}
args = args ? args.slice(0) : [];
options = Object.assign({}, options);
const parsed = {
command: command2,
args,
options,
file: void 0,
original: {
command: command2,
args
}
};
return options.shell ? parsed : parseNonShell(parsed);
}
module2.exports = parse;
}
});
// node_modules/cross-spawn/lib/enoent.js
var require_enoent = __commonJS({
"node_modules/cross-spawn/lib/enoent.js"(exports, module2) {
"use strict";
var isWin = process.platform === "win32";
function notFoundError(original, syscall) {
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
code: "ENOENT",
errno: "ENOENT",
syscall: `${syscall} ${original.command}`,
path: original.command,
spawnargs: original.args
});
}
function hookChildProcess(cp, parsed) {
if (!isWin) {
return;
}
const originalEmit = cp.emit;
cp.emit = function(name, arg1) {
if (name === "exit") {
const err = verifyENOENT(arg1, parsed, "spawn");
if (err) {
return originalEmit.call(cp, "error", err);
}
}
return originalEmit.apply(cp, arguments);
};
}
function verifyENOENT(status, parsed) {
if (isWin && status === 1 && !parsed.file) {
return notFoundError(parsed.original, "spawn");
}
return null;
}
function verifyENOENTSync(status, parsed) {
if (isWin && status === 1 && !parsed.file) {
return notFoundError(parsed.original, "spawnSync");
}
return null;
}
module2.exports = {
hookChildProcess,
verifyENOENT,
verifyENOENTSync,
notFoundError
};
}
});
// node_modules/cross-spawn/index.js
var require_cross_spawn = __commonJS({
"node_modules/cross-spawn/index.js"(exports, module2) {
"use strict";
var cp = require("child_process");
var parse = require_parse();
var enoent = require_enoent();
function spawn(command2, args, options) {
const parsed = parse(command2, args, options);
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
enoent.hookChildProcess(spawned, parsed);
return spawned;
}
function spawnSync(command2, args, options) {
const parsed = parse(command2, args, options);
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
return result;
}
module2.exports = spawn;
module2.exports.spawn = spawn;
module2.exports.sync = spawnSync;
module2.exports._parse = parse;
module2.exports._enoent = enoent;
}
});
// node_modules/signal-exit/signals.js
var require_signals = __commonJS({
"node_modules/signal-exit/signals.js"(exports, module2) {
module2.exports = [
"SIGABRT",
"SIGALRM",
"SIGHUP",
"SIGINT",
"SIGTERM"
];
if (process.platform !== "win32") {
module2.exports.push(
"SIGVTALRM",
"SIGXCPU",
"SIGXFSZ",
"SIGUSR2",
"SIGTRAP",
"SIGSYS",
"SIGQUIT",
"SIGIOT"
);
}
if (process.platform === "linux") {
module2.exports.push(
"SIGIO",
"SIGPOLL",
"SIGPWR",
"SIGSTKFLT",
"SIGUNUSED"
);
}
}
});
// node_modules/signal-exit/index.js
var require_signal_exit = __commonJS({
"node_modules/signal-exit/index.js"(exports, module2) {
var process5 = global.process;
var processOk = function(process6) {
return process6 && typeof process6 === "object" && typeof process6.removeListener === "function" && typeof process6.emit === "function" && typeof process6.reallyExit === "function" && typeof process6.listeners === "function" && typeof process6.kill === "function" && typeof process6.pid === "number" && typeof process6.on === "function";
};
if (!processOk(process5)) {
module2.exports = function() {
return function() {
};
};
} else {
assert = require("assert");
signals = require_signals();
isWin = /^win/i.test(process5.platform);
EE = require("events");
if (typeof EE !== "function") {
EE = EE.EventEmitter;
}
if (process5.__signal_exit_emitter__) {
emitter = process5.__signal_exit_emitter__;
} else {
emitter = process5.__signal_exit_emitter__ = new EE();
emitter.count = 0;
emitter.emitted = {};
}
if (!emitter.infinite) {
emitter.setMaxListeners(Infinity);
emitter.infinite = true;
}
module2.exports = function(cb, opts) {
if (!processOk(global.process)) {
return function() {
};
}
assert.equal(typeof cb, "function", "a callback must be provided for exit handler");
if (loaded === false) {
load();
}
var ev = "exit";
if (opts && opts.alwaysLast) {
ev = "afterexit";
}
var remove = function() {
emitter.removeListener(ev, cb);
if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
unload();
}
};
emitter.on(ev, cb);
return remove;
};
unload = function unload2() {
if (!loaded || !processOk(global.process)) {
return;
}
loaded = false;
signals.forEach(function(sig) {
try {
process5.removeListener(sig, sigListeners[sig]);
} catch (er) {
}
});
process5.emit = originalProcessEmit;
process5.reallyExit = originalProcessReallyExit;
emitter.count -= 1;
};
module2.exports.unload = unload;
emit = function emit2(event, code, signal) {
if (emitter.emitted[event]) {
return;
}
emitter.emitted[event] = true;
emitter.emit(event, code, signal);
};
sigListeners = {};
signals.forEach(function(sig) {
sigListeners[sig] = function listener() {
if (!processOk(global.process)) {
return;
}
var listeners = process5.listeners(sig);
if (listeners.length === emitter.count) {
unload();
emit("exit", null, sig);
emit("afterexit", null, sig);
if (isWin && sig === "SIGHUP") {
sig = "SIGINT";
}
process5.kill(process5.pid, sig);
}
};
});
module2.exports.signals = function() {
return signals;
};
loaded = false;
load = function load2() {
if (loaded || !processOk(global.process)) {
return;
}
loaded = true;
emitter.count += 1;
signals = signals.filter(function(sig) {
try {
process5.on(sig, sigListeners[sig]);
return true;
} catch (er) {
return false;
}
});
process5.emit = processEmit;
process5.reallyExit = processReallyExit;
};
module2.exports.load = load;
originalProcessReallyExit = process5.reallyExit;
processReallyExit = function processReallyExit2(code) {
if (!processOk(global.process)) {
return;
}
process5.exitCode = code || 0;
emit("exit", process5.exitCode, null);
emit("afterexit", process5.exitCode, null);
originalProcessReallyExit.call(process5, process5.exitCode);
};
originalProcessEmit = process5.emit;
processEmit = function processEmit2(ev, arg) {
if (ev === "exit" && processOk(global.process)) {
if (arg !== void 0) {
process5.exitCode = arg;
}
var ret = originalProcessEmit.apply(this, arguments);
emit("exit", process5.exitCode, null);
emit("afterexit", process5.exitCode, null);
return ret;
} else {
return originalProcessEmit.apply(this, arguments);
}
};
}
var assert;
var signals;
var isWin;
var EE;
var emitter;
var unload;
var emit;
var sigListeners;
var loaded;
var load;
var originalProcessReallyExit;
var processReallyExit;
var originalProcessEmit;
var processEmit;
}
});
// node_modules/get-stream/buffer-stream.js
var require_buffer_stream = __commonJS({
"node_modules/get-stream/buffer-stream.js"(exports, module2) {
"use strict";
var { PassThrough: PassThroughStream } = require("stream");
module2.exports = (options) => {
options = { ...options };
const { array } = options;
let { encoding } = options;
const isBuffer2 = encoding === "buffer";
let objectMode = false;
if (array) {
objectMode = !(encoding || isBuffer2);
} else {
encoding = encoding || "utf8";
}
if (isBuffer2) {
encoding = null;
}
const stream4 = new PassThroughStream({ objectMode });
if (encoding) {
stream4.setEncoding(encoding);
}
let length = 0;
const chunks = [];
stream4.on("data", (chunk) => {
chunks.push(chunk);
if (objectMode) {
length = chunks.length;
} else {
length += chunk.length;
}
});
stream4.getBufferedValue = () => {
if (array) {
return chunks;
}
return isBuffer2 ? Buffer.concat(chunks, length) : chunks.join("");
};
stream4.getBufferedLength = () => length;
return stream4;
};
}
});
// node_modules/get-stream/index.js
var require_get_stream = __commonJS({
"node_modules/get-stream/index.js"(exports, module2) {
"use strict";
var { constants: BufferConstants } = require("buffer");
var stream4 = require("stream");
var { promisify } = require("util");
var bufferStream = require_buffer_stream();
var streamPipelinePromisified = promisify(stream4.pipeline);
var MaxBufferError = class extends Error {
constructor() {
super("maxBuffer exceeded");
this.name = "MaxBufferError";
}
};
async function getStream2(inputStream, options) {
if (!inputStream) {
throw new Error("Expected a stream");
}
options = {
maxBuffer: Infinity,
...options
};
const { maxBuffer } = options;
const stream5 = bufferStream(options);
await new Promise((resolve, reject) => {
const rejectPromise = (error) => {
if (error && stream5.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
error.bufferedData = stream5.getBufferedValue();
}
reject(error);
};
(async () => {
try {
await streamPipelinePromisified(inputStream, stream5);
resolve();
} catch (error) {
rejectPromise(error);
}
})();
stream5.on("data", () => {
if (stream5.getBufferedLength() > maxBuffer) {
rejectPromise(new MaxBufferError());
}
});
});
return stream5.getBufferedValue();
}
module2.exports = getStream2;
module2.exports.buffer = (stream5, options) => getStream2(stream5, { ...options, encoding: "buffer" });
module2.exports.array = (stream5, options) => getStream2(stream5, { ...options, array: true });
module2.exports.MaxBufferError = MaxBufferError;
}
});
// node_modules/merge-stream/index.js
var require_merge_stream = __commonJS({
"node_modules/merge-stream/index.js"(exports, module2) {
"use strict";
var { PassThrough } = require("stream");
module2.exports = function() {
var sources = [];
var output = new PassThrough({ objectMode: true });
output.setMaxListeners(0);
output.add = add;
output.isEmpty = isEmpty;
output.on("unpipe", remove);
Array.prototype.slice.call(arguments).forEach(add);
return output;
function add(source) {
if (Array.isArray(source)) {
source.forEach(add);
return this;
}
sources.push(source);
source.once("end", remove.bind(null, source));
source.once("error", output.emit.bind(output, "error"));
source.pipe(output, { end: false });
return this;
}
function isEmpty() {
return sources.length == 0;
}
function remove(source) {
sources = sources.filter(function(it) {
return it !== source;
});
if (!sources.length && output.readable) {
output.end();
}
}
};
}
});
// node_modules/ignore/index.js
var require_ignore = __commonJS({
"node_modules/ignore/index.js"(exports, module2) {
function makeArray(subject) {
return Array.isArray(subject) ? subject : [subject];
}
var EMPTY = "";
var SPACE = " ";
var ESCAPE = "\\";
var REGEX_TEST_BLANK_LINE = /^\s+$/;
var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
var REGEX_SPLITALL_CRLF = /\r?\n/g;
var REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/;
var SLASH = "/";
var TMP_KEY_IGNORE = "node-ignore";
if (typeof Symbol !== "undefined") {
TMP_KEY_IGNORE = Symbol.for("node-ignore");
}
var KEY_IGNORE = TMP_KEY_IGNORE;
var define = (object, key, value) => Object.defineProperty(object, key, { value });
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
var RETURN_FALSE = () => false;
var sanitizeRange = (range) => range.replace(
REGEX_REGEXP_RANGE,
(match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY
);
var cleanRangeBackSlash = (slashes) => {
const { length } = slashes;
return slashes.slice(0, length - length % 2);
};
var REPLACERS = [
[
/\\?\s+$/,
(match) => match.indexOf("\\") === 0 ? SPACE : EMPTY
],
[
/\\\s/g,
() => SPACE
],
[
/[\\$.|*+(){^]/g,
(match) => `\\${match}`
],
[
/(?!\\)\?/g,
() => "[^/]"
],
[
/^\//,
() => "^"
],
[
/\//g,
() => "\\/"
],
[
/^\^*\\\*\\\*\\\//,
() => "^(?:.*\\/)?"
],
[
/^(?=[^^])/,
function startingReplacer() {
return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^";
}
],
[
/\\\/\\\*\\\*(?=\\\/|$)/g,
(_6, index, str) => index + 6 < str.length ? "(?:\\/[^\\/]+)*" : "\\/.+"
],
[
/(^|[^\\]+)(\\\*)+(?=.+)/g,
(_6, p1, p22) => {
const unescaped = p22.replace(/\\\*/g, "[^\\/]*");
return p1 + unescaped;
}
],
[
/\\\\\\(?=[$.|*+(){^])/g,
() => ESCAPE
],
[
/\\\\/g,
() => ESCAPE
],
[
/(\\)?\[([^\]/]*?)(\\*)($|\])/g,
(match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${sanitizeRange(range)}${endEscape}]` : "[]" : "[]"
],
[
/(?:[^*])$/,
(match) => /\/$/.test(match) ? `${match}$` : `${match}(?=$|\\/$)`
],
[
/(\^|\\\/)?\\\*$/,
(_6, p1) => {
const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
return `${prefix}(?=$|\\/$)`;
}
]
];
var regexCache = /* @__PURE__ */ Object.create(null);
var makeRegex = (pattern, ignoreCase) => {
let source = regexCache[pattern];
if (!source) {
source = REPLACERS.reduce(
(prev, current) => prev.replace(current[0], current[1].bind(pattern)),
pattern
);
regexCache[pattern] = source;
}
return ignoreCase ? new RegExp(source, "i") : new RegExp(source);
};
var isString2 = (subject) => typeof subject === "string";
var checkPattern = (pattern) => pattern && isString2(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF);
var IgnoreRule = class {
constructor(origin, pattern, negative, regex) {
this.origin = origin;
this.pattern = pattern;
this.negative = negative;
this.regex = regex;
}
};
var createRule = (pattern, ignoreCase) => {
const origin = pattern;
let negative = false;
if (pattern.indexOf("!") === 0) {
negative = true;
pattern = pattern.substr(1);
}
pattern = pattern.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
const regex = makeRegex(pattern, ignoreCase);
return new IgnoreRule(
origin,
pattern,
negative,
regex
);
};
var throwError = (message, Ctor) => {
throw new Ctor(message);
};
var checkPath = (path4, originalPath, doThrow) => {
if (!isString2(path4)) {
return doThrow(
`path must be a string, but got \`${originalPath}\``,
TypeError
);
}
if (!path4) {
return doThrow(`path must not be empty`, TypeError);
}
if (checkPath.isNotRelative(path4)) {
const r2 = "`path.relative()`d";
return doThrow(
`path should be a ${r2} string, but got "${originalPath}"`,
RangeError
);
}
return true;
};
var isNotRelative = (path4) => REGEX_TEST_INVALID_PATH.test(path4);
checkPath.isNotRelative = isNotRelative;
checkPath.convert = (p4) => p4;
var Ignore2 = class {
constructor({
ignorecase = true,
ignoreCase = ignorecase,
allowRelativePaths = false
} = {}) {
define(this, KEY_IGNORE, true);
this._rules = [];
this._ignoreCase = ignoreCase;
this._allowRelativePaths = allowRelativePaths;
this._initCache();
}
_initCache() {
this._ignoreCache = /* @__PURE__ */ Object.create(null);
this._testCache = /* @__PURE__ */ Object.create(null);
}
_addPattern(pattern) {
if (pattern && pattern[KEY_IGNORE]) {
this._rules = this._rules.concat(pattern._rules);
this._added = true;
return;
}
if (checkPattern(pattern)) {
const rule = createRule(pattern, this._ignoreCase);
this._added = true;
this._rules.push(rule);
}
}
add(pattern) {
this._added = false;
makeArray(
isString2(pattern) ? splitPattern(pattern) : pattern
).forEach(this._addPattern, this);
if (this._added) {
this._initCache();
}
return this;
}
addPattern(pattern) {
return this.add(pattern);
}
_testOne(path4, checkUnignored) {
let ignored = false;
let unignored = false;
this._rules.forEach((rule) => {
const { negative } = rule;
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
return;
}
const matched = rule.regex.test(path4);
if (matched) {
ignored = !negative;
unignored = negative;
}
});
return {
ignored,
unignored
};
}
_test(originalPath, cache, checkUnignored, slices) {
const path4 = originalPath && checkPath.convert(originalPath);
checkPath(
path4,
originalPath,
this._allowRelativePaths ? RETURN_FALSE : throwError
);
return this._t(path4, cache, checkUnignored, slices);
}
_t(path4, cache, checkUnignored, slices) {
if (path4 in cache) {
return cache[path4];
}
if (!slices) {
slices = path4.split(SLASH);
}
slices.pop();
if (!slices.length) {
return cache[path4] = this._testOne(path4, checkUnignored);
}
const parent = this._t(
slices.join(SLASH) + SLASH,
cache,
checkUnignored,
slices
);
return cache[path4] = parent.ignored ? parent : this._testOne(path4, checkUnignored);
}
ignores(path4) {
return this._test(path4, this._ignoreCache, false).ignored;
}
createFilter() {
return (path4) => !this.ignores(path4);
}
filter(paths) {
return makeArray(paths).filter(this.createFilter());
}
test(path4) {
return this._test(path4, this._testCache, true);
}
};
var factory = (options) => new Ignore2(options);
var isPathValid = (path4) => checkPath(path4 && checkPath.convert(path4), path4, RETURN_FALSE);
factory.isPathValid = isPathValid;
factory.default = factory;
module2.exports = factory;
if (typeof process !== "undefined" && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === "win32")) {
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
checkPath.convert = makePosix;
const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
checkPath.isNotRelative = (path4) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path4) || isNotRelative(path4);
}
}
});
// node_modules/openai/node_modules/axios/lib/helpers/bind.js
var require_bind = __commonJS({
"node_modules/openai/node_modules/axios/lib/helpers/bind.js"(exports, module2) {
"use strict";
module2.exports = function bind2(fn, thisArg) {
return function wrap() {
var args = new Array(arguments.length);
for (var i2 = 0; i2 < args.length; i2++) {
args[i2] = arguments[i2];
}
return fn.apply(thisArg, args);
};
};
}
});
// node_modules/openai/node_modules/axios/lib/utils.js
var require_utils = __commonJS({
"node_modules/openai/node_modules/axios/lib/utils.js"(exports, module2) {
"use strict";
var bind2 = require_bind();
var toString3 = Object.prototype.toString;
function isArray2(val) {
return Array.isArray(val);
}
function isUndefined2(val) {
return typeof val === "undefined";
}
function isBuffer2(val) {
return val !== null && !isUndefined2(val) && val.constructor !== null && !isUndefined2(val.constructor) && typeof val.constructor.isBuffer === "function" && val.constructor.isBuffer(val);
}
function isArrayBuffer2(val) {
return toString3.call(val) === "[object ArrayBuffer]";
}
function isFormData2(val) {
return toString3.call(val) === "[object FormData]";
}
function isArrayBufferView2(val) {
var result;
if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
result = ArrayBuffer.isView(val);
} else {
result = val && val.buffer && isArrayBuffer2(val.buffer);
}
return result;
}
function isString2(val) {
return typeof val === "string";
}
function isNumber2(val) {
return typeof val === "number";
}
function isObject2(val) {
return val !== null && typeof val === "object";
}
function isPlainObject2(val) {
if (toString3.call(val) !== "[object Object]") {
return false;
}
var prototype3 = Object.getPrototypeOf(val);
return prototype3 === null || prototype3 === Object.prototype;
}
function isDate2(val) {
return toString3.call(val) === "[object Date]";
}
function isFile2(val) {
return toString3.call(val) === "[object File]";
}
function isBlob2(val) {
return toString3.call(val) === "[object Blob]";
}
function isFunction2(val) {
return toString3.call(val) === "[object Function]";
}
function isStream3(val) {
return isObject2(val) && isFunction2(val.pipe);
}
function isURLSearchParams2(val) {
return toString3.call(val) === "[object URLSearchParams]";
}
function trim2(str) {
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, "");
}
function isStandardBrowserEnv() {
if (typeof navigator !== "undefined" && (navigator.product === "ReactNative" || navigator.product === "NativeScript" || navigator.product === "NS")) {
return false;
}
return typeof window !== "undefined" && typeof document !== "undefined";
}
function forEach2(obj, fn) {
if (obj === null || typeof obj === "undefined") {
return;
}
if (typeof obj !== "object") {
obj = [obj];
}
if (isArray2(obj)) {
for (var i2 = 0, l = obj.length; i2 < l; i2++) {
fn.call(null, obj[i2], i2, obj);
}
} else {
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
fn.call(null, obj[key], key, obj);
}
}
}
}
function merge2() {
var result = {};
function assignValue(val, key) {
if (isPlainObject2(result[key]) && isPlainObject2(val)) {
result[key] = merge2(result[key], val);
} else if (isPlainObject2(val)) {
result[key] = merge2({}, val);