lingtest-cli 0.2.0__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.
@@ -0,0 +1,11 @@
1
+ .venv/
2
+ dist/
3
+ .pytest_cache/
4
+ .ruff_cache/
5
+ __pycache__/
6
+ *.py[cod]
7
+ *.egg-info/
8
+ lingtest-cases.json
9
+ lingtest-report.json
10
+ junit.xml
11
+
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 LingTest Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,410 @@
1
+ Metadata-Version: 2.4
2
+ Name: lingtest-cli
3
+ Version: 0.2.0
4
+ Summary: AI testing agent for PRDs, OpenAPI specifications, and Vibe Coding workflows
5
+ Project-URL: Homepage, https://github.com/sunweitest/lingtest-cli
6
+ Project-URL: Repository, https://github.com/sunweitest/lingtest-cli
7
+ Project-URL: Issues, https://github.com/sunweitest/lingtest-cli/issues
8
+ Author: LingTest Contributors
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: ai,api,cli,openapi,pytest,testing,vibe-coding
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Software Development :: Testing
19
+ Requires-Python: >=3.11
20
+ Requires-Dist: httpx<1,>=0.27
21
+ Requires-Dist: pydantic<3,>=2.8
22
+ Requires-Dist: pyyaml<7,>=6.0
23
+ Requires-Dist: typer<1,>=0.12
24
+ Provides-Extra: ai
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest-cov<7,>=5; extra == 'dev'
27
+ Requires-Dist: pytest<9,>=8.2; extra == 'dev'
28
+ Requires-Dist: ruff>=0.6; extra == 'dev'
29
+ Requires-Dist: twine<7,>=5; extra == 'dev'
30
+ Description-Content-Type: text/markdown
31
+
32
+ # LingTest CLI
33
+
34
+ [简体中文](README.zh-CN.md) | English
35
+
36
+ LingTest CLI is a local-first AI testing agent for Vibe Coding workflows. It
37
+ analyzes PRDs, generates validated test plans from requirements and OpenAPI,
38
+ runs deterministic HTTP tests, and diagnoses failures with structured evidence.
39
+
40
+ The deterministic core does not require an LLM or API key. Generated cases are
41
+ plain JSON, so they can be reviewed and changed before any request is sent.
42
+
43
+ > Status: `0.2.0` alpha. The file format and Python API may evolve before 1.0.
44
+
45
+ ## What's New in 0.2.0
46
+
47
+ - Independent OpenAI-compatible provider layer with no FastAPI, Redis, database,
48
+ or worker dependency.
49
+ - Built-in provider presets for OpenAI, DeepSeek, and Qwen, plus custom
50
+ `base_url` and model support.
51
+ - `lingtest analyze` for PRD ambiguity, contradiction, missing requirement, and
52
+ testability-risk analysis.
53
+ - `lingtest ai-generate` for functional, boundary, exception, and API test plans.
54
+ - `lingtest diagnose` for evidence-grounded failure classification and advice.
55
+ - Pydantic validation for every AI result, with one controlled correction retry.
56
+ - Provider credentials read from environment variables and excluded from cases
57
+ and reports.
58
+ - Expanded Chinese and English documentation, product design, and Vibe Coding
59
+ testing article.
60
+
61
+ ## Features
62
+
63
+ - Read OpenAPI specifications in YAML or JSON.
64
+ - Discover GET, POST, PUT, PATCH, DELETE, HEAD, and OPTIONS operations.
65
+ - Generate values from `example`, `default`, `enum`, and schema types.
66
+ - Resolve path parameters and generate query, header, and JSON body values.
67
+ - Select the first documented 2xx response as the expected status.
68
+ - Run cases with HTTPX using a configurable base URL and timeout.
69
+ - Add runtime headers without storing credentials in generated cases.
70
+ - Write detailed JSON reports and optional JUnit XML.
71
+ - Return CI-friendly exit codes.
72
+ - Use the same core through a small Python API.
73
+ - Analyze PRDs for ambiguity, contradictions, missing requirements, and testability risks.
74
+ - Generate validated functional, boundary, exception, and API test plans with an LLM.
75
+ - Diagnose failed HTTP tests with evidence-grounded structured output.
76
+ - Connect to OpenAI, DeepSeek, Qwen, or a custom OpenAI-compatible provider.
77
+
78
+ ## Requirements
79
+
80
+ - Python 3.11 or newer
81
+ - An OpenAPI 3.x YAML or JSON document
82
+ - Network access to the API under test when running cases
83
+
84
+ ## Installation
85
+
86
+ ### Standard `pip`
87
+
88
+ Install into the active Python environment or virtual environment:
89
+
90
+ ```bash
91
+ python -m pip install lingtest-cli
92
+ lingtest --version
93
+ ```
94
+
95
+ Use this when LingTest should share an existing project environment or when
96
+ `pip` is your standard package manager.
97
+
98
+ ### Isolated CLI with `pipx` (recommended)
99
+
100
+ ```bash
101
+ pipx install lingtest-cli
102
+ ```
103
+
104
+ `pipx` creates a dedicated environment while making the `lingtest` command
105
+ available globally. This avoids dependency conflicts with application projects.
106
+
107
+ ### Isolated CLI with `uv`
108
+
109
+ ```bash
110
+ uv tool install lingtest-cli
111
+ ```
112
+
113
+ ### Add to a UV project
114
+
115
+ ```bash
116
+ uv add --dev lingtest-cli
117
+ uv run lingtest --help
118
+ ```
119
+
120
+ All installation methods provide the same `lingtest` command and Python API.
121
+
122
+ ## Quick Start
123
+
124
+ Generate cases:
125
+
126
+ ```bash
127
+ lingtest generate openapi.yaml -o cases.json
128
+ ```
129
+
130
+ Review `cases.json`, then run it:
131
+
132
+ ```bash
133
+ lingtest run cases.json \
134
+ --base-url http://localhost:8000 \
135
+ --junit junit.xml \
136
+ -o report.json
137
+ ```
138
+
139
+ PowerShell authentication example:
140
+
141
+ ```powershell
142
+ lingtest run cases.json `
143
+ --base-url https://api.example.com `
144
+ -H "Authorization:Bearer $env:API_TOKEN" `
145
+ --junit junit.xml
146
+ ```
147
+
148
+ Use `-H` multiple times to add more headers:
149
+
150
+ ```bash
151
+ lingtest run cases.json --base-url https://api.example.com \
152
+ -H "Authorization:Bearer ${API_TOKEN}" \
153
+ -H "X-Tenant-ID:demo"
154
+ ```
155
+
156
+ Analyze requirements and generate an AI test plan:
157
+
158
+ ```bash
159
+ export OPENAI_API_KEY="..."
160
+ lingtest analyze requirements.md -o analysis.json
161
+ lingtest ai-generate requirements.md -o ai-cases.json
162
+ ```
163
+
164
+ Diagnose failed cases from a LingTest JSON report:
165
+
166
+ ```bash
167
+ lingtest diagnose report.json -o diagnosis.json
168
+ ```
169
+
170
+ Use `--provider deepseek`, `--provider qwen`, or a custom OpenAI-compatible
171
+ endpoint with `--provider custom --base-url URL --model MODEL`.
172
+
173
+ ## Test Data Flow
174
+
175
+ ```mermaid
176
+ flowchart LR
177
+ PRD["PRD / Requirements"] --> Analyze["lingtest analyze"]
178
+ Analyze --> Analysis["analysis.json<br/>ambiguities and risks"]
179
+
180
+ PRD --> AIGenerate["lingtest ai-generate"]
181
+ OpenAPI["OpenAPI YAML / JSON"] --> AIGenerate
182
+ AIGenerate --> AIPlan["ai-cases.json<br/>validated test plan"]
183
+ AIPlan --> Review["Human review"]
184
+
185
+ OpenAPI --> Generate["lingtest generate"]
186
+ Generate --> Cases["cases.json<br/>executable HTTP cases"]
187
+ Review -.->|planned 0.3 conversion| Cases
188
+
189
+ Cases --> Run["lingtest run"]
190
+ Runtime["Base URL + runtime headers"] --> Run
191
+ Run --> JSONReport["report.json<br/>original evidence"]
192
+ Run --> JUnit["junit.xml<br/>CI result"]
193
+
194
+ JSONReport --> Diagnose["lingtest diagnose"]
195
+ Diagnose --> Diagnosis["diagnosis.json<br/>classification, evidence, advice"]
196
+ ```
197
+
198
+ The solid path is implemented in `0.2.0`. AI plans remain review artifacts;
199
+ automatic conversion from an approved AI plan to executable HTTP cases is
200
+ planned for `0.3`. Diagnosis produces a separate file and never overwrites the
201
+ original run report.
202
+
203
+ ## Commands
204
+
205
+ ### `lingtest analyze`
206
+
207
+ Finds ambiguities, contradictions, missing requirements, and testability risks
208
+ in `.txt`, `.md`, `.json`, `.yaml`, and `.yml` documents.
209
+
210
+ ### `lingtest ai-generate`
211
+
212
+ Generates a validated plan containing functional, boundary, exception, and API
213
+ test cases. AI cases are review artifacts and are never executed implicitly.
214
+
215
+ ### `lingtest diagnose`
216
+
217
+ Reads a LingTest JSON run report and classifies failed cases using the supplied
218
+ execution evidence.
219
+
220
+ ### `lingtest generate`
221
+
222
+ ```text
223
+ lingtest generate SPEC [-o OUTPUT]
224
+ ```
225
+
226
+ `SPEC` is an OpenAPI YAML or JSON file. The default output is
227
+ `lingtest-cases.json`.
228
+
229
+ ### `lingtest run`
230
+
231
+ ```text
232
+ lingtest run CASES_FILE --base-url URL [OPTIONS]
233
+ ```
234
+
235
+ Important options:
236
+
237
+ | Option | Description | Default |
238
+ | --- | --- | --- |
239
+ | `--base-url` | Base URL of the API under test. It can also be provided through `LINGTEST_BASE_URL`. | Required |
240
+ | `-o`, `--output` | JSON report path. | `lingtest-report.json` |
241
+ | `--junit` | Optional JUnit XML report path. | Disabled |
242
+ | `--timeout` | Per-request timeout in seconds. | `10.0` |
243
+ | `-H`, `--header` | Runtime HTTP header in `NAME:VALUE` form. Repeatable. | None |
244
+
245
+ Exit codes:
246
+
247
+ | Code | Meaning |
248
+ | --- | --- |
249
+ | `0` | All test cases passed. |
250
+ | `1` | One or more test cases failed or produced a request error. |
251
+ | `2` | The command input or case file is invalid. |
252
+
253
+ ## Case File
254
+
255
+ Generated files are JSON arrays. A case looks like this:
256
+
257
+ ```json
258
+ {
259
+ "id": "get_user",
260
+ "title": "Get user",
261
+ "method": "GET",
262
+ "path": "/users/42",
263
+ "expected_status": 200,
264
+ "headers": {},
265
+ "query": {
266
+ "verbose": true
267
+ },
268
+ "body": null
269
+ }
270
+ ```
271
+
272
+ Edit `expected_status`, request values, or titles before execution. Do not put
273
+ long-lived credentials in this file; inject them with `--header` and environment
274
+ variables at runtime.
275
+
276
+ ## Reports
277
+
278
+ The JSON report contains the start time, base URL, and a result for each case:
279
+
280
+ - case ID and title
281
+ - `passed`, `failed`, or `error` status
282
+ - request duration in milliseconds
283
+ - expected and actual HTTP status
284
+ - a concise error message
285
+
286
+ JUnit output can be uploaded to GitHub Actions, Jenkins, GitLab CI, Azure
287
+ Pipelines, and other systems that support JUnit XML.
288
+
289
+ ## Python API
290
+
291
+ ```python
292
+ from lingtest import generate_cases, run_cases
293
+
294
+ cases = generate_cases("openapi.yaml")
295
+ report = run_cases(cases, "http://localhost:8000")
296
+
297
+ print(f"{report.passed} passed, {report.failed} failed")
298
+ for result in report.results:
299
+ print(result.case_id, result.status, result.duration_ms)
300
+ ```
301
+
302
+ The public data models are `TestCase`, `TestResult`, and `RunReport`.
303
+
304
+ ## CI Example
305
+
306
+ ```yaml
307
+ name: API tests
308
+
309
+ on: [push, pull_request]
310
+
311
+ jobs:
312
+ lingtest:
313
+ runs-on: ubuntu-latest
314
+ steps:
315
+ - uses: actions/checkout@v4
316
+ - uses: astral-sh/setup-uv@v6
317
+ - run: uv tool install lingtest-cli
318
+ - run: lingtest generate openapi.yaml -o cases.json
319
+ - run: lingtest run cases.json --base-url "${{ secrets.TEST_API_URL }}" --junit junit.xml
320
+ ```
321
+
322
+ The target API must be reachable from the runner. Start the service in an
323
+ earlier step or point the command at a deployed test environment.
324
+
325
+ ## AI Providers
326
+
327
+ | Provider | Option | API key environment variable | Default model |
328
+ | --- | --- | --- | --- |
329
+ | OpenAI | `--provider openai` | `OPENAI_API_KEY` | `gpt-4.1-mini` |
330
+ | DeepSeek | `--provider deepseek` | `DEEPSEEK_API_KEY` | `deepseek-chat` |
331
+ | Qwen | `--provider qwen` | `DASHSCOPE_API_KEY` | `qwen-plus` |
332
+ | Custom | `--provider custom` | `LINGTEST_API_KEY` | Set with `--model` |
333
+
334
+ Provider responses are parsed as JSON and validated with Pydantic. LingTest
335
+ requests one correction when a response fails validation. Documents are sent
336
+ to the configured provider; review its privacy policy before processing
337
+ confidential requirements.
338
+
339
+ ## Current Limitations
340
+
341
+ - `$ref` resolution and advanced schema composition are not implemented yet.
342
+ - Assertions currently compare the HTTP status only.
343
+ - Cases run sequentially.
344
+ - OpenAPI security schemes are not applied automatically.
345
+ - PDF and DOCX document extraction are not implemented.
346
+ - AI-generated cases are review artifacts and are not automatically converted
347
+ into executable HTTP cases.
348
+
349
+ See [product-design.html](product-design.html) for implemented scope, design
350
+ decisions, and the roadmap.
351
+
352
+ The Chinese essay [AI Agent 时代如何打造高质量软件](docs/blog/ai-testing-for-vibe-coding.zh-CN.md)
353
+ explains the Vibe Coding quality problem behind this project.
354
+
355
+ ## Development
356
+
357
+ Clone the repository and install all development dependencies:
358
+
359
+ ```bash
360
+ uv sync --extra dev
361
+ uv run pytest
362
+ uv run ruff check .
363
+ ```
364
+
365
+ Build and validate distributions:
366
+
367
+ ```bash
368
+ uv build
369
+ uv run twine check dist/*
370
+ ```
371
+
372
+ Run the development CLI:
373
+
374
+ ```bash
375
+ uv run lingtest --version
376
+ uv run lingtest generate examples/openapi.yaml -o cases.json
377
+ ```
378
+
379
+ ## Release
380
+
381
+ 1. Update the version in `pyproject.toml` and `src/lingtest/__init__.py`.
382
+ 2. Run tests, Ruff, `uv build`, and `twine check`.
383
+ 3. Commit the release and create a matching Git tag.
384
+ 4. Publish with `UV_PUBLISH_TOKEN`:
385
+
386
+ ```bash
387
+ uv publish
388
+ ```
389
+
390
+ ## Security
391
+
392
+ Only run generated cases against systems you are authorized to test. Runtime
393
+ headers are not written to the report by version 0.2, but generated case files
394
+ and reports should still be treated as project data.
395
+
396
+ ## Roadmap
397
+
398
+ - Better OpenAPI schema and `$ref` support
399
+ - Configuration files and named environments
400
+ - Filtering by tag, operation, path, and method
401
+ - JSON-path, schema, header, and latency assertions
402
+ - Authentication strategies
403
+ - Controlled concurrency and retries
404
+ - Static HTML reports
405
+ - Conversion of reviewed AI API cases into deterministic executable cases
406
+ - pytest export and a stable plugin API
407
+
408
+ ## License
409
+
410
+ [MIT](LICENSE)