@visulima/cerebro 3.0.0-alpha.3 → 3.0.0-alpha.30

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 (90) hide show
  1. package/CHANGELOG.md +458 -0
  2. package/LICENSE.md +605 -4095
  3. package/README.md +152 -2
  4. package/dist/commands/completion-command.d.ts +6 -5
  5. package/dist/commands/completion-command.js +3 -3
  6. package/dist/commands/help-command.d.ts +10 -9
  7. package/dist/commands/help-command.js +1 -1
  8. package/dist/commands/readme-command.d.ts +6 -5
  9. package/dist/commands/readme-command.js +20 -20
  10. package/dist/commands/version-command.d.ts +4 -3
  11. package/dist/index.d.ts +501 -95
  12. package/dist/index.js +1 -1
  13. package/dist/logger/create-pail-logger.d.ts +745 -8
  14. package/dist/logger/create-pail-logger.js +1 -1
  15. package/dist/packem_chunks/has-new-version.js +1 -1
  16. package/dist/packem_shared/Cerebro-BN_nIZ8z.js +4 -0
  17. package/dist/packem_shared/VisulimaError-WfDZ45Qv.js +76 -0
  18. package/dist/packem_shared/constants-DmzZF6_u-BmMwILI_.js +1 -0
  19. package/dist/packem_shared/index-CkkDAMKi.js +6 -0
  20. package/dist/packem_shared/index.d-Br8HpP0A.d.ts +93 -0
  21. package/dist/packem_shared/lazyNamed-DOmefeJM.js +1 -0
  22. package/dist/packem_shared/plugin-manager.d-BSQtHbWS.d.ts +620 -0
  23. package/dist/packem_shared/renderError-DxgI44AK-DFDWFoCr.js +24 -0
  24. package/dist/packem_shared/{runtime-process-G-n-wOub.js → runtime-process-DKHFvYkv.js} +1 -1
  25. package/dist/plugins/error-handler-plugin.d.ts +21 -19
  26. package/dist/plugins/error-handler-plugin.js +1 -1
  27. package/dist/plugins/runtime-version-check-plugin.d.ts +22 -20
  28. package/dist/plugins/runtime-version-check-plugin.js +1 -1
  29. package/dist/plugins/update-notifier/update-notifier-plugin.d.ts +21 -8
  30. package/dist/plugins/update-notifier/update-notifier-plugin.js +1 -1
  31. package/dist/util/general/compile-cache.d.ts +41 -0
  32. package/dist/util/general/compile-cache.js +1 -0
  33. package/dist/util/general/heap-tuning.d.ts +18 -0
  34. package/dist/util/general/heap-tuning.js +1 -0
  35. package/package.json +32 -26
  36. package/dist/cli.d.ts +0 -203
  37. package/dist/constants.d.ts +0 -29
  38. package/dist/default-env.d.ts +0 -7
  39. package/dist/default-options.d.ts +0 -3
  40. package/dist/empty-toolbox.d.ts +0 -15
  41. package/dist/errors/cerebro-error.d.ts +0 -10
  42. package/dist/errors/command-not-found-error.d.ts +0 -9
  43. package/dist/errors/command-validation-error.d.ts +0 -10
  44. package/dist/errors/completion-error.d.ts +0 -9
  45. package/dist/errors/conflicting-options-error.d.ts +0 -10
  46. package/dist/errors/plugin-error.d.ts +0 -9
  47. package/dist/errors/update-notifier-error.d.ts +0 -7
  48. package/dist/packem_shared/Cerebro-aPZjbfzf.js +0 -4
  49. package/dist/packem_shared/VisulimaError-BJideSBf.js +0 -76
  50. package/dist/packem_shared/help-command-CIRIXN03.js +0 -1
  51. package/dist/packem_shared/index-DQ3pvLQH.js +0 -6
  52. package/dist/packem_shared/renderError-ZMlMvw1N-eVUSdl6c.js +0 -24
  53. package/dist/plugin-manager.d.ts +0 -53
  54. package/dist/plugins/update-notifier/cache.d.ts +0 -11
  55. package/dist/plugins/update-notifier/get-distribution-version.d.ts +0 -2
  56. package/dist/plugins/update-notifier/has-new-version.d.ts +0 -14
  57. package/dist/types/cli.d.ts +0 -102
  58. package/dist/types/command-line-usage.d.ts +0 -37
  59. package/dist/types/command.d.ts +0 -136
  60. package/dist/types/option-types.d.ts +0 -83
  61. package/dist/types/options.d.ts +0 -4
  62. package/dist/types/plugin.d.ts +0 -53
  63. package/dist/types/toolbox.d.ts +0 -96
  64. package/dist/util/arg-processing/get-boolean-values.d.ts +0 -7
  65. package/dist/util/arg-processing/get-parameter-option.d.ts +0 -7
  66. package/dist/util/arg-processing/map-option-type-label.d.ts +0 -3
  67. package/dist/util/arg-processing/option-is-boolean.d.ts +0 -9
  68. package/dist/util/arg-processing/remove-boolean-values.d.ts +0 -9
  69. package/dist/util/command-line-commands.d.ts +0 -10
  70. package/dist/util/command-line-usage/get-terminal-width.d.ts +0 -7
  71. package/dist/util/command-line-usage/index.d.ts +0 -3
  72. package/dist/util/command-line-usage/section/base-section.d.ts +0 -8
  73. package/dist/util/command-line-usage/section/content-section.d.ts +0 -65
  74. package/dist/util/command-line-usage/section/option-list-section.d.ts +0 -44
  75. package/dist/util/command-processing/command-processor.d.ts +0 -37
  76. package/dist/util/command-processing/command-validation.d.ts +0 -17
  77. package/dist/util/command-processing/nested-command-parser.d.ts +0 -25
  78. package/dist/util/command-processing/option-processor.d.ts +0 -44
  79. package/dist/util/data-processing/list-missing-arguments.d.ts +0 -15
  80. package/dist/util/data-processing/merge-arguments.d.ts +0 -7
  81. package/dist/util/general/find-alternatives.d.ts +0 -8
  82. package/dist/util/general/hide-bin.d.ts +0 -2
  83. package/dist/util/general/parse-raw-command.d.ts +0 -7
  84. package/dist/util/general/register-exception-handler.d.ts +0 -9
  85. package/dist/util/general/runtime-process.d.ts +0 -65
  86. package/dist/util/general/semver-gt.d.ts +0 -2
  87. package/dist/util/general/validate-input.d.ts +0 -24
  88. package/dist/util/process-env-variables.d.ts +0 -9
  89. package/dist/util/security.d.ts +0 -58
  90. package/dist/util/text-processing/template-format.d.ts +0 -5
