You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Add external repository support for repro command (v0.20.1) (#52)
* fix: add external repository support for repro command (0.20.1)
- Add environment manager detection (hatch, poetry, uv, pip)
- Make all validation tools optional with clear messaging
- Add dynamic source directory detection
- Update documentation for external repo support
- Add comprehensive test coverage (25 new tests)
Fixes critical design issue where repro command only worked on
SpecFact CLI's own codebase. Now works on external repositories
without requiring SpecFact CLI adoption.
Closes: External repository support issue
Reference: CRITICAL_DESIGN_ISSUE_EXTERNAL_REPO_SUPPORT.md
* fix: add external repository support for generate commands (0.20.1)
- Fix generate contracts-apply: use dynamic source/test detection
- Fix generate test-prompt: use dynamic source directory detection
- Add test directory detection utilities (detect_test_directories, find_test_files_for_source)
- Use environment detection for Python/pytest invocations
- Add comprehensive tests (6 new tests for test detection utilities)
Completes external repository support fixes identified in analysis.
All generate commands now work on external repositories.
* test: add comprehensive tests for repro setup and init environment warning
- Add 15 integration tests for repro setup command covering:
- pyproject.toml creation and updates with CrossHair config
- Environment manager detection (hatch, poetry, uv, pip)
- Source directory detection (src/, lib/, package name)
- CrossHair tool availability checking and installation
- Error handling and user guidance
- Add 5 e2e tests for init command environment manager warning:
- Warning display when no environment manager detected
- No warning when hatch/poetry/pip/uv detected
- Update CHANGELOG.md with new features and test coverage improvements
All tests passing (20/20)
* feat: align init --install-deps with environment manager detection
- Update init --install-deps to use build_tool_command for environment-aware installation
- Automatically detect and use hatch, poetry, uv, or pip based on project configuration
- Show detected environment manager message and command being used
- Provide environment-specific installation guidance on errors
- Add 5-minute timeout for package installation
- Track environment manager in telemetry
- Update help text to reflect environment manager awareness
- Update CHANGELOG.md with improvements
This ensures consistent behavior with repro setup command and proper
integration with different Python project management tools.
---------
Co-authored-by: Dominikus Nold <[email protected]>
-**Documentation**: Updated `repro` command documentation to clarify external repository support and environment requirements
49
+
- Added `repro setup` command documentation
50
+
- Updated all example flows to include CrossHair setup step
51
+
- Added "Supported Project Management Tools" section to installation guide
52
+
-**Error Messages**: Improved messaging when tools are unavailable, providing clear guidance on installation
53
+
-**Code Quality**: All linting/formatting tools in `generate contracts-apply` now use environment detection
54
+
-**Test Coverage**: Added comprehensive test suite for `repro setup` command (15 tests) and `init` command environment warning (5 tests)
55
+
-**`init --install-deps` Command**: Now uses environment manager detection for package installation
56
+
- Automatically detects and uses hatch, poetry, uv, or pip based on project configuration
57
+
- Provides environment-specific installation commands and error guidance
58
+
- Shows detected environment manager and command being used
59
+
- Adds timeout handling and improved error messages
60
+
- Tracks environment manager in telemetry
61
+
62
+
### Notes (0.20.1)
63
+
64
+
This patch release fixes the critical design issue identified during OSS validation planning. The `repro` command can now be used to validate external repositories (Requests, Flask, FastAPI, etc.) without requiring those projects to adopt SpecFact CLI.
Copy file name to clipboardExpand all lines: docs/examples/integration-showcases/integration-showcases-testing-guide.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1035,11 +1035,17 @@ Report written to: .specfact/projects/<bundle-name>/reports/enforcement/report-<
1035
1035
- Type checking (basedpyright) - type annotations and type safety
1036
1036
1037
1037
- **Conditionally runs** (only if present):
1038
-
- Contract exploration (CrossHair) - only if `src/` directory exists (symbolic execution to find counterexamples, not runtime contract validation)
1038
+
- Contract exploration (CrossHair) - only if `[tool.crosshair]` config exists in `pyproject.toml` (use `specfact repro setup` to generate) and `src/` directory exists (symbolic execution to find counterexamples, not runtime contract validation)
1039
1039
- Semgrep async patterns - only if `tools/semgrep/async.yml` exists (requires semgrep installed)
1040
1040
- Property tests (pytest) - only if `tests/contracts/` directory exists
1041
1041
- Smoke tests (pytest) - only if `tests/smoke/` directory exists
1042
1042
1043
+
**CrossHair Setup**: Before running `repro` for the first time, set up CrossHair configuration:
1044
+
```bash
1045
+
specfact repro setup
1046
+
```
1047
+
This automatically generates `[tool.crosshair]` configuration in `pyproject.toml` to enable contract exploration.
1048
+
1043
1049
**Important**: `repro` does **not** perform runtime contract validation (checking `@icontract` decorators at runtime). It runs static analysis (linting, type checking) and symbolic execution (CrossHair) for contract exploration. Type mismatches will be detected by the type checking tool (basedpyright) if available. The enforcement configuration determines whether failures block the workflow.
- **Bidirectional sync**: Use `sync bridge --adapter <adapter>` or `sync repository` for ongoing change management
323
326
- **Semgrep (optional)**: Install `pip install semgrep` for async pattern detection in `specfact repro`
324
327
328
+
---
329
+
330
+
## Supported Project Management Tools
331
+
332
+
SpecFact CLI automatically detects and works with the following Python project management tools. **No configuration needed** - it detects your project's environment manager automatically!
333
+
334
+
### Automatic Detection
335
+
336
+
When you run SpecFact CLI commands on a repository, it automatically:
337
+
338
+
1. **Detects the environment manager** by checking for configuration files
339
+
2. **Detects source directories** (`src/`, `lib/`, or package name from `pyproject.toml`)
340
+
3. **Builds appropriate commands** using the detected environment manager
341
+
4. **Checks tool availability** and skips with clear messages if tools are missing
342
+
343
+
### Supported Tools
344
+
345
+
#### 1. **hatch** - Modern Python project manager
346
+
347
+
- **Detection**: `[tool.hatch]` section in `pyproject.toml`
348
+
- **Command prefix**: `hatch run`
349
+
- **Example**: `hatch run pytest tests/`
350
+
- **Use case**: Modern Python projects using hatch for build and dependency management
351
+
352
+
#### 2. **poetry** - Dependency management and packaging
353
+
354
+
- **Detection**: `[tool.poetry]` section in `pyproject.toml` or `poetry.lock` file
355
+
- **Command prefix**: `poetry run`
356
+
- **Example**: `poetry run pytest tests/`
357
+
- **Use case**: Projects using Poetry for dependency management
358
+
359
+
#### 3. **uv** - Fast Python package installer and resolver
360
+
361
+
- **Detection**: `[tool.uv]` section in `pyproject.toml`, `uv.lock`, or `uv.toml` file
362
+
- **Command prefix**: `uv run`
363
+
- **Example**: `uv run pytest tests/`
364
+
- **Use case**: Projects using uv for fast package management
365
+
366
+
#### 4. **pip** - Standard Python package installer
367
+
368
+
- **Detection**: `requirements.txt` or `setup.py` file
369
+
- **Command prefix**: Direct tool invocation (no prefix)
370
+
- **Example**: `pytest tests/`
371
+
- **Use case**: Traditional Python projects using pip and virtual environments
372
+
373
+
### Detection Priority
374
+
375
+
SpecFact CLI checks in this order:
376
+
377
+
1. `pyproject.toml` for tool sections (`[tool.hatch]`, `[tool.poetry]`, `[tool.uv]`)
0 commit comments