@llmnesia/mcp 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../node_modules/isexe/windows.js","../../node_modules/isexe/mode.js","../../node_modules/isexe/index.js","../../node_modules/which/which.js","../../node_modules/path-key/index.js","../../node_modules/cross-spawn/lib/util/resolveCommand.js","../../node_modules/cross-spawn/lib/util/escape.js","../../node_modules/shebang-regex/index.js","../../node_modules/shebang-command/index.js","../../node_modules/cross-spawn/lib/util/readShebang.js","../../node_modules/cross-spawn/lib/parse.js","../../node_modules/cross-spawn/lib/enoent.js","../../node_modules/cross-spawn/index.js","../src/cli.ts","../../packages/native-host/install.mjs","../src/args.ts","../../node_modules/chokidar/esm/index.js","../../node_modules/readdirp/esm/index.js","../../node_modules/chokidar/esm/handler.js","../src/watch.ts","../src/clientRegistration.ts","../src/doctor.ts","../src/runtimeInstall.ts"],"sourcesContent":["module.exports = isexe\nisexe.sync = sync\n\nvar fs = require('fs')\n\nfunction checkPathExt (path, options) {\n var pathext = options.pathExt !== undefined ?\n options.pathExt : process.env.PATHEXT\n\n if (!pathext) {\n return true\n }\n\n pathext = pathext.split(';')\n if (pathext.indexOf('') !== -1) {\n return true\n }\n for (var i = 0; i < pathext.length; i++) {\n var p = pathext[i].toLowerCase()\n if (p && path.substr(-p.length).toLowerCase() === p) {\n return true\n }\n }\n return false\n}\n\nfunction checkStat (stat, path, options) {\n if (!stat.isSymbolicLink() && !stat.isFile()) {\n return false\n }\n return checkPathExt(path, options)\n}\n\nfunction isexe (path, options, cb) {\n fs.stat(path, function (er, stat) {\n cb(er, er ? false : checkStat(stat, path, options))\n })\n}\n\nfunction sync (path, options) {\n return checkStat(fs.statSync(path), path, options)\n}\n","module.exports = isexe\nisexe.sync = sync\n\nvar fs = require('fs')\n\nfunction isexe (path, options, cb) {\n fs.stat(path, function (er, stat) {\n cb(er, er ? false : checkStat(stat, options))\n })\n}\n\nfunction sync (path, options) {\n return checkStat(fs.statSync(path), options)\n}\n\nfunction checkStat (stat, options) {\n return stat.isFile() && checkMode(stat, options)\n}\n\nfunction checkMode (stat, options) {\n var mod = stat.mode\n var uid = stat.uid\n var gid = stat.gid\n\n var myUid = options.uid !== undefined ?\n options.uid : process.getuid && process.getuid()\n var myGid = options.gid !== undefined ?\n options.gid : process.getgid && process.getgid()\n\n var u = parseInt('100', 8)\n var g = parseInt('010', 8)\n var o = parseInt('001', 8)\n var ug = u | g\n\n var ret = (mod & o) ||\n (mod & g) && gid === myGid ||\n (mod & u) && uid === myUid ||\n (mod & ug) && myUid === 0\n\n return ret\n}\n","var fs = require('fs')\nvar core\nif (process.platform === 'win32' || global.TESTING_WINDOWS) {\n core = require('./windows.js')\n} else {\n core = require('./mode.js')\n}\n\nmodule.exports = isexe\nisexe.sync = sync\n\nfunction isexe (path, options, cb) {\n if (typeof options === 'function') {\n cb = options\n options = {}\n }\n\n if (!cb) {\n if (typeof Promise !== 'function') {\n throw new TypeError('callback not provided')\n }\n\n return new Promise(function (resolve, reject) {\n isexe(path, options || {}, function (er, is) {\n if (er) {\n reject(er)\n } else {\n resolve(is)\n }\n })\n })\n }\n\n core(path, options || {}, function (er, is) {\n // ignore EACCES because that just means we aren't allowed to run it\n if (er) {\n if (er.code === 'EACCES' || options && options.ignoreErrors) {\n er = null\n is = false\n }\n }\n cb(er, is)\n })\n}\n\nfunction sync (path, options) {\n // my kingdom for a filtered catch\n try {\n return core.sync(path, options || {})\n } catch (er) {\n if (options && options.ignoreErrors || er.code === 'EACCES') {\n return false\n } else {\n throw er\n }\n }\n}\n","const isWindows = process.platform === 'win32' ||\n process.env.OSTYPE === 'cygwin' ||\n process.env.OSTYPE === 'msys'\n\nconst path = require('path')\nconst COLON = isWindows ? ';' : ':'\nconst isexe = require('isexe')\n\nconst getNotFoundError = (cmd) =>\n Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' })\n\nconst getPathInfo = (cmd, opt) => {\n const colon = opt.colon || COLON\n\n // If it has a slash, then we don't bother searching the pathenv.\n // just check the file itself, and that's it.\n const pathEnv = cmd.match(/\\//) || isWindows && cmd.match(/\\\\/) ? ['']\n : (\n [\n // windows always checks the cwd first\n ...(isWindows ? [process.cwd()] : []),\n ...(opt.path || process.env.PATH ||\n /* istanbul ignore next: very unusual */ '').split(colon),\n ]\n )\n const pathExtExe = isWindows\n ? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM'\n : ''\n const pathExt = isWindows ? pathExtExe.split(colon) : ['']\n\n if (isWindows) {\n if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')\n pathExt.unshift('')\n }\n\n return {\n pathEnv,\n pathExt,\n pathExtExe,\n }\n}\n\nconst which = (cmd, opt, cb) => {\n if (typeof opt === 'function') {\n cb = opt\n opt = {}\n }\n if (!opt)\n opt = {}\n\n const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)\n const found = []\n\n const step = i => new Promise((resolve, reject) => {\n if (i === pathEnv.length)\n return opt.all && found.length ? resolve(found)\n : reject(getNotFoundError(cmd))\n\n const ppRaw = pathEnv[i]\n const pathPart = /^\".*\"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw\n\n const pCmd = path.join(pathPart, cmd)\n const p = !pathPart && /^\\.[\\\\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd\n : pCmd\n\n resolve(subStep(p, i, 0))\n })\n\n const subStep = (p, i, ii) => new Promise((resolve, reject) => {\n if (ii === pathExt.length)\n return resolve(step(i + 1))\n const ext = pathExt[ii]\n isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {\n if (!er && is) {\n if (opt.all)\n found.push(p + ext)\n else\n return resolve(p + ext)\n }\n return resolve(subStep(p, i, ii + 1))\n })\n })\n\n return cb ? step(0).then(res => cb(null, res), cb) : step(0)\n}\n\nconst whichSync = (cmd, opt) => {\n opt = opt || {}\n\n const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)\n const found = []\n\n for (let i = 0; i < pathEnv.length; i ++) {\n const ppRaw = pathEnv[i]\n const pathPart = /^\".*\"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw\n\n const pCmd = path.join(pathPart, cmd)\n const p = !pathPart && /^\\.[\\\\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd\n : pCmd\n\n for (let j = 0; j < pathExt.length; j ++) {\n const cur = p + pathExt[j]\n try {\n const is = isexe.sync(cur, { pathExt: pathExtExe })\n if (is) {\n if (opt.all)\n found.push(cur)\n else\n return cur\n }\n } catch (ex) {}\n }\n }\n\n if (opt.all && found.length)\n return found\n\n if (opt.nothrow)\n return null\n\n throw getNotFoundError(cmd)\n}\n\nmodule.exports = which\nwhich.sync = whichSync\n","'use strict';\n\nconst pathKey = (options = {}) => {\n\tconst environment = options.env || process.env;\n\tconst platform = options.platform || process.platform;\n\n\tif (platform !== 'win32') {\n\t\treturn 'PATH';\n\t}\n\n\treturn Object.keys(environment).reverse().find(key => key.toUpperCase() === 'PATH') || 'Path';\n};\n\nmodule.exports = pathKey;\n// TODO: Remove this for the next major release\nmodule.exports.default = pathKey;\n","'use strict';\n\nconst path = require('path');\nconst which = require('which');\nconst getPathKey = require('path-key');\n\nfunction resolveCommandAttempt(parsed, withoutPathExt) {\n const env = parsed.options.env || process.env;\n const cwd = process.cwd();\n const hasCustomCwd = parsed.options.cwd != null;\n // Worker threads do not have process.chdir()\n const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled;\n\n // If a custom `cwd` was specified, we need to change the process cwd\n // because `which` will do stat calls but does not support a custom cwd\n if (shouldSwitchCwd) {\n try {\n process.chdir(parsed.options.cwd);\n } catch (err) {\n /* Empty */\n }\n }\n\n let resolved;\n\n try {\n resolved = which.sync(parsed.command, {\n path: env[getPathKey({ env })],\n pathExt: withoutPathExt ? path.delimiter : undefined,\n });\n } catch (e) {\n /* Empty */\n } finally {\n if (shouldSwitchCwd) {\n process.chdir(cwd);\n }\n }\n\n // If we successfully resolved, ensure that an absolute path is returned\n // Note that when a custom `cwd` was used, we need to resolve to an absolute path based on it\n if (resolved) {\n resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : '', resolved);\n }\n\n return resolved;\n}\n\nfunction resolveCommand(parsed) {\n return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);\n}\n\nmodule.exports = resolveCommand;\n","'use strict';\n\n// See http://www.robvanderwoude.com/escapechars.php\nconst metaCharsRegExp = /([()\\][%!^\"`<>&|;, *?])/g;\n\nfunction escapeCommand(arg) {\n // Escape meta chars\n arg = arg.replace(metaCharsRegExp, '^$1');\n\n return arg;\n}\n\nfunction escapeArgument(arg, doubleEscapeMetaChars) {\n // Convert to string\n arg = `${arg}`;\n\n // Algorithm below is based on https://qntm.org/cmd\n // It's slightly altered to disable JS backtracking to avoid hanging on specially crafted input\n // Please see https://github.com/moxystudio/node-cross-spawn/pull/160 for more information\n\n // Sequence of backslashes followed by a double quote:\n // double up all the backslashes and escape the double quote\n arg = arg.replace(/(?=(\\\\+?)?)\\1\"/g, '$1$1\\\\\"');\n\n // Sequence of backslashes followed by the end of the string\n // (which will become a double quote later):\n // double up all the backslashes\n arg = arg.replace(/(?=(\\\\+?)?)\\1$/, '$1$1');\n\n // All other backslashes occur literally\n\n // Quote the whole thing:\n arg = `\"${arg}\"`;\n\n // Escape meta chars\n arg = arg.replace(metaCharsRegExp, '^$1');\n\n // Double escape meta chars if necessary\n if (doubleEscapeMetaChars) {\n arg = arg.replace(metaCharsRegExp, '^$1');\n }\n\n return arg;\n}\n\nmodule.exports.command = escapeCommand;\nmodule.exports.argument = escapeArgument;\n","'use strict';\nmodule.exports = /^#!(.*)/;\n","'use strict';\nconst shebangRegex = require('shebang-regex');\n\nmodule.exports = (string = '') => {\n\tconst match = string.match(shebangRegex);\n\n\tif (!match) {\n\t\treturn null;\n\t}\n\n\tconst [path, argument] = match[0].replace(/#! ?/, '').split(' ');\n\tconst binary = path.split('/').pop();\n\n\tif (binary === 'env') {\n\t\treturn argument;\n\t}\n\n\treturn argument ? `${binary} ${argument}` : binary;\n};\n","'use strict';\n\nconst fs = require('fs');\nconst shebangCommand = require('shebang-command');\n\nfunction readShebang(command) {\n // Read the first 150 bytes from the file\n const size = 150;\n const buffer = Buffer.alloc(size);\n\n let fd;\n\n try {\n fd = fs.openSync(command, 'r');\n fs.readSync(fd, buffer, 0, size, 0);\n fs.closeSync(fd);\n } catch (e) { /* Empty */ }\n\n // Attempt to extract shebang (null is returned if not a shebang)\n return shebangCommand(buffer.toString());\n}\n\nmodule.exports = readShebang;\n","'use strict';\n\nconst path = require('path');\nconst resolveCommand = require('./util/resolveCommand');\nconst escape = require('./util/escape');\nconst readShebang = require('./util/readShebang');\n\nconst isWin = process.platform === 'win32';\nconst isExecutableRegExp = /\\.(?:com|exe)$/i;\nconst isCmdShimRegExp = /node_modules[\\\\/].bin[\\\\/][^\\\\/]+\\.cmd$/i;\n\nfunction detectShebang(parsed) {\n parsed.file = resolveCommand(parsed);\n\n const shebang = parsed.file && readShebang(parsed.file);\n\n if (shebang) {\n parsed.args.unshift(parsed.file);\n parsed.command = shebang;\n\n return resolveCommand(parsed);\n }\n\n return parsed.file;\n}\n\nfunction parseNonShell(parsed) {\n if (!isWin) {\n return parsed;\n }\n\n // Detect & add support for shebangs\n const commandFile = detectShebang(parsed);\n\n // We don't need a shell if the command filename is an executable\n const needsShell = !isExecutableRegExp.test(commandFile);\n\n // If a shell is required, use cmd.exe and take care of escaping everything correctly\n // Note that `forceShell` is an hidden option used only in tests\n if (parsed.options.forceShell || needsShell) {\n // Need to double escape meta chars if the command is a cmd-shim located in `node_modules/.bin/`\n // The cmd-shim simply calls execute the package bin file with NodeJS, proxying any argument\n // Because the escape of metachars with ^ gets interpreted when the cmd.exe is first called,\n // we need to double escape them\n const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);\n\n // Normalize posix paths into OS compatible paths (e.g.: foo/bar -> foo\\bar)\n // This is necessary otherwise it will always fail with ENOENT in those cases\n parsed.command = path.normalize(parsed.command);\n\n // Escape command & arguments\n parsed.command = escape.command(parsed.command);\n parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));\n\n const shellCommand = [parsed.command].concat(parsed.args).join(' ');\n\n parsed.args = ['/d', '/s', '/c', `\"${shellCommand}\"`];\n parsed.command = process.env.comspec || 'cmd.exe';\n parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped\n }\n\n return parsed;\n}\n\nfunction parse(command, args, options) {\n // Normalize arguments, similar to nodejs\n if (args && !Array.isArray(args)) {\n options = args;\n args = null;\n }\n\n args = args ? args.slice(0) : []; // Clone array to avoid changing the original\n options = Object.assign({}, options); // Clone object to avoid changing the original\n\n // Build our parsed object\n const parsed = {\n command,\n args,\n options,\n file: undefined,\n original: {\n command,\n args,\n },\n };\n\n // Delegate further parsing to shell or non-shell\n return options.shell ? parsed : parseNonShell(parsed);\n}\n\nmodule.exports = parse;\n","'use strict';\n\nconst isWin = process.platform === 'win32';\n\nfunction notFoundError(original, syscall) {\n return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {\n code: 'ENOENT',\n errno: 'ENOENT',\n syscall: `${syscall} ${original.command}`,\n path: original.command,\n spawnargs: original.args,\n });\n}\n\nfunction hookChildProcess(cp, parsed) {\n if (!isWin) {\n return;\n }\n\n const originalEmit = cp.emit;\n\n cp.emit = function (name, arg1) {\n // If emitting \"exit\" event and exit code is 1, we need to check if\n // the command exists and emit an \"error\" instead\n // See https://github.com/IndigoUnited/node-cross-spawn/issues/16\n if (name === 'exit') {\n const err = verifyENOENT(arg1, parsed);\n\n if (err) {\n return originalEmit.call(cp, 'error', err);\n }\n }\n\n return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params\n };\n}\n\nfunction verifyENOENT(status, parsed) {\n if (isWin && status === 1 && !parsed.file) {\n return notFoundError(parsed.original, 'spawn');\n }\n\n return null;\n}\n\nfunction verifyENOENTSync(status, parsed) {\n if (isWin && status === 1 && !parsed.file) {\n return notFoundError(parsed.original, 'spawnSync');\n }\n\n return null;\n}\n\nmodule.exports = {\n hookChildProcess,\n verifyENOENT,\n verifyENOENTSync,\n notFoundError,\n};\n","'use strict';\n\nconst cp = require('child_process');\nconst parse = require('./lib/parse');\nconst enoent = require('./lib/enoent');\n\nfunction spawn(command, args, options) {\n // Parse the arguments\n const parsed = parse(command, args, options);\n\n // Spawn the child process\n const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);\n\n // Hook into child process \"exit\" event to emit an error if the command\n // does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16\n enoent.hookChildProcess(spawned, parsed);\n\n return spawned;\n}\n\nfunction spawnSync(command, args, options) {\n // Parse the arguments\n const parsed = parse(command, args, options);\n\n // Spawn the child process\n const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);\n\n // Analyze if the command does not exist, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16\n result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);\n\n return result;\n}\n\nmodule.exports = spawn;\nmodule.exports.spawn = spawn;\nmodule.exports.sync = spawnSync;\n\nmodule.exports._parse = parse;\nmodule.exports._enoent = enoent;\n","import { createInterface } from \"node:readline/promises\";\nimport { installNativeHost, uninstallNativeHost } from \"@llmnesia/claude-code-host\";\nimport { parseArgs } from \"./args.js\";\nimport { resolveCorpusDir } from \"./config.js\";\nimport { Corpus } from \"./corpus.js\";\nimport { drainInbox, ingestFile } from \"./ingest.js\";\nimport { SearchIndex, deleteIndexDb, openSearchIndex } from \"./searchIndex.js\";\nimport type { SearchFilters } from \"./retriever.js\";\nimport { watchInbox } from \"./watch.js\";\nimport { registerClients, unregisterClients, type ClientRegistrationResult } from \"./clientRegistration.js\";\nimport { formatDoctorReport, runDoctor } from \"./doctor.js\";\nimport { installRuntime, uninstallRuntime } from \"./runtimeInstall.js\";\nimport { VERSION } from \"./version.js\";\n\nconst USAGE = `llmnesia-mcp ${VERSION}\n\nUsage: llmnesia-mcp <command> [options]\n\nSetup:\n install [ext-id...] Install the native host + register this MCP server with\n detected clients (Claude Code/Desktop, Cursor, Codex, ...)\n doctor Diagnose: host installed? corpus present? clients wired?\n uninstall Remove native host + client registrations (never deletes\n your corpus — see the printed path if you want that too)\n serve Run the MCP stdio server (what install registers with clients)\n\nPower-user / debugging:\n init Create the corpus directory skeleton\n ingest <file...> Ingest one or more NDJSON backup files into the corpus\n drain Ingest every file in <corpus>/inbox, then archive them\n watch Watch <corpus>/inbox and ingest new deltas live\n stats Print corpus counts (conversations, messages, platforms)\n reindex Drop and rebuild the search index from the corpus\n search <query> Full-text search the corpus (BM25)\n\nOptions:\n -c, --corpus <dir> Corpus root (default: $LLMNESIA_CORPUS_DIR or ~/.llmnesia/corpus)\n -n, --limit <n> search: max results (default 10)\n --platform <name> search: restrict to one platform\n --title <substr> search: title must contain this substring\n --from <iso|ms> search: only conversations created on/after this date\n --to <iso|ms> search: only conversations created on/before this date\n --force install: overwrite a differing corpus root in config.json\n --yes, -y install/uninstall: skip confirmation prompts\n --version, -v print the version and exit\n`;\n\nfunction parseDate(value: string | undefined): number | undefined {\n if (!value) {\n return undefined;\n }\n if (/^\\d+$/.test(value)) {\n return Number(value);\n }\n const ms = Date.parse(value);\n return Number.isNaN(ms) ? undefined : ms;\n}\n\n/** Real interactive y/N prompt. `--yes` bypasses this entirely (never called). */\nasync function promptConfirm(message: string): Promise<boolean> {\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n try {\n process.stdout.write(`\\n${message}\\n`);\n const answer = await rl.question(\"Proceed? [y/N] \");\n return /^y(es)?$/i.test(answer.trim());\n } finally {\n rl.close();\n }\n}\n\nfunction printRegistrationResults(results: ClientRegistrationResult[]): void {\n for (const r of results) {\n const icon = r.action === \"registered\" ? \"✓\" : r.action === \"error\" ? \"✗\" : \"•\";\n process.stdout.write(`${icon} ${r.client}: ${r.detail}\\n\\n`);\n }\n}\n\nasync function runInstall(positionals: string[], options: Record<string, string>, flags: Set<string>): Promise<number> {\n const skipConfirm = flags.has(\"yes\");\n process.stdout.write(\"Installing native messaging host…\\n\");\n try {\n await installNativeHost({ ids: positionals, corpus: options.corpus, force: flags.has(\"force\") });\n } catch (err) {\n process.stderr.write(`\\nNative host install failed: ${err instanceof Error ? err.message : String(err)}\\n`);\n process.stderr.write(\"Continuing to register MCP clients anyway — the server itself doesn't need a browser.\\n\");\n }\n\n // Must happen before registration: clients are registered with the absolute\n // path this produces, not with a bare bin name that would need to be on PATH.\n process.stdout.write(\"\\nInstalling the MCP server runtime…\\n\");\n const runtime = await installRuntime();\n process.stdout.write(`Installed to ${runtime.binDir} (running on ${runtime.nodePath})\\n`);\n\n process.stdout.write(\"\\nRegistering MCP clients…\\n\\n\");\n const confirm = skipConfirm ? async () => true : promptConfirm;\n const results = await registerClients({ serve: runtime.serve, confirm });\n printRegistrationResults(results);\n\n // The single most common \"it didn't work\": clients read their MCP config\n // once at startup, so nothing above takes effect until a full quit.\n process.stdout.write(\n \"Next step: fully quit and reopen your MCP client (and your browser, if you\\n\" +\n \"use the extension). Reloading a window is not enough — the config is read\\n\" +\n \"once at startup.\\n\\n\"\n );\n process.stdout.write(\"Then run `llmnesia-mcp doctor` to check what's wired up.\\n\");\n return 0;\n}\n\nasync function runUninstall(flags: Set<string>): Promise<number> {\n const skipConfirm = flags.has(\"yes\");\n if (!skipConfirm) {\n const ok = await promptConfirm(\n \"This removes the native-messaging host and MCP client registrations. Your corpus (conversation data) is never deleted by this command.\"\n );\n if (!ok) {\n process.stdout.write(\"Cancelled.\\n\");\n return 0;\n }\n }\n\n const hostResult = await uninstallNativeHost();\n process.stdout.write(`Removed: ${hostResult.removed.length > 0 ? hostResult.removed.join(\", \") : \"(nothing to remove)\"}\\n`);\n\n const removedRuntime = await uninstallRuntime();\n process.stdout.write(`Removed runtime: ${removedRuntime ?? \"(none installed)\"}\\n\\n`);\n\n const results = await unregisterClients();\n printRegistrationResults(results);\n\n if (hostResult.corpusRoot) {\n process.stdout.write(\n `Your corpus was NOT deleted — it's still at ${hostResult.corpusRoot}\\n` +\n `Delete it yourself if you want your data gone: rm -rf \"${hostResult.corpusRoot}\"\\n`\n );\n }\n return 0;\n}\n\nasync function main(): Promise<number> {\n const { command, positionals, options, flags } = parseArgs(process.argv.slice(2));\n\n // Checked before the command switch so `--version` works on its own and\n // alongside a subcommand, the way every other CLI behaves.\n if (flags.has(\"version\")) {\n process.stdout.write(`${VERSION}\\n`);\n return 0;\n }\n if (flags.has(\"help\")) {\n process.stdout.write(USAGE);\n return 0;\n }\n\n const root = resolveCorpusDir(options.corpus);\n const corpus = new Corpus(root);\n\n switch (command) {\n case undefined:\n case \"help\":\n process.stdout.write(USAGE);\n return 0;\n\n case \"install\":\n return runInstall(positionals, options, flags);\n\n case \"uninstall\":\n return runUninstall(flags);\n\n case \"doctor\": {\n const report = await runDoctor();\n process.stdout.write(`${formatDoctorReport(report)}\\n`);\n return report.allOk ? 0 : 1;\n }\n\n case \"serve\": {\n const { runServe } = await import(\"./mcp.js\");\n await runServe();\n return 0;\n }\n\n case \"init\": {\n await corpus.init();\n process.stdout.write(`Initialized corpus at ${root}\\n`);\n return 0;\n }\n\n case \"ingest\": {\n if (positionals.length === 0) {\n process.stderr.write(\"ingest: expected at least one file path\\n\");\n return 2;\n }\n await corpus.init();\n let created = 0;\n let updated = 0;\n let skipped = 0;\n let conversations = 0;\n let malformed = 0;\n for (const file of positionals) {\n const report = await ingestFile(corpus, file);\n created += report.created;\n updated += report.updated;\n skipped += report.skipped;\n conversations += report.conversations;\n malformed += report.malformedLines;\n }\n await corpus.touchIngestMeta();\n process.stdout.write(\n `Ingested ${conversations} conversation(s): ${created} created, ${updated} updated, ${skipped} unchanged` +\n (malformed > 0 ? `, ${malformed} malformed line(s) skipped` : \"\") +\n `\\n`\n );\n return 0;\n }\n\n case \"drain\": {\n const index = await openSearchIndex(corpus);\n try {\n const report = await drainInbox(corpus, index, {\n onFileError: (name, error) =>\n process.stderr.write(` ! ${name}: ${error instanceof Error ? error.message : String(error)}\\n`)\n });\n process.stdout.write(\n `Drained ${report.files} inbox file(s): ${report.conversations} conversation(s) — ` +\n `${report.created} created, ${report.updated} updated, ${report.skipped} unchanged` +\n (report.failed > 0 ? `, ${report.failed} file(s) failed` : \"\") +\n `\\n`\n );\n } finally {\n index.close();\n }\n return 0;\n }\n\n case \"watch\": {\n process.stdout.write(`Watching ${corpus.paths.inboxDir} for new deltas (Ctrl+C to stop)…\\n`);\n const handle = await watchInbox(corpus, (s) => {\n process.stdout.write(\n `Ingested ${s.files} file(s): ${s.created} created, ${s.updated} updated, ${s.skipped} unchanged\\n`\n );\n });\n await new Promise<void>((resolve) => {\n const stop = () => {\n void handle.close().then(resolve);\n };\n process.once(\"SIGINT\", stop);\n process.once(\"SIGTERM\", stop);\n });\n return 0;\n }\n\n case \"stats\": {\n const stats = await corpus.stats();\n const platforms = Object.entries(stats.byPlatform)\n .sort((a, b) => b[1] - a[1])\n .map(([p, n]) => ` ${p}: ${n}`)\n .join(\"\\n\");\n process.stdout.write(\n `Corpus: ${root}\\n` +\n ` conversations: ${stats.conversationCount}\\n` +\n ` messages: ${stats.messageCount}\\n` +\n (platforms ? ` by platform:\\n${platforms}\\n` : \"\")\n );\n return 0;\n }\n\n case \"reindex\": {\n await corpus.init();\n await deleteIndexDb(corpus.paths.indexDbFile);\n const index = new SearchIndex(corpus.paths.indexDbFile);\n try {\n const { conversations } = await index.rebuildFrom(corpus);\n process.stdout.write(`Rebuilt index: ${conversations} conversation(s)\\n`);\n } finally {\n index.close();\n }\n return 0;\n }\n\n case \"search\": {\n const query = positionals.join(\" \").trim();\n if (!query) {\n process.stderr.write(\"search: expected a query\\n\");\n return 2;\n }\n const filters: SearchFilters = {\n platform: options.platform || undefined,\n title: options.title || undefined,\n dateFrom: parseDate(options.from),\n dateTo: parseDate(options.to),\n limit: options.limit ? Number(options.limit) : undefined\n };\n const index = await openSearchIndex(corpus);\n try {\n const hits = index.search(query, filters);\n if (hits.length === 0) {\n process.stdout.write(\"No matches.\\n\");\n return 0;\n }\n for (const hit of hits) {\n const when = new Date(hit.createdAt).toISOString().slice(0, 10);\n const where = hit.matchRole === \"title\" ? \"title\" : `${hit.matchRole} #${hit.matchMsgIndex}`;\n process.stdout.write(\n `${hit.pinned ? \"★ \" : \"\"}${hit.title} [${hit.platform} · ${when} · score ${hit.score.toFixed(2)}]\\n` +\n ` ${hit.docId}\\n` +\n ` ${collapse(hit.snippet)} (${where})\\n\\n`\n );\n }\n } finally {\n index.close();\n }\n return 0;\n }\n\n default:\n process.stderr.write(`Unknown command: ${command}\\n\\n${USAGE}`);\n return 2;\n }\n}\n\nfunction collapse(text: string): string {\n return text.replace(/\\s+/g, \" \").trim();\n}\n\nmain()\n .then((code) => {\n process.exitCode = code;\n })\n .catch((err) => {\n process.stderr.write(`Error: ${err instanceof Error ? err.message : String(err)}\\n`);\n process.exitCode = 1;\n });\n","#!/usr/bin/env node\n// Installs the LLMnesia native messaging host so the browser extension can read\n// local Claude Code sessions automatically (no folder picking) and sync its\n// conversation corpus for the MCP companion (no File System Access picker).\n//\n// Usage: node install.mjs [<extension-id> ...] [--corpus <dir>] [--force]\n//\n// With no extension id it authorises the published Chrome Web Store build\n// (STORE_EXTENSION_ID below). Pass ids only to ALSO allow dev/unpacked builds,\n// whose ids are random per machine.\n//\n// It (1) copies the host script to ~/.llmnesia/, and (2) registers a\n// com.llmnesia.claude_code native-messaging host — locked to the given extension\n// id(s) — for every Chromium browser found, and (3) writes ~/.llmnesia/config.json\n// naming the corpus root the host is allowed to write into. The host reads that\n// root from its own config and never from anything the browser sends, so this\n// file is what gives the write path a fixed, host-owned destination.\n// • macOS / Linux: native messaging launches the script directly, so we pin its\n// shebang to THIS node (nvm/volta node isn't on the bare PATH hosts get) and\n// drop a JSON manifest into each browser's NativeMessagingHosts folder.\n// • Windows: native messaging can't launch a .mjs directly and finds hosts via\n// the registry, so we write a .bat launcher (invokes node with the script)\n// and point an HKCU registry key at the manifest.\n//\n// The core logic below is exported as `installNativeHost()` so other packages\n// (the @llmnesia/mcp installer) can call it in-process instead of shelling out\n// to this script. Everything exported is a plain function with no dependency on\n// process.argv — argv parsing lives only in this file's own CLI `main()`, which\n// only runs when the file is executed directly (not when imported as a module).\n\nimport { execFile } from \"node:child_process\";\nimport { chmod, mkdir, readFile, rm, stat, writeFile } from \"node:fs/promises\";\nimport { homedir, platform } from \"node:os\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { promisify } from \"node:util\";\n\nconst execFileAsync = promisify(execFile);\nexport const HOST_NAME = \"com.llmnesia.claude_code\";\n// The published Chrome Web Store build's permanent id. It is derived from the\n// item's public key and never changes across versions, so baking it in lets a\n// normal install run with no arguments. (Source: the store reviews URL in\n// extension/src/shared/review_prompt.ts.)\nexport const STORE_EXTENSION_ID = \"leekfgbdojiaabifbjbbgiiclannjdkf\";\nconst here = dirname(fileURLToPath(import.meta.url));\nconst home = homedir();\n// Test seam: LLMNESIA_FAKE_PLATFORM lets the suite exercise the Windows install\n// path (registry + .bat) from a non-Windows host. Unset in normal use.\nconst osPlatform = process.env.LLMNESIA_FAKE_PLATFORM || platform();\n\n// Same resolution order as companion/src/config.ts: explicit --corpus > the\n// LLMNESIA_CORPUS_DIR env > the documented default. Both the host's write path\n// and the companion's read path must resolve to the same directory.\nexport function expandHome(p) {\n if (p === \"~\") {\n return home;\n }\n if (p.startsWith(\"~/\") || p.startsWith(\"~\\\\\")) {\n return resolve(home, p.slice(2));\n }\n return resolve(p);\n}\nexport function resolveCorpusDir(explicit) {\n const raw = explicit ?? process.env.LLMNESIA_CORPUS_DIR ?? \"~/.llmnesia/corpus\";\n return expandHome(raw);\n}\n\nasync function exists(path) {\n try {\n await stat(path);\n return true;\n } catch {\n return false;\n }\n}\n\n// --- macOS / Linux: a JSON manifest in each browser's profile -------------\n\n/**\n * Browser profile roots to install into. `homeDir`/`forPlatform` default to\n * this machine's real values; callers pass them explicitly to inspect a\n * different home or OS (the doctor command does, so its --home is honest\n * rather than silently reporting on the real one).\n */\nexport function posixBrowsers(homeDir = home, forPlatform = osPlatform) {\n if (forPlatform === \"darwin\") {\n const base = join(homeDir, \"Library\", \"Application Support\");\n return [\n [\"Brave\", join(base, \"BraveSoftware\", \"Brave-Browser\")],\n [\"Chrome\", join(base, \"Google\", \"Chrome\")],\n [\"Edge\", join(base, \"Microsoft Edge\")],\n [\"Chromium\", join(base, \"Chromium\")]\n ];\n }\n // Linux\n const base = join(homeDir, \".config\");\n return [\n [\"Brave\", join(base, \"BraveSoftware\", \"Brave-Browser\")],\n [\"Chrome\", join(base, \"google-chrome\")],\n [\"Edge\", join(base, \"microsoft-edge\")],\n [\"Chromium\", join(base, \"chromium\")]\n ];\n}\n\nasync function installPosix(manifestBase, hostPath) {\n const manifest = { ...manifestBase, path: hostPath };\n let installed = 0;\n for (const [label, browserDir] of posixBrowsers()) {\n if (!(await exists(browserDir))) {\n continue;\n }\n const dir = join(browserDir, \"NativeMessagingHosts\");\n await mkdir(dir, { recursive: true });\n await writeFile(join(dir, `${HOST_NAME}.json`), `${JSON.stringify(manifest, null, 2)}\\n`, \"utf8\");\n console.log(`Manifest → ${label}: ${join(dir, `${HOST_NAME}.json`)}`);\n installed += 1;\n }\n return installed;\n}\n\n// --- Windows: an HKCU registry key + a .bat launcher ----------------------\n\nexport function windowsBrowsers() {\n const localAppData = process.env.LOCALAPPDATA || join(home, \"AppData\", \"Local\");\n // [label, \"User Data\" dir (presence check), registry vendor path under HKCU]\n return [\n [\"Brave\", join(localAppData, \"BraveSoftware\", \"Brave-Browser\", \"User Data\"), \"Software\\\\BraveSoftware\\\\Brave-Browser\"],\n [\"Chrome\", join(localAppData, \"Google\", \"Chrome\", \"User Data\"), \"Software\\\\Google\\\\Chrome\"],\n [\"Edge\", join(localAppData, \"Microsoft\", \"Edge\", \"User Data\"), \"Software\\\\Microsoft\\\\Edge\"],\n [\"Chromium\", join(localAppData, \"Chromium\", \"User Data\"), \"Software\\\\Chromium\"]\n ];\n}\n\nasync function installWindows(manifestBase, hostPath, installDir) {\n // Chrome launches native hosts hidden (no console flash), but it can't run a\n // .mjs, so point the manifest at a .bat that invokes THIS node with the script.\n const batPath = join(installDir, \"llmnesia-claude-host.bat\");\n await writeFile(batPath, `@echo off\\r\\n\"${process.execPath}\" \"${hostPath}\" %*\\r\\n`, \"utf8\");\n console.log(`Launcher → ${batPath}`);\n\n // The manifest lives in ~/.llmnesia; browsers find it via a registry key whose\n // default value is this manifest's full path.\n const manifest = { ...manifestBase, path: batPath };\n const manifestPath = join(installDir, `${HOST_NAME}.json`);\n await writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\\n`, \"utf8\");\n console.log(`Manifest → ${manifestPath}`);\n\n let installed = 0;\n for (const [label, userDataDir, vendorKey] of windowsBrowsers()) {\n if (!(await exists(userDataDir))) {\n continue;\n }\n const key = `HKCU\\\\${vendorKey}\\\\NativeMessagingHosts\\\\${HOST_NAME}`;\n // /ve sets the key's (default) value; Chrome reads that as the manifest path.\n // Use reg.exe's absolute path: without a shell, a bare \"reg\" isn't reliably\n // resolved via PATHEXT, and System32 is redirected to SysWOW64 for a 32-bit\n // node — reg.exe exists in both, and HKCU\\Software isn't WOW64-split.\n const regExe = join(process.env.SystemRoot || \"C:\\\\Windows\", \"System32\", \"reg.exe\");\n await execFileAsync(regExe, [\"add\", key, \"/ve\", \"/t\", \"REG_SZ\", \"/d\", manifestPath, \"/f\"]);\n console.log(`Registry → ${label}: ${key}`);\n installed += 1;\n }\n return installed;\n}\n\n/**\n * Install (or update) the native-messaging host and its corpus config. Pure\n * function of its arguments — no process.argv/process.exit — so it can be\n * called both from this file's own CLI `main()` and imported by\n * `@llmnesia/mcp`'s `install` subcommand.\n *\n * @param {{ ids?: string[], corpus?: string, force?: boolean }} options\n * `ids` are EXTRA dev/unpacked extension ids to allow, on top of the\n * published Web Store build (always allowed). `corpus` overrides the\n * resolved corpus directory. `force` allows overwriting an existing,\n * different corpusRoot in config.json.\n * @returns {Promise<{ installedCount: number, allowedIds: string[], configPath: string, corpusRoot: string, corpusRootChanged: boolean }>}\n * @throws if no supported browser was found on this machine.\n */\nexport async function installNativeHost({ ids = [], corpus, force = false } = {}) {\n const isWindows = osPlatform === \"win32\";\n // The Web Store build is always allowed; any ids passed in are dev/unpacked\n // builds allowed on top of it (deduped), so a call with no ids works for\n // normal store users.\n const allIds = [...new Set([STORE_EXTENSION_ID, ...ids])];\n const allowedOrigins = allIds.map((id) => `chrome-extension://${id}/`);\n\n // 1. Install the host script into ~/.llmnesia.\n const installDir = join(home, \".llmnesia\");\n await mkdir(installDir, { recursive: true });\n const hostSource = await readFile(join(here, \"llmnesia-claude-host.mjs\"), \"utf8\");\n // POSIX launches the script directly, so pin its shebang to THIS node. On\n // Windows the .bat wrapper invokes node explicitly, so the shebang is unused.\n const hosted = isWindows ? hostSource : hostSource.replace(/^#![^\\n]*\\n/, `#!${process.execPath}\\n`);\n const hostPath = join(installDir, \"llmnesia-claude-host.mjs\");\n await writeFile(hostPath, hosted, \"utf8\");\n if (!isWindows) {\n await chmod(hostPath, 0o755);\n }\n console.log(`Host script → ${hostPath}`);\n\n const manifestBase = {\n name: HOST_NAME,\n description: \"LLMnesia — reads local Claude Code sessions\",\n type: \"stdio\",\n allowed_origins: allowedOrigins\n };\n\n // 2. Register the host for each installed browser.\n const installedCount = isWindows\n ? await installWindows(manifestBase, hostPath, installDir)\n : await installPosix(manifestBase, hostPath);\n\n if (installedCount === 0) {\n throw new Error(\"No Chromium-based browsers found — nothing to install.\");\n }\n\n // 3. Write the corpus config the host writes into (host-owned write root).\n const configPath = join(installDir, \"config.json\");\n const corpusRoot = resolveCorpusDir(corpus);\n let existing = null;\n try {\n existing = JSON.parse(await readFile(configPath, \"utf8\"));\n } catch {\n // No config yet, or unreadable/invalid — treat as absent and write fresh.\n }\n const existingRoot = existing && typeof existing.corpusRoot === \"string\" ? existing.corpusRoot : null;\n let corpusRootChanged = true;\n if (existingRoot && existingRoot !== corpusRoot && !force) {\n // Re-running the installer must not silently move a corpus that already has\n // history in it. Keep the existing one; require --force to change it.\n corpusRootChanged = false;\n console.log(`Corpus config kept → ${configPath}`);\n console.log(` already points at: ${existingRoot}`);\n console.log(` to change it: re-run with --corpus <dir> --force`);\n } else {\n await writeFile(configPath, `${JSON.stringify({ corpusRoot }, null, 2)}\\n`, { encoding: \"utf8\", mode: 0o600 });\n await chmod(configPath, 0o600);\n console.log(`Corpus config → ${configPath}`);\n console.log(` corpus root: ${corpusRoot}`);\n }\n\n console.log(`\\nDone. Allowed extension id(s): ${allIds.join(\", \")}`);\n console.log(\"Fully quit and reopen the browser, then open LLMnesia Settings.\");\n\n return {\n installedCount,\n allowedIds: allIds,\n configPath,\n corpusRoot: existingRoot && !corpusRootChanged ? existingRoot : corpusRoot,\n corpusRootChanged\n };\n}\n\n/**\n * Remove the native-messaging manifests/registry keys and the host script\n * this installer wrote. Deliberately does NOT touch ~/.llmnesia/config.json\n * or the corpus directory it points at — uninstalling the plumbing must never\n * delete the user's actual conversation data as a side effect. Returns what\n * was removed; never throws for something already absent.\n *\n * @returns {Promise<{ removed: string[], corpusRoot: string | null }>}\n */\nexport async function uninstallNativeHost() {\n const isWindows = osPlatform === \"win32\";\n const removed = [];\n const installDir = join(home, \".llmnesia\");\n\n if (isWindows) {\n const manifestPath = join(installDir, `${HOST_NAME}.json`);\n const batPath = join(installDir, \"llmnesia-claude-host.bat\");\n for (const [label, userDataDir, vendorKey] of windowsBrowsers()) {\n if (!(await exists(userDataDir))) {\n continue;\n }\n const key = `HKCU\\\\${vendorKey}\\\\NativeMessagingHosts\\\\${HOST_NAME}`;\n const regExe = join(process.env.SystemRoot || \"C:\\\\Windows\", \"System32\", \"reg.exe\");\n try {\n await execFileAsync(regExe, [\"delete\", key, \"/f\"]);\n removed.push(`registry:${label}`);\n } catch {\n // Key may already be gone — not an error for uninstall.\n }\n }\n await rm(manifestPath, { force: true });\n await rm(batPath, { force: true });\n removed.push(\"manifest\", \"launcher\");\n } else {\n for (const [label, browserDir] of posixBrowsers()) {\n if (!(await exists(browserDir))) {\n continue;\n }\n const manifestPath = join(browserDir, \"NativeMessagingHosts\", `${HOST_NAME}.json`);\n if (await exists(manifestPath)) {\n await rm(manifestPath, { force: true });\n removed.push(`manifest:${label}`);\n }\n }\n }\n\n const hostScriptPath = join(installDir, \"llmnesia-claude-host.mjs\");\n if (await exists(hostScriptPath)) {\n await rm(hostScriptPath, { force: true });\n removed.push(\"host-script\");\n }\n\n const corpusRoot = resolveCorpusDir();\n return { removed, corpusRoot };\n}\n\n// This file is a pure module: importing it must have no side effects. The CLI\n// lives in ./cli.mjs.\n//\n// It used to end with an `import.meta.url === file://${process.argv[1]}`\n// self-execution guard. That guard is not bundler-safe: once this file is\n// inlined into another bundle, import.meta.url becomes the *bundle's* URL, so\n// the guard reads as true and the installer CLI runs on every invocation of\n// the host program — parsing that program's own argv as extension ids and\n// writing them into allowed_origins. Splitting the entry point out removes the\n// failure mode rather than trying to detect it.\n","export type ParsedArgs = {\n command: string | undefined;\n positionals: string[];\n options: Record<string, string>;\n flags: Set<string>;\n};\n\nconst OPTION_ALIASES: Record<string, string> = {\n c: \"corpus\",\n n: \"limit\",\n v: \"version\",\n h: \"help\",\n y: \"yes\"\n};\n\n// Boolean flags never consume the following token as a value.\nconst BOOLEAN_FLAGS = new Set([\"force\", \"yes\", \"version\", \"help\"]);\n\nexport function parseArgs(argv: string[]): ParsedArgs {\n const positionals: string[] = [];\n const options: Record<string, string> = {};\n const flags = new Set<string>();\n for (let i = 0; i < argv.length; i += 1) {\n const arg = argv[i];\n if (arg.startsWith(\"--\") && arg.includes(\"=\")) {\n const eq = arg.indexOf(\"=\");\n options[arg.slice(2, eq)] = arg.slice(eq + 1);\n } else if (arg.startsWith(\"--\")) {\n const key = arg.slice(2);\n if (BOOLEAN_FLAGS.has(key)) {\n flags.add(key);\n } else {\n options[key] = argv[++i] ?? \"\";\n }\n } else if (arg.startsWith(\"-\") && arg.length === 2) {\n const key = OPTION_ALIASES[arg.slice(1)] ?? arg.slice(1);\n if (BOOLEAN_FLAGS.has(key)) {\n flags.add(key);\n } else {\n options[key] = argv[++i] ?? \"\";\n }\n } else {\n positionals.push(arg);\n }\n }\n return { command: positionals[0], positionals: positionals.slice(1), options, flags };\n}\n","/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */\nimport { stat as statcb } from 'fs';\nimport { stat, readdir } from 'fs/promises';\nimport { EventEmitter } from 'events';\nimport * as sysPath from 'path';\nimport { readdirp } from 'readdirp';\nimport { NodeFsHandler, EVENTS as EV, isWindows, isIBMi, EMPTY_FN, STR_CLOSE, STR_END, } from './handler.js';\nconst SLASH = '/';\nconst SLASH_SLASH = '//';\nconst ONE_DOT = '.';\nconst TWO_DOTS = '..';\nconst STRING_TYPE = 'string';\nconst BACK_SLASH_RE = /\\\\/g;\nconst DOUBLE_SLASH_RE = /\\/\\//;\nconst DOT_RE = /\\..*\\.(sw[px])$|~$|\\.subl.*\\.tmp/;\nconst REPLACER_RE = /^\\.[/\\\\]/;\nfunction arrify(item) {\n return Array.isArray(item) ? item : [item];\n}\nconst isMatcherObject = (matcher) => typeof matcher === 'object' && matcher !== null && !(matcher instanceof RegExp);\nfunction createPattern(matcher) {\n if (typeof matcher === 'function')\n return matcher;\n if (typeof matcher === 'string')\n return (string) => matcher === string;\n if (matcher instanceof RegExp)\n return (string) => matcher.test(string);\n if (typeof matcher === 'object' && matcher !== null) {\n return (string) => {\n if (matcher.path === string)\n return true;\n if (matcher.recursive) {\n const relative = sysPath.relative(matcher.path, string);\n if (!relative) {\n return false;\n }\n return !relative.startsWith('..') && !sysPath.isAbsolute(relative);\n }\n return false;\n };\n }\n return () => false;\n}\nfunction normalizePath(path) {\n if (typeof path !== 'string')\n throw new Error('string expected');\n path = sysPath.normalize(path);\n path = path.replace(/\\\\/g, '/');\n let prepend = false;\n if (path.startsWith('//'))\n prepend = true;\n const DOUBLE_SLASH_RE = /\\/\\//;\n while (path.match(DOUBLE_SLASH_RE))\n path = path.replace(DOUBLE_SLASH_RE, '/');\n if (prepend)\n path = '/' + path;\n return path;\n}\nfunction matchPatterns(patterns, testString, stats) {\n const path = normalizePath(testString);\n for (let index = 0; index < patterns.length; index++) {\n const pattern = patterns[index];\n if (pattern(path, stats)) {\n return true;\n }\n }\n return false;\n}\nfunction anymatch(matchers, testString) {\n if (matchers == null) {\n throw new TypeError('anymatch: specify first argument');\n }\n // Early cache for matchers.\n const matchersArray = arrify(matchers);\n const patterns = matchersArray.map((matcher) => createPattern(matcher));\n if (testString == null) {\n return (testString, stats) => {\n return matchPatterns(patterns, testString, stats);\n };\n }\n return matchPatterns(patterns, testString);\n}\nconst unifyPaths = (paths_) => {\n const paths = arrify(paths_).flat();\n if (!paths.every((p) => typeof p === STRING_TYPE)) {\n throw new TypeError(`Non-string provided as watch path: ${paths}`);\n }\n return paths.map(normalizePathToUnix);\n};\n// If SLASH_SLASH occurs at the beginning of path, it is not replaced\n// because \"//StoragePC/DrivePool/Movies\" is a valid network path\nconst toUnix = (string) => {\n let str = string.replace(BACK_SLASH_RE, SLASH);\n let prepend = false;\n if (str.startsWith(SLASH_SLASH)) {\n prepend = true;\n }\n while (str.match(DOUBLE_SLASH_RE)) {\n str = str.replace(DOUBLE_SLASH_RE, SLASH);\n }\n if (prepend) {\n str = SLASH + str;\n }\n return str;\n};\n// Our version of upath.normalize\n// TODO: this is not equal to path-normalize module - investigate why\nconst normalizePathToUnix = (path) => toUnix(sysPath.normalize(toUnix(path)));\n// TODO: refactor\nconst normalizeIgnored = (cwd = '') => (path) => {\n if (typeof path === 'string') {\n return normalizePathToUnix(sysPath.isAbsolute(path) ? path : sysPath.join(cwd, path));\n }\n else {\n return path;\n }\n};\nconst getAbsolutePath = (path, cwd) => {\n if (sysPath.isAbsolute(path)) {\n return path;\n }\n return sysPath.join(cwd, path);\n};\nconst EMPTY_SET = Object.freeze(new Set());\n/**\n * Directory entry.\n */\nclass DirEntry {\n constructor(dir, removeWatcher) {\n this.path = dir;\n this._removeWatcher = removeWatcher;\n this.items = new Set();\n }\n add(item) {\n const { items } = this;\n if (!items)\n return;\n if (item !== ONE_DOT && item !== TWO_DOTS)\n items.add(item);\n }\n async remove(item) {\n const { items } = this;\n if (!items)\n return;\n items.delete(item);\n if (items.size > 0)\n return;\n const dir = this.path;\n try {\n await readdir(dir);\n }\n catch (err) {\n if (this._removeWatcher) {\n this._removeWatcher(sysPath.dirname(dir), sysPath.basename(dir));\n }\n }\n }\n has(item) {\n const { items } = this;\n if (!items)\n return;\n return items.has(item);\n }\n getChildren() {\n const { items } = this;\n if (!items)\n return [];\n return [...items.values()];\n }\n dispose() {\n this.items.clear();\n this.path = '';\n this._removeWatcher = EMPTY_FN;\n this.items = EMPTY_SET;\n Object.freeze(this);\n }\n}\nconst STAT_METHOD_F = 'stat';\nconst STAT_METHOD_L = 'lstat';\nexport class WatchHelper {\n constructor(path, follow, fsw) {\n this.fsw = fsw;\n const watchPath = path;\n this.path = path = path.replace(REPLACER_RE, '');\n this.watchPath = watchPath;\n this.fullWatchPath = sysPath.resolve(watchPath);\n this.dirParts = [];\n this.dirParts.forEach((parts) => {\n if (parts.length > 1)\n parts.pop();\n });\n this.followSymlinks = follow;\n this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;\n }\n entryPath(entry) {\n return sysPath.join(this.watchPath, sysPath.relative(this.watchPath, entry.fullPath));\n }\n filterPath(entry) {\n const { stats } = entry;\n if (stats && stats.isSymbolicLink())\n return this.filterDir(entry);\n const resolvedPath = this.entryPath(entry);\n // TODO: what if stats is undefined? remove !\n return this.fsw._isntIgnored(resolvedPath, stats) && this.fsw._hasReadPermissions(stats);\n }\n filterDir(entry) {\n return this.fsw._isntIgnored(this.entryPath(entry), entry.stats);\n }\n}\n/**\n * Watches files & directories for changes. Emitted events:\n * `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `all`, `error`\n *\n * new FSWatcher()\n * .add(directories)\n * .on('add', path => log('File', path, 'was added'))\n */\nexport class FSWatcher extends EventEmitter {\n // Not indenting methods for history sake; for now.\n constructor(_opts = {}) {\n super();\n this.closed = false;\n this._closers = new Map();\n this._ignoredPaths = new Set();\n this._throttled = new Map();\n this._streams = new Set();\n this._symlinkPaths = new Map();\n this._watched = new Map();\n this._pendingWrites = new Map();\n this._pendingUnlinks = new Map();\n this._readyCount = 0;\n this._readyEmitted = false;\n const awf = _opts.awaitWriteFinish;\n const DEF_AWF = { stabilityThreshold: 2000, pollInterval: 100 };\n const opts = {\n // Defaults\n persistent: true,\n ignoreInitial: false,\n ignorePermissionErrors: false,\n interval: 100,\n binaryInterval: 300,\n followSymlinks: true,\n usePolling: false,\n // useAsync: false,\n atomic: true, // NOTE: overwritten later (depends on usePolling)\n ..._opts,\n // Change format\n ignored: _opts.ignored ? arrify(_opts.ignored) : arrify([]),\n awaitWriteFinish: awf === true ? DEF_AWF : typeof awf === 'object' ? { ...DEF_AWF, ...awf } : false,\n };\n // Always default to polling on IBM i because fs.watch() is not available on IBM i.\n if (isIBMi)\n opts.usePolling = true;\n // Editor atomic write normalization enabled by default with fs.watch\n if (opts.atomic === undefined)\n opts.atomic = !opts.usePolling;\n // opts.atomic = typeof _opts.atomic === 'number' ? _opts.atomic : 100;\n // Global override. Useful for developers, who need to force polling for all\n // instances of chokidar, regardless of usage / dependency depth\n const envPoll = process.env.CHOKIDAR_USEPOLLING;\n if (envPoll !== undefined) {\n const envLower = envPoll.toLowerCase();\n if (envLower === 'false' || envLower === '0')\n opts.usePolling = false;\n else if (envLower === 'true' || envLower === '1')\n opts.usePolling = true;\n else\n opts.usePolling = !!envLower;\n }\n const envInterval = process.env.CHOKIDAR_INTERVAL;\n if (envInterval)\n opts.interval = Number.parseInt(envInterval, 10);\n // This is done to emit ready only once, but each 'add' will increase that?\n let readyCalls = 0;\n this._emitReady = () => {\n readyCalls++;\n if (readyCalls >= this._readyCount) {\n this._emitReady = EMPTY_FN;\n this._readyEmitted = true;\n // use process.nextTick to allow time for listener to be bound\n process.nextTick(() => this.emit(EV.READY));\n }\n };\n this._emitRaw = (...args) => this.emit(EV.RAW, ...args);\n this._boundRemove = this._remove.bind(this);\n this.options = opts;\n this._nodeFsHandler = new NodeFsHandler(this);\n // You’re frozen when your heart’s not open.\n Object.freeze(opts);\n }\n _addIgnoredPath(matcher) {\n if (isMatcherObject(matcher)) {\n // return early if we already have a deeply equal matcher object\n for (const ignored of this._ignoredPaths) {\n if (isMatcherObject(ignored) &&\n ignored.path === matcher.path &&\n ignored.recursive === matcher.recursive) {\n return;\n }\n }\n }\n this._ignoredPaths.add(matcher);\n }\n _removeIgnoredPath(matcher) {\n this._ignoredPaths.delete(matcher);\n // now find any matcher objects with the matcher as path\n if (typeof matcher === 'string') {\n for (const ignored of this._ignoredPaths) {\n // TODO (43081j): make this more efficient.\n // probably just make a `this._ignoredDirectories` or some\n // such thing.\n if (isMatcherObject(ignored) && ignored.path === matcher) {\n this._ignoredPaths.delete(ignored);\n }\n }\n }\n }\n // Public methods\n /**\n * Adds paths to be watched on an existing FSWatcher instance.\n * @param paths_ file or file list. Other arguments are unused\n */\n add(paths_, _origAdd, _internal) {\n const { cwd } = this.options;\n this.closed = false;\n this._closePromise = undefined;\n let paths = unifyPaths(paths_);\n if (cwd) {\n paths = paths.map((path) => {\n const absPath = getAbsolutePath(path, cwd);\n // Check `path` instead of `absPath` because the cwd portion can't be a glob\n return absPath;\n });\n }\n paths.forEach((path) => {\n this._removeIgnoredPath(path);\n });\n this._userIgnored = undefined;\n if (!this._readyCount)\n this._readyCount = 0;\n this._readyCount += paths.length;\n Promise.all(paths.map(async (path) => {\n const res = await this._nodeFsHandler._addToNodeFs(path, !_internal, undefined, 0, _origAdd);\n if (res)\n this._emitReady();\n return res;\n })).then((results) => {\n if (this.closed)\n return;\n results.forEach((item) => {\n if (item)\n this.add(sysPath.dirname(item), sysPath.basename(_origAdd || item));\n });\n });\n return this;\n }\n /**\n * Close watchers or start ignoring events from specified paths.\n */\n unwatch(paths_) {\n if (this.closed)\n return this;\n const paths = unifyPaths(paths_);\n const { cwd } = this.options;\n paths.forEach((path) => {\n // convert to absolute path unless relative path already matches\n if (!sysPath.isAbsolute(path) && !this._closers.has(path)) {\n if (cwd)\n path = sysPath.join(cwd, path);\n path = sysPath.resolve(path);\n }\n this._closePath(path);\n this._addIgnoredPath(path);\n if (this._watched.has(path)) {\n this._addIgnoredPath({\n path,\n recursive: true,\n });\n }\n // reset the cached userIgnored anymatch fn\n // to make ignoredPaths changes effective\n this._userIgnored = undefined;\n });\n return this;\n }\n /**\n * Close watchers and remove all listeners from watched paths.\n */\n close() {\n if (this._closePromise) {\n return this._closePromise;\n }\n this.closed = true;\n // Memory management.\n this.removeAllListeners();\n const closers = [];\n this._closers.forEach((closerList) => closerList.forEach((closer) => {\n const promise = closer();\n if (promise instanceof Promise)\n closers.push(promise);\n }));\n this._streams.forEach((stream) => stream.destroy());\n this._userIgnored = undefined;\n this._readyCount = 0;\n this._readyEmitted = false;\n this._watched.forEach((dirent) => dirent.dispose());\n this._closers.clear();\n this._watched.clear();\n this._streams.clear();\n this._symlinkPaths.clear();\n this._throttled.clear();\n this._closePromise = closers.length\n ? Promise.all(closers).then(() => undefined)\n : Promise.resolve();\n return this._closePromise;\n }\n /**\n * Expose list of watched paths\n * @returns for chaining\n */\n getWatched() {\n const watchList = {};\n this._watched.forEach((entry, dir) => {\n const key = this.options.cwd ? sysPath.relative(this.options.cwd, dir) : dir;\n const index = key || ONE_DOT;\n watchList[index] = entry.getChildren().sort();\n });\n return watchList;\n }\n emitWithAll(event, args) {\n this.emit(event, ...args);\n if (event !== EV.ERROR)\n this.emit(EV.ALL, event, ...args);\n }\n // Common helpers\n // --------------\n /**\n * Normalize and emit events.\n * Calling _emit DOES NOT MEAN emit() would be called!\n * @param event Type of event\n * @param path File or directory path\n * @param stats arguments to be passed with event\n * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag\n */\n async _emit(event, path, stats) {\n if (this.closed)\n return;\n const opts = this.options;\n if (isWindows)\n path = sysPath.normalize(path);\n if (opts.cwd)\n path = sysPath.relative(opts.cwd, path);\n const args = [path];\n if (stats != null)\n args.push(stats);\n const awf = opts.awaitWriteFinish;\n let pw;\n if (awf && (pw = this._pendingWrites.get(path))) {\n pw.lastChange = new Date();\n return this;\n }\n if (opts.atomic) {\n if (event === EV.UNLINK) {\n this._pendingUnlinks.set(path, [event, ...args]);\n setTimeout(() => {\n this._pendingUnlinks.forEach((entry, path) => {\n this.emit(...entry);\n this.emit(EV.ALL, ...entry);\n this._pendingUnlinks.delete(path);\n });\n }, typeof opts.atomic === 'number' ? opts.atomic : 100);\n return this;\n }\n if (event === EV.ADD && this._pendingUnlinks.has(path)) {\n event = EV.CHANGE;\n this._pendingUnlinks.delete(path);\n }\n }\n if (awf && (event === EV.ADD || event === EV.CHANGE) && this._readyEmitted) {\n const awfEmit = (err, stats) => {\n if (err) {\n event = EV.ERROR;\n args[0] = err;\n this.emitWithAll(event, args);\n }\n else if (stats) {\n // if stats doesn't exist the file must have been deleted\n if (args.length > 1) {\n args[1] = stats;\n }\n else {\n args.push(stats);\n }\n this.emitWithAll(event, args);\n }\n };\n this._awaitWriteFinish(path, awf.stabilityThreshold, event, awfEmit);\n return this;\n }\n if (event === EV.CHANGE) {\n const isThrottled = !this._throttle(EV.CHANGE, path, 50);\n if (isThrottled)\n return this;\n }\n if (opts.alwaysStat &&\n stats === undefined &&\n (event === EV.ADD || event === EV.ADD_DIR || event === EV.CHANGE)) {\n const fullPath = opts.cwd ? sysPath.join(opts.cwd, path) : path;\n let stats;\n try {\n stats = await stat(fullPath);\n }\n catch (err) {\n // do nothing\n }\n // Suppress event when fs_stat fails, to avoid sending undefined 'stat'\n if (!stats || this.closed)\n return;\n args.push(stats);\n }\n this.emitWithAll(event, args);\n return this;\n }\n /**\n * Common handler for errors\n * @returns The error if defined, otherwise the value of the FSWatcher instance's `closed` flag\n */\n _handleError(error) {\n const code = error && error.code;\n if (error &&\n code !== 'ENOENT' &&\n code !== 'ENOTDIR' &&\n (!this.options.ignorePermissionErrors || (code !== 'EPERM' && code !== 'EACCES'))) {\n this.emit(EV.ERROR, error);\n }\n return error || this.closed;\n }\n /**\n * Helper utility for throttling\n * @param actionType type being throttled\n * @param path being acted upon\n * @param timeout duration of time to suppress duplicate actions\n * @returns tracking object or false if action should be suppressed\n */\n _throttle(actionType, path, timeout) {\n if (!this._throttled.has(actionType)) {\n this._throttled.set(actionType, new Map());\n }\n const action = this._throttled.get(actionType);\n if (!action)\n throw new Error('invalid throttle');\n const actionPath = action.get(path);\n if (actionPath) {\n actionPath.count++;\n return false;\n }\n // eslint-disable-next-line prefer-const\n let timeoutObject;\n const clear = () => {\n const item = action.get(path);\n const count = item ? item.count : 0;\n action.delete(path);\n clearTimeout(timeoutObject);\n if (item)\n clearTimeout(item.timeoutObject);\n return count;\n };\n timeoutObject = setTimeout(clear, timeout);\n const thr = { timeoutObject, clear, count: 0 };\n action.set(path, thr);\n return thr;\n }\n _incrReadyCount() {\n return this._readyCount++;\n }\n /**\n * Awaits write operation to finish.\n * Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback.\n * @param path being acted upon\n * @param threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished\n * @param event\n * @param awfEmit Callback to be called when ready for event to be emitted.\n */\n _awaitWriteFinish(path, threshold, event, awfEmit) {\n const awf = this.options.awaitWriteFinish;\n if (typeof awf !== 'object')\n return;\n const pollInterval = awf.pollInterval;\n let timeoutHandler;\n let fullPath = path;\n if (this.options.cwd && !sysPath.isAbsolute(path)) {\n fullPath = sysPath.join(this.options.cwd, path);\n }\n const now = new Date();\n const writes = this._pendingWrites;\n function awaitWriteFinishFn(prevStat) {\n statcb(fullPath, (err, curStat) => {\n if (err || !writes.has(path)) {\n if (err && err.code !== 'ENOENT')\n awfEmit(err);\n return;\n }\n const now = Number(new Date());\n if (prevStat && curStat.size !== prevStat.size) {\n writes.get(path).lastChange = now;\n }\n const pw = writes.get(path);\n const df = now - pw.lastChange;\n if (df >= threshold) {\n writes.delete(path);\n awfEmit(undefined, curStat);\n }\n else {\n timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);\n }\n });\n }\n if (!writes.has(path)) {\n writes.set(path, {\n lastChange: now,\n cancelWait: () => {\n writes.delete(path);\n clearTimeout(timeoutHandler);\n return event;\n },\n });\n timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);\n }\n }\n /**\n * Determines whether user has asked to ignore this path.\n */\n _isIgnored(path, stats) {\n if (this.options.atomic && DOT_RE.test(path))\n return true;\n if (!this._userIgnored) {\n const { cwd } = this.options;\n const ign = this.options.ignored;\n const ignored = (ign || []).map(normalizeIgnored(cwd));\n const ignoredPaths = [...this._ignoredPaths];\n const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];\n this._userIgnored = anymatch(list, undefined);\n }\n return this._userIgnored(path, stats);\n }\n _isntIgnored(path, stat) {\n return !this._isIgnored(path, stat);\n }\n /**\n * Provides a set of common helpers and properties relating to symlink handling.\n * @param path file or directory pattern being watched\n */\n _getWatchHelpers(path) {\n return new WatchHelper(path, this.options.followSymlinks, this);\n }\n // Directory helpers\n // -----------------\n /**\n * Provides directory tracking objects\n * @param directory path of the directory\n */\n _getWatchedDir(directory) {\n const dir = sysPath.resolve(directory);\n if (!this._watched.has(dir))\n this._watched.set(dir, new DirEntry(dir, this._boundRemove));\n return this._watched.get(dir);\n }\n // File helpers\n // ------------\n /**\n * Check for read permissions: https://stackoverflow.com/a/11781404/1358405\n */\n _hasReadPermissions(stats) {\n if (this.options.ignorePermissionErrors)\n return true;\n return Boolean(Number(stats.mode) & 0o400);\n }\n /**\n * Handles emitting unlink events for\n * files and directories, and via recursion, for\n * files and directories within directories that are unlinked\n * @param directory within which the following item is located\n * @param item base path of item/directory\n */\n _remove(directory, item, isDirectory) {\n // if what is being deleted is a directory, get that directory's paths\n // for recursive deleting and cleaning of watched object\n // if it is not a directory, nestedDirectoryChildren will be empty array\n const path = sysPath.join(directory, item);\n const fullPath = sysPath.resolve(path);\n isDirectory =\n isDirectory != null ? isDirectory : this._watched.has(path) || this._watched.has(fullPath);\n // prevent duplicate handling in case of arriving here nearly simultaneously\n // via multiple paths (such as _handleFile and _handleDir)\n if (!this._throttle('remove', path, 100))\n return;\n // if the only watched file is removed, watch for its return\n if (!isDirectory && this._watched.size === 1) {\n this.add(directory, item, true);\n }\n // This will create a new entry in the watched object in either case\n // so we got to do the directory check beforehand\n const wp = this._getWatchedDir(path);\n const nestedDirectoryChildren = wp.getChildren();\n // Recursively remove children directories / files.\n nestedDirectoryChildren.forEach((nested) => this._remove(path, nested));\n // Check if item was on the watched list and remove it\n const parent = this._getWatchedDir(directory);\n const wasTracked = parent.has(item);\n parent.remove(item);\n // Fixes issue #1042 -> Relative paths were detected and added as symlinks\n // (https://github.com/paulmillr/chokidar/blob/e1753ddbc9571bdc33b4a4af172d52cb6e611c10/lib/nodefs-handler.js#L612),\n // but never removed from the map in case the path was deleted.\n // This leads to an incorrect state if the path was recreated:\n // https://github.com/paulmillr/chokidar/blob/e1753ddbc9571bdc33b4a4af172d52cb6e611c10/lib/nodefs-handler.js#L553\n if (this._symlinkPaths.has(fullPath)) {\n this._symlinkPaths.delete(fullPath);\n }\n // If we wait for this file to be fully written, cancel the wait.\n let relPath = path;\n if (this.options.cwd)\n relPath = sysPath.relative(this.options.cwd, path);\n if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {\n const event = this._pendingWrites.get(relPath).cancelWait();\n if (event === EV.ADD)\n return;\n }\n // The Entry will either be a directory that just got removed\n // or a bogus entry to a file, in either case we have to remove it\n this._watched.delete(path);\n this._watched.delete(fullPath);\n const eventName = isDirectory ? EV.UNLINK_DIR : EV.UNLINK;\n if (wasTracked && !this._isIgnored(path))\n this._emit(eventName, path);\n // Avoid conflicts if we later create another file with the same name\n this._closePath(path);\n }\n /**\n * Closes all watchers for a path\n */\n _closePath(path) {\n this._closeFile(path);\n const dir = sysPath.dirname(path);\n this._getWatchedDir(dir).remove(sysPath.basename(path));\n }\n /**\n * Closes only file-specific watchers\n */\n _closeFile(path) {\n const closers = this._closers.get(path);\n if (!closers)\n return;\n closers.forEach((closer) => closer());\n this._closers.delete(path);\n }\n _addPathCloser(path, closer) {\n if (!closer)\n return;\n let list = this._closers.get(path);\n if (!list) {\n list = [];\n this._closers.set(path, list);\n }\n list.push(closer);\n }\n _readdirp(root, opts) {\n if (this.closed)\n return;\n const options = { type: EV.ALL, alwaysStat: true, lstat: true, ...opts, depth: 0 };\n let stream = readdirp(root, options);\n this._streams.add(stream);\n stream.once(STR_CLOSE, () => {\n stream = undefined;\n });\n stream.once(STR_END, () => {\n if (stream) {\n this._streams.delete(stream);\n stream = undefined;\n }\n });\n return stream;\n }\n}\n/**\n * Instantiates watcher with paths to be tracked.\n * @param paths file / directory paths\n * @param options opts, such as `atomic`, `awaitWriteFinish`, `ignored`, and others\n * @returns an instance of FSWatcher for chaining.\n * @example\n * const watcher = watch('.').on('all', (event, path) => { console.log(event, path); });\n * watch('.', { atomic: true, awaitWriteFinish: true, ignored: (f, stats) => stats?.isFile() && !f.endsWith('.js') })\n */\nexport function watch(paths, options = {}) {\n const watcher = new FSWatcher(options);\n watcher.add(paths);\n return watcher;\n}\nexport default { watch, FSWatcher };\n","import { stat, lstat, readdir, realpath } from 'node:fs/promises';\nimport { Readable } from 'node:stream';\nimport { resolve as presolve, relative as prelative, join as pjoin, sep as psep } from 'node:path';\nexport const EntryTypes = {\n FILE_TYPE: 'files',\n DIR_TYPE: 'directories',\n FILE_DIR_TYPE: 'files_directories',\n EVERYTHING_TYPE: 'all',\n};\nconst defaultOptions = {\n root: '.',\n fileFilter: (_entryInfo) => true,\n directoryFilter: (_entryInfo) => true,\n type: EntryTypes.FILE_TYPE,\n lstat: false,\n depth: 2147483648,\n alwaysStat: false,\n highWaterMark: 4096,\n};\nObject.freeze(defaultOptions);\nconst RECURSIVE_ERROR_CODE = 'READDIRP_RECURSIVE_ERROR';\nconst NORMAL_FLOW_ERRORS = new Set(['ENOENT', 'EPERM', 'EACCES', 'ELOOP', RECURSIVE_ERROR_CODE]);\nconst ALL_TYPES = [\n EntryTypes.DIR_TYPE,\n EntryTypes.EVERYTHING_TYPE,\n EntryTypes.FILE_DIR_TYPE,\n EntryTypes.FILE_TYPE,\n];\nconst DIR_TYPES = new Set([\n EntryTypes.DIR_TYPE,\n EntryTypes.EVERYTHING_TYPE,\n EntryTypes.FILE_DIR_TYPE,\n]);\nconst FILE_TYPES = new Set([\n EntryTypes.EVERYTHING_TYPE,\n EntryTypes.FILE_DIR_TYPE,\n EntryTypes.FILE_TYPE,\n]);\nconst isNormalFlowError = (error) => NORMAL_FLOW_ERRORS.has(error.code);\nconst wantBigintFsStats = process.platform === 'win32';\nconst emptyFn = (_entryInfo) => true;\nconst normalizeFilter = (filter) => {\n if (filter === undefined)\n return emptyFn;\n if (typeof filter === 'function')\n return filter;\n if (typeof filter === 'string') {\n const fl = filter.trim();\n return (entry) => entry.basename === fl;\n }\n if (Array.isArray(filter)) {\n const trItems = filter.map((item) => item.trim());\n return (entry) => trItems.some((f) => entry.basename === f);\n }\n return emptyFn;\n};\n/** Readable readdir stream, emitting new files as they're being listed. */\nexport class ReaddirpStream extends Readable {\n constructor(options = {}) {\n super({\n objectMode: true,\n autoDestroy: true,\n highWaterMark: options.highWaterMark,\n });\n const opts = { ...defaultOptions, ...options };\n const { root, type } = opts;\n this._fileFilter = normalizeFilter(opts.fileFilter);\n this._directoryFilter = normalizeFilter(opts.directoryFilter);\n const statMethod = opts.lstat ? lstat : stat;\n // Use bigint stats if it's windows and stat() supports options (node 10+).\n if (wantBigintFsStats) {\n this._stat = (path) => statMethod(path, { bigint: true });\n }\n else {\n this._stat = statMethod;\n }\n this._maxDepth = opts.depth ?? defaultOptions.depth;\n this._wantsDir = type ? DIR_TYPES.has(type) : false;\n this._wantsFile = type ? FILE_TYPES.has(type) : false;\n this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;\n this._root = presolve(root);\n this._isDirent = !opts.alwaysStat;\n this._statsProp = this._isDirent ? 'dirent' : 'stats';\n this._rdOptions = { encoding: 'utf8', withFileTypes: this._isDirent };\n // Launch stream with one parent, the root dir.\n this.parents = [this._exploreDir(root, 1)];\n this.reading = false;\n this.parent = undefined;\n }\n async _read(batch) {\n if (this.reading)\n return;\n this.reading = true;\n try {\n while (!this.destroyed && batch > 0) {\n const par = this.parent;\n const fil = par && par.files;\n if (fil && fil.length > 0) {\n const { path, depth } = par;\n const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path));\n const awaited = await Promise.all(slice);\n for (const entry of awaited) {\n if (!entry)\n continue;\n if (this.destroyed)\n return;\n const entryType = await this._getEntryType(entry);\n if (entryType === 'directory' && this._directoryFilter(entry)) {\n if (depth <= this._maxDepth) {\n this.parents.push(this._exploreDir(entry.fullPath, depth + 1));\n }\n if (this._wantsDir) {\n this.push(entry);\n batch--;\n }\n }\n else if ((entryType === 'file' || this._includeAsFile(entry)) &&\n this._fileFilter(entry)) {\n if (this._wantsFile) {\n this.push(entry);\n batch--;\n }\n }\n }\n }\n else {\n const parent = this.parents.pop();\n if (!parent) {\n this.push(null);\n break;\n }\n this.parent = await parent;\n if (this.destroyed)\n return;\n }\n }\n }\n catch (error) {\n this.destroy(error);\n }\n finally {\n this.reading = false;\n }\n }\n async _exploreDir(path, depth) {\n let files;\n try {\n files = await readdir(path, this._rdOptions);\n }\n catch (error) {\n this._onError(error);\n }\n return { files, depth, path };\n }\n async _formatEntry(dirent, path) {\n let entry;\n const basename = this._isDirent ? dirent.name : dirent;\n try {\n const fullPath = presolve(pjoin(path, basename));\n entry = { path: prelative(this._root, fullPath), fullPath, basename };\n entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);\n }\n catch (err) {\n this._onError(err);\n return;\n }\n return entry;\n }\n _onError(err) {\n if (isNormalFlowError(err) && !this.destroyed) {\n this.emit('warn', err);\n }\n else {\n this.destroy(err);\n }\n }\n async _getEntryType(entry) {\n // entry may be undefined, because a warning or an error were emitted\n // and the statsProp is undefined\n if (!entry && this._statsProp in entry) {\n return '';\n }\n const stats = entry[this._statsProp];\n if (stats.isFile())\n return 'file';\n if (stats.isDirectory())\n return 'directory';\n if (stats && stats.isSymbolicLink()) {\n const full = entry.fullPath;\n try {\n const entryRealPath = await realpath(full);\n const entryRealPathStats = await lstat(entryRealPath);\n if (entryRealPathStats.isFile()) {\n return 'file';\n }\n if (entryRealPathStats.isDirectory()) {\n const len = entryRealPath.length;\n if (full.startsWith(entryRealPath) && full.substr(len, 1) === psep) {\n const recursiveError = new Error(`Circular symlink detected: \"${full}\" points to \"${entryRealPath}\"`);\n // @ts-ignore\n recursiveError.code = RECURSIVE_ERROR_CODE;\n return this._onError(recursiveError);\n }\n return 'directory';\n }\n }\n catch (error) {\n this._onError(error);\n return '';\n }\n }\n }\n _includeAsFile(entry) {\n const stats = entry && entry[this._statsProp];\n return stats && this._wantsEverything && !stats.isDirectory();\n }\n}\n/**\n * Streaming version: Reads all files and directories in given root recursively.\n * Consumes ~constant small amount of RAM.\n * @param root Root directory\n * @param options Options to specify root (start directory), filters and recursion depth\n */\nexport function readdirp(root, options = {}) {\n // @ts-ignore\n let type = options.entryType || options.type;\n if (type === 'both')\n type = EntryTypes.FILE_DIR_TYPE; // backwards-compatibility\n if (type)\n options.type = type;\n if (!root) {\n throw new Error('readdirp: root argument is required. Usage: readdirp(root, options)');\n }\n else if (typeof root !== 'string') {\n throw new TypeError('readdirp: root argument must be a string. Usage: readdirp(root, options)');\n }\n else if (type && !ALL_TYPES.includes(type)) {\n throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(', ')}`);\n }\n options.root = root;\n return new ReaddirpStream(options);\n}\n/**\n * Promise version: Reads all files and directories in given root recursively.\n * Compared to streaming version, will consume a lot of RAM e.g. when 1 million files are listed.\n * @returns array of paths and their entry infos\n */\nexport function readdirpPromise(root, options = {}) {\n return new Promise((resolve, reject) => {\n const files = [];\n readdirp(root, options)\n .on('data', (entry) => files.push(entry))\n .on('end', () => resolve(files))\n .on('error', (error) => reject(error));\n });\n}\nexport default readdirp;\n","import { watchFile, unwatchFile, watch as fs_watch } from 'fs';\nimport { open, stat, lstat, realpath as fsrealpath } from 'fs/promises';\nimport * as sysPath from 'path';\nimport { type as osType } from 'os';\nexport const STR_DATA = 'data';\nexport const STR_END = 'end';\nexport const STR_CLOSE = 'close';\nexport const EMPTY_FN = () => { };\nexport const IDENTITY_FN = (val) => val;\nconst pl = process.platform;\nexport const isWindows = pl === 'win32';\nexport const isMacos = pl === 'darwin';\nexport const isLinux = pl === 'linux';\nexport const isFreeBSD = pl === 'freebsd';\nexport const isIBMi = osType() === 'OS400';\nexport const EVENTS = {\n ALL: 'all',\n READY: 'ready',\n ADD: 'add',\n CHANGE: 'change',\n ADD_DIR: 'addDir',\n UNLINK: 'unlink',\n UNLINK_DIR: 'unlinkDir',\n RAW: 'raw',\n ERROR: 'error',\n};\nconst EV = EVENTS;\nconst THROTTLE_MODE_WATCH = 'watch';\nconst statMethods = { lstat, stat };\nconst KEY_LISTENERS = 'listeners';\nconst KEY_ERR = 'errHandlers';\nconst KEY_RAW = 'rawEmitters';\nconst HANDLER_KEYS = [KEY_LISTENERS, KEY_ERR, KEY_RAW];\n// prettier-ignore\nconst binaryExtensions = new Set([\n '3dm', '3ds', '3g2', '3gp', '7z', 'a', 'aac', 'adp', 'afdesign', 'afphoto', 'afpub', 'ai',\n 'aif', 'aiff', 'alz', 'ape', 'apk', 'appimage', 'ar', 'arj', 'asf', 'au', 'avi',\n 'bak', 'baml', 'bh', 'bin', 'bk', 'bmp', 'btif', 'bz2', 'bzip2',\n 'cab', 'caf', 'cgm', 'class', 'cmx', 'cpio', 'cr2', 'cur', 'dat', 'dcm', 'deb', 'dex', 'djvu',\n 'dll', 'dmg', 'dng', 'doc', 'docm', 'docx', 'dot', 'dotm', 'dra', 'DS_Store', 'dsk', 'dts',\n 'dtshd', 'dvb', 'dwg', 'dxf',\n 'ecelp4800', 'ecelp7470', 'ecelp9600', 'egg', 'eol', 'eot', 'epub', 'exe',\n 'f4v', 'fbs', 'fh', 'fla', 'flac', 'flatpak', 'fli', 'flv', 'fpx', 'fst', 'fvt',\n 'g3', 'gh', 'gif', 'graffle', 'gz', 'gzip',\n 'h261', 'h263', 'h264', 'icns', 'ico', 'ief', 'img', 'ipa', 'iso',\n 'jar', 'jpeg', 'jpg', 'jpgv', 'jpm', 'jxr', 'key', 'ktx',\n 'lha', 'lib', 'lvp', 'lz', 'lzh', 'lzma', 'lzo',\n 'm3u', 'm4a', 'm4v', 'mar', 'mdi', 'mht', 'mid', 'midi', 'mj2', 'mka', 'mkv', 'mmr', 'mng',\n 'mobi', 'mov', 'movie', 'mp3',\n 'mp4', 'mp4a', 'mpeg', 'mpg', 'mpga', 'mxu',\n 'nef', 'npx', 'numbers', 'nupkg',\n 'o', 'odp', 'ods', 'odt', 'oga', 'ogg', 'ogv', 'otf', 'ott',\n 'pages', 'pbm', 'pcx', 'pdb', 'pdf', 'pea', 'pgm', 'pic', 'png', 'pnm', 'pot', 'potm',\n 'potx', 'ppa', 'ppam',\n 'ppm', 'pps', 'ppsm', 'ppsx', 'ppt', 'pptm', 'pptx', 'psd', 'pya', 'pyc', 'pyo', 'pyv',\n 'qt',\n 'rar', 'ras', 'raw', 'resources', 'rgb', 'rip', 'rlc', 'rmf', 'rmvb', 'rpm', 'rtf', 'rz',\n 's3m', 's7z', 'scpt', 'sgi', 'shar', 'snap', 'sil', 'sketch', 'slk', 'smv', 'snk', 'so',\n 'stl', 'suo', 'sub', 'swf',\n 'tar', 'tbz', 'tbz2', 'tga', 'tgz', 'thmx', 'tif', 'tiff', 'tlz', 'ttc', 'ttf', 'txz',\n 'udf', 'uvh', 'uvi', 'uvm', 'uvp', 'uvs', 'uvu',\n 'viv', 'vob',\n 'war', 'wav', 'wax', 'wbmp', 'wdp', 'weba', 'webm', 'webp', 'whl', 'wim', 'wm', 'wma',\n 'wmv', 'wmx', 'woff', 'woff2', 'wrm', 'wvx',\n 'xbm', 'xif', 'xla', 'xlam', 'xls', 'xlsb', 'xlsm', 'xlsx', 'xlt', 'xltm', 'xltx', 'xm',\n 'xmind', 'xpi', 'xpm', 'xwd', 'xz',\n 'z', 'zip', 'zipx',\n]);\nconst isBinaryPath = (filePath) => binaryExtensions.has(sysPath.extname(filePath).slice(1).toLowerCase());\n// TODO: emit errors properly. Example: EMFILE on Macos.\nconst foreach = (val, fn) => {\n if (val instanceof Set) {\n val.forEach(fn);\n }\n else {\n fn(val);\n }\n};\nconst addAndConvert = (main, prop, item) => {\n let container = main[prop];\n if (!(container instanceof Set)) {\n main[prop] = container = new Set([container]);\n }\n container.add(item);\n};\nconst clearItem = (cont) => (key) => {\n const set = cont[key];\n if (set instanceof Set) {\n set.clear();\n }\n else {\n delete cont[key];\n }\n};\nconst delFromSet = (main, prop, item) => {\n const container = main[prop];\n if (container instanceof Set) {\n container.delete(item);\n }\n else if (container === item) {\n delete main[prop];\n }\n};\nconst isEmptySet = (val) => (val instanceof Set ? val.size === 0 : !val);\nconst FsWatchInstances = new Map();\n/**\n * Instantiates the fs_watch interface\n * @param path to be watched\n * @param options to be passed to fs_watch\n * @param listener main event handler\n * @param errHandler emits info about errors\n * @param emitRaw emits raw event data\n * @returns {NativeFsWatcher}\n */\nfunction createFsWatchInstance(path, options, listener, errHandler, emitRaw) {\n const handleEvent = (rawEvent, evPath) => {\n listener(path);\n emitRaw(rawEvent, evPath, { watchedPath: path });\n // emit based on events occurring for files from a directory's watcher in\n // case the file's watcher misses it (and rely on throttling to de-dupe)\n if (evPath && path !== evPath) {\n fsWatchBroadcast(sysPath.resolve(path, evPath), KEY_LISTENERS, sysPath.join(path, evPath));\n }\n };\n try {\n return fs_watch(path, {\n persistent: options.persistent,\n }, handleEvent);\n }\n catch (error) {\n errHandler(error);\n return undefined;\n }\n}\n/**\n * Helper for passing fs_watch event data to a collection of listeners\n * @param fullPath absolute path bound to fs_watch instance\n */\nconst fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {\n const cont = FsWatchInstances.get(fullPath);\n if (!cont)\n return;\n foreach(cont[listenerType], (listener) => {\n listener(val1, val2, val3);\n });\n};\n/**\n * Instantiates the fs_watch interface or binds listeners\n * to an existing one covering the same file system entry\n * @param path\n * @param fullPath absolute path\n * @param options to be passed to fs_watch\n * @param handlers container for event listener functions\n */\nconst setFsWatchListener = (path, fullPath, options, handlers) => {\n const { listener, errHandler, rawEmitter } = handlers;\n let cont = FsWatchInstances.get(fullPath);\n let watcher;\n if (!options.persistent) {\n watcher = createFsWatchInstance(path, options, listener, errHandler, rawEmitter);\n if (!watcher)\n return;\n return watcher.close.bind(watcher);\n }\n if (cont) {\n addAndConvert(cont, KEY_LISTENERS, listener);\n addAndConvert(cont, KEY_ERR, errHandler);\n addAndConvert(cont, KEY_RAW, rawEmitter);\n }\n else {\n watcher = createFsWatchInstance(path, options, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, // no need to use broadcast here\n fsWatchBroadcast.bind(null, fullPath, KEY_RAW));\n if (!watcher)\n return;\n watcher.on(EV.ERROR, async (error) => {\n const broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR);\n if (cont)\n cont.watcherUnusable = true; // documented since Node 10.4.1\n // Workaround for https://github.com/joyent/node/issues/4337\n if (isWindows && error.code === 'EPERM') {\n try {\n const fd = await open(path, 'r');\n await fd.close();\n broadcastErr(error);\n }\n catch (err) {\n // do nothing\n }\n }\n else {\n broadcastErr(error);\n }\n });\n cont = {\n listeners: listener,\n errHandlers: errHandler,\n rawEmitters: rawEmitter,\n watcher,\n };\n FsWatchInstances.set(fullPath, cont);\n }\n // const index = cont.listeners.indexOf(listener);\n // removes this instance's listeners and closes the underlying fs_watch\n // instance if there are no more listeners left\n return () => {\n delFromSet(cont, KEY_LISTENERS, listener);\n delFromSet(cont, KEY_ERR, errHandler);\n delFromSet(cont, KEY_RAW, rawEmitter);\n if (isEmptySet(cont.listeners)) {\n // Check to protect against issue gh-730.\n // if (cont.watcherUnusable) {\n cont.watcher.close();\n // }\n FsWatchInstances.delete(fullPath);\n HANDLER_KEYS.forEach(clearItem(cont));\n // @ts-ignore\n cont.watcher = undefined;\n Object.freeze(cont);\n }\n };\n};\n// fs_watchFile helpers\n// object to hold per-process fs_watchFile instances\n// (may be shared across chokidar FSWatcher instances)\nconst FsWatchFileInstances = new Map();\n/**\n * Instantiates the fs_watchFile interface or binds listeners\n * to an existing one covering the same file system entry\n * @param path to be watched\n * @param fullPath absolute path\n * @param options options to be passed to fs_watchFile\n * @param handlers container for event listener functions\n * @returns closer\n */\nconst setFsWatchFileListener = (path, fullPath, options, handlers) => {\n const { listener, rawEmitter } = handlers;\n let cont = FsWatchFileInstances.get(fullPath);\n // let listeners = new Set();\n // let rawEmitters = new Set();\n const copts = cont && cont.options;\n if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) {\n // \"Upgrade\" the watcher to persistence or a quicker interval.\n // This creates some unlikely edge case issues if the user mixes\n // settings in a very weird way, but solving for those cases\n // doesn't seem worthwhile for the added complexity.\n // listeners = cont.listeners;\n // rawEmitters = cont.rawEmitters;\n unwatchFile(fullPath);\n cont = undefined;\n }\n if (cont) {\n addAndConvert(cont, KEY_LISTENERS, listener);\n addAndConvert(cont, KEY_RAW, rawEmitter);\n }\n else {\n // TODO\n // listeners.add(listener);\n // rawEmitters.add(rawEmitter);\n cont = {\n listeners: listener,\n rawEmitters: rawEmitter,\n options,\n watcher: watchFile(fullPath, options, (curr, prev) => {\n foreach(cont.rawEmitters, (rawEmitter) => {\n rawEmitter(EV.CHANGE, fullPath, { curr, prev });\n });\n const currmtime = curr.mtimeMs;\n if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {\n foreach(cont.listeners, (listener) => listener(path, curr));\n }\n }),\n };\n FsWatchFileInstances.set(fullPath, cont);\n }\n // const index = cont.listeners.indexOf(listener);\n // Removes this instance's listeners and closes the underlying fs_watchFile\n // instance if there are no more listeners left.\n return () => {\n delFromSet(cont, KEY_LISTENERS, listener);\n delFromSet(cont, KEY_RAW, rawEmitter);\n if (isEmptySet(cont.listeners)) {\n FsWatchFileInstances.delete(fullPath);\n unwatchFile(fullPath);\n cont.options = cont.watcher = undefined;\n Object.freeze(cont);\n }\n };\n};\n/**\n * @mixin\n */\nexport class NodeFsHandler {\n constructor(fsW) {\n this.fsw = fsW;\n this._boundHandleError = (error) => fsW._handleError(error);\n }\n /**\n * Watch file for changes with fs_watchFile or fs_watch.\n * @param path to file or dir\n * @param listener on fs change\n * @returns closer for the watcher instance\n */\n _watchWithNodeFs(path, listener) {\n const opts = this.fsw.options;\n const directory = sysPath.dirname(path);\n const basename = sysPath.basename(path);\n const parent = this.fsw._getWatchedDir(directory);\n parent.add(basename);\n const absolutePath = sysPath.resolve(path);\n const options = {\n persistent: opts.persistent,\n };\n if (!listener)\n listener = EMPTY_FN;\n let closer;\n if (opts.usePolling) {\n const enableBin = opts.interval !== opts.binaryInterval;\n options.interval = enableBin && isBinaryPath(basename) ? opts.binaryInterval : opts.interval;\n closer = setFsWatchFileListener(path, absolutePath, options, {\n listener,\n rawEmitter: this.fsw._emitRaw,\n });\n }\n else {\n closer = setFsWatchListener(path, absolutePath, options, {\n listener,\n errHandler: this._boundHandleError,\n rawEmitter: this.fsw._emitRaw,\n });\n }\n return closer;\n }\n /**\n * Watch a file and emit add event if warranted.\n * @returns closer for the watcher instance\n */\n _handleFile(file, stats, initialAdd) {\n if (this.fsw.closed) {\n return;\n }\n const dirname = sysPath.dirname(file);\n const basename = sysPath.basename(file);\n const parent = this.fsw._getWatchedDir(dirname);\n // stats is always present\n let prevStats = stats;\n // if the file is already being watched, do nothing\n if (parent.has(basename))\n return;\n const listener = async (path, newStats) => {\n if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))\n return;\n if (!newStats || newStats.mtimeMs === 0) {\n try {\n const newStats = await stat(file);\n if (this.fsw.closed)\n return;\n // Check that change event was not fired because of changed only accessTime.\n const at = newStats.atimeMs;\n const mt = newStats.mtimeMs;\n if (!at || at <= mt || mt !== prevStats.mtimeMs) {\n this.fsw._emit(EV.CHANGE, file, newStats);\n }\n if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats.ino) {\n this.fsw._closeFile(path);\n prevStats = newStats;\n const closer = this._watchWithNodeFs(file, listener);\n if (closer)\n this.fsw._addPathCloser(path, closer);\n }\n else {\n prevStats = newStats;\n }\n }\n catch (error) {\n // Fix issues where mtime is null but file is still present\n this.fsw._remove(dirname, basename);\n }\n // add is about to be emitted if file not already tracked in parent\n }\n else if (parent.has(basename)) {\n // Check that change event was not fired because of changed only accessTime.\n const at = newStats.atimeMs;\n const mt = newStats.mtimeMs;\n if (!at || at <= mt || mt !== prevStats.mtimeMs) {\n this.fsw._emit(EV.CHANGE, file, newStats);\n }\n prevStats = newStats;\n }\n };\n // kick off the watcher\n const closer = this._watchWithNodeFs(file, listener);\n // emit an add event if we're supposed to\n if (!(initialAdd && this.fsw.options.ignoreInitial) && this.fsw._isntIgnored(file)) {\n if (!this.fsw._throttle(EV.ADD, file, 0))\n return;\n this.fsw._emit(EV.ADD, file, stats);\n }\n return closer;\n }\n /**\n * Handle symlinks encountered while reading a dir.\n * @param entry returned by readdirp\n * @param directory path of dir being read\n * @param path of this item\n * @param item basename of this item\n * @returns true if no more processing is needed for this entry.\n */\n async _handleSymlink(entry, directory, path, item) {\n if (this.fsw.closed) {\n return;\n }\n const full = entry.fullPath;\n const dir = this.fsw._getWatchedDir(directory);\n if (!this.fsw.options.followSymlinks) {\n // watch symlink directly (don't follow) and detect changes\n this.fsw._incrReadyCount();\n let linkPath;\n try {\n linkPath = await fsrealpath(path);\n }\n catch (e) {\n this.fsw._emitReady();\n return true;\n }\n if (this.fsw.closed)\n return;\n if (dir.has(item)) {\n if (this.fsw._symlinkPaths.get(full) !== linkPath) {\n this.fsw._symlinkPaths.set(full, linkPath);\n this.fsw._emit(EV.CHANGE, path, entry.stats);\n }\n }\n else {\n dir.add(item);\n this.fsw._symlinkPaths.set(full, linkPath);\n this.fsw._emit(EV.ADD, path, entry.stats);\n }\n this.fsw._emitReady();\n return true;\n }\n // don't follow the same symlink more than once\n if (this.fsw._symlinkPaths.has(full)) {\n return true;\n }\n this.fsw._symlinkPaths.set(full, true);\n }\n _handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {\n // Normalize the directory name on Windows\n directory = sysPath.join(directory, '');\n throttler = this.fsw._throttle('readdir', directory, 1000);\n if (!throttler)\n return;\n const previous = this.fsw._getWatchedDir(wh.path);\n const current = new Set();\n let stream = this.fsw._readdirp(directory, {\n fileFilter: (entry) => wh.filterPath(entry),\n directoryFilter: (entry) => wh.filterDir(entry),\n });\n if (!stream)\n return;\n stream\n .on(STR_DATA, async (entry) => {\n if (this.fsw.closed) {\n stream = undefined;\n return;\n }\n const item = entry.path;\n let path = sysPath.join(directory, item);\n current.add(item);\n if (entry.stats.isSymbolicLink() &&\n (await this._handleSymlink(entry, directory, path, item))) {\n return;\n }\n if (this.fsw.closed) {\n stream = undefined;\n return;\n }\n // Files that present in current directory snapshot\n // but absent in previous are added to watch list and\n // emit `add` event.\n if (item === target || (!target && !previous.has(item))) {\n this.fsw._incrReadyCount();\n // ensure relativeness of path is preserved in case of watcher reuse\n path = sysPath.join(dir, sysPath.relative(dir, path));\n this._addToNodeFs(path, initialAdd, wh, depth + 1);\n }\n })\n .on(EV.ERROR, this._boundHandleError);\n return new Promise((resolve, reject) => {\n if (!stream)\n return reject();\n stream.once(STR_END, () => {\n if (this.fsw.closed) {\n stream = undefined;\n return;\n }\n const wasThrottled = throttler ? throttler.clear() : false;\n resolve(undefined);\n // Files that absent in current directory snapshot\n // but present in previous emit `remove` event\n // and are removed from @watched[directory].\n previous\n .getChildren()\n .filter((item) => {\n return item !== directory && !current.has(item);\n })\n .forEach((item) => {\n this.fsw._remove(directory, item);\n });\n stream = undefined;\n // one more time for any missed in case changes came in extremely quickly\n if (wasThrottled)\n this._handleRead(directory, false, wh, target, dir, depth, throttler);\n });\n });\n }\n /**\n * Read directory to add / remove files from `@watched` list and re-read it on change.\n * @param dir fs path\n * @param stats\n * @param initialAdd\n * @param depth relative to user-supplied path\n * @param target child path targeted for watch\n * @param wh Common watch helpers for this path\n * @param realpath\n * @returns closer for the watcher instance.\n */\n async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath) {\n const parentDir = this.fsw._getWatchedDir(sysPath.dirname(dir));\n const tracked = parentDir.has(sysPath.basename(dir));\n if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {\n this.fsw._emit(EV.ADD_DIR, dir, stats);\n }\n // ensure dir is tracked (harmless if redundant)\n parentDir.add(sysPath.basename(dir));\n this.fsw._getWatchedDir(dir);\n let throttler;\n let closer;\n const oDepth = this.fsw.options.depth;\n if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath)) {\n if (!target) {\n await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler);\n if (this.fsw.closed)\n return;\n }\n closer = this._watchWithNodeFs(dir, (dirPath, stats) => {\n // if current directory is removed, do nothing\n if (stats && stats.mtimeMs === 0)\n return;\n this._handleRead(dirPath, false, wh, target, dir, depth, throttler);\n });\n }\n return closer;\n }\n /**\n * Handle added file, directory, or glob pattern.\n * Delegates call to _handleFile / _handleDir after checks.\n * @param path to file or ir\n * @param initialAdd was the file added at watch instantiation?\n * @param priorWh depth relative to user-supplied path\n * @param depth Child path actually targeted for watch\n * @param target Child path actually targeted for watch\n */\n async _addToNodeFs(path, initialAdd, priorWh, depth, target) {\n const ready = this.fsw._emitReady;\n if (this.fsw._isIgnored(path) || this.fsw.closed) {\n ready();\n return false;\n }\n const wh = this.fsw._getWatchHelpers(path);\n if (priorWh) {\n wh.filterPath = (entry) => priorWh.filterPath(entry);\n wh.filterDir = (entry) => priorWh.filterDir(entry);\n }\n // evaluate what is at the path we're being asked to watch\n try {\n const stats = await statMethods[wh.statMethod](wh.watchPath);\n if (this.fsw.closed)\n return;\n if (this.fsw._isIgnored(wh.watchPath, stats)) {\n ready();\n return false;\n }\n const follow = this.fsw.options.followSymlinks;\n let closer;\n if (stats.isDirectory()) {\n const absPath = sysPath.resolve(path);\n const targetPath = follow ? await fsrealpath(path) : path;\n if (this.fsw.closed)\n return;\n closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);\n if (this.fsw.closed)\n return;\n // preserve this symlink's target path\n if (absPath !== targetPath && targetPath !== undefined) {\n this.fsw._symlinkPaths.set(absPath, targetPath);\n }\n }\n else if (stats.isSymbolicLink()) {\n const targetPath = follow ? await fsrealpath(path) : path;\n if (this.fsw.closed)\n return;\n const parent = sysPath.dirname(wh.watchPath);\n this.fsw._getWatchedDir(parent).add(wh.watchPath);\n this.fsw._emit(EV.ADD, wh.watchPath, stats);\n closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath);\n if (this.fsw.closed)\n return;\n // preserve this symlink's target path\n if (targetPath !== undefined) {\n this.fsw._symlinkPaths.set(sysPath.resolve(path), targetPath);\n }\n }\n else {\n closer = this._handleFile(wh.watchPath, stats, initialAdd);\n }\n ready();\n if (closer)\n this.fsw._addPathCloser(path, closer);\n return false;\n }\n catch (error) {\n if (this.fsw._handleError(error)) {\n ready();\n return path;\n }\n }\n }\n}\n","import chokidar from \"chokidar\";\nimport type { Corpus } from \"./corpus.js\";\nimport { drainInbox } from \"./ingest.js\";\nimport { openSearchIndex } from \"./searchIndex.js\";\n\nexport type WatchHandle = {\n close: () => Promise<void>;\n};\n\n/**\n * Watch `<corpus>/inbox/` and drain new NDJSON delta files as they land, keeping\n * both the corpus and the search index current. The extension's attended \"Sync\n * now\" drops files here; this makes them appear live without a manual `drain`.\n *\n * Drains are serialized (a run in progress defers the next trigger) and an\n * initial drain catches anything already waiting. `onDrain` reports each batch.\n */\nexport async function watchInbox(\n corpus: Corpus,\n onDrain?: (summary: { files: number; created: number; updated: number; skipped: number }) => void\n): Promise<WatchHandle> {\n await corpus.init();\n const index = await openSearchIndex(corpus);\n\n let draining = false;\n let pending = false;\n const runDrain = async (): Promise<void> => {\n if (draining) {\n pending = true;\n return;\n }\n draining = true;\n try {\n do {\n pending = false;\n const report = await drainInbox(corpus, index);\n if (report.files > 0) {\n onDrain?.(report);\n }\n } while (pending);\n } finally {\n draining = false;\n }\n };\n\n // Only react to files dropped directly in inbox/, not the processed/ archive.\n const watcher = chokidar.watch(corpus.paths.inboxDir, {\n ignoreInitial: true,\n depth: 0,\n awaitWriteFinish: { stabilityThreshold: 300, pollInterval: 100 }\n });\n watcher.on(\"add\", () => void runDrain());\n\n // Catch anything already sitting in the inbox at startup.\n await runDrain();\n\n return {\n close: async () => {\n await watcher.close();\n index.close();\n }\n };\n}\n","// Registers the LLMnesia MCP server with whatever MCP clients are detected on\n// this machine. Mirrors docs/MCP_INSTALLER_BOARD.md's client matrix exactly:\n//\n// Claude Code -> shell out to `claude mcp add` (cleanest, no file editing)\n// Claude Desktop -> edit claude_desktop_config.json (JSON, back up first)\n// Cursor -> edit ~/.cursor/mcp.json (same JSON shape)\n// Codex -> shell out to `codex mcp add`; print TOML only as fallback\n// Everything else (Windsurf, Zed, LM Studio, ...) -> print a generic\n// command+args block, since every local MCP client accepts that shape.\n//\n// Principle throughout: detect -> show the change -> confirm -> back up ->\n// write. Never silently edit a user's config. Every JSON write keeps whatever\n// else was already in the file (other mcpServers entries, unrelated keys).\n\nimport { execFile } from \"node:child_process\";\nimport { access, readFile, stat, writeFile } from \"node:fs/promises\";\nimport { homedir, platform } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport { promisify } from \"node:util\";\nimport crossSpawn from \"cross-spawn\";\n\nconst execFileAsync = promisify(execFile);\n\nexport const SERVER_NAME = \"llmnesia\";\n\nexport type ServeCommand = { command: string; args: string[] };\n\nexport type ClientRegistrationResult = {\n client: string;\n action: \"registered\" | \"printed\" | \"skipped\" | \"declined\" | \"error\";\n detail: string;\n};\n\n/**\n * The `claude` CLI, behind an interface. Claude Code is the one client we\n * configure by running a command rather than editing a file, so it is also the\n * one client a test cannot exercise without mutating the developer's own real\n * MCP registration. Tests pass a fake; production gets {@link realClaudeCli}.\n */\nexport type ClaudeCliAdapter = {\n detect: () => Promise<boolean>;\n add: (name: string, serve: ServeCommand) => Promise<void>;\n remove: (name: string) => Promise<void>;\n};\n\nexport type CodexServerRegistration = {\n /** null means the name exists, but it is not a recognisable stdio entry. */\n serve: ServeCommand | null;\n};\n\nexport type CodexCliAdapter = {\n detect: () => Promise<boolean>;\n get: (name: string) => Promise<CodexServerRegistration | null>;\n add: (name: string, serve: ServeCommand) => Promise<void>;\n remove: (name: string) => Promise<void>;\n};\n\nasync function commandOnPath(name: string): Promise<string | null> {\n try {\n const { stdout } = await execFileAsync(process.platform === \"win32\" ? \"where\" : \"which\", [name]);\n return stdout\n .split(/\\r?\\n/)\n .map((line) => line.trim())\n .find(Boolean) ?? null;\n } catch {\n return null;\n }\n}\n\ntype CliOutput = { stdout: string; stderr: string };\n\n/**\n * Spawn a CLI without a shell on POSIX, while still supporting npm's `.cmd`\n * shims on Windows. cross-spawn performs the Windows escaping; using\n * `shell: true` here would make paths containing shell metacharacters unsafe.\n */\nasync function runExecutable(executable: string, args: string[]): Promise<CliOutput> {\n return new Promise((resolve, reject) => {\n const child = crossSpawn(executable, args, { stdio: [\"ignore\", \"pipe\", \"pipe\"] });\n let stdout = \"\";\n let stderr = \"\";\n child.stdout?.setEncoding(\"utf8\");\n child.stderr?.setEncoding(\"utf8\");\n child.stdout?.on(\"data\", (chunk: string) => {\n stdout += chunk;\n });\n child.stderr?.on(\"data\", (chunk: string) => {\n stderr += chunk;\n });\n child.once(\"error\", reject);\n child.once(\"close\", (code, signal) => {\n if (code === 0) {\n resolve({ stdout, stderr });\n return;\n }\n reject(\n Object.assign(new Error(`Command failed with ${signal ? `signal ${signal}` : `exit code ${code ?? \"unknown\"}`}`), {\n code,\n signal,\n stdout,\n stderr\n })\n );\n });\n });\n}\n\nasync function runPathCli(name: string, args: string[]): Promise<CliOutput> {\n const executable = await commandOnPath(name);\n if (!executable) {\n throw new Error(`\\`${name}\\` was not found on PATH`);\n }\n return runExecutable(executable, args);\n}\n\nasync function resolveCodexExecutable(): Promise<string | null> {\n const onPath = await commandOnPath(\"codex\");\n if (onPath) {\n return onPath;\n }\n\n // The desktop app ships the CLI inside its application bundle on macOS,\n // but does not always add it to PATH. Using that official bundled binary is\n // what makes `install` work for ordinary Codex app users too.\n if (process.platform === \"darwin\") {\n const candidates = [\n \"/Applications/ChatGPT.app/Contents/Resources/codex\",\n \"/Applications/Codex.app/Contents/Resources/codex\",\n join(homedir(), \"Applications\", \"ChatGPT.app\", \"Contents\", \"Resources\", \"codex\"),\n join(homedir(), \"Applications\", \"Codex.app\", \"Contents\", \"Resources\", \"codex\")\n ];\n for (const candidate of candidates) {\n try {\n await access(candidate);\n return candidate;\n } catch {\n // Try the next known app location.\n }\n }\n }\n return null;\n}\n\nexport const realClaudeCli: ClaudeCliAdapter = {\n detect: async () => {\n return (await commandOnPath(\"claude\")) !== null;\n },\n add: async (name, serve) => {\n await runPathCli(\"claude\", [\"mcp\", \"add\", name, \"--\", serve.command, ...serve.args]);\n },\n remove: async (name) => {\n await runPathCli(\"claude\", [\"mcp\", \"remove\", name]);\n }\n};\n\nasync function runCodex(args: string[]): Promise<CliOutput> {\n const executable = await resolveCodexExecutable();\n if (!executable) {\n throw new Error(\"`codex` was not found on PATH or in a supported desktop app location\");\n }\n return runExecutable(executable, args);\n}\n\nfunction parseCodexRegistration(raw: string): CodexServerRegistration {\n const value = JSON.parse(raw) as Record<string, unknown>;\n const transport =\n value.transport && typeof value.transport === \"object\" ? (value.transport as Record<string, unknown>) : value;\n const command = transport.command;\n const rawArgs = transport.args;\n if (typeof command !== \"string\" || !Array.isArray(rawArgs) || !rawArgs.every((arg) => typeof arg === \"string\")) {\n return { serve: null };\n }\n return { serve: { command, args: rawArgs as string[] } };\n}\n\nexport const realCodexCli: CodexCliAdapter = {\n detect: async () => (await resolveCodexExecutable()) !== null,\n get: async (name) => {\n try {\n const { stdout } = await runCodex([\"mcp\", \"get\", name, \"--json\"]);\n return parseCodexRegistration(stdout);\n } catch (err) {\n const output =\n err && typeof err === \"object\"\n ? `${\"stdout\" in err ? String(err.stdout) : \"\"}\\n${\"stderr\" in err ? String(err.stderr) : \"\"}`\n : errorMessage(err);\n if (/No MCP server named/i.test(output)) {\n return null;\n }\n throw err;\n }\n },\n add: async (name, serve) => {\n await runCodex([\"mcp\", \"add\", name, \"--\", serve.command, ...serve.args]);\n },\n remove: async (name) => {\n await runCodex([\"mcp\", \"remove\", name]);\n }\n};\n\nexport type RegisterClientsOptions = {\n serve: ServeCommand;\n /** Injected so tests (and --yes) don't need a real TTY. */\n confirm: (message: string) => Promise<boolean>;\n /** Injected for deterministic backup filenames in tests. */\n now?: () => number;\n /** Override for tests; defaults to the real HOME. */\n home?: string;\n osPlatform?: NodeJS.Platform;\n /** Override for tests; defaults to shelling out to the real `claude` binary. */\n claudeCli?: ClaudeCliAdapter;\n /** Override for tests; defaults to the real Codex CLI/app-bundled binary. */\n codexCli?: CodexCliAdapter;\n};\n\nfunction paths(home: string, osPlatform: NodeJS.Platform) {\n const claudeDesktop =\n osPlatform === \"darwin\"\n ? join(home, \"Library\", \"Application Support\", \"Claude\", \"claude_desktop_config.json\")\n : osPlatform === \"win32\"\n ? join(process.env.APPDATA || join(home, \"AppData\", \"Roaming\"), \"Claude\", \"claude_desktop_config.json\")\n : null; // Claude Desktop has no official Linux build as of this writing.\n return {\n claudeDesktop,\n cursor: join(home, \".cursor\", \"mcp.json\"),\n codex: join(home, \".codex\", \"config.toml\")\n };\n}\n\nasync function readJsonFile(path: string): Promise<{ data: Record<string, unknown>; existed: boolean }> {\n let raw: string;\n try {\n raw = await readFile(path, \"utf8\");\n } catch (err) {\n if (isErrnoException(err) && err.code === \"ENOENT\") {\n return { data: {}, existed: false };\n }\n throw new Error(`Could not read ${path}: ${errorMessage(err)}`, { cause: err });\n }\n\n try {\n const parsed = JSON.parse(raw) as unknown;\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n throw new Error(\"the top-level value must be a JSON object\");\n }\n return { data: parsed as Record<string, unknown>, existed: true };\n } catch (err) {\n throw new Error(`Could not parse ${path}: ${errorMessage(err)}. The file was left unchanged.`, { cause: err });\n }\n}\n\nfunction isErrnoException(value: unknown): value is NodeJS.ErrnoException {\n return value instanceof Error && \"code\" in value;\n}\n\nfunction errorMessage(value: unknown): string {\n return value instanceof Error ? value.message : String(value);\n}\n\n/**\n * A client counts as installed when its config *directory* exists — the file\n * itself is usually absent until the user first changes a setting, so keying\n * off the file would skip every fresh install. Keying off the directory also\n * stops us creating a stray ~/.cursor on a machine that has never had Cursor.\n */\nasync function clientDirExists(configPath: string): Promise<boolean> {\n try {\n return (await stat(dirname(configPath))).isDirectory();\n } catch {\n return false;\n }\n}\n\nasync function registerClaudeCode(serve: ServeCommand, cli: ClaudeCliAdapter): Promise<ClientRegistrationResult> {\n const present = await cli.detect();\n if (!present) {\n return { client: \"Claude Code\", action: \"skipped\", detail: \"`claude` not found on PATH.\" };\n }\n try {\n await cli.add(SERVER_NAME, serve);\n return {\n client: \"Claude Code\",\n action: \"registered\",\n detail: `Ran: claude mcp add ${SERVER_NAME} -- ${serve.command} ${serve.args.join(\" \")}`\n };\n } catch (err) {\n return {\n client: \"Claude Code\",\n action: \"error\",\n detail: `claude mcp add failed: ${err instanceof Error ? err.message : String(err)}`\n };\n }\n}\n\nfunction sameServeCommand(left: ServeCommand, right: ServeCommand): boolean {\n return left.command === right.command && JSON.stringify(left.args) === JSON.stringify(right.args);\n}\n\nasync function registerCodex(\n serve: ServeCommand,\n cli: CodexCliAdapter,\n configPath: string,\n confirm: (message: string) => Promise<boolean>\n): Promise<ClientRegistrationResult> {\n if (!(await cli.detect())) {\n if (!(await clientDirExists(configPath))) {\n return {\n client: \"Codex\",\n action: \"skipped\",\n detail: `Not installed (no Codex CLI and no ${dirname(configPath)}).`\n };\n }\n return {\n client: \"Codex\",\n action: \"printed\",\n detail:\n `Codex's CLI was not found. Add this to ${configPath}:\\n${codexBlock(serve)}` +\n `Then fully quit and reopen Codex.`\n };\n }\n\n let existing: CodexServerRegistration | null;\n try {\n existing = await cli.get(SERVER_NAME);\n } catch (err) {\n return { client: \"Codex\", action: \"error\", detail: `Could not inspect Codex MCP settings: ${errorMessage(err)}` };\n }\n\n if (existing?.serve && sameServeCommand(existing.serve, serve)) {\n return { client: \"Codex\", action: \"skipped\", detail: \"Already registered.\" };\n }\n if (existing && !existing.serve) {\n return {\n client: \"Codex\",\n action: \"error\",\n detail: `A non-stdio or unrecognised \"${SERVER_NAME}\" entry already exists. It was left unchanged.`\n };\n }\n\n const verb = existing ? \"replace its existing LLMnesia MCP registration\" : \"register the LLMnesia MCP server\";\n const ok = await confirm(\n `Codex: ${verb}?\\n` +\n `codex mcp add ${SERVER_NAME} -- ${serve.command} ${serve.args.join(\" \")}`\n );\n if (!ok) {\n return { client: \"Codex\", action: \"declined\", detail: \"Skipped by user.\" };\n }\n\n if (existing) {\n try {\n await cli.remove(SERVER_NAME);\n } catch (err) {\n return { client: \"Codex\", action: \"error\", detail: `Could not remove the old registration: ${errorMessage(err)}` };\n }\n }\n\n try {\n await cli.add(SERVER_NAME, serve);\n } catch (err) {\n if (existing?.serve) {\n try {\n await cli.add(SERVER_NAME, existing.serve);\n } catch (restoreErr) {\n return {\n client: \"Codex\",\n action: \"error\",\n detail: `Registration failed (${errorMessage(err)}) and restoring the previous entry also failed (${errorMessage(restoreErr)}).`\n };\n }\n }\n return { client: \"Codex\", action: \"error\", detail: `codex mcp add failed: ${errorMessage(err)}` };\n }\n\n return {\n client: \"Codex\",\n action: \"registered\",\n detail: `Ran: codex mcp add ${SERVER_NAME} -- ${serve.command} ${serve.args.join(\" \")}`\n };\n}\n\n/** Detect -> show -> confirm -> back up -> write, for a JSON `mcpServers`-shaped client config. */\nasync function registerJsonClient(\n clientLabel: string,\n configPath: string,\n serve: ServeCommand,\n confirm: (message: string) => Promise<boolean>,\n now: () => number\n): Promise<ClientRegistrationResult> {\n if (!(await clientDirExists(configPath))) {\n return {\n client: clientLabel,\n action: \"skipped\",\n detail: `Not installed (no ${dirname(configPath)}). Re-run install after setting it up.`\n };\n }\n let data: Record<string, unknown>;\n let existed: boolean;\n try {\n ({ data, existed } = await readJsonFile(configPath));\n } catch (err) {\n return { client: clientLabel, action: \"error\", detail: errorMessage(err) };\n }\n const servers = (data.mcpServers && typeof data.mcpServers === \"object\" ? data.mcpServers : {}) as Record<\n string,\n unknown\n >;\n const already = servers[SERVER_NAME];\n const nextEntry = { command: serve.command, args: serve.args };\n if (already && JSON.stringify(already) === JSON.stringify(nextEntry)) {\n return { client: clientLabel, action: \"skipped\", detail: `Already registered at ${configPath}.` };\n }\n\n const preview = JSON.stringify({ mcpServers: { ...servers, [SERVER_NAME]: nextEntry } }, null, 2);\n const message = existed\n ? `${clientLabel}: update ${configPath} to add the \"${SERVER_NAME}\" MCP server?\\n${preview}`\n : `${clientLabel}: create ${configPath} with the \"${SERVER_NAME}\" MCP server?\\n${preview}`;\n const ok = await confirm(message);\n if (!ok) {\n return { client: clientLabel, action: \"declined\", detail: `Skipped by user. Config: ${configPath}` };\n }\n\n if (existed) {\n const backupPath = `${configPath}.bak-${now()}`;\n await writeFile(backupPath, JSON.stringify(data, null, 2), \"utf8\");\n }\n const nextData = { ...data, mcpServers: { ...servers, [SERVER_NAME]: nextEntry } };\n await writeFile(configPath, `${JSON.stringify(nextData, null, 2)}\\n`, \"utf8\");\n return { client: clientLabel, action: \"registered\", detail: `Wrote ${configPath}.` };\n}\n\nfunction codexBlock(serve: ServeCommand): string {\n // JSON string escaping is compatible with TOML basic strings and safely\n // handles Windows backslashes, quotes, and control characters in paths.\n const argsToml = serve.args.map((a) => JSON.stringify(a)).join(\", \");\n return (\n `[mcp_servers.${SERVER_NAME}]\\n` +\n `command = ${JSON.stringify(serve.command)}\\n` +\n `args = [${argsToml}]\\n`\n );\n}\n\nfunction genericBlock(serve: ServeCommand): string {\n return JSON.stringify({ mcpServers: { [SERVER_NAME]: { command: serve.command, args: serve.args } } }, null, 2);\n}\n\n/**\n * Register (or print instructions for) the LLMnesia MCP server across every\n * client the board's matrix covers. Never throws for an individual client's\n * absence — a client just not being installed is not an error.\n */\nexport async function registerClients(options: RegisterClientsOptions): Promise<ClientRegistrationResult[]> {\n const home = options.home ?? homedir();\n const osPlatform = options.osPlatform ?? platform();\n const now = options.now ?? (() => Date.now());\n const { claudeDesktop, cursor, codex } = paths(home, osPlatform);\n\n const results: ClientRegistrationResult[] = [];\n\n results.push(await registerClaudeCode(options.serve, options.claudeCli ?? realClaudeCli));\n\n if (claudeDesktop) {\n results.push(await registerJsonClient(\"Claude Desktop\", claudeDesktop, options.serve, options.confirm, now));\n }\n\n results.push(await registerJsonClient(\"Cursor\", cursor, options.serve, options.confirm, now));\n\n results.push(await registerCodex(options.serve, options.codexCli ?? realCodexCli, codex, options.confirm));\n\n results.push({\n client: \"Other MCP clients (Windsurf, Zed, LM Studio, ...)\",\n action: \"printed\",\n detail: `Any client that accepts a stdio command+args block can use:\\n${genericBlock(options.serve)}`\n });\n\n return results;\n}\n\nasync function unregisterClaudeCode(cli: ClaudeCliAdapter): Promise<ClientRegistrationResult> {\n const present = await cli.detect();\n if (!present) {\n return { client: \"Claude Code\", action: \"skipped\", detail: \"`claude` not found on PATH.\" };\n }\n try {\n await cli.remove(SERVER_NAME);\n return { client: \"Claude Code\", action: \"registered\", detail: `Ran: claude mcp remove ${SERVER_NAME}` };\n } catch (err) {\n return {\n client: \"Claude Code\",\n action: \"error\",\n detail: `claude mcp remove failed (may already be unregistered): ${err instanceof Error ? err.message : String(err)}`\n };\n }\n}\n\nasync function unregisterCodex(cli: CodexCliAdapter): Promise<ClientRegistrationResult> {\n if (!(await cli.detect())) {\n return { client: \"Codex\", action: \"skipped\", detail: \"`codex` not found; no automatic registration to remove.\" };\n }\n try {\n const existing = await cli.get(SERVER_NAME);\n if (!existing) {\n return { client: \"Codex\", action: \"skipped\", detail: \"Not registered.\" };\n }\n await cli.remove(SERVER_NAME);\n return { client: \"Codex\", action: \"registered\", detail: `Ran: codex mcp remove ${SERVER_NAME}` };\n } catch (err) {\n return { client: \"Codex\", action: \"error\", detail: `codex mcp remove failed: ${errorMessage(err)}` };\n }\n}\n\nasync function unregisterJsonClient(\n clientLabel: string,\n configPath: string,\n now: () => number\n): Promise<ClientRegistrationResult> {\n let data: Record<string, unknown>;\n let existed: boolean;\n try {\n ({ data, existed } = await readJsonFile(configPath));\n } catch (err) {\n return { client: clientLabel, action: \"error\", detail: errorMessage(err) };\n }\n if (!existed) {\n return { client: clientLabel, action: \"skipped\", detail: `No ${configPath}.` };\n }\n const servers = (data.mcpServers && typeof data.mcpServers === \"object\" ? data.mcpServers : {}) as Record<\n string,\n unknown\n >;\n if (!(SERVER_NAME in servers)) {\n return { client: clientLabel, action: \"skipped\", detail: `Not registered in ${configPath}.` };\n }\n // Symmetric with registration: any write to a file we do not own gets a\n // backup first, removals included.\n const backupPath = `${configPath}.bak-${now()}`;\n await writeFile(backupPath, JSON.stringify(data, null, 2), \"utf8\");\n const { [SERVER_NAME]: _removed, ...rest } = servers;\n const nextData = { ...data, mcpServers: rest };\n await writeFile(configPath, `${JSON.stringify(nextData, null, 2)}\\n`, \"utf8\");\n return { client: clientLabel, action: \"registered\", detail: `Removed from ${configPath} (backup: ${backupPath}).` };\n}\n\n/**\n * Reverse of {@link registerClients} for the clients we can safely auto-edit\n * (Claude Code and Codex via their CLIs, Claude Desktop/Cursor JSON). Generic\n * print-only clients were never auto-written, so there is nothing to remove.\n */\nexport async function unregisterClients(\n options: {\n home?: string;\n osPlatform?: NodeJS.Platform;\n claudeCli?: ClaudeCliAdapter;\n codexCli?: CodexCliAdapter;\n /** Injected for deterministic backup filenames in tests. */\n now?: () => number;\n } = {}\n): Promise<ClientRegistrationResult[]> {\n const home = options.home ?? homedir();\n const osPlatform = options.osPlatform ?? platform();\n const now = options.now ?? (() => Date.now());\n const { claudeDesktop, cursor } = paths(home, osPlatform);\n\n const results: ClientRegistrationResult[] = [await unregisterClaudeCode(options.claudeCli ?? realClaudeCli)];\n if (claudeDesktop) {\n results.push(await unregisterJsonClient(\"Claude Desktop\", claudeDesktop, now));\n }\n results.push(await unregisterJsonClient(\"Cursor\", cursor, now));\n results.push(await unregisterCodex(options.codexCli ?? realCodexCli));\n results.push({\n client: \"Other MCP clients\",\n action: \"skipped\",\n detail: \"These were only shown as copy-paste blocks, never auto-edited — remove the block yourself if you added it.\"\n });\n return results;\n}\n","// `llmnesia-mcp doctor` — the biggest support-load reducer per\n// docs/MCP_INSTALLER_BOARD.md: a single command that tells a user (or whoever\n// is helping them) exactly what part of the pipeline is missing, instead of\n// them guessing between \"the extension,\" \"the native host,\" and \"the MCP\n// client config.\"\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { delimiter, dirname, isAbsolute, join, sep } from \"node:path\";\nimport { homedir, platform } from \"node:os\";\nimport { HOST_NAME, posixBrowsers } from \"@llmnesia/claude-code-host\";\nimport { resolveCorpusDir } from \"./config.js\";\nimport { Corpus } from \"./corpus.js\";\nimport { SERVER_NAME, realClaudeCli, type ClaudeCliAdapter } from \"./clientRegistration.js\";\nimport { runtimeBinDir } from \"./runtimeInstall.js\";\n\nexport type DoctorCheck = {\n name: string;\n status: \"ok\" | \"warn\" | \"missing\";\n detail: string;\n};\n\nexport type DoctorReport = {\n checks: DoctorCheck[];\n /**\n * True when nothing is actually broken — i.e. no check is \"missing\".\n * Deliberately not \"every check is ok\": several checks are informational\n * warnings that are correct on a healthy machine (a client you don't have\n * installed, the restart reminder), so requiring all-ok would make this\n * permanently false and the command's exit code meaningless.\n */\n allOk: boolean;\n};\n\nexport type RunDoctorOptions = {\n /** Override for tests; defaults to the real HOME. */\n home?: string;\n osPlatform?: NodeJS.Platform;\n /** Override for tests; defaults to the normal corpus-path resolution. */\n corpusRoot?: string;\n /** Override for tests; defaults to shelling out to the real `claude` binary. */\n claudeCli?: ClaudeCliAdapter;\n};\n\nfunction checkNativeHostManifest(home: string, osPlatform: NodeJS.Platform): DoctorCheck {\n if (osPlatform === \"win32\") {\n const manifestPath = join(home, \".llmnesia\", `${HOST_NAME}.json`);\n if (existsSync(manifestPath)) {\n return {\n name: \"Native messaging host\",\n status: \"ok\",\n detail: `Manifest present at ${manifestPath}. (This confirms the file the installer writes, not the registry key independently — re-run \"install\" if a browser still can't find it.)`\n };\n }\n return {\n name: \"Native messaging host\",\n status: \"missing\",\n detail: `No manifest at ${manifestPath}. Run: llmnesia-mcp install`\n };\n }\n const found: string[] = [];\n for (const [label, browserDir] of posixBrowsers(home, osPlatform)) {\n if (!existsSync(browserDir)) {\n continue;\n }\n const manifestPath = join(browserDir, \"NativeMessagingHosts\", `${HOST_NAME}.json`);\n if (existsSync(manifestPath)) {\n found.push(label);\n }\n }\n if (found.length > 0) {\n return { name: \"Native messaging host\", status: \"ok\", detail: `Registered for: ${found.join(\", \")}.` };\n }\n return {\n name: \"Native messaging host\",\n status: \"missing\",\n detail: \"No browser has the native-messaging manifest installed. Run: llmnesia-mcp install\"\n };\n}\n\nasync function checkCorpus(home: string, corpusRoot: string | undefined): Promise<DoctorCheck> {\n const configPath = join(home, \".llmnesia\", \"config.json\");\n if (!corpusRoot && !existsSync(configPath)) {\n return {\n name: \"Corpus config\",\n status: \"missing\",\n detail: `No ${configPath}. Run: llmnesia-mcp install`\n };\n }\n const root = corpusRoot ?? resolveCorpusDir();\n if (!existsSync(root)) {\n // A warning, not a failure: this is the expected state immediately after a\n // correct install, before the browser has synced anything across.\n return {\n name: \"Corpus\",\n status: \"warn\",\n detail: `Config points at ${root}, but that directory doesn't exist yet. It's created on first sync from your browser — open a chat and wait ~a minute. Normal right after installing.`\n };\n }\n try {\n const corpus = new Corpus(root);\n const stats = await corpus.stats();\n if (stats.conversationCount === 0) {\n return {\n name: \"Corpus\",\n status: \"warn\",\n detail: `Corpus at ${root} exists but is empty. It fills in as you chat, or on the browser extension's first backfill sync.`\n };\n }\n return {\n name: \"Corpus\",\n status: \"ok\",\n detail: `${stats.conversationCount} conversation(s), ${stats.messageCount} message(s) at ${root}.`\n };\n } catch (err) {\n return {\n name: \"Corpus\",\n status: \"warn\",\n detail: `Couldn't read corpus at ${root}: ${err instanceof Error ? err.message : String(err)}`\n };\n }\n}\n\n/**\n * Whether a registered spawn command could actually be executed, and why not.\n *\n * A config that *names* this server is not the same as a config that can start\n * it — the failure this exists to catch is a registration pointing at a bare\n * `llmnesia-mcp`, or at a path under a wiped npx cache. Reporting such an entry\n * as healthy sends the user looking everywhere except the actual fault.\n *\n * Returns null when the command looks runnable.\n */\nexport function commandProblem(command: string, args: string[] = []): string | null {\n const looksLikePath = isAbsolute(command) || command.includes(sep) || command.includes(\"/\");\n if (looksLikePath) {\n if (!existsSync(command)) {\n return `its command does not exist: ${command}`;\n }\n } else if (!resolveOnPath(command)) {\n // GUI-launched clients inherit a minimal PATH, so even a command this\n // process can find may be unreachable for them. Not-found here is a\n // definite failure; found is only \"probably fine\".\n return (\n `its command \"${command}\" is not on PATH. GUI clients get a minimal PATH ` +\n `(no nvm, no homebrew), so a bare command name is unreliable even when your ` +\n `shell can find it. Re-run: llmnesia-mcp install`\n );\n }\n\n // `node /path/to/cli.js serve` — the script matters as much as the binary.\n const script = args.find((a) => a.endsWith(\".js\") || a.endsWith(\".mjs\"));\n if (script && (isAbsolute(script) || script.includes(sep)) && !existsSync(script)) {\n return `its script does not exist: ${script}. Re-run: llmnesia-mcp install`;\n }\n return null;\n}\n\nfunction resolveOnPath(command: string): boolean {\n const exts = process.platform === \"win32\" ? (process.env.PATHEXT ?? \".EXE;.CMD;.BAT\").split(\";\") : [\"\"];\n for (const dir of (process.env.PATH ?? \"\").split(delimiter)) {\n if (!dir) {\n continue;\n }\n for (const ext of exts) {\n if (existsSync(join(dir, command + ext))) {\n return true;\n }\n }\n }\n return false;\n}\n\nfunction checkRuntime(home: string): DoctorCheck {\n const entry = join(runtimeBinDir(home), \"cli.js\");\n if (existsSync(entry)) {\n return { name: \"MCP server runtime\", status: \"ok\", detail: `Installed at ${entry}.` };\n }\n return {\n name: \"MCP server runtime\",\n status: \"missing\",\n detail: `No runtime at ${entry}. Clients spawn this copy, so registration alone is not enough. Run: llmnesia-mcp install`\n };\n}\n\nasync function checkJsonClient(label: string, configPath: string): Promise<DoctorCheck> {\n // Same \"installed\" test registration uses: the directory, not the file. The\n // file is absent until the user first changes a setting, so a fresh install\n // must read as installed-but-unregistered, not as absent.\n if (!existsSync(dirname(configPath))) {\n return { name: label, status: \"warn\", detail: `Not installed (no ${dirname(configPath)}).` };\n }\n if (!existsSync(configPath)) {\n return {\n name: label,\n status: \"missing\",\n detail: `${label} is installed but has no MCP config yet. Run: llmnesia-mcp install`\n };\n }\n try {\n const data = JSON.parse(readFileSync(configPath, \"utf8\")) as { mcpServers?: Record<string, unknown> };\n const entry = data.mcpServers?.[SERVER_NAME] as { command?: unknown; args?: unknown } | undefined;\n if (!entry) {\n return {\n name: label,\n status: \"missing\",\n detail: `${label} is installed but not registered. Run: llmnesia-mcp install`\n };\n }\n if (typeof entry.command !== \"string\") {\n return { name: label, status: \"missing\", detail: `Registered in ${configPath} but the entry has no command. Run: llmnesia-mcp install` };\n }\n const args = Array.isArray(entry.args) ? entry.args.filter((a): a is string => typeof a === \"string\") : [];\n const problem = commandProblem(entry.command, args);\n if (problem) {\n return { name: label, status: \"missing\", detail: `Registered in ${configPath}, but ${problem}` };\n }\n return { name: label, status: \"ok\", detail: `Registered in ${configPath} and its command resolves.` };\n } catch (err) {\n return {\n name: label,\n status: \"warn\",\n detail: `Found ${configPath} but couldn't parse it: ${err instanceof Error ? err.message : String(err)}`\n };\n }\n}\n\nasync function checkClaudeCode(cli: ClaudeCliAdapter): Promise<DoctorCheck> {\n if (!(await cli.detect())) {\n return {\n name: \"Claude Code\",\n status: \"warn\",\n detail: \"`claude` not found on PATH — not installed, or not registered here yet.\"\n };\n }\n const { execFile } = await import(\"node:child_process\");\n const { promisify } = await import(\"node:util\");\n const execFileAsync = promisify(execFile);\n try {\n const { stdout } = await execFileAsync(\"claude\", [\"mcp\", \"list\"]);\n const line = stdout.split(\"\\n\").find((l) => l.trimStart().startsWith(`${SERVER_NAME}:`));\n if (!line) {\n return { name: \"Claude Code\", status: \"missing\", detail: \"`claude` found but not registered. Run: llmnesia-mcp install\" };\n }\n // `claude mcp list` health-checks each server, so its own verdict beats\n // anything we could infer about the command.\n if (/✗|failed|error/i.test(line)) {\n return { name: \"Claude Code\", status: \"missing\", detail: `Registered but not connecting — ${line.trim()}` };\n }\n return { name: \"Claude Code\", status: \"ok\", detail: `Registered: ${line.trim()}` };\n } catch (err) {\n return {\n name: \"Claude Code\",\n status: \"warn\",\n detail: `\\`claude mcp list\\` failed: ${err instanceof Error ? err.message : String(err)}`\n };\n }\n}\n\nfunction checkCodex(home: string): DoctorCheck {\n const configPath = join(home, \".codex\", \"config.toml\");\n if (!existsSync(configPath)) {\n return { name: \"Codex\", status: \"warn\", detail: `Not installed (no ${configPath}), or never configured.` };\n }\n let text: string;\n try {\n text = readFileSync(configPath, \"utf8\");\n } catch (err) {\n // An unreadable config is one client's problem, not a reason to lose the\n // whole report — doctor exists precisely for machines in a bad state.\n return {\n name: \"Codex\",\n status: \"warn\",\n detail: `Found ${configPath} but couldn't read it: ${err instanceof Error ? err.message : String(err)}`\n };\n }\n if (text.includes(`mcp_servers.${SERVER_NAME}`)) {\n return { name: \"Codex\", status: \"ok\", detail: `Found in ${configPath}.` };\n }\n return {\n name: \"Codex\",\n status: \"missing\",\n detail: `Codex is installed but not configured. Run: llmnesia-mcp install (it uses Codex's CLI when available).`\n };\n}\n\n/** Run every diagnostic check and return a structured report. Never throws. */\nexport async function runDoctor(options: RunDoctorOptions = {}): Promise<DoctorReport> {\n const home = options.home ?? homedir();\n const osPlatform = options.osPlatform ?? platform();\n const claudeCli = options.claudeCli ?? realClaudeCli;\n const claudeDesktopPath =\n osPlatform === \"darwin\"\n ? join(home, \"Library\", \"Application Support\", \"Claude\", \"claude_desktop_config.json\")\n : osPlatform === \"win32\"\n ? join(process.env.APPDATA || join(home, \"AppData\", \"Roaming\"), \"Claude\", \"claude_desktop_config.json\")\n : null;\n\n // Every check is isolated: one unreadable file or unexpected error must not\n // cost the user the rest of the report, which is the whole point of doctor.\n const checks: DoctorCheck[] = [];\n const run = async (name: string, fn: () => DoctorCheck | Promise<DoctorCheck>): Promise<void> => {\n try {\n checks.push(await fn());\n } catch (err) {\n checks.push({\n name,\n status: \"warn\",\n detail: `Check failed unexpectedly: ${err instanceof Error ? err.message : String(err)}`\n });\n }\n };\n\n await run(\"Native messaging host\", () => checkNativeHostManifest(home, osPlatform));\n await run(\"MCP server runtime\", () => checkRuntime(home));\n await run(\"Corpus\", () => checkCorpus(home, options.corpusRoot));\n if (claudeDesktopPath) {\n await run(\"Claude Desktop\", () => checkJsonClient(\"Claude Desktop\", claudeDesktopPath));\n }\n await run(\"Cursor\", () => checkJsonClient(\"Cursor\", join(home, \".cursor\", \"mcp.json\")));\n await run(\"Claude Code\", () => checkClaudeCode(claudeCli));\n await run(\"Codex\", () => checkCodex(home));\n\n checks.push({\n name: \"Reminder\",\n status: \"warn\",\n detail:\n \"This can't detect whether you've restarted your browser or MCP client since installing — \" +\n \"a fully quit-and-reopen is required for any of the above to take effect.\"\n });\n\n return { checks, allOk: checks.every((c) => c.status !== \"missing\") };\n}\n\nexport function formatDoctorReport(report: DoctorReport): string {\n const icon = { ok: \"✓\", warn: \"•\", missing: \"✗\" } as const;\n return report.checks.map((c) => `${icon[c.status]} ${c.name}: ${c.detail}`).join(\"\\n\");\n}\n","// Gives the MCP server a durable home on disk, so client configs can point at\n// an absolute path instead of a bare `llmnesia-mcp` on PATH.\n//\n// Why this exists at all: the advertised entry point is\n// `npx @llmnesia/mcp install`, and npx unpacks the package into a\n// hash-derived cache (~/.npm/_npx/<hash>/) that is on PATH only for the\n// duration of that one command and is wiped by `npm cache clean`. Registering\n// `{ command: \"llmnesia-mcp\" }` from there produces a config that cannot spawn\n// anything the moment install exits.\n//\n// A global `npm i -g` does not fix it either. On the common nvm setup the bin\n// lands in ~/.nvm/versions/node/<v>/bin, and GUI-launched clients (Claude\n// Desktop, Cursor) inherit launchd's PATH — /usr/bin:/bin:/usr/sbin:/sbin —\n// where neither the bin nor `node` itself resolves.\n//\n// So `install` copies dist/ to ~/.llmnesia/bin and registers the absolute node\n// binary plus the absolute script path. No PATH lookup happens at spawn time,\n// which is also what a hand-written working config looks like.\n\nimport { cp, mkdir, readdir, rm, writeFile } from \"node:fs/promises\";\nimport { existsSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { ServeCommand } from \"./clientRegistration.js\";\n\nexport type RuntimeInstallResult = {\n /** Where the runtime now lives (~/.llmnesia/bin). */\n binDir: string;\n /** Absolute path to the copied CLI entry point. */\n entry: string;\n /** The spawn command to register with clients — absolute, PATH-independent. */\n serve: ServeCommand;\n /** Which directory the copy came from. */\n sourceDir: string;\n /** The node binary baked into `serve.command`. */\n nodePath: string;\n};\n\nexport type InstallRuntimeOptions = {\n /** Override for tests; defaults to the real HOME. */\n home?: string;\n /** Override for tests; defaults to the dist/ directory this module runs from. */\n sourceDir?: string;\n /** Override for tests; defaults to the node binary running this process. */\n nodePath?: string;\n};\n\n/** The directory the running bundle lives in — `dist/` in a published install. */\nfunction defaultSourceDir(): string {\n return dirname(fileURLToPath(import.meta.url));\n}\n\nexport function runtimeBinDir(home: string = homedir()): string {\n return join(home, \".llmnesia\", \"bin\");\n}\n\n/**\n * Copy the built runtime into ~/.llmnesia/bin and return the absolute spawn\n * command clients should be registered with.\n *\n * The destination is wiped first: chunk filenames are content-hashed, so\n * upgrading in place would otherwise accumulate orphaned chunks from every\n * previous version. Only ~/.llmnesia/bin is removed — the sibling corpus/ and\n * config.json are never touched.\n */\nexport async function installRuntime(options: InstallRuntimeOptions = {}): Promise<RuntimeInstallResult> {\n const home = options.home ?? homedir();\n const sourceDir = options.sourceDir ?? defaultSourceDir();\n const nodePath = options.nodePath ?? process.execPath;\n const binDir = runtimeBinDir(home);\n\n const sourceEntry = join(sourceDir, \"cli.js\");\n if (!existsSync(sourceEntry)) {\n // Running from source (tsx src/cli.ts) rather than a build. Fail loudly:\n // silently registering a path that does not exist is the bug this module\n // was written to remove.\n throw new Error(\n `Cannot locate the built runtime: no cli.js in ${sourceDir}. ` +\n `Run this from an installed package (npx @llmnesia/mcp install) or build first (npm run build).`\n );\n }\n\n await rm(binDir, { recursive: true, force: true });\n await mkdir(binDir, { recursive: true });\n for (const name of await readdir(sourceDir)) {\n await cp(join(sourceDir, name), join(binDir, name), { recursive: true });\n }\n\n // The bundle is ESM, and a bare .js file is only ESM because the package.json\n // above it says so. Copied out of the package that marker is gone and node\n // parses the same file as CommonJS, failing on the first `import`. So the\n // copy carries its own marker.\n await writeFile(\n join(binDir, \"package.json\"),\n `${JSON.stringify(\n {\n name: \"llmnesia-mcp-runtime\",\n private: true,\n type: \"module\",\n comment: \"Installed copy of @llmnesia/mcp's dist. Managed by `llmnesia-mcp install`; edits are lost on reinstall.\"\n },\n null,\n 2\n )}\\n`,\n \"utf8\"\n );\n\n const entry = join(binDir, \"cli.js\");\n return {\n binDir,\n entry,\n serve: { command: nodePath, args: [entry, \"serve\"] },\n sourceDir,\n nodePath\n };\n}\n\n/** Remove the copied runtime. Never touches the corpus or config.json. */\nexport async function uninstallRuntime(home: string = homedir()): Promise<string | null> {\n const binDir = runtimeBinDir(home);\n if (!existsSync(binDir)) {\n return null;\n }\n await rm(binDir, { recursive: true, force: true });\n return binDir;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,WAAO,UAAU;AACjB,UAAM,OAAO;AAEb,QAAI,KAAK,UAAQ,IAAI;AAErB,aAAS,aAAc,MAAM,SAAS;AACpC,UAAI,UAAU,QAAQ,YAAY,SAChC,QAAQ,UAAU,QAAQ,IAAI;AAEhC,UAAI,CAAC,SAAS;AACZ,eAAO;AAAA,MACT;A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,GAAG,CAAC;AAAA,CAAI;AACnF,UAAQ,WAAW;AACrB,CAAC;","names":["stat","stat","resolve","isWindows","resolve","platform","cp","cp","resolveCorpusDir","base","isWindows","stat","readdir","sysPath","stat","basename","stat","lstat","lstat","stat","main","rawEmitter","listener","basename","dirname","newStats","closer","resolve","realpath","stats","relative","DOUBLE_SLASH_RE","testString","paths","readdir","path","stats","stat","now","execFile","readFile","stat","writeFile","homedir","platform","dirname","join","promisify","execFileAsync","resolve","crossSpawn","home","osPlatform","existsSync","dirname","isAbsolute","join","homedir","platform","mkdir","readdir","rm","writeFile","homedir","dirname","join","fileURLToPath","home","home","osPlatform","join","existsSync","isAbsolute","dirname","execFile","promisify","execFileAsync","homedir","platform","resolve"]}