@qodalis/cli-core 2.0.0-beta.7 → 2.0.0-beta.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qodalis/cli-core",
3
- "version": "2.0.0-beta.7",
3
+ "version": "2.0.0-beta.8",
4
4
  "description": "Core interfaces, types, and utilities for the @qodalis CLI ecosystem.",
5
5
  "author": "Nicolae Lupei, Qodalis Solutions",
6
6
  "license": "MIT",
package/public-api.d.mts CHANGED
@@ -546,13 +546,82 @@ declare const enums: {
546
546
  };
547
547
 
548
548
  /**
549
- * Represents an option for the readSelect prompt.
549
+ * Options for readFile file picker.
550
+ */
551
+ interface CliFilePickerOptions {
552
+ /** Allow selecting multiple files. Default: false. */
553
+ multiple?: boolean;
554
+ /**
555
+ * File type filter. Accepts MIME types (e.g. 'image/*') or extensions
556
+ * (e.g. '.json,.txt'). Maps to the HTML accept attribute in browsers
557
+ * and file filter in Electron.
558
+ */
559
+ accept?: string;
560
+ /**
561
+ * When true, pick a directory instead of files. Default: false.
562
+ * Cannot be combined with `multiple` — if both are set, `directory` takes precedence
563
+ * and a single directory is returned.
564
+ */
565
+ directory?: boolean;
566
+ /**
567
+ * How to read file content. Default: 'text'.
568
+ * - 'text': Read as UTF-8 string (suitable for text files)
569
+ * - 'arraybuffer': Read as ArrayBuffer (suitable for binary files like images)
570
+ */
571
+ readAs?: 'text' | 'arraybuffer';
572
+ }
573
+ /**
574
+ * Result returned by readFile for each selected file.
575
+ */
576
+ interface CliFileResult {
577
+ /** File name without path (e.g. 'config.json') */
578
+ name: string;
579
+ /** Full file path. Available in Electron, undefined in browser. */
580
+ path?: string;
581
+ /**
582
+ * File content. Type depends on `CliFilePickerOptions.readAs`:
583
+ * - 'text' (default): `string` (UTF-8 decoded)
584
+ * - 'arraybuffer': `ArrayBuffer` (raw bytes)
585
+ */
586
+ content: string | ArrayBuffer;
587
+ /** File size in bytes */
588
+ size: number;
589
+ /** MIME type (e.g. 'application/json', 'image/png') */
590
+ type: string;
591
+ }
592
+ /**
593
+ * Abstraction for environment-specific file picking.
594
+ * Implementations handle the actual dialog interaction for their environment.
595
+ */
596
+ interface ICliFilePickerProvider {
597
+ /** Whether file picking is supported in this environment */
598
+ readonly isSupported: boolean;
599
+ /**
600
+ * Open a file picker dialog and return selected files.
601
+ * @returns Array of selected files, or null if the user cancelled
602
+ */
603
+ pickFiles(options?: CliFilePickerOptions): Promise<CliFileResult[] | null>;
604
+ /**
605
+ * Open a directory picker dialog and return the selected directory.
606
+ * @returns The selected directory, or null if the user cancelled
607
+ */
608
+ pickDirectory(): Promise<CliFileResult | null>;
609
+ }
610
+
611
+ /**
612
+ * Represents an option for the readSelect and readSelectInline prompts.
550
613
  */
551
614
  interface CliSelectOption {
552
615
  /** Display text shown to the user */
553
616
  label: string;
554
617
  /** Value returned when this option is selected */
555
618
  value: string;
619
+ /** Optional description shown as dimmed italic text after the label */
620
+ description?: string;
621
+ /** Group name — options sharing the same group are displayed under a group header */
622
+ group?: string;
623
+ /** When true, the option is visible but cannot be selected (rendered dimmed) */
624
+ disabled?: boolean;
556
625
  }
