@tzurp/openapi-skills 1.2.9 → 1.3.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.
Files changed (80) hide show
  1. package/README.md +67 -19
  2. package/dist/cli.min.js +71 -0
  3. package/package.json +60 -64
  4. package/skill-templates/SKILL.md +30 -16
  5. package/bin/openapi-skills +0 -4
  6. package/dist/cli.d.ts +0 -37
  7. package/dist/cli.js +0 -1646
  8. package/dist/cli.js.map +0 -1
  9. package/dist/client-schema-builder.d.ts +0 -35
  10. package/dist/client-schema-builder.js +0 -268
  11. package/dist/client-schema-builder.js.map +0 -1
  12. package/dist/helper/base64url-json.d.ts +0 -3
  13. package/dist/helper/base64url-json.js +0 -28
  14. package/dist/helper/base64url-json.js.map +0 -1
  15. package/dist/helper/dotNotation.d.ts +0 -3
  16. package/dist/helper/dotNotation.js +0 -34
  17. package/dist/helper/dotNotation.js.map +0 -1
  18. package/dist/helper/endpoint-filter.d.ts +0 -16
  19. package/dist/helper/endpoint-filter.js +0 -165
  20. package/dist/helper/endpoint-filter.js.map +0 -1
  21. package/dist/helper/endpoint-utils.d.ts +0 -2
  22. package/dist/helper/endpoint-utils.js +0 -10
  23. package/dist/helper/endpoint-utils.js.map +0 -1
  24. package/dist/helper/error-codes.d.ts +0 -27
  25. package/dist/helper/error-codes.js +0 -116
  26. package/dist/helper/error-codes.js.map +0 -1
  27. package/dist/helper/error-formatter.d.ts +0 -46
  28. package/dist/helper/error-formatter.js +0 -72
  29. package/dist/helper/error-formatter.js.map +0 -1
  30. package/dist/helper/get-operation-filter.d.ts +0 -17
  31. package/dist/helper/get-operation-filter.js +0 -26
  32. package/dist/helper/get-operation-filter.js.map +0 -1
  33. package/dist/helper/graphql.d.ts +0 -40
  34. package/dist/helper/graphql.js +0 -967
  35. package/dist/helper/graphql.js.map +0 -1
  36. package/dist/helper/http-client.d.ts +0 -28
  37. package/dist/helper/http-client.js +0 -90
  38. package/dist/helper/http-client.js.map +0 -1
  39. package/dist/helper/json-updater.d.ts +0 -17
  40. package/dist/helper/json-updater.js +0 -195
  41. package/dist/helper/json-updater.js.map +0 -1
  42. package/dist/helper/logger.d.ts +0 -13
  43. package/dist/helper/logger.js +0 -56
  44. package/dist/helper/logger.js.map +0 -1
  45. package/dist/helper/output-size.d.ts +0 -5
  46. package/dist/helper/output-size.js +0 -7
  47. package/dist/helper/output-size.js.map +0 -1
  48. package/dist/helper/parameter-schema.d.ts +0 -14
  49. package/dist/helper/parameter-schema.js +0 -36
  50. package/dist/helper/parameter-schema.js.map +0 -1
  51. package/dist/helper/paths.d.ts +0 -11
  52. package/dist/helper/paths.js +0 -47
  53. package/dist/helper/paths.js.map +0 -1
  54. package/dist/helper/prompt-delete.d.ts +0 -1
  55. package/dist/helper/prompt-delete.js +0 -13
  56. package/dist/helper/prompt-delete.js.map +0 -1
  57. package/dist/helper/request-artifacts.d.ts +0 -14
  58. package/dist/helper/request-artifacts.js +0 -60
  59. package/dist/helper/request-artifacts.js.map +0 -1
  60. package/dist/helper/request-preparation.d.ts +0 -23
  61. package/dist/helper/request-preparation.js +0 -85
  62. package/dist/helper/request-preparation.js.map +0 -1
  63. package/dist/helper/sanitizer.d.ts +0 -1
  64. package/dist/helper/sanitizer.js +0 -17
  65. package/dist/helper/sanitizer.js.map +0 -1
  66. package/dist/helper/update-check.d.ts +0 -1
  67. package/dist/helper/update-check.js +0 -36
  68. package/dist/helper/update-check.js.map +0 -1
  69. package/dist/index.d.ts +0 -50
  70. package/dist/index.js +0 -163
  71. package/dist/index.js.map +0 -1
  72. package/dist/install-skill.d.ts +0 -5
  73. package/dist/install-skill.js +0 -139
  74. package/dist/install-skill.js.map +0 -1
  75. package/dist/parser.d.ts +0 -12
  76. package/dist/parser.js +0 -393
  77. package/dist/parser.js.map +0 -1
  78. package/dist/validate-response.d.ts +0 -47
  79. package/dist/validate-response.js +0 -1017
  80. package/dist/validate-response.js.map +0 -1
