@visulima/cerebro 3.0.0-alpha.2 → 3.0.0-alpha.21

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 (89) hide show
  1. package/CHANGELOG.md +334 -0
  2. package/LICENSE.md +589 -4096
  3. package/README.md +26 -0
  4. package/dist/commands/completion-command.d.ts +6 -5
  5. package/dist/commands/completion-command.js +2 -2
  6. package/dist/commands/help-command.d.ts +9 -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 +422 -95
  12. package/dist/index.js +1 -1
  13. package/dist/logger/create-pail-logger.d.ts +779 -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-DVWKQlmP.js +4 -0
  17. package/dist/packem_shared/VisulimaError-Bh91XNXu.js +76 -0
  18. package/dist/packem_shared/index-B0BiusY7.js +6 -0
  19. package/dist/packem_shared/index.d-Br8HpP0A.d.ts +93 -0
  20. package/dist/packem_shared/lazyNamed-DOmefeJM.js +1 -0
  21. package/dist/packem_shared/plugin-manager.d-Dz-wu1tI.d.ts +544 -0
  22. package/dist/packem_shared/renderError-B_XyYPKJ-B65kP-Ou.js +24 -0
  23. package/dist/packem_shared/{runtime-process-G-n-wOub.js → runtime-process-DKHFvYkv.js} +1 -1
  24. package/dist/plugins/error-handler-plugin.d.ts +21 -19
  25. package/dist/plugins/error-handler-plugin.js +1 -1
  26. package/dist/plugins/runtime-version-check-plugin.d.ts +22 -20
  27. package/dist/plugins/runtime-version-check-plugin.js +1 -1
  28. package/dist/plugins/update-notifier/update-notifier-plugin.d.ts +21 -8
  29. package/dist/plugins/update-notifier/update-notifier-plugin.js +1 -1
  30. package/dist/util/general/compile-cache.d.ts +41 -0
  31. package/dist/util/general/compile-cache.js +1 -0
  32. package/dist/util/general/heap-tuning.d.ts +18 -0
  33. package/dist/util/general/heap-tuning.js +1 -0
  34. package/package.json +52 -44
  35. package/dist/cli.d.ts +0 -203
  36. package/dist/constants.d.ts +0 -29
  37. package/dist/default-env.d.ts +0 -7
  38. package/dist/default-options.d.ts +0 -3
  39. package/dist/empty-toolbox.d.ts +0 -15
  40. package/dist/errors/cerebro-error.d.ts +0 -10
  41. package/dist/errors/command-not-found-error.d.ts +0 -9
  42. package/dist/errors/command-validation-error.d.ts +0 -10
  43. package/dist/errors/completion-error.d.ts +0 -9
  44. package/dist/errors/conflicting-options-error.d.ts +0 -10
  45. package/dist/errors/plugin-error.d.ts +0 -9
  46. package/dist/errors/update-notifier-error.d.ts +0 -7
  47. package/dist/packem_shared/Cerebro-aPZjbfzf.js +0 -4
  48. package/dist/packem_shared/VisulimaError-BJideSBf.js +0 -76
  49. package/dist/packem_shared/help-command-CIRIXN03.js +0 -1
  50. package/dist/packem_shared/index-DQ3pvLQH.js +0 -6
  51. package/dist/packem_shared/renderError-ZMlMvw1N-eVUSdl6c.js +0 -24
  52. package/dist/plugin-manager.d.ts +0 -53
  53. package/dist/plugins/update-notifier/cache.d.ts +0 -11
  54. package/dist/plugins/update-notifier/get-distribution-version.d.ts +0 -2
  55. package/dist/plugins/update-notifier/has-new-version.d.ts +0 -14
  56. package/dist/types/cli.d.ts +0 -102
  57. package/dist/types/command-line-usage.d.ts +0 -37
  58. package/dist/types/command.d.ts +0 -136
  59. package/dist/types/option-types.d.ts +0 -83
  60. package/dist/types/options.d.ts +0 -4
  61. package/dist/types/plugin.d.ts +0 -53
  62. package/dist/types/toolbox.d.ts +0 -96
  63. package/dist/util/arg-processing/get-boolean-values.d.ts +0 -7
  64. package/dist/util/arg-processing/get-parameter-option.d.ts +0 -7
  65. package/dist/util/arg-processing/map-option-type-label.d.ts +0 -3
  66. package/dist/util/arg-processing/option-is-boolean.d.ts +0 -9
  67. package/dist/util/arg-processing/remove-boolean-values.d.ts +0 -9
  68. package/dist/util/command-line-commands.d.ts +0 -10
  69. package/dist/util/command-line-usage/get-terminal-width.d.ts +0 -7
  70. package/dist/util/command-line-usage/index.d.ts +0 -3
  71. package/dist/util/command-line-usage/section/base-section.d.ts +0 -8
  72. package/dist/util/command-line-usage/section/content-section.d.ts +0 -65
  73. package/dist/util/command-line-usage/section/option-list-section.d.ts +0 -44
  74. package/dist/util/command-processing/command-processor.d.ts +0 -37
  75. package/dist/util/command-processing/command-validation.d.ts +0 -17
  76. package/dist/util/command-processing/nested-command-parser.d.ts +0 -25
  77. package/dist/util/command-processing/option-processor.d.ts +0 -44
  78. package/dist/util/data-processing/list-missing-arguments.d.ts +0 -15
  79. package/dist/util/data-processing/merge-arguments.d.ts +0 -7
  80. package/dist/util/general/find-alternatives.d.ts +0 -8
  81. package/dist/util/general/hide-bin.d.ts +0 -2
  82. package/dist/util/general/parse-raw-command.d.ts +0 -7
  83. package/dist/util/general/register-exception-handler.d.ts +0 -9
  84. package/dist/util/general/runtime-process.d.ts +0 -65
  85. package/dist/util/general/semver-gt.d.ts +0 -2
  86. package/dist/util/general/validate-input.d.ts +0 -24
  87. package/dist/util/process-env-variables.d.ts +0 -9
  88. package/dist/util/security.d.ts +0 -58
  89. package/dist/util/text-processing/template-format.d.ts +0 -5