package/dist/index.d.ts CHANGED
@@ -1,99 +1,505 @@
1
- import type { CliOptions } from './cli.d.ts';
2
- import { Cli } from './cli.d.ts';
1
+ import { a as CerebroFs, b as CommandSection, O as OptionDefinition, C as Command, P as Plugin, c as PluginManager, d as CliRunOptions, R as RunCommandOptions, T as Toolbox, e as CommandExecute, f as Cli$1, L as LazyCommandModule } from "./packem_shared/plugin-manager.d-BSQtHbWS.js";
2
+ export { type A as ArgumentDefinition, type g as CerebroProcess, type E as EnvDefinition, type h as OutputType, type i as PluginContext, type V as VERBOSITY_LEVEL } from "./packem_shared/plugin-manager.d-BSQtHbWS.js";
3
+ export { V as VisulimaError } from "./packem_shared/index.d-Br8HpP0A.js";
4
+ import '@visulima/tabular';
5
+ type CliOptions<T extends Console = Console> = {
6
+ argv?: ReadonlyArray<string>;
7
+ cwd?: string;
8
+ /**
9
+ * Process environment variables exposed to commands via `toolbox.process.env`.
10
+ * Defaults to the runtime's process environment. Override to provide a
11
+ * captured snapshot in tests so commands don't read mutating host state.
12
+ */
13
+ env?: Record<string, string | undefined>;
14
+ /**
15
+ * Function called when a command invokes `toolbox.process.exit(code)`.
16
+ * Defaults to the runtime-agnostic exit helper that terminates the process.
17
+ * Override with a `vi.fn()` in tests to capture exit codes without killing
18
+ * the test runner.
19
+ */
20
+ exit?: (code?: number) => void;
21
+ /**
22
+ * Filesystem adapter exposed via `toolbox.fs`. Defaults to `node:fs/promises`.
23
+ * Override with an in-memory or sandboxed adapter for tests and embedded
24
+ * runtimes (MCP, JustBash).
25
+ */
26
+ fs?: CerebroFs;
27
+ logger?: T;
28
+ packageName?: string;
29
+ packageVersion?: string;
30
+ /**
31
+ * Buffered stdin content exposed via `toolbox.process.stdin`. Empty string
32
+ * by default. Useful for tests and sandboxed runtimes where wiring real
33
+ * stdin is impractical.
34
+ */
35
+ stdin?: string;
36
+ };
37
+ declare class Cli<T extends Console = Console> implements Cli$1<T> {
38
+ #private;
39
+ /**
40
+ * Create a new CLI instance.
41
+ * @param cliName
42
+ * @param options The options for the CLI.
43
+ * @param options.argv The command line arguments.
44
+ * @param options.cwd The current working directory.
45
+ * @param options.logger The logger to use.
46
+ * @param options.packageName
47
+ * @param options.packageVersion
48
+ */
49
+ constructor(cliName: string, options?: CliOptions<T>);
50
+ /**
51
+ * Sets the command section configuration for help display.
52
+ *
53
+ * This affects how the CLI name and version are displayed in help output.
54
+ * @param commandSection The command section configuration
55
+ * @returns The CLI instance for method chaining
56
+ * @example
57
+ * ```typescript
58
+ * cli.setCommandSection({
59
+ * header: 'My App v2.0.0',
60
+ * footer: 'For more info, visit https://example.com'
61
+ * });
62
+ * ```
63
+ */
64
+ setCommandSection(commandSection: CommandSection): this;
65
+ /**
66
+ * Gets the current command section configuration.
67
+ * @returns The command section configuration
68
+ */
69
+ getCommandSection(): CommandSection;
70
+ /**
71
+ * Sets the default command to run when no command is specified.
72
+ *
73
+ * By default, this is set to 'help'. The command must already be registered
74
+ * with the CLI instance.
75
+ * @param commandName The command name to use as the default
76
+ * @returns The CLI instance for method chaining
77
+ * @example
78
+ * ```typescript
79
+ * cli.setDefaultCommand('start');
80
+ * ```
81
+ */
82
+ setDefaultCommand(commandName: string): this;
83
+ /**
84
+ * Gets the current default command.
85
+ * @returns The name of the default command
86
+ */
87
+ get defaultCommand(): string;
88
+ /**
89
+ * Adds a command to the CLI.
90
+ *
91
+ * Commands define the available operations that users can execute.
92
+ * Each command can have options, arguments, aliases, and custom execution logic.
93
+ * @template OD - The option definition type for the command
94
+ * @param command The command configuration object
95
+ * @returns The CLI instance for method chaining
96
+ * @throws {CerebroError} If the command name already exists or validation fails
97
+ * @example
98
+ * ```typescript
99
+ * cli.addCommand({
100
+ * name: 'build',
101
+ * description: 'Build the project',
102
+ * options: [
103
+ * {
104
+ * name: 'output',
105
+ * alias: 'o',
106
+ * type: String,
107
+ * description: 'Output directory'
108
+ * }
109
+ * ],
110
+ * execute: ({ options }) => {
111
+ * console.log(`Building to ${options.output || 'dist'}`);
112
+ * }
113
+ * });
114
+ * ```
115
+ */
116
+ addCommand<OD extends OptionDefinition<unknown> = OptionDefinition<unknown>>(command: Command<OD, T>): this;
117
+ /**
118
+ * Adds a global option available to all commands.
119
+ *
120
+ * Global options are parsed alongside command-specific options and displayed
121
+ * in the help output under the "Global Options" section.
122
+ * @param option The option definition
123
+ * @returns The CLI instance for method chaining
124
+ * @example
125
+ * ```typescript
126
+ * cli.addGlobalOption({
127
+ * name: 'cwd',
128
+ * type: String,
129
+ * description: 'Override working directory',
130
+ * });
131
+ * ```
132
+ */
133
+ addGlobalOption<V = unknown>(option: OptionDefinition<V>): this;
134
+ /**
135
+ * Gets all global options (built-in + custom).
136
+ * @returns Array of all global option definitions
137
+ */
138
+ getGlobalOptions(): OptionDefinition<unknown>[];
139
+ /**
140
+ * Adds a plugin to extend the CLI functionality.
141
+ *
142
+ * Plugins can hook into various lifecycle events and modify the toolbox
143
+ * to provide additional functionality to commands.
144
+ * @param plugin The plugin to register
145
+ * @returns The CLI instance for method chaining
146
+ * @example
147
+ * ```typescript
148
+ * cli.addPlugin({
149
+ * name: 'logger',
150
+ * execute: (toolbox) => {
151
+ * toolbox.logger = createCustomLogger();
152
+ * }
153
+ * });
154
+ * ```
155
+ */
156
+ addPlugin(plugin: Plugin<T>): this;
157
+ /**
158
+ * Gets the plugin manager instance for advanced plugin management.
159
+ * @returns The plugin manager instance
160
+ */
161
+ getPluginManager(): PluginManager<T>;
162
+ /**
163
+ * Gets the CLI application name.
164
+ */
165
+ getCliName(): string;
166
+ /**
167
+ * Gets the package version if configured.
168
+ * @returns The package version or undefined
169
+ */
170
+ getPackageVersion(): string | undefined;
171
+ /**
172
+ * Gets the package name if configured.
173
+ * @returns The package name or undefined
174
+ */
175
+ getPackageName(): string | undefined;
176
+ /**
177
+ * Gets all registered commands.
178
+ * @returns A map of command names to command definitions
179
+ */
180
+ getCommands(): Map<string, Command<OptionDefinition<unknown>, T>>;
181
+ /**
182
+ * Gets the current working directory.
183
+ * @returns The current working directory path
184
+ */
185
+ getCwd(): string;
186
+ /**
187
+ * Disposes the CLI instance and cleans up resources.
188
+ *
189
+ * This method removes event listeners and performs cleanup to prevent memory leaks.
190
+ * Call this method when the CLI instance is no longer needed, especially in long-running
191
+ * processes or when creating multiple CLI instances.
192
+ * @example
193
+ * ```typescript
194
+ * const cli = new Cerebro('my-app');
195
+ * // ... use the cli
196
+ * cli.dispose(); // Clean up when done
197
+ * ```
198
+ */
199
+ dispose(): void;
200
+ /**
201
+ * Runs the CLI application.
202
+ *
203
+ * This method parses command line arguments, executes the appropriate command,
204
+ * and handles the complete CLI lifecycle including plugin initialization,
205
+ * error handling, process termination, and automatic cleanup.
206
+ * @param extraOptions Additional options to pass to commands
207
+ * @param extraOptions.shouldExitProcess Whether to exit the process after execution (default: true)
208
+ * @param extraOptions.autoDispose Whether to automatically cleanup/dispose resources after execution (default: true)
209
+ * @returns A promise that resolves when execution completes
210
+ * @throws {CommandNotFoundError} If the specified command doesn't exist
211
+ * @throws {Error} If command arguments are invalid or conflicting options are provided
212
+ * @example
213
+ * ```typescript
214
+ * // Run with default behavior (exits process and auto-disposes)
215
+ * await cli.run();
216
+ *
217
+ * // Run without exiting (for testing)
218
+ * await cli.run({ shouldExitProcess: false });
219
+ *
220
+ * // Run without auto-disposing (for reuse)
221
+ * await cli.run({ autoDispose: false });
222
+ * ```
223
+ */
224
+ run(extraOptions?: CliRunOptions): Promise<void>;
225
+ /**
226
+ * Runs a command programmatically from within another command.
227
+ *
228
+ * This method allows commands to call other commands during execution,
229
+ * enabling composition of commands and reusable command logic.
230
+ * @param commandName The name of the command to execute
231
+ * @param options Optional options including argv and other command options
232
+ * @returns A promise that resolves with the command's result
233
+ * @throws {CommandNotFoundError} If the specified command doesn't exist
234
+ * @throws {CerebroError} If command validation fails
235
+ * @example
236
+ * ```typescript
237
+ * cli.addCommand({
238
+ * name: 'deploy',
239
+ * execute: async ({ runtime, logger }) => {
240
+ * logger.info('Building...');
241
+ * await runtime.runCommand('build', { argv: ['--production'] });
242
+ *
243
+ * logger.info('Testing...');
244
+ * await runtime.runCommand('test', { argv: ['--coverage'] });
245
+ * }
246
+ * });
247
+ * ```
248
+ */
249
+ runCommand(commandName: string, options?: RunCommandOptions): Promise<unknown>;
250
+ /**
251
+ * Creates a shallow copy of the CLI with optional `CliOptions` overrides.
252
+ *
253
+ * The clone shares the underlying command definitions (the same `Command`
254
+ * objects are reused), but has its own commands map, global-options list,
255
+ * default-command setting, command-section configuration, and a freshly
256
+ * initialized plugin manager. Mutating one CLI's commands after cloning
257
+ * does not affect the other.
258
+ *
259
+ * Primarily useful in tests to run the same CLI definition with different
260
+ * argv / stdout / exit / fs overrides without rebuilding the command tree.
261
+ * @param overrides Optional `CliOptions` to merge over the clone's existing options
262
+ * @returns A new `Cli` instance with the same commands and merged options
263
+ * @example
264
+ * ```typescript
265
+ * const cli = new Cerebro("acme");
266
+ * cli.addCommand({ name: "build", execute: ({ console }) => console.log("building") });
267
+ *
268
+ * // In tests: clone with mocked exit + captured stdout
269
+ * const exitSpy = vi.fn();
270
+ * const isolated = cli.clone({ argv: ["build"], exit: exitSpy });
271
+ * await isolated.run({ shouldExitProcess: false });
272
+ * ```
273
+ */
274
+ clone(overrides?: CliOptions<T>): Cli<T>;
275
+ /**
276
+ * Returns the resolved `execute` function for a registered command.
277
+ *
278
+ * For lazy-loaded commands (defined via `loader`), the loader is awaited
279
+ * and its module's default export is returned. The result is cached on the
280
+ * command for subsequent calls. Supports space-separated nested command
281
+ * paths (e.g. `"git remote add"`).
282
+ *
283
+ * Primarily useful in tests to invoke a command's handler directly with a
284
+ * synthesized toolbox, without going through argv parsing or the full
285
+ * `run()` lifecycle.
286
+ * @param commandName The command name or space-separated nested path
287
+ * @returns A promise resolving to the command's handler function
288
+ * @throws {CommandNotFoundError} If no command matches the given name
289
+ * @throws {CerebroError} If the command has neither `execute` nor `loader`
290
+ * @example
291
+ * ```typescript
292
+ * const cli = new Cerebro("acme");
293
+ * cli.addCommand({
294
+ * name: "deploy",
295
+ * execute: ({ console, options }) => console.log("deploying to", options.env),
296
+ * });
297
+ *
298
+ * // In tests: call the action directly with a mocked toolbox
299
+ * const action = await cli.getAction("deploy");
300
+ * await action({ console: fakeConsole, options: { env: "staging" } } as never);
301
+ * ```
302
+ */
303
+ getAction(commandName: string): Promise<CommandExecute<Toolbox<T>>>;
304
+ }
305
+ /**
306
+ * Output with this verbosity won't write anything at all.
307
+ */
308
+ declare const VERBOSITY_QUIET = 16;
309
+ /**
310
+ * Output with this verbosity will write default content.
311
+ */
312
+ declare const VERBOSITY_NORMAL = 32;
313
+ /**
314
+ * Output with this verbosity will be more detailed.
315
+ */
316
+ declare const VERBOSITY_VERBOSE = 64;
317
+ /**
318
+ * Output with this verbosity will reveal internals.
319
+ */
320
+ declare const VERBOSITY_DEBUG = 128;
321
+ /**
322
+ * Helper types for creating type-safe commands with autocomplete support.
323
+ * These types help you define your options and environment variables with full TypeScript autocomplete.
324
+ * Use these types to create type-safe Toolbox interfaces for your commands.
325
+ * @example
326
+ * ```typescript
327
+ * import { CreateOptions, CreateEnv, type Toolbox } from '@visulima/cerebro';
328
+ *
329
+ * // Define options with their original names (they'll be converted to camelCase)
330
+ * type BuildOptions = CreateOptions<{
331
+ * "output-dir": string | undefined;
332
+ * "verbose": boolean | undefined;
333
+ * "port": number | undefined;
334
+ * }>;
335
+ * // Result: { outputDir: string | undefined, verbose: boolean | undefined, port: number | undefined }
336
+ *
337
+ * // Define environment variables (UPPER_SNAKE_CASE -> camelCase)
338
+ * type BuildEnv = CreateEnv<{
339
+ * "API_KEY": string | undefined;
340
+ * "DEBUG": boolean | undefined;
341
+ * }>;
342
+ * // Result: { apiKey: string | undefined, debug: boolean | undefined }
343
+ *
344
+ * // Use in your command
345
+ * cli.addCommand({
346
+ * name: "build",
347
+ * options: [
348
+ * { name: "output-dir", type: String },
349
+ * { name: "verbose", type: Boolean },
350
+ * { name: "port", type: Number }
351
+ * ],
352
+ * env: [
353
+ * { name: "API_KEY", type: String },
354
+ * { name: "DEBUG", type: Boolean }
355
+ * ],
356
+ * execute: ({ options, env }: Toolbox<Console, BuildOptions, BuildEnv>) => {
357
+ * // Full autocomplete on options.outputDir, options.verbose, env.apiKey, etc.
358
+ * console.log(options.outputDir, options.verbose, env.apiKey);
359
+ * }
360
+ * });
361
+ * ```
362
+ */
363
+ /**
364
+ * Converts option names to camelCase for the options object.
365
+ * Options like "output-dir" become "outputDir" in the toolbox.
366
+ * @example
367
+ * ```typescript
368
+ * // Option name: "output-dir" -> options.outputDir
369
+ * // Option name: "api_key" -> options.apiKey
370
+ * // Option name: "verbose" -> options.verbose
371
+ * ```
372
+ */
373
+ type OptionNameToCamelCase<T extends string> = T extends `${infer Start}-${infer Rest}` ? `${Lowercase<Start>}${Capitalize<OptionNameToCamelCase<Rest>>}` : T extends `${infer Start}_${infer Rest}` ? `${Lowercase<Start>}${Capitalize<OptionNameToCamelCase<Rest>>}` : Lowercase<T>;
374
+ /**
375
+ * Helper type to create a type-safe options object from option definitions.
376
+ * @example
377
+ * ```typescript
378
+ * type MyOptions = CreateOptions<{
379
+ * "output-dir": string | undefined;
380
+ * "verbose": boolean | undefined;
381
+ * "port": number | undefined;
382
+ * }>;
383
+ * // Result: { outputDir: string | undefined, verbose: boolean | undefined, port: number | undefined }
384
+ * ```
385
+ */
386
+ type CreateOptions<T extends Record<string, unknown>> = { [K in keyof T as OptionNameToCamelCase<K & string>]: T[K] };
387
+ /**
388
+ * Helper type to create a type-safe environment variables object from env definitions.
389
+ * Environment variable names are converted from UPPER_SNAKE_CASE to camelCase.
390
+ * @example
391
+ * ```typescript
392
+ * type MyEnv = CreateEnv<{
393
+ * "API_KEY": string | undefined;
394
+ * "DEBUG": boolean | undefined;
395
+ * }>;
396
+ * // Result: { apiKey: string | undefined, debug: boolean | undefined }
397
+ * ```
398
+ */
399
+ type CreateEnv<T extends Record<string, unknown>> = { [K in keyof T as OptionNameToCamelCase<K & string>]: T[K] };
400
+ /**
401
+ * Builds a `loader` for commands whose handler lives as a named export in a
402
+ * shared handler module (the typical pattern when one file holds multiple
403
+ * subcommands' execute functions).
404
+ * @example
405
+ * ```ts
406
+ * // commands/cache/handler.ts
407
+ * export const cacheListExecute: CommandExecute<Toolbox> = async (toolbox) => { ... };
408
+ * export const cacheCleanExecute: CommandExecute<Toolbox> = async (toolbox) => { ... };
409
+ *
410
+ * // commands/cache/index.ts
411
+ * cli.addCommand({
412
+ * name: "list",
413
+ * loader: lazyNamed(() => import("./handler"), "cacheListExecute"),
414
+ * });
415
+ * ```
416
+ */
417
+ declare const lazyNamed: <M extends Record<string, unknown>, K extends keyof M, TContext>(load: () => Promise<M>, key: K) => () => Promise<LazyCommandModule<TContext>>;
3
418
  declare global {
4
- namespace Cerebro {
5
- /**
6
- * Extend this interface to add custom properties to the Toolbox.
7
- * This allows plugins and extensions to add type-safe properties to the toolbox.
8
- * @example
9
- * ```typescript
10
- * declare global {
11
- * namespace Cerebro {
12
- * interface ExtensionOverrides {
13
- * // Add custom properties with full type safety
14
- * fs: {
15
- * readFile: (path: string) => Promise<string>;
16
- * writeFile: (path: string, content: string) => Promise<void>;
17
- * };
18
- * http: {
19
- * get: <T>(url: string) => Promise<T>;
20
- * post: <T>(url: string, data: unknown) => Promise<T>;
21
- * };
22
- * myCustomUtil: () => void;
23
- * }
24
- * }
25
- * }
26
- *
27
- * // Now in your commands, you get full autocomplete:
28
- * cli.addCommand({
29
- * name: "example",
30
- * execute: ({ fs, http, myCustomUtil }) => {
31
- * // ✅ Full autocomplete and type safety!
32
- * const content = await fs.readFile("file.txt");
33
- * const data = await http.get<MyType>("https://api.example.com");
34
- * myCustomUtil();
35
- * }
36
- * });
37
- * ```
38
- */
39
- interface ExtensionOverrides {
40
- }
41
- }
419
+ namespace Cerebro {
420
+ /**
421
+ * Extend this interface to add custom properties to the Toolbox.
422
+ * This allows plugins and extensions to add type-safe properties to the toolbox.
423
+ * @example
424
+ * ```typescript
425
+ * declare global {
426
+ * namespace Cerebro {
427
+ * interface ExtensionOverrides {
428
+ * // Add custom properties with full type safety
429
+ * fs: {
430
+ * readFile: (path: string) => Promise<string>;
431
+ * writeFile: (path: string, content: string) => Promise<void>;
432
+ * };
433
+ * http: {
434
+ * get: <T>(url: string) => Promise<T>;
435
+ * post: <T>(url: string, data: unknown) => Promise<T>;
436
+ * };
437
+ * myCustomUtil: () => void;
438
+ * }
439
+ * }
440
+ * }
441
+ *
442
+ * // Now in your commands, you get full autocomplete:
443
+ * cli.addCommand({
444
+ * name: "example",
445
+ * execute: ({ fs, http, myCustomUtil }) => {
446
+ * // ✅ Full autocomplete and type safety!
447
+ * const content = await fs.readFile("file.txt");
448
+ * const data = await http.get<MyType>("https://api.example.com");
449
+ * myCustomUtil();
450
+ * }
451
+ * });
452
+ * ```
453
+ */
454
+ export interface ExtensionOverrides {}
455
+ }
42
456
  }