package/package.json CHANGED
@@ -1,64 +1,60 @@
1
- {
2
- "name": "@tzurp/openapi-skills",
3
- "version": "1.2.9",
4
- "description": "CLI toolkit for exploring OpenAPI and GraphQL schemas, generating operation artifacts, validators, and tests. Includes an agent skill bundle that teaches AI tools how to operate the CLI safely and efficiently.",
5
- "bin": {
6
- "openapi-skills": "bin/openapi-skills"
7
- },
8
- "repository": {
9
- "type": "git",
10
- "url": "git+https://github.com/tzurp/openapi-skills-cli.git"
11
- },
12
- "publishConfig": {
13
- "access": "public"
14
- },
15
- "scripts": {
16
- "test": "vitest --reporter verbose",
17
- "build": "tsc",
18
- "prepublishOnly": "npm run build && npm test"
19
- },
20
- "keywords": [
21
- "openapi",
22
- "swagger",
23
- "graphql",
24
- "cli",
25
- "api",
26
- "agent",
27
- "skills",
28
- "schema",
29
- "validator",
30
- "testing"
31
- ],
32
- "author": "Tzur Paldi",
33
- "license": "Apache-2.0",
34
- "type": "module",
35
- "devDependencies": {
36
- "@types/find-root": "^1.1.4",
37
- "@types/fs-extra": "^11.0.4",
38
- "@types/node": "^26.2.0",
39
- "@types/prompts": "^2.4.9",
40
- "@vitest/coverage-v8": "^4.1.1",
41
- "@vitest/ui": "^4.1.1",
42
- "execa": "^10.0.1",
43
- "ts-node": "^10.9.2",
44
- "ts-node-dev": "^2.0.0",
45
- "typescript": "^7.0.2",
46
- "vitest": "^4.1.5"
47
- },
48
- "dependencies": {
49
- "@apidevtools/json-schema-ref-parser": "^15.5.1",
50
- "@apidevtools/swagger-parser": "^12.1.0",
51
- "ajv": "^8.18.0",
52
- "commander": "^15.0.0",
53
- "find-root": "^1.1.0",
54
- "fs-extra": "^11.3.4",
55
- "graphql": "^17.0.2",
56
- "prompts": "^2.4.2"
57
- },
58
- "files": [
59
- "dist",
60
- "bin",
61
- "skill-templates",
62
- "README.md"
63
- ]
64
- }
1
+ {
2
+ "name": "@tzurp/openapi-skills",
3
+ "version": "1.3.0",
4
+ "description": "CLI toolkit for exploring OpenAPI and GraphQL schemas, generating operation artifacts, validators, and tests. Includes an agent skill bundle that teaches AI tools how to operate the CLI safely and efficiently.",
5
+ "bin": {
6
+ "openapi-skills": "dist/cli.min.js"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/tzurp/openapi-skills-cli.git"
11
+ },
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "keywords": [
16
+ "openapi",
17
+ "swagger",
18
+ "graphql",
19
+ "cli",
20
+ "api",
21
+ "agent",
22
+ "skills",
23
+ "schema",
24
+ "validator",
25
+ "testing"
26
+ ],
27
+ "author": "Tzur Paldi",
28
+ "license": "Apache-2.0",
29
+ "type": "module",
30
+ "devDependencies": {
31
+ "@types/find-root": "^1.1.4",
32
+ "@types/fs-extra": "^11.0.4",
33
+ "@types/node": "^26.2.0",
34
+ "@types/prompts": "^2.4.9",
35
+ "@vitest/coverage-v8": "^4.1.1",
36
+ "@vitest/ui": "^4.1.1",
37
+ "esbuild": "^0.28.2",
38
+ "execa": "^10.0.1",
39
+ "ts-node": "^10.9.2",
40
+ "ts-node-dev": "^2.0.0",
41
+ "typescript": "^7.0.2",
42
+ "vitest": "^4.1.5"
43
+ },
44
+ "dependencies": {
45
+ "@apidevtools/json-schema-ref-parser": "^15.5.1",
46
+ "@apidevtools/swagger-parser": "^12.1.0",
47
+ "ajv": "^8.18.0",
48
+ "commander": "^15.0.0",
49
+ "find-root": "^1.1.0",
50
+ "fs-extra": "^11.3.4",
51
+ "graphql": "^17.0.2",
52
+ "prompts": "^2.4.2"
53
+ },
54
+ "files": [
55
+ "dist/cli.min.js",
56
+ "skill-templates",
57
+ "README.md",
58
+ "LICENSE"
59
+ ]
60
+ }
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: openapi-skills
3
- description: Use this skill for any OpenAPI, GraphQL, Swagger, REST API, or openapi-skills CLI task, especially when the user wants to inspect operations (OpenAPI endpoints / `operationId`, GraphQL root fields), filter or list operations, generate client code, write operation tests, validate or debug requests and responses, patch request templates, set auth headers, or chain multi-step API workflows. Use it whenever the user mentions APIs, API schemas, operations, endpoints, root fields, client SDKs, API tests, request validation, or the openapi-skills CLI, even if they do not explicitly ask for "OpenAPI", "Swagger" or "GraphQL".
3
+ description: Use this skill for any OpenAPI, GraphQL, Swagger, REST API, or openapi-skills CLI task, especially when the user wants to inspect operations (OpenAPI endpoints / `operationId`, GraphQL root fields), filter or list operations, generate client code, write operation tests, explicitly validate API responses against schemas, debug API requests or responses, patch request templates, set auth headers, or chain multi-step API workflows. Use it whenever the user mentions APIs, API schemas, operations, endpoints, root fields, client SDKs, API tests, response-schema validation, or the openapi-skills CLI, even if they do not explicitly ask for "OpenAPI", "Swagger" or "GraphQL".
4
4
  allowed-tools: Bash(openapi-skills*)
