@visulima/cerebro 3.0.0-alpha.8 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +610 -0
- package/LICENSE.md +1295 -3950
- package/README.md +182 -2
- package/dist/commands/completion-command.d.ts +6 -5
- package/dist/commands/completion-command.js +5 -203
- package/dist/commands/help-command.d.ts +10 -9
- package/dist/commands/help-command.js +1 -3
- package/dist/commands/readme-command.d.ts +6 -5
- package/dist/commands/readme-command.js +32 -330
- package/dist/commands/version-command.d.ts +4 -3
- package/dist/commands/version-command.js +1 -18
- package/dist/index.d.ts +516 -95
- package/dist/index.js +1 -7
- package/dist/logger/create-pail-logger.d.ts +770 -8
- package/dist/logger/create-pail-logger.js +1 -34
- package/dist/packem_chunks/has-new-version.js +1 -259
- package/dist/packem_shared/Cerebro-Czc4t-75.js +4 -0
- package/dist/packem_shared/VERBOSITY_DEBUG-XPultrIA.js +1 -0
- package/dist/packem_shared/VisulimaError-C90oeIMu.js +76 -0
- package/dist/packem_shared/VisulimaError-DTMgXonA-CzaryRgZ.js +1 -0
- package/dist/packem_shared/cerebro-error-BjBcYVRO.js +1 -0
- package/dist/packem_shared/command.d-DbhtfXF4.d.ts +639 -0
- package/dist/packem_shared/index-B7-8G-9s.js +29 -0
- package/dist/packem_shared/index.d-BL4NtVR3.d.ts +127 -0
- package/dist/packem_shared/lazyNamed-DMUm8mZe.js +1 -0
- package/dist/packem_shared/renderError-B3ePOoBG-BmZlyMcr.js +25 -0
- package/dist/packem_shared/runtime-process-Dmz0vCJy.js +1 -0
- package/dist/packem_shared/split-by-case-Dbpgd7rf.js +1 -0
- package/dist/plugins/error-handler-plugin.d.ts +21 -19
- package/dist/plugins/error-handler-plugin.js +1 -636
- package/dist/plugins/runtime-version-check-plugin.d.ts +22 -20
- package/dist/plugins/runtime-version-check-plugin.js +1 -77
- package/dist/plugins/update-notifier/update-notifier-plugin.d.ts +28 -8
- package/dist/plugins/update-notifier/update-notifier-plugin.js +1 -517
- package/dist/util/general/compile-cache.d.ts +41 -0
- package/dist/util/general/compile-cache.js +1 -0
- package/dist/util/general/heap-tuning.d.ts +18 -0
- package/dist/util/general/heap-tuning.js +1 -0
- package/package.json +33 -28
- package/dist/cli.d.ts +0 -203
- package/dist/constants.d.ts +0 -29
- package/dist/default-env.d.ts +0 -7
- package/dist/default-options.d.ts +0 -3
- package/dist/empty-toolbox.d.ts +0 -15
- package/dist/errors/cerebro-error.d.ts +0 -10
- package/dist/errors/command-not-found-error.d.ts +0 -9
- package/dist/errors/command-validation-error.d.ts +0 -10
- package/dist/errors/completion-error.d.ts +0 -9
- package/dist/errors/conflicting-options-error.d.ts +0 -10
- package/dist/errors/plugin-error.d.ts +0 -9
- package/dist/errors/update-notifier-error.d.ts +0 -7
- package/dist/packem_shared/Cerebro-C2mnCyQf.js +0 -3313
- package/dist/packem_shared/VERBOSITY_QUIET-Dp46zlLW.js +0 -10
- package/dist/packem_shared/VisulimaError-DA7QsCxH.js +0 -34
- package/dist/packem_shared/cerebro-error-GmJ3jN7Q.js +0 -16
- package/dist/packem_shared/help-command-BY7rQUvM.js +0 -249
- package/dist/packem_shared/index-C2-8b3A4.js +0 -259
- package/dist/packem_shared/runtime-process-B6ZplyWn.js +0 -187
- package/dist/plugin-manager.d.ts +0 -53
- package/dist/plugins/update-notifier/cache.d.ts +0 -11
- package/dist/plugins/update-notifier/get-distribution-version.d.ts +0 -2
- package/dist/plugins/update-notifier/has-new-version.d.ts +0 -14
- package/dist/types/cli.d.ts +0 -102
- package/dist/types/command-line-usage.d.ts +0 -37
- package/dist/types/command.d.ts +0 -136
- package/dist/types/option-types.d.ts +0 -83
- package/dist/types/options.d.ts +0 -4
- package/dist/types/plugin.d.ts +0 -53
- package/dist/types/toolbox.d.ts +0 -96
- package/dist/util/arg-processing/get-boolean-values.d.ts +0 -7
- package/dist/util/arg-processing/get-parameter-option.d.ts +0 -7
- package/dist/util/arg-processing/map-option-type-label.d.ts +0 -3
- package/dist/util/arg-processing/option-is-boolean.d.ts +0 -9
- package/dist/util/arg-processing/remove-boolean-values.d.ts +0 -9
- package/dist/util/command-line-commands.d.ts +0 -10
- package/dist/util/command-line-usage/get-terminal-width.d.ts +0 -7
- package/dist/util/command-line-usage/index.d.ts +0 -3
- package/dist/util/command-line-usage/section/base-section.d.ts +0 -8
- package/dist/util/command-line-usage/section/content-section.d.ts +0 -65
- package/dist/util/command-line-usage/section/option-list-section.d.ts +0 -44
- package/dist/util/command-processing/command-processor.d.ts +0 -37
- package/dist/util/command-processing/command-validation.d.ts +0 -17
- package/dist/util/command-processing/nested-command-parser.d.ts +0 -25
- package/dist/util/command-processing/option-processor.d.ts +0 -44
- package/dist/util/data-processing/list-missing-arguments.d.ts +0 -15
- package/dist/util/data-processing/merge-arguments.d.ts +0 -7
- package/dist/util/general/find-alternatives.d.ts +0 -8
- package/dist/util/general/hide-bin.d.ts +0 -2
- package/dist/util/general/parse-raw-command.d.ts +0 -7
- package/dist/util/general/register-exception-handler.d.ts +0 -9
- package/dist/util/general/runtime-process.d.ts +0 -65
- package/dist/util/general/semver-gt.d.ts +0 -2
- package/dist/util/general/validate-input.d.ts +0 -24
- package/dist/util/process-env-variables.d.ts +0 -9
- package/dist/util/security.d.ts +0 -58
- package/dist/util/text-processing/template-format.d.ts +0 -5
|
@@ -1,34 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import MessageFormatterProcessor from '@visulima/pail/processor/message-formatter';
|
|
3
|
-
import { createPail } from '@visulima/pail/server';
|
|
4
|
-
import { VERBOSITY_DEBUG, VERBOSITY_QUIET } from '../packem_shared/VERBOSITY_QUIET-Dp46zlLW.js';
|
|
5
|
-
import { d as getEnv } from '../packem_shared/runtime-process-B6ZplyWn.js';
|
|
6
|
-
|
|
7
|
-
const createPailLogger = (options) => {
|
|
8
|
-
const cerebroLevelToPailLevel = {
|
|
9
|
-
16: "informational",
|
|
10
|
-
32: "informational",
|
|
11
|
-
64: "trace",
|
|
12
|
-
128: "debug",
|
|
13
|
-
256: "debug"
|
|
14
|
-
};
|
|
15
|
-
const processors = [new MessageFormatterProcessor()];
|
|
16
|
-
const env = getEnv();
|
|
17
|
-
const outputLevel = env.CEREBRO_OUTPUT_LEVEL;
|
|
18
|
-
if (outputLevel === String(128) || outputLevel === String(VERBOSITY_DEBUG)) {
|
|
19
|
-
processors.push(new CallerProcessor());
|
|
20
|
-
}
|
|
21
|
-
const envLogLevel = outputLevel && cerebroLevelToPailLevel[outputLevel] || "informational";
|
|
22
|
-
const loggerOptions = {
|
|
23
|
-
...options,
|
|
24
|
-
logLevel: options?.logLevel ?? envLogLevel,
|
|
25
|
-
processors: options?.processors ? [...processors, ...options.processors] : processors
|
|
26
|
-
};
|
|
27
|
-
const logger = createPail(loggerOptions);
|
|
28
|
-
if (outputLevel === String(VERBOSITY_QUIET)) {
|
|
29
|
-
logger.disable();
|
|
30
|
-
}
|
|
31
|
-
return logger;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export { createPailLogger as default };
|
|
1
|
+
import a from"@visulima/pail/processor/caller";import m from"@visulima/pail/processor/message-formatter";import{createPail as l}from"@visulima/pail/server";import{VERBOSITY_DEBUG as p,VERBOSITY_QUIET as E}from"../packem_shared/VERBOSITY_DEBUG-XPultrIA.js";import{c}from"../packem_shared/runtime-process-Dmz0vCJy.js";const d=o=>{const i={16:"informational",32:"informational",64:"trace",128:"debug",256:"debug"},t=[new m],r=c().CEREBRO_OUTPUT_LEVEL;(r===String(128)||r===String(p))&&t.push(new a);const n=(r&&i[r])??"informational",s={...o,logLevel:o?.logLevel??n,processors:o?.processors?[...t,...o.processors]:t},e=l(s);return r===String(E)&&e.disable(),e};export{d as default};
|
|
@@ -1,259 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
-
|
|
5
|
-
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
-
|
|
7
|
-
const __cjs_getBuiltinModule = (module) => {
|
|
8
|
-
// Check if we're in Node.js and version supports getBuiltinModule
|
|
9
|
-
if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
|
|
10
|
-
const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
|
|
11
|
-
// Node.js 20.16.0+ and 22.3.0+
|
|
12
|
-
if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
|
|
13
|
-
return __cjs_getProcess.getBuiltinModule(module);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
// Fallback to createRequire
|
|
17
|
-
return __cjs_require(module);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const {
|
|
21
|
-
existsSync,
|
|
22
|
-
readFileSync,
|
|
23
|
-
mkdirSync,
|
|
24
|
-
writeFileSync
|
|
25
|
-
} = __cjs_getBuiltinModule("node:fs");
|
|
26
|
-
import { findCacheDirSync } from '@visulima/find-cache-dir';
|
|
27
|
-
import { C as CerebroError } from '../packem_shared/cerebro-error-GmJ3jN7Q.js';
|
|
28
|
-
const {
|
|
29
|
-
get
|
|
30
|
-
} = __cjs_getBuiltinModule("node:https");
|
|
31
|
-
|
|
32
|
-
const semverGt = (version1, version2) => {
|
|
33
|
-
const v1Components = version1.split(".").map(Number);
|
|
34
|
-
const v2Components = version2.split(".").map(Number);
|
|
35
|
-
for (const [index, v1Component] of v1Components.entries()) {
|
|
36
|
-
if (v1Component > v2Components[index]) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
if (v1Component < v2Components[index]) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return false;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const DRIVE_LETTER_START_RE = /^[A-Z]:\//i;
|
|
47
|
-
const normalizeWindowsPath = (input = "") => {
|
|
48
|
-
if (!input) {
|
|
49
|
-
return input;
|
|
50
|
-
}
|
|
51
|
-
return input.replaceAll("\\", "/").replace(DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
52
|
-
};
|
|
53
|
-
const UNC_REGEX = /^[/\\]{2}/;
|
|
54
|
-
const IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i;
|
|
55
|
-
const DRIVE_LETTER_RE = /^[A-Z]:$/i;
|
|
56
|
-
const normalizeString = (path2, allowAboveRoot) => {
|
|
57
|
-
let result = "";
|
|
58
|
-
let lastSegmentLength = 0;
|
|
59
|
-
let lastSlash = -1;
|
|
60
|
-
let dots = 0;
|
|
61
|
-
let char;
|
|
62
|
-
for (let index = 0; index <= path2.length; ++index) {
|
|
63
|
-
if (index < path2.length) {
|
|
64
|
-
char = path2[index];
|
|
65
|
-
} else if (char === "/") {
|
|
66
|
-
break;
|
|
67
|
-
} else {
|
|
68
|
-
char = "/";
|
|
69
|
-
}
|
|
70
|
-
if (char === "/") {
|
|
71
|
-
if (lastSlash === index - 1 || dots === 1) ;
|
|
72
|
-
else if (dots === 2) {
|
|
73
|
-
if (result.length < 2 || lastSegmentLength !== 2 || !result.endsWith(".") || result.at(-2) !== ".") {
|
|
74
|
-
if (result.length > 2) {
|
|
75
|
-
const lastSlashIndex = result.lastIndexOf("/");
|
|
76
|
-
if (lastSlashIndex === -1) {
|
|
77
|
-
result = "";
|
|
78
|
-
lastSegmentLength = 0;
|
|
79
|
-
} else {
|
|
80
|
-
result = result.slice(0, lastSlashIndex);
|
|
81
|
-
lastSegmentLength = result.length - 1 - result.lastIndexOf("/");
|
|
82
|
-
}
|
|
83
|
-
lastSlash = index;
|
|
84
|
-
dots = 0;
|
|
85
|
-
continue;
|
|
86
|
-
} else if (result.length > 0) {
|
|
87
|
-
result = "";
|
|
88
|
-
lastSegmentLength = 0;
|
|
89
|
-
lastSlash = index;
|
|
90
|
-
dots = 0;
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (allowAboveRoot) {
|
|
95
|
-
result += result.length > 0 ? "/.." : "..";
|
|
96
|
-
lastSegmentLength = 2;
|
|
97
|
-
}
|
|
98
|
-
} else {
|
|
99
|
-
if (result.length > 0) {
|
|
100
|
-
result += `/${path2.slice(lastSlash + 1, index)}`;
|
|
101
|
-
} else {
|
|
102
|
-
result = path2.slice(lastSlash + 1, index);
|
|
103
|
-
}
|
|
104
|
-
lastSegmentLength = index - lastSlash - 1;
|
|
105
|
-
}
|
|
106
|
-
lastSlash = index;
|
|
107
|
-
dots = 0;
|
|
108
|
-
} else if (char === "." && dots !== -1) {
|
|
109
|
-
++dots;
|
|
110
|
-
} else {
|
|
111
|
-
dots = -1;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return result;
|
|
115
|
-
};
|
|
116
|
-
const isAbsolute = (path2) => IS_ABSOLUTE_RE.test(path2);
|
|
117
|
-
const normalize = function(path2) {
|
|
118
|
-
if (path2.length === 0) {
|
|
119
|
-
return ".";
|
|
120
|
-
}
|
|
121
|
-
path2 = normalizeWindowsPath(path2);
|
|
122
|
-
const isUNCPath = UNC_REGEX.exec(path2);
|
|
123
|
-
const isPathAbsolute = isAbsolute(path2);
|
|
124
|
-
const trailingSeparator = path2.at(-1) === "/";
|
|
125
|
-
path2 = normalizeString(path2, !isPathAbsolute);
|
|
126
|
-
if (path2.length === 0) {
|
|
127
|
-
if (isPathAbsolute) {
|
|
128
|
-
return "/";
|
|
129
|
-
}
|
|
130
|
-
return trailingSeparator ? "./" : ".";
|
|
131
|
-
}
|
|
132
|
-
if (trailingSeparator) {
|
|
133
|
-
path2 += "/";
|
|
134
|
-
}
|
|
135
|
-
if (DRIVE_LETTER_RE.test(path2)) {
|
|
136
|
-
path2 += "/";
|
|
137
|
-
}
|
|
138
|
-
if (isUNCPath) {
|
|
139
|
-
if (!isPathAbsolute) {
|
|
140
|
-
return `//./${path2}`;
|
|
141
|
-
}
|
|
142
|
-
return `//${path2}`;
|
|
143
|
-
}
|
|
144
|
-
return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
|
|
145
|
-
};
|
|
146
|
-
const join = (...segments) => {
|
|
147
|
-
let path2 = "";
|
|
148
|
-
for (const seg of segments) {
|
|
149
|
-
if (!seg) {
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
if (path2.length > 0) {
|
|
153
|
-
const pathTrailing = path2[path2.length - 1] === "/";
|
|
154
|
-
const segLeading = seg[0] === "/";
|
|
155
|
-
const both = pathTrailing && segLeading;
|
|
156
|
-
if (both) {
|
|
157
|
-
path2 += seg.slice(1);
|
|
158
|
-
} else {
|
|
159
|
-
path2 += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
160
|
-
}
|
|
161
|
-
} else {
|
|
162
|
-
path2 += seg;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return normalize(path2);
|
|
166
|
-
};
|
|
167
|
-
const dirname = (path2) => {
|
|
168
|
-
const segments = normalizeWindowsPath(path2).replace(/\/$/, "").split("/").slice(0, -1);
|
|
169
|
-
if (segments.length === 1 && DRIVE_LETTER_RE.test(segments[0])) {
|
|
170
|
-
segments[0] += "/";
|
|
171
|
-
}
|
|
172
|
-
return segments.join("/") || (isAbsolute(path2) ? "/" : ".");
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
class UpdateNotifierError extends CerebroError {
|
|
176
|
-
constructor(message, code = "UPDATE_NOTIFIER_ERROR", context) {
|
|
177
|
-
super(message, code, context);
|
|
178
|
-
this.name = "UpdateNotifierError";
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const FILE_NAME = "last-update-check.json";
|
|
183
|
-
const getConfigFile = (packageName) => {
|
|
184
|
-
const cacheDirectory = findCacheDirSync(packageName);
|
|
185
|
-
if (cacheDirectory === void 0) {
|
|
186
|
-
throw new UpdateNotifierError("Could not find cache directory", "CACHE_DIRECTORY_NOT_FOUND", { packageName });
|
|
187
|
-
}
|
|
188
|
-
return join(cacheDirectory, FILE_NAME);
|
|
189
|
-
};
|
|
190
|
-
const getLastUpdate = (packageName) => {
|
|
191
|
-
const configFile = getConfigFile(packageName);
|
|
192
|
-
try {
|
|
193
|
-
if (!existsSync(configFile)) {
|
|
194
|
-
return void 0;
|
|
195
|
-
}
|
|
196
|
-
const { lastUpdateCheck } = JSON.parse(readFileSync(configFile, "utf8"));
|
|
197
|
-
return lastUpdateCheck;
|
|
198
|
-
} catch {
|
|
199
|
-
return void 0;
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
const saveLastUpdate = (packageName) => {
|
|
203
|
-
const configFile = getConfigFile(packageName);
|
|
204
|
-
const configDirectory = dirname(configFile);
|
|
205
|
-
if (!existsSync(configDirectory)) {
|
|
206
|
-
mkdirSync(configDirectory, { recursive: true });
|
|
207
|
-
}
|
|
208
|
-
writeFileSync(configFile, JSON.stringify({ lastUpdateCheck: Date.now() }));
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
const getDistributionVersion = async (packageName, distributionTag, registryUrl) => {
|
|
212
|
-
const url = registryUrl.replace("__NAME__", packageName);
|
|
213
|
-
return await new Promise((resolve, reject) => {
|
|
214
|
-
get(url, (message) => {
|
|
215
|
-
let body = "";
|
|
216
|
-
message.on("data", (chunk) => body += chunk);
|
|
217
|
-
message.on("end", () => {
|
|
218
|
-
try {
|
|
219
|
-
const json = JSON.parse(body);
|
|
220
|
-
const version = json[distributionTag];
|
|
221
|
-
if (!version) {
|
|
222
|
-
reject(new UpdateNotifierError("Error getting version", "VERSION_FETCH_ERROR", { distributionTag, packageName }));
|
|
223
|
-
}
|
|
224
|
-
resolve(version);
|
|
225
|
-
} catch {
|
|
226
|
-
reject(new UpdateNotifierError("Could not parse version response", "VERSION_PARSE_ERROR", { distributionTag, packageName }));
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
}).on("error", (error) => reject(error));
|
|
230
|
-
});
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
const hasNewVersion = async ({
|
|
234
|
-
alwaysRun,
|
|
235
|
-
debug,
|
|
236
|
-
distTag: distributionTag = "latest",
|
|
237
|
-
pkg,
|
|
238
|
-
registryUrl = "https://registry.npmjs.org/-/package/__NAME__/dist-tags",
|
|
239
|
-
updateCheckInterval = 1e3 * 60 * 60 * 24
|
|
240
|
-
}) => {
|
|
241
|
-
const lastUpdateCheck = getLastUpdate(pkg.name);
|
|
242
|
-
if (alwaysRun || !lastUpdateCheck || lastUpdateCheck < Date.now() - updateCheckInterval) {
|
|
243
|
-
const latestVersion = await getDistributionVersion(pkg.name, distributionTag, registryUrl);
|
|
244
|
-
saveLastUpdate(pkg.name);
|
|
245
|
-
if (semverGt(latestVersion, pkg.version)) {
|
|
246
|
-
return latestVersion;
|
|
247
|
-
}
|
|
248
|
-
if (debug) {
|
|
249
|
-
console.error(`Latest version (${latestVersion}) not newer than current version (${pkg.version})`);
|
|
250
|
-
}
|
|
251
|
-
} else if (debug) {
|
|
252
|
-
console.error(
|
|
253
|
-
`Too recent to check for a new update. simpleUpdateNotifier() interval set to ${updateCheckInterval}ms but only ${Date.now() - lastUpdateCheck}ms since last check.`
|
|
254
|
-
);
|
|
255
|
-
}
|
|
256
|
-
return void 0;
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
export { hasNewVersion as default };
|
|
1
|
+
import{createRequire as k}from"node:module";import{findCacheDirSync as $}from"@visulima/find-cache-dir";import{t as F}from"../packem_shared/cerebro-error-BjBcYVRO.js";const T=k(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,w=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[r,t]=g.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return g.getBuiltinModule(e)}return T(e)},{writeFile:b,readFile:R,mkdir:I,access:S}=w("node:fs/promises"),{get:U}=w("node:https"),N=e=>{const[r,t]=e.split("-");return{nums:r.split(".").map(s=>Number.parseInt(s,10)||0),pre:t}},A=(e,r)=>{const t=N(e),s=N(r),o=Math.max(t.nums.length,s.nums.length);for(let i=0;i<o;i+=1){const n=t.nums[i]??0,u=s.nums[i]??0;if(n>u)return!0;if(n<u)return!1}if(t.pre===void 0&&s.pre!==void 0)return!0;if(t.pre!==void 0&&s.pre===void 0||t.pre===void 0&&s.pre===void 0)return!1;const c=t.pre.split("."),l=s.pre.split("."),a=Math.max(c.length,l.length);for(let i=0;i<a;i+=1){const n=c[i],u=l[i];if(n===void 0)return!1;if(u===void 0)return!0;if(n===u)continue;const d=Number.parseInt(n,10),f=Number.parseInt(u,10),h=!Number.isNaN(d)&&String(d)===n,_=!Number.isNaN(f)&&String(f)===u;return h&&_?d>f:h?!1:_?!0:n>u}return!1},x=/^[A-Z]:\//i,v=(e="")=>e&&e.replaceAll("\\","/").replace(x,r=>r.toUpperCase()),j=/^[/\\]{2}/,D=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,E=/^[A-Z]:$/i,H=/\/$/,M=(e,r)=>{let t="",s=0,o=-1,c=0,l;for(let a=0;a<=e.length;++a){if(a<e.length)l=e[a];else{if(l==="/")break;l="/"}if(l==="/"){if(!(o===a-1||c===1))if(c===2){if(t.length<2||s!==2||!t.endsWith(".")||t.at(-2)!=="."){if(t.length>2){const i=t.lastIndexOf("/");i===-1?(t="",s=0):(t=t.slice(0,i),s=t.length-1-t.lastIndexOf("/")),o=a,c=0;continue}else if(t.length>0){t="",s=0,o=a,c=0;continue}}r&&(t+=t.length>0?"/..":"..",s=2)}else t.length>0?t+=`/${e.slice(o+1,a)}`:t=e.slice(o+1,a),s=a-o-1;o=a,c=0}else l==="."&&c!==-1?++c:c=-1}return t},m=e=>D.test(e),P=function(e){if(e.length===0)return".";e=v(e);const r=j.exec(e),t=m(e),s=e.at(-1)==="/";return e=M(e,!t),e.length===0?t?"/":s?"./":".":(s&&(e+="/"),E.test(e)&&(e+="/"),r?t?`//${e}`:`//./${e}`:t&&!m(e)?`/${e}`:e)},V=(...e)=>{let r="";for(const t of e)if(t)if(r.length>0){const s=r.at(-1)==="/",o=t[0]==="/";s&&o?r+=t.slice(1):r+=s||o?t:`/${t}`}else r+=t;return P(r)},q=e=>{const r=v(e).replace(H,""),t=r.lastIndexOf("/");if(t===-1)return m(e)?"/":".";const s=r.slice(0,t);return E.test(s)?`${s}/`:s||(m(e)?"/":".")};class p extends F{constructor(r,t="UPDATE_NOTIFIER_ERROR",s){super(r,t,s),this.name="UpdateNotifierError"}}const J="last-update-check.json",y={access:(e,r)=>S(e,r),mkdir:(e,r)=>I(e,r),readFile:(async(e,r)=>r===void 0?R(e):R(e,r)),writeFile:(e,r,t)=>b(e,r,t)},O=async(e,r)=>{try{return await e.access(r),!0}catch{return!1}},C=e=>{const r=$(e);if(r===void 0)throw new p("Could not find cache directory","CACHE_DIRECTORY_NOT_FOUND",{packageName:e});return V(r,J)},L=async(e,r=y)=>{const t=C(e);try{if(!await O(r,t))return;const{lastUpdateCheck:s}=JSON.parse(await r.readFile(t,"utf8"));return s}catch{return}},Z=async(e,r=y)=>{const t=C(e),s=q(t);await O(r,s)||await r.mkdir(s,{recursive:!0}),await r.writeFile(t,JSON.stringify({lastUpdateCheck:Date.now()}),"utf8")},B=5e3,W=async(e,r,t,s=B)=>{const o=t.replace("__NAME__",e),c=512*1024;return await new Promise((l,a)=>{const i=U(o,{timeout:s},n=>{if(n.statusCode!==void 0&&(n.statusCode<200||n.statusCode>=300)){a(new p(`Unexpected status code ${String(n.statusCode)}`,"VERSION_FETCH_ERROR",{distributionTag:r,packageName:e})),n.resume();return}let u="",d=!1;n.on("data",f=>{d||(u+=String(f),u.length>c&&(d=!0,a(new p("Response too large","VERSION_FETCH_ERROR",{distributionTag:r,packageName:e})),n.destroy()))}),n.on("end",()=>{if(!d)try{const f=JSON.parse(u)[r];if(!f){a(new p("Error getting version","VERSION_FETCH_ERROR",{distributionTag:r,packageName:e}));return}l(f)}catch{a(new p("Could not parse version response","VERSION_PARSE_ERROR",{distributionTag:r,packageName:e}))}})});i.on("timeout",()=>{i.destroy(new p("Request timed out","VERSION_FETCH_ERROR",{distributionTag:r,packageName:e}))}),i.on("error",n=>{a(n)})})},G=async({alwaysRun:e,debug:r,distTag:t="latest",fs:s,pkg:o,registryUrl:c="https://registry.npmjs.org/-/package/__NAME__/dist-tags",timeout:l,updateCheckInterval:a=1e3*60*60*24})=>{const i=await L(o.name,s);if(e||!i||i<Date.now()-a){const n=await W(o.name,t,c,l);if(await Z(o.name,s),A(n,o.version))return n;r&&console.error(`Latest version (${n}) not newer than current version (${o.version})`)}else r&&console.error(`Too recent to check for a new update. simpleUpdateNotifier() interval set to ${String(a)}ms but only ${String(Date.now()-i)}ms since last check.`)};export{G as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{createRequire as Te}from"node:module";import{VERBOSITY_DEBUG as T,POSITIONALS_KEY as Q,VERBOSITY_NORMAL as te,VERBOSITY_QUIET as Ge,VERBOSITY_VERBOSE as He}from"./VERBOSITY_DEBUG-XPultrIA.js";import{t as w}from"./cerebro-error-BjBcYVRO.js";import{c as X,d as se,o as ce,e as F,a as Ye,b as Je,f as Ke,h as Ze,i as Qe}from"./runtime-process-Dmz0vCJy.js";import"./renderError-B3ePOoBG-BmZlyMcr.js";import{h as H}from"./VisulimaError-DTMgXonA-CzaryRgZ.js";import{distance as Xe}from"fastest-levenshtein";import{k as et,A as tt}from"./split-by-case-Dbpgd7rf.js";const je=Te(import.meta.url),W=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ue=t=>{if(typeof W<"u"&&W.versions&&W.versions.node){const[e,n]=W.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return W.getBuiltinModule(t)}return je(t)},{writeFile:Be,stat:ze,rm:Re,readFile:le,readdir:Fe,mkdir:qe,access:We}=Ue("node:fs/promises"),J=[{alias:"v",description:"Turn on verbose output",group:"global",name:"verbose",type:Boolean},{description:"Turn on debugging output",group:"global",name:"debug",type:Boolean},{alias:"h",description:"Print out helpful usage information",group:"global",name:"help",type:Boolean},{alias:"q",description:"Silence output",group:"global",name:"quiet",type:Boolean},{alias:"V",description:"Print version info",group:"global",name:"version",type:Boolean},{description:"Turn off colored output",group:"global",name:"no-color",type:Boolean},{description:"Force colored output",group:"global",name:"color",type:Boolean}];let U=class extends w{commandName;constructor(e,n=[]){const o=`Command "${e}" not found${n.length>0?`. Did you mean: ${n.join(", ")}?`:""}`;super(o,"COMMAND_NOT_FOUND",{commandName:e,suggestions:n}),this.name="CommandNotFoundError",this.commandName=e,n.length>0&&(this.hint=`Try one of these commands: ${n.join(", ")}`)}},xe=class extends w{option1;option2;constructor(e,n){super(`Options "${e}" and "${n}" cannot be used together`,"CONFLICTING_OPTIONS",{option1:e,option2:n}),this.name="ConflictingOptionsError",this.option1=e,this.option2=n,this.hint=`Remove either --${e} or --${n}`}},nt=class extends w{unknownOptions;constructor(e,n){const o=e.join(", "),s=`Found unknown ${e.length===1?"option":"options"}: ${o}`;super(s,"UNKNOWN_OPTION",{suggestions:n,unknownOptions:e}),this.name="UnknownOptionError",this.unknownOptions=e,n&&n.length>0&&(this.hint=`Did you mean: ${n.join(", ")}?`)}},ot=class extends w{pluginName;constructor(e,n,o){super(`Plugin "${e}" error: ${n}`,"PLUGIN_ERROR",{originalError:o,pluginName:e}),this.name="PluginError",this.pluginName=e,o&&(this.cause=o)}},it=class{logger;plugins=new Map;initialized=!1;cachedDependencyOrder=void 0;constructor(e){this.logger=e}hasPlugins(){return this.plugins.size>0}register(e){if(this.initialized)throw new Error(`Cannot register plugin "${e.name}" after initialization`);if(this.plugins.has(e.name))throw new Error(`Plugin "${e.name}" is already registered`);X().CEREBRO_OUTPUT_LEVEL===String(T)&&this.logger.debug(`registering plugin: ${e.name}`),this.plugins.set(e.name,e),this.cachedDependencyOrder=void 0}async init(e){if(this.initialized)throw new Error("PluginManager already initialized");if(this.plugins.size===0){this.logger.debug("no plugins registered, skipping initialization"),this.initialized=!0;return}this.validateDependencies();const n=this.getDependencyOrder();this.logger.debug(`initializing ${String(n.length)} plugin(s)...`);for(const o of n)if(typeof o.init=="function"){this.logger.debug(`initializing plugin: ${o.name}`);try{await o.init(e)}catch(s){const i=new ot(o.name,`Failed to initialize: ${s instanceof Error?s.message:String(s)}`,s instanceof Error?s:void 0);throw this.logger.error(i.message),i}}this.initialized=!0}async executeLifecycle(e,n,o){if(!this.initialized)throw new Error("PluginManager not initialized");if(this.plugins.size===0)return;const s=this.getDependencyOrder();for(const i of s){const l=i[e];if(typeof l=="function"){this.logger.debug(`executing ${e} hook for plugin: ${i.name}`);try{await(e==="afterCommand"?l(n,o):l(n))}catch(a){throw this.logger.error(`Error in ${e} hook for plugin "${i.name}":`,a),a}}}}async executeErrorHandlers(e,n){if(!this.initialized||this.plugins.size===0)return;const o=this.getDependencyOrder();for(const s of o)if(typeof s.onError=="function"){this.logger.debug(`executing error handler for plugin: ${s.name}`);try{await s.onError(e,n)}catch(i){this.logger.error(`Error in error handler for plugin "${s.name}":`,i)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const e=[],n=new Set,o=new Set,s=i=>{if(n.has(i))return;if(o.has(i))throw new Error(`Circular dependency detected involving plugin "${i}"`);const l=this.plugins.get(i);if(!l)throw new Error(`Plugin "${i}" not found`);if(o.add(i),l.dependencies)for(const a of l.dependencies)s(a);o.delete(i),n.add(i),e.push(l)};for(const i of this.plugins.keys())s(i);return this.cachedDependencyOrder=e,e}validateDependencies(){for(const e of this.plugins.values())if(e.dependencies){for(const n of e.dependencies)if(!this.plugins.has(n))throw new Error(`Plugin "${e.name}" depends on "${n}" which is not registered`)}}};const G=t=>t.type?.name==="Boolean",st=t=>{let e=t.type?t.type.name.toLowerCase():"string";const n=t.multiple??t.lazyMultiple?"[]":"";return e&&(e=e==="boolean"?"":`{underline ${e}${n}}`),e},de=t=>(G(t)||(t.typeLabel=t.typeLabel??st(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),at=new RegExp(/^-([^\d-])$/),rt=new RegExp(/^--(\S+)/),lt=new RegExp(/^-([^\d-]{2,})$/),ct=t=>at.test(t)||rt.test(t)||lt.test(t),dt=(t,e)=>{const n=e[0]&&ct(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const o=new Error(`Command not recognised: ${String(n)}`);throw o.command=n,o.name="INVALID_COMMAND",o}return{argv:e,command:n}};class re extends H{optionName;value;constructor(e,n,o){super({hint:`Pass a valid ${o} value for '${e}'.`,message:`Invalid ${o} value '${n}' for option '${e}'`,name:"INVALID_VALUE",title:"Invalid Value"}),this.optionName=e,this.value=n,Object.setPrototypeOf(this,re.prototype)}}let ut=class Ie extends H{optionName;constructor(e){super({cause:void 0,hint:`Remove the duplicate option '${e}' from your command line arguments.`,location:void 0,message:`Option '${e}' is already set`,name:"ALREADY_SET",stack:void 0,title:"Option Already Set"}),this.optionName=e,Object.setPrototypeOf(this,Ie.prototype)}},ue=class ke extends H{optionName;constructor(e){super({cause:void 0,hint:`Check your option definitions or remove the unknown option '${e}' from your command line arguments.`,location:void 0,message:`Unknown option: --${e}`,name:"UNKNOWN_OPTION",stack:void 0,title:"Unknown Option"}),this.optionName=`--${e}`,Object.setPrototypeOf(this,ke.prototype)}},mt=class Ee extends H{value;constructor(e){super({hint:"Use a defined option or add a defaultOption to capture this value.",message:`Unknown value: ${e}`,name:"UNKNOWN_VALUE",title:"Unknown Value"}),this.value=e,Object.setPrototypeOf(this,Ee.prototype)}};class x extends H{constructor(e,n){super({cause:void 0,hint:n,location:void 0,message:e,name:"INVALID_DEFINITIONS",stack:void 0,title:"Invalid Option Definition"}),Object.setPrototypeOf(this,x.prototype)}}const me=(t,e,n)=>{const o=Number(t);if(e&&Number.isNaN(o)&&String(t).trim().toLowerCase()!=="nan")throw new re(n??"",String(t),"Number");return o},he=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",pe=t=>t===Number||typeof t=="function"&&t.name==="Number",fe=t=>t===String||typeof t=="function"&&t.name==="String",ht=(t,e,n={})=>{const{optionName:o,strictTypes:s}=n;return Array.isArray(t)?he(e)?t.map(Boolean):pe(e)?t.map(i=>me(i,s,o)):fe(e)?t.map(String):t.map(i=>e(String(i))):t===null?null:he(e)?!!t:pe(e)?me(t,s,o):fe(e)?typeof t=="string"?t:String(t):e(typeof t=="string"?t:String(t))},b=(t,e,n,...o)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...o)},pt=/-([a-z])/g,ft=/^\d+$/,K=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",gt=t=>t.codePointAt(0)===95,ge=(t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],we=t=>t==="__proto__"||t==="constructor"||t==="prototype",ye=(t,e,n,o=!1)=>{t[e]===void 0?t[e]=o?[n]:n:o&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},ve=(t,e,n,o,s)=>{let i=e.get(t)??n.get(t);if(!i&&o){const l=t.toLowerCase();i=o.get(l)??s?.get(l)}return i},wt=(t,e,n,o)=>{const s=n.debug??!1;b(s,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),b(s,"Starting argument resolution","resolver"),b(s,"Tokens:","resolver",t),b(s,"Definitions:","resolver",e),b(s,"Processing tokens...","resolver");const i=new Map,l=new Map,a=n.caseInsensitive?new Map:void 0,d=n.caseInsensitive?new Map:void 0,r=n.camelCase?new Map:void 0,m=n.camelCase?new Map:void 0;for(const c of e)if(i.set(c.name,c),c.alias&&l.set(c.alias,c),n.caseInsensitive&&a&&(a.set(c.name.toLowerCase(),c),c.alias&&d&&d.set(c.alias.toLowerCase(),c)),n.camelCase&&r&&m){const u=c.name.replaceAll(pt,(p,C)=>C.toUpperCase());r.set(c.name,u),m.set(u,c.name)}const h=Object.create(null),f=Object.create(null),y=[],E=[],A=new Set;let I=!1;const O=e.find(c=>c.defaultOption),v=e.some(c=>c.group),$=e.find(c=>c.type===Number);for(let c=0;c<t.length;c++){const u=t[c];if(u.kind==="option-terminator"){h._unknown=o.slice(u.index),I=!0;break}if(u.kind==="option"&&u.name){let p=ve(u.name,i,l,a,d);!p&&u.value===void 0&&$&&ft.test(u.name)&&(p=$,u.value=u.name,u.name=$.name);let C=!1;if(!p&&n.negation&&u.value===void 0&&u.name.startsWith("no-")){const N=u.name.slice(3),P=ve(N,i,l,a,d);P?.type&&K(P.type)&&(p=P,C=!0)}const g=p?p.name:u.name,k=p?.multiple,D=p?.lazyMultiple;if(Object.hasOwn(f,g)&&f[g]!==void 0&&!k&&!D&&!n.partial)throw new ut(g);if(!p&&n.partial){const N=u.rawName??`--${u.name}${u.value!==void 0&&u.inlineValue?`=${u.value}`:""}`;y.push({index:u.index,value:N});continue}if(!p&&n.stopAtFirstUnknown){h._unknown=o.slice(u.index);break}if(!p&&!n.partial)throw new ue(u.name);if(u.value===void 0){const N=t[c+1],P=N?.kind==="option"&&!("name"in N)&&N.value!==void 0,M=N&&p&&!(p.type&&K(p.type))&&(N.kind==="positional"||P),Se=p&&p.defaultOption&&!p.multiple&&!p.lazyMultiple;if(M&&(!p?.defaultOption||Se))if(k){let S=c+1;const ee=[];for(;S<t.length&&(t[S].kind==="positional"||t[S].kind==="option"&&!("name"in t[S])&&t[S].value!==void 0);)ee.push(t[S].value),A.add(t[S].index),S++;f[g]=f[g]===void 0?ee:ge(f[g],ee),c=S-1}else D?(ye(f,g,N.value,!0),A.add(N.index),c++):(f[g]=N.value,A.add(N.index),c++);else p?.type&&K(p.type)?ye(f,g,!C,k):f[g]=k?[]:null}else{let{value:N}=u;if(p?.type&&K(p.type))switch(N){case"":{if(n.partial){f._unknown??=[];const M=`${u.rawName??`--${u.name}`}${u.value?`=${u.value}`:""}`;f._unknown.push(M),E.push({index:u.index,value:M}),N=!0}else throw new ue(u.name);break}case"false":{N=!1;break}case"true":{N=!0;break}default:N=!0}const P=[N];if(k){let M=c+1;for(;M<t.length&&t[M].kind==="positional";)P.push(t[M].value),A.add(t[M].index),M++;c=M-1}f[g]===void 0?f[g]=k||D?P:N:k||D?f[g]=ge(f[g],P):f[g]=N}}else if(u.kind==="positional"&&n.stopAtFirstUnknown&&!A.has(u.index)&&!O){b(s,`Found unconsumed positional token at index ${String(u.index)}, stopping processing`,"resolver"),h._unknown=o.slice(u.index);break}}for(const[c,u]of Object.entries(f)){const p=i.get(c);p&&(p.multiple||p.lazyMultiple)&&!Array.isArray(u)&&(f[c]=[u])}const _=c=>c.kind==="option"&&!i.has(c.name??"")&&!l.has(c.name??"")&&(!n.caseInsensitive||!a?.has(c.name?.toLowerCase()??"")&&!d?.has(c.name?.toLowerCase()??""));let L=-1,V=Number.POSITIVE_INFINITY;if(n.stopAtFirstUnknown&&!I&&(L=t.findIndex(c=>_(c)),L!==-1&&(V=t[L].index)),O){const c=[],u=[];for(const p of t)p.kind==="positional"&&!A.has(p.index)&&p.index<V&&(c.push(p.value),u.push(p));if(c.length>0){const p=f[O.name],C=O.multiple??O.lazyMultiple;p===void 0?C?(u.forEach(g=>A.add(g.index)),f[O.name]=c):(A.add(u[0].index),f[O.name]=c[0]):C&&(u.forEach(g=>A.add(g.index)),f[O.name]=Array.isArray(p)?[...c,...p]:[...c,p])}}if(!n.partial){for(const c of t)if(c.kind==="positional"&&!A.has(c.index))throw new mt(o[c.index])}if(n.partial&&!n.stopAtFirstUnknown){const c=[...y];if(f._unknown)for(const u of E)c.push({index:u.index,value:u.value});for(const u of t)u.kind==="positional"&&!A.has(u.index)&&c.push({index:u.index,value:o[u.index]});c.length>0&&(c.sort((u,p)=>u.index-p.index),h._unknown=c.map(u=>u.value))}if(n.stopAtFirstUnknown&&!I){const c=t.findIndex(p=>p.kind==="positional"&&!A.has(p.index));let u=-1;if(L!==-1&&c!==-1?u=Math.min(L,c):L!==-1?u=L:c!==-1&&(u=c),u>=0){const p=t[u].index;h._unknown=o.slice(p)}}else y.length>0&&!n.partial&&(h._unknown=y.map(c=>c.value));for(const[c,u]of Object.entries(f)){const p=n.camelCase?r?.get(c)??c:c,C=i.get(c);C?.type?h[p]=ht(u,C.type,{optionName:C.name,strictTypes:n.strictTypes}):h[p]=u===void 0?null:u}for(const c of e){const u=n.camelCase?r?.get(c.name)??c.name:c.name;!(u in h)&&c.defaultValue!==void 0&&(c.multiple??c.lazyMultiple?h[u]=Array.isArray(c.defaultValue)?[...c.defaultValue]:[c.defaultValue]:h[u]=c.defaultValue)}if(v){const c={},u={},p={};for(const g of e)if(g.group){const k=Array.isArray(g.group)?g.group:[g.group];for(const D of k)we(D)||(c[D]??={})}for(const g of Object.keys(h))if(!gt(g)){u[g]=h[g];let k=g;n.camelCase&&(k=m?.get(g)??g);const D=i.get(k);if(D?.group){const N=Array.isArray(D.group)?D.group:[D.group];for(const P of N)we(P)||c[P]&&(c[P][g]=h[g])}else p[g]=h[g]}const C={_all:u};for(const[g,k]of Object.entries(c))C[g]=k;Object.keys(p).length>0&&(C._none=p),h._unknown&&(C._unknown=h._unknown),Object.keys(h).forEach(g=>delete h[g]),Object.assign(h,C)}const Y=Object.defineProperties({},Object.getOwnPropertyDescriptors(h));return b(s,"Final parsed result:","resolver",Y),Y},q="-".codePointAt(0),z="=",yt=z.codePointAt(0),vt="--",Nt="-",$t="--",Pe=t=>t.length>2&&t.startsWith($t),bt=t=>Pe(t)&&!t.includes(z,3),At=t=>Pe(t)&&t.includes(z,3),Ot=t=>{if(t.length!==2||t.codePointAt(0)!==q||t.codePointAt(1)===q)return!1;const e=t.codePointAt(1);return e!==void 0&&(e<48||e>57)},_t=t=>!(t.length<=2||t.codePointAt(0)!==q||t.codePointAt(1)===q),Ct=t=>{const e=[];let n=0,o=[],s=0,i=-1,l=0;for(;s<o.length||n<t.length;){let a;if(s<o.length?(a=o[s],s++):(a=t[n],n++),l>0?l--:i++,a===vt){e.push({index:i,kind:"option-terminator"});const d=[...o.slice(s),...t.slice(n)],r=d.map((m,h)=>({index:i+h+1,kind:"positional",value:m}));e.push(...r),i+=d.length;break}if(Ot(a)){const d=a.charAt(1);e.push({index:i,kind:"option",name:d,rawName:a});continue}if(_t(a)&&!a.includes(z)){const d=[];let r="",m=!1;for(let h=1;h<a.length;h++){const f=a.charAt(h);m?r+=f:f.codePointAt(0)===yt?m=!0:d.push(`${Nt}${f}`)}if(m)if(d.length>0){const h=d.pop();d.push(`${h}=${r}`)}else d.push(r);o=s<o.length?[...d,...o.slice(s)]:d,s=0,l=d.length;continue}if(bt(a)){const d=a.slice(2);e.push({index:i,kind:"option",name:d,rawName:a});continue}if(At(a)){const d=a.indexOf(z),r=a.slice(2,d),m=a.slice(d+1);e.push({index:i,inlineValue:!0,kind:"option",name:r,rawName:a,value:m});continue}if(a.length>2&&a.codePointAt(0)===q&&a.codePointAt(1)!==q&&a.includes(z)){const d=a.indexOf(z),r=a.charAt(1),m=a.slice(d+1);e.push({index:i,inlineValue:!0,kind:"option",name:r,rawName:a,value:m});continue}e.push({index:i,kind:"positional",value:a})}return e},xt=/\d/,It=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",kt=t=>typeof t=="function",Et=(t,e,n)=>{const o=n?.debug??!1;b(o,"Validating definitions:","validation",t,"caseInsensitive:",e);const s=new Set,i=new Set,l=new Set,a=new Set;let d=0;for(const r of t){if(b(o,"Checking definition:","validation",r),!r.name)throw b(o,"Validation failed: name is required","validation"),new x("Invalid option definition: name is required");if(typeof r.name!="string")throw new x("Invalid option definition: name must be a string");if(r.name.trim()==="")throw new x("Invalid option definition: name cannot be empty");const m=e?r.name.toLowerCase():"";if(s.has(r.name)||e&&l.has(m))throw new x(`Invalid option definition: duplicate name '${r.name}'`);if(i.has(r.name)||e&&a.has(m))throw new x(`Invalid option definition: name '${r.name}' conflicts with an existing alias`);if(s.add(r.name),e&&l.add(m),r.alias!==void 0){if(typeof r.alias!="string")throw new x("Invalid option definition: alias must be a string");if(r.alias.length!==1)throw new x("Invalid option definition: alias must be a single character");if(xt.test(r.alias))throw new x("Invalid option definition: alias cannot be numeric");if(r.alias==="-")throw new x('Invalid option definition: alias cannot be "-"');const h=e?r.alias.toLowerCase():"";if(i.has(r.alias)||e&&a.has(h))throw new x(`Invalid option definition: duplicate alias '${r.alias}'`);if(s.has(r.alias)||e&&l.has(h))throw new x(`Invalid option definition: alias '${r.alias}' conflicts with an existing option name`);i.add(r.alias),e&&a.add(h)}if(r.defaultOption&&(d++,r.type!==void 0&&It(r.type)))throw new x("Invalid option definition: defaultOption cannot be Boolean type");if(r.type!==void 0&&!(r.type===Boolean||r.type===Number||r.type===String||typeof r.type=="function"&&kt(r.type)))throw new x("Invalid option definition: invalid type")}if(d>1)throw b(o,"Validation failed: multiple defaultOptions not allowed","validation"),new x("Invalid option definition: multiple defaultOptions not allowed");b(o,"Validation completed successfully","validation")};function Pt(t,e={}){const n=e.debug??!1;b(n,"Starting command-line-args parsing","index"),b(n,"Options:","index",e);const o={...e};o.stopAtFirstUnknown&&(o.partial=!0);const s=Array.isArray(t)?t:[t];b(n,"Normalized definitions:","index",s),Et(s,o.caseInsensitive,n?o:void 0);let{argv:i}=o;if(!i&&(i=process.argv.slice(2),process.execArgv.length>0)){const r=new Set(process.execArgv);i=i.filter(m=>!r.has(m))}b(n,"Using argv:","index",i);let l=i;o.caseInsensitive&&(l=i.map(r=>{if(r.startsWith("--")){const m=r.indexOf("="),h=(m===-1?r.slice(2):r.slice(2,m)).toLowerCase();return m===-1?`--${h}`:`--${h}${r.slice(m)}`}if(r.startsWith("-")&&!r.startsWith("--")&&r.length>1){const m=r.slice(1).split("=",2),h=m[0],f=m[1];if(!h)return r;const y=h.toLowerCase();return f===void 0?`-${y}`:`-${y}=${f}`}return r}));const a=Ct(l.map(String));b(n,"Tokenized arguments:","index",a);const d=wt(a,s,o,i);return b(n,"Command-line-args parsing completed","index"),d}class Lt{result;argv;options;argument;command;commandName;env;logger;console;fs;process;runtime;rawUnknown;constructor(e,n){this.commandName=e,this.command=n}}let ne=class extends w{commandName;constructor(e,n,o){super(`Failed to load command "${e}": ${n}`,"COMMAND_LOADER_ERROR",{commandName:e,reason:n}),this.name="CommandLoaderError",this.commandName=e,this.hint="Ensure the loader resolves to a module with a default export that is the command handler function.",o!==void 0&&(this.cause=o)}};const Dt=/^-{1,2}(\w+)(=(.+))?$/,Le=(t,e,n,o)=>{const s=Dt.exec(t);if(s===null)return{};const i=s[1];if(!i)return{};const l=n&&o?n.get(i)??o.get(i):e.find(a=>a.name===i||a.alias===i);return l!==void 0?{argName:l.name,argValue:s[3],option:l}:{}},Ne=(t,e)=>{if(e.type===void 0)return t;if(e.type.name==="Boolean"){if(t==="true"||t==="1")return e.type(!0);if(t==="false"||t==="0")return e.type(!1)}return e.type(t)},Mt=new Set(["0","1","false","true"]),Vt=(t,e,n,o)=>{if(e.length===0||t.length===0)return{};const s=(i,l)=>{const{argName:a,argValue:d,option:r}=Le(l,e,n,o),{lastOption:m}=i;return r&&G(r)&&d&&a?i.partial[a]=Ne(d,r):i.lastName&&m&&G(m)&&Mt.has(l)&&(i.partial[i.lastName]=Ne(l,m)),{lastName:a,lastOption:r,partial:i.partial}};return t.reduce(s,{partial:{}}).partial},St=new Set(["0","1","false","true"]),Tt=(t,e,n,o)=>{if(e.length===0||t.length===0)return t;const s=(i,l)=>{const{argValue:a,option:d}=Le(l,e,n,o),{lastOption:r}=i;if(r&&G(r)&&St.has(l)){const{args:m}=i;return{args:m.slice(0,-1)}}return d&&G(d)&&a?{args:i.args}:{args:[...i.args,l],lastOption:d}};return t.reduce(s,{args:[]}).args},$e=t=>{const e=new Map;for(const n of t){const o=e.get(n.name);o?e.set(n.name,{...o,...n}):e.set(n.name,n)}return[...e.values()]},jt=t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},Ut=(t,e)=>{if(!t.type)return e;if(e!==void 0){if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return jt(e);if(t.type===Number||typeof t.type=="function"&&t.type.name==="Number"){const n=Number.parseFloat(e);return Number.isNaN(n)?void 0:n}return t.type===String||typeof t.type=="function"&&t.type.name==="String"?e:t.type(e)}},Bt=/_./g,zt=/^[A-Z]/,Rt=t=>t.toLowerCase().replaceAll(Bt,e=>e[1]?.toUpperCase()??e).replace(zt,e=>e.toLowerCase()),Ft=t=>{if(!t||t.length===0)return{};const e={},n=X();for(const o of t){const s=n[o.name],i=Ut(o,s),l=i===void 0?o.defaultValue:i,a=Rt(o.name);e[a]=l}return e},qt=t=>{const e=new Map,n=new Map;for(const o of t)if(e.set(o.name,o),o.alias){const s=Array.isArray(o.alias)?o.alias:[o.alias];for(const i of s)n.set(i,o)}return{optionMapByAlias:n,optionMapByName:e}},De=async t=>{if(typeof t.__resolvedExecute__=="function")return t.__resolvedExecute__;if(typeof t.loader!="function")throw new ne(t.name,"no execute or loader defined");let e;try{e=await t.loader()}catch(o){throw new ne(t.name,o instanceof Error?o.message:String(o),o)}const n=e.default;if(typeof n!="function")throw new ne(t.name,"loader did not return a module with a default-exported handler function");return t.__resolvedExecute__=n,n},Wt=(t,e,n,o)=>{const s=new Lt(t.name,t),{_all:i,_unknown:l,positionals:a}=e,d=Object.keys(n).length>0?{...i,...n}:i;Q in d&&delete d[Q],s.argument=a?.[Q]??[],s.rawUnknown=[...l??[]];const r=Object.keys(o).length>0;return s.options=r?{...d,...o}:d,s.env=Ft(t.env),s},Gt=(t,e,n)=>{const o=t.options??[],s=o.length>0;let i=$e(s?[...o,...n]:n);if(i.length>0){for(const r of i)if(r.multiple&&r.lazyMultiple)throw new Error(`Argument "${r.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}t.argument&&(i=[{defaultOption:!0,description:t.argument.description,group:"positionals",multiple:!0,name:Q,type:t.argument.type,typeLabel:t.argument.typeLabel},...i]);let l,a;if(s){const{optionMapByAlias:r,optionMapByName:m}=qt(o);l=Tt(e,o,m,r),a=Vt(e,o,m,r)}else l=e,a={};const d=Pt(i,{argv:l,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:i,booleanValues:a,parsedArgs:d}},R=async(t,e,n)=>typeof t.execute=="function"?t.execute(e):(await De(t))(e);let Ht=class extends w{commandName;missingOptions;constructor(e,n){super(`Command "${e}" is missing required options: ${n.join(", ")}`,"COMMAND_VALIDATION_ERROR",{commandName:e,missingOptions:n}),this.name="CommandValidationError",this.commandName=e,this.missingOptions=n,this.hint=`Provide the following required options: ${n.join(", ")}`}},Yt=class extends w{choices;option;value;constructor(e,n,o){super(`Invalid value "${n}" for option "${e}". Allowed values: ${o.join(", ")}`,"INVALID_CHOICE",{choices:o,option:e,value:n}),this.name="InvalidChoiceError",this.option=e,this.value=n,this.choices=o,this.hint=`Use one of: ${o.map(s=>`--${e} ${s}`).join(", ")}`}};const be=(t,e,n=!1)=>{const o=[];for(const s of t)if(!(!n&&!s.required)&&e[s.name]===void 0){if(s.type?.name==="Boolean"){e[s.name]=!1;continue}o.push(s)}return o},Jt=(t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:Xe(t,e)<=t.length/3,j=(t,e)=>{const n=t.toLowerCase();return e.filter(o=>Jt(o.toLowerCase(),n))},Kt=(t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(o=>{const s=o.startsWith("--");let i=`Found unknown ${s?"option":"argument"} "${o}"`;if(s){const l=j(o.replace("--",""),(e.options??[]).map(a=>a.name));if(l.length>0){const[a,...d]=l.map(r=>`--${r}`);i+=d.length>0?`, did you mean ${a??""} or ${d.join(", ")}?`:`, did you mean ${a??""}?`}}n.push(i)}),n.length>0)throw new Error(n.join(`
|
|
2
|
+
`))},Zt=(t,e,n)=>{const o=n.__requiredOptions__,s=o?be(o,e,!0):be(t,e,!1);if(s.length>0)throw new Ht(n.name,s.map(i=>i.name));e._unknown&&e._unknown.length>0&&!n.argument&&Kt(e,n)},Qt=(t,e,n)=>{const o=n.__conflictingOptions__??t.filter(s=>s.conflicts!==void 0);if(o.length>0){const s=o.find(i=>Array.isArray(i.conflicts)?i.conflicts.some(l=>e[l]!==void 0)&&e[i.name]!==void 0:e[i.conflicts]!==void 0&&e[i.name]!==void 0);if(s)throw new xe(s.name,typeof s.conflicts=="string"?s.conflicts:s.conflicts?.[0]??"unknown")}},Xt=(t,e)=>{const n=e.options;if(n)for(const o of n){if(!o.choices||o.choices.length===0)continue;const s=t[o.name];if(s==null)continue;const i=Array.isArray(s)?s:[s];for(const l of i){const a=String(l);if(!o.choices.includes(a))throw new Yt(o.name,a,o.choices)}}},en=t=>{if(!Array.isArray(t.options))return;const e=new Map,n=new Map;for(const s of t.options){if(s.name){const i=e.get(s.name)??[];i.push(s),e.set(s.name,i)}if(typeof s.alias=="string"&&s.alias.length>0){const i=n.get(s.alias)??[];i.push(s),n.set(s.alias,i)}else if(Array.isArray(s.alias)){for(const i of s.alias)if(i.length>0){const l=n.get(i)??[];l.push(s),n.set(i,l)}}}const o=[];for(const[s,i]of e)i.length>1&&o.push(`Duplicate option name "${s}" in command "${t.name}": ${JSON.stringify(i)}`);for(const[s,i]of n)i.length>1&&o.push(`Duplicate option alias "-${s}" used by options ${i.map(l=>`"${l.name}"`).join(", ")} in command "${t.name}"`);if(o.length>0)throw new Error(o.join(`
|
|
3
|
+
`))},tn=(t,e)=>{if(e.length===0)return{argv:[],commandPath:void 0};const n=[];let o;for(let s=1;s<=e.length;s+=1){const i=e[s-1];if(i===void 0||i.startsWith("-"))break;n.push(i);const l=n.join(" ");t.has(l)&&(o={commandPath:[...n],depth:s})}return o?{argv:e.slice(o.depth),commandPath:o.commandPath}:{argv:e,commandPath:void 0}},B=t=>t.join(" "),Ae=(t,e)=>e&&e.length>0?[...e,t]:[t],nn=(t,e)=>typeof t!="string"||t===""?"":t[0].toLowerCase()+t.slice(1),on=(t,e)=>typeof t!="string"||t===""?"":t[0].toUpperCase()+t.slice(1),sn=(t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const o=[];let s="",i="";for(let l=0;l<n;l++){const a=t[l];if(et.test(a)){s?(o.push(s+i+a),s="",i=""):(o.length>0&&o.push(e),s=a);continue}s?(i&&(i+=e),i+=a):(o.length>0&&o.push(e),o.push(a))}return o.join("")},Me=(t,e)=>{if(typeof t!="string"||!t)return"";let n=!0;return sn(tt(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(s=>{const i=s,l=i.toLowerCase();return n?(n=!1,nn(l)):on(l)}),"")},an=/^no-/,rn=t=>{t.options?.forEach(e=>{e.__camelCaseName__=Me(e.name)})},ln=t=>{if(!Array.isArray(t.options)||t.options.length===0)return;const e=new Set;for(const o of t.options)e.add(o.name);const n=[];for(const o of t.options)if(o.name.startsWith("no-")){const s=o.name.replace(an,"");if(!e.has(s)){if(o.type!==Boolean)throw new Error(`Cannot add negated option "${o.name}" to command "${t.name}" because it is not a boolean.`);const i={...o,defaultValue:o.defaultValue===void 0?!0:!o.defaultValue,name:s};n.push(i),e.add(s)}}n.length>0&&t.options.push(...n)},cn=(t,e)=>{if(!e.options||e.options.length===0)return;const{options:n}=t,o=new Map;for(const i of e.options)if(i.name.startsWith("no-")){const l=Me(i.name);o.set(l,i)}const s=Object.keys(n).filter(i=>o.has(i));if(s.length!==0)for(const i of s){const l=i.charAt(2);if(!l)continue;const a=l.toLowerCase()+i.slice(3),d=o.get(i);d&&(d.__negated__=!0),n[a]=!n[i],Reflect.deleteProperty(n,i)}},dn=(t,e)=>{if(!e.options||e.options.length===0)return;const n=new Map;for(const s of e.options)s.__camelCaseName__&&s.__negated__===void 0&&s.implies!==void 0&&n.set(s.__camelCaseName__,s);if(n.size===0)return;const{options:o}=t;for(const s of Object.keys(o)){const i=n.get(s);if(i?.implies){const{implies:l}=i;for(const[a,d]of Object.entries(l))o[a]===void 0&&(o[a]=d)}}},un=()=>!!process.versions.electron,mn=()=>un()&&!process.defaultApp,hn=()=>mn()?0:1,pn=t=>t.slice(hn()+1),fn=" ",gn=(t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,o)=>n===e[o]),wn=t=>{if(typeof t=="string")return t.split(fn);const e=se();return gn(t,e)?pn(t):t},yn=t=>{const e=i=>{t.error(`Uncaught exception: ${i.message||i}`),i.stack&&t.error(i.stack),F(1)},n=(i,l)=>{if(i instanceof Error)t.error(`Promise rejection: ${i.message||i}`),i.stack&&t.error(i.stack);else{let a;if(typeof i=="string")a=i;else try{a=JSON.stringify(i)}catch{a=String(i)}t.error(`Promise rejection: ${a}`)}F(1)},o=ce("uncaughtException",e),s=ce("unhandledRejection",n);return()=>{o(),s()}},Oe=100,vn=/^[a-z][\w-]*$/i,ae=(t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new w(`${e} must be a non-empty string`,"INVALID_INPUT",{fieldName:e,value:t});return t.trim()},_e=(t,e)=>{if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))throw new w(`${e} must be an array of strings`,"INVALID_INPUT",{fieldName:e,value:t});return t},oe=(t,e)=>{if(typeof t!="object"||t===null)throw new w(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},Z=t=>{const e=ae(t,"Command name");if(e.length>Oe)throw new w(`Command name is too long (maximum ${String(Oe)} characters)`,"INVALID_COMMAND_NAME",{commandName:e,length:e.length});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new w(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!vn.test(e))throw new w(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},Nn=new Set([`
|
|
4
|
+
`,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),$n=(t,e={})=>{if(typeof t!="string")throw new TypeError("Argument must be a string");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,o=n.maxArgumentLength??1e6;if(Number.isFinite(o)&&o>0&&t.length>o)throw new Error(`Argument is too long (maximum ${String(o)} characters)`);if(n.checkDangerousChars){for(const s of t)if(Nn.has(s))throw new Error(`Argument contains dangerous character: ${s}`)}return n.trim?t.trim():t},Ce=(t,e={})=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,o=n.maxArguments??1e5;if(Number.isFinite(o)&&o>0&&t.length>o)throw new Error(`Too many arguments (maximum ${String(o)})`);return t.map(s=>$n(s,n))},bn=/^-([^\d-])$/,An=/^--(\S+)/,On=/^-([^\d-]{2,})$/,ie=t=>bn.test(t)||An.test(t)||On.test(t),_n={access:(t,e)=>We(t,e),mkdir:(t,e)=>qe(t,e),readdir:t=>Fe(t),readFile:(async(t,e)=>e===void 0?le(t):le(t,e)),rm:(t,e)=>Re(t,e),stat:t=>ze(t),writeFile:(t,e,n)=>Be(t,e,n)},Cn=(t,e,n)=>{const o=e.indexOf("--"),s=o===-1?new Set:new Set(e.slice(o+1)),i=n.filter(d=>d.startsWith("--")&&d!=="--"&&!s.has(d));if(i.length===0)return;const l=(t.options??[]).map(d=>d.name),a=i.flatMap(d=>j(d.slice(2),l).map(r=>`--${r}`));throw new nt(i,a)};class Ve{#t;#e;#d;#u;#p;#f;#O;#_;#C;#N;#x;#$;#I;#k=te;#m;#n;#o;#i;#s;#a;#g=!1;#E;#P=!1;#w;#y;#v;#l=[];#S(){return this.#w===void 0&&(this.#w=[...this.#o.keys()]),this.#w}#L(){return this.#y===void 0&&(this.#y=[...this.#n.keys()]),this.#y}#r(){return this.#v===void 0&&(this.#v=[...this.#S(),...this.#L()]),this.#v}#D(){return this.#l.length===0?J:[...J,...this.#l]}#M(){this.#w=void 0,this.#y=void 0,this.#v=void 0}#b(){if(this.#d===void 0){const e=wn(this.#e.argv);this.#d=Ce(e,{maxArguments:this.#$}),this.#T()}return this.#d}#A(){return this.#N??X()}#h(e){this.#k=e,this.#A().CEREBRO_OUTPUT_LEVEL=String(e)}#c(){const e=this.#A().CEREBRO_OUTPUT_LEVEL,n=e===void 0?Number.NaN:Number(e);return Number.isNaN(n)?this.#k:n}#T(){if(!this.#d)return;let e=!1;for(const n of this.#d){if(n==="--quiet"||n==="-q"){this.#h(Ge),e=!0;break}if(n==="--verbose"||n==="-v"){this.#h(He),e=!0;break}if(n==="--debug"){this.#h(T),e=!0;break}}e||this.#h(Object.hasOwn(this.#A(),"DEBUG")?T:te)}#j(){this.#P||(this.#E=yn(this.#t),this.#P=!0)}#U(){return{arch:Je(),argv:this.#b(),cwd:this.#u,env:this.#N??X(),exit:this.#C??(e=>F(e??0)),platform:Ye(),stdin:this.#x}}#V(e,n,o,s){this.#c()===T&&this.#t.debug(`command '${s}' found, parsing command args: ${n.join(", ")}`);const{arguments_:i,booleanValues:l,parsedArgs:a}=Gt(e,n,this.#D()),d=Object.keys(l).length>0;let r=a;d&&(r={...a,_all:{...a._all,...l}}),Zt(i,r,e);const m=Wt(e,a,l,o);m.runtime=this,m.argv=this.#b(),m.fs=this.#_??_n,m.process=this.#U(),m.console=this.#t;const h=e.options&&e.options.length>0;if(h&&e.options){const f=e.options.filter(y=>y.name.startsWith("no-"));for(const y of f){const E=y.name.slice(3),A=`--${y.name}`,I=`--${E}`,O=n.includes(A),v=n.includes(I);if(O&&v)throw new xe(E,y.name)}}return h&&(cn(m,e),dn(m,e)),Qt(i,m.options,e),Xt(m.options,e),this.#I&&Cn(e,n,m.rawUnknown),this.#c()===T&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(m.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(m.argument,null,2))),{arguments_:i,booleanValues:l,commandArgs:r,parsedArgs:a,toolbox:m}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new w("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#p=e.trim();const o=n.argv??se(),s=n.cwd??Ke();if(this.#e={...n,argv:o,cwd:s},this.#e.argv&&!Array.isArray(this.#e.argv))throw new w("CLI argv option must be an array of strings","INVALID_INPUT",{argv:this.#e.argv});if(this.#e.cwd&&typeof this.#e.cwd!="string")throw new w("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new w("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new w("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});if(typeof this.#e.logger=="object"){const r=["debug","error","info","log","warn"],m=[],h=this.#e.logger;for(const f of r)typeof h[f]!="function"&&m.push(f);if(m.length>0)throw new w(`Logger object is missing required methods: ${m.join(", ")}`,"INVALID_INPUT",{logger:this.#e.logger,missingMethods:m});this.#t=this.#e.logger}else this.#t={...console,debug:(...r)=>{this.#c()===T&&console.debug(...r)}};this.#f=this.#e.packageVersion,this.#O=this.#e.packageName,this.#u=this.#e.cwd,this.#s="help",this.#a={};const i=n.fs;if(i!==void 0&&(typeof i!="object"||i===null))throw new w("CLI fs option must be an object implementing the CerebroFs interface","INVALID_INPUT",{fs:n.fs});const l=n.exit;if(l!==void 0&&typeof l!="function")throw new w("CLI exit option must be a function","INVALID_INPUT",{exit:n.exit});const a=n.env;if(a!==void 0&&(typeof a!="object"||a===null))throw new w("CLI env option must be a record of string keys","INVALID_INPUT",{env:n.env});const d=n.stdin;if(d!==void 0&&typeof d!="string")throw new w("CLI stdin option must be a string","INVALID_INPUT",{stdin:n.stdin});this.#_=n.fs,this.#C=n.exit,this.#N=n.env,this.#x=n.stdin??"",this.#$=n.maxArguments,this.#I=n.strictOptions??!1,this.#h(te),this.#n=new Map,this.#o=new Map,this.#i=new Map}setCommandSection(e){return this.#a=e,this}getCommandSection(){return this.#a.header||(this.#a.header=`${this.#p}${this.#f?` v${this.#f}`:""}`),this.#a}setDefaultCommand(e){return this.#s=e,this}get defaultCommand(){return this.#s}addCommand(e){oe(e,"Command"),Z(e.name);const n=typeof e.execute=="function",o=typeof e.loader=="function";if(n&&o)throw new w(`Command "${e.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:e.name});if(!n&&!o)throw new w(`Command "${e.name}" must define either "execute" or "loader"`,"INVALID_COMMAND",{commandName:e.name});e.alias&&(typeof e.alias=="string"?Z(e.alias):_e(e.alias,"Command alias").forEach(r=>Z(r))),e.argument&&oe(e.argument,"Command argument"),e.options&&oe(e.options,"Command options"),e.commandPath&&(_e(e.commandPath,"Command commandPath"),e.commandPath.forEach(r=>{Z(r)}));const s=Ae(e.name,e.commandPath),i=B(s);if(this.#o.has(i))throw new w(`Command with path "${i}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name,commandPath:e.commandPath});const l=Array.isArray(e.commandPath)&&e.commandPath.length>0,a=this.#n.get(e.name),d=a!==void 0&&(a.commandPath===void 0||a.commandPath.length===0);if(!l&&d)throw new w(`Command with name "${e.name}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name});if(e.options)for(const r of e.options)de(r);if(en(e),ln(e),rn(e),e.options&&(e.__conflictingOptions__=e.options.filter(r=>r.conflicts!==void 0),e.__requiredOptions__=e.options.filter(r=>r.required===!0)),l&&a!==void 0)this.#n.set(i,e);else{if(!l&&a!==void 0&&!d){const r=Ae(a.name,a.commandPath);this.#n.set(B(r),a)}this.#n.set(e.name,e)}if(this.#o.set(i,s),this.#i.set(i,e),this.#M(),e.alias!==void 0){const r=typeof e.alias=="string"?[e.alias]:e.alias;for(const m of r){if(this.#c()===T&&this.#t.debug("adding alias",m),this.#n.has(m))throw new w(`Command alias "${m}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:m,commandName:e.name});this.#n.set(m,e)}}return this}addGlobalOption(e){const n=e,o=new Set(J.map(i=>i.name)),s=new Set(J.map(i=>i.alias).filter(Boolean));if(o.has(n.name))throw new w(`Cannot add global option "--${n.name}": it conflicts with a built-in global option`,"DUPLICATE_OPTION",{optionName:n.name});if(n.alias&&s.has(n.alias))throw new w(`Cannot add global option with alias "-${n.alias}": it conflicts with a built-in global option alias`,"DUPLICATE_OPTION",{alias:n.alias,optionName:n.name});if(new Set(this.#l.map(i=>i.name)).has(n.name))throw new w(`Global option "--${n.name}" has already been added`,"DUPLICATE_OPTION",{optionName:n.name});return n.group="global",de(n),this.#l.push(n),this}getGlobalOptions(){return this.#D()}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#m?this.#m:(this.#m=new it(this.#t),this.#m.register({description:"Attaches the logger to the toolbox",execute:e=>{e.logger=this.#t,e.console=e.logger},name:"logger"}),this.#m)}getCliName(){return this.#p}getPackageVersion(){return this.#f}getPackageName(){return this.#O}getCommands(){return this.#n}getCwd(){return this.#u}dispose(){this.#E?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:o=!0,...s}=e;if(!this.#n.has("help")){const{default:v}=await import("../commands/help-command.js");this.addCommand(new v(this.#n))}const i=this.#L(),l=this.#o;this.#j();const a=this.#b();let d,r=[...a];this.#c()===T&&(this.#t.debug(`process.execPath: ${Ze()}`),this.#t.debug(`process.execArgv: ${Qe().join(" ")}`),this.#t.debug(`process.argv: ${se().join(" ")}`));const m=tn(l,[...a]);if(m.commandPath)d=m.commandPath,r=m.argv;else{if(a.length>1&&a[0]&&a[1]&&!ie(a[0])&&!ie(a[1])){const $=[];let _=0;for(;_<a.length;){const V=a[_];if(!V||ie(V))break;$.push(V),_+=1}const L=B($);if($[0]&&!i.includes($[0])){const V=this.#r(),Y=j(L,V);throw new U(L,Y)}}let v;try{v=dt([null,...i],[...a])}catch($){if($ instanceof Error&&$.name==="INVALID_COMMAND"&&"command"in $){const _=$.command,L=this.#r(),V=j(_,L);throw new U(_,V)}throw $}v.command&&(d=[v.command],r=v.argv)}if(!d)if(this.#s)d=[this.#s];else{const v=this.#r();throw new U("",v)}const h=B(d),f=this.#o.get(h);let y;if(f){if(y=this.#i.get(h),!y||B(f)!==h){const v=this.#r(),$=j(h,v);throw new U(h,$)}}else{const v=d.at(-1);if(y=v?this.#n.get(v):void 0,!y){const $=this.#r(),_=j(h,$);throw new U(h,_)}}if(typeof y.execute!="function"&&typeof y.loader!="function")return this.#t.error(`Command "${y.name}" has no function to execute.`),o?F(1):void 0;const E=r;let A,I;try{({commandArgs:A,toolbox:I}=this.#V(y,E,s,h))}catch(v){if(this.#t.error(v),o)return F(1);throw v}const O=this.getPluginManager();try{!this.#g&&O.hasPlugins()&&(await O.init({cli:this,cwd:this.#u,logger:this.#t}),this.#g=!0),await O.executeLifecycle("execute",I),await O.executeLifecycle("beforeCommand",I);let v;const $=A.global;if($?.help){const _=this.#n.get("help");if(!_)throw new w("Help command not found","COMMAND_NOT_FOUND");v=await R(_,I)}else if($?.version??$?.V){const _=this.#n.get("version");if(!_)throw new w("Version command not found","COMMAND_NOT_FOUND");v=await R(_,I)}else v=await R(y,I);return await O.executeLifecycle("afterCommand",I,v),o?F(0):void 0}catch(v){throw await O.executeErrorHandlers(v,I),v}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:o=[],...s}=n;ae(e,"Command name");const i=e.split(" ").filter(Boolean),l=B(i),a=this.#o.get(l)?this.#i.get(l):this.#n.get(e);if(!a){const f=this.#r(),y=j(l||e,f);throw new U(e,y)}if(typeof a.execute!="function"&&typeof a.loader!="function")throw new w(`Command "${a.name}" has no function to execute`,"INVALID_COMMAND",{commandName:a.name});const d=[...Ce(o,{maxArguments:this.#$})];this.#c()===T&&this.#t.debug(`running command '${e}' programmatically with args: ${d.join(", ")}`);const{commandArgs:r,toolbox:m}=this.#V(a,d,s,l||e),h=this.getPluginManager();try{!this.#g&&h.hasPlugins()&&(await h.init({cli:this,cwd:this.#u,logger:this.#t}),this.#g=!0),await h.executeLifecycle("execute",m),await h.executeLifecycle("beforeCommand",m);let f;const y=r.global;if(y?.help){const E=this.#n.get("help");if(!E)throw new w("Help command not found","COMMAND_NOT_FOUND");f=await R(E,m)}else if(y?.version??y?.V){const E=this.#n.get("version");if(!E)throw new w("Version command not found","COMMAND_NOT_FOUND");f=await R(E,m)}else f=await R(a,m);return await h.executeLifecycle("afterCommand",m,f),f}catch(f){throw await h.executeErrorHandlers(f,m),f}}clone(e){const n={...this.#e,...e},o=new Ve(this.#p,n);for(const[s,i]of this.#n)o.#n.set(s,i);for(const[s,i]of this.#o)o.#o.set(s,[...i]);for(const[s,i]of this.#i)o.#i.set(s,i);for(const s of this.#l)o.#l.push(s);return o.#s=this.#s,o.#a={...this.#a},o.#M(),o}async getAction(e){ae(e,"Command name");const n=e.split(" ").filter(Boolean),o=B(n),s=this.#o.get(o)?this.#i.get(o):this.#n.get(e);if(!s){const i=this.#r(),l=j(o||e,i);throw new U(e,l)}if(typeof s.execute=="function")return s.execute;if(typeof s.loader=="function")return De(s);throw new w(`Command "${s.name}" has no execute or loader defined`,"INVALID_COMMAND",{commandName:s.name})}}export{Ve as Cli};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const O=1,T=2,E=4,I=16,R=32,U=64,_=128,S="positionals";export{O as OUTPUT_NORMAL,E as OUTPUT_PLAIN,T as OUTPUT_RAW,S as POSITIONALS_KEY,_ as VERBOSITY_DEBUG,R as VERBOSITY_NORMAL,I as VERBOSITY_QUIET,U as VERBOSITY_VERBOSE};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import{g as b,n as N}from"./renderError-B3ePOoBG-BmZlyMcr.js";import{S as re,s as ne,W as oe,X as ae,c as ie,Y as se,U as ue,R as le}from"./renderError-B3ePOoBG-BmZlyMcr.js";import{h as fe,c as pe}from"./VisulimaError-DTMgXonA-CzaryRgZ.js";const S=(e,t)=>{let r=0,o=t.length-2;for(;r<o;){const n=r+(o-r>>1);if(e<t[n])o=n-1;else if(e>=t[n+1])r=n+1;else{r=n;break}}return r},E=/\n|\r(?!\n)/,P=e=>e.split(E).reduce((t,r)=>(t.push(t.at(-1)+r.length+1),t),[0]),K=(e,t,r)=>{const o=r?.skipChecks??!1;if(!o&&(!Array.isArray(e)&&typeof e!="string"||(typeof e=="string"||Array.isArray(e))&&e.length===0))return{column:0,line:0};if(!o&&(typeof t!="number"||typeof e=="string"&&t>=e.length||Array.isArray(e)&&t+1>=e.at(-1)))return{column:0,line:0};if(typeof e=="string"){const a=P(e),i=S(t,a);return{column:t-a[i]+1,line:i+1}}const n=S(t,e);return{column:t-e[n]+1,line:n+1}},B=({applicationType:e,error:t,file:r})=>`You are a very skilled ${r.language??"unknown"} programmer.
|
|
2
|
+
|
|
3
|
+
${e?`You are working on a ${e} application.`:""}
|
|
4
|
+
|
|
5
|
+
Use the following context to find a possible fix for the exception message at the end. Limit your answer to 4 or 5 sentences. Also include a few links to documentation that might help.
|
|
6
|
+
|
|
7
|
+
Use this format in your answer, make sure links are json:
|
|
8
|
+
|
|
9
|
+
FIX
|
|
10
|
+
insert the possible fix here
|
|
11
|
+
ENDFIX
|
|
12
|
+
LINKS
|
|
13
|
+
{"title": "Title link 1", "url": "URL link 1"}
|
|
14
|
+
{"title": "Title link 2", "url": "URL link 2"}
|
|
15
|
+
ENDLINKS
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
Here comes the context and the exception message:
|
|
19
|
+
|
|
20
|
+
Line: ${String(r.line)}
|
|
21
|
+
|
|
22
|
+
File:
|
|
23
|
+
${r.file}
|
|
24
|
+
|
|
25
|
+
Snippet including line numbers:
|
|
26
|
+
${r.snippet??""}
|
|
27
|
+
|
|
28
|
+
Exception class:
|
|
29
|
+
${t.name}
|
|
30
|
+
|
|
31
|
+
Exception message:
|
|
32
|
+
${t.message}`,j=(e,t,r)=>{const o=r.indexOf(e);if(o===-1)return"";const n=o+e.length,a=r.indexOf(t,n);return a===-1?"":r.slice(n,a).trim()},X=e=>{const t=j("FIX","ENDFIX",e);if(!t)return["No solution found.",'Provide this response to the Maintainer of <a href="https://github.com/visulima/visulima/issues/new?assignees=&labels=s%3A+pending+triage%2Cc%3A+bug&projects=&template=bug_report.yml" target="_blank" rel="noopener noreferrer" class="text-blue-500 hover:underline inline-flex items-center text-sm">@visulima/error</a>.',`"${e}"`].join("</br></br>");const r=j("LINKS","ENDLINKS",e),o=r?r.split(`
|
|
33
|
+
`).map(a=>a.trim()).filter(Boolean).map(a=>{try{return JSON.parse(a)}catch{return}}).filter(a=>a!==void 0):[],n=o.length>0?`
|
|
34
|
+
|
|
35
|
+
## Links
|
|
36
|
+
|
|
37
|
+
${o.map(a=>`- <a href="${a.url}" target="_blank" rel="noopener noreferrer">${a.title}</a>`).join(`
|
|
38
|
+
`)}`:"";return`${t.replaceAll(/"([^"]*)"(?:\s|\.)/g,"<code>$1</code> ")}${n}
|
|
39
|
+
|
|
40
|
+
--------------------
|
|
41
|
+
This solution was generated with the <a href="https://sdk.vercel.ai/" target="_blank" rel="noopener noreferrer">AI SDK</a> and may not be 100% accurate.`},q={handle:e=>e.hint===void 0?Promise.resolve(void 0):typeof e.hint=="string"&&e.hint!==""?Promise.resolve({body:e.hint}):typeof e.hint=="object"&&typeof e.hint.body=="string"?Promise.resolve(e.hint):Array.isArray(e.hint)?Promise.resolve({body:e.hint.join(`
|
|
42
|
+
`)}):Promise.resolve(void 0),name:"errorHint",priority:1},A=e=>`\`\`\`
|
|
43
|
+
${e.trim()}
|
|
44
|
+
\`\`\``,d=e=>`\`\`\`bash
|
|
45
|
+
${e.trim()}
|
|
46
|
+
\`\`\``,h=e=>`\`\`\`ts
|
|
47
|
+
${e.trim()}
|
|
48
|
+
\`\`\``,I=e=>`\`\`\`js
|
|
49
|
+
${e.trim()}
|
|
50
|
+
\`\`\``,c=(e,...t)=>{const r=e.toLowerCase();return t.some(o=>r.includes(o.toLowerCase()))},T=[{name:"esm-cjs-interop",test:e=>{const{message:t}=e;if(c(t,"err_require_esm","cannot use import statement outside a module","must use import to load es module","require() of es module","does not provide an export named"))return{md:["Your project or a dependency may be mixing CommonJS and ES Modules.","","Try:","- Ensure package.json has the correct `type` (either `module` or `commonjs`).","- Use dynamic `import()` when requiring ESM from CJS.","- Prefer ESM-compatible entrypoints from dependencies.","- In Node, align `module` resolution with your bundler config.","","Check Node resolution:",d(`node -v
|
|
51
|
+
cat package.json | jq .type`),"","Example dynamic import in CJS:",I("(async () => { const mod = await import('some-esm'); mod.default(); })();")].join(`
|
|
52
|
+
`),title:"ESM/CJS interop"}}},{name:"missing-default-export",test:e=>{const{message:t}=e;if(c(t,"default export not found","has no default export","does not provide an export named 'default'","is not exported from"))return{md:["Verify your import/export shapes.","","Default export example:",h(`export default function Component() {}
|
|
53
|
+
// import Component from './file'`),"","Named export example:",h(`export function Component() {}
|
|
54
|
+
// import { Component } from './file'`)].join(`
|
|
55
|
+
`),title:"Export mismatch (default vs named)"}}},{name:"port-in-use",test:e=>{const{message:t}=e;if(c(t,"eaddrinuse","address already in use","listen eaddrinuse"))return{md:["Another process is using the port.","","Change the port or stop the other process.","","On macOS/Linux:",d(`lsof -i :3000
|
|
56
|
+
kill -9 <PID>`),"","On Windows (PowerShell):",d(`netstat -ano | findstr :3000
|
|
57
|
+
taskkill /PID <PID> /F`)].join(`
|
|
58
|
+
`),title:"Port already in use"}}},{name:"file-not-found-or-case",test:(e,t)=>{const{message:r}=e;if(c(r,"enoent","module not found","cannot find module"))return{md:["Check the import path and filename case (Linux/macOS are case-sensitive).","If using TS path aliases, verify `tsconfig.paths` and bundler aliases.","","Current file:",A(`${t.file}:${String(t.line)}`)].join(`
|
|
59
|
+
`),title:"Missing file or path case mismatch"}}},{name:"ts-path-mapping",test:e=>{const{message:t}=e;if(c(t,"ts2307","cannot find module")||t.includes("TS2307"))return{md:["If you use path aliases, align TS `paths` with Vite/Webpack resolve aliases.","Ensure file extensions are correct and included in resolver.","","tsconfig.json excerpt:",h(`{
|
|
60
|
+
"compilerOptions": {
|
|
61
|
+
"baseUrl": ".",
|
|
62
|
+
"paths": { "@/*": ["src/*"] }
|
|
63
|
+
}
|
|
64
|
+
}`)].join(`
|
|
65
|
+
`),title:"TypeScript path mapping / resolution"}}},{name:"network-dns-enotfound",test:e=>{const{message:t}=e;if(c(t,"enotfound","getaddrinfo enotfound","dns","fetch failed","ecconnrefused","econnrefused"))return{md:["The host may be unreachable or misconfigured.","","Try:","- Verify the hostname and protocol (http/https).","- Check VPN/proxy and firewall.","- Confirm the service is running and listening on the expected port.","",d(`ping <host>
|
|
66
|
+
nslookup <host>
|
|
67
|
+
curl -v http://<host>:<port>`)].join(`
|
|
68
|
+
`),title:"Network/DNS connection issue"}}},{name:"undefined-property",test:e=>{const{message:t}=e;if(c(t,"cannot read properties of undefined","reading '"))return{md:["A variable or function returned `undefined`.","","Mitigations:","- Add nullish checks before property access.","- Validate function return values and input props/state.","",h("const value = maybe?.prop; // or: if (maybe) { use(maybe.prop) }")].join(`
|
|
69
|
+
`),title:"Accessing property of undefined"}}}],H={handle:(e,t)=>{try{const r=T.map(n=>({match:n.test(e,t),rule:n})).filter(n=>!!n.match);if(r.length===0)return Promise.resolve(void 0);const o=r.toSorted((n,a)=>(n.match.priority??0)-(a.match.priority??0)).map(n=>`#### ${n.match.title}
|
|
70
|
+
|
|
71
|
+
${n.match.md}`).join(`
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
`);return o===""?Promise.resolve(void 0):Promise.resolve({body:o,header:"### Potential fixes detected"})}catch{return Promise.resolve(void 0)}},name:"ruleBasedHints",priority:0};let p=class extends Error{constructor(t){super(t),this.name="NonError"}};const z=()=>{if(!Error.captureStackTrace)return;const e=new Error;return Error.captureStackTrace(e),e.stack},x=e=>{if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null},_={maxDepth:Number.POSITIVE_INFINITY},$=(e,t,r=0)=>b(e)?v(e,t,r):t.maxDepth!==void 0&&r>=t.maxDepth?new p(JSON.stringify(e)):new p(JSON.stringify(e)),C=(e,t,r,o,n)=>{const a=t.map(i=>l(i,o,n+1));return new e(a,r)},v=(e,t,r)=>{if(t.maxDepth!==void 0&&r>=t.maxDepth)return new p(JSON.stringify(e));const{cause:o,errors:n,message:a,name:i,stack:s,...m}=e,O=N(i)??Error,u=i==="AggregateError"&&Array.isArray(n)?C(O,n,a,t,r):new O(a);return!u.name&&i&&(u.name=i),a!==void 0&&(u.message=a),s&&(u.stack=s),D(u,m,o,i,t,r),o!==void 0&&(u.cause=l(o,t,r+1)),J(u,e),u},l=(e,t,r)=>{if(x(e)){if(e.__dataType==="Map"&&Array.isArray(e.value))return new Map(e.value.map(([n,a])=>[l(n,t,r+1),l(a,t,r+1)]));if(e.__dataType==="Set"&&Array.isArray(e.value))return new Set(e.value.map(n=>l(n,t,r+1)));if(b(e))return $(e,t,r);const o={};for(const[n,a]of Object.entries(e))n==="__proto__"||n==="constructor"||n==="prototype"||(o[n]=l(a,t,r+1));return o}return Array.isArray(e)?e.map(o=>l(o,t,r)):e},D=(e,t,r,o,n,a)=>{const i=e;for(const[s,m]of Object.entries(t))if(!(s==="__proto__"||s==="constructor"||s==="prototype")){if(s==="cause"&&r!==void 0||s==="errors"&&o==="AggregateError")continue;Object.defineProperty(i,s,{configurable:!0,enumerable:!0,value:l(m,n,a+1),writable:!0})}},J=(e,t)=>{const r=new Set(["message","name","stack"]);for(const o of Object.keys(t))r.add(o);for(const o of r)if(o in e){const n=Object.getOwnPropertyDescriptor(e,o);n&&!n.enumerable&&Object.defineProperty(e,o,{...n,enumerable:!0})}},w=e=>new p(JSON.stringify(e)),F=e=>new p(JSON.stringify(e)),L=(e,t)=>b(e)?v(e,t,0):$(e,t),G=(e,t={})=>{const r={..._,...t};return e instanceof Error?e:e===null?w(null):typeof e=="string"||typeof e=="number"||typeof e=="boolean"?w(e):Array.isArray(e)?F(e):b(e)?v(e,r,0):x(e)?L(e,r):new p(JSON.stringify(e))},M=e=>{const t=e.methodName&&e.methodName!=="<unknown>"?`${e.methodName} `:"",r=e.file??"<unknown>",o=String(e.line??0),n=String(e.column??0);return t.trim()?` at ${t}(${r}:${o}:${n})`:` at ${r}:${o}:${n}`},Q=(e,t)=>{const r=[];if(t?.header&&(t.header.name||t.header.message)){const o=t.header.name??"Error",n=t.header.message??"";r.push(`${o}${n?": ":""}${n}`)}for(const o of e)r.push(M(o));return r.join(`
|
|
76
|
+
`)},R=Object.create({},{cause:{enumerable:!1,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!1,value:void 0,writable:!0},message:{enumerable:!1,value:void 0,writable:!0},name:{enumerable:!1,value:void 0,writable:!0},stack:{enumerable:!1,value:void 0,writable:!0}}),U=e=>{if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null},g=new WeakSet,k=e=>{const t=Object.getOwnPropertyNames(e);for(const r of t){const o=Object.getOwnPropertyDescriptor(e,r);o&&(o.enumerable||Object.defineProperty(e,r,{...o,enumerable:!0}),o.value&&typeof o.value=="object"&&!Array.isArray(o.value)&&(Object.getPrototypeOf(o.value)===Object.prototype||Object.getPrototypeOf(o.value)===null)&&k(o.value))}},V=e=>{g.add(e);const t=e.toJSON();return g.delete(e),Object.isExtensible(t)&&k(t),t},f=(e,t,r,o,n=new Set)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&"pipe"in e&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return t.has(e)?"[Circular]":(r+=1,y(e,o,t,r));if(o.useToJSON&&e!==null&&typeof e=="object"&&"toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();if(e instanceof Date)return e.toISOString();if(e instanceof RegExp)return e.toString();if(typeof URL<"u"&&e instanceof URL)return e.href;if(e instanceof Map){const a=[];for(const[i,s]of e.entries())a.push([f(i,t,r,o,n),f(s,t,r,o,n)]);return{__dataType:"Map",value:a}}if(e instanceof Set){const a=[];for(const i of e.values())a.push(f(i,t,r,o,n));return{__dataType:"Set",value:a}}if(typeof e=="function")return`[Function: ${e.name||"anonymous"}]`;if(typeof e=="bigint")return`${String(e)}n`;if(U(e)){if(n.has(e))return"[Circular]";if(o.maxDepth!==void 0&&o.maxDepth!==Number.POSITIVE_INFINITY&&r+1>=o.maxDepth)return{};r+=1,n.add(e);const a={};for(const i in e)a[i]=f(e[i],t,r,o,n);return n.delete(e),a}try{return e}catch{return"[Not Available]"}},y=(e,t,r,o)=>{if(r.add(e),t.maxDepth===0)return{};if(t.useToJSON&&typeof e.toJSON=="function"&&!g.has(e))return V(e);const n=Object.create(R);if(Object.defineProperty(n,"name",{configurable:!0,enumerable:!0,value:Object.prototype.toString.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,writable:!0}),Object.defineProperty(n,"message",{configurable:!0,enumerable:!0,value:e.message,writable:!0}),Object.defineProperty(n,"stack",{configurable:!0,enumerable:!0,value:e.stack,writable:!0}),Array.isArray(e.errors)){const i=[];for(const s of e.errors){if(!(s instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(r.has(s))return Object.defineProperty(n,"errors",{configurable:!0,enumerable:!0,value:[],writable:!0}),n;i.push(y(s,t,r,o))}Object.defineProperty(n,"errors",{configurable:!0,enumerable:!0,value:i,writable:!0})}const a=e.cause;if(a!=null)if(a instanceof Error)r.has(a)?Object.defineProperty(n,"cause",{configurable:!0,enumerable:!0,value:"[Circular]",writable:!0}):Object.defineProperty(n,"cause",{configurable:!0,enumerable:!0,value:y(a,t,r,o),writable:!0});else{const i=f(a,r,o,t);Object.defineProperty(n,"cause",{configurable:!0,enumerable:!0,value:i,writable:!0})}for(const i in e){if(i==="name"||i==="message"||i==="stack"||i==="cause"||i==="errors")continue;const s=e[i],m=f(s,r,o,t);Object.defineProperty(n,i,{configurable:!0,enumerable:!0,value:m,writable:!0})}if(Array.isArray(t.exclude)&&t.exclude.length>0)for(const i of t.exclude)try{delete n[i]}catch{}return n},Z=(e,t={})=>y(e,{exclude:t.exclude??[],maxDepth:t.maxDepth??Number.POSITIVE_INFINITY,useToJSON:t.useToJSON??!1},new Set,0);export{re as CODE_FRAME_POINTER,p as NonError,fe as VisulimaError,ne as addKnownErrorConstructor,B as aiPrompt,X as aiSolutionResponse,z as captureRawStackTrace,oe as codeFrame,ae as composeFilters,G as deserializeError,q as errorHintFinder,M as formatStackFrameLine,Q as formatStacktrace,ie as getErrorCauses,K as indexToLineColumn,b as isErrorLike,pe as isVisulimaError,se as parseStacktrace,ue as renderError,H as ruleBasedFinder,Z as serializeError,le as stackFilters};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const h=s=>s instanceof Error&&s.type==="VisulimaError";class n extends Error{loc;title;hint;type="VisulimaError";constructor({cause:t,hint:e,location:i,message:a,name:c,stack:o,title:r}){super(a,{cause:t}),this.title=r,this.name=c,this.stack=o??this.stack,this.loc=i,this.hint=e}setLocation(t){this.loc=t}setName(t){this.name=t}setMessage(t){this.message=t}setHint(t){this.hint=t}}export{h as c,n as h};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./renderError-B3ePOoBG-BmZlyMcr.js";import{h as r}from"./VisulimaError-DTMgXonA-CzaryRgZ.js";class n extends r{code;context;constructor(e,t,o){super({message:e,name:"CerebroError"}),this.code=t,this.context=o}}export{n as t};
|