557
626
  /**
558
627
  * Represents an option for the readMultiSelect prompt.
@@ -561,59 +630,114 @@ interface CliMultiSelectOption extends CliSelectOption {
561
630
  /** Whether the option is pre-selected */
562
631
  checked?: boolean;
563
632
  }
633
+ /**
634
+ * Options for readLine input.
635
+ */
636
+ interface CliLineOptions {
637
+ /**
638
+ * Pre-filled default value. Shown in the buffer when the prompt opens.
639
+ * The cursor starts at the end of the default text.
640
+ */
641
+ default?: string;
642
+ /**
643
+ * Validation function called on Enter.
644
+ * Return an error message string to reject the input and display the error.
645
+ * Return null to accept the input.
646
+ */
647
+ validate?: (value: string) => string | null;
648
+ /** Placeholder text shown dimmed when the buffer is empty */
649
+ placeholder?: string;
650
+ }
651
+ /**
652
+ * Options for readSelect and readSelectInline.
653
+ */
654
+ interface CliSelectOptions {
655
+ /** Pre-select an option by its value */
656
+ default?: string;
657
+ /** Enable type-to-filter. When true, printable keystrokes filter the option list. Default: false. */
658
+ searchable?: boolean;
659
+ /** Callback invoked each time the highlighted option changes */
660
+ onChange?: (value: string) => void;
661
+ }
662
+ /**
663
+ * Options for readMultiSelect.
664
+ */
665
+ interface CliMultiSelectOptions {
666
+ /** Enable type-to-filter. When true, printable keystrokes filter the option list. Default: false. */
667
+ searchable?: boolean;
668
+ /** Callback invoked each time the set of checked options changes */
669
+ onChange?: (values: string[]) => void;
670
+ }
671
+ /**
672
+ * Options for readDate input.
673
+ */
674
+ interface CliDateOptions {
675
+ /**
676
+ * Date format string. Supported tokens: YYYY (4-digit year), MM (2-digit month),
677
+ * DD (2-digit day). Separators can be `-`, `/`, or `.`.
678
+ * @default 'YYYY-MM-DD'
679
+ */
680
+ format?: string;
681
+ /** Minimum allowed date in the same format as `format` */
682
+ min?: string;
683
+ /** Maximum allowed date in the same format as `format` */
684
+ max?: string;
685
+ /** Pre-filled default value */
686
+ default?: string;
687
+ }
564
688
  /**
565
689
  * Provides interactive input reading from the terminal.
566
690
  * All methods resolve with `null` when the user aborts (Ctrl+C or Escape).
567
691
  */