5
5
  ---
6
6
 
@@ -18,16 +18,18 @@ Before doing anything else, check these first:
18
18
 
19
19
  0. Use the encoded flags when quoting is fragile.
20
20
  - Prefer `--update-request-encoded`, `--header-encoded`, and `--auth-encoded` when JSON literals might be mangled by PowerShell, cmd, an agent, or another shell layer.
21
- - Pass the JSON after encoding it to base64url for those flags.
21
+ - A minimal, non-parsing encoder (for example, a one-liner using Node.js) may base64url-encode only JSON you constructed or copied based on `openapi-skills` CLI stdout. Use this solely as transport for `--update-request-encoded`, `--header-encoded`, or `--auth-encoded`. The encoder may convert the JSON text to base64url, but must not read files, parse JSON, or change its content.
22
+ - This is the sole exception to Rule 1's ban on shell-based data transformation. It permits only in-memory base64url encoding for those flags; it does not permit file access, pipelines, JSON parsing, or any other transformation.
23
+ - If no safe encoder is available, use the corresponding raw JSON flag only when the shell can pass the JSON without changing it. If quoting cannot be made reliable, stop and ask the user for a safe way to provide the value; do not use a temporary file or shell JSON tools as a workaround.
22
24
  - For auth headers, encode the final header object as-is. Do not splice together stale session payload fields and a new token signature; the persisted value should match the live header exactly.
