baio
Version:
Simple AI operator for the CLI, for any LLM
1,458 lines (1,420 loc) • 1.24 MB
JavaScript
#!/usr/bin/env node
import path from 'node:path';
import fs$1, { constants, readFile, unlink, mkdir, writeFile, open as open$1, rm, glob } from 'node:fs/promises';
import os from 'node:os';
import util, { promisify, stripVTControlCharacters, parseArgs } from 'node:util';
import fs from 'node:fs';
import { setTimeout as setTimeout$1 } from 'node:timers/promises';
import childProcess, { execFile as execFile$1 } from 'node:child_process';
import cliMd from 'cli-markdown';
import require$$0$4 from 'fs';
import require$$1$1 from 'os';
import require$$0$3 from 'path';
import require$$2$1 from 'child_process';
import require$$7$1 from 'url';
import process$2 from 'node:process';
import { Buffer as Buffer$1 } from 'node:buffer';
import { fileURLToPath } from 'node:url';
import clipboard from 'copy-paste/promises.js';
import require$$0$5 from 'node:tty';
import * as readline$1 from 'node:readline';
import { AsyncLocalStorage, AsyncResource } from 'node:async_hooks';
import require$$1$2 from 'stream';
import require$$0$6 from 'tty';
import tgl from 'inquirer-toggle';
import fileSelector from 'inquirer-file-selector';
import require$$0$7 from 'util';
import require$$0$8 from 'buffer';
import require$$1$3 from 'string_decoder';
import require$$2$2 from 'crypto';
var name = "baio";
var version = "1.0.42";
var description = "Simple AI operator for the CLI, for any LLM";
var author = {
name: "BananaAcid (Nabil Redmann)",
email: "repo@bananaacid.de"
};
var homepage = "https://github.com/BananaAcid/ai-operator";
var license = "MIT";
var packageJSON = {
name: name,
version: version,
description: description,
author: author,
homepage: homepage,
license: license};
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
function getAugmentedNamespace(n) {
if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n;
var f = n.default;
if (typeof f == "function") {
var a = function a () {
var isInstance = false;
try {
isInstance = this instanceof a;
} catch {}
if (isInstance) {
return Reflect.construct(f, arguments, this.constructor);
}
return f.apply(this, arguments);
};
a.prototype = f.prototype;
} else a = {};
Object.defineProperty(a, '__esModule', {value: true});
Object.keys(n).forEach(function (k) {
var d = Object.getOwnPropertyDescriptor(n, k);
Object.defineProperty(a, k, d.get ? d : {
enumerable: true,
get: function () {
return n[k];
}
});
});
return a;
}
var picocolors = {exports: {}};
var hasRequiredPicocolors;
function requirePicocolors () {
if (hasRequiredPicocolors) return picocolors.exports;
hasRequiredPicocolors = 1;
let p = process || {}, argv = p.argv || [], env = p.env || {};
let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
let formatter = (open, close, replace = open) => (input) => {
let string = "" + input, index = string.indexOf(close, open.length);
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
};
let replaceClose = (string, close, replace, index) => {
let result = "", cursor = 0;
do {
result += string.substring(cursor, index) + replace;
cursor = index + close.length;
index = string.indexOf(close, cursor);
} while (~index);
return result + string.substring(cursor);
};
let createColors = (enabled = isColorSupported) => {
let f = enabled ? formatter : () => String;
return {
isColorSupported: enabled,
reset: f("\x1B[0m", "\x1B[0m"),
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
italic: f("\x1B[3m", "\x1B[23m"),
underline: f("\x1B[4m", "\x1B[24m"),
inverse: f("\x1B[7m", "\x1B[27m"),
hidden: f("\x1B[8m", "\x1B[28m"),
strikethrough: f("\x1B[9m", "\x1B[29m"),
black: f("\x1B[30m", "\x1B[39m"),
red: f("\x1B[31m", "\x1B[39m"),
green: f("\x1B[32m", "\x1B[39m"),
yellow: f("\x1B[33m", "\x1B[39m"),
blue: f("\x1B[34m", "\x1B[39m"),
magenta: f("\x1B[35m", "\x1B[39m"),
cyan: f("\x1B[36m", "\x1B[39m"),
white: f("\x1B[37m", "\x1B[39m"),
gray: f("\x1B[90m", "\x1B[39m"),
bgBlack: f("\x1B[40m", "\x1B[49m"),
bgRed: f("\x1B[41m", "\x1B[49m"),
bgGreen: f("\x1B[42m", "\x1B[49m"),
bgYellow: f("\x1B[43m", "\x1B[49m"),
bgBlue: f("\x1B[44m", "\x1B[49m"),
bgMagenta: f("\x1B[45m", "\x1B[49m"),
bgCyan: f("\x1B[46m", "\x1B[49m"),
bgWhite: f("\x1B[47m", "\x1B[49m"),
blackBright: f("\x1B[90m", "\x1B[39m"),
redBright: f("\x1B[91m", "\x1B[39m"),
greenBright: f("\x1B[92m", "\x1B[39m"),
yellowBright: f("\x1B[93m", "\x1B[39m"),
blueBright: f("\x1B[94m", "\x1B[39m"),
magentaBright: f("\x1B[95m", "\x1B[39m"),
cyanBright: f("\x1B[96m", "\x1B[39m"),
whiteBright: f("\x1B[97m", "\x1B[39m"),
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
bgRedBright: f("\x1B[101m", "\x1B[49m"),
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
};
};
picocolors.exports = createColors();
picocolors.exports.createColors = createColors;
return picocolors.exports;
}
var shellQuote = {};
var quote;
var hasRequiredQuote;
function requireQuote () {
if (hasRequiredQuote) return quote;
hasRequiredQuote = 1;
quote = function quote(xs) {
return xs.map(function(s) {
if (s === "") {
return "''";
}
if (s && typeof s === "object") {
return s.op.replace(/(.)/g, "\\$1");
}
if (/["\s]/.test(s) && !/'/.test(s)) {
return "'" + s.replace(/(['\\])/g, "\\$1") + "'";
}
if (/["'\s]/.test(s)) {
return '"' + s.replace(/(["\\$`!])/g, "\\$1") + '"';
}
return String(s).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}])/g, "$1\\$2");
}).join(" ");
};
return quote;
}
var parse$3;
var hasRequiredParse$2;
function requireParse$2 () {
if (hasRequiredParse$2) return parse$3;
hasRequiredParse$2 = 1;
var CONTROL = "(?:" + [
"\\|\\|",
"\\&\\&",
";;",
"\\|\\&",
"\\<\\(",
"\\<\\<\\<",
">>",
">\\&",
"<\\&",
"[&;()|<>]"
].join("|") + ")";
var controlRE = new RegExp("^" + CONTROL + "$");
var META = "|&;()<> \\t";
var SINGLE_QUOTE = '"((\\\\"|[^"])*?)"';
var DOUBLE_QUOTE = "'((\\\\'|[^'])*?)'";
var hash = /^#$/;
var SQ = "'";
var DQ = '"';
var DS = "$";
var TOKEN = "";
var mult = 4294967296;
for (var i = 0; i < 4; i++) {
TOKEN += (mult * Math.random()).toString(16);
}
var startsWithToken = new RegExp("^" + TOKEN);
function matchAll(s, r) {
var origIndex = r.lastIndex;
var matches = [];
var matchObj;
while (matchObj = r.exec(s)) {
matches.push(matchObj);
if (r.lastIndex === matchObj.index) {
r.lastIndex += 1;
}
}
r.lastIndex = origIndex;
return matches;
}
function getVar(env, pre, key) {
var r = typeof env === "function" ? env(key) : env[key];
if (typeof r === "undefined" && key != "") {
r = "";
} else if (typeof r === "undefined") {
r = "$";
}
if (typeof r === "object") {
return pre + TOKEN + JSON.stringify(r) + TOKEN;
}
return pre + r;
}
function parseInternal(string, env, opts) {
if (!opts) {
opts = {};
}
var BS = opts.escape || "\\";
var BAREWORD = "(\\" + BS + `['"` + META + `]|[^\\s'"` + META + "])+";
var chunker = new RegExp([
"(" + CONTROL + ")",
// control chars
"(" + BAREWORD + "|" + SINGLE_QUOTE + "|" + DOUBLE_QUOTE + ")+"
].join("|"), "g");
var matches = matchAll(string, chunker);
if (matches.length === 0) {
return [];
}
if (!env) {
env = {};
}
var commented = false;
return matches.map(function(match) {
var s = match[0];
if (!s || commented) {
return void 0;
}
if (controlRE.test(s)) {
return { op: s };
}
var quote = false;
var esc = false;
var out = "";
var isGlob = false;
var i2;
function parseEnvVar() {
i2 += 1;
var varend;
var varname;
var char = s.charAt(i2);
if (char === "{") {
i2 += 1;
if (s.charAt(i2) === "}") {
throw new Error("Bad substitution: " + s.slice(i2 - 2, i2 + 1));
}
varend = s.indexOf("}", i2);
if (varend < 0) {
throw new Error("Bad substitution: " + s.slice(i2));
}
varname = s.slice(i2, varend);
i2 = varend;
} else if (/[*@#?$!_-]/.test(char)) {
varname = char;
i2 += 1;
} else {
var slicedFromI = s.slice(i2);
varend = slicedFromI.match(/[^\w\d_]/);
if (!varend) {
varname = slicedFromI;
i2 = s.length;
} else {
varname = slicedFromI.slice(0, varend.index);
i2 += varend.index - 1;
}
}
return getVar(env, "", varname);
}
for (i2 = 0; i2 < s.length; i2++) {
var c = s.charAt(i2);
isGlob = isGlob || !quote && (c === "*" || c === "?");
if (esc) {
out += c;
esc = false;
} else if (quote) {
if (c === quote) {
quote = false;
} else if (quote == SQ) {
out += c;
} else {
if (c === BS) {
i2 += 1;
c = s.charAt(i2);
if (c === DQ || c === BS || c === DS) {
out += c;
} else {
out += BS + c;
}
} else if (c === DS) {
out += parseEnvVar();
} else {
out += c;
}
}
} else if (c === DQ || c === SQ) {
quote = c;
} else if (controlRE.test(c)) {
return { op: s };
} else if (hash.test(c)) {
commented = true;
var commentObj = { comment: string.slice(match.index + i2 + 1) };
if (out.length) {
return [out, commentObj];
}
return [commentObj];
} else if (c === BS) {
esc = true;
} else if (c === DS) {
out += parseEnvVar();
} else {
out += c;
}
}
if (isGlob) {
return { op: "glob", pattern: out };
}
return out;
}).reduce(function(prev, arg) {
return typeof arg === "undefined" ? prev : prev.concat(arg);
}, []);
}
parse$3 = function parse(s, env, opts) {
var mapped = parseInternal(s, env, opts);
if (typeof env !== "function") {
return mapped;
}
return mapped.reduce(function(acc, s2) {
if (typeof s2 === "object") {
return acc.concat(s2);
}
var xs = s2.split(RegExp("(" + TOKEN + ".*?" + TOKEN + ")", "g"));
if (xs.length === 1) {
return acc.concat(xs[0]);
}
return acc.concat(xs.filter(Boolean).map(function(x) {
if (startsWithToken.test(x)) {
return JSON.parse(x.split(TOKEN)[1]);
}
return x;
}));
}, []);
};
return parse$3;
}
var hasRequiredShellQuote;
function requireShellQuote () {
if (hasRequiredShellQuote) return shellQuote;
hasRequiredShellQuote = 1;
shellQuote.quote = requireQuote();
shellQuote.parse = requireParse$2();
return shellQuote;
}
var macos;
var hasRequiredMacos;
function requireMacos () {
if (hasRequiredMacos) return macos;
hasRequiredMacos = 1;
macos = {
"/Applications/Atom.app/Contents/MacOS/Atom": "atom",
"/Applications/Atom Beta.app/Contents/MacOS/Atom Beta": "/Applications/Atom Beta.app/Contents/MacOS/Atom Beta",
"/Applications/Brackets.app/Contents/MacOS/Brackets": "brackets",
"/Applications/Sublime Text.app/Contents/MacOS/Sublime Text": "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl",
"/Applications/Sublime Text.app/Contents/MacOS/sublime_text": "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl",
"/Applications/Sublime Text 2.app/Contents/MacOS/Sublime Text 2": "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl",
"/Applications/Sublime Text Dev.app/Contents/MacOS/Sublime Text": "/Applications/Sublime Text Dev.app/Contents/SharedSupport/bin/subl",
"/Applications/Visual Studio Code.app/Contents/MacOS/Electron": "code",
"/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron": "code-insiders",
"/Applications/VSCodium.app/Contents/MacOS/Electron": "codium",
"/Applications/Cursor.app/Contents/MacOS/Cursor": "cursor",
"/Applications/AppCode.app/Contents/MacOS/appcode": "/Applications/AppCode.app/Contents/MacOS/appcode",
"/Applications/CLion.app/Contents/MacOS/clion": "/Applications/CLion.app/Contents/MacOS/clion",
"/Applications/IntelliJ IDEA.app/Contents/MacOS/idea": "/Applications/IntelliJ IDEA.app/Contents/MacOS/idea",
"/Applications/IntelliJ IDEA Ultimate.app/Contents/MacOS/idea": "/Applications/IntelliJ IDEA Ultimate.app/Contents/MacOS/idea",
"/Applications/IntelliJ IDEA Community Edition.app/Contents/MacOS/idea": "/Applications/IntelliJ IDEA Community Edition.app/Contents/MacOS/idea",
"/Applications/PhpStorm.app/Contents/MacOS/phpstorm": "/Applications/PhpStorm.app/Contents/MacOS/phpstorm",
"/Applications/PyCharm.app/Contents/MacOS/pycharm": "/Applications/PyCharm.app/Contents/MacOS/pycharm",
"/Applications/PyCharm CE.app/Contents/MacOS/pycharm": "/Applications/PyCharm CE.app/Contents/MacOS/pycharm",
"/Applications/RubyMine.app/Contents/MacOS/rubymine": "/Applications/RubyMine.app/Contents/MacOS/rubymine",
"/Applications/WebStorm.app/Contents/MacOS/webstorm": "/Applications/WebStorm.app/Contents/MacOS/webstorm",
"/Applications/MacVim.app/Contents/MacOS/MacVim": "mvim",
"/Applications/GoLand.app/Contents/MacOS/goland": "/Applications/GoLand.app/Contents/MacOS/goland",
"/Applications/Rider.app/Contents/MacOS/rider": "/Applications/Rider.app/Contents/MacOS/rider",
"/Applications/Zed.app/Contents/MacOS/zed": "zed"
};
return macos;
}
var linux;
var hasRequiredLinux;
function requireLinux () {
if (hasRequiredLinux) return linux;
hasRequiredLinux = 1;
linux = {
atom: "atom",
Brackets: "brackets",
"code-insiders": "code-insiders",
code: "code",
vscodium: "vscodium",
codium: "codium",
emacs: "emacs",
gvim: "gvim",
idea: "idea",
"idea.sh": "idea",
phpstorm: "phpstorm",
"phpstorm.sh": "phpstorm",
pycharm: "pycharm",
"pycharm.sh": "pycharm",
rubymine: "rubymine",
"rubymine.sh": "rubymine",
sublime_text: "subl",
vim: "vim",
webstorm: "webstorm",
"webstorm.sh": "webstorm",
goland: "goland",
"goland.sh": "goland",
rider: "rider",
"rider.sh": "rider"
};
return linux;
}
var windows;
var hasRequiredWindows;
function requireWindows () {
if (hasRequiredWindows) return windows;
hasRequiredWindows = 1;
windows = [
"Brackets.exe",
"Code.exe",
"Code - Insiders.exe",
"VSCodium.exe",
"Cursor.exe",
"atom.exe",
"sublime_text.exe",
"notepad++.exe",
"clion.exe",
"clion64.exe",
"idea.exe",
"idea64.exe",
"phpstorm.exe",
"phpstorm64.exe",
"pycharm.exe",
"pycharm64.exe",
"rubymine.exe",
"rubymine64.exe",
"webstorm.exe",
"webstorm64.exe",
"goland.exe",
"goland64.exe",
"rider.exe",
"rider64.exe"
];
return windows;
}
var guess;
var hasRequiredGuess;
function requireGuess () {
if (hasRequiredGuess) return guess;
hasRequiredGuess = 1;
const path = require$$0$3;
const shellQuote = requireShellQuote();
const childProcess = require$$2$1;
const COMMON_EDITORS_MACOS = requireMacos();
const COMMON_EDITORS_LINUX = requireLinux();
const COMMON_EDITORS_WIN = requireWindows();
guess = function guessEditor(specifiedEditor) {
if (specifiedEditor) {
return shellQuote.parse(specifiedEditor);
}
if (process.env.LAUNCH_EDITOR) {
return [process.env.LAUNCH_EDITOR];
}
if (process.versions.webcontainer) {
return [process.env.EDITOR || "code"];
}
try {
if (process.platform === "darwin") {
const output = childProcess.execSync("ps x -o comm=", {
stdio: ["pipe", "pipe", "ignore"]
}).toString();
const processNames = Object.keys(COMMON_EDITORS_MACOS);
const processList = output.split("\n");
for (let i = 0; i < processNames.length; i++) {
const processName = processNames[i];
if (processList.includes(processName)) {
return [COMMON_EDITORS_MACOS[processName]];
}
const processNameWithoutApplications = processName.replace("/Applications", "");
if (output.indexOf(processNameWithoutApplications) !== -1) {
if (processName !== COMMON_EDITORS_MACOS[processName]) {
return [COMMON_EDITORS_MACOS[processName]];
}
const runningProcess = processList.find((procName) => procName.endsWith(processNameWithoutApplications));
if (runningProcess !== void 0) {
return [runningProcess];
}
}
}
} else if (process.platform === "win32") {
const output = childProcess.execSync(
'powershell -NoProfile -Command "[Console]::OutputEncoding=[Text.Encoding]::UTF8;Get-CimInstance -Query \\"select executablepath from win32_process where executablepath is not null\\" | % { $_.ExecutablePath }"',
{
stdio: ["pipe", "pipe", "ignore"]
}
).toString();
const runningProcesses = output.split("\r\n");
for (let i = 0; i < runningProcesses.length; i++) {
const fullProcessPath = runningProcesses[i].trim();
const shortProcessName = path.basename(fullProcessPath);
if (COMMON_EDITORS_WIN.indexOf(shortProcessName) !== -1) {
return [fullProcessPath];
}
}
} else if (process.platform === "linux") {
const output = childProcess.execSync("ps x --no-heading -o comm --sort=comm", {
stdio: ["pipe", "pipe", "ignore"]
}).toString();
const processNames = Object.keys(COMMON_EDITORS_LINUX);
for (let i = 0; i < processNames.length; i++) {
const processName = processNames[i];
if (output.indexOf(processName) !== -1) {
return [COMMON_EDITORS_LINUX[processName]];
}
}
}
} catch (ignoreError) {
}
if (process.env.VISUAL) {
return [process.env.VISUAL];
} else if (process.env.EDITOR) {
return [process.env.EDITOR];
}
return [null];
};
return guess;
}
var getArgs;
var hasRequiredGetArgs;
function requireGetArgs () {
if (hasRequiredGetArgs) return getArgs;
hasRequiredGetArgs = 1;
const path = require$$0$3;
getArgs = function getArgumentsForPosition(editor, fileName, lineNumber, columnNumber = 1) {
const editorBasename = path.basename(editor).replace(/\.(exe|cmd|bat)$/i, "");
switch (editorBasename) {
case "atom":
case "Atom":
case "Atom Beta":
case "subl":
case "sublime":
case "sublime_text":
case "wstorm":
case "charm":
case "zed":
return [`${fileName}:${lineNumber}:${columnNumber}`];
case "notepad++":
return ["-n" + lineNumber, "-c" + columnNumber, fileName];
case "vim":
case "mvim":
return [`+call cursor(${lineNumber}, ${columnNumber})`, fileName];
case "joe":
case "gvim":
return [`+${lineNumber}`, fileName];
case "emacs":
case "emacsclient":
return [`+${lineNumber}:${columnNumber}`, fileName];
case "rmate":
case "mate":
case "mine":
return ["--line", lineNumber, fileName];
case "code":
case "Code":
case "code-insiders":
case "Code - Insiders":
case "codium":
case "cursor":
case "vscodium":
case "VSCodium":
return ["-r", "-g", `${fileName}:${lineNumber}:${columnNumber}`];
case "appcode":
case "clion":
case "clion64":
case "idea":
case "idea64":
case "phpstorm":
case "phpstorm64":
case "pycharm":
case "pycharm64":
case "rubymine":
case "rubymine64":
case "webstorm":
case "webstorm64":
case "goland":
case "goland64":
case "rider":
case "rider64":
return ["--line", lineNumber, "--column", columnNumber, fileName];
}
if (process.env.LAUNCH_EDITOR) {
return [fileName, lineNumber, columnNumber];
}
return [fileName];
};
return getArgs;
}
var launchEditor_1;
var hasRequiredLaunchEditor;
function requireLaunchEditor () {
if (hasRequiredLaunchEditor) return launchEditor_1;
hasRequiredLaunchEditor = 1;
const fs = require$$0$4;
const os = require$$1$1;
const path = require$$0$3;
const colors = /*@__PURE__*/ requirePicocolors();
const childProcess = require$$2$1;
const guessEditor = requireGuess();
const getArgumentsForPosition = requireGetArgs();
function wrapErrorCallback(cb) {
return (fileName, errorMessage) => {
console.log();
console.log(
colors.red("Could not open " + path.basename(fileName) + " in the editor.")
);
if (errorMessage) {
if (errorMessage[errorMessage.length - 1] !== ".") {
errorMessage += ".";
}
console.log(
colors.red("The editor process exited with an error: " + errorMessage)
);
}
console.log();
if (cb) cb(fileName, errorMessage);
};
}
function isTerminalEditor(editor) {
switch (editor) {
case "vim":
case "emacs":
case "nano":
return true;
}
return false;
}
const positionRE = /:(\d+)(:(\d+))?$/;
function parseFile(file) {
if (file.startsWith("file://")) {
file = require$$7$1.fileURLToPath(file);
}
const fileName = file.replace(positionRE, "");
const match = file.match(positionRE);
const lineNumber = match && match[1];
const columnNumber = match && match[3];
return {
fileName,
lineNumber,
columnNumber
};
}
let _childProcess = null;
function launchEditor(file, specifiedEditor, onErrorCallback) {
const parsed = parseFile(file);
let { fileName } = parsed;
const { lineNumber, columnNumber } = parsed;
if (!fs.existsSync(fileName)) {
return;
}
if (typeof specifiedEditor === "function") {
onErrorCallback = specifiedEditor;
specifiedEditor = void 0;
}
onErrorCallback = wrapErrorCallback(onErrorCallback);
const [editor, ...args] = guessEditor(specifiedEditor);
if (!editor) {
onErrorCallback(fileName, null);
return;
}
if (process.platform === "linux" && fileName.startsWith("/mnt/") && /Microsoft/i.test(os.release())) {
fileName = path.relative("", fileName);
}
if (lineNumber) {
const extraArgs = getArgumentsForPosition(editor, fileName, lineNumber, columnNumber);
args.push.apply(args, extraArgs);
} else {
args.push(fileName);
}
if (_childProcess && isTerminalEditor(editor)) {
_childProcess.kill("SIGKILL");
}
if (process.platform === "win32") {
let escapeCmdArgs2 = function(cmdArgs) {
return cmdArgs.replace(/([&|<>,;=^])/g, "^$1");
}, doubleQuoteIfNeeded2 = function(str) {
if (str.includes("^")) {
return `^"${str}^"`;
} else if (str.includes(" ")) {
return `"${str}"`;
}
return str;
};
const launchCommand = [editor, ...args.map(escapeCmdArgs2)].map(doubleQuoteIfNeeded2).join(" ");
_childProcess = childProcess.exec(launchCommand, {
stdio: "inherit",
shell: true
});
} else {
_childProcess = childProcess.spawn(editor, args, { stdio: "inherit" });
}
_childProcess.on("exit", function(errorCode) {
_childProcess = null;
if (errorCode) {
onErrorCallback(fileName, "(code " + errorCode + ")");
}
});
_childProcess.on("error", function(error) {
let { code, message } = error;
if ("ENOENT" === code) {
message = `${message} ('${editor}' command does not exist in 'PATH')`;
}
onErrorCallback(fileName, message);
});
}
launchEditor_1 = launchEditor;
return launchEditor_1;
}
var launchEditorExports = requireLaunchEditor();
var launchEditorX = /*@__PURE__*/getDefaultExportFromCjs(launchEditorExports);
let isDockerCached;
function hasDockerEnv() {
try {
fs.statSync("/.dockerenv");
return true;
} catch {
return false;
}
}
function hasDockerCGroup() {
try {
return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
} catch {
return false;
}
}
function isDocker() {
if (isDockerCached === void 0) {
isDockerCached = hasDockerEnv() || hasDockerCGroup();
}
return isDockerCached;
}
let cachedResult;
const hasContainerEnv = () => {
try {
fs.statSync("/run/.containerenv");
return true;
} catch {
return false;
}
};
function isInsideContainer() {
if (cachedResult === void 0) {
cachedResult = hasContainerEnv() || isDocker();
}
return cachedResult;
}
const isWsl = () => {
if (process$2.platform !== "linux") {
return false;
}
if (os.release().toLowerCase().includes("microsoft")) {
if (isInsideContainer()) {
return false;
}
return true;
}
try {
return fs.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isInsideContainer() : false;
} catch {
return false;
}
};
var isWsl$1 = process$2.env.__IS_WSL_TEST__ ? isWsl : isWsl();
function defineLazyProperty(object, propertyName, valueGetter) {
const define = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
Object.defineProperty(object, propertyName, {
configurable: true,
enumerable: true,
get() {
const result = valueGetter();
define(result);
return result;
},
set(value) {
define(value);
}
});
return object;
}
const execFileAsync$3 = promisify(execFile$1);
async function defaultBrowserId() {
if (process$2.platform !== "darwin") {
throw new Error("macOS only");
}
const { stdout } = await execFileAsync$3("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
return match?.groups.id ?? "com.apple.Safari";
}
const execFileAsync$2 = promisify(execFile$1);
async function runAppleScript(script, { humanReadableOutput = true } = {}) {
if (process$2.platform !== "darwin") {
throw new Error("macOS only");
}
const outputArguments = humanReadableOutput ? [] : ["-ss"];
const { stdout } = await execFileAsync$2("osascript", ["-e", script, outputArguments]);
return stdout.trim();
}
async function bundleName(bundleId) {
return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
}
const execFileAsync$1 = promisify(execFile$1);
const windowsBrowserProgIds = {
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
MSEdgeDHTML: { name: "Edge", id: "com.microsoft.edge" },
// On macOS, it's "com.microsoft.edgemac"
MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
// Newer Edge/Win10 releases
"IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" },
FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
BraveHTML: { name: "Brave", id: "com.brave.Browser" },
BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" }
};
class UnknownBrowserError extends Error {
}
async function defaultBrowser$1(_execFileAsync = execFileAsync$1) {
const { stdout } = await _execFileAsync("reg", [
"QUERY",
" HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
"/v",
"ProgId"
]);
const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
if (!match) {
throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
}
const { id } = match.groups;
const browser = windowsBrowserProgIds[id];
if (!browser) {
throw new UnknownBrowserError(`Unknown browser ID: ${id}`);
}
return browser;
}
const execFileAsync = promisify(execFile$1);
const titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
async function defaultBrowser() {
if (process$2.platform === "darwin") {
const id = await defaultBrowserId();
const name = await bundleName(id);
return { name, id };
}
if (process$2.platform === "linux") {
const { stdout } = await execFileAsync("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
const id = stdout.trim();
const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
return { name, id };
}
if (process$2.platform === "win32") {
return defaultBrowser$1();
}
throw new Error("Only macOS, Linux, and Windows are supported");
}
const execFile = util.promisify(childProcess.execFile);
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const localXdgOpenPath = path.join(__dirname, "xdg-open");
const { platform, arch } = process$2;
const getWslDrivesMountPoint = /* @__PURE__ */ (() => {
const defaultMountPoint = "/mnt/";
let mountPoint;
return async function() {
if (mountPoint) {
return mountPoint;
}
const configFilePath = "/etc/wsl.conf";
let isConfigFileExists = false;
try {
await fs$1.access(configFilePath, constants.F_OK);
isConfigFileExists = true;
} catch {
}
if (!isConfigFileExists) {
return defaultMountPoint;
}
const configContent = await fs$1.readFile(configFilePath, { encoding: "utf8" });
const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
if (!configMountPoint) {
return defaultMountPoint;
}
mountPoint = configMountPoint.groups.mountPoint.trim();
mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
return mountPoint;
};
})();
const getPowershellPathFromWsl = async () => {
const mountPoint = await getWslDrivesMountPoint();
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
};
async function getWindowsDefaultBrowserFromWsl() {
const powershellPath = await getPowershellPathFromWsl();
const rawCommand = '(Get-ItemProperty -Path "HKCU:\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice").ProgId';
const encodedCommand = Buffer$1.from(rawCommand, "utf16le").toString("base64");
const { stdout } = await execFile(
powershellPath,
[
"-NoProfile",
"-NonInteractive",
"-ExecutionPolicy",
"Bypass",
"-EncodedCommand",
encodedCommand
],
{ encoding: "utf8" }
);
const progId = stdout.trim();
const browserMap = {
ChromeHTML: "com.google.chrome",
MSEdgeHTM: "com.microsoft.edge",
FirefoxURL: "org.mozilla.firefox"
};
return browserMap[progId] ? { id: browserMap[progId] } : {};
}
const pTryEach = async (array, mapper) => {
let latestError;
for (const item of array) {
try {
return await mapper(item);
} catch (error) {
latestError = error;
}
}
throw latestError;
};
const baseOpen = async (options) => {
options = {
wait: false,
background: false,
newInstance: false,
allowNonzeroExitCode: false,
...options
};
if (Array.isArray(options.app)) {
return pTryEach(options.app, (singleApp) => baseOpen({
...options,
app: singleApp
}));
}
let { name: app, arguments: appArguments = [] } = options.app ?? {};
appArguments = [...appArguments];
if (Array.isArray(app)) {
return pTryEach(app, (appName) => baseOpen({
...options,
app: {
name: appName,
arguments: appArguments
}
}));
}
if (app === "browser" || app === "browserPrivate") {
const ids = {
"com.google.chrome": "chrome",
"google-chrome.desktop": "chrome",
"org.mozilla.firefox": "firefox",
"firefox.desktop": "firefox",
"com.microsoft.msedge": "edge",
"com.microsoft.edge": "edge",
"com.microsoft.edgemac": "edge",
"microsoft-edge.desktop": "edge"
};
const flags = {
chrome: "--incognito",
firefox: "--private-window",
edge: "--inPrivate"
};
const browser = isWsl$1 ? await getWindowsDefaultBrowserFromWsl() : await defaultBrowser();
if (browser.id in ids) {
const browserName = ids[browser.id];
if (app === "browserPrivate") {
appArguments.push(flags[browserName]);
}
return baseOpen({
...options,
app: {
name: apps[browserName],
arguments: appArguments
}
});
}
throw new Error(`${browser.name} is not supported as a default browser`);
}
let command;
const cliArguments = [];
const childProcessOptions = {};
if (platform === "darwin") {
command = "open";
if (options.wait) {
cliArguments.push("--wait-apps");
}
if (options.background) {
cliArguments.push("--background");
}
if (options.newInstance) {
cliArguments.push("--new");
}
if (app) {
cliArguments.push("-a", app);
}
} else if (platform === "win32" || isWsl$1 && !isInsideContainer() && !app) {
command = isWsl$1 ? await getPowershellPathFromWsl() : `${process$2.env.SYSTEMROOT || process$2.env.windir || "C:\\Windows"}\\System32\\WindowsPowerShell\\v1.0\\powershell`;
cliArguments.push(
"-NoProfile",
"-NonInteractive",
"-ExecutionPolicy",
"Bypass",
"-EncodedCommand"
);
if (!isWsl$1) {
childProcessOptions.windowsVerbatimArguments = true;
}
const encodedArguments = ["Start"];
if (options.wait) {
encodedArguments.push("-Wait");
}
if (app) {
encodedArguments.push(`"\`"${app}\`""`);
if (options.target) {
appArguments.push(options.target);
}
} else if (options.target) {
encodedArguments.push(`"${options.target}"`);
}
if (appArguments.length > 0) {
appArguments = appArguments.map((argument) => `"\`"${argument}\`""`);
encodedArguments.push("-ArgumentList", appArguments.join(","));
}
options.target = Buffer$1.from(encodedArguments.join(" "), "utf16le").toString("base64");
} else {
if (app) {
command = app;
} else {
const isBundled = !__dirname || __dirname === "/";
let exeLocalXdgOpen = false;
try {
await fs$1.access(localXdgOpenPath, constants.X_OK);
exeLocalXdgOpen = true;
} catch {
}
const useSystemXdgOpen = process$2.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
}
if (appArguments.length > 0) {
cliArguments.push(...appArguments);
}
if (!options.wait) {
childProcessOptions.stdio = "ignore";
childProcessOptions.detached = true;
}
}
if (platform === "darwin" && appArguments.length > 0) {
cliArguments.push("--args", ...appArguments);
}
if (options.target) {
cliArguments.push(options.target);
}
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
if (options.wait) {
return new Promise((resolve, reject) => {
subprocess.once("error", reject);
subprocess.once("close", (exitCode) => {
if (!options.allowNonzeroExitCode && exitCode > 0) {
reject(new Error(`Exited with code ${exitCode}`));
return;
}
resolve(subprocess);
});
});
}
subprocess.unref();
return subprocess;
};
const open = (target, options) => {
if (typeof target !== "string") {
throw new TypeError("Expected a `target`");
}
return baseOpen({
...options,
target
});
};
function detectArchBinary(binary) {
if (typeof binary === "string" || Array.isArray(binary)) {
return binary;
}
const { [arch]: archBinary } = binary;
if (!archBinary) {
throw new Error(`${arch} is not supported`);
}
return archBinary;
}
function detectPlatformBinary({ [platform]: platformBinary }, { wsl }) {
if (wsl && isWsl$1) {
return detectArchBinary(wsl);
}
if (!platformBinary) {
throw new Error(`${platform} is not supported`);
}
return detectArchBinary(platformBinary);
}
const apps = {};
defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
darwin: "google chrome",
win32: "chrome",
linux: ["google-chrome", "google-chrome-stable", "chromium"]
}, {
wsl: {
ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
}
}));
defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
darwin: "firefox",
win32: "C:\\Program Files\\Mozilla Firefox\\firefox.exe",
linux: "firefox"
}, {
wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
}));
defineLazyProperty(apps, "edge", () => detectPlatformBinary({
darwin: "microsoft edge",
win32: "msedge",
linux: ["microsoft-edge", "microsoft-edge-dev"]
}, {
wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
}));
defineLazyProperty(apps, "browser", () => "browser");
defineLazyProperty(apps, "browserPrivate", () => "browserPrivate");
const types$1 = {
"application/prs.cww": ["cww"],
"application/prs.xsf+xml": ["xsf"],
"application/vnd.1000minds.decision-model+xml": ["1km"],
"application/vnd.3gpp.pic-bw-large": ["plb"],
"application/vnd.3gpp.pic-bw-small": ["psb"],
"application/vnd.3gpp.pic-bw-var": ["pvb"],
"application/vnd.3gpp2.tcap": ["tcap"],
"application/vnd.3m.post-it-notes": ["pwn"],
"application/vnd.accpac.simply.aso": ["aso"],
"application/vnd.accpac.simply.imp": ["imp"],
"application/vnd.acucobol": ["acu"],
"application/vnd.acucorp": ["atc", "acutc"],
"application/vnd.adobe.air-application-installer-package+zip": ["air"],
"application/vnd.adobe.formscentral.fcdt": ["fcdt"],
"application/vnd.adobe.fxp": ["fxp", "fxpl"],
"application/vnd.adobe.xdp+xml": ["xdp"],
"application/vnd.adobe.xfdf": ["*xfdf"],
"application/vnd.age": ["age"],
"application/vnd.ahead.space": ["ahead"],
"application/vnd.airzip.filesecure.azf": ["azf"],
"application/vnd.airzip.filesecure.azs": ["azs"],
"application/vnd.amazon.ebook": ["azw"],
"application/vnd.americandynamics.acc": ["acc"],
"application/vnd.amiga.ami": ["ami"],
"application/vnd.android.package-archive": ["apk"],
"application/vnd.anser-web-certificate-issue-initiation": ["cii"],
"application/vnd.anser-web-funds-transfer-initiation": ["fti"],
"application/vnd.antix.game-component": ["atx"],
"application/vnd.apple.installer+xml": ["mpkg"],
"application/vnd.apple.keynote": ["key"],
"application/vnd.apple.mpegurl": ["m3u8"],
"application/vnd.apple.numbers": ["numbers"],
"application/vnd.apple.pages": ["pages"],
"application/vnd.apple.pkpass": ["pkpass"],
"application/vnd.aristanetworks.swi": ["swi"],
"application/vnd.astraea-software.iota": ["iota"],
"application/vnd.audiograph": ["aep"],
"application/vnd.autodesk.fbx": ["fbx"],
"application/vnd.balsamiq.bmml+xml": ["bmml"],
"application/vnd.blueice.multipass": ["mpm"],
"application/vnd.bmi": ["bmi"],
"application/vnd.businessobjects": ["rep"],
"application/vnd.chemdraw+xml": ["cdxml"],
"application/vnd.chipnuts.karaoke-mmd": ["mmd"],
"application/vnd.cinderella": ["cdy"],
"application/vnd.citationstyles.style+xml": ["csl"],
"application/vnd.claymore": ["cla"],
"application/vnd.cloanto.rp9": ["rp9"],
"application/vnd.clonk.c4group": ["c4g", "c4d", "c4f", "c4p", "c4u"],
"application/vnd.cluetrust.cartomobile-config": ["c11amc"],
"application/vnd.cluetrust.cartomobile-config-pkg": ["c11amz"],
"application/vnd.commonspace": ["csp"],
"application/vnd.contact.cmsg": ["cdbcmsg"],
"application/vnd.cosmocaller": ["cmc"],
"application/vnd.crick.clicker": ["clkx"],
"application/vnd.crick.clicker.keyboard": ["clkk"],
"application/vnd.crick.clicker.palette": ["clkp"],
"application/vnd.crick.clicker.template": ["clkt"],
"application/vnd.crick.clicker.wordbank": ["clkw"],
"application/vnd.criticaltools.wbs+xml": ["wbs"],
"application/vnd.ctc-posml": ["pml"],
"application/vnd.cups-ppd": ["ppd"],
"application/vnd.curl.car": ["car"],
"application/vnd.curl.pcurl": ["pcurl"],
"application/vnd.dart": ["dart"],
"application/vnd.data-vision.rdz": ["rdz"],
"application/vnd.dbf": ["dbf"],
"application/vnd.dcmp+xml": ["dcmp"],
"application/vnd.dece.data": ["uvf", "uvvf", "uvd", "uvvd"],
"application/vnd.dece.ttml+xml": ["uvt", "uvvt"],
"application/vnd.dece.unspecified": ["uvx", "uvvx"],
"application/vnd.dece.zip": ["uvz", "uvvz"],
"application/vnd.denovo.fcselayout-link": ["fe_launch"],
"application/vnd.dna": ["dna"],
"application/vnd.dolby.mlp": ["mlp"],
"application/vnd.dpgraph": ["dpg"],
"application/vnd.dreamfactory": ["dfac"],
"application/vnd.ds-keypoint": ["kpxx"],
"application/vnd.dvb.ait": ["ait"],
"application/vnd.dvb.service": ["svc"],
"application/vnd.dynageo": ["geo"],
"application/vnd.ecowin.chart": ["mag"],
"application/vnd.enliven": ["nml"],
"application/vnd.epson.esf": ["esf"],
"application/vnd.epson.msf": ["msf"],
"application/vnd.epson.quickanime": ["qam"],
"application/vnd.epson.salt": ["slt"],
"application/vnd.epson.ssf": ["ssf"],
"application/vnd.eszigno3+xml": ["es3", "et3"],
"application/vnd.ezpix-album": ["ez2"],
"application/vnd.ezpix-package": ["ez3"],
"application/vnd.fdf": ["*fdf"],
"application/vnd.fdsn.mseed": ["mseed"],
"application/vnd.fdsn.seed": ["seed", "dataless"],
"application/vnd.flographit": ["gph"],
"application/vnd.fluxtime.clip": ["ftc"],
"application/vnd.framemaker": ["fm", "frame", "maker", "book"],
"application/vnd.frogans.fnc": ["fnc"],
"application/vnd.frogans.ltf": ["ltf"],
"application/vnd.fsc.weblaunch": ["fsc"],
"application/vnd.fujitsu.oasys": ["oas"],
"application/vnd.fujitsu.oasys2": ["oa2"],
"application/vnd.fujitsu.oasys3": ["oa3"],
"application/vnd.fujitsu.oasysgp": ["fg5"],
"application/vnd.fujitsu.oasysprs": ["bh2"],
"application/vnd.fujixerox.ddd": ["ddd"],
"application/vnd.fujixerox.docuworks": ["xdw"],
"application/vnd.fujixerox.docuworks.binder": ["xbd"],
"application/vnd.fuzzysheet": ["fzs"],
"application/vnd.genomatix.tuxedo": ["txd"],
"application/vnd.geogebra.file": ["ggb"],
"application/vnd.geogebra.slides": ["ggs"],
"application/vnd.geogebra.tool": ["ggt"],
"application/vnd.geometry-explorer": ["gex", "gre"],
"application/vnd.geonext": ["gxt"],
"application/vnd.geoplan": ["g2w"],
"application/vnd.geospace": ["g3w"],
"application/vnd.gmx": ["gmx"],
"application/vnd.google-apps.document": ["gdoc"],
"application/vnd.google-apps.drawing": ["gdraw"],
"application/vnd.google-apps.form": ["gform"],
"application/vnd.google-apps.jam": ["gjam"],
"application/vnd.google-apps.map": ["gmap"],
"application/vnd.google-apps.presentation": ["gslides"],
"application/vnd.google-apps.script": ["gscript"],
"application/vnd.google-apps.site": ["gsite"],
"application/vnd.google-apps.spreadsheet": ["gsheet"],
"application/vnd.google-earth.kml+xml": ["kml"],
"application/vnd.google-earth.kmz": ["kmz"],
"application/vnd.gov.sk.xmldatacontainer+xml": ["xdcf"],
"application/vnd.grafeq": ["gqf", "gqs"],
"application/vnd.groove-account": ["gac"],
"application/vnd.groove-help": ["ghf"],
"application/vnd.groove-identity-message": ["gim"],
"application/vnd.groove-injector": ["grv"],
"application/vnd.groove-tool-message": ["gtm"],
"application/vnd.groove-tool-template": ["tpl"],
"application/vnd.groove-vcard": ["vcg"],
"application/vnd.hal+xml": ["hal"],
"application/vnd.handheld-entertainment+xml": ["zmm"],
"application/vnd.hbci": ["hbci"],
"application/vnd.hhe.lesson-player": ["les"],
"application/vnd.hp-hpgl": ["hpgl"],
"application/vnd.hp-hpid": ["hpid"],
"application/vnd.hp-hps": ["hps"],
"application/vnd.hp-jlyt": ["jlt"],
"application/vnd.hp-pcl": ["pcl"],
"application/vnd.hp-pclxl": ["pclxl"],
"application/vnd.hydrostatix.sof-data": ["sfd-hdstx"],
"application/vnd.ibm.minipay": ["mpy"],
"application/vnd.ibm.modcap": ["afp", "listafp", "list3820"],
"application/vnd.ibm.rights-management": ["irm"],
"application/vnd.ibm.secure-container": ["sc"],
"application/vnd.iccprofile": ["icc", "icm"],
"application/vnd.igloader": ["igl"],
"application/vnd.immervision-ivp": ["ivp"],
"application/vnd.immervision-ivu": ["ivu"],
"application/vnd.insors.igm": ["igm"],
"application/vnd.intercon.formnet": ["xpw", "xpx"],
"application/vnd.intergeo": ["i2g"],
"application/vnd.intu.qbo": ["qbo"],
"application/vnd.intu.qfx": ["qfx"],
"application/vnd.ipunplugged.rcprofile": ["rcprofile"],
"application/vnd.irepository.package+xml": ["irp"],
"application/vnd.is-xpr": ["xpr"],
"application/vnd.isac.fcs": ["fcs"],
"application/vnd.jam": ["jam"],
"application/vnd.jcp.javame.midlet-rms": ["rms"],
"application/vnd.jisp": ["jisp"],
"application/vnd.joost.joda-archive": ["joda"],
"application/vnd.kahootz": ["ktz", "ktr"],
"application/vnd.kde.karbon": ["karbon"],
"application/vnd.kde.kchart": ["chrt"],
"application/vnd.kde.kformula": ["kfo"],
"application/vnd.kde.kivio": ["flw"],
"application/vnd.kde.kontour": ["kon"],
"application/vnd.kde.kpresenter": ["kpr", "kpt"],
"application/vnd.kde.kspread": ["ksp"],
"application/vnd.kde.kword": ["kwd", "kwt"],
"application/vnd.kenameaapp": ["htke"],
"application/vnd.kidspiration": ["kia"],
"application/vnd.kinar": ["kne", "knp"],
"application/vnd.koan": ["skp", "skd", "skt", "skm"],
"application/vnd.kodak-descriptor": ["sse"],
"application/vnd.las.las+xml": ["lasxml"],
"application/vnd.llamagraphics.life-balance.desktop": ["lbd"],
"application/vnd.llamagraphics.life-balance.exchange+xml": ["lbe"],
"application/vnd.lotus-1-2-3": ["123"],
"application/vnd.lotus-approach": ["apr"],
"application/vnd.lotus-freelance": ["pre"],
"application/vnd.lotus-notes": ["nsf"],
"application/vnd.lotus-organizer": ["org"],
"application/vnd.lotus-screencam": ["scm"],
"application/vnd.lotus-wordpro": ["lwp"],
"application/vnd.macports.portpkg": ["portpkg"],
"application/vnd.mapbox-vector-tile": ["mvt"],
"application/vnd.mcd": ["mcd"],
"application/vnd.medcalcdata": ["mc1"],
"application/vnd.mediastation.cdkey": ["cdkey"],
"application/vnd.mfer": ["mwf"],
"application/vnd.mfmp": ["mfm"],
"application/vnd.micrografx.flo": ["flo"],
"application/vnd.micrografx.igx": ["igx"],
"application/vnd.mif": ["mif"],
"application/vnd.mobius.daf": ["daf"],
"application/vnd.mobius.dis": ["dis"],
"application/vnd.mobius.mbk": ["mbk"],
"application/vnd.mobius.mqy": ["mqy"],
"application/vnd.mobius.msl": ["msl"],
"application/vnd.mobius.plc": ["plc"],
"application/vnd.mobius.txf": ["txf"],
"application/vnd.mophun.application": ["mpn"],
"application/vnd.mophun.certificate": ["mpc"],
"application/vnd.mozilla.xul+xml": ["xul"],
"application/vnd.ms-artgalry": ["cil"],
"application/vnd.ms-cab-compressed": ["cab"],
"application/vnd.ms-excel": ["xls", "xlm", "xla", "xlc", "xlt", "xlw"],
"application/vnd.ms-excel.addin.macroenabled.12": ["xlam"],
"application/vnd.ms-excel.sheet.binary.macroenabled.12": ["xlsb"],
"application/vnd.ms-excel.sheet.macroenabled.12": ["xlsm"],
"application/vnd.ms-excel.template.macroenabled.12": ["xltm"],
"application/vnd.ms-fontobject": ["eot"],
"application/vnd.ms-htmlhelp": ["chm"],
"application/vnd.ms-ims": ["ims"],
"application/vnd.ms-lrm": ["lrm"],
"application/vnd.ms-officetheme": ["thmx"],
"application/vnd.ms-outlook": ["msg"],
"application/vnd.ms-pki.seccat": ["cat"],
"application/vnd.ms-pki.stl": ["*stl"],
"application/vnd.ms-powerpoint": ["ppt", "pps", "pot"],
"application/vnd.ms-powerpoint.addin.macroenabled.12": ["ppam"],
"application/vnd.ms-powerpoint.presentation.macroenabled.12": ["pptm"],
"application/vnd.ms-powerpoint.slide.macroenabled.12": ["sldm"],
"application/vnd.ms-powerpoint.slideshow.macroenabled.12": ["ppsm"],
"application/vnd.ms-powerpoint.template.macroenabled.12": ["potm"],
"application/vnd.ms-project": ["*mpp", "mpt"],
"application/vnd.ms-visio.viewer": ["vdx"],
"application/vnd.ms-word.document.macroenabled.12": ["docm"],
"application/vnd.ms-word.template.macroenabled.12": ["dotm"],
"application/vnd.ms-works": ["wps", "wks", "wcm", "wdb"],
"application/vnd.ms-wpl": ["wpl"],
"application/vnd.ms-xpsdocument": ["xps"],
"application/vnd.mseq": ["mseq"],
"application/vnd.musician": ["mus"],
"application/vnd.muvee.style": ["msty"],
"application/vnd.mynfc": ["taglet"],
"application/vnd.nato.bindingdataobject+xml": ["bdo"],
"application/vnd.neurolanguage.nlu": ["nlu"],
"application/vnd.nitf": ["ntf", "nitf"],
"application/vnd.noblenet-directory": ["nnd"],
"application/vnd.noblenet-sealer": ["nns"],
"ap