568
692
  interface ICliInputReader {
569
693
  /**
570
- * Prompt the user for a line of text input.
571
- * @param prompt The prompt text to display (e.g. "Enter your name: ")
572
- * @returns The entered text, empty string if Enter pressed with no input, or null if aborted
694
+ * Read a line of text input.
695
+ * @param prompt - The prompt text displayed to the user
696
+ * @param options - Optional configuration for default value, validation, and placeholder
697
+ * @returns The entered text, or null if aborted
573
698
  */
574
- readLine(prompt: string): Promise<string | null>;
699
+ readLine(prompt: string, options?: CliLineOptions): Promise<string | null>;
575
700
  /**
576
- * Prompt the user for password input. Characters are masked with asterisks.
577
- * @param prompt The prompt text to display (e.g. "Password: ")
578
- * @returns The entered password, empty string if Enter pressed with no input, or null if aborted
701
+ * Read a password (masked input).
702
+ * @param prompt - The prompt text displayed to the user
703
+ * @returns The entered password, or null if aborted
579
704
  */
580
705
  readPassword(prompt: string): Promise<string | null>;
581
706
  /**
582
- * Prompt the user for a yes/no confirmation.
583
- * @param prompt The prompt text to display (e.g. "Continue?")
584
- * @param defaultValue The default value when Enter is pressed without input (defaults to false)
585
- * @returns true for yes, false for no, defaultValue on empty Enter, or null if aborted
707
+ * Read a yes/no confirmation.
708
+ * @param prompt - The prompt text displayed to the user
709
+ * @param defaultValue - Default value when Enter is pressed without input
710
+ * @returns true for yes, false for no, or null if aborted
586
711
  */
587
712
  readConfirm(prompt: string, defaultValue?: boolean): Promise<boolean | null>;
588
713
  /**
589
- * Prompt the user to select from a list of options using arrow keys.
590
- * @param prompt The prompt text to display (e.g. "Pick one:")
591
- * @param options The list of options to choose from
592
- * @param onChange Optional callback invoked each time the highlighted option changes
593
- * @returns The value of the selected option, or null if aborted
714
+ * Read a selection from a vertical list of options.
715
+ * @param prompt - The prompt text displayed to the user
716
+ * @param options - Array of options to choose from
717
+ * @param selectOptions - Optional configuration for default, search, onChange
718
+ * @returns The selected option's value, or null if aborted
594
719
  */
595
- readSelect(prompt: string, options: CliSelectOption[], onChange?: (value: string) => void): Promise<string | null>;
720
+ readSelect(prompt: string, options: CliSelectOption[], selectOptions?: CliSelectOptions): Promise<string | null>;
596
721
  /**
597
- * Prompt the user to select from a horizontal single-line option picker.
598
- * Navigate with Left/Right arrow keys.
599
- * @param prompt The prompt text to display
600
- * @param options The list of options to choose from
601
- * @param onChange Optional callback invoked each time the highlighted option changes
602
- * @returns The value of the selected option, or null if aborted
722
+ * Read a selection from an inline horizontal list.
723
+ * @param prompt - The prompt text displayed to the user
724
+ * @param options - Array of options to choose from
725
+ * @param selectOptions - Optional configuration for default, search, onChange
726
+ * @returns The selected option's value, or null if aborted
603
727
  */
604
- readSelectInline(prompt: string, options: CliSelectOption[], onChange?: (value: string) => void): Promise<string | null>;
728
+ readSelectInline(prompt: string, options: CliSelectOption[], selectOptions?: CliSelectOptions): Promise<string | null>;
605
729
  /**
606
- * Prompt the user to select multiple items from a checkbox list.
607
- * Navigate with Up/Down, toggle with Space, confirm with Enter.
608
- * @param prompt The prompt text to display
609
- * @param options The list of options with optional pre-checked state
610
- * @returns Array of selected values, or null if aborted
730
+ * Read multiple selections from a checkbox list.
731
+ * @param prompt - The prompt text displayed to the user
732
+ * @param options - Array of options with optional pre-checked state
733
+ * @param selectOptions - Optional configuration for search, onChange
734
+ * @returns Array of selected option values, or null if aborted
611
735
  */
612
- readMultiSelect(prompt: string, options: CliMultiSelectOption[]): Promise<string[] | null>;
736
+ readMultiSelect(prompt: string, options: CliMultiSelectOption[], selectOptions?: CliMultiSelectOptions): Promise<string[] | null>;
613
737
  /**
614
- * Prompt the user for numeric input with optional min/max validation.
615
- * @param prompt The prompt text to display
616
- * @param options Optional constraints: min, max, and default value
738
+ * Read a number input.
739
+ * @param prompt - The prompt text displayed to the user
740
+ * @param options - Optional configuration for min, max, and default value
617
741
  * @returns The entered number, or null if aborted
618
742
  */
619
743
  readNumber(prompt: string, options?: {
@@ -621,6 +745,20 @@ interface ICliInputReader {
621
745
  max?: number;
622
746
  default?: number;
623
747
  }): Promise<number | null>;
748
+ /**
749
+ * Read a date input with format validation.
750
+ * @param prompt - The prompt text displayed to the user
751
+ * @param options - Optional configuration for format, min/max range, default
752
+ * @returns The date string in the specified format, or null if aborted
753
+ */
754
+ readDate(prompt: string, options?: CliDateOptions): Promise<string | null>;
755
+ /**
756
+ * Read file(s) via the environment's file picker dialog.
757
+ * @param prompt - The prompt text displayed to the user
758
+ * @param options - Optional configuration for multiple, accept filter, directory mode
759
+ * @returns Array of selected files with content, or null if cancelled/unsupported
760
+ */
761
+ readFile(prompt: string, options?: CliFilePickerOptions): Promise<CliFileResult[] | null>;
624
762
  }
625
763
 
626
764
  /**
@@ -707,6 +845,8 @@ interface ICliBackgroundService {
707
845
  * Read-only snapshot of a background service's current state.
708
846
  */
709
847
  interface ICliBackgroundServiceInfo {
848
+ /** Process ID assigned by the process registry */
849
+ pid?: number;
710
850
  name: string;
711
851
  description?: string;
712
852
  type: CliBackgroundServiceType;
@@ -1474,6 +1614,24 @@ interface ICliDragDropService {
1474
1614
  readonly onFileDrop: Observable<File[]>;
1475
1615
  }
1476
1616
 
1617
+ type LineState = number;
1618
+ interface ISyntaxHighlightRule {
1619
+ pattern: RegExp;
1620
+ tokenType: string;
1621
+ captureGroup?: number;
1622
+ }
1623
+ interface ISyntaxHighlighter {
1624
+ id: string;
1625
+ extensions: string[];
1626
+ initialState: LineState;
1627
+ getRules(state: LineState): ISyntaxHighlightRule[];
1628
+ getNextLineState(line: string, currentState: LineState): LineState;
1629
+ }
1630
+ interface ISyntaxTheme {
1631
+ name: string;
1632
+ colors: Record<string, string>;
1633
+ }
1634
+
1477
1635
  interface ICliTerminalWriter {
1478
1636
  /**
1479
1637
  * Write text to the terminal
@@ -1718,17 +1876,30 @@ interface ICliExecutionProcess {
1718
1876
  */
1719
1877
  interface ICliProcessEntry {
1720
1878
  pid: number;
1879
+ /** Display name (service name for bg services, command text for commands) */
1880
+ name: string;
1881
+ /** Process type */
1882
+ type: 'command' | 'daemon' | 'job' | 'service';
1721
1883
  command: string;
1722
1884
  startTime: number;
1723
1885
  status: 'running' | 'completed' | 'failed' | 'killed';
1724
1886
  exitCode?: number;
1725
1887
  }
1888
+ /** Options for registering a process */
1889
+ interface ICliProcessRegisterOptions {
1890
+ /** Display name (defaults to command) */
1891
+ name?: string;
1892
+ /** Process type (defaults to 'command') */
1893
+ type?: 'command' | 'daemon' | 'job' | 'service';
1894
+ /** Custom kill handler (e.g. for background services) */
1895
+ onKill?: () => Promise<void> | void;
1896
+ }
1726
1897
  /**
1727
1898
  * Registry for tracking CLI processes
1728
1899
  */
1729
1900
  interface ICliProcessRegistry {
1730
1901
  /** Register a new process, returns assigned PID */
1731
- register(command: string): {
1902
+ register(command: string, options?: ICliProcessRegisterOptions): {
1732
1903
  pid: number;
1733
1904
  abortController: AbortController;
1734
1905
  };
@@ -2256,7 +2427,7 @@ declare const DefaultThemes: DefaultThemesType;
2256
2427
 
2257
2428
  declare const DefaultThemeInfos: Record<string, CliThemeInfo>;
2258
2429
 
2259
- declare const LIBRARY_VERSION = "2.0.0-beta.7";
2430
+ declare const LIBRARY_VERSION = "2.0.0-beta.8";
2260
2431
  declare const API_VERSION = 2;
2261
2432
 
2262
2433
  /**
@@ -2319,4 +2490,4 @@ declare class BrowserFileTransferService implements ICliFileTransferService {
2319
2490
  private _pickFile;
2320
2491
  }
2321
2492
 
2322
- export { API_VERSION, BrowserFileTransferService, CLI_CONFIGURE_STORE_NAME, CancellablePromise, type CliAddUser, CliBackgroundColor, type CliBackgroundServiceStatus, type CliBackgroundServiceType, type CliEngineSnapshot, type CliFactoryProvider, CliForegroundColor, CliIcon, CliLogLevel, CliModuleRegistry, type CliMultiSelectOption, type CliOptions, type CliPackageSource, type CliPanelConfig, type CliPanelHideAlignment, type CliPanelPosition, type CliPercentageProgressBarUpdateValueOptions, type CliProcessCommand, type CliProcessorMetadata, type CliProvider, type CliSelectOption, type CliServerCapabilities, type CliServerCommandDescriptor, type CliServerConfig, type CliServerOutput, type CliServerResponse, type CliServiceEventHandler, type CliServiceExecutionMode, type CliState, type CliStateConfiguration, type CliTextAnimatorOptions, type CliTheme, type CliThemeCategory, type CliThemeInfo, type CliTypeProvider, type CliUpdateUser, type CliValueProvider, type CliWorkerInboundMessage, type CliWorkerOutboundMessage, DEFAULT_DIR_PERMISSIONS, DEFAULT_FILE_PERMISSIONS, DefaultLibraryAuthor, DefaultThemeInfos, DefaultThemes, type ICliAuthService, ICliAuthService_TOKEN, type ICliBackgroundService, type ICliBackgroundServiceInfo, type ICliBackgroundServiceRegistry, type ICliClipboard, type ICliCommandAuthor, type ICliCommandChildProcessor, type ICliCommandExecutorService, type ICliCommandParameterDescriptor, type ICliCommandProcessor, type ICliCommandProcessorRegistry, type ICliCompletionContext, type ICliCompletionProvider, ICliCompletionProvider_TOKEN, type ICliConfigurationOption, type ICliDragDropService, ICliDragDropService_TOKEN, type ICliExecutionContext, type ICliExecutionProcess, type ICliFileEntry, type ICliFileTransferService, ICliFileTransferService_TOKEN, type ICliGlobalParameterHandler, type ICliGroup, type ICliGroupsStoreService, ICliGroupsStoreService_TOKEN, type ICliInputReader, type ICliKeyValueStore, type ICliLogger, type ICliManagedInterval, type ICliManagedTimer, type ICliModule, type ICliOwnership, type ICliPercentageProgressBar, type ICliPermissionService, ICliPermissionService_TOKEN, type ICliPingServerService, type ICliProcessEntry, type ICliProcessRegistry, type ICliProcessorHook, type ICliProgressBar, type ICliServiceContext, type ICliServiceEvent, type ICliServiceLogEntry, type ICliServiceProvider, type ICliSpinner, type ICliStateStore, type ICliTerminalWriter, type ICliTextAnimator, type ICliTranslationService, ICliTranslationService_TOKEN, type ICliUmdModule, type ICliUser, type ICliUserCredentials, type ICliUserSession, type ICliUserSessionService, ICliUserSessionService_TOKEN, type ICliUsersStoreService, ICliUsersStoreService_TOKEN, LIBRARY_VERSION, ObjectDescriber, type Package, type ServerVersionInfo, ServerVersionNegotiator, type WorkerServiceContext, bootCliModule, bootUmdModule, clearTerminalLine, colorFirstWord, colorizeJson, compareVersions, constants, createWorkerService, delay, derivePanelThemeStyles, enums, formatJson, getConfigValue, getParameterValue, getRightOfWord, highlightTextWithBg, initializeBrowserEnvironment, loadPanelPosition, nextPanelPosition, resolveConfigurationCategories, satisfiesMinVersion, satisfiesVersionRange, savePanelPosition, toQueryString, utils };
2493
+ export { API_VERSION, BrowserFileTransferService, CLI_CONFIGURE_STORE_NAME, CancellablePromise, type CliAddUser, CliBackgroundColor, type CliBackgroundServiceStatus, type CliBackgroundServiceType, type CliDateOptions, type CliEngineSnapshot, type CliFactoryProvider, type CliFilePickerOptions, type CliFileResult, CliForegroundColor, CliIcon, type CliLineOptions, CliLogLevel, CliModuleRegistry, type CliMultiSelectOption, type CliMultiSelectOptions, type CliOptions, type CliPackageSource, type CliPanelConfig, type CliPanelHideAlignment, type CliPanelPosition, type CliPercentageProgressBarUpdateValueOptions, type CliProcessCommand, type CliProcessorMetadata, type CliProvider, type CliSelectOption, type CliSelectOptions, type CliServerCapabilities, type CliServerCommandDescriptor, type CliServerConfig, type CliServerOutput, type CliServerResponse, type CliServiceEventHandler, type CliServiceExecutionMode, type CliState, type CliStateConfiguration, type CliTextAnimatorOptions, type CliTheme, type CliThemeCategory, type CliThemeInfo, type CliTypeProvider, type CliUpdateUser, type CliValueProvider, type CliWorkerInboundMessage, type CliWorkerOutboundMessage, DEFAULT_DIR_PERMISSIONS, DEFAULT_FILE_PERMISSIONS, DefaultLibraryAuthor, DefaultThemeInfos, DefaultThemes, type ICliAuthService, ICliAuthService_TOKEN, type ICliBackgroundService, type ICliBackgroundServiceInfo, type ICliBackgroundServiceRegistry, type ICliClipboard, type ICliCommandAuthor, type ICliCommandChildProcessor, type ICliCommandExecutorService, type ICliCommandParameterDescriptor, type ICliCommandProcessor, type ICliCommandProcessorRegistry, type ICliCompletionContext, type ICliCompletionProvider, ICliCompletionProvider_TOKEN, type ICliConfigurationOption, type ICliDragDropService, ICliDragDropService_TOKEN, type ICliExecutionContext, type ICliExecutionProcess, type ICliFileEntry, type ICliFilePickerProvider, type ICliFileTransferService, ICliFileTransferService_TOKEN, type ICliGlobalParameterHandler, type ICliGroup, type ICliGroupsStoreService, ICliGroupsStoreService_TOKEN, type ICliInputReader, type ICliKeyValueStore, type ICliLogger, type ICliManagedInterval, type ICliManagedTimer, type ICliModule, type ICliOwnership, type ICliPercentageProgressBar, type ICliPermissionService, ICliPermissionService_TOKEN, type ICliPingServerService, type ICliProcessEntry, type ICliProcessRegisterOptions, type ICliProcessRegistry, type ICliProcessorHook, type ICliProgressBar, type ICliServiceContext, type ICliServiceEvent, type ICliServiceLogEntry, type ICliServiceProvider, type ICliSpinner, type ICliStateStore, type ICliTerminalWriter, type ICliTextAnimator, type ICliTranslationService, ICliTranslationService_TOKEN, type ICliUmdModule, type ICliUser, type ICliUserCredentials, type ICliUserSession, type ICliUserSessionService, ICliUserSessionService_TOKEN, type ICliUsersStoreService, ICliUsersStoreService_TOKEN, type ISyntaxHighlightRule, type ISyntaxHighlighter, type ISyntaxTheme, LIBRARY_VERSION, type LineState, ObjectDescriber, type Package, type ServerVersionInfo, ServerVersionNegotiator, type WorkerServiceContext, bootCliModule, bootUmdModule, clearTerminalLine, colorFirstWord, colorizeJson, compareVersions, constants, createWorkerService, delay, derivePanelThemeStyles, enums, formatJson, getConfigValue, getParameterValue, getRightOfWord, highlightTextWithBg, initializeBrowserEnvironment, loadPanelPosition, nextPanelPosition, resolveConfigurationCategories, satisfiesMinVersion, satisfiesVersionRange, savePanelPosition, toQueryString, utils };