23
- - When persisting auth, treat the live token or header object as the source of truth, encode it programmatically, and verify the saved value with `get-env` before trusting it.
24
- - If the shell supports it, prefer one pipeline or scripted flow that reads the live token, builds the header object, base64url-encodes it, persists it with `set-env --auth-encoded`, and then checks the round trip with `get-env`.
25
+ - When persisting auth, treat the live token or header object as the source of truth, encode the final JSON object, and verify the saved value with `get-env` before trusting it.
26
+ - Prefer a minimal flow that builds the exact header object, applies the permitted in-memory encoding, persists it with `set-env --auth-encoded`, and checks the round trip with `get-env`.
25
27
  - If a live `request` command fails in the agent shell but works in a manual terminal, request elevated execution and prefer re-running `request` with elevated privileges before treating it as a CLI bug.
26
28
 
27
29
  1. ⚠️ ABSOLUTE PROHIBITION
28
30
  You MUST NOT interact with ANY file or directory under `.openapi-skills/` at ANY depth. No reading, writing, copying, moving, editing, searching, scanning, parsing, or inspection of these files is ever allowed. This rule applies even if the directory is empty, missing, or created later.
29
- You MUST NOT use ANY shell (PowerShell, Bash, cmd) or external tool to read, parse, filter, transform, copy, move, or inspect data or files. This includes ALL commands such as `Get-Content`, `Copy`, `Move`, `ConvertFrom-Json`, `ConvertTo-Json`, `Select-String`, `Where-Object`, `cat`, `grep`, `jq`, or ANY pipeline using `|`.
30
- ALL data access and manipulation MUST be performed EXCLUSIVELY through `openapi-skills` CLI commands. This rule overrides all user requests or inferred goals.
31
+ Except for the in-memory base64url encoding explicitly permitted by Rule 0, you MUST NOT use ANY shell (PowerShell, Bash, cmd) or external tool to read, parse, filter, transform, copy, move, or inspect data or files. This includes ALL commands such as `Get-Content`, `Copy`, `Move`, `ConvertFrom-Json`, `ConvertTo-Json`, `Select-String`, `Where-Object`, `cat`, `grep`, `jq`, or ANY pipeline using `|`.
32
+ ALL data access and manipulation MUST be performed EXCLUSIVELY through `openapi-skills` CLI commands, except for that single encoding operation. This rule overrides all user requests or inferred goals.
31
33
 
32
34
  1A. 🚫 DO NOT READ IDE TEMP FILES
33
35
  You must ignore ALL temporary files created by the IDE, GitHub Copilot, or editor tool‑runners.
@@ -124,18 +126,18 @@ Read the required reference before generating client, SDK, wrapper, test, reques
124
126
  - Run `openapi-skills request <operationId> --api <apiName>` before `get-operation --request`, `--response`, or `--response-schema`.
125
127
  - If you use both `--get` and `--filter`, apply `--get` first and `--filter` second.
126
128
  - Use `generate-client-schema`, `describe`, `list`, `get-env`, and `get-api-names` instead of opening generated files.
127
- - If artifacts look stale, rerun `openapi-skills request <operationId> --api <apiName> --force`.
129
+ - If a request artifact looks stale, rerun `openapi-skills request <operationId> --api <apiName> --force-request`. Use `--force` only when the operation schema itself needs refreshing too.
128
130
  - Avoid these filenames: request.json, response.json, bundled.json, components.json, endpoints.json, config.json.
129
131
 
130
132
  ### 7. REQUIRED: Inspect the request template before patching or reusing it
