@alcyone-labs/arg-parser 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +155 -13
  2. package/dist/config/ConfigurationManager.d.ts +74 -0
  3. package/dist/config/ConfigurationManager.d.ts.map +1 -0
  4. package/dist/config/plugins/ConfigPlugin.d.ts +60 -0
  5. package/dist/config/plugins/ConfigPlugin.d.ts.map +1 -0
  6. package/dist/config/plugins/ConfigPluginRegistry.d.ts +72 -0
  7. package/dist/config/plugins/ConfigPluginRegistry.d.ts.map +1 -0
  8. package/dist/config/plugins/TomlConfigPlugin.d.ts +30 -0
  9. package/dist/config/plugins/TomlConfigPlugin.d.ts.map +1 -0
  10. package/dist/config/plugins/YamlConfigPlugin.d.ts +29 -0
  11. package/dist/config/plugins/YamlConfigPlugin.d.ts.map +1 -0
  12. package/dist/config/plugins/index.d.ts +5 -0
  13. package/dist/config/plugins/index.d.ts.map +1 -0
  14. package/dist/core/ArgParser.d.ts +380 -0
  15. package/dist/core/ArgParser.d.ts.map +1 -0
  16. package/dist/core/ArgParserBase.d.ts +212 -0
  17. package/dist/core/ArgParserBase.d.ts.map +1 -0
  18. package/dist/core/FlagManager.d.ts +16 -0
  19. package/dist/core/FlagManager.d.ts.map +1 -0
  20. package/dist/core/types.d.ts +355 -0
  21. package/dist/core/types.d.ts.map +1 -0
  22. package/dist/dxt/DxtGenerator.d.ts +111 -0
  23. package/dist/dxt/DxtGenerator.d.ts.map +1 -0
  24. package/dist/index.cjs +70 -34
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.ts +11 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.min.mjs +3214 -3181
  29. package/dist/index.min.mjs.map +1 -1
  30. package/dist/index.mjs +70 -34
  31. package/dist/index.mjs.map +1 -1
  32. package/dist/mcp/ArgParserMcp.d.ts +21 -0
  33. package/dist/mcp/ArgParserMcp.d.ts.map +1 -0
  34. package/dist/mcp/mcp-integration.d.ts +86 -0
  35. package/dist/mcp/mcp-integration.d.ts.map +1 -0
  36. package/dist/mcp/mcp-notifications.d.ts +138 -0
  37. package/dist/mcp/mcp-notifications.d.ts.map +1 -0
  38. package/dist/mcp/mcp-prompts.d.ts +132 -0
  39. package/dist/mcp/mcp-prompts.d.ts.map +1 -0
  40. package/dist/mcp/mcp-protocol-versions.d.ts +150 -0
  41. package/dist/mcp/mcp-protocol-versions.d.ts.map +1 -0
  42. package/dist/mcp/mcp-resources.d.ts +133 -0
  43. package/dist/mcp/mcp-resources.d.ts.map +1 -0
  44. package/dist/testing/fuzzy-test-cli.d.ts +5 -0
  45. package/dist/testing/fuzzy-test-cli.d.ts.map +1 -0
  46. package/dist/testing/fuzzy-tester.d.ts +101 -0
  47. package/dist/testing/fuzzy-tester.d.ts.map +1 -0
  48. package/package.json +5 -3
package/README.md CHANGED
@@ -257,6 +257,44 @@ yarn unlink
257
257
 
258
258
  ArgParser's `parse()` method is async and automatically handles both synchronous and asynchronous handlers:
259
259
 
