@alcyone-labs/arg-parser 2.1.0 → 2.1.1
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/dist/config/ConfigurationManager.d.ts +74 -0
- package/dist/config/ConfigurationManager.d.ts.map +1 -0
- package/dist/config/plugins/ConfigPlugin.d.ts +60 -0
- package/dist/config/plugins/ConfigPlugin.d.ts.map +1 -0
- package/dist/config/plugins/ConfigPluginRegistry.d.ts +72 -0
- package/dist/config/plugins/ConfigPluginRegistry.d.ts.map +1 -0
- package/dist/config/plugins/TomlConfigPlugin.d.ts +30 -0
- package/dist/config/plugins/TomlConfigPlugin.d.ts.map +1 -0
- package/dist/config/plugins/YamlConfigPlugin.d.ts +29 -0
- package/dist/config/plugins/YamlConfigPlugin.d.ts.map +1 -0
- package/dist/config/plugins/index.d.ts +5 -0
- package/dist/config/plugins/index.d.ts.map +1 -0
- package/dist/core/ArgParser.d.ts +380 -0
- package/dist/core/ArgParser.d.ts.map +1 -0
- package/dist/core/ArgParserBase.d.ts +206 -0
- package/dist/core/ArgParserBase.d.ts.map +1 -0
- package/dist/core/FlagManager.d.ts +16 -0
- package/dist/core/FlagManager.d.ts.map +1 -0
- package/dist/core/types.d.ts +355 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/dxt/DxtGenerator.d.ts +111 -0
- package/dist/dxt/DxtGenerator.d.ts.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/mcp/ArgParserMcp.d.ts +21 -0
- package/dist/mcp/ArgParserMcp.d.ts.map +1 -0
- package/dist/mcp/mcp-integration.d.ts +86 -0
- package/dist/mcp/mcp-integration.d.ts.map +1 -0
- package/dist/mcp/mcp-notifications.d.ts +138 -0
- package/dist/mcp/mcp-notifications.d.ts.map +1 -0
- package/dist/mcp/mcp-prompts.d.ts +132 -0
- package/dist/mcp/mcp-prompts.d.ts.map +1 -0
- package/dist/mcp/mcp-protocol-versions.d.ts +150 -0
- package/dist/mcp/mcp-protocol-versions.d.ts.map +1 -0
- package/dist/mcp/mcp-resources.d.ts +133 -0
- package/dist/mcp/mcp-resources.d.ts.map +1 -0
- package/dist/testing/fuzzy-test-cli.d.ts +5 -0
- package/dist/testing/fuzzy-test-cli.d.ts.map +1 -0
- package/dist/testing/fuzzy-tester.d.ts +101 -0
- package/dist/testing/fuzzy-tester.d.ts.map +1 -0
- package/package.json +5 -3
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export type ArgParserInstance = any;
|
|
3
|
+
export declare const zodFlagSchema: z.ZodEffects<z.ZodObject<{
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
allowLigature: z.ZodDefault<z.ZodBoolean>;
|
|
6
|
+
allowMultiple: z.ZodDefault<z.ZodBoolean>;
|
|
7
|
+
description: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
8
|
+
options: z.ZodArray<z.ZodString, "many">;
|
|
9
|
+
defaultValue: z.ZodOptional<z.ZodAny>;
|
|
10
|
+
type: z.ZodDefault<z.ZodUnion<[z.ZodEffects<z.ZodAny, any, any>, z.ZodEffects<z.ZodAny, any, any>, z.ZodEffects<z.ZodAny, any, any>, z.ZodEffects<z.ZodAny, any, any>, z.ZodEffects<z.ZodAny, any, any>, z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodAny>, z.ZodEffects<z.ZodString, string, string>]>>;
|
|
11
|
+
mandatory: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodBoolean>]>>;
|
|
12
|
+
flagOnly: z.ZodDefault<z.ZodBoolean>;
|
|
13
|
+
validate: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodOptional<z.ZodAny>, z.ZodOptional<z.ZodAny>], z.ZodUnknown>, z.ZodUnion<[z.ZodBoolean, z.ZodString, z.ZodVoid, z.ZodPromise<z.ZodUnion<[z.ZodBoolean, z.ZodString, z.ZodVoid]>>]>>>;
|
|
14
|
+
enum: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
15
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
allowLigature: z.ZodDefault<z.ZodBoolean>;
|
|
18
|
+
allowMultiple: z.ZodDefault<z.ZodBoolean>;
|
|
19
|
+
description: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
20
|
+
options: z.ZodArray<z.ZodString, "many">;
|
|
21
|
+
defaultValue: z.ZodOptional<z.ZodAny>;
|
|
22
|
+
type: z.ZodDefault<z.ZodUnion<[z.ZodEffects<z.ZodAny, any, any>, z.ZodEffects<z.ZodAny, any, any>, z.ZodEffects<z.ZodAny, any, any>, z.ZodEffects<z.ZodAny, any, any>, z.ZodEffects<z.ZodAny, any, any>, z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodAny>, z.ZodEffects<z.ZodString, string, string>]>>;
|
|
23
|
+
mandatory: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodBoolean>]>>;
|
|
24
|
+
flagOnly: z.ZodDefault<z.ZodBoolean>;
|
|
25
|
+
validate: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodOptional<z.ZodAny>, z.ZodOptional<z.ZodAny>], z.ZodUnknown>, z.ZodUnion<[z.ZodBoolean, z.ZodString, z.ZodVoid, z.ZodPromise<z.ZodUnion<[z.ZodBoolean, z.ZodString, z.ZodVoid]>>]>>>;
|
|
26
|
+
enum: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
27
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
28
|
+
name: z.ZodString;
|
|
29
|
+
allowLigature: z.ZodDefault<z.ZodBoolean>;
|
|
30
|
+
allowMultiple: z.ZodDefault<z.ZodBoolean>;
|
|
31
|
+
description: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
32
|
+
options: z.ZodArray<z.ZodString, "many">;
|
|
33
|
+
defaultValue: z.ZodOptional<z.ZodAny>;
|
|
34
|
+
type: z.ZodDefault<z.ZodUnion<[z.ZodEffects<z.ZodAny, any, any>, z.ZodEffects<z.ZodAny, any, any>, z.ZodEffects<z.ZodAny, any, any>, z.ZodEffects<z.ZodAny, any, any>, z.ZodEffects<z.ZodAny, any, any>, z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodAny>, z.ZodEffects<z.ZodString, string, string>]>>;
|
|
35
|
+
mandatory: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodBoolean>]>>;
|
|
36
|
+
flagOnly: z.ZodDefault<z.ZodBoolean>;
|
|
37
|
+
validate: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodOptional<z.ZodAny>, z.ZodOptional<z.ZodAny>], z.ZodUnknown>, z.ZodUnion<[z.ZodBoolean, z.ZodString, z.ZodVoid, z.ZodPromise<z.ZodUnion<[z.ZodBoolean, z.ZodString, z.ZodVoid]>>]>>>;
|
|
38
|
+
enum: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
39
|
+
}, z.ZodTypeAny, "passthrough">>, {
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
}, z.objectInputType<{
|
|
42
|
+
name: z.ZodString;
|
|
43
|
+
allowLigature: z.ZodDefault<z.ZodBoolean>;
|
|
44
|
+
allowMultiple: z.ZodDefault<z.ZodBoolean>;
|
|
45
|
+
description: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
46
|
+
options: z.ZodArray<z.ZodString, "many">;
|
|
47
|
+
defaultValue: z.ZodOptional<z.ZodAny>;
|
|
48
|
+
type: z.ZodDefault<z.ZodUnion<[z.ZodEffects<z.ZodAny, any, any>, z.ZodEffects<z.ZodAny, any, any>, z.ZodEffects<z.ZodAny, any, any>, z.ZodEffects<z.ZodAny, any, any>, z.ZodEffects<z.ZodAny, any, any>, z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodAny>, z.ZodEffects<z.ZodString, string, string>]>>;
|
|
49
|
+
mandatory: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodBoolean>]>>;
|
|
50
|
+
flagOnly: z.ZodDefault<z.ZodBoolean>;
|
|
51
|
+
validate: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodOptional<z.ZodAny>, z.ZodOptional<z.ZodAny>], z.ZodUnknown>, z.ZodUnion<[z.ZodBoolean, z.ZodString, z.ZodVoid, z.ZodPromise<z.ZodUnion<[z.ZodBoolean, z.ZodString, z.ZodVoid]>>]>>>;
|
|
52
|
+
enum: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
53
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
54
|
+
/**
|
|
55
|
+
* The raw input type for defining a flag, before Zod processing (aliases, defaults).
|
|
56
|
+
*/
|
|
57
|
+
export type IFlagCore = z.input<typeof zodFlagSchema>;
|
|
58
|
+
/**
|
|
59
|
+
* The type of the `type` property in a ProcessedFlagCore object.
|
|
60
|
+
* This represents all valid forms the `type` property can take after Zod processing.
|
|
61
|
+
*/
|
|
62
|
+
export type TParsedArgsTypeFromFlagDef = StringConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor | ObjectConstructor | ((value: string) => any) | "string" | "number" | "boolean" | "array" | "object";
|
|
63
|
+
/**
|
|
64
|
+
* The core type of a flag after Zod processing (defaults applied, aliases resolved),
|
|
65
|
+
* but before some properties are made more specific (like `type` constructor to actual type).
|
|
66
|
+
* This type is output by `zodFlagSchema.parse()`.
|
|
67
|
+
*/
|
|
68
|
+
export type ProcessedFlagCore = Omit<z.output<typeof zodFlagSchema>, "type"> & {
|
|
69
|
+
type: TParsedArgsTypeFromFlagDef;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* The user-facing type for defining a flag. It includes aliases like `default` and `required`.
|
|
73
|
+
* The `handler` property is removed as handlers are typically associated with commands/subcommands, not individual flags.
|
|
74
|
+
*/
|
|
75
|
+
export type IFlag = IFlagCore & {
|
|
76
|
+
/** @alias defaultValue */
|
|
77
|
+
default?: any;
|
|
78
|
+
/** @alias mandatory */
|
|
79
|
+
required?: boolean | ((parsedArgs: TParsedArgs<any>) => boolean);
|
|
80
|
+
/** Environment variables that should be set from this flag's value in DXT packages */
|
|
81
|
+
env?: string | string[];
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* A more refined type for a flag after it has been fully processed by ArgParser,
|
|
85
|
+
* particularly its `type` property and validation/enum/mandatory functions.
|
|
86
|
+
* This is the type that ArgParser would internally work with for parsing and type extraction.
|
|
87
|
+
*/
|
|
88
|
+
export type ProcessedFlag = Omit<ProcessedFlagCore, "validate" | "enum" | "mandatory"> & {
|
|
89
|
+
validate?: (value: any, parsedArgs?: TParsedArgs<ProcessedFlag[]>) => boolean | string | void | Promise<boolean | string | void>;
|
|
90
|
+
enum?: any[];
|
|
91
|
+
mandatory?: boolean | ((parsedArgs: TParsedArgs<ProcessedFlag[]>) => boolean);
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Resolves the TypeScript type from a flag's `type` definition.
|
|
95
|
+
*/
|
|
96
|
+
export type ResolveType<T extends TParsedArgsTypeFromFlagDef> = T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends ArrayConstructor ? any[] : T extends ObjectConstructor ? Record<string, any> : T extends "string" ? string : T extends "number" ? number : T extends "boolean" ? boolean : T extends "array" ? any[] : T extends "object" ? Record<string, any> : T extends (value: string) => infer R ? R : any;
|
|
97
|
+
/**
|
|
98
|
+
* Extracts the final TypeScript type for a flag's value based on its definition,
|
|
99
|
+
* considering `flagOnly` and `allowMultiple` properties.
|
|
100
|
+
*/
|
|
101
|
+
export type ExtractFlagType<TFlag extends ProcessedFlag> = TFlag["flagOnly"] extends true ? TFlag["allowMultiple"] extends true ? boolean[] : boolean : TFlag["allowMultiple"] extends true ? Array<ResolveType<TFlag["type"]>> : ResolveType<TFlag["type"]>;
|
|
102
|
+
/**
|
|
103
|
+
* Represents the structured object of parsed arguments.
|
|
104
|
+
* Keys are flag names, and values are their parsed and typed values.
|
|
105
|
+
* `TFlags` should be the array of `ProcessedFlag` definitions for the specific command.
|
|
106
|
+
*/
|
|
107
|
+
export type TParsedArgs<TFlags extends readonly ProcessedFlag[]> = {
|
|
108
|
+
[K in TFlags[number]["name"]]: ExtractFlagType<Extract<TFlags[number], {
|
|
109
|
+
name: K;
|
|
110
|
+
}>>;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Generic context object passed to command handlers.
|
|
114
|
+
* @template TCurrentCommandArgs Shape of `args` for the current command, derived from its flags.
|
|
115
|
+
* @template TParentCommandArgs Shape of `parentArgs` from the parent command, if any.
|
|
116
|
+
*/
|
|
117
|
+
export type IHandlerContext<TCurrentCommandArgs extends Record<string, any> = Record<string, any>, TParentCommandArgs extends Record<string, any> = Record<string, any>> = {
|
|
118
|
+
/** Parsed arguments specific to the current command. */
|
|
119
|
+
args: TCurrentCommandArgs;
|
|
120
|
+
/** Parsed arguments from the parent command, if this is a subcommand. */
|
|
121
|
+
parentArgs?: TParentCommandArgs;
|
|
122
|
+
/** The sequence of command names that led to this handler. */
|
|
123
|
+
commandChain: string[];
|
|
124
|
+
/** The `ArgParser` instance that invoked this handler (could be a subcommand's parser). */
|
|
125
|
+
parser: ArgParserInstance;
|
|
126
|
+
/** The parent `ArgParser` instance, if this is a subcommand handler. */
|
|
127
|
+
parentParser?: ArgParserInstance;
|
|
128
|
+
/** Optional: The root `ArgParser` instance of the CLI. */
|
|
129
|
+
/** Indicates if the handler is being called from MCP mode (true) or CLI mode (false). */
|
|
130
|
+
isMcp?: boolean;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Generic type for the collection of processed flags that an ArgParser instance manages.
|
|
134
|
+
*/
|
|
135
|
+
export type FlagsArray = readonly ProcessedFlag[];
|
|
136
|
+
/**
|
|
137
|
+
* Converts a flag type to a JSON Schema type string.
|
|
138
|
+
* This function handles all possible flag type formats and returns a valid JSON Schema type.
|
|
139
|
+
*
|
|
140
|
+
* @param flagType - The flag type from IFlag or ProcessedFlag
|
|
141
|
+
* @returns A JSON Schema type string: "string" | "number" | "boolean" | "array" | "object"
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* getJsonSchemaTypeFromFlag(String) // returns "string"
|
|
146
|
+
* getJsonSchemaTypeFromFlag("number") // returns "number"
|
|
147
|
+
* getJsonSchemaTypeFromFlag((val) => parseInt(val)) // returns "string" (fallback for custom functions)
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
export declare function getJsonSchemaTypeFromFlag(flagType: TParsedArgsTypeFromFlagDef): "string" | "number" | "boolean" | "array" | "object";
|
|
151
|
+
/**
|
|
152
|
+
* Common output schema patterns for typical CLI/MCP tool responses
|
|
153
|
+
*/
|
|
154
|
+
export declare const OutputSchemaPatterns: {
|
|
155
|
+
/**
|
|
156
|
+
* Simple success/error response pattern
|
|
157
|
+
* @example { success: true, message: "Operation completed" }
|
|
158
|
+
*/
|
|
159
|
+
readonly successError: () => z.ZodObject<{
|
|
160
|
+
success: z.ZodBoolean;
|
|
161
|
+
message: z.ZodOptional<z.ZodString>;
|
|
162
|
+
error: z.ZodOptional<z.ZodString>;
|
|
163
|
+
}, "strip", z.ZodTypeAny, {
|
|
164
|
+
success: boolean;
|
|
165
|
+
message?: string | undefined;
|
|
166
|
+
error?: string | undefined;
|
|
167
|
+
}, {
|
|
168
|
+
success: boolean;
|
|
169
|
+
message?: string | undefined;
|
|
170
|
+
error?: string | undefined;
|
|
171
|
+
}>;
|
|
172
|
+
/**
|
|
173
|
+
* Success response with data payload
|
|
174
|
+
* @example { success: true, data: {...}, message: "Data retrieved" }
|
|
175
|
+
*/
|
|
176
|
+
readonly successWithData: (dataSchema?: z.ZodTypeAny) => z.ZodObject<{
|
|
177
|
+
success: z.ZodBoolean;
|
|
178
|
+
data: z.ZodTypeAny;
|
|
179
|
+
message: z.ZodOptional<z.ZodString>;
|
|
180
|
+
error: z.ZodOptional<z.ZodString>;
|
|
181
|
+
}, "strip", z.ZodTypeAny, {
|
|
182
|
+
success: boolean;
|
|
183
|
+
message?: string | undefined;
|
|
184
|
+
error?: string | undefined;
|
|
185
|
+
data?: any;
|
|
186
|
+
}, {
|
|
187
|
+
success: boolean;
|
|
188
|
+
message?: string | undefined;
|
|
189
|
+
error?: string | undefined;
|
|
190
|
+
data?: any;
|
|
191
|
+
}>;
|
|
192
|
+
/**
|
|
193
|
+
* List/array response pattern
|
|
194
|
+
* @example { items: [...], count: 5, hasMore: false }
|
|
195
|
+
*/
|
|
196
|
+
readonly list: (itemSchema?: z.ZodTypeAny) => z.ZodObject<{
|
|
197
|
+
items: z.ZodArray<z.ZodTypeAny, "many">;
|
|
198
|
+
count: z.ZodOptional<z.ZodNumber>;
|
|
199
|
+
hasMore: z.ZodOptional<z.ZodBoolean>;
|
|
200
|
+
}, "strip", z.ZodTypeAny, {
|
|
201
|
+
items: any[];
|
|
202
|
+
count?: number | undefined;
|
|
203
|
+
hasMore?: boolean | undefined;
|
|
204
|
+
}, {
|
|
205
|
+
items: any[];
|
|
206
|
+
count?: number | undefined;
|
|
207
|
+
hasMore?: boolean | undefined;
|
|
208
|
+
}>;
|
|
209
|
+
/**
|
|
210
|
+
* File operation response pattern
|
|
211
|
+
* @example { path: "/path/to/file", size: 1024, created: true }
|
|
212
|
+
*/
|
|
213
|
+
readonly fileOperation: () => z.ZodObject<{
|
|
214
|
+
path: z.ZodString;
|
|
215
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
216
|
+
created: z.ZodOptional<z.ZodBoolean>;
|
|
217
|
+
modified: z.ZodOptional<z.ZodBoolean>;
|
|
218
|
+
exists: z.ZodOptional<z.ZodBoolean>;
|
|
219
|
+
}, "strip", z.ZodTypeAny, {
|
|
220
|
+
path: string;
|
|
221
|
+
size?: number | undefined;
|
|
222
|
+
created?: boolean | undefined;
|
|
223
|
+
modified?: boolean | undefined;
|
|
224
|
+
exists?: boolean | undefined;
|
|
225
|
+
}, {
|
|
226
|
+
path: string;
|
|
227
|
+
size?: number | undefined;
|
|
228
|
+
created?: boolean | undefined;
|
|
229
|
+
modified?: boolean | undefined;
|
|
230
|
+
exists?: boolean | undefined;
|
|
231
|
+
}>;
|
|
232
|
+
/**
|
|
233
|
+
* Process execution response pattern
|
|
234
|
+
* @example { exitCode: 0, stdout: "output", stderr: "", duration: 1500 }
|
|
235
|
+
*/
|
|
236
|
+
readonly processExecution: () => z.ZodObject<{
|
|
237
|
+
exitCode: z.ZodNumber;
|
|
238
|
+
stdout: z.ZodOptional<z.ZodString>;
|
|
239
|
+
stderr: z.ZodOptional<z.ZodString>;
|
|
240
|
+
duration: z.ZodOptional<z.ZodNumber>;
|
|
241
|
+
command: z.ZodOptional<z.ZodString>;
|
|
242
|
+
}, "strip", z.ZodTypeAny, {
|
|
243
|
+
exitCode: number;
|
|
244
|
+
stdout?: string | undefined;
|
|
245
|
+
stderr?: string | undefined;
|
|
246
|
+
duration?: number | undefined;
|
|
247
|
+
command?: string | undefined;
|
|
248
|
+
}, {
|
|
249
|
+
exitCode: number;
|
|
250
|
+
stdout?: string | undefined;
|
|
251
|
+
stderr?: string | undefined;
|
|
252
|
+
duration?: number | undefined;
|
|
253
|
+
command?: string | undefined;
|
|
254
|
+
}>;
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* Type for output schema pattern names with auto-completion support
|
|
258
|
+
*/
|
|
259
|
+
export type OutputSchemaPatternName = keyof typeof OutputSchemaPatterns;
|
|
260
|
+
/**
|
|
261
|
+
* Type for output schema configuration - supports pattern names, Zod schemas, or schema definition objects
|
|
262
|
+
*/
|
|
263
|
+
export type OutputSchemaConfig = OutputSchemaPatternName | z.ZodTypeAny | Record<string, z.ZodTypeAny>;
|
|
264
|
+
/**
|
|
265
|
+
* Creates a Zod output schema from a pattern or custom definition
|
|
266
|
+
*
|
|
267
|
+
* @param pattern - Either a predefined pattern name, a Zod schema, or a schema definition object
|
|
268
|
+
* @returns A Zod schema for output validation
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```typescript
|
|
272
|
+
* // Using a predefined pattern
|
|
273
|
+
* const schema1 = createOutputSchema('successError');
|
|
274
|
+
*
|
|
275
|
+
* // Using a custom Zod schema
|
|
276
|
+
* const schema2 = createOutputSchema(z.object({ result: z.string() }));
|
|
277
|
+
*
|
|
278
|
+
* // Using a schema definition object
|
|
279
|
+
* const schema3 = createOutputSchema({
|
|
280
|
+
* result: z.string().describe("The result"),
|
|
281
|
+
* timestamp: z.string().describe("When the operation completed")
|
|
282
|
+
* });
|
|
283
|
+
* ```
|
|
284
|
+
*/
|
|
285
|
+
export declare function createOutputSchema(pattern: OutputSchemaConfig): z.ZodTypeAny;
|
|
286
|
+
/**
|
|
287
|
+
* Defines a subcommand within an ArgParser setup.
|
|
288
|
+
* @template TSubCommandFlags Flags defined specifically FOR this subcommand.
|
|
289
|
+
* @template TParentCommandFlags Flags defined for the PARENT of this subcommand.
|
|
290
|
+
* @template THandlerReturn The expected return type of the subcommand's handler.
|
|
291
|
+
*/
|
|
292
|
+
export interface ISubCommand<TSubCommandFlags extends FlagsArray = FlagsArray, TParentCommandFlags extends FlagsArray = FlagsArray, THandlerReturn = any> {
|
|
293
|
+
name: string;
|
|
294
|
+
description?: string;
|
|
295
|
+
/** The ArgParser instance for this subcommand, typed with its own flags. */
|
|
296
|
+
parser: ArgParserInstance;
|
|
297
|
+
/** Handler function for this subcommand. */
|
|
298
|
+
handler?: (ctx: IHandlerContext<TParsedArgs<TSubCommandFlags>, TParsedArgs<TParentCommandFlags>>) => THandlerReturn | Promise<THandlerReturn>;
|
|
299
|
+
/** Internal flag to identify MCP subcommands for proper exclusion from tool generation */
|
|
300
|
+
isMcp?: boolean;
|
|
301
|
+
/** MCP server information for DXT generation */
|
|
302
|
+
mcpServerInfo?: {
|
|
303
|
+
name: string;
|
|
304
|
+
version: string;
|
|
305
|
+
description?: string;
|
|
306
|
+
};
|
|
307
|
+
/** MCP tool generation options for DXT generation */
|
|
308
|
+
mcpToolOptions?: any;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Result of parsing operations that replaces process.exit() calls.
|
|
312
|
+
* Provides structured information about the parsing outcome.
|
|
313
|
+
*/
|
|
314
|
+
export interface ParseResult<T = any> {
|
|
315
|
+
/** Whether the parsing was successful */
|
|
316
|
+
success: boolean;
|
|
317
|
+
/** Exit code that would have been used with process.exit() */
|
|
318
|
+
exitCode: number;
|
|
319
|
+
/** The parsed data/result when successful */
|
|
320
|
+
data?: T;
|
|
321
|
+
/** Human-readable message about the result */
|
|
322
|
+
message?: string;
|
|
323
|
+
/** Whether the process should exit (for help, version, etc.) */
|
|
324
|
+
shouldExit?: boolean;
|
|
325
|
+
/** Type of result for better handling */
|
|
326
|
+
type?: 'success' | 'error' | 'help' | 'version' | 'debug';
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Configuration options for ArgParser behavior
|
|
330
|
+
* @deprecated Use IArgParserParams for full configuration options. This interface will be removed in v3.0.
|
|
331
|
+
*/
|
|
332
|
+
export interface ArgParserOptions {
|
|
333
|
+
/** Whether to automatically call process.exit() based on ParseResult (default: true for backward compatibility) */
|
|
334
|
+
autoExit?: boolean;
|
|
335
|
+
/** Whether to handle errors by exiting or throwing (default: true for backward compatibility) */
|
|
336
|
+
handleErrors?: boolean;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Configuration options for ArgParser runtime behavior
|
|
340
|
+
* This is a more clearly named version of ArgParserOptions
|
|
341
|
+
*/
|
|
342
|
+
export interface ArgParserBehaviorOptions {
|
|
343
|
+
/** Whether to automatically call process.exit() based on ParseResult (default: true for backward compatibility) */
|
|
344
|
+
autoExit?: boolean;
|
|
345
|
+
/** Whether to handle errors by exiting or throwing (default: true for backward compatibility) */
|
|
346
|
+
handleErrors?: boolean;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Type for the main handler of an ArgParser instance (root command or a command defined by an ArgParser).
|
|
350
|
+
* @template TParserFlags Flags defined for this ArgParser instance.
|
|
351
|
+
* @template TParentParserFlags Flags of the parent parser, if this parser is used as a subcommand.
|
|
352
|
+
* @template THandlerReturn The expected return type of the handler.
|
|
353
|
+
*/
|
|
354
|
+
export type MainHandler<TParserFlags extends FlagsArray = FlagsArray, TParentParserFlags extends FlagsArray = FlagsArray, THandlerReturn = any> = (ctx: IHandlerContext<TParsedArgs<TParserFlags>, TParsedArgs<TParentParserFlags>>) => THandlerReturn | Promise<THandlerReturn>;
|
|
355
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,MAAM,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAEpC,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAwHtB,CAAC;AAEL;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAClC,iBAAiB,GACjB,iBAAiB,GACjB,kBAAkB,GAClB,gBAAgB,GAChB,iBAAiB,GACjB,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,GAAG,CAAC,GACxB,QAAQ,GACR,QAAQ,GACR,SAAS,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YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,MAAM,WAAW,CACrB,YAAY,SAAS,UAAU,GAAG,UAAU,EAC5C,kBAAkB,SAAS,UAAU,GAAG,UAAU,EAClD,cAAc,GAAG,GAAG,IAClB,CACF,GAAG,EAAE,eAAe,CAClB,WAAW,CAAC,YAAY,CAAC,EACzB,WAAW,CAAC,kBAAkB,CAAC,CAChC,KACE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { ParseResult } from "../core/types";
|
|
2
|
+
/**
|
|
3
|
+
* DxtGenerator handles the generation of DXT (Desktop Extension) packages
|
|
4
|
+
* for MCP servers created from ArgParser instances.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DxtGenerator {
|
|
7
|
+
private argParserInstance;
|
|
8
|
+
constructor(argParserInstance: any);
|
|
9
|
+
/**
|
|
10
|
+
* Helper method to handle exit logic based on autoExit setting
|
|
11
|
+
*/
|
|
12
|
+
private _handleExit;
|
|
13
|
+
/**
|
|
14
|
+
* Handles the --s-build-dxt system flag to generate DXT packages for MCP servers
|
|
15
|
+
*/
|
|
16
|
+
handleBuildDxtFlag(processArgs: string[], buildDxtIndex: number): Promise<boolean | ParseResult>;
|
|
17
|
+
/**
|
|
18
|
+
* Handles DXT generation in test mode by creating mock DXT package structure
|
|
19
|
+
*/
|
|
20
|
+
private handleTestModeDxtGeneration;
|
|
21
|
+
/**
|
|
22
|
+
* Generates a DXT package for the unified MCP server
|
|
23
|
+
* Now supports both withMcp() configuration and legacy addMcpSubCommand()
|
|
24
|
+
*/
|
|
25
|
+
generateDxtPackage(mcpSubCommand?: any, outputDir?: string): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Reads package.json to extract fallback information for DXT manifest
|
|
28
|
+
*/
|
|
29
|
+
private readPackageJsonInfo;
|
|
30
|
+
/**
|
|
31
|
+
* Extracts server information from MCP configuration
|
|
32
|
+
* Now supports both withMcp() configuration and legacy addMcpSubCommand()
|
|
33
|
+
*/
|
|
34
|
+
private extractMcpServerInfo;
|
|
35
|
+
private generateMcpToolsForDxt;
|
|
36
|
+
private createDxtManifest;
|
|
37
|
+
private validateDxtManifest;
|
|
38
|
+
private createServerScript;
|
|
39
|
+
private createDxtPackageJson;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a .dxtignore file to exclude build artifacts and unnecessary files
|
|
42
|
+
*/
|
|
43
|
+
private createDxtIgnore;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a simple build script that uses TSDown bundling and Anthropic's dxt pack
|
|
46
|
+
*/
|
|
47
|
+
private createSimpleBuildScript;
|
|
48
|
+
private createDxtReadme;
|
|
49
|
+
/**
|
|
50
|
+
* Maps ArgParser flag types to DXT user config types
|
|
51
|
+
*/
|
|
52
|
+
private mapFlagTypeToUserConfigType;
|
|
53
|
+
/**
|
|
54
|
+
* Generates CLI arguments for DXT manifest based on ArgParser flags
|
|
55
|
+
*/
|
|
56
|
+
private generateCliArgsForDxt;
|
|
57
|
+
/**
|
|
58
|
+
* Generates environment variables and user config for DXT manifest
|
|
59
|
+
*/
|
|
60
|
+
private generateEnvAndUserConfig;
|
|
61
|
+
/**
|
|
62
|
+
* Generates a user-friendly title for user config fields
|
|
63
|
+
*/
|
|
64
|
+
private generateUserConfigTitle;
|
|
65
|
+
/**
|
|
66
|
+
* Checks if a field should be marked as sensitive in user config
|
|
67
|
+
*/
|
|
68
|
+
private isSensitiveField;
|
|
69
|
+
/**
|
|
70
|
+
* Adds the logo to the build folder if available
|
|
71
|
+
* @returns The filename of the logo that was added, or undefined if no logo was added
|
|
72
|
+
*/
|
|
73
|
+
private addLogoToFolder;
|
|
74
|
+
/**
|
|
75
|
+
* Processes CLI source code to replace global console with MCP-compliant Logger
|
|
76
|
+
*/
|
|
77
|
+
private processCliSourceForMcp;
|
|
78
|
+
/**
|
|
79
|
+
* Adds the original CLI source to the build folder for handler execution
|
|
80
|
+
*/
|
|
81
|
+
private addOriginalCliToFolder;
|
|
82
|
+
/**
|
|
83
|
+
* Builds a complete DXT package using TSDown CLI for autonomous execution
|
|
84
|
+
*/
|
|
85
|
+
private buildDxtWithTsdown;
|
|
86
|
+
/**
|
|
87
|
+
* Bundles the original CLI using TSDown for autonomous execution (legacy method)
|
|
88
|
+
*/
|
|
89
|
+
private bundleOriginalCliWithTsdown;
|
|
90
|
+
/**
|
|
91
|
+
* Checks if a module ID is a Node.js built-in
|
|
92
|
+
*/
|
|
93
|
+
private isNodeBuiltin;
|
|
94
|
+
/**
|
|
95
|
+
* Gets the TSDown configuration content as a string
|
|
96
|
+
*/
|
|
97
|
+
private getTsdownConfigContent;
|
|
98
|
+
/**
|
|
99
|
+
* Gets the path to the .dxtignore template file in assets
|
|
100
|
+
*/
|
|
101
|
+
private getDxtIgnoreTemplatePath;
|
|
102
|
+
/**
|
|
103
|
+
* Sets up DXT package files (manifest.json) in the dxt output directory
|
|
104
|
+
*/
|
|
105
|
+
private setupDxtPackageFiles;
|
|
106
|
+
/**
|
|
107
|
+
* Manually copy logo since TSDown's copy option doesn't work programmatically
|
|
108
|
+
*/
|
|
109
|
+
private copyLogoManually;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=DxtGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DxtGenerator.d.ts","sourceRoot":"","sources":["../../src/dxt/DxtGenerator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAIjD;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,iBAAiB,CAAM;gBAEnB,iBAAiB,EAAE,GAAG;IAIlC;;OAEG;IACH,OAAO,CAAC,WAAW;IAiBnB;;OAEG;IACU,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,WAAW,CAAC;IAmC7G;;OAEG;YACW,2BAA2B;IA2EzC;;;OAGG;IACU,kBAAkB,CAAC,aAAa,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA0FvF;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAoB3B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IA8B5B,OAAO,CAAC,sBAAsB;IA8D9B,OAAO,CAAC,iBAAiB;IAiFzB,OAAO,CAAC,mBAAmB;IAuC3B,OAAO,CAAC,kBAAkB;IAqC1B,OAAO,CAAC,oBAAoB;IA8D5B;;OAEG;IACH,OAAO,CAAC,eAAe;IA4CvB;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAqF/B,OAAO,CAAC,eAAe;IAkGvB;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAwBnC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAc7B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IA8DhC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAO/B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAUxB;;;OAGG;YACW,eAAe;IAqF7B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA2D9B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAmJ9B;;OAEG;YACW,kBAAkB;IAuHhC;;OAEG;YACW,2BAA2B;IAiIzC;;OAEG;IACH,OAAO,CAAC,aAAa;IAarB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAyD9B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IA4BhC;;OAEG;YACW,oBAAoB;IA8JlC;;OAEG;YACW,gBAAgB;CAgC/B"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { ArgParserBase, ArgParserError, type IParseOptions } from "./core/ArgParserBase";
|
|
2
|
+
export { ArgParser, type McpTransportConfig, type McpSubCommandOptions, type DxtServerInfo, type McpServerOptions, type WithMcpOptions, type ArgParserWithMcpOptions, type McpToolConfig, type ToolConfig } from "./core/ArgParser";
|
|
3
|
+
export { ArgParserMcp, createMcpArgParser } from "./mcp/ArgParserMcp";
|
|
4
|
+
export { zodFlagSchema, type IFlagCore, type IFlag, type ProcessedFlagCore, type ProcessedFlag, type TParsedArgsTypeFromFlagDef, type FlagsArray, type ResolveType, type ExtractFlagType, type TParsedArgs, type IHandlerContext, type MainHandler, type ISubCommand, type ArgParserInstance, getJsonSchemaTypeFromFlag, OutputSchemaPatterns, type OutputSchemaPatternName, type OutputSchemaConfig, createOutputSchema, type ArgParserOptions, type ArgParserBehaviorOptions, } from "./core/types";
|
|
5
|
+
export { generateMcpToolsFromArgParser, type IMcpToolStructure, type GenerateMcpToolsOptions, type IParseExecutionResult, type SimplifiedToolResponse, extractSimplifiedResponse, convertFlagToJsonSchemaProperty, convertFlagsToJsonSchema, convertFlagsToZodSchema, createMcpSuccessResponse, createMcpErrorResponse, type McpResponse, } from "./mcp/mcp-integration";
|
|
6
|
+
export { type IConfigPlugin, ConfigPlugin, JsonConfigPlugin, EnvConfigPlugin, ConfigPluginRegistry, globalConfigPluginRegistry, enableOptionalConfigPlugins, enableOptionalConfigPluginsAsync, enableConfigPlugins, TomlConfigPlugin, createTomlPlugin, createTomlPluginAsync, YamlConfigPlugin, createYamlPlugin, createYamlPluginAsync, } from "./config/plugins";
|
|
7
|
+
export { ArgParserFuzzyTester } from "./testing/fuzzy-tester";
|
|
8
|
+
export type { FuzzyTestOptions, TestResult, FuzzyTestReport } from "./testing/fuzzy-tester";
|
|
9
|
+
export { default as SimpleChalk } from "@alcyone-labs/simple-chalk";
|
|
10
|
+
export { Logger, logger, createMcpLogger, createCliLogger, type LogLevel, type LoggerConfig } from "@alcyone-labs/simple-mcp-logger";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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,kBAAkB,CAAC;AAE1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG5F,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAGpE,OAAO,EACL,MAAM,EACN,MAAM,EACN,eAAe,EACf,eAAe,EACf,KAAK,QAAQ,EACb,KAAK,YAAY,EAClB,MAAM,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ArgParser } from "../core/ArgParser";
|
|
2
|
+
import type { IArgParserParams } from "../core/ArgParserBase";
|
|
3
|
+
import type { IFlag } from "../core/types";
|
|
4
|
+
/**
|
|
5
|
+
* MCP-optimized ArgParser that excludes config file functionality
|
|
6
|
+
* This version doesn't load any config plugins, making it suitable for
|
|
7
|
+
* autonomous builds where TOML/YAML dependencies cause bundling issues.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ArgParserMcp<THandlerReturn = any> extends ArgParser<THandlerReturn> {
|
|
10
|
+
constructor(params?: IArgParserParams<THandlerReturn>, initialFlags?: IFlag[]);
|
|
11
|
+
/**
|
|
12
|
+
* Override parse to skip config file processing
|
|
13
|
+
*/
|
|
14
|
+
parse(processArgs: string[], options?: any): any;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Convenience function to create MCP-optimized ArgParser
|
|
18
|
+
* This is the recommended way to create ArgParser instances for MCP servers
|
|
19
|
+
*/
|
|
20
|
+
export declare function createMcpArgParser<THandlerReturn = any>(params?: IArgParserParams<THandlerReturn>, initialFlags?: IFlag[]): ArgParserMcp<THandlerReturn>;
|
|
21
|
+
//# sourceMappingURL=ArgParserMcp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArgParserMcp.d.ts","sourceRoot":"","sources":["../../src/mcp/ArgParserMcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE3C;;;;GAIG;AACH,qBAAa,YAAY,CAAC,cAAc,GAAG,GAAG,CAAE,SAAQ,SAAS,CAAC,cAAc,CAAC;gBACnE,MAAM,CAAC,EAAE,gBAAgB,CAAC,cAAc,CAAC,EAAE,YAAY,CAAC,EAAE,KAAK,EAAE;IAS7E;;OAEG;IACI,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,GAAG;CAUxD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,GAAG,GAAG,EACrD,MAAM,CAAC,EAAE,gBAAgB,CAAC,cAAc,CAAC,EACzC,YAAY,CAAC,EAAE,KAAK,EAAE,GACrB,YAAY,CAAC,cAAc,CAAC,CAE9B"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { ZodTypeAny } from "zod";
|
|
2
|
+
import { ArgParserBase } from "../core/ArgParserBase";
|
|
3
|
+
import type { IFlag, ProcessedFlag, TParsedArgs } from "../core/types";
|
|
4
|
+
/**
|
|
5
|
+
* Standard MCP response format
|
|
6
|
+
*/
|
|
7
|
+
export interface McpResponse {
|
|
8
|
+
content: Array<{
|
|
9
|
+
type: "text";
|
|
10
|
+
text: string;
|
|
11
|
+
}>;
|
|
12
|
+
isError?: boolean;
|
|
13
|
+
structuredContent?: any;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Create a standardized MCP success response
|
|
17
|
+
*/
|
|
18
|
+
export declare function createMcpSuccessResponse(data: any): McpResponse;
|
|
19
|
+
/**
|
|
20
|
+
* Create a standardized MCP error response
|
|
21
|
+
*/
|
|
22
|
+
export declare function createMcpErrorResponse(error: string | Error): McpResponse;
|
|
23
|
+
/**
|
|
24
|
+
* Convert a single ArgParser flag to JSON Schema property
|
|
25
|
+
*/
|
|
26
|
+
export declare function convertFlagToJsonSchemaProperty(flag: IFlag | ProcessedFlag): {
|
|
27
|
+
property: any;
|
|
28
|
+
isRequired: boolean;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Convert ArgParser flags to MCP JSON Schema
|
|
32
|
+
*/
|
|
33
|
+
export declare function convertFlagsToJsonSchema(flags: readonly (IFlag | ProcessedFlag)[]): {
|
|
34
|
+
type: "object";
|
|
35
|
+
properties: Record<string, any>;
|
|
36
|
+
required: string[];
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Convert ArgParser flags to Zod schema for MCP tools
|
|
40
|
+
*/
|
|
41
|
+
export declare function convertFlagsToZodSchema(flags: readonly (IFlag | ProcessedFlag)[]): ZodTypeAny;
|
|
42
|
+
/**
|
|
43
|
+
* Simplified response format for testing and validation
|
|
44
|
+
*/
|
|
45
|
+
export interface SimplifiedToolResponse {
|
|
46
|
+
success: boolean;
|
|
47
|
+
data?: any;
|
|
48
|
+
error?: string;
|
|
49
|
+
message?: string;
|
|
50
|
+
exitCode?: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Extract simplified response from MCP protocol response
|
|
54
|
+
*/
|
|
55
|
+
export declare function extractSimplifiedResponse(mcpResponse: any): SimplifiedToolResponse;
|
|
56
|
+
export interface IMcpToolStructure {
|
|
57
|
+
name: string;
|
|
58
|
+
description?: string;
|
|
59
|
+
inputSchema: ZodTypeAny;
|
|
60
|
+
outputSchema?: ZodTypeAny;
|
|
61
|
+
execute: (args: any) => Promise<any>;
|
|
62
|
+
executeForTesting?: (args: any) => Promise<SimplifiedToolResponse>;
|
|
63
|
+
}
|
|
64
|
+
export interface GenerateMcpToolsOptions {
|
|
65
|
+
outputSchemaMap?: Record<string, ZodTypeAny>;
|
|
66
|
+
defaultOutputSchema?: ZodTypeAny;
|
|
67
|
+
/** Automatically generate output schemas for tools that don't have explicit schemas */
|
|
68
|
+
autoGenerateOutputSchema?: boolean | keyof typeof import("../core/types").OutputSchemaPatterns;
|
|
69
|
+
generateToolName?: (commandPath: string[], appName?: string) => string;
|
|
70
|
+
includeSubCommands?: boolean;
|
|
71
|
+
toolNamePrefix?: string;
|
|
72
|
+
toolNameSuffix?: string;
|
|
73
|
+
}
|
|
74
|
+
interface ISpecialParseResultProps {
|
|
75
|
+
$commandChain?: string[];
|
|
76
|
+
$error?: {
|
|
77
|
+
type: string;
|
|
78
|
+
message: string;
|
|
79
|
+
details?: any;
|
|
80
|
+
};
|
|
81
|
+
handlerResponse?: any;
|
|
82
|
+
}
|
|
83
|
+
export type IParseExecutionResult = TParsedArgs<ProcessedFlag[]> & ISpecialParseResultProps;
|
|
84
|
+
export declare function generateMcpToolsFromArgParser(rootParser: ArgParserBase, options?: GenerateMcpToolsOptions): IMcpToolStructure[];
|
|
85
|
+
export {};
|
|
86
|
+
//# sourceMappingURL=mcp-integration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-integration.d.ts","sourceRoot":"","sources":["../../src/mcp/mcp-integration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,KAAK,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EACV,KAAK,EAEL,aAAa,EACb,WAAW,EACZ,MAAM,eAAe,CAAC;AASvB;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iBAAiB,CAAC,EAAE,GAAG,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,GAAG,GAAG,WAAW,CAS/D;AAED;;GAEG;AACH,wBAAgB,s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