@visulima/cerebro 3.0.0-alpha.11 → 3.0.0-alpha.13

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.
Files changed (74) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/LICENSE.md +471 -4345
  3. package/README.md +26 -0
  4. package/dist/commands/completion-command.d.ts +6 -5
  5. package/dist/commands/help-command.d.ts +9 -9
  6. package/dist/commands/help-command.js +63 -1
  7. package/dist/commands/readme-command.d.ts +6 -5
  8. package/dist/commands/readme-command.js +1 -1
  9. package/dist/commands/version-command.d.ts +4 -3
  10. package/dist/index.d.ts +422 -95
  11. package/dist/index.js +2 -1
  12. package/dist/logger/create-pail-logger.d.ts +779 -8
  13. package/dist/packem_shared/{Cerebro-CXEIHSN2.js → Cerebro-C1h3DXwy.js} +66 -8
  14. package/dist/packem_shared/{index-DNXLgme3.js → index--1UArng3.js} +1 -2
  15. package/dist/packem_shared/index.d-Br8HpP0A.d.ts +93 -0
  16. package/dist/packem_shared/lazyNamed-B278Tf9_.js +6 -0
  17. package/dist/packem_shared/plugin-manager.d-Du-YXFui.d.ts +541 -0
  18. package/dist/plugins/error-handler-plugin.d.ts +21 -19
  19. package/dist/plugins/runtime-version-check-plugin.d.ts +22 -20
  20. package/dist/plugins/update-notifier/update-notifier-plugin.d.ts +21 -8
  21. package/dist/plugins/update-notifier/update-notifier-plugin.js +1 -2
  22. package/dist/util/general/compile-cache.d.ts +38 -38
  23. package/dist/util/general/heap-tuning.d.ts +14 -77
  24. package/package.json +18 -18
  25. package/dist/cli.d.ts +0 -225
  26. package/dist/constants.d.ts +0 -29
  27. package/dist/default-env.d.ts +0 -7
  28. package/dist/default-options.d.ts +0 -3
  29. package/dist/empty-toolbox.d.ts +0 -16
  30. package/dist/errors/cerebro-error.d.ts +0 -10
  31. package/dist/errors/command-not-found-error.d.ts +0 -9
  32. package/dist/errors/command-validation-error.d.ts +0 -10
  33. package/dist/errors/completion-error.d.ts +0 -9
  34. package/dist/errors/conflicting-options-error.d.ts +0 -10
  35. package/dist/errors/plugin-error.d.ts +0 -9
  36. package/dist/errors/update-notifier-error.d.ts +0 -7
  37. package/dist/plugin-manager.d.ts +0 -53
  38. package/dist/plugins/update-notifier/cache.d.ts +0 -11
  39. package/dist/plugins/update-notifier/get-distribution-version.d.ts +0 -2
  40. package/dist/plugins/update-notifier/has-new-version.d.ts +0 -14
  41. package/dist/types/cli.d.ts +0 -113
  42. package/dist/types/command-line-usage.d.ts +0 -37
  43. package/dist/types/command.d.ts +0 -136
  44. package/dist/types/option-types.d.ts +0 -83
  45. package/dist/types/options.d.ts +0 -4
  46. package/dist/types/plugin.d.ts +0 -53
  47. package/dist/types/toolbox.d.ts +0 -120
  48. package/dist/util/arg-processing/get-boolean-values.d.ts +0 -7
  49. package/dist/util/arg-processing/get-parameter-option.d.ts +0 -7
  50. package/dist/util/arg-processing/map-option-type-label.d.ts +0 -3
  51. package/dist/util/arg-processing/option-is-boolean.d.ts +0 -9
  52. package/dist/util/arg-processing/remove-boolean-values.d.ts +0 -9
  53. package/dist/util/command-line-commands.d.ts +0 -10
  54. package/dist/util/command-line-usage/get-terminal-width.d.ts +0 -7
  55. package/dist/util/command-line-usage/index.d.ts +0 -3
  56. package/dist/util/command-line-usage/section/base-section.d.ts +0 -8
  57. package/dist/util/command-line-usage/section/content-section.d.ts +0 -65
  58. package/dist/util/command-line-usage/section/option-list-section.d.ts +0 -44
  59. package/dist/util/command-processing/command-processor.d.ts +0 -37
  60. package/dist/util/command-processing/command-validation.d.ts +0 -17
  61. package/dist/util/command-processing/nested-command-parser.d.ts +0 -25
  62. package/dist/util/command-processing/option-processor.d.ts +0 -44
  63. package/dist/util/data-processing/list-missing-arguments.d.ts +0 -15
  64. package/dist/util/data-processing/merge-arguments.d.ts +0 -7
  65. package/dist/util/general/find-alternatives.d.ts +0 -8
  66. package/dist/util/general/hide-bin.d.ts +0 -2
  67. package/dist/util/general/parse-raw-command.d.ts +0 -7
  68. package/dist/util/general/register-exception-handler.d.ts +0 -9
  69. package/dist/util/general/runtime-process.d.ts +0 -65
  70. package/dist/util/general/semver-gt.d.ts +0 -2
  71. package/dist/util/general/validate-input.d.ts +0 -24
  72. package/dist/util/process-env-variables.d.ts +0 -9
  73. package/dist/util/security.d.ts +0 -58
  74. package/dist/util/text-processing/template-format.d.ts +0 -5
