@skill-tools/gen 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,196 @@
1
+ /**
2
+ * Configuration for generating a SKILL.md file.
3
+ */
4
+ interface GenerateOptions {
5
+ /** Skill name (kebab-case, max 64 chars). Auto-derived if not provided. */
6
+ readonly name?: string;
7
+ /** Output directory path. Defaults to current working directory. */
8
+ readonly outDir?: string;
9
+ /** Generation mode: one skill per endpoint or one unified skill */
10
+ readonly mode?: 'unified' | 'per-endpoint';
11
+ /** Maximum token budget for the generated SKILL.md (default: 4000) */
12
+ readonly maxTokens?: number;
13
+ /** Include example requests/responses in the output */
14
+ readonly includeExamples?: boolean;
15
+ /** Include error handling section */
16
+ readonly includeErrorHandling?: boolean;
17
+ /** Custom description override */
18
+ readonly description?: string;
19
+ }
20
+ /**
21
+ * Intermediate representation of an API parsed from any source.
22
+ */
23
+ interface ApiSpec {
24
+ /** API title */
25
+ readonly title: string;
26
+ /** API description/summary */
27
+ readonly description: string;
28
+ /** Base URL(s) */
29
+ readonly servers: readonly string[];
30
+ /** API version */
31
+ readonly version: string;
32
+ /** Parsed endpoints */
33
+ readonly endpoints: readonly ApiEndpoint[];
34
+ /** Authentication schemes */
35
+ readonly auth: readonly AuthScheme[];
36
+ }
37
+ /**
38
+ * A single API endpoint.
39
+ */
40
+ interface ApiEndpoint {
41
+ /** HTTP method (GET, POST, etc.) */
42
+ readonly method: string;
43
+ /** URL path (e.g. /users/{id}) */
44
+ readonly path: string;
45
+ /** Operation ID (e.g. getUser) */
46
+ readonly operationId?: string;
47
+ /** Summary (short description) */
48
+ readonly summary?: string;
49
+ /** Detailed description */
50
+ readonly description?: string;
51
+ /** Tags for grouping */
52
+ readonly tags: readonly string[];
53
+ /** Path + query + header parameters */
54
+ readonly parameters: readonly ApiParameter[];
55
+ /** Request body schema */
56
+ readonly requestBody?: ApiRequestBody;
57
+ /** Response schemas by status code */
58
+ readonly responses: readonly ApiResponse[];
59
+ }
60
+ /**
61
+ * An API parameter (path, query, header, cookie).
62
+ */
63
+ interface ApiParameter {
64
+ /** Parameter name */
65
+ readonly name: string;
66
+ /** Location: path, query, header, cookie */
67
+ readonly in: 'path' | 'query' | 'header' | 'cookie';
68
+ /** Description */
69
+ readonly description?: string;
70
+ /** Whether the parameter is required */
71
+ readonly required: boolean;
72
+ /** Schema type (string, integer, etc.) */
73
+ readonly type?: string;
74
+ /** Example value */
75
+ readonly example?: unknown;
76
+ }
77
+ /**
78
+ * Request body definition.
79
+ */
80
+ interface ApiRequestBody {
81
+ /** Description */
82
+ readonly description?: string;
83
+ /** Content type (e.g. application/json) */
84
+ readonly contentType: string;
85
+ /** Whether the body is required */
86
+ readonly required: boolean;
87
+ /** Schema properties (flattened) */
88
+ readonly properties: readonly ApiProperty[];
89
+ /** Example body */
90
+ readonly example?: unknown;
91
+ }
92
+ /**
93
+ * A property in a request/response body.
94
+ */
95
+ interface ApiProperty {
96
+ /** Property name */
97
+ readonly name: string;
98
+ /** Schema type */
99
+ readonly type: string;
100
+ /** Description */
101
+ readonly description?: string;
102
+ /** Whether the property is required */
103
+ readonly required: boolean;
104
+ /** Example value */
105
+ readonly example?: unknown;
106
+ }
107
+ /**
108
+ * An API response definition.
109
+ */
110
+ interface ApiResponse {
111
+ /** HTTP status code (e.g. "200", "404") */
112
+ readonly statusCode: string;
113
+ /** Description */
114
+ readonly description?: string;
115
+ /** Content type */
116
+ readonly contentType?: string;
117
+ /** Schema properties (flattened) */
118
+ readonly properties: readonly ApiProperty[];
119
+ }
120
+ /**
121
+ * Authentication scheme.
122
+ */
123
+ interface AuthScheme {
124
+ /** Scheme type */
125
+ readonly type: 'apiKey' | 'http' | 'oauth2' | 'openIdConnect';
126
+ /** Scheme name */
127
+ readonly name: string;
128
+ /** Description */
129
+ readonly description?: string;
130
+ /** For apiKey: where the key goes */
131
+ readonly in?: 'header' | 'query' | 'cookie';
132
+ /** For http: scheme (bearer, basic) */
133
+ readonly scheme?: string;
134
+ }
135
+ /**
136
+ * Result of a generation operation.
137
+ */
138
+ interface GenerateResult {
139
+ /** Whether generation succeeded */
140
+ readonly ok: true;
141
+ /** Generated files (path → content) */
142
+ readonly files: ReadonlyMap<string, string>;
143
+ /** Number of endpoints processed */
144
+ readonly endpointCount: number;
145
+ /** Estimated token count of generated content */
146
+ readonly tokenCount: number;
147
+ }
148
+ /**
149
+ * Error result from generation.
150
+ */
151
+ interface GenerateError {
152
+ readonly ok: false;
153
+ readonly error: string;
154
+ }
155
+
156
+ /**
157
+ * Generate SKILL.md files from an OpenAPI specification file.
158
+ *
159
+ * @param specPath - Path to an OpenAPI 3.x spec (JSON or YAML)
160
+ * @param options - Generation options
161
+ * @returns Generation result with files map, or an error
162
+ */
163
+ declare function generateFromOpenApi(specPath: string, options?: GenerateOptions): Promise<GenerateResult | GenerateError>;
164
+ /**
165
+ * Generate SKILL.md files from a pre-parsed ApiSpec.
166
+ *
167
+ * @param spec - The API specification
168
+ * @param options - Generation options
169
+ * @returns Generation result with files map
170
+ */
171
+ declare function generateFromSpec(spec: ApiSpec, options?: GenerateOptions): GenerateResult | GenerateError;
172
+ /**
173
+ * Generate a SKILL.md from a simple text description.
174
+ *
175
+ * This is a lightweight alternative for when you don't have an OpenAPI spec.
176
+ * Produces a basic SKILL.md with the given name and description.
177
+ */
178
+ declare function generateFromText(name: string, description: string, instructions?: string): GenerateResult;
179
+
180
+ /**
181
+ * Parse an OpenAPI 3.x specification (JSON or YAML) into an ApiSpec.
182
+ *
183
+ * Supports OpenAPI 3.0.x and 3.1.x. Does not support Swagger 2.0.
184
+ * Resolves local `$ref` references within the document.
185
+ */
186
+ declare function parseOpenApi(content: string): ApiSpec;
187
+
188
+ /**
189
+ * Render a SKILL.md file from an ApiSpec.
190
+ *
191
+ * In "unified" mode, produces a single SKILL.md covering the entire API.
192
+ * In "per-endpoint" mode, produces one SKILL.md per endpoint.
193
+ */
194
+ declare function renderSkillMd(spec: ApiSpec, options?: GenerateOptions): Map<string, string>;
195
+
196
+ export { type ApiEndpoint, type ApiParameter, type ApiProperty, type ApiRequestBody, type ApiResponse, type ApiSpec, type AuthScheme, type GenerateError, type GenerateOptions, type GenerateResult, generateFromOpenApi, generateFromSpec, generateFromText, parseOpenApi, renderSkillMd };
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ import {
2
+ generateFromOpenApi,
3
+ generateFromSpec,
4
+ generateFromText,
5
+ parseOpenApi,
6
+ renderSkillMd
7
+ } from "./chunk-EMDMG3H6.js";
8
+ export {
9
+ generateFromOpenApi,
10
+ generateFromSpec,
11
+ generateFromText,
12
+ parseOpenApi,
13
+ renderSkillMd
14
+ };
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@skill-tools/gen",
3
+ "version": "0.2.0",
4
+ "description": "Generate Agent Skills (SKILL.md) from OpenAPI specs, REST APIs, and text descriptions",
5
+ "type": "module",
6
+ "license": "Apache-2.0",
7
+ "author": "Piyush Vyas <pyyush>",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/skill-tools/skill-tools",
11
+ "directory": "packages/gen"
12
+ },
13
+ "homepage": "https://github.com/skill-tools/skill-tools/tree/main/packages/gen",
14
+ "bugs": {
15
+ "url": "https://github.com/skill-tools/skill-tools/issues"
16
+ },
17
+ "exports": {
18
+ ".": {
19
+ "import": {
20
+ "types": "./dist/index.d.ts",
21
+ "default": "./dist/index.js"
22
+ },
23
+ "require": {
24
+ "types": "./dist/index.d.cts",
25
+ "default": "./dist/index.cjs"
26
+ }
27
+ }
28
+ },
29
+ "main": "./dist/index.cjs",
30
+ "module": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "bin": {
33
+ "skillgen": "./dist/cli.js"
34
+ },
35
+ "files": [
36
+ "dist"
37
+ ],
38
+ "keywords": [
39
+ "agent-skills",
40
+ "skill-md",
41
+ "openapi",
42
+ "code-generation",
43
+ "ai-agent"
44
+ ],
45
+ "engines": {
46
+ "node": ">=18.0.0"
47
+ },
48
+ "dependencies": {
49
+ "commander": "^13.1.0",
50
+ "yaml": "^2.7.0",
51
+ "@skill-tools/core": "0.2.0"
52
+ },
53
+ "devDependencies": {
54
+ "@biomejs/biome": "^2.3.14",
55
+ "@types/node": "^25.2.2",
56
+ "tsup": "^8.5.1",
57
+ "typescript": "^5.9.3",
58
+ "vitest": "^4.0.18"
59
+ },
60
+ "scripts": {
61
+ "build": "tsup",
62
+ "test": "vitest run",
63
+ "test:watch": "vitest",
64
+ "typecheck": "tsc --noEmit",
65
+ "lint": "biome check src/",
66
+ "lint:fix": "biome check --write src/",
67
+ "format": "biome format --write src/",
68
+ "format:check": "biome format src/",
69
+ "clean": "rm -rf dist"
70
+ }
71
+ }