260
+ ### Automatic Argument Detection
261
+
262
+ `parse()` can now be called without arguments for improved developer experience:
263
+
264
+ ```typescript
265
+ const cli = ArgParser.withMcp({
266
+ appName: "My CLI",
267
+ appCommandName: "my-cli",
268
+ handler: async (ctx) => ({ success: true, data: ctx.args }),
269
+ });
270
+
271
+ // NEW: Call parse() without arguments
272
+ // Automatically detects Node.js environment and uses process.argv.slice(2)
273
+ async function main() {
274
+ try {
275
+ const result = await cli.parse(); // No arguments needed!
276
+ console.log("Success:", result);
277
+ } catch (error) {
278
+ console.error("Error:", error.message);
279
+ process.exit(1);
280
+ }
281
+ }
282
+ ```
283
+
284
+ **How it works:**
285
+
286
+ - ✅ **Auto-detection**: When `parse()` is called without arguments, ArgParser automatically detects if it's running in Node.js
287
+ - ✅ **Smart fallback**: Uses `process.argv.slice(2)` automatically in Node.js environments
288
+ - ✅ **User-friendly warning**: Shows a helpful warning in CLI mode to inform users about the behavior
289
+ - ✅ **Error handling**: Throws a clear error in non-Node.js environments when arguments are required
290
+ - ✅ **Backward compatible**: Explicit arguments still work exactly as before
291
+
292
+ **When warnings are shown:**
293
+
294
+ - ✅ CLI mode (when `appCommandName` is set)
295
+ - ❌ Library/programmatic usage (no `appCommandName`)
296
+ - ❌ MCP mode (warnings suppressed for clean MCP output)
297
+
260
298
  ### Cannonical Usage Pattern
261
299
 
262
300
  ```typescript
@@ -272,7 +310,12 @@ const cli = ArgParser.withMcp({
272
310
  // parse() is async and works with both sync and async handlers
273
311
  async function main() {
274
312
  try {
275
- const result = await cli.parse(process.argv.slice(2));
313
+ // Option 1: Auto-detection (NEW) - convenient for simple scripts
314
+ const result = await cli.parse();
315
+
316
+ // Option 2: Explicit arguments - full control
317
+ // const result = await cli.parse(process.argv.slice(2));
318
+
276
319
  // Handler results are automatically awaited and merged
277
320
  console.log(result.success); // true
278
321
  } catch (error) {
@@ -288,7 +331,12 @@ Works in ES modules or Node.js >=18 with top-level await
288
331
 
289
332
  ```javascript
