@alcyone-labs/arg-parser 2.14.2 → 3.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 +20 -127
- package/dist/config/plugins/index.d.ts +36 -4
- package/dist/config/plugins/index.d.ts.map +1 -1
- package/dist/core/ArgParser.d.ts +124 -464
- package/dist/core/ArgParser.d.ts.map +1 -1
- package/dist/core/FlagManager.d.ts +36 -136
- package/dist/core/FlagManager.d.ts.map +1 -1
- package/dist/core/PromptManager.d.ts +42 -91
- package/dist/core/PromptManager.d.ts.map +1 -1
- package/dist/core/log-path-utils.d.ts +28 -36
- package/dist/core/log-path-utils.d.ts.map +1 -1
- package/dist/core/types.d.ts +83 -592
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.cjs +599 -9658
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +26 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.min.mjs +615 -8224
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +581 -8881
- package/dist/index.mjs.map +1 -1
- package/dist/plugin/types.d.ts +121 -0
- package/dist/plugin/types.d.ts.map +1 -0
- package/dist/utils/debug-utils.d.ts +4 -26
- package/dist/utils/debug-utils.d.ts.map +1 -1
- package/package.json +12 -73
- package/dist/assets/.dxtignore.template +0 -37
- package/dist/assets/logo_1_small.jpg +0 -0
- package/dist/config/ConfigurationManager.d.ts +0 -82
- package/dist/config/ConfigurationManager.d.ts.map +0 -1
- package/dist/config/plugins/ConfigPlugin.d.ts +0 -60
- package/dist/config/plugins/ConfigPlugin.d.ts.map +0 -1
- package/dist/config/plugins/ConfigPluginRegistry.d.ts +0 -72
- package/dist/config/plugins/ConfigPluginRegistry.d.ts.map +0 -1
- package/dist/config/plugins/TomlConfigPlugin.d.ts +0 -30
- package/dist/config/plugins/TomlConfigPlugin.d.ts.map +0 -1
- package/dist/config/plugins/YamlConfigPlugin.d.ts +0 -29
- package/dist/config/plugins/YamlConfigPlugin.d.ts.map +0 -1
- package/dist/core/ArgParserBase.d.ts +0 -319
- package/dist/core/ArgParserBase.d.ts.map +0 -1
- package/dist/core/dxt-path-resolver.d.ts +0 -100
- package/dist/core/dxt-path-resolver.d.ts.map +0 -1
- package/dist/dxt/DxtGenerator-testUtils.d.ts +0 -22
- package/dist/dxt/DxtGenerator-testUtils.d.ts.map +0 -1
- package/dist/dxt/DxtGenerator.d.ts +0 -120
- package/dist/dxt/DxtGenerator.d.ts.map +0 -1
- package/dist/mcp/ArgParserMcp.d.ts +0 -21
- package/dist/mcp/ArgParserMcp.d.ts.map +0 -1
- package/dist/mcp/mcp-integration.d.ts +0 -86
- package/dist/mcp/mcp-integration.d.ts.map +0 -1
- package/dist/mcp/mcp-lifecycle.d.ts +0 -163
- package/dist/mcp/mcp-lifecycle.d.ts.map +0 -1
- package/dist/mcp/mcp-notifications.d.ts +0 -132
- package/dist/mcp/mcp-notifications.d.ts.map +0 -1
- package/dist/mcp/mcp-prompts.d.ts +0 -132
- package/dist/mcp/mcp-prompts.d.ts.map +0 -1
- package/dist/mcp/mcp-protocol-versions.d.ts +0 -150
- package/dist/mcp/mcp-protocol-versions.d.ts.map +0 -1
- package/dist/mcp/mcp-resources.d.ts +0 -133
- package/dist/mcp/mcp-resources.d.ts.map +0 -1
- package/dist/mcp/mcp-utils.d.ts +0 -20
- package/dist/mcp/mcp-utils.d.ts.map +0 -1
- package/dist/mcp/zod-compatibility.d.ts +0 -74
- package/dist/mcp/zod-compatibility.d.ts.map +0 -1
- package/dist/testing/fuzzy-test-cli.d.ts +0 -5
- package/dist/testing/fuzzy-test-cli.d.ts.map +0 -1
- package/dist/testing/fuzzy-tester.d.ts +0 -101
- package/dist/testing/fuzzy-tester.d.ts.map +0 -1
- package/dist/tui/index.d.ts +0 -281
- package/dist/tui/types.d.ts +0 -60
- package/dist/tui/types.d.ts.map +0 -1
- package/dist/tui.cjs +0 -1060
- package/dist/tui.cjs.map +0 -1
- package/dist/tui.mjs +0 -967
- package/dist/tui.mjs.map +0 -1
package/dist/core/ArgParser.d.ts
CHANGED
|
@@ -1,525 +1,185 @@
|
|
|
1
|
-
import type { Application as ExpressApplication } from "express";
|
|
2
|
-
import { type McpLoggerOptions } from "@alcyone-labs/simple-mcp-logger";
|
|
3
|
-
import type { GenerateMcpToolsOptions, IMcpToolStructure } from "../mcp/mcp-integration";
|
|
4
|
-
import type { McpLifecycleEvents } from "../mcp/mcp-lifecycle";
|
|
5
|
-
import { ArgParserBase, type IArgParserParams } from "./ArgParserBase";
|
|
6
|
-
import { type LogPath } from "./log-path-utils";
|
|
7
|
-
import { type IMcpServerMethods } from "./types";
|
|
8
|
-
import type { IFlag, IHandlerContext, OutputSchemaConfig } from "./types";
|
|
9
|
-
export type { Application as ExpressApplication } from "express";
|
|
10
1
|
/**
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
methods?: string[];
|
|
16
|
-
headers?: string[];
|
|
17
|
-
exposedHeaders?: string[];
|
|
18
|
-
credentials?: boolean;
|
|
19
|
-
maxAge?: number;
|
|
20
|
-
};
|
|
21
|
-
export type JwtVerifyOptions = {
|
|
22
|
-
algorithms?: ("HS256" | "RS256")[];
|
|
23
|
-
secret?: string;
|
|
24
|
-
publicKey?: string;
|
|
25
|
-
getPublicKey?: (header: Record<string, unknown>, payload: Record<string, unknown>) => Promise<string> | string;
|
|
26
|
-
audience?: string | string[];
|
|
27
|
-
issuer?: string | string[];
|
|
28
|
-
clockToleranceSec?: number;
|
|
29
|
-
};
|
|
30
|
-
export type AuthOptions = {
|
|
31
|
-
required?: boolean;
|
|
32
|
-
scheme?: "bearer" | "jwt";
|
|
33
|
-
allowedTokens?: string[];
|
|
34
|
-
validator?: (req: any, token: string | undefined) => boolean | Promise<boolean>;
|
|
35
|
-
jwt?: JwtVerifyOptions;
|
|
36
|
-
publicPaths?: string[];
|
|
37
|
-
protectedPaths?: string[];
|
|
38
|
-
customMiddleware?: (req: any, res: any, next: any) => any;
|
|
39
|
-
};
|
|
40
|
-
export type McpTransportConfig = {
|
|
41
|
-
type: "stdio" | "sse" | "streamable-http";
|
|
42
|
-
port?: number;
|
|
43
|
-
host?: string;
|
|
44
|
-
path?: string;
|
|
45
|
-
sessionIdGenerator?: () => string;
|
|
46
|
-
cors?: CorsOptions;
|
|
47
|
-
auth?: AuthOptions;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Configuration options for MCP sub-command
|
|
51
|
-
*/
|
|
52
|
-
export type McpSubCommandOptions = {
|
|
53
|
-
/** Preset transport configurations to use when no CLI flags are provided */
|
|
54
|
-
defaultTransports?: McpTransportConfig[];
|
|
55
|
-
/** Single preset transport configuration (alternative to defaultTransports) */
|
|
56
|
-
defaultTransport?: McpTransportConfig;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Extended server information for DXT package generation and MCP server metadata
|
|
60
|
-
* This type includes logo support for MCP servers and DXT packages
|
|
61
|
-
*/
|
|
62
|
-
export type DxtServerInfo = {
|
|
63
|
-
name: string;
|
|
64
|
-
version: string;
|
|
65
|
-
description?: string;
|
|
66
|
-
/** Author information for DXT manifest */
|
|
67
|
-
author?: {
|
|
68
|
-
name: string;
|
|
69
|
-
email?: string;
|
|
70
|
-
url?: string;
|
|
71
|
-
};
|
|
72
|
-
/** Repository information for DXT manifest */
|
|
73
|
-
repository?: {
|
|
74
|
-
type: string;
|
|
75
|
-
url: string;
|
|
76
|
-
};
|
|
77
|
-
/** License identifier for DXT manifest */
|
|
78
|
-
license?: string;
|
|
79
|
-
/** Homepage URL for DXT manifest */
|
|
80
|
-
homepage?: string;
|
|
81
|
-
/** Documentation URL for DXT manifest */
|
|
82
|
-
documentation?: string;
|
|
83
|
-
/** Support/issues URL for DXT manifest */
|
|
84
|
-
support?: string;
|
|
85
|
-
/** Keywords for DXT manifest */
|
|
86
|
-
keywords?: string[];
|
|
87
|
-
/**
|
|
88
|
-
* Logo/icon for DXT manifest and MCP server - can be a local file path or URL
|
|
89
|
-
* This is where logo support is provided for MCP-enabled ArgParser instances
|
|
90
|
-
*/
|
|
91
|
-
logo?: string;
|
|
92
|
-
};
|
|
93
|
-
/**
|
|
94
|
-
* Copy entry for DXT package bundling, compatible with TSDown's copy options
|
|
95
|
-
*/
|
|
96
|
-
export type DxtCopyEntry = {
|
|
97
|
-
from: string;
|
|
98
|
-
to: string;
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* Copy options for DXT package bundling, compatible with TSDown's copy options
|
|
102
|
-
* @example
|
|
103
|
-
* ```ts
|
|
104
|
-
* [
|
|
105
|
-
* 'migrations',
|
|
106
|
-
* { from: 'migrations', to: 'migrations' },
|
|
107
|
-
* { from: 'config/default.json', to: 'config/default.json' }
|
|
108
|
-
* ]
|
|
109
|
-
* ```
|
|
110
|
-
*/
|
|
111
|
-
export type DxtCopyOptions = Array<string | DxtCopyEntry>;
|
|
112
|
-
/**
|
|
113
|
-
* DXT-specific configuration options
|
|
114
|
-
*/
|
|
115
|
-
export type DxtOptions = {
|
|
116
|
-
/**
|
|
117
|
-
* Additional files and directories to include in the DXT package.
|
|
118
|
-
* Paths are relative to the project root (where package.json/tsconfig.json are located).
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* ```ts
|
|
122
|
-
* include: [
|
|
123
|
-
* 'migrations', // Copy entire migrations folder
|
|
124
|
-
* { from: 'config/prod.json', to: 'config.json' }, // Copy and rename file
|
|
125
|
-
* 'assets/logo.png' // Copy specific file
|
|
126
|
-
* ]
|
|
127
|
-
* ```
|
|
128
|
-
*/
|
|
129
|
-
include?: DxtCopyOptions;
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* MCP server configuration options for withMcp() method
|
|
133
|
-
* This centralizes MCP server metadata that was previously scattered across addMcpSubCommand calls
|
|
134
|
-
*/
|
|
135
|
-
export type HttpServerOptions = {
|
|
136
|
-
configureExpress?: (app: ExpressApplication) => void;
|
|
137
|
-
};
|
|
138
|
-
export type McpServerOptions = {
|
|
139
|
-
/** MCP server metadata */
|
|
140
|
-
serverInfo?: DxtServerInfo;
|
|
141
|
-
/** Default transport configurations for the MCP server */
|
|
142
|
-
defaultTransports?: McpTransportConfig[];
|
|
143
|
-
/** Single default transport configuration (alternative to defaultTransports) */
|
|
144
|
-
defaultTransport?: McpTransportConfig;
|
|
145
|
-
/** Tool generation options for the MCP server */
|
|
146
|
-
toolOptions?: GenerateMcpToolsOptions;
|
|
147
|
-
/**
|
|
148
|
-
* Custom log file path for MCP server logs (default: "./logs/mcp.log" relative to entry point)
|
|
149
|
-
*
|
|
150
|
-
* @deprecated Use 'log' property instead for more comprehensive logging configuration
|
|
151
|
-
*
|
|
152
|
-
* Can be:
|
|
153
|
-
* - Simple string: "./logs/app.log" (relative to entry point)
|
|
154
|
-
* - Absolute path: "/tmp/app.log"
|
|
155
|
-
* - Explicit cwd: "cwd:./logs/app.log" (relative to process.cwd())
|
|
156
|
-
* - Config object: { path: "./logs/app.log", relativeTo: "entry" | "cwd" | "absolute" }
|
|
157
|
-
*/
|
|
158
|
-
logPath?: LogPath;
|
|
159
|
-
/**
|
|
160
|
-
* MCP logger configuration options
|
|
161
|
-
*
|
|
162
|
-
* Can be:
|
|
163
|
-
* - Simple string: "./logs/app.log" (equivalent to logPath for backward compatibility)
|
|
164
|
-
* - Full options object: { level: "debug", logToFile: "./logs/app.log", prefix: "MyServer" }
|
|
165
|
-
*
|
|
166
|
-
* When both 'log' and 'logPath' are specified, they are merged intelligently:
|
|
167
|
-
* - 'log' provides logger options (level, prefix, mcpMode)
|
|
168
|
-
* - 'logPath' provides flexible path resolution (relativeTo, basePath)
|
|
169
|
-
* - If 'log' has logToFile, 'logPath' still takes precedence for path resolution
|
|
170
|
-
*/
|
|
171
|
-
log?: string | McpLoggerOptions;
|
|
172
|
-
/**
|
|
173
|
-
* Lifecycle event handlers for MCP server operations
|
|
174
|
-
* These provide hooks for initialization, cleanup, and other lifecycle events
|
|
175
|
-
*/
|
|
176
|
-
lifecycle?: McpLifecycleEvents;
|
|
177
|
-
/** DXT package configuration options */
|
|
178
|
-
dxt?: DxtOptions;
|
|
179
|
-
/** Optional HTTP server configuration hooks */
|
|
180
|
-
httpServer?: HttpServerOptions;
|
|
181
|
-
};
|
|
182
|
-
/**
|
|
183
|
-
* Combined options for withMcp() method
|
|
2
|
+
* Core ArgParser implementation
|
|
3
|
+
*
|
|
4
|
+
* This is the main ArgParser class with full CLI parsing capabilities.
|
|
5
|
+
* It has NO dependencies on MCP, DXT, or TUI - those are provided by plugins.
|
|
184
6
|
*/
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
mcp?: McpServerOptions;
|
|
188
|
-
};
|
|
7
|
+
import type { IArgParserPlugin } from "../plugin/types";
|
|
8
|
+
import type { IFlag, IHandlerContext, ISubCommand, ProcessedFlag, PromptWhen, TFlagInheritance } from "./types";
|
|
189
9
|
/**
|
|
190
|
-
*
|
|
191
|
-
* This provides a clearer name for WithMcpOptions
|
|
10
|
+
* Error thrown by ArgParser
|
|
192
11
|
*/
|
|
193
|
-
export
|
|
12
|
+
export declare class ArgParserError extends Error {
|
|
13
|
+
cmdChain: string[];
|
|
14
|
+
commandChain: string[];
|
|
15
|
+
constructor(message: string, cmdChain?: string[]);
|
|
16
|
+
}
|
|
194
17
|
/**
|
|
195
|
-
*
|
|
196
|
-
* @deprecated Use ToolConfig and addTool() instead. Will be removed in v2.0.
|
|
18
|
+
* Parameters for creating an ArgParser
|
|
197
19
|
*/
|
|
198
|
-
export
|
|
199
|
-
/**
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
name: string;
|
|
205
|
-
/** Tool description */
|
|
20
|
+
export interface IArgParserParams<THandlerReturn = any> {
|
|
21
|
+
/** Display name of the application */
|
|
22
|
+
appName?: string;
|
|
23
|
+
/** Command name for help text */
|
|
24
|
+
appCommandName?: string;
|
|
25
|
+
/** Description of the application */
|
|
206
26
|
description?: string;
|
|
207
|
-
/**
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
|
|
213
|
-
|
|
27
|
+
/** Handler function */
|
|
28
|
+
handler?: (ctx: IHandlerContext<any, any>) => THandlerReturn | Promise<THandlerReturn>;
|
|
29
|
+
/** Subcommands */
|
|
30
|
+
subCommands?: ISubCommand[];
|
|
31
|
+
/** Extra newline between flag groups in help */
|
|
32
|
+
extraNewLine?: boolean;
|
|
33
|
+
/** Wrap help text at this width */
|
|
34
|
+
wrapAtWidth?: number;
|
|
35
|
+
/** Width of blank space in help */
|
|
36
|
+
blankSpaceWidth?: number;
|
|
37
|
+
/** Character for mandatory flags */
|
|
38
|
+
mandatoryCharacter?: string;
|
|
39
|
+
/** Throw error for duplicate flags */
|
|
40
|
+
throwForDuplicateFlags?: boolean;
|
|
41
|
+
/** Handle errors automatically */
|
|
42
|
+
handleErrors?: boolean;
|
|
43
|
+
/** Auto exit on parse result */
|
|
44
|
+
autoExit?: boolean;
|
|
45
|
+
/** Trigger auto-help if no handler */
|
|
46
|
+
triggerAutoHelpIfNoHandler?: boolean;
|
|
47
|
+
/** Flag inheritance behavior */
|
|
48
|
+
inheritParentFlags?: TFlagInheritance;
|
|
49
|
+
/** When to trigger interactive prompts */
|
|
50
|
+
promptWhen?: PromptWhen;
|
|
51
|
+
/** Cancel callback for prompts */
|
|
52
|
+
onCancel?: (ctx: IHandlerContext) => void | Promise<void>;
|
|
53
|
+
}
|
|
214
54
|
/**
|
|
215
|
-
*
|
|
55
|
+
* Parse options
|
|
216
56
|
*/
|
|
217
|
-
export
|
|
218
|
-
/**
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
|
|
232
|
-
}
|
|
57
|
+
export interface IParseOptions {
|
|
58
|
+
/** Skip help handling */
|
|
59
|
+
skipHelpHandling?: boolean;
|
|
60
|
+
/** Skip handler execution */
|
|
61
|
+
skipHandlers?: boolean;
|
|
62
|
+
/** Await async handlers */
|
|
63
|
+
deep?: boolean;
|
|
64
|
+
/** MCP mode flag */
|
|
65
|
+
isMcp?: boolean;
|
|
66
|
+
/** Dynamic help preload */
|
|
67
|
+
dynamicHelpPreload?: boolean;
|
|
68
|
+
/** Auto execute */
|
|
69
|
+
autoExecute?: boolean;
|
|
70
|
+
/** Import meta URL */
|
|
71
|
+
importMetaUrl?: string;
|
|
72
|
+
}
|
|
233
73
|
/**
|
|
234
|
-
* ArgParser
|
|
74
|
+
* Core ArgParser class
|
|
235
75
|
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
* appName: "My CLI",
|
|
243
|
-
* appCommandName: "my-cli",
|
|
244
|
-
* handler: async (ctx) => ({ result: "success" })
|
|
245
|
-
* })
|
|
246
|
-
* .addFlags([...])
|
|
247
|
-
* .addMcpSubCommand("serve", {
|
|
248
|
-
* name: "my-cli-mcp-server",
|
|
249
|
-
* version: "1.0.0"
|
|
250
|
-
* });
|
|
251
|
-
* ```
|
|
76
|
+
* Provides complete CLI argument parsing with support for:
|
|
77
|
+
* - Flags (with types, validation, defaults)
|
|
78
|
+
* - Subcommands
|
|
79
|
+
* - Interactive prompts
|
|
80
|
+
* - Help generation
|
|
81
|
+
* - Plugin system
|
|
252
82
|
*/
|
|
253
|
-
export declare class ArgParser<THandlerReturn = any>
|
|
83
|
+
export declare class ArgParser<THandlerReturn = any> {
|
|
254
84
|
#private;
|
|
255
|
-
|
|
256
|
-
private _mcpServerConfig?;
|
|
257
|
-
/** Registered MCP tools (deprecated) */
|
|
258
|
-
private _mcpTools;
|
|
259
|
-
/** Registered unified tools */
|
|
260
|
-
private _tools;
|
|
261
|
-
/** Output schema management */
|
|
262
|
-
private _defaultOutputSchema?;
|
|
263
|
-
private _outputSchemaMap;
|
|
264
|
-
private _autoGenerateOutputSchema?;
|
|
265
|
-
/** MCP version for output schema compatibility */
|
|
266
|
-
private _mcpProtocolVersion;
|
|
267
|
-
/**
|
|
268
|
-
* Get the stored MCP server configuration
|
|
269
|
-
* @returns MCP server configuration if set via withMcp(), undefined otherwise
|
|
270
|
-
*/
|
|
271
|
-
getMcpServerConfig(): McpServerOptions | undefined;
|
|
272
|
-
/**
|
|
273
|
-
* Set a default output schema for all MCP tools generated from this parser
|
|
274
|
-
* @param schema - Predefined pattern name, Zod schema, or schema definition object
|
|
275
|
-
* @returns This ArgParser instance for chaining
|
|
276
|
-
*/
|
|
277
|
-
setDefaultOutputSchema(schema: OutputSchemaConfig): this;
|
|
278
|
-
/**
|
|
279
|
-
* Set an output schema for a specific tool/command
|
|
280
|
-
* @param toolName - Name of the tool/command
|
|
281
|
-
* @param schema - Predefined pattern name, Zod schema, or schema definition object
|
|
282
|
-
* @returns This ArgParser instance for chaining
|
|
283
|
-
*/
|
|
284
|
-
setOutputSchema(toolName: string, schema: OutputSchemaConfig): this;
|
|
285
|
-
/**
|
|
286
|
-
* Enable automatic output schema generation for MCP tools
|
|
287
|
-
* @param pattern - True for default pattern, or specific pattern name
|
|
288
|
-
* @returns This ArgParser instance for chaining
|
|
289
|
-
*/
|
|
290
|
-
enableAutoOutputSchema(pattern?: boolean | keyof typeof import("./types").OutputSchemaPatterns): this;
|
|
291
|
-
/**
|
|
292
|
-
* Set the MCP protocol version for compatibility checks
|
|
293
|
-
* @param version - MCP protocol version (e.g., "2025-06-18")
|
|
294
|
-
* @returns This ArgParser instance for chaining
|
|
295
|
-
*/
|
|
296
|
-
setMcpProtocolVersion(version: string): this;
|
|
85
|
+
constructor(params?: IArgParserParams<THandlerReturn>, initialFlags?: readonly IFlag[]);
|
|
297
86
|
/**
|
|
298
|
-
*
|
|
299
|
-
* Output schemas were introduced in MCP version 2025-06-18
|
|
300
|
-
* @returns true if output schemas are supported
|
|
87
|
+
* Install a plugin
|
|
301
88
|
*/
|
|
302
|
-
|
|
89
|
+
use(plugin: IArgParserPlugin): this;
|
|
303
90
|
/**
|
|
304
|
-
*
|
|
305
|
-
* In CLI mode, the tool becomes a subcommand with its own flags
|
|
306
|
-
* In MCP mode, the tool becomes an MCP tool with auto-generated schema
|
|
307
|
-
*
|
|
308
|
-
* @param toolConfig Configuration for the tool
|
|
309
|
-
* @returns This ArgParser instance for chaining
|
|
91
|
+
* Check if a plugin is installed
|
|
310
92
|
*/
|
|
311
|
-
|
|
93
|
+
hasPlugin(name: string): boolean;
|
|
312
94
|
/**
|
|
313
|
-
*
|
|
314
|
-
* @deprecated Use addTool() instead. This method will be removed in v2.0.
|
|
315
|
-
* @param toolConfig Configuration for the MCP tool
|
|
316
|
-
* @returns This ArgParser instance for chaining
|
|
95
|
+
* Get an installed plugin
|
|
317
96
|
*/
|
|
318
|
-
|
|
97
|
+
getPlugin(name: string): IArgParserPlugin | undefined;
|
|
319
98
|
/**
|
|
320
|
-
*
|
|
321
|
-
* @returns Map of tool names to tool configurations
|
|
99
|
+
* List all installed plugins
|
|
322
100
|
*/
|
|
323
|
-
|
|
101
|
+
listPlugins(): string[];
|
|
324
102
|
/**
|
|
325
|
-
*
|
|
326
|
-
* @deprecated Use getTools() instead
|
|
327
|
-
* @returns Map of tool names to tool configurations
|
|
103
|
+
* Add a flag
|
|
328
104
|
*/
|
|
329
|
-
|
|
105
|
+
addFlag(flag: IFlag): this;
|
|
330
106
|
/**
|
|
331
|
-
*
|
|
332
|
-
* @param options Optional configuration for MCP tool generation
|
|
333
|
-
* @returns Object with tool counts and names for debugging
|
|
107
|
+
* Add multiple flags
|
|
334
108
|
*/
|
|
335
|
-
|
|
336
|
-
unifiedTools: string[];
|
|
337
|
-
legacyMcpTools: string[];
|
|
338
|
-
cliTools: string[];
|
|
339
|
-
totalTools: number;
|
|
340
|
-
duplicates: string[];
|
|
341
|
-
};
|
|
109
|
+
addFlags(flags: readonly IFlag[]): this;
|
|
342
110
|
/**
|
|
343
|
-
*
|
|
344
|
-
* @deprecated Use getToolInfo() instead
|
|
345
|
-
* @param options Optional configuration for MCP tool generation
|
|
346
|
-
* @returns Object with tool counts and names for debugging
|
|
111
|
+
* Check if a flag exists
|
|
347
112
|
*/
|
|
348
|
-
|
|
349
|
-
manualTools: string[];
|
|
350
|
-
cliTools: string[];
|
|
351
|
-
totalTools: number;
|
|
352
|
-
duplicates: string[];
|
|
353
|
-
};
|
|
113
|
+
hasFlag(name: string): boolean;
|
|
354
114
|
/**
|
|
355
|
-
*
|
|
356
|
-
* @returns Validation results
|
|
115
|
+
* Get a flag definition
|
|
357
116
|
*/
|
|
358
|
-
|
|
359
|
-
isValid: boolean;
|
|
360
|
-
issues: string[];
|
|
361
|
-
cliSubcommands: string[];
|
|
362
|
-
mcpTools: string[];
|
|
363
|
-
};
|
|
117
|
+
getFlagDefinition(name: string): ProcessedFlag | undefined;
|
|
364
118
|
/**
|
|
365
|
-
*
|
|
366
|
-
* This is useful for debugging and ensuring tools are properly registered
|
|
367
|
-
* @param toolName Name of the tool to test
|
|
368
|
-
* @param args Arguments to pass to the tool
|
|
369
|
-
* @returns Promise with the tool execution result or error
|
|
119
|
+
* Get all flags
|
|
370
120
|
*/
|
|
371
|
-
|
|
372
|
-
success: boolean;
|
|
373
|
-
result?: any;
|
|
374
|
-
error?: string;
|
|
375
|
-
executionTime?: number;
|
|
376
|
-
}>;
|
|
121
|
+
get flags(): ProcessedFlag[];
|
|
377
122
|
/**
|
|
378
|
-
*
|
|
379
|
-
* @param options Optional configuration for MCP tool generation
|
|
380
|
-
* @returns Array of MCP tool structures ready for server registration
|
|
123
|
+
* Get all flag names
|
|
381
124
|
*/
|
|
382
|
-
|
|
125
|
+
get flagNames(): string[];
|
|
383
126
|
/**
|
|
384
|
-
*
|
|
385
|
-
* @param serverInfo Server configuration
|
|
386
|
-
* @param toolOptions Optional MCP tool generation options
|
|
387
|
-
* @param logPath Optional log path (deprecated, use log config in withMcp instead)
|
|
388
|
-
* @returns Configured MCP server instance
|
|
127
|
+
* Add a subcommand
|
|
389
128
|
*/
|
|
390
|
-
|
|
129
|
+
addSubCommand(subCommand: ISubCommand): this;
|
|
391
130
|
/**
|
|
392
|
-
*
|
|
393
|
-
* @param _server The MCP server instance (unused for now, but reserved for future client connection tracking)
|
|
131
|
+
* Get a subcommand
|
|
394
132
|
*/
|
|
395
|
-
|
|
133
|
+
getSubCommand(name: string): ISubCommand | undefined;
|
|
396
134
|
/**
|
|
397
|
-
*
|
|
398
|
-
* @param serverInfo Server configuration
|
|
399
|
-
* @param toolOptions Optional MCP tool generation options
|
|
400
|
-
* @returns Promise that resolves when server is connected
|
|
135
|
+
* Get all subcommands
|
|
401
136
|
*/
|
|
402
|
-
|
|
403
|
-
name: string;
|
|
404
|
-
version: string;
|
|
405
|
-
description?: string;
|
|
406
|
-
}, toolOptions?: GenerateMcpToolsOptions): Promise<void>;
|
|
137
|
+
getSubCommands(): Map<string, ISubCommand>;
|
|
407
138
|
/**
|
|
408
|
-
*
|
|
409
|
-
* @param serverInfo Server configuration
|
|
410
|
-
* @param transports Array of transport configurations
|
|
411
|
-
* @param toolOptions Optional MCP tool generation options
|
|
412
|
-
* @returns Promise that resolves when all servers are started
|
|
139
|
+
* Inherit flags to a sub-parser
|
|
413
140
|
*/
|
|
414
|
-
|
|
415
|
-
name: string;
|
|
416
|
-
version: string;
|
|
417
|
-
description?: string;
|
|
418
|
-
}, transports: Array<{
|
|
419
|
-
type: "stdio" | "sse" | "streamable-http";
|
|
420
|
-
port?: number;
|
|
421
|
-
host?: string;
|
|
422
|
-
path?: string;
|
|
423
|
-
sessionIdGenerator?: () => string;
|
|
424
|
-
cors?: CorsOptions;
|
|
425
|
-
auth?: AuthOptions;
|
|
426
|
-
}>, toolOptions?: GenerateMcpToolsOptions, logPath?: LogPath): Promise<void>;
|
|
141
|
+
private inheritFlagsToSubParser;
|
|
427
142
|
/**
|
|
428
|
-
*
|
|
429
|
-
* @param serverInfo Server configuration
|
|
430
|
-
* @param transportType Type of transport to use
|
|
431
|
-
* @param transportOptions Transport-specific options
|
|
432
|
-
* @param toolOptions Optional MCP tool generation options
|
|
433
|
-
* @returns Promise that resolves when server is connected
|
|
143
|
+
* Set the handler
|
|
434
144
|
*/
|
|
435
|
-
|
|
436
|
-
name: string;
|
|
437
|
-
version: string;
|
|
438
|
-
description?: string;
|
|
439
|
-
}, transportType: "stdio" | "sse" | "streamable-http", transportOptions?: {
|
|
440
|
-
port?: number;
|
|
441
|
-
host?: string;
|
|
442
|
-
path?: string;
|
|
443
|
-
sessionIdGenerator?: () => string;
|
|
444
|
-
cors?: CorsOptions;
|
|
445
|
-
auth?: AuthOptions;
|
|
446
|
-
}, toolOptions?: GenerateMcpToolsOptions, logPath?: LogPath): Promise<void>;
|
|
447
|
-
parse(processArgs?: string[], options?: any): Promise<any>;
|
|
145
|
+
setHandler(handler: (ctx: IHandlerContext<any, any>) => THandlerReturn | Promise<THandlerReturn>): this;
|
|
448
146
|
/**
|
|
449
|
-
*
|
|
450
|
-
* When autoExit is false, this method will call process.exit() based on ParseResult
|
|
451
|
-
* This ensures backward compatibility for CLI applications
|
|
147
|
+
* Get the handler
|
|
452
148
|
*/
|
|
453
|
-
|
|
149
|
+
getHandler(): ((ctx: IHandlerContext) => any) | undefined;
|
|
150
|
+
getAppName(): string;
|
|
151
|
+
getAppCommandName(): string | undefined;
|
|
152
|
+
getDescription(): string | undefined;
|
|
153
|
+
getSubCommandName(): string;
|
|
154
|
+
getAutoExit(): boolean;
|
|
155
|
+
getPromptWhen(): PromptWhen;
|
|
454
156
|
/**
|
|
455
|
-
*
|
|
456
|
-
* Since parse() is already async, this just calls parse()
|
|
457
|
-
*
|
|
458
|
-
* @deprecated Use parse() instead. This method will be removed in a future version.
|
|
157
|
+
* Parse command line arguments
|
|
459
158
|
*/
|
|
460
|
-
|
|
159
|
+
parse(processArgs?: string[], options?: IParseOptions): Promise<any>;
|
|
461
160
|
/**
|
|
462
|
-
*
|
|
463
|
-
* This eliminates the need for boilerplate code to check if the script is being run directly.
|
|
464
|
-
*
|
|
465
|
-
* @param importMetaUrl Pass import.meta.url from your script for reliable detection
|
|
466
|
-
* @param processArgs Optional arguments to parse (defaults to process.argv.slice(2))
|
|
467
|
-
* @param options Additional parse options
|
|
468
|
-
* @returns Promise that resolves to the parse result, or empty object if script is imported
|
|
469
|
-
*
|
|
470
|
-
* @example
|
|
471
|
-
* ```typescript
|
|
472
|
-
* // At the bottom of your CLI script:
|
|
473
|
-
* await cli.parseIfExecutedDirectly(import.meta.url);
|
|
474
|
-
*
|
|
475
|
-
* // With error handling:
|
|
476
|
-
* await cli.parseIfExecutedDirectly(import.meta.url).catch((error) => {
|
|
477
|
-
* this.logger.error("Fatal error:", error instanceof Error ? error.message : String(error));
|
|
478
|
-
* process.exit(1);
|
|
479
|
-
* });
|
|
480
|
-
* ```
|
|
161
|
+
* Parse flags only
|
|
481
162
|
*/
|
|
482
|
-
|
|
163
|
+
private parseFlags;
|
|
483
164
|
/**
|
|
484
|
-
*
|
|
485
|
-
* @param subCommandName Name of the sub-command (default: "mcp-server")
|
|
486
|
-
* @param serverInfo Server configuration (supports extended DXT fields)
|
|
487
|
-
* @param options Optional configuration including preset transports and tool options
|
|
488
|
-
* @returns This ArgParserWithMcp instance for chaining
|
|
489
|
-
* @deprecated Use withMcp() to configure server metadata and --s-mcp-serve system flag instead. This method will be removed in v2.0.
|
|
165
|
+
* Parse a flag value based on type
|
|
490
166
|
*/
|
|
491
|
-
|
|
492
|
-
toolOptions?: GenerateMcpToolsOptions;
|
|
493
|
-
}): this;
|
|
167
|
+
private parseFlagValue;
|
|
494
168
|
/**
|
|
495
|
-
*
|
|
496
|
-
* @param subCommandName Name of the sub-command (default: "mcp-server")
|
|
497
|
-
* @param serverInfo Server configuration (supports extended DXT fields)
|
|
498
|
-
* @param toolOptions Optional MCP tool generation options (backward compatibility)
|
|
499
|
-
* @returns This ArgParserWithMcp instance for chaining
|
|
500
|
-
* @deprecated Use withMcp() to configure server metadata and --s-mcp-serve system flag instead. This method will be removed in v2.0.
|
|
169
|
+
* Find the command chain for subcommands
|
|
501
170
|
*/
|
|
502
|
-
|
|
171
|
+
private findCommandChain;
|
|
503
172
|
/**
|
|
504
|
-
*
|
|
505
|
-
* This provides a clean API for users who want MCP functionality from the start
|
|
506
|
-
* Automatically sets handleErrors: false for MCP compatibility
|
|
507
|
-
*
|
|
508
|
-
* @param options Combined ArgParser and MCP server configuration options
|
|
509
|
-
* @param initialFlags Optional array of initial flags to add
|
|
510
|
-
* @returns ArgParser instance with MCP capabilities and stored server metadata
|
|
173
|
+
* Detect and strip system flags
|
|
511
174
|
*/
|
|
512
|
-
|
|
175
|
+
private detectAndStripSystemFlags;
|
|
513
176
|
/**
|
|
514
|
-
*
|
|
515
|
-
* This sets autoExit: true by default for traditional CLI behavior
|
|
177
|
+
* Handle exit
|
|
516
178
|
*/
|
|
517
|
-
|
|
179
|
+
private handleExit;
|
|
518
180
|
/**
|
|
519
|
-
*
|
|
520
|
-
* This sets autoExit: false by default for programmatic control
|
|
181
|
+
* Generate help text
|
|
521
182
|
*/
|
|
522
|
-
|
|
523
|
-
static fromArgParser<T = any>(parser: ArgParserBase<T>): ArgParser<T>;
|
|
183
|
+
helpText(): string;
|
|
524
184
|
}
|
|
525
185
|
//# sourceMappingURL=ArgParser.d.ts.map
|