@@ -1,41 +1,41 @@
1
1
  /**
2
- * V8 compile cache helper for faster CLI startup.
3
- *
4
- * Enables the V8 compile cache so that subsequent runs of the CLI skip
5
- * re-parsing and re-compiling JavaScript/TypeScript source files. This
6
- * can reduce startup time by 30-70% for large CLI tools.
7
- *
8
- * ## When to use
9
- *
10
- * Call `enableCompileCache()` early in your CLI entry point, after heap
11
- * tuning but before importing heavy modules:
12
- *
13
- * ```typescript
14
- * // bin.ts
15
- * import { applyHeapTuning } from "@visulima/cerebro/heap-tuning";
16
- * import { enableCompileCache } from "@visulima/cerebro/compile-cache";
17
- *
18
- * applyHeapTuning();
19
- * enableCompileCache();
20
- *
21
- * import { createCerebro } from "@visulima/cerebro";
22
- * // ... rest of your CLI setup
23
- * ```
24
- *
25
- * ## How it works
26
- *
27
- * 1. Tries `module.enableCompileCache()` (Node.js 22.8+ native API) which
28
- * stores compiled bytecode alongside source files for instant reuse.
29
- * 2. If that's unavailable, falls back to the `v8-compile-cache` npm package
30
- * which achieves a similar effect on older Node.js versions.
31
- * 3. If neither is available, silently does nothing — startup is just slower.
32
- * @module
33
- */
2
+ * V8 compile cache helper for faster CLI startup.
3
+ *
4
+ * Enables the V8 compile cache so that subsequent runs of the CLI skip
5
+ * re-parsing and re-compiling JavaScript/TypeScript source files. This
6
+ * can reduce startup time by 30-70% for large CLI tools.
7
+ *
8
+ * ## When to use
9
+ *
10
+ * Call `enableCompileCache()` early in your CLI entry point, after heap
11
+ * tuning but before importing heavy modules:
12
+ *
13
+ * ```typescript
14
+ * // bin.ts
15
+ * import { applyHeapTuning } from "@visulima/cerebro/heap-tuning";
16
+ * import { enableCompileCache } from "@visulima/cerebro/compile-cache";
17
+ *
18
+ * applyHeapTuning();
19
+ * enableCompileCache();
20
+ *
21
+ * import { createCerebro } from "@visulima/cerebro";
22
+ * // ... rest of your CLI setup
23
+ * ```
24
+ *
25
+ * ## How it works
26
+ *
27
+ * 1. Tries `module.enableCompileCache()` (Node.js 22.8+ native API) which
28
+ * stores compiled bytecode alongside source files for instant reuse.
29
+ * 2. If that's unavailable, falls back to the `v8-compile-cache` npm package
30
+ * which achieves a similar effect on older Node.js versions.
31
+ * 3. If neither is available, silently does nothing — startup is just slower.
32
+ * @module
33
+ */
34
34
  /**
35
- * Enable V8 compile cache for faster subsequent CLI startups.
36
- *
37
- * Safe to call unconditionally — silently no-ops if the runtime doesn't
38
- * support compile caching or the fallback package isn't installed.
39
- */
35
+ * Enable V8 compile cache for faster subsequent CLI startups.
36
+ *
37
+ * Safe to call unconditionally — silently no-ops if the runtime doesn't
38
+ * support compile caching or the fallback package isn't installed.
39
+ */
40
40
  declare const enableCompileCache: () => void;