290
333
  try {
291
- const result = await cli.parse(process.argv.slice(2));
334
+ // Auto-detection approach (recommended for simple scripts)
335
+ const result = await cli.parse();
336
+
337
+ // Or explicit approach for full control
338
+ // const result = await cli.parse(process.argv.slice(2));
339
+
292
340
  console.log("Success:", result);
293
341
  } catch (error) {
294
342
  console.error("Error:", error.message);
@@ -301,8 +349,9 @@ try {
301
349
  If you need synchronous contexts, you can simply rely on promise-based APIs
302
350
 
303
351
  ```javascript
352
+ // Auto-detection approach
304
353
  cli
305
- .parse(process.argv.slice(2))
354
+ .parse()
306
355
  .then((result) => {
307
356
  console.log("Success:", result);
308
357
  })
@@ -310,6 +359,17 @@ cli
310
359
  console.error("Error:", error.message);
311
360
  process.exit(1);
312
361
  });
362
+
363
+ // Or explicit approach
364
+ // cli
365
+ // .parse(process.argv.slice(2))
366
+ // .then((result) => {
367
+ // console.log("Success:", result);
368
+ // })
369
+ // .catch((error) => {
370
+ // console.error("Error:", error.message);
371
+ // process.exit(1);
372
+ // });
313
373
  ```
314
374
 
315
375
  ---
@@ -428,7 +488,9 @@ ArgParser provides **strong typing** for flag definitions with comprehensive val
428
488
  You can define flag types using either **constructor functions** or **string literals**:
429
489
 
430
490
  ```typescript
431
- const parser = new ArgParser({ /* ... */ }).addFlags([
491
+ const parser = new ArgParser({
492
+ /* ... */
493
+ }).addFlags([
432
494
  // Constructor functions (recommended for TypeScript)
433
495
  { name: "count", options: ["--count"], type: Number },
434
496
  { name: "enabled", options: ["--enabled"], type: Boolean, flagOnly: true },
@@ -441,12 +503,30 @@ const parser = new ArgParser({ /* ... */ }).addFlags([
441
503
  { name: "tags", options: ["--tags"], type: "array", allowMultiple: true },
442
504
  { name: "config", options: ["--config"], type: "object" },
443
505
 
444
- // Custom parser functions
506
+ // Custom parser functions (sync)
445
507
  {
446
508
  name: "date",
447
509
  options: ["--date"],
448
- type: (value: string) => new Date(value)
449
- }
510
+ type: (value: string) => new Date(value),
511
+ },
512
+
513
+ // Async custom parser functions
514
+ {
515
+ name: "config",
516
+ options: ["--config"],
517
+ type: async (filePath: string) => {
518
+ const content = await fs.readFile(filePath, "utf8");
519
+ return JSON.parse(content);
520
+ },
521
+ },
522
+ {
523
+ name: "user",
524
+ options: ["--user-id"],
525
+ type: async (userId: string) => {
526
+ const response = await fetch(`/api/users/${userId}`);
527
+ return response.json();
528
+ },
529
+ },
450
530
  ]);
451
531
  ```
452
532
 
@@ -470,9 +550,49 @@ The type system validates flag definitions at runtime and throws descriptive err
470
550
 
471
551
  - **String literals** are automatically converted to constructor functions internally
472
552
  - **Constructor functions** are preserved as-is
473
- - **Custom parser functions** allow complex transformations
553
+ - **Custom parser functions** (sync and async) allow complex transformations
474
554
  - **undefined** falls back to the default `"string"` type
475
555
 
556
+ #### Async Custom Parser Support
557
+
558
+ Custom parser functions can be **asynchronous**, enabling powerful use cases like file I/O, API calls, and database lookups:
559
+
560
+ ```typescript
561
+ const parser = new ArgParser({
562
+ /* ... */
563
+ }).addFlags([
564
+ {
565
+ name: "config",
566
+ options: ["--config"],
567
+ type: async (filePath: string) => {
568
+ const content = await fs.readFile(filePath, "utf8");
569
+ return JSON.parse(content);
570
+ },
571
+ },
572
+ {
573
+ name: "user",
574
+ options: ["--user-id"],
575
+ type: async (userId: string) => {
576
+ const response = await fetch(`/api/users/${userId}`);
577
+ if (!response.ok) throw new Error(`User not found: ${userId}`);
578
+ return response.json();
579
+ },
580
+ },
581
+ ]);
582
+
583
+ // Usage: --config ./settings.json --user-id 123
584
+ const result = await parser.parse(process.argv.slice(2));
585
+ // result.config contains parsed JSON from file
586
+ // result.user contains user data from API
587
+ ```
588
+
589
+ **Key Features:**
590
+
591
+ - ✅ **Backward compatible** - existing sync parsers continue to work
592
+ - ✅ **Automatic detection** - no configuration needed, just return a Promise
593
+ - ✅ **Error handling** - async errors are properly propagated
594
+ - ✅ **Performance** - parsers run concurrently when possible
595
+
476
596
  #### Type Conversion Examples
477
597
 
478
598
  ```typescript
@@ -492,9 +612,13 @@ The type system validates flag definitions at runtime and throws descriptive err
492
612
  --tags tag1,tag2,tag3 → ["tag1", "tag2", "tag3"]
493
613
  --file file1.txt --file file2.txt → ["file1.txt", "file2.txt"]
494
614
 
495
- // Custom parser functions
615
+ // Custom parser functions (sync)
496
616
  --date "2023-01-01" → Date object
497
617
  --json '{"key":"val"}' → parsed JSON object
618
+
619
+ // Async custom parser functions
620
+ --config "./settings.json" → parsed JSON from file (async)
621
+ --user-id "123" → user data from API (async)
498
622
  ```
499
623
 
500
624
  ### Hierarchical CLIs (Sub-Commands)
@@ -958,7 +1082,7 @@ ArgParser includes built-in `--s-*` flags for development, debugging, and config
958
1082
  | --------------------------- | ---------------------------------------------------------------------------------------------- |
959
1083
  | **MCP & DXT** | |
960
1084
  | `--s-mcp-serve` | Starts the application in MCP server mode, exposing all tools. |
961
- | `--s-build-dxt [dir]` | Generates a complete, autonomous DXT package for Claude Desktop. |
1085
+ | `--s-build-dxt [dir]` | Generates a complete, autonomous DXT package for Claude Desktop in the specified directory. |
962
1086
  | `--s-mcp-transport <type>` | Overrides the MCP transport (`stdio`, `sse`, `streamable-http`). |
963
1087
  | `--s-mcp-transports <json>` | Overrides transports with a JSON array for multi-transport setups. |
964
1088
  | `--s-mcp-port <number>` | Sets the port for HTTP-based transports (`sse`, `streamable-http`). |
@@ -975,6 +1099,24 @@ ArgParser includes built-in `--s-*` flags for development, debugging, and config
975
1099
 
976
1100
  ## Changelog
977
1101
 
1102
+ ### v2.2.0
1103
+
1104
+ **Feat**
1105
+
1106
+ - IFlag function-based `type` now supports async methods such as `type: async () => Promise<string>`.
1107
+
1108
+ **Fixes and changes**
1109
+
1110
+ - `.parse()` can now work without arguments, it will try to infer that if you are in CLI mode and on a Node environment, it should use `process.argv` as the input. You can still pass parameters to control more granularly.
1111
+ - `--s-build-dxt` now takes an optional path to specify where to prepare the assets prior to packing, the path you pass is in relation to process.cwd() (current working directory).
1112
+ - `--s-build-dxt` logo detection now resolves paths more accurately...
1113
+
1114
+ ### v2.1.1
1115
+
1116
+ **Fixes and changes**
1117
+
1118
+ - Fix missing missing types fr
1119
+
978
1120
  ### v2.1.0
979
1121
 
980
1122
  **Feat**
@@ -983,8 +1125,8 @@ ArgParser includes built-in `--s-*` flags for development, debugging, and config
983
1125
  - Add support for MCP output_schema field for clients that support it, CLI isn't impacted by it, this helps a lot the interactivity, self-documentation, and improves the API guarantees
984
1126
 
985
1127
  **Fixes and changes**
986
- - Fix missing missing types
987
- - Improved MCP version compliance
1128
+
1129
+ - Improved MCP version compliance
988
1130
 
989
1131
  ### v2.0.0
990
1132
 
@@ -1018,10 +1160,10 @@ ArgParser includes built-in `--s-*` flags for development, debugging, and config
1018
1160
  - [x] Rename --LIB-\* flags to --s-\*
1019
1161
  - [x] Make it possible to pass a `--s-save-to-env /path/to/file` parameter that saves all the parameters to a file (works with Bash-style .env, JSON, YAML, TOML)
1020
1162
  - [x] Make it possible to pass a `--s-with-env /path/to/file` parameter that loads all the parameters from a file (works with Bash-style .env, JSON, YAML, TOML)
1163
+ - [x] Add support for async type function to enable more flexibility
1021
1164
  - [ ] Add System flags to args.systemArgs
1022
1165
  - [ ] Improve flag options collision prevention
1023
1166
  - [ ] Add support for locales / translations
1024
- - [ ] Add support for async type function to enable more flexibility
1025
1167
  - [ ] (potentially) add support for fully typed parsed output, this has proven very challenging
1026
1168
  - [ ] Upgrade to Zod/V4 (V4 does not support functions well, this will take more time, not a priority)
1027
1169
 
@@ -0,0 +1,74 @@
1
+ import type { ProcessedFlag, TParsedArgs } from "../core/types";
2
+ /**
3
+ * ConfigurationManager handles environment file operations, format conversion,
4
+ * and configuration merging for ArgParser instances.
5
+ */
6
+ export declare class ConfigurationManager {
7
+ private argParserInstance;
8
+ constructor(argParserInstance: any);
9
+ /**
10
+ * Generates a default environment file name based on app configuration
11
+ */
12
+ generateDefaultEnvFileName(): string;
13
+ /**
14
+ * Handles the --s-save-to-env system flag at the final parser level
15
+ */
16
+ handleSaveToEnvFlag(processArgs: string[], parserChain: any[]): boolean;
17
+ /**
18
+ * Saves current configuration to an environment file
19
+ */
20
+ saveToEnvFile(filePath: string, _processArgs: string[], parserChain: any[]): void;
21
+ /**
22
+ * Loads configuration from an environment file
23
+ */
24
+ loadEnvFile(filePath: string, parserChain: any[]): Record<string, any>;
25
+ /**
26
+ * Parses environment file content
27
+ */
28
+ parseEnvFile(content: string): Record<string, any>;
29
+ /**
30
+ * Parses YAML file content (legacy method - now uses plugin system)
31
+ */
32
+ parseYamlFile(content: string): Record<string, any>;
33
+ /**
34
+ * Parses JSON file content
35
+ */
36
+ parseJsonFile(content: string): Record<string, any>;
37
+ /**
38
+ * Parses TOML file content (legacy method - now uses plugin system)
39
+ */
40
+ parseTomlFile(content: string): Record<string, any>;
41
+ /**
42
+ * Converts raw configuration to flag values with proper type conversion
43
+ */
44
+ convertConfigToFlagValues(rawConfig: Record<string, any>, parserChain: any[]): Record<string, any>;
45
+ /**
46
+ * Converts a value to the appropriate flag type
47
+ */
48
+ convertValueToFlagType(value: any, flag: ProcessedFlag): any;
49
+ /**
50
+ * Merges environment configuration with command line arguments
51
+ */
52
+ mergeEnvConfigWithArgs(envConfig: Record<string, any>, processArgs: string[]): string[];
53
+ /**
54
+ * Generates environment file format
55
+ */
56
+ generateEnvFormat(flags: ProcessedFlag[], parsedArgs: TParsedArgs<any>): string;
57
+ /**
58
+ * Generates YAML file format (legacy method - now uses plugin system)
59
+ */
60
+ generateYamlFormat(flags: ProcessedFlag[], parsedArgs: TParsedArgs<any>): string;
61
+ /**
62
+ * Generates JSON file format
63
+ */
64
+ generateJsonFormat(flags: ProcessedFlag[], parsedArgs: TParsedArgs<any>): string;
65
+ /**
66
+ * Generates TOML file format (legacy method - now uses plugin system)
67
+ */
68
+ generateTomlFormat(flags: ProcessedFlag[], parsedArgs: TParsedArgs<any>): string;
69
+ /**
70
+ * Gets a string representation of a flag type
71
+ */
72
+ private getTypeString;
73
+ }
74
+ //# sourceMappingURL=ConfigurationManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigurationManager.d.ts","sourceRoot":"","sources":["../../src/config/ConfigurationManager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGhE;;;GAGG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,iBAAiB,CAAM;gBAEnB,iBAAiB,EAAE,GAAG;IAOlC;;OAEG;IACI,0BAA0B,IAAI,MAAM;IAqB3C;;OAEG;IACI,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,OAAO;IAyB9E;;OAEG;IACI,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,IAAI;IAyDxF;;OAEG;IACI,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC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AEG;IACH,OAAO,CAAC,aAAa;CAStB"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Plugin interface for configuration file format support
3
+ */
4
+ export interface IConfigPlugin {
5
+ /**
6
+ * File extensions this plugin supports (e.g., ['.toml', '.tml'])
7
+ */
8
+ readonly supportedExtensions: string[];
9
+ /**
10
+ * Plugin name for identification
11
+ */
12
+ readonly name: string;
13
+ /**
14
+ * Parse configuration file content
15
+ * @param content File content as string
16
+ * @returns Parsed configuration object
17
+ */
18
+ parse(content: string): Record<string, any>;
19
+ /**
20
+ * Generate configuration file content
21
+ * @param config Configuration object
22
+ * @param flags Flag definitions for metadata
23
+ * @param parsedArgs Parsed arguments for values
24
+ * @returns Generated file content
25
+ */
26
+ generate(config: Record<string, any>, flags: any[], parsedArgs: any): string;
27
+ }
28
+ /**
29
+ * Base class for configuration plugins
30
+ */
31
+ export declare abstract class ConfigPlugin implements IConfigPlugin {
32
+ abstract readonly supportedExtensions: string[];
33
+ abstract readonly name: string;
34
+ abstract parse(content: string): Record<string, any>;
35
+ abstract generate(config: Record<string, any>, flags: any[], parsedArgs: any): string;
36
+ /**
37
+ * Check if this plugin supports a given file extension
38
+ */
39
+ supportsExtension(extension: string): boolean;
40
+ }
41
+ /**
42
+ * Built-in JSON configuration plugin (no external dependencies)
43
+ */
44
+ export declare class JsonConfigPlugin extends ConfigPlugin {
45
+ readonly supportedExtensions: string[];
46
+ readonly name = "json";
47
+ parse(content: string): Record<string, any>;
48
+ generate(_config: Record<string, any>, flags: any[], parsedArgs: any): string;
49
+ }
50
+ /**
51
+ * Built-in ENV configuration plugin (no external dependencies)
52
+ */
53
+ export declare class EnvConfigPlugin extends ConfigPlugin {
54
+ readonly supportedExtensions: string[];
55
+ readonly name = "env";
56
+ parse(content: string): Record<string, any>;
57
+ generate(_config: Record<string, any>, flags: any[], parsedArgs: any): string;
58
+ private getTypeString;
59
+ }
60
+ //# sourceMappingURL=ConfigPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"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G,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,GAAG,GAAG,MAAM;CA4B9E;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,YAAY;IAC/C,QAAQ,CAAC,mBAAmB,WAAY;IACxC,QAAQ,CAAC,IAAI,SAAS;IAEtB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IA0B3C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,GAAG,GAAG,MAAM;IAmC7E,OAAO,CAAC,aAAa;CAMtB"}
@@ -0,0 +1,72 @@
1
+ import type { IConfigPlugin } from './ConfigPlugin';
2
+ /**
3
+ * Registry for configuration plugins
4
+ * Manages available config format plugins and provides plugin lookup
5
+ */
6
+ export declare class ConfigPluginRegistry {
7
+ private plugins;
8
+ private extensionMap;
9
+ constructor();
10
+ /**
11
+ * Register a configuration plugin
12
+ */
13
+ registerPlugin(plugin: IConfigPlugin): void;
14
+ /**
15
+ * Get plugin by name
16
+ */
17
+ getPlugin(name: string): IConfigPlugin | undefined;
18
+ /**
19
+ * Get plugin by file extension
20
+ */
21
+ getPluginByExtension(extension: string): IConfigPlugin | undefined;
22
+ /**
23
+ * Check if a file extension is supported
24
+ */
25
+ isExtensionSupported(extension: string): boolean;
26
+ /**
27
+ * Get all registered plugin names
28
+ */
29
+ getRegisteredPlugins(): string[];
30
+ /**
31
+ * Get all supported extensions
32
+ */
33
+ getSupportedExtensions(): string[];
34
+ /**
35
+ * Unregister a plugin
36
+ */
37
+ unregisterPlugin(name: string): boolean;
38
+ /**
39
+ * Clear all plugins (useful for testing)
40
+ */
41
+ clear(): void;
42
+ /**
43
+ * Auto-register optional plugins if their dependencies are available
44
+ * This method attempts to load TOML and YAML plugins without throwing errors
45
+ */
46
+ autoRegisterOptionalPlugins(): void;
47
+ /**
48
+ * Async version of auto-register optional plugins with ESM support
49
+ * This method attempts to load TOML and YAML plugins without throwing errors
50
+ */
51
+ autoRegisterOptionalPluginsAsync(): Promise<void>;
52
+ }
53
+ /**
54
+ * Global plugin registry instance
55
+ * This can be used throughout the application
56
+ */
57
+ export declare const globalConfigPluginRegistry: ConfigPluginRegistry;
58
+ /**
59
+ * Convenience function to register optional plugins
60
+ * Call this once at application startup if you want TOML/YAML support
61
+ */
62
+ export declare function enableOptionalConfigPlugins(): void;
63
+ /**
64
+ * Async convenience function to register optional plugins with ESM support
65
+ * Call this once at application startup if you want TOML/YAML support in ESM environments
66
+ */
67
+ export declare function enableOptionalConfigPluginsAsync(): Promise<void>;
68
+ /**
69
+ * Convenience function to register only specific plugins
70
+ */
71
+ export declare function enableConfigPlugins(pluginNames: string[]): void;
72
+ //# sourceMappingURL=ConfigPluginRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigPluginRegistry.d.ts","sourceRoot":"","sources":["../../../src/config/plugins/ConfigPluginRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGpD;;;GAGG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,OAAO,CAAyC;IACxD,OAAO,CAAC,YAAY,CAAyC;;IAQ7D;;OAEG;IACI,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IASlD;;OAEG;IACI,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAIzD;;OAEG;IACI,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAIzE;;OAEG;IACI,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAIvD;;OAEG;IACI,oBAAoB,IAAI,MAAM,EAAE;IAIvC;;OAEG;IACI,sBAAsB,IAAI,MAAM,EAAE;IAIzC;;OAEG;IACI,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAiB9C;;OAEG;IACI,KAAK,IAAI,IAAI;IAKpB;;;OAGG;IACI,2BAA2B,IAAI,IAAI;IAwB1C;;;OAGG;IACU,gCAAgC,IAAI,OAAO,CAAC,IAAI,CAAC;CAuB/D;AAED;;;GAGG;AACH,eAAO,MAAM,0BAA0B,sBAA6B,CAAC;AAErE;;;GAGG;AACH,wBAAgB,2BAA2B,IAAI,IAAI,CAElD;AAED;;;GAGG;AACH,wBAAsB,gCAAgC,IAAI,OAAO,CAAC,IAAI,CAAC,CAEtE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,CA+B/D"}
@@ -0,0 +1,30 @@
1
+ import { ConfigPlugin } from './ConfigPlugin';
2
+ /**
3
+ * TOML configuration plugin (requires smol-toml dependency)
4
+ * This plugin is optional and only loaded when TOML support is needed
5
+ */
6
+ export declare class TomlConfigPlugin extends ConfigPlugin {
7
+ readonly supportedExtensions: string[];
8
+ readonly name = "toml";
9
+ private tomlModule;
10
+ constructor(tomlModule?: any);
11
+ private loadTomlModule;
12
+ parse(content: string): Record<string, any>;
13
+ generate(_config: Record<string, any>, flags: any[], parsedArgs: any): string;
14
+ /**
15
+ * Simple TOML parsing fallback for basic key-value pairs
16
+ */
17
+ private parseTomlSimple;
18
+ private getTypeString;
19
+ }
20
+ /**
21
+ * Factory function to create TOML plugin safely
22
+ * Returns null if TOML dependency is not available
23
+ */
24
+ export declare function createTomlPlugin(): TomlConfigPlugin | null;
25
+ /**
26
+ * Async factory function to create TOML plugin with ESM support
27
+ * Returns null if TOML dependency is not available
28
+ */
29
+ export declare function createTomlPluginAsync(): Promise<TomlConfigPlugin | null>;
30
+ //# sourceMappingURL=TomlConfigPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TomlConfigPlugin.d.ts","sourceRoot":"","sources":["../../../src/config/plugins/TomlConfigPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,YAAY;IAChD,QAAQ,CAAC,mBAAmB,WAAqB;IACjD,QAAQ,CAAC,IAAI,UAAU;IAEvB,OAAO,CAAC,UAAU,CAAa;gBAEnB,UAAU,CAAC,EAAE,GAAG;IAS5B,OAAO,CAAC,cAAc;IAkBtB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAiB3C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,GAAG,GAAG,MAAM;IAmD7E;;OAEG;IACH,OAAO,CAAC,eAAe;IA0BvB,OAAO,CAAC,aAAa;CAMtB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,gBAAgB,GAAG,IAAI,CAO1D;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAmB9E"}
@@ -0,0 +1,29 @@
1
+ import { ConfigPlugin } from './ConfigPlugin';
2
+ /**
3
+ * YAML configuration plugin (requires js-yaml dependency)
4
+ * This plugin is optional and only loaded when YAML support is needed
5
+ */
6
+ export declare class YamlConfigPlugin extends ConfigPlugin {
7
+ readonly supportedExtensions: string[];
8
+ readonly name = "yaml";
9
+ private yamlModule;
10
+ constructor(yamlModule?: any);
11
+ private loadYamlModule;
12
+ parse(content: string): Record<string, any>;
13
+ generate(_config: Record<string, any>, flags: any[], parsedArgs: any): string;
14
+ /**
15
+ * Simple YAML parsing fallback for basic key-value pairs
16
+ */
17
+ private parseYamlSimple;
18
+ }
19
+ /**
20
+ * Factory function to create YAML plugin safely
21
+ * Returns null if YAML dependency is not available
22
+ */
23
+ export declare function createYamlPlugin(): YamlConfigPlugin | null;
24
+ /**
25
+ * Async factory function to create YAML plugin with ESM support
26
+ * Returns null if YAML dependency is not available
27
+ */
28
+ export declare function createYamlPluginAsync(): Promise<YamlConfigPlugin | null>;
29
+ //# sourceMappingURL=YamlConfigPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"YamlConfigPlugin.d.ts","sourceRoot":"","sources":["../../../src/config/plugins/YamlConfigPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,YAAY;IAChD,QAAQ,CAAC,mBAAmB,WAAqB;IACjD,QAAQ,CAAC,IAAI,UAAU;IAEvB,OAAO,CAAC,UAAU,CAAa;gBAEnB,UAAU,CAAC,EAAE,GAAG;IAS5B,OAAO,CAAC,cAAc;IAgBtB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAiB3C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,GAAG,GAAG,MAAM;IA0C7E;;OAEG;IACH,OAAO,CAAC,eAAe;CAyBxB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,gBAAgB,GAAG,IAAI,CAO1D;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAmB9E"}
@@ -0,0 +1,5 @@
1
+ export { type IConfigPlugin, ConfigPlugin, JsonConfigPlugin, EnvConfigPlugin } from './ConfigPlugin';
2
+ export { ConfigPluginRegistry, globalConfigPluginRegistry, enableOptionalConfigPlugins, enableOptionalConfigPluginsAsync, enableConfigPlugins } from './ConfigPluginRegistry';
3
+ export { TomlConfigPlugin, createTomlPlugin, createTomlPluginAsync } from './TomlConfigPlugin';
4
+ export { YamlConfigPlugin, createYamlPlugin, createYamlPluginAsync } from './YamlConfigPlugin';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/plugins/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC3B,gCAAgC,EAChC,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC"}