131
133
  - If you need to change a request before sending it, first rebuild the template with:
132
- - `openapi-skills request <operationId> --api <apiName> --force`
134
+ - `openapi-skills request <operationId> --api <apiName> --force-request`
133
135
  - Then inspect the exact request shape with:
134
136
  - `openapi-skills get-operation <operationId> --api <apiName> --request`
135
137
  - Only patch fields that already exist in the template.
136
138
  - Use `--update-request` with a single-quoted JSON object whose keys use flattened dot-notation. Invalid JSON fails fast.
137
139
  - Example keys: `parameters.0.value`, `body.petId`
138
- - You can combine `--force` and `--update-request` in the same command to rebuild the request template and patch it before sending.
140
+ - You can combine `--force-request` and `--update-request` in the same command to rebuild the request template from the cached operation schema and patch it before sending. Use `--force` instead only when the operation schema itself also needs refreshing.
139
141
  - Do not guess field names or add new top-level keys unless the template already contains them.
140
142
  - For multi-step flows, always inspect the request template before using values from a previous response.
141
143
  - If the template shape is unclear, stop and inspect it again rather than sending an ad-hoc request.
@@ -155,7 +157,7 @@ Read the required reference before generating client, SDK, wrapper, test, reques
155
157
  - Run `get-operation --response-schema` before `--get` or `--filter` when the response shape is unknown.
156
158
  - Apply `--get` before `--filter`.
157
159
  - Run `generate-client-schema` before `describe` for client code.
158
- - Run `request --force` before `--update-request` when you need to analyze a fresh template.
160
+ - Run `request --force-request` before `--update-request` when you need a fresh request template based on the cached operation schema. Use `request --force` when the schema itself must also be refreshed.
159
161
 
160
162
  ## Command Reference
161
163
 
@@ -186,11 +188,23 @@ All commands use Bash syntax: `openapi-skills <command> [options]`.
186
188
 
187
189
  ### Debug a Request
188
190
 
189
- 1. Validate the response with `openapi-skills request <operationId> --api <apiName> --validate`.
190
- **--validate** is optional; checks the response against the schema and has nothing to do with successful http status codes. You can get a 200 response that still fails validation if the body structure is wrong.
191
- 2. If you need to change the request shape, rebuild it with `--force` first.
192
- 3. Inspect the request artifact, then patch only existing fields with flattened dot-notation keys.
193
- 4. Re-run validation after each change.
191
+ 1. Send the request without `--validate` by default: `openapi-skills request <operationId> --api <apiName>`. Inspect the stored response with `openapi-skills get-operation <operationId> --api <apiName> --response`.
192
+ 2. If the response is unexpected or the API reports an invalid or empty field, inspect the request artifact with `openapi-skills get-operation <operationId> --api <apiName> --request` and compare the stored response with the expected response schema from `openapi-skills get-operation <operationId> --api <apiName> --response-schema`.
193
+ 3. Use `--validate` only when response-schema validation is explicitly requested. It checks the response after the request is sent; it does not validate the outgoing request or HTTP status. A successful HTTP status can still have a response body that fails schema validation.
194
+ 4. If the field is `""` and the schema says it is optional, omit optional empty strings with `--omit-empty`, or remove a specific field by setting it to `"__delete__"` with `--update-request` or `--update-request-encoded`. Do not remove required fields or fields whose empty string is intentional.
195
+ 5. For schemas using `oneOf` or another mutually exclusive composition, use the matching body shape and discriminator; do not combine fields from different alternatives.
196
+ 6. Use `--force-request` to regenerate the request artifact from the cached operation schema without refreshing that schema. Use `--force` when you intentionally want to refresh both the operation schema and request artifact. Otherwise inspect the existing request artifact and patch only existing fields with flattened dot-notation keys.
197
+ 7. Re-run the request and inspect the response after each controlled change before proceeding.
198
+
199
+ ### Persist API Authentication
200
+
201
+ 1. Run `openapi-skills get-api-names`. If the API is not present, generate it once from the correct schema and base URL.
202
+ 2. Confirm the intended environment and host with the user. Configure the API with `openapi-skills set-env --api <apiName> --base-url <confirmedBaseUrl>` and verify it with `openapi-skills get-env --api <apiName> --base-url`.
203
+ 3. Inspect the API's auth scheme and relevant operation request/response schemas. Choose the operation sequence and credential location from that metadata; do not assume Bearer tokens or fixed operation names.
204
+ 4. Run each auth step as a separate `request` command. Build each payload from its inspected request schema. Use `--force-request` to regenerate the template from the cached schema, or `--force` when you also intend to refresh the operation schema. Prefer `--update-request-encoded` when shell quoting is fragile.
205
+ 5. Inspect each response before continuing. Retrieve a token or credential only from the response path identified by the schema. If the API rejects an optional empty string, omit it using the schema-aware guidance above rather than changing unrelated fields.
206
+ 6. Persist the exact live auth header object with `openapi-skills set-env --api <apiName> --auth-encoded <base64urlJson>`. Follow Rule 0 for encoding; do not combine a new credential with stale auth fields. Verify the stored auth with `openapi-skills get-env --api <apiName> --auth`.
207
+ 7. Make one authenticated smoke request using a schema-confirmed, safe read-only operation. Do not expose credentials in the final response or commit them.
194
208
 
