jentic-apitools-cli 0.0.0a9__tar.gz
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.
- jentic_apitools_cli-0.0.0a9/LICENSE +202 -0
- jentic_apitools_cli-0.0.0a9/NOTICE +4 -0
- jentic_apitools_cli-0.0.0a9/PKG-INFO +233 -0
- jentic_apitools_cli-0.0.0a9/README.md +213 -0
- jentic_apitools_cli-0.0.0a9/pyproject.toml +36 -0
- jentic_apitools_cli-0.0.0a9/src/jentic/apitools/cli/helpers.py +295 -0
- jentic_apitools_cli-0.0.0a9/src/jentic/apitools/cli/main.py +781 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jentic-apitools-cli
|
|
3
|
+
Version: 0.0.0a9
|
|
4
|
+
Summary: Jentic Apitools CLI - Full-featured command-line interface independent of API
|
|
5
|
+
Author: Jentic
|
|
6
|
+
Author-email: Jentic <hello@jentic.com>
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
License-File: NOTICE
|
|
10
|
+
Requires-Dist: pydantic>=2.7,<3.0
|
|
11
|
+
Requires-Dist: jentic-apitools-common~=0.0.0a9
|
|
12
|
+
Requires-Dist: jentic-apitools-analyze~=0.0.0a9
|
|
13
|
+
Requires-Dist: jentic-apitools-pipelines~=0.0.0a9
|
|
14
|
+
Requires-Dist: jentic-apitools-jobs~=0.0.0a9
|
|
15
|
+
Requires-Dist: click>=8.1.0
|
|
16
|
+
Requires-Dist: rich>=13.0.0
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Project-URL: Homepage, https://github.com/jentic/jentic-apitools
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# cli
|
|
22
|
+
|
|
23
|
+
Click-based command-line interface for Jentic API Tools, providing commands for analyzing, scoring, and importing OpenAPI specifications, as well as bulk repository operations.
|
|
24
|
+
|
|
25
|
+
## Key Features
|
|
26
|
+
|
|
27
|
+
The CLI registers as the `jentic-apitools` entry point and provides seven commands. The `analyze` command runs validation diagnostics against an OpenAPI spec using multiple backends (Redocly, Spectral, custom rules, and optional LLM semantic analysis). The `score` command calculates the AI-readiness score using Jentic's 6-dimension framework. The `import` command processes a spec through the full import pipeline, producing scored and cataloged artifacts written to a directory or ZIP archive.
|
|
28
|
+
|
|
29
|
+
All three core commands accept input as a local file path, an HTTP(S) URL, or stdin (using `-` with optional `--stdin-filepath`). For `analyze` and `score`, output defaults to JSON on stdout and can be redirected to a file with `--output`. The `import` command always writes its artifacts to a directory (via `--output`) or to a ZIP archive (via `--archive`) and emits a summary JSON document to stdout. A `--format text` option provides human-readable output. The `-q`/`--quiet` flag, available on `analyze`, `score`, and `import`, suppresses log output so only command results appear on stdout, which is useful when piping to tools like `jq`.
|
|
30
|
+
|
|
31
|
+
The remaining commands handle batch repository operations: `bulk-rescore` iterates all specs in a local repository clone; `recalculate-scores` rebuilds the `scores.json` index; `rebuild-scores-json` and `rebuild-apis-json` rebuild catalog files.
|
|
32
|
+
|
|
33
|
+
## LLM Configuration
|
|
34
|
+
|
|
35
|
+
The `--enable-llm-analysis` flag (on `analyze`, `score`, and `import`) and the `bulk-rescore` command (which always uses LLM) require credentials for the configured LLM provider. Set `LLM_PROVIDER` and `LIGHT_LLM_PROVIDER` (default: `BEDROCK`) and provide the corresponding API key:
|
|
36
|
+
|
|
37
|
+
| Provider | Required environment variable |
|
|
38
|
+
|---|---|
|
|
39
|
+
| `OPENAI` | `OPENAI_API_KEY` or `JENTIC_OPENAI_API_KEY` |
|
|
40
|
+
| `CLAUDE` / `ANTHROPIC` | `ANTHROPIC_API_KEY` or `JENTIC_ANTHROPIC_API_KEY` |
|
|
41
|
+
| `GEMINI` | `GEMINI_API_KEY` or `JENTIC_GEMINI_API_KEY` |
|
|
42
|
+
| `BEDROCK` | AWS credentials via boto3 (IAM role or `~/.aws/credentials`) |
|
|
43
|
+
|
|
44
|
+
See `.env.example` for the full list of configuration options. The CLI validates credentials at startup and provides actionable error messages if they are missing.
|
|
45
|
+
|
|
46
|
+
## Dependencies
|
|
47
|
+
|
|
48
|
+
Internal: `jentic.apitools.common`, `jentic.apitools.analyze`, `jentic.apitools.pipelines`, `jentic.apitools.jobs`. External: click, rich.
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
uv add cli
|
|
54
|
+
# The CLI is available as:
|
|
55
|
+
uv run jentic-apitools --help
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Quick Start
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Analyze a local spec
|
|
62
|
+
uv run jentic-apitools analyze openapi.json
|
|
63
|
+
|
|
64
|
+
# Analyze with text output and fail on warnings
|
|
65
|
+
uv run jentic-apitools analyze openapi.json --format text --fail-on warn
|
|
66
|
+
|
|
67
|
+
# Score a spec from URL
|
|
68
|
+
uv run jentic-apitools score https://petstore3.swagger.io/api/v3/openapi.json
|
|
69
|
+
|
|
70
|
+
# Score with minimum threshold
|
|
71
|
+
uv run jentic-apitools score openapi.json --min-score 80
|
|
72
|
+
|
|
73
|
+
# Import from URL to directory
|
|
74
|
+
uv run jentic-apitools import https://example.com/openapi.json --output ./output --label example.com/api
|
|
75
|
+
|
|
76
|
+
# Import to ZIP archive
|
|
77
|
+
uv run jentic-apitools import openapi.json --archive output.zip
|
|
78
|
+
|
|
79
|
+
# Pipe from stdin
|
|
80
|
+
cat openapi.yaml | uv run jentic-apitools analyze - --stdin-filepath openapi.yaml
|
|
81
|
+
curl -s https://example.com/openapi.json | uv run jentic-apitools score -
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### analyze
|
|
85
|
+
|
|
86
|
+
The `analyze` command runs validation diagnostics against an OpenAPI specification.
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
uv run jentic-apitools analyze <SPEC> [--format json|text] [--output FILE] [--base-url URL] [--enable-llm-analysis] [--stdin-filepath PATH] [--fail-on error|warn|info|hint|none]
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The `SPEC` argument accepts a local file path (relative or absolute), an HTTP(S) URL, or `-` for stdin. When using stdin, `--stdin-filepath` provides a virtual path for format detection.
|
|
93
|
+
|
|
94
|
+
Default output is JSON to stdout with a diagnostics array and summary counts. The `--format text` option produces a human-readable report. The `--fail-on` option causes exit code 2 if any diagnostic meets or exceeds the specified severity.
|
|
95
|
+
|
|
96
|
+
Options:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
SPEC Local file path, URL, or - for stdin (required)
|
|
100
|
+
--format, -f TEXT Output format: json or text (default: json)
|
|
101
|
+
--output, -o FILE Write output to file instead of stdout
|
|
102
|
+
--base-url URL Base URL for resolving references (default: spec URL)
|
|
103
|
+
--stdin-filepath PATH Virtual filepath for stdin input (format detection)
|
|
104
|
+
--enable-llm-analysis Enable LLM-based semantic analysis
|
|
105
|
+
--fail-on LEVEL Exit code 2 if severity >= level (default: none)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### score
|
|
109
|
+
|
|
110
|
+
The `score` command calculates the AI-readiness score for an OpenAPI specification.
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
uv run jentic-apitools score <SPEC> [--format json|text] [--output FILE] [--label LABEL] [--vendor VENDOR] [--api API] [--min-score N] [--enable-llm-analysis] [--include-diagnostics] [--skip-bundle] [--stdin-filepath PATH] [--original-url URL] [--api-id ID] [--api-version-id ID] [--canonical-source-url URL] [--canonical-artifacts-base-url URL] [--canonical-artifacts-base-url-ui URL]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Output is the full scorecard JSON by default. The `--format text` option shows a human-readable summary with overall score, grade, level, and per-dimension breakdowns. The `--min-score` option causes exit code 2 if the overall score is below the threshold.
|
|
117
|
+
|
|
118
|
+
Options:
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
SPEC Local file path, URL, or - for stdin (required)
|
|
122
|
+
--format, -f TEXT Output format: json or text (default: json)
|
|
123
|
+
--output, -o FILE Write output to file instead of stdout
|
|
124
|
+
--label TEXT Vendor/API label (mutually exclusive with --vendor)
|
|
125
|
+
--vendor TEXT Vendor name, combined with --api to form label
|
|
126
|
+
--api TEXT API name (default: main, requires --vendor)
|
|
127
|
+
--min-score N Exit code 2 if score < N
|
|
128
|
+
--enable-llm-analysis Enable LLM-based semantic analysis
|
|
129
|
+
--include-diagnostics Include diagnostics in score output
|
|
130
|
+
--skip-bundle Skip bundling step
|
|
131
|
+
--stdin-filepath PATH Virtual filepath for stdin input
|
|
132
|
+
--original-url URL Original spec URL for provenance tracking
|
|
133
|
+
--api-id ID Logical API identifier
|
|
134
|
+
--api-version-id ID Logical API version identifier
|
|
135
|
+
--canonical-source-url URL Canonical source URL for metadata
|
|
136
|
+
--canonical-artifacts-base-url URL Canonical base URL for raw artifacts
|
|
137
|
+
--canonical-artifacts-base-url-ui URL Canonical base URL for UI artifact links
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### import
|
|
141
|
+
|
|
142
|
+
The `import` command processes an OpenAPI specification through the full import pipeline.
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
uv run jentic-apitools import <SPEC> (--output DIR | --archive FILE.zip) [--label LABEL] [--vendor VENDOR] [--api API] [--overwrite] [--enable-llm-analysis] [--skip-bundle] [--stdin-filepath PATH] [--original-url URL] [--api-id ID] [--api-version-id ID] [--canonical-source-url URL] [--canonical-artifacts-base-url URL] [--canonical-artifacts-base-url-ui URL]
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Either `--output DIR` or `--archive FILE.zip` must be specified. With `--output`, artifacts are written to the directory. With `--archive`, they are packaged as a ZIP file. On success, a JSON manifest is written to stdout.
|
|
149
|
+
|
|
150
|
+
Options:
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
SPEC Local file path, URL, or - for stdin (required)
|
|
154
|
+
--output, -o DIR Output directory for artifacts
|
|
155
|
+
--archive FILE.zip Write artifacts as a ZIP archive
|
|
156
|
+
--label TEXT Vendor/API label (mutually exclusive with --vendor)
|
|
157
|
+
--vendor TEXT Vendor name, combined with --api to form label
|
|
158
|
+
--api TEXT API name (default: main, requires --vendor)
|
|
159
|
+
--overwrite Overwrite existing output directory or archive
|
|
160
|
+
--enable-llm-analysis Enable LLM-based semantic analysis
|
|
161
|
+
--skip-bundle Skip bundling step
|
|
162
|
+
--stdin-filepath PATH Virtual filepath for stdin input
|
|
163
|
+
--original-url URL Original spec URL for provenance tracking
|
|
164
|
+
--api-id ID Logical API identifier
|
|
165
|
+
--api-version-id ID Logical API version identifier
|
|
166
|
+
--canonical-source-url URL Canonical source URL for metadata
|
|
167
|
+
--canonical-artifacts-base-url URL Canonical base URL for raw artifacts
|
|
168
|
+
--canonical-artifacts-base-url-ui URL Canonical base URL for UI artifact links
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### bulk-rescore
|
|
172
|
+
|
|
173
|
+
The `bulk-rescore` command rescores all OpenAPI specs in a local clone of a repository with the `apis/openapi/<vendor>/<api>/<version>/openapi.json` directory structure. It runs `import_openapi` for each spec, then copies the updated `scorecard.json`, `diagnostics.json`, and the `diagnostics` section of `meta.json` back into the local repo. When not in dry-run mode, the command also recalculates `scores.json` with all scores sorted by value in descending order.
|
|
174
|
+
|
|
175
|
+
> **Note:** This command always uses LLM analysis. Ensure your LLM provider credentials are configured (see [LLM Configuration](#llm-configuration)).
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
uv run jentic-apitools bulk-rescore /path/to/jentic-public-apis
|
|
179
|
+
uv run jentic-apitools bulk-rescore /path/to/jentic-public-apis --max-iterations 2 --dry-run
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Options:
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
LOCAL_REPO_PATH Path to root of the local repo clone (required)
|
|
186
|
+
--github-repo-url TEXT GitHub repository URL (default: https://github.com/jentic/jentic-public-apis)
|
|
187
|
+
--output-dir, -o PATH Output directory for rescore results (default: __data__/rescore_<datetime>)
|
|
188
|
+
--github-repo-branch TEXT GitHub repository branch (default: main)
|
|
189
|
+
--base-dir TEXT Base directory for OpenAPI specs within the repo (default: apis/openapi)
|
|
190
|
+
--max-iterations INTEGER Maximum number of APIs to process, useful for testing (default: no limit)
|
|
191
|
+
--dry-run Run without copying results to the local repo
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### recalculate-scores
|
|
195
|
+
|
|
196
|
+
Rebuilds `scores.json` from all `scorecard.json` files found under a local repository clone.
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
uv run jentic-apitools recalculate-scores /path/to/jentic-public-apis
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Options:
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
LOCAL_REPO_PATH Path to root of the local repo clone (required)
|
|
206
|
+
--base-dir TEXT Base directory for OpenAPI specs within the repo (default: apis/openapi)
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### rebuild-scores-json
|
|
210
|
+
|
|
211
|
+
Rebuilds `scores.json` from all `scorecard.json` files with additional GitHub repo and branch configuration.
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
uv run jentic-apitools rebuild-scores-json /path/to/jentic-public-apis
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### rebuild-apis-json
|
|
218
|
+
|
|
219
|
+
Rebuilds the root `apis.json` catalog from all version-level `apis.json` files.
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
uv run jentic-apitools rebuild-apis-json /path/to/jentic-public-apis
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Exit Codes
|
|
226
|
+
|
|
227
|
+
All commands use consistent exit codes: 0 for success, 1 for runtime or pipeline errors, and 2 for policy failures (triggered by `--fail-on` or `--min-score` thresholds).
|
|
228
|
+
|
|
229
|
+
## Testing
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
uv run --package cli pytest packages/cli/tests -v
|
|
233
|
+
```
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# cli
|
|
2
|
+
|
|
3
|
+
Click-based command-line interface for Jentic API Tools, providing commands for analyzing, scoring, and importing OpenAPI specifications, as well as bulk repository operations.
|
|
4
|
+
|
|
5
|
+
## Key Features
|
|
6
|
+
|
|
7
|
+
The CLI registers as the `jentic-apitools` entry point and provides seven commands. The `analyze` command runs validation diagnostics against an OpenAPI spec using multiple backends (Redocly, Spectral, custom rules, and optional LLM semantic analysis). The `score` command calculates the AI-readiness score using Jentic's 6-dimension framework. The `import` command processes a spec through the full import pipeline, producing scored and cataloged artifacts written to a directory or ZIP archive.
|
|
8
|
+
|
|
9
|
+
All three core commands accept input as a local file path, an HTTP(S) URL, or stdin (using `-` with optional `--stdin-filepath`). For `analyze` and `score`, output defaults to JSON on stdout and can be redirected to a file with `--output`. The `import` command always writes its artifacts to a directory (via `--output`) or to a ZIP archive (via `--archive`) and emits a summary JSON document to stdout. A `--format text` option provides human-readable output. The `-q`/`--quiet` flag, available on `analyze`, `score`, and `import`, suppresses log output so only command results appear on stdout, which is useful when piping to tools like `jq`.
|
|
10
|
+
|
|
11
|
+
The remaining commands handle batch repository operations: `bulk-rescore` iterates all specs in a local repository clone; `recalculate-scores` rebuilds the `scores.json` index; `rebuild-scores-json` and `rebuild-apis-json` rebuild catalog files.
|
|
12
|
+
|
|
13
|
+
## LLM Configuration
|
|
14
|
+
|
|
15
|
+
The `--enable-llm-analysis` flag (on `analyze`, `score`, and `import`) and the `bulk-rescore` command (which always uses LLM) require credentials for the configured LLM provider. Set `LLM_PROVIDER` and `LIGHT_LLM_PROVIDER` (default: `BEDROCK`) and provide the corresponding API key:
|
|
16
|
+
|
|
17
|
+
| Provider | Required environment variable |
|
|
18
|
+
|---|---|
|
|
19
|
+
| `OPENAI` | `OPENAI_API_KEY` or `JENTIC_OPENAI_API_KEY` |
|
|
20
|
+
| `CLAUDE` / `ANTHROPIC` | `ANTHROPIC_API_KEY` or `JENTIC_ANTHROPIC_API_KEY` |
|
|
21
|
+
| `GEMINI` | `GEMINI_API_KEY` or `JENTIC_GEMINI_API_KEY` |
|
|
22
|
+
| `BEDROCK` | AWS credentials via boto3 (IAM role or `~/.aws/credentials`) |
|
|
23
|
+
|
|
24
|
+
See `.env.example` for the full list of configuration options. The CLI validates credentials at startup and provides actionable error messages if they are missing.
|
|
25
|
+
|
|
26
|
+
## Dependencies
|
|
27
|
+
|
|
28
|
+
Internal: `jentic.apitools.common`, `jentic.apitools.analyze`, `jentic.apitools.pipelines`, `jentic.apitools.jobs`. External: click, rich.
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
uv add cli
|
|
34
|
+
# The CLI is available as:
|
|
35
|
+
uv run jentic-apitools --help
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Quick Start
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Analyze a local spec
|
|
42
|
+
uv run jentic-apitools analyze openapi.json
|
|
43
|
+
|
|
44
|
+
# Analyze with text output and fail on warnings
|
|
45
|
+
uv run jentic-apitools analyze openapi.json --format text --fail-on warn
|
|
46
|
+
|
|
47
|
+
# Score a spec from URL
|
|
48
|
+
uv run jentic-apitools score https://petstore3.swagger.io/api/v3/openapi.json
|
|
49
|
+
|
|
50
|
+
# Score with minimum threshold
|
|
51
|
+
uv run jentic-apitools score openapi.json --min-score 80
|
|
52
|
+
|
|
53
|
+
# Import from URL to directory
|
|
54
|
+
uv run jentic-apitools import https://example.com/openapi.json --output ./output --label example.com/api
|
|
55
|
+
|
|
56
|
+
# Import to ZIP archive
|
|
57
|
+
uv run jentic-apitools import openapi.json --archive output.zip
|
|
58
|
+
|
|
59
|
+
# Pipe from stdin
|
|
60
|
+
cat openapi.yaml | uv run jentic-apitools analyze - --stdin-filepath openapi.yaml
|
|
61
|
+
curl -s https://example.com/openapi.json | uv run jentic-apitools score -
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### analyze
|
|
65
|
+
|
|
66
|
+
The `analyze` command runs validation diagnostics against an OpenAPI specification.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
uv run jentic-apitools analyze <SPEC> [--format json|text] [--output FILE] [--base-url URL] [--enable-llm-analysis] [--stdin-filepath PATH] [--fail-on error|warn|info|hint|none]
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The `SPEC` argument accepts a local file path (relative or absolute), an HTTP(S) URL, or `-` for stdin. When using stdin, `--stdin-filepath` provides a virtual path for format detection.
|
|
73
|
+
|
|
74
|
+
Default output is JSON to stdout with a diagnostics array and summary counts. The `--format text` option produces a human-readable report. The `--fail-on` option causes exit code 2 if any diagnostic meets or exceeds the specified severity.
|
|
75
|
+
|
|
76
|
+
Options:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
SPEC Local file path, URL, or - for stdin (required)
|
|
80
|
+
--format, -f TEXT Output format: json or text (default: json)
|
|
81
|
+
--output, -o FILE Write output to file instead of stdout
|
|
82
|
+
--base-url URL Base URL for resolving references (default: spec URL)
|
|
83
|
+
--stdin-filepath PATH Virtual filepath for stdin input (format detection)
|
|
84
|
+
--enable-llm-analysis Enable LLM-based semantic analysis
|
|
85
|
+
--fail-on LEVEL Exit code 2 if severity >= level (default: none)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### score
|
|
89
|
+
|
|
90
|
+
The `score` command calculates the AI-readiness score for an OpenAPI specification.
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
uv run jentic-apitools score <SPEC> [--format json|text] [--output FILE] [--label LABEL] [--vendor VENDOR] [--api API] [--min-score N] [--enable-llm-analysis] [--include-diagnostics] [--skip-bundle] [--stdin-filepath PATH] [--original-url URL] [--api-id ID] [--api-version-id ID] [--canonical-source-url URL] [--canonical-artifacts-base-url URL] [--canonical-artifacts-base-url-ui URL]
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Output is the full scorecard JSON by default. The `--format text` option shows a human-readable summary with overall score, grade, level, and per-dimension breakdowns. The `--min-score` option causes exit code 2 if the overall score is below the threshold.
|
|
97
|
+
|
|
98
|
+
Options:
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
SPEC Local file path, URL, or - for stdin (required)
|
|
102
|
+
--format, -f TEXT Output format: json or text (default: json)
|
|
103
|
+
--output, -o FILE Write output to file instead of stdout
|
|
104
|
+
--label TEXT Vendor/API label (mutually exclusive with --vendor)
|
|
105
|
+
--vendor TEXT Vendor name, combined with --api to form label
|
|
106
|
+
--api TEXT API name (default: main, requires --vendor)
|
|
107
|
+
--min-score N Exit code 2 if score < N
|
|
108
|
+
--enable-llm-analysis Enable LLM-based semantic analysis
|
|
109
|
+
--include-diagnostics Include diagnostics in score output
|
|
110
|
+
--skip-bundle Skip bundling step
|
|
111
|
+
--stdin-filepath PATH Virtual filepath for stdin input
|
|
112
|
+
--original-url URL Original spec URL for provenance tracking
|
|
113
|
+
--api-id ID Logical API identifier
|
|
114
|
+
--api-version-id ID Logical API version identifier
|
|
115
|
+
--canonical-source-url URL Canonical source URL for metadata
|
|
116
|
+
--canonical-artifacts-base-url URL Canonical base URL for raw artifacts
|
|
117
|
+
--canonical-artifacts-base-url-ui URL Canonical base URL for UI artifact links
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### import
|
|
121
|
+
|
|
122
|
+
The `import` command processes an OpenAPI specification through the full import pipeline.
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
uv run jentic-apitools import <SPEC> (--output DIR | --archive FILE.zip) [--label LABEL] [--vendor VENDOR] [--api API] [--overwrite] [--enable-llm-analysis] [--skip-bundle] [--stdin-filepath PATH] [--original-url URL] [--api-id ID] [--api-version-id ID] [--canonical-source-url URL] [--canonical-artifacts-base-url URL] [--canonical-artifacts-base-url-ui URL]
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Either `--output DIR` or `--archive FILE.zip` must be specified. With `--output`, artifacts are written to the directory. With `--archive`, they are packaged as a ZIP file. On success, a JSON manifest is written to stdout.
|
|
129
|
+
|
|
130
|
+
Options:
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
SPEC Local file path, URL, or - for stdin (required)
|
|
134
|
+
--output, -o DIR Output directory for artifacts
|
|
135
|
+
--archive FILE.zip Write artifacts as a ZIP archive
|
|
136
|
+
--label TEXT Vendor/API label (mutually exclusive with --vendor)
|
|
137
|
+
--vendor TEXT Vendor name, combined with --api to form label
|
|
138
|
+
--api TEXT API name (default: main, requires --vendor)
|
|
139
|
+
--overwrite Overwrite existing output directory or archive
|
|
140
|
+
--enable-llm-analysis Enable LLM-based semantic analysis
|
|
141
|
+
--skip-bundle Skip bundling step
|
|
142
|
+
--stdin-filepath PATH Virtual filepath for stdin input
|
|
143
|
+
--original-url URL Original spec URL for provenance tracking
|
|
144
|
+
--api-id ID Logical API identifier
|
|
145
|
+
--api-version-id ID Logical API version identifier
|
|
146
|
+
--canonical-source-url URL Canonical source URL for metadata
|
|
147
|
+
--canonical-artifacts-base-url URL Canonical base URL for raw artifacts
|
|
148
|
+
--canonical-artifacts-base-url-ui URL Canonical base URL for UI artifact links
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### bulk-rescore
|
|
152
|
+
|
|
153
|
+
The `bulk-rescore` command rescores all OpenAPI specs in a local clone of a repository with the `apis/openapi/<vendor>/<api>/<version>/openapi.json` directory structure. It runs `import_openapi` for each spec, then copies the updated `scorecard.json`, `diagnostics.json`, and the `diagnostics` section of `meta.json` back into the local repo. When not in dry-run mode, the command also recalculates `scores.json` with all scores sorted by value in descending order.
|
|
154
|
+
|
|
155
|
+
> **Note:** This command always uses LLM analysis. Ensure your LLM provider credentials are configured (see [LLM Configuration](#llm-configuration)).
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
uv run jentic-apitools bulk-rescore /path/to/jentic-public-apis
|
|
159
|
+
uv run jentic-apitools bulk-rescore /path/to/jentic-public-apis --max-iterations 2 --dry-run
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Options:
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
LOCAL_REPO_PATH Path to root of the local repo clone (required)
|
|
166
|
+
--github-repo-url TEXT GitHub repository URL (default: https://github.com/jentic/jentic-public-apis)
|
|
167
|
+
--output-dir, -o PATH Output directory for rescore results (default: __data__/rescore_<datetime>)
|
|
168
|
+
--github-repo-branch TEXT GitHub repository branch (default: main)
|
|
169
|
+
--base-dir TEXT Base directory for OpenAPI specs within the repo (default: apis/openapi)
|
|
170
|
+
--max-iterations INTEGER Maximum number of APIs to process, useful for testing (default: no limit)
|
|
171
|
+
--dry-run Run without copying results to the local repo
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### recalculate-scores
|
|
175
|
+
|
|
176
|
+
Rebuilds `scores.json` from all `scorecard.json` files found under a local repository clone.
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
uv run jentic-apitools recalculate-scores /path/to/jentic-public-apis
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Options:
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
LOCAL_REPO_PATH Path to root of the local repo clone (required)
|
|
186
|
+
--base-dir TEXT Base directory for OpenAPI specs within the repo (default: apis/openapi)
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### rebuild-scores-json
|
|
190
|
+
|
|
191
|
+
Rebuilds `scores.json` from all `scorecard.json` files with additional GitHub repo and branch configuration.
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
uv run jentic-apitools rebuild-scores-json /path/to/jentic-public-apis
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### rebuild-apis-json
|
|
198
|
+
|
|
199
|
+
Rebuilds the root `apis.json` catalog from all version-level `apis.json` files.
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
uv run jentic-apitools rebuild-apis-json /path/to/jentic-public-apis
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Exit Codes
|
|
206
|
+
|
|
207
|
+
All commands use consistent exit codes: 0 for success, 1 for runtime or pipeline errors, and 2 for policy failures (triggered by `--fail-on` or `--min-score` thresholds).
|
|
208
|
+
|
|
209
|
+
## Testing
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
uv run --package cli pytest packages/cli/tests -v
|
|
213
|
+
```
|