41
- export default enableCompileCache;
41
+ export { enableCompileCache as default };
@@ -1,81 +1,18 @@
1
- /**
2
- * Dynamic V8 heap memory tuning based on system memory.
3
- *
4
- * This helper computes optimal `--max-old-space-size` and `--max-semi-space-size`
5
- * flags for Node.js/Bun, then re-spawns the process with those flags applied.
6
- * If the flags are already set (via `NODE_OPTIONS` or direct CLI arguments),
7
- * the user's values are respected and no re-spawn occurs.
8
- *
9
- * ## When to use
10
- *
11
- * Import this helper **before** any heavy work — ideally as the very first
12
- * import in your CLI entry point. Because V8 memory flags can only be set at
13
- * process startup, this helper works by re-spawning the current process with
14
- * the computed flags when they are missing. After re-spawn, the module detects
15
- * that flags are already present and becomes a no-op.
16
- *
17
- * ## How to use
18
- *
19
- * Call `applyHeapTuning()` as early as possible in your CLI entry point,
20
- * **before** creating the cerebro instance or importing heavy modules:
21
- *
22
- * ```typescript
23
- * // bin.ts
24
- * import { applyHeapTuning } from "@visulima/cerebro/heap-tuning";
25
- *
26
- * // Apply with defaults (75% of system RAM)
27
- * applyHeapTuning();
28
- *
29
- * // Or customize the allocation percentage
30
- * applyHeapTuning({ maxOldSpacePercent: 0.5 });
31
- *
32
- * import { createCerebro } from "@visulima/cerebro";
33
- * // ... rest of your CLI setup
34
- * ```
35
- *
36
- * If heap tuning is needed, `applyHeapTuning()` re-spawns the process and
37
- * **never returns** — subsequent code in the parent is not reached. After
38
- * re-spawn, the flags are already set so the call becomes a no-op.
39
- *
40
- * ## How it works
41
- *
42
- * 1. Checks `process.execArgv` for existing `--max-old-space-size` and
43
- * `--max-semi-space-size` flags.
44
- * 2. If both are present, returns immediately (no-op).
45
- * 3. Otherwise, computes defaults:
46
- * - `--max-old-space-size`: percentage of total system memory (default 75%)
47
- * - `--max-semi-space-size`: tiered scaling based on old-space size
48
- * 4. Re-spawns the current process via `execFileSync` with the computed flags
49
- * prepended to `execArgv`, then exits the parent with the child's exit code.
50
- *
51
- * ## Semi-space sizing tiers
52
- *
53
- * | Old-space (MiB) | Semi-space (MiB) |
54
- * |-----------------|-----------------|
55
- * | <= 512 | 4 |
56
- * | <= 1024 | 8 |
57
- * | <= 2048 | 16 |
58
- * | <= 4096 | 32 |
59
- * | <= 8192 | 64 |
60
- * | > 8192 | log2-scaled |
61
- * @module
62
- */
63
1
  interface HeapTuningOptions {
64
- /**
65
- * Fraction of total system memory to allocate as `--max-old-space-size`.
66
- * Must be between 0 and 1. Default: `0.75` (75%).
67
- */
68
- maxOldSpacePercent?: number;
2
+ /**
3
+ * Fraction of total system memory to allocate as `--max-old-space-size`.
4
+ * Must be between 0 and 1. Default: `0.75` (75%).
5
+ */
6
+ maxOldSpacePercent?: number;
69
7
  }
