@alcyone-labs/arg-parser 1.1.0 → 2.0.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.
- package/README.md +460 -1179
- package/dist/assets/.dxtignore.template +38 -0
- package/dist/assets/logo_1_small.jpg +0 -0
- package/dist/assets/tsdown.dxt.config.ts +37 -0
- package/dist/index.cjs +23702 -2315
- package/dist/index.cjs.map +1 -1
- package/dist/index.min.mjs +16360 -1725
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +23694 -2315
- package/dist/index.mjs.map +1 -1
- package/dist/src/config/ConfigurationManager.d.ts +74 -0
- package/dist/src/config/ConfigurationManager.d.ts.map +1 -0
- package/dist/src/config/plugins/ConfigPlugin.d.ts +60 -0
- package/dist/src/config/plugins/ConfigPlugin.d.ts.map +1 -0
- package/dist/src/config/plugins/ConfigPluginRegistry.d.ts +72 -0
- package/dist/src/config/plugins/ConfigPluginRegistry.d.ts.map +1 -0
- package/dist/src/config/plugins/TomlConfigPlugin.d.ts +30 -0
- package/dist/src/config/plugins/TomlConfigPlugin.d.ts.map +1 -0
- package/dist/src/config/plugins/YamlConfigPlugin.d.ts +29 -0
- package/dist/src/config/plugins/YamlConfigPlugin.d.ts.map +1 -0
- package/dist/src/config/plugins/index.d.ts +5 -0
- package/dist/src/config/plugins/index.d.ts.map +1 -0
- package/dist/src/core/ArgParser.d.ts +332 -0
- package/dist/src/core/ArgParser.d.ts.map +1 -0
- package/dist/src/{ArgParserBase.d.ts → core/ArgParserBase.d.ts} +84 -3
- package/dist/src/core/ArgParserBase.d.ts.map +1 -0
- package/dist/src/core/FlagManager.d.ts.map +1 -0
- package/dist/src/{types.d.ts → core/types.d.ts} +40 -0
- package/dist/src/core/types.d.ts.map +1 -0
- package/dist/src/dxt/DxtGenerator.d.ts +115 -0
- package/dist/src/dxt/DxtGenerator.d.ts.map +1 -0
- package/dist/src/index.d.ts +10 -6
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/mcp/ArgParserMcp.d.ts +21 -0
- package/dist/src/mcp/ArgParserMcp.d.ts.map +1 -0
- package/dist/src/mcp/mcp-integration.d.ts +83 -0
- package/dist/src/mcp/mcp-integration.d.ts.map +1 -0
- package/dist/src/mcp/mcp-notifications.d.ts +138 -0
- package/dist/src/mcp/mcp-notifications.d.ts.map +1 -0
- package/dist/src/mcp/mcp-prompts.d.ts +132 -0
- package/dist/src/mcp/mcp-prompts.d.ts.map +1 -0
- package/dist/src/mcp/mcp-resources.d.ts +133 -0
- package/dist/src/mcp/mcp-resources.d.ts.map +1 -0
- package/dist/src/testing/fuzzy-test-cli.d.ts +5 -0
- package/dist/src/testing/fuzzy-test-cli.d.ts.map +1 -0
- package/dist/src/{fuzzy-tester.d.ts → testing/fuzzy-tester.d.ts} +1 -1
- package/dist/src/testing/fuzzy-tester.d.ts.map +1 -0
- package/package.json +51 -17
- package/dist/examples/fuzzy-demo.d.ts +0 -8
- package/dist/examples/fuzzy-demo.d.ts.map +0 -1
- package/dist/examples/fuzzy-test-example.d.ts +0 -8
- package/dist/examples/fuzzy-test-example.d.ts.map +0 -1
- package/dist/examples/fzf-search-cli.d.ts +0 -8
- package/dist/examples/fzf-search-cli.d.ts.map +0 -1
- package/dist/examples/getting-started.d.ts +0 -27
- package/dist/examples/getting-started.d.ts.map +0 -1
- package/dist/examples/mcp-preset-transports.d.ts +0 -19
- package/dist/examples/mcp-preset-transports.d.ts.map +0 -1
- package/dist/examples/simple-cli.d.ts +0 -26
- package/dist/examples/simple-cli.d.ts.map +0 -1
- package/dist/examples/v1.1.0-showcase.d.ts +0 -16
- package/dist/examples/v1.1.0-showcase.d.ts.map +0 -1
- package/dist/examples/with-env-example.d.ts +0 -3
- package/dist/examples/with-env-example.d.ts.map +0 -1
- package/dist/index-6G9StDO_.js +0 -6445
- package/dist/index-6G9StDO_.js.map +0 -1
- package/dist/index-CqU7Fj3C.cjs +0 -6444
- package/dist/index-CqU7Fj3C.cjs.map +0 -1
- package/dist/index-Dx_q1msW.js +0 -4682
- package/dist/index-Dx_q1msW.js.map +0 -1
- package/dist/src/ArgParser.d.ts +0 -156
- package/dist/src/ArgParser.d.ts.map +0 -1
- package/dist/src/ArgParserBase.d.ts.map +0 -1
- package/dist/src/FlagManager.d.ts.map +0 -1
- package/dist/src/fuzzy-test-cli.d.ts +0 -5
- package/dist/src/fuzzy-test-cli.d.ts.map +0 -1
- package/dist/src/fuzzy-tester.d.ts.map +0 -1
- package/dist/src/mcp-integration.d.ts +0 -31
- package/dist/src/mcp-integration.d.ts.map +0 -1
- package/dist/src/types.d.ts.map +0 -1
- package/dist/sse-B5Jf_YpG.cjs +0 -121
- package/dist/sse-B5Jf_YpG.cjs.map +0 -1
- package/dist/sse-BDL3h2Ll.js +0 -121
- package/dist/sse-BDL3h2Ll.js.map +0 -1
- package/dist/sse-DSjLfGFo.js +0 -107
- package/dist/sse-DSjLfGFo.js.map +0 -1
- package/dist/stdio-Cf19UQO7.js +0 -70
- package/dist/stdio-Cf19UQO7.js.map +0 -1
- package/dist/stdio-DESvSONI.cjs +0 -94
- package/dist/stdio-DESvSONI.cjs.map +0 -1
- package/dist/stdio-DLOResWr.js +0 -94
- package/dist/stdio-DLOResWr.js.map +0 -1
- package/dist/streamableHttp-DXIdDSbF.js +0 -342
- package/dist/streamableHttp-DXIdDSbF.js.map +0 -1
- package/dist/streamableHttp-DsXlAnqJ.cjs +0 -456
- package/dist/streamableHttp-DsXlAnqJ.cjs.map +0 -1
- package/dist/streamableHttp-Vd4Qsgko.js +0 -456
- package/dist/streamableHttp-Vd4Qsgko.js.map +0 -1
- package/dist/types-DSxPEImy.cjs +0 -943
- package/dist/types-DSxPEImy.cjs.map +0 -1
- package/dist/types-DdsPVLQ5.js +0 -846
- package/dist/types-DdsPVLQ5.js.map +0 -1
- package/dist/types-DpK81FWv.js +0 -944
- package/dist/types-DpK81FWv.js.map +0 -1
- /package/dist/src/{FlagManager.d.ts → core/FlagManager.d.ts} +0 -0
|
@@ -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,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EAAE,UAAU,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,MAAM;IAmCvF;;OAEG;IACI,kBAAkB,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,MAAM;IAavF;;OAEG;IACI,kBAAkB,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,MAAM;IAmCvF;;OAEG;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
|
+
{"version":3,"file":"ConfigPlugin.d.ts","sourceRoot":"","sources":["../../../../src/config/plugins/ConfigPlugin.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,QAAQ,CAAC,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAEvC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;;OAIG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE5C;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,G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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"}
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import { ArgParserBase, type IArgParserParams } from "./ArgParserBase";
|
|
2
|
+
import type { GenerateMcpToolsOptions, IMcpToolStructure } from "../mcp/mcp-integration";
|
|
3
|
+
import type { IHandlerContext, IFlag } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for a single MCP transport
|
|
6
|
+
*/
|
|
7
|
+
export type McpTransportConfig = {
|
|
8
|
+
type: "stdio" | "sse" | "streamable-http";
|
|
9
|
+
port?: number;
|
|
10
|
+
host?: string;
|
|
11
|
+
path?: string;
|
|
12
|
+
sessionIdGenerator?: () => string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Configuration options for MCP sub-command
|
|
16
|
+
*/
|
|
17
|
+
export type McpSubCommandOptions = {
|
|
18
|
+
/** Preset transport configurations to use when no CLI flags are provided */
|
|
19
|
+
defaultTransports?: McpTransportConfig[];
|
|
20
|
+
/** Single preset transport configuration (alternative to defaultTransports) */
|
|
21
|
+
defaultTransport?: McpTransportConfig;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Extended server information for DXT package generation
|
|
25
|
+
*/
|
|
26
|
+
export type DxtServerInfo = {
|
|
27
|
+
name: string;
|
|
28
|
+
version: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
/** Author information for DXT manifest */
|
|
31
|
+
author?: {
|
|
32
|
+
name: string;
|
|
33
|
+
email?: string;
|
|
34
|
+
url?: string;
|
|
35
|
+
};
|
|
36
|
+
/** Repository information for DXT manifest */
|
|
37
|
+
repository?: {
|
|
38
|
+
type: string;
|
|
39
|
+
url: string;
|
|
40
|
+
};
|
|
41
|
+
/** License identifier for DXT manifest */
|
|
42
|
+
license?: string;
|
|
43
|
+
/** Homepage URL for DXT manifest */
|
|
44
|
+
homepage?: string;
|
|
45
|
+
/** Documentation URL for DXT manifest */
|
|
46
|
+
documentation?: string;
|
|
47
|
+
/** Support/issues URL for DXT manifest */
|
|
48
|
+
support?: string;
|
|
49
|
+
/** Keywords for DXT manifest */
|
|
50
|
+
keywords?: string[];
|
|
51
|
+
/** Logo/icon for DXT manifest - can be a local file path or URL */
|
|
52
|
+
logo?: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* MCP server configuration options for withMcp() method
|
|
56
|
+
* This centralizes MCP server metadata that was previously scattered across addMcpSubCommand calls
|
|
57
|
+
*/
|
|
58
|
+
export type McpServerOptions = {
|
|
59
|
+
/** MCP server metadata */
|
|
60
|
+
serverInfo?: DxtServerInfo;
|
|
61
|
+
/** Default transport configurations for the MCP server */
|
|
62
|
+
defaultTransports?: McpTransportConfig[];
|
|
63
|
+
/** Single default transport configuration (alternative to defaultTransports) */
|
|
64
|
+
defaultTransport?: McpTransportConfig;
|
|
65
|
+
/** Tool generation options for the MCP server */
|
|
66
|
+
toolOptions?: GenerateMcpToolsOptions;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Combined options for withMcp() method
|
|
70
|
+
*/
|
|
71
|
+
export type WithMcpOptions<THandlerReturn = any> = IArgParserParams<THandlerReturn> & {
|
|
72
|
+
/** MCP-specific server configuration */
|
|
73
|
+
mcp?: McpServerOptions;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Configuration for an individual MCP tool (deprecated - use ToolConfig instead)
|
|
77
|
+
* @deprecated Use ToolConfig and addTool() instead. Will be removed in v2.0.
|
|
78
|
+
*/
|
|
79
|
+
export type McpToolConfig = {
|
|
80
|
+
/** Tool name (must be unique within the server) */
|
|
81
|
+
name: string;
|
|
82
|
+
/** Tool description */
|
|
83
|
+
description?: string;
|
|
84
|
+
/** Input schema for the tool (Zod schema) */
|
|
85
|
+
inputSchema?: any;
|
|
86
|
+
/** Output schema for the tool (Zod schema) */
|
|
87
|
+
outputSchema?: any;
|
|
88
|
+
/** Handler function for the tool */
|
|
89
|
+
handler: (args: any) => Promise<any> | any;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Configuration for a unified tool that works in both CLI and MCP modes
|
|
93
|
+
*/
|
|
94
|
+
export type ToolConfig = {
|
|
95
|
+
/** Tool name (CLI subcommand name & MCP tool name) */
|
|
96
|
+
name: string;
|
|
97
|
+
/** Tool description */
|
|
98
|
+
description?: string;
|
|
99
|
+
/** Flags for this tool (auto-converted to MCP schema) */
|
|
100
|
+
flags: readonly IFlag[];
|
|
101
|
+
/** Handler function for the tool */
|
|
102
|
+
handler: (ctx: IHandlerContext) => Promise<any> | any;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* ArgParser with Model Context Protocol (MCP) integration capabilities.
|
|
106
|
+
*
|
|
107
|
+
* This class adds MCP server functionality on top of the standard ArgParser,
|
|
108
|
+
* allowing CLI tools to be easily exposed as MCP tools with minimal boilerplate.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* const parser = new ArgParser({
|
|
113
|
+
* appName: "My CLI",
|
|
114
|
+
* appCommandName: "my-cli",
|
|
115
|
+
* handler: async (ctx) => ({ result: "success" })
|
|
116
|
+
* })
|
|
117
|
+
* .addFlags([...])
|
|
118
|
+
* .addMcpSubCommand("serve", {
|
|
119
|
+
* name: "my-cli-mcp-server",
|
|
120
|
+
* version: "1.0.0"
|
|
121
|
+
* });
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
export declare class ArgParser<THandlerReturn = any> extends ArgParserBase<THandlerReturn> {
|
|
125
|
+
#private;
|
|
126
|
+
/** Stored MCP server configuration from withMcp() */
|
|
127
|
+
private _mcpServerConfig?;
|
|
128
|
+
/** Registered MCP tools (deprecated) */
|
|
129
|
+
private _mcpTools;
|
|
130
|
+
/** Registered unified tools */
|
|
131
|
+
private _tools;
|
|
132
|
+
/**
|
|
133
|
+
* Get the stored MCP server configuration
|
|
134
|
+
* @returns MCP server configuration if set via withMcp(), undefined otherwise
|
|
135
|
+
*/
|
|
136
|
+
getMcpServerConfig(): McpServerOptions | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* Add a unified tool that works in both CLI and MCP modes
|
|
139
|
+
* In CLI mode, the tool becomes a subcommand with its own flags
|
|
140
|
+
* In MCP mode, the tool becomes an MCP tool with auto-generated schema
|
|
141
|
+
*
|
|
142
|
+
* @param toolConfig Configuration for the tool
|
|
143
|
+
* @returns This ArgParser instance for chaining
|
|
144
|
+
*/
|
|
145
|
+
addTool(toolConfig: ToolConfig): this;
|
|
146
|
+
/**
|
|
147
|
+
* Add an MCP tool to this parser (deprecated)
|
|
148
|
+
* @deprecated Use addTool() instead. This method will be removed in v2.0.
|
|
149
|
+
* @param toolConfig Configuration for the MCP tool
|
|
150
|
+
* @returns This ArgParser instance for chaining
|
|
151
|
+
*/
|
|
152
|
+
addMcpTool(toolConfig: McpToolConfig): this;
|
|
153
|
+
/**
|
|
154
|
+
* Get all registered unified tools
|
|
155
|
+
* @returns Map of tool names to tool configurations
|
|
156
|
+
*/
|
|
157
|
+
getTools(): Map<string, ToolConfig>;
|
|
158
|
+
/**
|
|
159
|
+
* Get all registered MCP tools (deprecated)
|
|
160
|
+
* @deprecated Use getTools() instead
|
|
161
|
+
* @returns Map of tool names to tool configurations
|
|
162
|
+
*/
|
|
163
|
+
getMcpTools(): Map<string, McpToolConfig>;
|
|
164
|
+
/**
|
|
165
|
+
* Get information about all available tools (unified, legacy MCP, and CLI-generated)
|
|
166
|
+
* @param options Optional configuration for MCP tool generation
|
|
167
|
+
* @returns Object with tool counts and names for debugging
|
|
168
|
+
*/
|
|
169
|
+
getToolInfo(options?: GenerateMcpToolsOptions): {
|
|
170
|
+
unifiedTools: string[];
|
|
171
|
+
legacyMcpTools: string[];
|
|
172
|
+
cliTools: string[];
|
|
173
|
+
totalTools: number;
|
|
174
|
+
duplicates: string[];
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Get information about all available MCP tools (legacy method)
|
|
178
|
+
* @deprecated Use getToolInfo() instead
|
|
179
|
+
* @param options Optional configuration for MCP tool generation
|
|
180
|
+
* @returns Object with tool counts and names for debugging
|
|
181
|
+
*/
|
|
182
|
+
getMcpToolInfo(options?: GenerateMcpToolsOptions): {
|
|
183
|
+
manualTools: string[];
|
|
184
|
+
cliTools: string[];
|
|
185
|
+
totalTools: number;
|
|
186
|
+
duplicates: string[];
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Validate that all tools are properly registered and routable
|
|
190
|
+
* @returns Validation results
|
|
191
|
+
*/
|
|
192
|
+
validateToolRouting(): {
|
|
193
|
+
isValid: boolean;
|
|
194
|
+
issues: string[];
|
|
195
|
+
cliSubcommands: string[];
|
|
196
|
+
mcpTools: string[];
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Test tool routing by simulating a tool call
|
|
200
|
+
* This is useful for debugging and ensuring tools are properly registered
|
|
201
|
+
* @param toolName Name of the tool to test
|
|
202
|
+
* @param args Arguments to pass to the tool
|
|
203
|
+
* @returns Promise with the tool execution result or error
|
|
204
|
+
*/
|
|
205
|
+
testMcpToolRouting(toolName: string, args?: any): Promise<{
|
|
206
|
+
success: boolean;
|
|
207
|
+
result?: any;
|
|
208
|
+
error?: string;
|
|
209
|
+
executionTime?: number;
|
|
210
|
+
}>;
|
|
211
|
+
/**
|
|
212
|
+
* Generate MCP tools from this ArgParser instance
|
|
213
|
+
* @param options Optional configuration for MCP tool generation
|
|
214
|
+
* @returns Array of MCP tool structures ready for server registration
|
|
215
|
+
*/
|
|
216
|
+
toMcpTools(options?: GenerateMcpToolsOptions): IMcpToolStructure[];
|
|
217
|
+
/**
|
|
218
|
+
* Create an MCP server with tools generated from this ArgParser
|
|
219
|
+
* @param serverInfo Server configuration
|
|
220
|
+
* @param toolOptions Optional MCP tool generation options
|
|
221
|
+
* @returns Configured MCP server instance
|
|
222
|
+
*/
|
|
223
|
+
createMcpServer(serverInfo: DxtServerInfo, toolOptions?: GenerateMcpToolsOptions): Promise<any>;
|
|
224
|
+
/**
|
|
225
|
+
* Set up change notifications for the MCP server
|
|
226
|
+
* @param _server The MCP server instance (unused for now, but reserved for future client connection tracking)
|
|
227
|
+
*/
|
|
228
|
+
private setupMcpChangeNotifications;
|
|
229
|
+
/**
|
|
230
|
+
* Start an MCP server using stdio transport
|
|
231
|
+
* @param serverInfo Server configuration
|
|
232
|
+
* @param toolOptions Optional MCP tool generation options
|
|
233
|
+
* @returns Promise that resolves when server is connected
|
|
234
|
+
*/
|
|
235
|
+
startMcpServer(serverInfo: {
|
|
236
|
+
name: string;
|
|
237
|
+
version: string;
|
|
238
|
+
description?: string;
|
|
239
|
+
}, toolOptions?: GenerateMcpToolsOptions): Promise<void>;
|
|
240
|
+
/**
|
|
241
|
+
* Start an MCP server with multiple transport types simultaneously
|
|
242
|
+
* @param serverInfo Server configuration
|
|
243
|
+
* @param transports Array of transport configurations
|
|
244
|
+
* @param toolOptions Optional MCP tool generation options
|
|
245
|
+
* @returns Promise that resolves when all servers are started
|
|
246
|
+
*/
|
|
247
|
+
startMcpServerWithMultipleTransports(serverInfo: {
|
|
248
|
+
name: string;
|
|
249
|
+
version: string;
|
|
250
|
+
description?: string;
|
|
251
|
+
}, transports: Array<{
|
|
252
|
+
type: "stdio" | "sse" | "streamable-http";
|
|
253
|
+
port?: number;
|
|
254
|
+
host?: string;
|
|
255
|
+
path?: string;
|
|
256
|
+
sessionIdGenerator?: () => string;
|
|
257
|
+
}>, toolOptions?: GenerateMcpToolsOptions): Promise<void>;
|
|
258
|
+
/**
|
|
259
|
+
* Start an MCP server with a specific transport type
|
|
260
|
+
* @param serverInfo Server configuration
|
|
261
|
+
* @param transportType Type of transport to use
|
|
262
|
+
* @param transportOptions Transport-specific options
|
|
263
|
+
* @param toolOptions Optional MCP tool generation options
|
|
264
|
+
* @returns Promise that resolves when server is connected
|
|
265
|
+
*/
|
|
266
|
+
startMcpServerWithTransport(serverInfo: {
|
|
267
|
+
name: string;
|
|
268
|
+
version: string;
|
|
269
|
+
description?: string;
|
|
270
|
+
}, transportType: "stdio" | "sse" | "streamable-http", transportOptions?: {
|
|
271
|
+
port?: number;
|
|
272
|
+
host?: string;
|
|
273
|
+
path?: string;
|
|
274
|
+
sessionIdGenerator?: () => string;
|
|
275
|
+
}, toolOptions?: GenerateMcpToolsOptions): Promise<void>;
|
|
276
|
+
parse(processArgs: string[], options?: any): Promise<any>;
|
|
277
|
+
/**
|
|
278
|
+
* CLI-friendly parse method that automatically handles ParseResult objects
|
|
279
|
+
* When autoExit is false, this method will call process.exit() based on ParseResult
|
|
280
|
+
* This ensures backward compatibility for CLI applications
|
|
281
|
+
*/
|
|
282
|
+
parseForCli(processArgs: string[], options?: any): any;
|
|
283
|
+
/**
|
|
284
|
+
* Alias for parse() method for backward compatibility
|
|
285
|
+
* Since parse() is already async, this just calls parse()
|
|
286
|
+
*
|
|
287
|
+
* @deprecated Use parse() instead. This method will be removed in a future version.
|
|
288
|
+
*/
|
|
289
|
+
parseAsync(processArgs: string[], options?: any): Promise<any>;
|
|
290
|
+
/**
|
|
291
|
+
* Add an MCP sub-command that starts an MCP server exposing this parser's functionality
|
|
292
|
+
* @param subCommandName Name of the sub-command (default: "mcp-server")
|
|
293
|
+
* @param serverInfo Server configuration (supports extended DXT fields)
|
|
294
|
+
* @param options Optional configuration including preset transports and tool options
|
|
295
|
+
* @returns This ArgParserWithMcp instance for chaining
|
|
296
|
+
* @deprecated Use withMcp() to configure server metadata and --s-mcp-serve system flag instead. This method will be removed in v2.0.
|
|
297
|
+
*/
|
|
298
|
+
addMcpSubCommand(subCommandName: string | undefined, serverInfo: DxtServerInfo, options?: McpSubCommandOptions & {
|
|
299
|
+
toolOptions?: GenerateMcpToolsOptions;
|
|
300
|
+
}): this;
|
|
301
|
+
/**
|
|
302
|
+
* Add an MCP sub-command that starts an MCP server exposing this parser's functionality
|
|
303
|
+
* @param subCommandName Name of the sub-command (default: "mcp-server")
|
|
304
|
+
* @param serverInfo Server configuration (supports extended DXT fields)
|
|
305
|
+
* @param toolOptions Optional MCP tool generation options (backward compatibility)
|
|
306
|
+
* @returns This ArgParserWithMcp instance for chaining
|
|
307
|
+
* @deprecated Use withMcp() to configure server metadata and --s-mcp-serve system flag instead. This method will be removed in v2.0.
|
|
308
|
+
*/
|
|
309
|
+
addMcpSubCommand(subCommandName: string | undefined, serverInfo: DxtServerInfo, toolOptions?: GenerateMcpToolsOptions): this;
|
|
310
|
+
/**
|
|
311
|
+
* Factory method to create an ArgParser instance with MCP capabilities
|
|
312
|
+
* This provides a clean API for users who want MCP functionality from the start
|
|
313
|
+
* Automatically sets handleErrors: false for MCP compatibility
|
|
314
|
+
*
|
|
315
|
+
* @param options Combined ArgParser and MCP server configuration options
|
|
316
|
+
* @param initialFlags Optional array of initial flags to add
|
|
317
|
+
* @returns ArgParser instance with MCP capabilities and stored server metadata
|
|
318
|
+
*/
|
|
319
|
+
static withMcp<T = any>(options?: WithMcpOptions<T>, initialFlags?: readonly IFlag[]): ArgParser<T>;
|
|
320
|
+
/**
|
|
321
|
+
* Create an ArgParser instance optimized for CLI usage
|
|
322
|
+
* This sets autoExit: true by default for traditional CLI behavior
|
|
323
|
+
*/
|
|
324
|
+
static forCli<T = any>(options?: ConstructorParameters<typeof ArgParserBase>[0], initialFlags?: ConstructorParameters<typeof ArgParserBase>[1]): ArgParser<T>;
|
|
325
|
+
/**
|
|
326
|
+
* Create an ArgParser instance optimized for library usage
|
|
327
|
+
* This sets autoExit: false by default for programmatic control
|
|
328
|
+
*/
|
|
329
|
+
static forLibrary<T = any>(options?: ConstructorParameters<typeof ArgParserBase>[0], initialFlags?: ConstructorParameters<typeof ArgParserBase>[1]): ArgParser<T>;
|
|
330
|
+
static fromArgParser<T = any>(parser: ArgParserBase<T>): ArgParser<T>;
|
|
331
|
+
}
|
|
332
|
+
//# sourceMappingURL=ArgParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArgParser.d.ts","sourceRoot":"","sources":["../../../src/core/ArgParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAOvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAA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