@@ -1,25 +0,0 @@
1
- /**
2
- * Parses nested command paths from argv.
3
- * Supports both flat commands (e.g., "build") and nested commands (e.g., "deploy staging").
4
- * @param availableCommands Map of all available commands keyed by their full path string
5
- * @param argv Command line arguments to parse
6
- * @returns Object with the matched command path and remaining argv
7
- */
8
- export declare const parseNestedCommand: (availableCommands: Map<string, string[]>, argv: string[]) => {
9
- argv: string[];
10
- commandPath: string[] | undefined;
11
- };
12
- /**
13
- * Generates a lookup key from a command path array.
14
- * @param commandPath Array of command path segments
15
- * @returns The command path key string
16
- */
17
- export declare const getCommandPathKey: (commandPath: string[]) => string;
18
- /**
19
- * Generates the full command path for a command, including its commandPath if present.
20
- * Combines the command name with any parent path segments.
21
- * @param commandName The name of the command to add to the path
22
- * @param commandPath Optional path segments from the command definition
23
- * @returns The full command path array combining commandPath and commandName
24
- */
25
- export declare const getFullCommandPath: (commandName: string, commandPath?: string[]) => string[];
@@ -1,44 +0,0 @@
1
- import type { OptionDefinition } from "../../types/command.d.ts";
2
- import type { Toolbox as IToolbox } from "../../types/toolbox.d.ts";
3
- /**
4
- * Converts option names to camelCase and adds them as __camelCaseName__ properties.
5
- * @template OD The option definition type
6
- * @param command The command object containing options to process
7
- * @param command.options The options array to process
8
- */
9
- export declare const processOptionNames: <OD extends OptionDefinition<unknown>>(command: {
10
- options?: OD[];
11
- }) => void;
12
- /**
13
- * Adds negatable options for boolean flags.
14
- * For options starting with "no-", creates a corresponding non-negated option.
15
- * @template OD The option definition type
16
- * @param command The command object to add negatable options to
17
- * @param command.name The name of the command (used for error messages)
18
- * @param command.options The array of option definitions to process
19
- * @throws {Error} When a negated option is not of type Boolean
20
- */
21
- export declare const addNegatableOptions: <OD extends OptionDefinition<unknown>>(command: {
22
- name: string;
23
- options?: OD[];
24
- }) => void;
25
- /**
26
- * Maps negatable options to their non-negated counterparts.
27
- * Processes toolbox options starting with "no" and converts them to non-negated form.
28
- * @param toolbox The command toolbox containing options
29
- * @param command The command object with option definitions
30
- * @param command.options The command options array
31
- */
32
- export declare const mapNegatableOptions: <O extends OptionDefinition<unknown>, TLogger extends Console = Console>(toolbox: IToolbox<TLogger>, command: {
33
- options?: ReadonlyArray<O | OptionDefinition<boolean[]> | OptionDefinition<boolean> | OptionDefinition<number[]> | OptionDefinition<number> | OptionDefinition<string[]> | OptionDefinition<string>>;
34
- }) => void;
35
- /**
36
- * Applies implied option values.
37
- * Sets implied option values from option definitions that have an implies property.
38
- * @param toolbox The command toolbox to apply implied values to
39
- * @param command The command object with option definitions
40
- * @param command.options The command options array
41
- */
42
- export declare const mapImpliedOptions: <O extends OptionDefinition<unknown>, TLogger extends Console = Console>(toolbox: IToolbox<TLogger>, command: {
43
- options?: ReadonlyArray<O | OptionDefinition<boolean[]> | OptionDefinition<boolean> | OptionDefinition<number[]> | OptionDefinition<number> | OptionDefinition<string[]> | OptionDefinition<string>>;
44
- }) => void;
@@ -1,15 +0,0 @@
1
- import type { CommandLineOptions } from "@visulima/command-line-args";
2
- import type { OptionDefinition, PossibleOptionDefinition } from "../../types/command.d.ts";
3
- /**
4
- * Lists missing required arguments from parsed command line options
5
- * Optimized to use pre-filtered required options when available
6
- * Combines filter operations for better performance
7
- *
8
- * Note: This function mutates parsedArguments by setting missing boolean options to false.
9
- * @param commandLineConfig All command options OR pre-filtered required options
10
- * @param parsedArguments Parsed command line arguments (will be mutated for boolean defaults)
11
- * @param onlyRequired If true, commandLineConfig already contains only required options (optimization)
12
- * @returns Array of missing required options
13
- */
14
- declare const listMissingArguments: <OD extends OptionDefinition<any>>(commandLineConfig: PossibleOptionDefinition<OD>[], parsedArguments: CommandLineOptions, onlyRequired?: boolean) => PossibleOptionDefinition<OD>[];
15
- export default listMissingArguments;
@@ -1,7 +0,0 @@
1
- import type { OptionDefinition, PossibleOptionDefinition } from "../../types/command.d.ts";
2
- /**
3
- * Performs a simple merge of multiple argument lists. Does not mutate given
4
- * argument lists or argument.
5
- */
6
- declare const mergeArguments: <OD extends OptionDefinition<any>>(argumentLists: PossibleOptionDefinition<OD>[]) => PossibleOptionDefinition<OD>[];
7
- export default mergeArguments;
@@ -1,8 +0,0 @@
1
- /**
2
- * Finds strings in an array that are similar to the given string.
3
- * @param string The target string to match against
4
- * @param array Array of candidate strings to search
5
- * @returns Array of similar strings from the input array
6
- */
7
- declare const findAlternatives: (string: string, array: string[]) => string[];
8
- export default findAlternatives;
@@ -1,2 +0,0 @@
1
- declare const hideBin: (argv: string[]) => string[];
2
- export default hideBin;
@@ -1,7 +0,0 @@
1
- /**
2
- * Parses the raw command into an array of strings.
3
- * @param commandArray Command string or list of command parts.
4
- * @returns The command as an array of strings.
5
- */
6
- declare const parseRawCommand: (commandArray: string[] | string) => string[];
7
- export default parseRawCommand;
@@ -1,9 +0,0 @@
1
- /**
2
- * Registers global exception handlers for uncaught exceptions and unhandled promise rejections.
3
- * Logs errors using the provided logger and exits the process with code 1.
4
- * @template T - Logger type that extends Console interface
5
- * @param logger Console-like logger instance for error reporting
6
- * @returns Cleanup function to remove event listeners
7
- */
8
- declare const registerExceptionHandler: <T extends Console = Console>(logger: T) => () => void;
9
- export default registerExceptionHandler;
@@ -1,65 +0,0 @@
1
- /**
2
- * Runtime-agnostic process-like APIs that work across Node.js, Deno, and Bun.
3
- */
4
- /**
5
- * Gets command line arguments compatible with process.argv format.
6
- * For Deno, constructs argv from Deno.args (prepending execPath).
7
- * For Node.js and Bun, uses process.argv directly.
8
- * @returns Array of command line arguments
9
- */
10
- export declare const getArgv: () => ReadonlyArray<string>;
11
- /**
12
- * Gets the current working directory.
13
- * @returns The current working directory path
14
- */
15
- export declare const getCwd: () => string;
16
- /**
17
- * Gets environment variables as a mutable object.
18
- * Returns a proxy object that handles mutations across different runtimes.
19
- * @returns Environment variables object (mutable proxy)
20
- */
21
- export declare const getEnv: () => Record<string, string | undefined>;
22
- /**
23
- * Gets execution arguments (e.g., --inspect, --trace-warnings).
24
- * @returns Array of execution arguments
25
- */
26
- export declare const getExecArgv: () => ReadonlyArray<string>;
27
- /**
28
- * Gets the absolute pathname of the executable that started the process.
29
- * @returns The executable path
30
- */
31
- export declare const getExecPath: () => string;
32
- /**
33
- * Gets the operating system platform.
34
- * @returns Platform string (e.g., "darwin", "linux", "win32")
35
- */
36
- export declare const getPlatform: () => string;
37
- /**
38
- * Gets the CPU architecture.
39
- * @returns Architecture string (e.g., "x64", "arm64")
40
- */
41
- export declare const getArch: () => string;
42
- /**
43
- * Gets version information about the runtime.
44
- * @returns Object with version strings
45
- */
46
- export declare const getVersions: () => Record<string, string>;
47
- /**
48
- * Terminates the process with the specified exit code.
49
- * @param exitCode Exit code (default: 0)
50
- */
51
- export declare const exitProcess: (exitCode?: number) => never;
52
- /**
53
- * Runtime-agnostic event handler registration.
54
- * Note: Deno and Bun don't have equivalent event emitters, so this only works in Node.js.
55
- * In other runtimes, handlers are registered but may not be called for all events.
56
- */
57
- export type ProcessEventType = "uncaughtException" | "unhandledRejection";
58
- export type ProcessEventHandler = (...args: unknown[]) => void;
59
- /**
60
- * Registers an event handler for process events.
61
- * @param event Event type to listen for
62
- * @param handler Handler function
63
- * @returns Cleanup function to remove the handler
64
- */
65
- export declare const onProcessEvent: (event: ProcessEventType, handler: ProcessEventHandler) => () => void;
@@ -1,2 +0,0 @@
1
- declare const semverGt: (version1: string, version2: string) => boolean;
2
- export default semverGt;
@@ -1,24 +0,0 @@
1
- /**
2
- * Validates that a string is not empty or whitespace-only.
3
- */
4
- export declare const validateNonEmptyString: (value: unknown, fieldName: string) => string;
5
- /**
6
- * Validates that a value is an array of strings.
7
- */
8
- export declare const validateStringArray: (value: unknown, fieldName: string) => string[];
9
- /**
10
- * Validates that a value is a function.
11
- */
12
- export declare const validateFunction: (value: unknown, fieldName: string) => (...args: unknown[]) => unknown;
13
- /**
14
- * Validates that a value is an object (but not null).
15
- */
16
- export declare const validateObject: (value: unknown, fieldName: string) => Record<string, unknown>;
17
- /**
18
- * Validates command name format and prevents malicious inputs.
19
- */
20
- export declare const validateCommandName: (name: string) => string;
21
- /**
22
- * Validates plugin name format and prevents malicious inputs.
23
- */
24
- export declare const validatePluginName: (name: string) => string;
@@ -1,9 +0,0 @@
1
- import type { EnvDefinition } from "../types/command.d.ts";
2
- /**
3
- * Processes environment variables from a command definition.
4
- * Transforms string values to their specified types and applies default values.
5
- * @param envDefinitions Array of environment variable definitions
6
- * @returns Object with camelCase keys and transformed values
7
- */
8
- declare const processEnvVariables: (envDefinitions: (EnvDefinition<boolean> | EnvDefinition<number> | EnvDefinition<string>)[] | undefined) => Record<string, unknown>;
9
- export default processEnvVariables;
@@ -1,58 +0,0 @@
1
- /**
2
- * Security utilities for preventing injection attacks and malicious inputs
3
- */
4
- /**
5
- * Sanitizes a command argument to prevent injection attacks.
6
- * @param argument The argument string to sanitize.
7
- * @returns The sanitized argument with whitespace trimmed.
8
- * @throws {TypeError} If the argument is not a string.
9
- * @throws {Error} If the argument exceeds maximum length or contains dangerous characters.
10
- */
11
- export declare const sanitizeArgument: (argument: string) => string;
12
- /**
13
- * Sanitizes an array of arguments.
14
- * @param args The array of arguments to sanitize.
15
- * @returns Array of sanitized arguments.
16
- * @throws {TypeError} If args is not an array or if any argument is not a string.
17
- * @throws {Error} If there are too many arguments or if any argument is invalid.
18
- */
19
- export declare const sanitizeArguments: (args: ReadonlyArray<string>) => string[];
20
- /**
21
- * Validates that a file path is safe (prevents directory traversal).
22
- * @param path The file path to validate.
23
- * @returns The validated path with whitespace trimmed.
24
- * @throws {TypeError} If the path is not a string.
25
- * @throws {Error} If the path contains traversal sequences, is absolute, or exceeds maximum length.
26
- */
27
- export declare const validateSafePath: (path: string) => string;
28
- /**
29
- * Rate limiting helper to prevent brute force attacks
30
- * Automatically cleans up expired entries to prevent memory leaks
31
- */
32
- export declare class RateLimiter {
33
- private attempts;
34
- private readonly maxAttempts;
35
- private readonly windowMs;
36
- /**
37
- * Creates a new RateLimiter instance.
38
- * @param maxAttempts Maximum number of attempts allowed within the time window (default: 5).
39
- * @param windowMs Time window in milliseconds (default: 60000).
40
- */
41
- constructor(maxAttempts?: number, windowMs?: number);
42
- /**
43
- * Checks if the key has exceeded the rate limit.
44
- * @param key Unique identifier for the rate limit check.
45
- * @returns true if the request is allowed, false if rate limit exceeded.
46
- */
47
- checkLimit(key: string): boolean;
48
- /**
49
- * Resets the rate limit for a specific key.
50
- * @param key The key to reset.
51
- */
52
- reset(key: string): void;
53
- /**
54
- * Removes expired entries from the attempts map.
55
- * @param now Current timestamp.
56
- */
57
- private cleanup;
58
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Formats templates with intelligent caching.
3
- */
4
- declare const templateFormat: (string_?: string) => string;
5
- export default templateFormat;