70
8
  /**
71
- * Apply heap memory tuning to the current process.
72
- *
73
- * When tuning is needed, this function re-spawns the process with computed
74
- * V8 memory flags and **never returns** — the parent exits with the child's
75
- * exit code. When no tuning is needed (flags already set), it returns
76
- * immediately.
77
- * @param options Optional configuration for heap tuning.
78
- */
9
+ * Apply heap memory tuning to the current process.
10
+ *
11
+ * When tuning is needed, this function re-spawns the process with computed
12
+ * V8 memory flags and **never returns** — the parent exits with the child's
13
+ * exit code. When no tuning is needed (flags already set), it returns
14
+ * immediately.
15
+ * @param options Optional configuration for heap tuning.
16
+ */
79
17
  declare const applyHeapTuning: (options?: HeapTuningOptions) => void;
80
- export type { HeapTuningOptions };
81
- export { applyHeapTuning };
18
+ export { type HeapTuningOptions, applyHeapTuning };
package/package.json CHANGED
@@ -1,34 +1,34 @@
1
1
  {
2
2
  "name": "@visulima/cerebro",
3
- "version": "3.0.0-alpha.11",
3
+ "version": "3.0.0-alpha.13",
4
4
  "description": "A delightful toolkit for building cross-runtime CLIs for Node.js, Deno, and Bun.",
5
5
  "keywords": [
6
- "visulima",
7
- "command",
8
- "line",
9
- "class",
10
- "terminal",
11
6
  "ansi",
12
- "cli",
13
- "opts",
14
- "nopt",
15
- "options",
16
7
  "args",
8
+ "argument",
17
9
  "argv",
18
- "interactive",
19
- "commander",
20
10
  "clap",
11
+ "class",
12
+ "cli",
21
13
  "cli-app",
22
- "minimist",
14
+ "command",
23
15
  "command line apps",
24
16
  "command-line-usage",
25
- "option",
26
- "parser",
27
- "argument",
17
+ "commander",
28
18
  "flag",
29
19
  "gluegun",
20
+ "interactive",
21
+ "line",
30
22
  "meow",
23
+ "minimist",
24
+ "nopt",
31
25
  "oclif",
26
+ "option",
27
+ "options",
28
+ "opts",
29
+ "parser",
30
+ "terminal",
31
+ "visulima",
32
32
  "yargs"
33
33
  ],
34
34
  "homepage": "https://visulima.com/packages/cerebro",
@@ -116,10 +116,10 @@
116
116
  "fastest-levenshtein": "^1.0.16"
117
117
  },
118
118
  "peerDependencies": {
119
- "@bomb.sh/tab": "0.0.14",
119
+ "@bomb.sh/tab": "0.0.15",
120
120
  "@visulima/boxen": "3.0.0-alpha.10",
121
121
  "@visulima/find-cache-dir": "3.0.0-alpha.9",
122
- "@visulima/pail": "4.0.0-alpha.11",
122
+ "@visulima/pail": "4.0.0-alpha.12",
123
123
  "github-slugger": "2.0.0"
124
124
  },