43
457
  /**
44
- * Main entry point for the Cerebro CLI framework.
45
- *
46
- * This module provides a lightweight, extensible CLI framework for building command-line applications.
47
- * It supports plugins, subcommands, argument parsing, help generation, and more.
48
- * @example
49
- * ```typescript
50
- * import { createCerebro } from '@visulima/cerebro';
51
- *
52
- * const cli = createCerebro('my-app', {
53
- * packageName: 'my-app',
54
- * packageVersion: '1.0.0'
55
- * });
56
- *
57
- * cli.addCommand({
58
- * name: 'greet',
59
- * description: 'Greet someone',
60
- * argument: {
61
- * name: 'name',
62
- * description: 'Name to greet',
63
- * type: String
64
- * },
65
- * execute: ({ argument }) => {
66
- * console.log(`Hello, ${argument[0]}!`);
67
- * }
68
- * });
69
- *
70
- * cli.run();
71
- * ```
72
- */
73
- export type { CliOptions } from './cli.d.ts';
74
- export { Cli as Cerebro } from './cli.d.ts';
75
- export { VERBOSITY_DEBUG, VERBOSITY_NORMAL, VERBOSITY_QUIET, VERBOSITY_VERBOSE } from './constants.d.ts';
76
- export type { Cli, CliRunOptions, OutputType, RunCommandOptions, VERBOSITY_LEVEL } from './types/cli.d.ts';
77
- export type { ArgumentDefinition, Command, EnvDefinition, OptionDefinition } from './types/command.d.ts';
78
- export type { CreateEnv, CreateOptions, OptionNameToCamelCase } from './types/option-types.d.ts';
79
- export type { Plugin, PluginContext } from './types/plugin.d.ts';
80
- export type { Toolbox } from './types/toolbox.d.ts';
81
- export { VisulimaError } from "@visulima/error";
458
+ * Main entry point for the Cerebro CLI framework.
459
+ *
460
+ * This module provides a lightweight, extensible CLI framework for building command-line applications.
461
+ * It supports plugins, subcommands, argument parsing, help generation, and more.
462
+ * @example
463
+ * ```typescript
464
+ * import { createCerebro } from '@visulima/cerebro';
465
+ *
466
+ * const cli = createCerebro('my-app', {
467
+ * packageName: 'my-app',
468
+ * packageVersion: '1.0.0'
469
+ * });
470
+ *
471
+ * cli.addCommand({
472
+ * name: 'greet',
473
+ * description: 'Greet someone',
474
+ * argument: {
475
+ * name: 'name',
476
+ * description: 'Name to greet',
477
+ * type: String
478
+ * },
479
+ * execute: ({ argument }) => {
480
+ * console.log(`Hello, ${argument[0]}!`);
481
+ * }
482
+ * });
483
+ *
484
+ * cli.run();
485
+ * ```
486
+ */
82
487
  /**
83
- * Creates a new Cerebro CLI instance.
84
- *
85
- * This is the main factory function for creating CLI applications with Cerebro.
86
- * The returned CLI instance can be configured with commands, plugins, and options.
87
- * @template T - The console type (defaults to Console)
88
- * @param name The name of the CLI application
89
- * @param options Configuration options for the CLI
90
- * @returns A configured Cerebro CLI instance
91
- * @example
92
- * ```typescript
93
- * const cli = createCerebro('my-app', {
94
- * packageName: 'my-app',
95
- * packageVersion: '1.0.0'
96
- * });
97
- * ```
98
- */
99
- export declare const createCerebro: <T extends Console = Console>(name: string, options?: CliOptions<T>) => InstanceType<typeof Cli<T>>;
488
+ * Creates a new Cerebro CLI instance.
489
+ *
490
+ * This is the main factory function for creating CLI applications with Cerebro.
491
+ * The returned CLI instance can be configured with commands, plugins, and options.
492
+ * @template T - The console type (defaults to Console)
493
+ * @param name The name of the CLI application
494
+ * @param options Configuration options for the CLI
495
+ * @returns A configured Cerebro CLI instance
496
+ * @example
497
+ * ```typescript
498
+ * const cli = createCerebro('my-app', {
499
+ * packageName: 'my-app',
500
+ * packageVersion: '1.0.0'
501
+ * });
502
+ * ```
503
+ */
504
+ declare const createCerebro: <T extends Console = Console>(name: string, options?: CliOptions<T>) => InstanceType<typeof Cli<T>>;
505
+ export { Cli as Cerebro, type CerebroFs, type Cli$1 as Cli, type CliOptions, type CliRunOptions, type Command, type CommandExecute, type CreateEnv, type CreateOptions, type LazyCommandModule, type OptionDefinition, type OptionNameToCamelCase, type Plugin, type RunCommandOptions, type Toolbox, VERBOSITY_DEBUG, VERBOSITY_NORMAL, VERBOSITY_QUIET, VERBOSITY_VERBOSE, createCerebro, lazyNamed };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var t=Object.defineProperty;var o=(r,e)=>t(r,"name",{value:e,configurable:!0});import{Cli as a}from"./packem_shared/Cerebro-aPZjbfzf.js";import{VERBOSITY_DEBUG as V,VERBOSITY_NORMAL as b,VERBOSITY_QUIET as c,VERBOSITY_VERBOSE as f}from"./packem_shared/VERBOSITY_QUIET-XPultrIA.js";import{p as I}from"./packem_shared/isVisulimaError-jVZgumOU-C4fgdbWg.js";var E=Object.defineProperty,O=o((r,e)=>E(r,"name",{value:e,configurable:!0}),"t");const p=O((r,e)=>new a(r,e),"createCerebro");export{a as Cerebro,V as VERBOSITY_DEBUG,b as VERBOSITY_NORMAL,c as VERBOSITY_QUIET,f as VERBOSITY_VERBOSE,I as VisulimaError,p as createCerebro};
1
+ var a=Object.defineProperty;var o=(r,e)=>a(r,"name",{value:e,configurable:!0});import{Cli as t}from"./packem_shared/Cerebro-BN_nIZ8z.js";import{VERBOSITY_DEBUG as R,VERBOSITY_NORMAL as V,VERBOSITY_QUIET as b,VERBOSITY_VERBOSE as c}from"./packem_shared/VERBOSITY_QUIET-XPultrIA.js";import{lazyNamed as n}from"./packem_shared/lazyNamed-DOmefeJM.js";import{p as S}from"./packem_shared/isVisulimaError-jVZgumOU-C4fgdbWg.js";var E=Object.defineProperty,m=o((r,e)=>E(r,"name",{value:e,configurable:!0}),"t");const f=m((r,e)=>new t(r,e),"createCerebro");export{t as Cerebro,R as VERBOSITY_DEBUG,V as VERBOSITY_NORMAL,b as VERBOSITY_QUIET,c as VERBOSITY_VERBOSE,S as VisulimaError,f as createCerebro,n as lazyNamed};