@lushly-dev/afd-server 1.0.0 → 2.1.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 +297 -14
- package/dist/bootstrap/afd-context.d.ts +11 -2
- package/dist/bootstrap/afd-context.d.ts.map +1 -1
- package/dist/bootstrap/afd-context.js +56 -11
- package/dist/bootstrap/afd-context.js.map +1 -1
- package/dist/bootstrap/afd-docs.d.ts +6 -3
- package/dist/bootstrap/afd-docs.d.ts.map +1 -1
- package/dist/bootstrap/afd-docs.js +27 -9
- package/dist/bootstrap/afd-docs.js.map +1 -1
- package/dist/bootstrap/afd-help.d.ts +11 -3
- package/dist/bootstrap/afd-help.d.ts.map +1 -1
- package/dist/bootstrap/afd-help.js +15 -9
- package/dist/bootstrap/afd-help.js.map +1 -1
- package/dist/bootstrap/afd-schema.d.ts +8 -4
- package/dist/bootstrap/afd-schema.d.ts.map +1 -1
- package/dist/bootstrap/afd-schema.js +55 -42
- package/dist/bootstrap/afd-schema.js.map +1 -1
- package/dist/bootstrap/described-command.d.ts +35 -0
- package/dist/bootstrap/described-command.d.ts.map +1 -0
- package/dist/bootstrap/described-command.js +12 -0
- package/dist/bootstrap/described-command.js.map +1 -0
- package/dist/bootstrap/index.d.ts +1 -0
- package/dist/bootstrap/index.d.ts.map +1 -1
- package/dist/bootstrap/index.js.map +1 -1
- package/dist/bootstrap/json-schema-to-ts.d.ts +27 -0
- package/dist/bootstrap/json-schema-to-ts.d.ts.map +1 -0
- package/dist/bootstrap/json-schema-to-ts.js +154 -0
- package/dist/bootstrap/json-schema-to-ts.js.map +1 -0
- package/dist/bootstrap/registry.d.ts +17 -6
- package/dist/bootstrap/registry.d.ts.map +1 -1
- package/dist/bootstrap/registry.js +29 -5
- package/dist/bootstrap/registry.js.map +1 -1
- package/dist/command-names.d.ts +19 -0
- package/dist/command-names.d.ts.map +1 -0
- package/dist/command-names.js +33 -0
- package/dist/command-names.js.map +1 -0
- package/dist/command-routing.d.ts +47 -0
- package/dist/command-routing.d.ts.map +1 -0
- package/dist/command-routing.js +75 -0
- package/dist/command-routing.js.map +1 -0
- package/dist/context-scope.d.ts +26 -0
- package/dist/context-scope.d.ts.map +1 -0
- package/dist/context-scope.js +31 -0
- package/dist/context-scope.js.map +1 -0
- package/dist/define.d.ts +42 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +41 -0
- package/dist/define.js.map +1 -0
- package/dist/direct-registry.d.ts +104 -0
- package/dist/direct-registry.d.ts.map +1 -0
- package/dist/direct-registry.js +103 -0
- package/dist/direct-registry.js.map +1 -0
- package/dist/execution.d.ts +9 -0
- package/dist/execution.d.ts.map +1 -1
- package/dist/execution.js +105 -321
- package/dist/execution.js.map +1 -1
- package/dist/http-handler.d.ts +24 -17
- package/dist/http-handler.d.ts.map +1 -1
- package/dist/http-handler.js +283 -252
- package/dist/http-handler.js.map +1 -1
- package/dist/http-security.d.ts +23 -0
- package/dist/http-security.d.ts.map +1 -0
- package/dist/http-security.js +101 -0
- package/dist/http-security.js.map +1 -0
- package/dist/http-sessions.d.ts +33 -0
- package/dist/http-sessions.d.ts.map +1 -0
- package/dist/http-sessions.js +65 -0
- package/dist/http-sessions.js.map +1 -0
- package/dist/http-sse.d.ts +30 -0
- package/dist/http-sse.d.ts.map +1 -0
- package/dist/http-sse.js +70 -0
- package/dist/http-sse.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/json-rpc.d.ts +56 -0
- package/dist/json-rpc.d.ts.map +1 -0
- package/dist/json-rpc.js +73 -0
- package/dist/json-rpc.js.map +1 -0
- package/dist/lazy-tools.d.ts +3 -12
- package/dist/lazy-tools.d.ts.map +1 -1
- package/dist/lazy-tools.js +10 -14
- package/dist/lazy-tools.js.map +1 -1
- package/dist/meta-tools.d.ts +116 -0
- package/dist/meta-tools.d.ts.map +1 -0
- package/dist/meta-tools.js +154 -0
- package/dist/meta-tools.js.map +1 -0
- package/dist/middleware.d.ts +34 -7
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +82 -40
- package/dist/middleware.js.map +1 -1
- package/dist/schema.d.ts +34 -6
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +22 -13
- package/dist/schema.js.map +1 -1
- package/dist/server-types.d.ts +90 -14
- package/dist/server-types.d.ts.map +1 -1
- package/dist/server-types.js.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +103 -21
- package/dist/server.js.map +1 -1
- package/dist/tool-router.d.ts +6 -5
- package/dist/tool-router.d.ts.map +1 -1
- package/dist/tool-router.js +105 -139
- package/dist/tool-router.js.map +1 -1
- package/dist/tools.d.ts +10 -420
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +82 -208
- package/dist/tools.js.map +1 -1
- package/package.json +13 -8
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generate markdown documentation for commands.
|
|
5
5
|
*/
|
|
6
|
-
import type { CommandDefinition } from '@lushly-dev/afd-core';
|
|
7
6
|
import { z } from 'zod';
|
|
7
|
+
import { type ZodCommandDefinition } from '../schema.js';
|
|
8
|
+
import { type GetDescribedCommands } from './described-command.js';
|
|
8
9
|
declare const inputSchema: z.ZodObject<{
|
|
9
10
|
command: z.ZodOptional<z.ZodString>;
|
|
10
11
|
}, z.core.$strip>;
|
|
11
|
-
type InputType = z.infer<typeof inputSchema>;
|
|
12
12
|
interface DocsOutput {
|
|
13
13
|
markdown: string;
|
|
14
14
|
commandCount: number;
|
|
@@ -16,8 +16,11 @@ interface DocsOutput {
|
|
|
16
16
|
/**
|
|
17
17
|
* Create the afd-docs bootstrap command.
|
|
18
18
|
*
|
|
19
|
+
* Documents only MCP-exposed commands. Parameters come from `parameters`, or from
|
|
20
|
+
* `jsonSchema` for commands built with `defineCommand`.
|
|
21
|
+
*
|
|
19
22
|
* @param getCommands - Function to get all registered commands
|
|
20
23
|
*/
|
|
21
|
-
export declare function createAfdDocsCommand(getCommands:
|
|
24
|
+
export declare function createAfdDocsCommand(getCommands: GetDescribedCommands): ZodCommandDefinition<typeof inputSchema, DocsOutput>;
|
|
22
25
|
export {};
|
|
23
26
|
//# sourceMappingURL=afd-docs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"afd-docs.d.ts","sourceRoot":"","sources":["../../src/bootstrap/afd-docs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"afd-docs.d.ts","sourceRoot":"","sources":["../../src/bootstrap/afd-docs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAyC,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAChG,OAAO,EAGN,KAAK,oBAAoB,EACzB,MAAM,wBAAwB,CAAC;AAEhC,QAAA,MAAM,WAAW;;iBAEf,CAAC;AAEH,UAAU,UAAU;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,oBAAoB,GAC/B,oBAAoB,CAAC,OAAO,WAAW,EAAE,UAAU,CAAC,CAgHtD"}
|
|
@@ -5,27 +5,31 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { success } from '@lushly-dev/afd-core';
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
+
import { defineCommand, jsonSchemaToParameters } from '../schema.js';
|
|
9
|
+
import { describableCommands, } from './described-command.js';
|
|
8
10
|
const inputSchema = z.object({
|
|
9
11
|
command: z.string().optional().describe('Specific command name, or omit for all'),
|
|
10
12
|
});
|
|
11
13
|
/**
|
|
12
14
|
* Create the afd-docs bootstrap command.
|
|
13
15
|
*
|
|
16
|
+
* Documents only MCP-exposed commands. Parameters come from `parameters`, or from
|
|
17
|
+
* `jsonSchema` for commands built with `defineCommand`.
|
|
18
|
+
*
|
|
14
19
|
* @param getCommands - Function to get all registered commands
|
|
15
20
|
*/
|
|
16
21
|
export function createAfdDocsCommand(getCommands) {
|
|
17
|
-
return {
|
|
22
|
+
return defineCommand({
|
|
18
23
|
name: 'afd-docs',
|
|
19
24
|
description: 'Get detailed documentation for commands',
|
|
20
25
|
category: 'bootstrap',
|
|
21
26
|
tags: ['bootstrap', 'read', 'safe'],
|
|
22
27
|
mutation: false,
|
|
23
28
|
version: '1.0.0',
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const allCommands = getCommands();
|
|
29
|
+
expose: { mcp: true },
|
|
30
|
+
input: inputSchema,
|
|
31
|
+
async handler(input, context) {
|
|
32
|
+
const allCommands = describableCommands(getCommands, context);
|
|
29
33
|
// Filter to specific command if provided
|
|
30
34
|
const commands = input.command
|
|
31
35
|
? allCommands.filter((cmd) => cmd.name === input.command)
|
|
@@ -64,13 +68,27 @@ export function createAfdDocsCommand(getCommands) {
|
|
|
64
68
|
lines.push(`**Mutation:** ${cmd.mutation ? 'Yes' : 'No (read-only)'}`);
|
|
65
69
|
lines.push('');
|
|
66
70
|
}
|
|
71
|
+
// Safety metadata
|
|
72
|
+
if (cmd.destructive !== undefined) {
|
|
73
|
+
lines.push(`**Destructive:** ${cmd.destructive ? 'Yes' : 'No'}`);
|
|
74
|
+
lines.push('');
|
|
75
|
+
}
|
|
76
|
+
if (cmd.confirmPrompt) {
|
|
77
|
+
lines.push(`**Confirmation prompt:** ${cmd.confirmPrompt}`);
|
|
78
|
+
lines.push('');
|
|
79
|
+
}
|
|
80
|
+
if (cmd.undoable !== undefined) {
|
|
81
|
+
lines.push(`**Undoable:** ${cmd.undoable ? 'Yes' : 'No'}`);
|
|
82
|
+
lines.push('');
|
|
83
|
+
}
|
|
67
84
|
// Parameters
|
|
68
|
-
|
|
85
|
+
const parameters = cmd.parameters ?? (cmd.jsonSchema ? jsonSchemaToParameters(cmd.jsonSchema) : []);
|
|
86
|
+
if (parameters.length > 0) {
|
|
69
87
|
lines.push('**Parameters:**');
|
|
70
88
|
lines.push('');
|
|
71
89
|
lines.push('| Name | Type | Required | Description |');
|
|
72
90
|
lines.push('|------|------|----------|-------------|');
|
|
73
|
-
for (const param of
|
|
91
|
+
for (const param of parameters) {
|
|
74
92
|
const required = param.required ? 'Yes' : 'No';
|
|
75
93
|
lines.push(`| ${param.name} | ${param.type} | ${required} | ${param.description || ''} |`);
|
|
76
94
|
}
|
|
@@ -88,6 +106,6 @@ export function createAfdDocsCommand(getCommands) {
|
|
|
88
106
|
confidence: 1.0,
|
|
89
107
|
});
|
|
90
108
|
},
|
|
91
|
-
};
|
|
109
|
+
});
|
|
92
110
|
}
|
|
93
111
|
//# sourceMappingURL=afd-docs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"afd-docs.js","sourceRoot":"","sources":["../../src/bootstrap/afd-docs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"afd-docs.js","sourceRoot":"","sources":["../../src/bootstrap/afd-docs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAA6B,MAAM,cAAc,CAAC;AAChG,OAAO,EAEN,mBAAmB,GAEnB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wCAAwC,CAAC;CACjF,CAAC,CAAC;AAOH;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CACnC,WAAiC;IAEjC,OAAO,aAAa,CAAC;QACpB,IAAI,EA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,CAAC,0CAA0C,CAAC,CAAC;wBACvD,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;4BAChC,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;4BAC/C,KAAK,CAAC,IAAI,CACT,KAAK,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,IAAI,MAAM,QAAQ,MAAM,KAAK,CAAC,WAAW,IAAI,EAAE,IAAI,CAC9E,CAAC;wBACH,CAAC;wBACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;oBAChB,CAAC;oBAED,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBAClB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAChB,CAAC;YACF,CAAC;YAED,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAElC,OAAO,OAAO,CACb,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,CAAC,MAAM,EAAE,EAC3C;gBACC,SAAS,EAAE,KAAK,CAAC,OAAO;oBACvB,CAAC,CAAC,gCAAgC,KAAK,CAAC,OAAO,GAAG;oBAClD,CAAC,CAAC,+BAA+B,QAAQ,CAAC,MAAM,WAAW;gBAC5D,UAAU,EAAE,GAAG;aACf,CACD,CAAC;QACH,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* List all available commands with tags and grouping.
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
6
|
+
import type { CommandExample } from '@lushly-dev/afd-core';
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
+
import { type ZodCommandDefinition } from '../schema.js';
|
|
9
|
+
import { type GetDescribedCommands } from './described-command.js';
|
|
8
10
|
declare const inputSchema: z.ZodObject<{
|
|
9
11
|
filter: z.ZodOptional<z.ZodString>;
|
|
10
12
|
format: z.ZodDefault<z.ZodEnum<{
|
|
@@ -12,17 +14,20 @@ declare const inputSchema: z.ZodObject<{
|
|
|
12
14
|
full: "full";
|
|
13
15
|
}>>;
|
|
14
16
|
}, z.core.$strip>;
|
|
15
|
-
type InputType = z.infer<typeof inputSchema>;
|
|
16
17
|
interface CommandInfo {
|
|
17
18
|
name: string;
|
|
18
19
|
description: string;
|
|
19
20
|
category?: string;
|
|
20
21
|
tags?: string[];
|
|
21
22
|
mutation?: boolean;
|
|
23
|
+
destructive?: boolean;
|
|
24
|
+
undoable?: boolean;
|
|
22
25
|
requires?: string[];
|
|
23
26
|
examples?: CommandExample[];
|
|
24
27
|
}
|
|
25
28
|
interface HelpOutput {
|
|
29
|
+
/** The AFD contract version this server implements (`AFD_CONTRACT_VERSION`). */
|
|
30
|
+
contractVersion: string;
|
|
26
31
|
commands: CommandInfo[];
|
|
27
32
|
total: number;
|
|
28
33
|
filtered: boolean;
|
|
@@ -31,8 +36,11 @@ interface HelpOutput {
|
|
|
31
36
|
/**
|
|
32
37
|
* Create the afd-help bootstrap command.
|
|
33
38
|
*
|
|
39
|
+
* Lists only MCP-exposed commands. `requires` is always included when set.
|
|
40
|
+
* The output also carries the AFD contract version the server implements.
|
|
41
|
+
*
|
|
34
42
|
* @param getCommands - Function to get all registered commands
|
|
35
43
|
*/
|
|
36
|
-
export declare function createAfdHelpCommand(getCommands:
|
|
44
|
+
export declare function createAfdHelpCommand(getCommands: GetDescribedCommands): ZodCommandDefinition<typeof inputSchema, HelpOutput>;
|
|
37
45
|
export {};
|
|
38
46
|
//# sourceMappingURL=afd-help.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"afd-help.d.ts","sourceRoot":"","sources":["../../src/bootstrap/afd-help.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"afd-help.d.ts","sourceRoot":"","sources":["../../src/bootstrap/afd-help.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAuB,KAAK,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAExF,QAAA,MAAM,WAAW;;;;;;iBAGf,CAAC;AAEH,UAAU,WAAW;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;CAC5B;AAED,UAAU,UAAU;IACnB,gFAAgF;IAChF,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;CACjD;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,oBAAoB,GAC/B,oBAAoB,CAAC,OAAO,WAAW,EAAE,UAAU,CAAC,CA6EtD"}
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* List all available commands with tags and grouping.
|
|
5
5
|
*/
|
|
6
|
-
import { success } from '@lushly-dev/afd-core';
|
|
6
|
+
import { AFD_CONTRACT_VERSION, success } from '@lushly-dev/afd-core';
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
+
import { defineCommand } from '../schema.js';
|
|
9
|
+
import { describableCommands } from './described-command.js';
|
|
8
10
|
const inputSchema = z.object({
|
|
9
11
|
filter: z.string().optional().describe('Tag filter: e.g., "todo" or "read"'),
|
|
10
12
|
format: z.enum(['brief', 'full']).default('brief').describe('Output format'),
|
|
@@ -12,22 +14,23 @@ const inputSchema = z.object({
|
|
|
12
14
|
/**
|
|
13
15
|
* Create the afd-help bootstrap command.
|
|
14
16
|
*
|
|
17
|
+
* Lists only MCP-exposed commands. `requires` is always included when set.
|
|
18
|
+
* The output also carries the AFD contract version the server implements.
|
|
19
|
+
*
|
|
15
20
|
* @param getCommands - Function to get all registered commands
|
|
16
21
|
*/
|
|
17
22
|
export function createAfdHelpCommand(getCommands) {
|
|
18
|
-
return {
|
|
23
|
+
return defineCommand({
|
|
19
24
|
name: 'afd-help',
|
|
20
25
|
description: 'List all available commands with tags and grouping',
|
|
21
26
|
category: 'bootstrap',
|
|
22
27
|
tags: ['bootstrap', 'read', 'safe'],
|
|
23
28
|
mutation: false,
|
|
24
29
|
version: '1.0.0',
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
async handler(input) {
|
|
30
|
-
const allCommands = getCommands();
|
|
30
|
+
expose: { mcp: true },
|
|
31
|
+
input: inputSchema,
|
|
32
|
+
async handler(input, context) {
|
|
33
|
+
const allCommands = describableCommands(getCommands, context);
|
|
31
34
|
// Filter by tag if provided
|
|
32
35
|
let commands = allCommands;
|
|
33
36
|
const filtered = !!input.filter;
|
|
@@ -50,6 +53,8 @@ export function createAfdHelpCommand(getCommands) {
|
|
|
50
53
|
info.category = cmd.category;
|
|
51
54
|
info.tags = cmd.tags;
|
|
52
55
|
info.mutation = cmd.mutation;
|
|
56
|
+
info.destructive = cmd.destructive;
|
|
57
|
+
info.undoable = cmd.undoable;
|
|
53
58
|
info.examples = cmd.examples;
|
|
54
59
|
}
|
|
55
60
|
return info;
|
|
@@ -64,6 +69,7 @@ export function createAfdHelpCommand(getCommands) {
|
|
|
64
69
|
groupedByCategory[category].push(cmd);
|
|
65
70
|
}
|
|
66
71
|
const output = {
|
|
72
|
+
contractVersion: AFD_CONTRACT_VERSION,
|
|
67
73
|
commands: commandInfos,
|
|
68
74
|
total: commandInfos.length,
|
|
69
75
|
filtered,
|
|
@@ -76,6 +82,6 @@ export function createAfdHelpCommand(getCommands) {
|
|
|
76
82
|
confidence: 1.0,
|
|
77
83
|
});
|
|
78
84
|
},
|
|
79
|
-
};
|
|
85
|
+
});
|
|
80
86
|
}
|
|
81
87
|
//# sourceMappingURL=afd-help.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"afd-help.js","sourceRoot":"","sources":["../../src/bootstrap/afd-help.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"afd-help.js","sourceRoot":"","sources":["../../src/bootstrap/afd-help.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAA6B,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAA6B,MAAM,wBAAwB,CAAC;AAExF,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;IAC5E,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC;CAC5E,CAAC,CAAC;AAuBH;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CACnC,WAAiC;IAEjC,OAAO,a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CAAC,CAAC,eAAe,YAAY,CAAC,MAAM,qBAAqB;gBAC1D,UAAU,EAAE,GAAG;aACf,CAAC,CAAC;QACJ,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview afd-schema bootstrap command
|
|
3
3
|
*
|
|
4
|
-
* Export
|
|
4
|
+
* Export input schemas for all commands as JSON Schema or TypeScript types.
|
|
5
5
|
*/
|
|
6
|
-
import type { CommandDefinition } from '@lushly-dev/afd-core';
|
|
7
6
|
import { z } from 'zod';
|
|
7
|
+
import { type ZodCommandDefinition } from '../schema.js';
|
|
8
|
+
import { type DescribedCommand, type GetDescribedCommands } from './described-command.js';
|
|
8
9
|
declare const inputSchema: z.ZodObject<{
|
|
9
10
|
format: z.ZodDefault<z.ZodEnum<{
|
|
10
11
|
json: "json";
|
|
11
12
|
typescript: "typescript";
|
|
12
13
|
}>>;
|
|
13
14
|
}, z.core.$strip>;
|
|
14
|
-
type InputType = z.infer<typeof inputSchema>;
|
|
15
15
|
interface SchemaInfo {
|
|
16
16
|
name: string;
|
|
17
17
|
description: string;
|
|
@@ -21,13 +21,17 @@ interface SchemaOutput {
|
|
|
21
21
|
schemas: SchemaInfo[];
|
|
22
22
|
count: number;
|
|
23
23
|
format: 'json' | 'typescript';
|
|
24
|
+
/** With `format: 'typescript'`: one module declaring an input type per command. */
|
|
25
|
+
typescript?: string;
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
28
|
* Create the afd-schema bootstrap command.
|
|
27
29
|
*
|
|
30
|
+
* Exports only MCP-exposed commands.
|
|
31
|
+
*
|
|
28
32
|
* @param getCommands - Function to get all registered commands
|
|
29
33
|
* @param getJsonSchema - Function to get JSON schema for a command
|
|
30
34
|
*/
|
|
31
|
-
export declare function createAfdSchemaCommand(getCommands:
|
|
35
|
+
export declare function createAfdSchemaCommand(getCommands: GetDescribedCommands, getJsonSchema?: (cmd: DescribedCommand) => Record<string, unknown>): ZodCommandDefinition<typeof inputSchema, SchemaOutput>;
|
|
32
36
|
export {};
|
|
33
37
|
//# sourceMappingURL=afd-schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"afd-schema.d.ts","sourceRoot":"","sources":["../../src/bootstrap/afd-schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"afd-schema.d.ts","sourceRoot":"","sources":["../../src/bootstrap/afd-schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EACN,KAAK,gBAAgB,EAErB,KAAK,oBAAoB,EACzB,MAAM,wBAAwB,CAAC;AAGhC,QAAA,MAAM,WAAW;;;;;iBAKf,CAAC;AAEH,UAAU,UAAU;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED,UAAU,YAAY;IACrB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,YAAY,CAAC;IAC9B,mFAAmF;IACnF,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AA2BD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACrC,WAAW,EAAE,oBAAoB,EACjC,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChE,oBAAoB,CAAC,OAAO,WAAW,EAAE,YAAY,CAAC,CA8CxD"}
|
|
@@ -1,78 +1,91 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview afd-schema bootstrap command
|
|
3
3
|
*
|
|
4
|
-
* Export
|
|
4
|
+
* Export input schemas for all commands as JSON Schema or TypeScript types.
|
|
5
5
|
*/
|
|
6
6
|
import { success } from '@lushly-dev/afd-core';
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
+
import { defineCommand } from '../schema.js';
|
|
9
|
+
import { describableCommands, } from './described-command.js';
|
|
10
|
+
import { generateInputTypes } from './json-schema-to-ts.js';
|
|
8
11
|
const inputSchema = z.object({
|
|
9
|
-
format: z
|
|
12
|
+
format: z
|
|
13
|
+
.enum(['json', 'typescript'])
|
|
14
|
+
.default('json')
|
|
15
|
+
.describe('Output format: JSON Schemas, or TypeScript input types in addition'),
|
|
10
16
|
});
|
|
17
|
+
/** Build a basic JSON Schema from core `parameters`. */
|
|
18
|
+
function schemaFromParameters(cmd) {
|
|
19
|
+
const parameters = cmd.parameters ?? [];
|
|
20
|
+
return {
|
|
21
|
+
type: 'object',
|
|
22
|
+
properties: Object.fromEntries(parameters.map((p) => [
|
|
23
|
+
p.name,
|
|
24
|
+
{
|
|
25
|
+
type: p.type === 'string'
|
|
26
|
+
? 'string'
|
|
27
|
+
: p.type === 'number'
|
|
28
|
+
? 'number'
|
|
29
|
+
: p.type === 'boolean'
|
|
30
|
+
? 'boolean'
|
|
31
|
+
: 'any',
|
|
32
|
+
description: p.description,
|
|
33
|
+
},
|
|
34
|
+
])),
|
|
35
|
+
required: parameters.filter((p) => p.required).map((p) => p.name),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
11
38
|
/**
|
|
12
39
|
* Create the afd-schema bootstrap command.
|
|
13
40
|
*
|
|
41
|
+
* Exports only MCP-exposed commands.
|
|
42
|
+
*
|
|
14
43
|
* @param getCommands - Function to get all registered commands
|
|
15
44
|
* @param getJsonSchema - Function to get JSON schema for a command
|
|
16
45
|
*/
|
|
17
46
|
export function createAfdSchemaCommand(getCommands, getJsonSchema) {
|
|
18
|
-
return {
|
|
47
|
+
return defineCommand({
|
|
19
48
|
name: 'afd-schema',
|
|
20
|
-
description: 'Export
|
|
49
|
+
description: 'Export input schemas for all commands as JSON Schema or TypeScript types',
|
|
21
50
|
category: 'bootstrap',
|
|
22
51
|
tags: ['bootstrap', 'read', 'safe'],
|
|
23
52
|
mutation: false,
|
|
24
53
|
version: '1.0.0',
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
54
|
+
expose: { mcp: true },
|
|
55
|
+
input: inputSchema,
|
|
56
|
+
async handler(input, context) {
|
|
57
|
+
const commands = describableCommands(getCommands, context);
|
|
28
58
|
const schemas = commands.map((cmd) => {
|
|
29
|
-
|
|
30
|
-
let schema = {};
|
|
59
|
+
let schema;
|
|
31
60
|
if (getJsonSchema) {
|
|
32
61
|
schema = getJsonSchema(cmd);
|
|
33
62
|
}
|
|
34
|
-
else if (
|
|
35
|
-
schema = cmd.jsonSchema;
|
|
63
|
+
else if (cmd.jsonSchema) {
|
|
64
|
+
schema = { ...cmd.jsonSchema };
|
|
36
65
|
}
|
|
37
|
-
else
|
|
38
|
-
|
|
39
|
-
schema = {
|
|
40
|
-
type: 'object',
|
|
41
|
-
properties: Object.fromEntries(cmd.parameters.map((p) => [
|
|
42
|
-
p.name,
|
|
43
|
-
{
|
|
44
|
-
type: p.type === 'string'
|
|
45
|
-
? 'string'
|
|
46
|
-
: p.type === 'number'
|
|
47
|
-
? 'number'
|
|
48
|
-
: p.type === 'boolean'
|
|
49
|
-
? 'boolean'
|
|
50
|
-
: 'any',
|
|
51
|
-
description: p.description,
|
|
52
|
-
},
|
|
53
|
-
])),
|
|
54
|
-
required: cmd.parameters.filter((p) => p.required).map((p) => p.name),
|
|
55
|
-
};
|
|
66
|
+
else {
|
|
67
|
+
schema = schemaFromParameters(cmd);
|
|
56
68
|
}
|
|
57
|
-
return {
|
|
58
|
-
name: cmd.name,
|
|
59
|
-
description: cmd.description,
|
|
60
|
-
inputSchema: schema,
|
|
61
|
-
};
|
|
69
|
+
return { name: cmd.name, description: cmd.description, inputSchema: schema };
|
|
62
70
|
});
|
|
63
|
-
// TODO: TypeScript format generation
|
|
64
71
|
if (input.format === 'typescript') {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
const output = {
|
|
73
|
+
schemas,
|
|
74
|
+
count: schemas.length,
|
|
75
|
+
format: 'typescript',
|
|
76
|
+
typescript: generateInputTypes(schemas),
|
|
77
|
+
};
|
|
78
|
+
return success(output, {
|
|
79
|
+
reasoning: `Exported ${schemas.length} schemas with TypeScript input types`,
|
|
80
|
+
confidence: 1.0,
|
|
69
81
|
});
|
|
70
82
|
}
|
|
71
|
-
|
|
83
|
+
const output = { schemas, count: schemas.length, format: 'json' };
|
|
84
|
+
return success(output, {
|
|
72
85
|
reasoning: `Exported JSON schemas for ${schemas.length} commands`,
|
|
73
86
|
confidence: 1.0,
|
|
74
87
|
});
|
|
75
88
|
},
|
|
76
|
-
};
|
|
89
|
+
});
|
|
77
90
|
}
|
|
78
91
|
//# sourceMappingURL=afd-schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"afd-schema.js","sourceRoot":"","sources":["../../src/bootstrap/afd-schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"afd-schema.js","sourceRoot":"","sources":["../../src/bootstrap/afd-schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAA6B,MAAM,cAAc,CAAC;AACxE,OAAO,EAEN,mBAAmB,GAEnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,MAAM,EAAE,CAAC;SACP,IAAI,CAAC,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;SAC5B,OAAO,CAAC,MAAM,CAAC;SACf,QAAQ,CAAC,oE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+1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The command shape the bootstrap tools describe.
|
|
3
|
+
*/
|
|
4
|
+
import type { CommandContext, CommandExample, CommandParameter, ExposeOptions, JsonSchema } from '@lushly-dev/afd-core';
|
|
5
|
+
/**
|
|
6
|
+
* What afd-help, afd-docs and afd-schema read from a command. Both core
|
|
7
|
+
* `CommandDefinition`s (with `parameters`) and `ZodCommandDefinition`s (with
|
|
8
|
+
* `jsonSchema`) satisfy it.
|
|
9
|
+
*/
|
|
10
|
+
export interface DescribedCommand {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
category?: string;
|
|
14
|
+
tags?: string[];
|
|
15
|
+
mutation?: boolean;
|
|
16
|
+
destructive?: boolean;
|
|
17
|
+
confirmPrompt?: string;
|
|
18
|
+
undoable?: boolean;
|
|
19
|
+
requires?: string[];
|
|
20
|
+
examples?: CommandExample[];
|
|
21
|
+
expose?: ExposeOptions;
|
|
22
|
+
parameters?: CommandParameter[];
|
|
23
|
+
jsonSchema?: JsonSchema;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Supplies the commands a bootstrap tool describes. Called on every invocation with
|
|
27
|
+
* that invocation's command context, so callers can scope the list per request.
|
|
28
|
+
*/
|
|
29
|
+
export type GetDescribedCommands = (context?: CommandContext) => readonly DescribedCommand[];
|
|
30
|
+
/**
|
|
31
|
+
* The commands a bootstrap tool may describe: only MCP-exposed ones, like every
|
|
32
|
+
* other discovery surface (`tools/list`, afd-discover, afd-detail).
|
|
33
|
+
*/
|
|
34
|
+
export declare function describableCommands(getCommands: GetDescribedCommands, context?: CommandContext): DescribedCommand[];
|
|
35
|
+
//# sourceMappingURL=described-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"described-command.d.ts","sourceRoot":"","sources":["../../src/bootstrap/described-command.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACX,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,MAAM,sBAAsB,CAAC;AAG9B;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAChC,UAAU,CAAC,EAAE,UAAU,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,CAAC,EAAE,cAAc,KAAK,SAAS,gBAAgB,EAAE,CAAC;AAE7F;;;GAGG;AACH,wBAAgB,mBAAmB,CAClC,WAAW,EAAE,oBAAoB,EACjC,OAAO,CAAC,EAAE,cAAc,GACtB,gBAAgB,EAAE,CAEpB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The command shape the bootstrap tools describe.
|
|
3
|
+
*/
|
|
4
|
+
import { isMcpExposed } from '@lushly-dev/afd-core';
|
|
5
|
+
/**
|
|
6
|
+
* The commands a bootstrap tool may describe: only MCP-exposed ones, like every
|
|
7
|
+
* other discovery surface (`tools/list`, afd-discover, afd-detail).
|
|
8
|
+
*/
|
|
9
|
+
export function describableCommands(getCommands, context) {
|
|
10
|
+
return getCommands(context).filter((command) => isMcpExposed(command));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=described-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"described-command.js","sourceRoot":"","sources":["../../src/bootstrap/described-command.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AA6BpD;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAClC,WAAiC,EACjC,OAAwB;IAExB,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -8,5 +8,6 @@ export { type ContextState, createAfdContextEnterCommand, createAfdContextExitCo
|
|
|
8
8
|
export { createAfdDocsCommand } from './afd-docs.js';
|
|
9
9
|
export { createAfdHelpCommand } from './afd-help.js';
|
|
10
10
|
export { createAfdSchemaCommand } from './afd-schema.js';
|
|
11
|
+
export type { DescribedCommand } from './described-command.js';
|
|
11
12
|
export { getBootstrapCommands } from './registry.js';
|
|
12
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bootstrap/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACN,KAAK,YAAY,EACjB,4BAA4B,EAC5B,2BAA2B,EAC3B,2BAA2B,EAC3B,kBAAkB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bootstrap/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACN,KAAK,YAAY,EACjB,4BAA4B,EAC5B,2BAA2B,EAC3B,2BAA2B,EAC3B,kBAAkB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bootstrap/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEN,4BAA4B,EAC5B,2BAA2B,EAC3B,2BAA2B,EAC3B,kBAAkB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bootstrap/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEN,4BAA4B,EAC5B,2BAA2B,EAC3B,2BAA2B,EAC3B,kBAAkB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAGzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview A small JSON Schema → TypeScript type generator for afd-schema.
|
|
3
|
+
*
|
|
4
|
+
* Covers what `z.toJSONSchema()` emits for command inputs: primitive types,
|
|
5
|
+
* `integer`, `null`, arrays, objects (with `required` and `additionalProperties`),
|
|
6
|
+
* `enum`, `const`, `anyOf`/`oneOf` (unions) and `allOf` (intersections).
|
|
7
|
+
* Anything else, including `$ref`, becomes `unknown`.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Convert a JSON Schema to a TypeScript type expression.
|
|
11
|
+
*
|
|
12
|
+
* @param schema - JSON Schema (draft-7)
|
|
13
|
+
* @param indent - Indentation of the line the type starts on
|
|
14
|
+
*/
|
|
15
|
+
export declare function toType(schema: unknown, indent?: string, depth?: number): string;
|
|
16
|
+
/** `todo-create` → `TodoCreateInput`. */
|
|
17
|
+
export declare function inputTypeName(commandName: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Generate one TypeScript module declaring an input type per command
|
|
20
|
+
* (`todo-create` → `export type TodoCreateInput = …`).
|
|
21
|
+
*/
|
|
22
|
+
export declare function generateInputTypes(commands: ReadonlyArray<{
|
|
23
|
+
name: string;
|
|
24
|
+
description: string;
|
|
25
|
+
inputSchema: unknown;
|
|
26
|
+
}>): string;
|
|
27
|
+
//# sourceMappingURL=json-schema-to-ts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema-to-ts.d.ts","sourceRoot":"","sources":["../../src/bootstrap/json-schema-to-ts.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA6FH;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,SAAK,EAAE,KAAK,SAAI,GAAG,MAAM,CA8BtE;AAED,yCAAyC;AACzC,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAQzD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CACjC,QAAQ,EAAE,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,OAAO,CAAA;CAAE,CAAC,GAClF,MAAM,CAWR"}
|