125
125
  "peerDependenciesMeta": {
package/dist/cli.d.ts DELETED
@@ -1,225 +0,0 @@
1
- import PluginManager from "./plugin-manager.d.ts";
2
- import type { Cli as ICli, CliRunOptions, CommandSection as ICommandSection, RunCommandOptions } from "./types/cli.d.ts";
3
- import type { Command as ICommand, OptionDefinition } from "./types/command.d.ts";
4
- import type { Plugin } from "./types/plugin.d.ts";
5
- export type CliOptions<T extends Console = Console> = {
6
- argv?: ReadonlyArray<string>;
7
- cwd?: string;
8
- logger?: T;
9
- packageName?: string;
10
- packageVersion?: string;
11
- };
12
- export declare class Cli<T extends Console = Console> implements ICli<T> {
13
- #private;
14
- /**
15
- * Create a new CLI instance.
16
- * @param cliName
17
- * @param options The options for the CLI.
18
- * @param options.argv The command line arguments.
19
- * @param options.cwd The current working directory.
20
- * @param options.logger The logger to use.
21
- * @param options.packageName
22
- * @param options.packageVersion
23
- */
24
- constructor(cliName: string, options?: CliOptions<T>);
25
- /**
26
- * Sets the command section configuration for help display.
27
- *
28
- * This affects how the CLI name and version are displayed in help output.
29
- * @param commandSection The command section configuration
30
- * @returns The CLI instance for method chaining
31
- * @example
32
- * ```typescript
33
- * cli.setCommandSection({
34
- * header: 'My App v2.0.0',
35
- * footer: 'For more info, visit https://example.com'
36
- * });
37
- * ```
38
- */
39
- setCommandSection(commandSection: ICommandSection): this;
40
- /**
41
- * Gets the current command section configuration.
42
- * @returns The command section configuration
43
- */
44
- getCommandSection(): ICommandSection;
45
- /**
46
- * Sets the default command to run when no command is specified.
47
- *
48
- * By default, this is set to 'help'. The command must already be registered
49
- * with the CLI instance.
50
- * @param commandName The command name to use as the default
51
- * @returns The CLI instance for method chaining
52
- * @example
53
- * ```typescript
54
- * cli.setDefaultCommand('start');
55
- * ```
56
- */
57
- setDefaultCommand(commandName: string): this;
58
- /**
59
- * Gets the current default command.
60
- * @returns The name of the default command
61
- */
62
- get defaultCommand(): string;
63
- /**
64
- * Adds a command to the CLI.
65
- *
66
- * Commands define the available operations that users can execute.
67
- * Each command can have options, arguments, aliases, and custom execution logic.
68
- * @template OD - The option definition type for the command
69
- * @param command The command configuration object
70
- * @returns The CLI instance for method chaining
71
- * @throws {CerebroError} If the command name already exists or validation fails
72
- * @example
73
- * ```typescript
74
- * cli.addCommand({
75
- * name: 'build',
76
- * description: 'Build the project',
77
- * options: [
78
- * {
79
- * name: 'output',
80
- * alias: 'o',
81
- * type: String,
82
- * description: 'Output directory'
83
- * }
84
- * ],
85
- * execute: ({ options }) => {
86
- * console.log(`Building to ${options.output || 'dist'}`);
87
- * }
88
- * });
89
- * ```
90
- */
91
- addCommand<OD extends OptionDefinition<unknown> = OptionDefinition<unknown>>(command: ICommand<OD, T>): this;
92
- /**
93
- * Adds a global option available to all commands.
94
- *
95
- * Global options are parsed alongside command-specific options and displayed
96
- * in the help output under the "Global Options" section.
97
- * @param option The option definition
98
- * @returns The CLI instance for method chaining
99
- * @example
100
- * ```typescript
101
- * cli.addGlobalOption({
102
- * name: 'cwd',
103
- * type: String,
104
- * description: 'Override working directory',
105
- * });
106
- * ```
107
- */
108
- addGlobalOption<V = unknown>(option: OptionDefinition<V>): this;
109
- /**
110
- * Gets all global options (built-in + custom).
111
- * @returns Array of all global option definitions
112
- */
113
- getGlobalOptions(): OptionDefinition<unknown>[];
114
- /**
115
- * Adds a plugin to extend the CLI functionality.
116
- *
117
- * Plugins can hook into various lifecycle events and modify the toolbox
118
- * to provide additional functionality to commands.
119
- * @param plugin The plugin to register
120
- * @returns The CLI instance for method chaining
121
- * @example
122
- * ```typescript
123
- * cli.addPlugin({
124
- * name: 'logger',
125
- * execute: (toolbox) => {
126
- * toolbox.logger = createCustomLogger();
127
- * }
128
- * });
129
- * ```
130
- */
131
- addPlugin(plugin: Plugin<T>): this;
132
- /**
133
- * Gets the plugin manager instance for advanced plugin management.
134
- * @returns The plugin manager instance
135
- */
136
- getPluginManager(): PluginManager<T>;
137
- /**
138
- * Gets the CLI application name.
139
- */
140
- getCliName(): string;
141
- /**
142
- * Gets the package version if configured.
143
- * @returns The package version or undefined
144
- */
145
- getPackageVersion(): string | undefined;
146
- /**
147
- * Gets the package name if configured.
148
- * @returns The package name or undefined
149
- */
150
- getPackageName(): string | undefined;
151
- /**
152
- * Gets all registered commands.
153
- * @returns A map of command names to command definitions
154
- */
155
- getCommands(): Map<string, ICommand<OptionDefinition<unknown>, T>>;
156
- /**
157
- * Gets the current working directory.
158
- * @returns The current working directory path
159
- */
160
- getCwd(): string;
161
- /**
162
- * Disposes the CLI instance and cleans up resources.
163
- *
164
- * This method removes event listeners and performs cleanup to prevent memory leaks.
165
- * Call this method when the CLI instance is no longer needed, especially in long-running
166
- * processes or when creating multiple CLI instances.
167
- * @example
168
- * ```typescript
169
- * const cli = new Cerebro('my-app');
170
- * // ... use the cli
171
- * cli.dispose(); // Clean up when done
172
- * ```
173
- */
174
- dispose(): void;
175
- /**
176
- * Runs the CLI application.
177
- *
178
- * This method parses command line arguments, executes the appropriate command,
179
- * and handles the complete CLI lifecycle including plugin initialization,
180
- * error handling, process termination, and automatic cleanup.
181
- * @param extraOptions Additional options to pass to commands
182
- * @param extraOptions.shouldExitProcess Whether to exit the process after execution (default: true)
183
- * @param extraOptions.autoDispose Whether to automatically cleanup/dispose resources after execution (default: true)
184
- * @returns A promise that resolves when execution completes
185
- * @throws {CommandNotFoundError} If the specified command doesn't exist
186
- * @throws {Error} If command arguments are invalid or conflicting options are provided
187
- * @example
188
- * ```typescript
189
- * // Run with default behavior (exits process and auto-disposes)
190
- * await cli.run();
191
- *
192
- * // Run without exiting (for testing)
193
- * await cli.run({ shouldExitProcess: false });
194
- *
195
- * // Run without auto-disposing (for reuse)
196
- * await cli.run({ autoDispose: false });
197
- * ```
198
- */
199
- run(extraOptions?: CliRunOptions): Promise<void>;
200
- /**
201
- * Runs a command programmatically from within another command.
202
- *
203
- * This method allows commands to call other commands during execution,
204
- * enabling composition of commands and reusable command logic.
205
- * @param commandName The name of the command to execute
206
- * @param options Optional options including argv and other command options
207
- * @returns A promise that resolves with the command's result
208
- * @throws {CommandNotFoundError} If the specified command doesn't exist
209
- * @throws {CerebroError} If command validation fails
210
- * @example
211
- * ```typescript
212
- * cli.addCommand({
213
- * name: 'deploy',
214
- * execute: async ({ runtime, logger }) => {
215
- * logger.info('Building...');
216
- * await runtime.runCommand('build', { argv: ['--production'] });
217
- *
218
- * logger.info('Testing...');
219
- * await runtime.runCommand('test', { argv: ['--coverage'] });
220
- * }
221
- * });
222
- * ```
223
- */
224
- runCommand(commandName: string, options?: RunCommandOptions): Promise<unknown>;
225
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * Output with this option will be formatted.
3
- */
4
- export declare const OUTPUT_NORMAL = 1;
5
- /**
6
- * Output with this option will be passed as-is.
7
- */
8
- export declare const OUTPUT_RAW = 2;
9
- /**
10
- * Output with this option will have any formatting stripped away.
11
- */
12
- export declare const OUTPUT_PLAIN = 4;
13
- /**
14
- * Output with this verbosity won't write anything at all.
15
- */
16
- export declare const VERBOSITY_QUIET = 16;
17
- /**
18
- * Output with this verbosity will write default content.
19
- */
20
- export declare const VERBOSITY_NORMAL = 32;
21
- /**
22
- * Output with this verbosity will be more detailed.
23
- */
24
- export declare const VERBOSITY_VERBOSE = 64;
25
- /**
26
- * Output with this verbosity will reveal internals.
27
- */
28
- export declare const VERBOSITY_DEBUG = 128;
29
- export declare const POSITIONALS_KEY = "positionals";
@@ -1,7 +0,0 @@
1
- import type { EnvDefinition } from "./types/command.d.ts";
2
- /**
3
- * Default environment variables used by Cerebro CLI framework.
4
- * These are displayed in the help output.
5
- */
6
- declare const defaultEnv: (EnvDefinition | EnvDefinition<number> | EnvDefinition<boolean>)[];
7
- export default defaultEnv;
@@ -1,3 +0,0 @@
1
- import type { OptionDefinition } from "./types/command.d.ts";
2
- declare const defaultOptions: OptionDefinition<boolean>[];
3
- export default defaultOptions;
@@ -1,16 +0,0 @@
1
- import type { Toolbox as IToolbox } from "./types/toolbox.d.ts";
2
- declare class EmptyToolbox implements Partial<IToolbox> {
3
- [x: string]: unknown;
4
- result?: unknown;
5
- argv?: IToolbox["argv"];
6
- options?: IToolbox["options"];
7
- argument?: IToolbox["argument"];
8
- command: IToolbox["command"];
9
- commandName: IToolbox["commandName"];
10
- env?: IToolbox["env"];
11
- logger?: IToolbox["logger"];
12
- runtime?: IToolbox["runtime"];
13
- rawUnknown?: IToolbox["rawUnknown"];
14
- constructor(commandName: IToolbox["commandName"], command: IToolbox["command"]);
15
- }
16
- export default EmptyToolbox;
@@ -1,10 +0,0 @@
1
- import { VisulimaError } from "@visulima/error";
2
- /**
3
- * Base error class for Cerebro CLI operations.
4
- */
5
- declare class CerebroError extends VisulimaError {
6
- readonly code: string;
7
- readonly context?: Record<string, unknown>;
8
- constructor(message: string, code: string, context?: Record<string, unknown>);
9
- }
10
- export default CerebroError;
@@ -1,9 +0,0 @@
1
- import CerebroError from "./cerebro-error.d.ts";
2
- /**
3
- * Error thrown when a command is not found.
4
- */
5
- declare class CommandNotFoundError extends CerebroError {
6
- readonly commandName: string;
7
- constructor(commandName: string, suggestions?: string[]);
8
- }
9
- export default CommandNotFoundError;
@@ -1,10 +0,0 @@
1
- import CerebroError from "./cerebro-error.d.ts";
2
- /**
3
- * Error thrown when command validation fails.
4
- */
5
- declare class CommandValidationError extends CerebroError {
6
- readonly commandName: string;
7
- readonly missingOptions: string[];
8
- constructor(commandName: string, missingOptions: string[]);
9
- }
10
- export default CommandValidationError;
@@ -1,9 +0,0 @@
1
- import CerebroError from "./cerebro-error.d.ts";
2
- /**
3
- * Error thrown when completion command operations fail.
4
- */
5
- declare class CompletionError extends CerebroError {
6
- readonly troubleshooting: string[];
7
- constructor(message: string, code: string, troubleshooting?: string[]);
8
- }
9
- export default CompletionError;
@@ -1,10 +0,0 @@
1
- import CerebroError from "./cerebro-error.d.ts";
2
- /**
3
- * Error thrown when there are conflicting options.
4
- */
5
- declare class ConflictingOptionsError extends CerebroError {
6
- readonly option1: string;
7
- readonly option2: string;
8
- constructor(option1: string, option2: string);
9
- }
10
- export default ConflictingOptionsError;
@@ -1,9 +0,0 @@
1
- import CerebroError from "./cerebro-error.d.ts";
2
- /**
3
- * Error thrown when plugin operations fail.
4
- */
5
- declare class PluginError extends CerebroError {
6
- readonly pluginName: string;
7
- constructor(pluginName: string, message: string, originalError?: Error);
8
- }
9
- export default PluginError;
@@ -1,7 +0,0 @@
1
- import CerebroError from "./cerebro-error.d.ts";
2
- /**
3
- * Error thrown when update notifier operations fail.
4
- */
5
- export default class UpdateNotifierError extends CerebroError {
6
- constructor(message: string, code?: string, context?: Record<string, unknown>);
7
- }
@@ -1,53 +0,0 @@
1
- import type { Plugin, PluginContext } from "./types/plugin.d.ts";
2
- import type { Toolbox } from "./types/toolbox.d.ts";
3
- type Logger = Console;
4
- /**
5
- * Manages plugin lifecycle and execution
6
- */
7
- declare class PluginManager<T extends Logger = Logger> {
8
- private readonly logger;
9
- private readonly plugins;
10
- private initialized;
11
- private cachedDependencyOrder;
12
- constructor(logger: T);
13
- /**
14
- * Checks if any plugins are registered.
15
- * @returns True if at least one plugin is registered
16
- */
17
- hasPlugins(): boolean;
18
- /**
19
- * Registers a plugin.
20
- * @param plugin The plugin to register
21
- * @throws {Error} If plugin name is already registered or dependencies are invalid
22
- */
23
- register(plugin: Plugin<T>): void;
24
- /**
25
- * Initializes all registered plugins.
26
- * @param context The plugin context for initialization
27
- */
28
- init(context: PluginContext<T>): Promise<void>;
29
- /**
30
- * Executes a specific lifecycle hook for all plugins.
31
- * @param hook The lifecycle hook name
32
- * @param toolbox The command toolbox (for command-specific hooks)
33
- * @param result The command result (for afterCommand hook)
34
- */
35
- executeLifecycle(hook: "beforeCommand" | "afterCommand" | "execute", toolbox: Toolbox<T>, result?: unknown): Promise<void>;
36
- /**
37
- * Executes error handlers for all plugins.
38
- * @param error The error that occurred
39
- * @param toolbox The command toolbox
40
- */
41
- executeErrorHandlers(error: Error, toolbox: Toolbox<T>): Promise<void>;
42
- /**
43
- * Gets all registered plugins in dependency order.
44
- * @returns Array of plugins sorted by dependencies
45
- */
46
- getDependencyOrder(): Plugin<T>[];
47
- /**
48
- * Validates that all plugin dependencies exist.
49
- * @throws {Error} If any dependencies are missing
50
- */
51
- private validateDependencies;
52
- }
53
- export default PluginManager;
@@ -1,11 +0,0 @@
1
- /**
2
- * Retrieves the last update check timestamp for the specified package.
3
- * @param packageName
4
- * @returns - The timestamp of the last update check, or undefined if the check failed.
5
- */
6
- export declare const getLastUpdate: (packageName: string) => number | undefined;
7
- /**
8
- * Saves the last update time for a given package.
9
- * @param packageName
10
- */
11
- export declare const saveLastUpdate: (packageName: string) => void;
@@ -1,2 +0,0 @@
1
- declare const getDistributionVersion: (packageName: string, distributionTag: string, registryUrl: string) => Promise<string>;
2
- export default getDistributionVersion;