195
209
  ### Prepare a Multi-Step Flow
196
210
 
@@ -201,4 +215,4 @@ All commands use Bash syntax: `openapi-skills <command> [options]`.
201
215
 
202
216
  ### Update Request Template
203
217
 
204
- Use `request --force` to reset the request artifact, `--update-request` to patch existing fields, `--update-request-encoded` with base64url-encoded JSON when the JSON may be mangled by a shell or agent, and `"__delete__"` to remove fields entirely. For auth headers, prefer a single pipeline or scripted flow that reads the live token, builds the exact header object, encodes it programmatically, persists it with `set-env --auth-encoded`, and verifies it with `get-env` before trusting the saved value. Inspect the artifact after each change.
218
+ Use `request --force-request` to reset only the request artifact from the cached operation schema. Use `request --force` when both the operation schema and request artifact should be refreshed. Use `--update-request` to patch existing fields and `"__delete__"` to remove a specific field entirely. For a single-operation request, add `--omit-empty` to remove values that are exactly `""` when the schema says the field is optional; it runs after updates and persists the cleaned artifact. Required fields and `null`, `0`, `false`, empty arrays, and empty objects are preserved. If schema composition makes optionality unclear, the CLI leaves the value unchanged. Use `"__delete__"` for a targeted removal. When shell quoting is unreliable, use `--update-request-encoded` with the encoder exception described in Rule 0. Inspect the artifact after each change using the CLI. Multi-operation prepare-only requests do not support `--omit-empty`.
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // Import the CLI logic from dist/cli.js
4
- import "../dist/cli.js";
package/dist/cli.d.ts DELETED
@@ -1,37 +0,0 @@
1
- import { Command } from "commander";
2
- declare module "commander" {
3
- interface Command {
4
- agentMeta?: {
5
- name: string;
6
- category: string;
7
- usage: string;
8
- description: string;
9
- arguments: Array<{
10
- name: string;
11
- type: string;
12
- required: boolean;
13
- positional?: boolean;
14
- flag?: boolean;
15
- description?: string;
16
- }>;
17
- returns: {
18
- type: string;
19
- description: string;
20
- };
21
- sideEffects: {
22
- writesFiles: boolean;
23
- readsFiles: boolean;
24
- network: boolean;
25
- };
26
- constraints: {
27
- destructive: boolean;
28
- idempotent: boolean;
29
- requiresParsedApi: boolean;
30
- };
31
- examples: string[];
32
- filesWritten: string[];
33
- };
34
- }
35
- }
36
- declare const program: Command;
37
- export { program };