pitstop-cli 1.1.1__tar.gz → 1.3.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.
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/.github/workflows/ci.yml +10 -3
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/.github/workflows/release.yml +22 -7
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/.github/workflows/upstream-smoke.yml +5 -0
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/CHANGELOG.md +31 -0
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/PKG-INFO +27 -13
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/README.md +24 -10
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/evals/agent/recipes.json +36 -8
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/evals/agent/tasks.json +20 -2
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/pyproject.toml +6 -5
- pitstop_cli-1.3.0/scripts/geo-acceptance.sh +136 -0
- pitstop_cli-1.3.0/scripts/smoke-installed.py +86 -0
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/skills/pitstop/SKILL.md +15 -4
- pitstop_cli-1.3.0/src/pitstop/cache.py +63 -0
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/src/pitstop/chargers.py +36 -6
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/src/pitstop/cli.py +89 -37
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/src/pitstop/core.py +65 -26
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/src/pitstop/cpo_tariffs.py +2 -2
- pitstop_cli-1.3.0/src/pitstop/geocoding.py +253 -0
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/src/pitstop/mcp_server.py +75 -40
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/src/pitstop/overpass.py +44 -19
- pitstop_cli-1.3.0/src/pitstop/results.py +22 -0
- pitstop_cli-1.3.0/src/pitstop/validation.py +52 -0
- pitstop_cli-1.3.0/src/pitstop/version.py +1 -0
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/tests/test_chargers.py +46 -3
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/tests/test_core.py +25 -0
- pitstop_cli-1.3.0/tests/test_geocoding.py +79 -0
- pitstop_cli-1.3.0/tests/test_query_reuse.py +39 -0
- pitstop_cli-1.3.0/tests/test_retry.py +61 -0
- pitstop_cli-1.3.0/tests/test_validation.py +59 -0
- pitstop_cli-1.1.1/src/pitstop/geocoding.py +0 -146
- pitstop_cli-1.1.1/src/pitstop/version.py +0 -1
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/.gitignore +0 -0
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/LICENSE +0 -0
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/evals/agent/README.md +0 -0
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/evals/agent/results/.gitkeep +0 -0
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/scripts/run-agent-evals.sh +0 -0
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/src/pitstop/__init__.py +0 -0
- {pitstop_cli-1.1.1 → pitstop_cli-1.3.0}/src/pitstop/__main__.py +0 -0
|
@@ -20,15 +20,20 @@ jobs:
|
|
|
20
20
|
- run: pip install -e ".[dev]"
|
|
21
21
|
- run: pytest -q
|
|
22
22
|
|
|
23
|
-
mcp-
|
|
23
|
+
mcp-protocol:
|
|
24
24
|
runs-on: ubuntu-latest
|
|
25
|
+
strategy:
|
|
26
|
+
matrix:
|
|
27
|
+
mcp-requirement: ["mcp==1.12.0", "mcp>=2"]
|
|
25
28
|
steps:
|
|
26
29
|
- uses: actions/checkout@v4
|
|
27
30
|
- uses: actions/setup-python@v5
|
|
28
31
|
with:
|
|
29
32
|
python-version: "3.12"
|
|
30
|
-
- run: pip install
|
|
31
|
-
|
|
33
|
+
- run: pip install ".[mcp]" "$MCP_REQUIREMENT"
|
|
34
|
+
env:
|
|
35
|
+
MCP_REQUIREMENT: ${{ matrix.mcp-requirement }}
|
|
36
|
+
- run: python scripts/smoke-installed.py
|
|
32
37
|
|
|
33
38
|
build:
|
|
34
39
|
runs-on: ubuntu-latest
|
|
@@ -39,6 +44,8 @@ jobs:
|
|
|
39
44
|
python-version: "3.12"
|
|
40
45
|
- run: pip install build
|
|
41
46
|
- run: python -m build
|
|
47
|
+
- run: pip install --no-deps dist/*.whl
|
|
48
|
+
- run: python scripts/smoke-installed.py
|
|
42
49
|
|
|
43
50
|
# Offline half of the eval suite: the eval files match the shipped parser, so a
|
|
44
51
|
# recipe or task can never name a command the CLI cannot run. The live half
|
|
@@ -7,7 +7,7 @@ on:
|
|
|
7
7
|
workflow_dispatch:
|
|
8
8
|
inputs:
|
|
9
9
|
version:
|
|
10
|
-
description: Existing tag to release, for example v1.0
|
|
10
|
+
description: Existing tag to release, for example v1.2.0
|
|
11
11
|
required: true
|
|
12
12
|
type: string
|
|
13
13
|
|
|
@@ -15,6 +15,9 @@ permissions:
|
|
|
15
15
|
contents: write
|
|
16
16
|
id-token: write
|
|
17
17
|
|
|
18
|
+
env:
|
|
19
|
+
RELEASE_TAG: ${{ inputs.version || github.ref_name }}
|
|
20
|
+
|
|
18
21
|
jobs:
|
|
19
22
|
build:
|
|
20
23
|
name: Build distributions
|
|
@@ -22,18 +25,34 @@ jobs:
|
|
|
22
25
|
steps:
|
|
23
26
|
- uses: actions/checkout@v4
|
|
24
27
|
with:
|
|
25
|
-
ref: ${{ github.
|
|
28
|
+
ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', inputs.version) || github.ref }}
|
|
26
29
|
|
|
27
30
|
- uses: actions/setup-python@v5
|
|
28
31
|
with:
|
|
29
32
|
python-version: "3.12"
|
|
30
33
|
|
|
34
|
+
- name: Check tag and package versions agree
|
|
35
|
+
run: |
|
|
36
|
+
python - <<'PY'
|
|
37
|
+
import os, runpy, tomllib
|
|
38
|
+
from pathlib import Path
|
|
39
|
+
tag = os.environ["RELEASE_TAG"]
|
|
40
|
+
package = tomllib.loads(Path("pyproject.toml").read_text())["project"]["version"]
|
|
41
|
+
runtime = runpy.run_path("src/pitstop/version.py")["__version__"]
|
|
42
|
+
if tag != f"v{package}" or runtime != package:
|
|
43
|
+
raise SystemExit(f"Version mismatch: tag={tag}, package={package}, runtime={runtime}")
|
|
44
|
+
PY
|
|
45
|
+
|
|
31
46
|
- run: python -m pip install --upgrade build twine
|
|
32
47
|
|
|
33
48
|
- run: python -m build
|
|
34
49
|
|
|
35
50
|
- run: python -m twine check dist/*
|
|
36
51
|
|
|
52
|
+
- run: python -m pip install --no-deps dist/*.whl
|
|
53
|
+
|
|
54
|
+
- run: python scripts/smoke-installed.py
|
|
55
|
+
|
|
37
56
|
- uses: actions/upload-artifact@v4
|
|
38
57
|
with:
|
|
39
58
|
name: pitstop-cli-dist
|
|
@@ -51,11 +70,7 @@ jobs:
|
|
|
51
70
|
|
|
52
71
|
- name: Resolve release tag
|
|
53
72
|
run: |
|
|
54
|
-
|
|
55
|
-
echo "VERSION=${{ inputs.version }}" >> "$GITHUB_ENV"
|
|
56
|
-
else
|
|
57
|
-
echo "VERSION=${GITHUB_REF_NAME}" >> "$GITHUB_ENV"
|
|
58
|
-
fi
|
|
73
|
+
echo "VERSION=$RELEASE_TAG" >> "$GITHUB_ENV"
|
|
59
74
|
|
|
60
75
|
- name: Publish release
|
|
61
76
|
env:
|
|
@@ -4,6 +4,37 @@ All notable changes to this project are documented here. The format is based on
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project aims
|
|
5
5
|
to follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [1.2.0] - 2026-09-10
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Municipality discovery through `pitstop places` and the `find_places` MCP tool;
|
|
12
|
+
charger searches accept province and ISTAT ID and report the resolved location.
|
|
13
|
+
- Search coverage counts and cache timestamps in JSON and GeoJSON envelopes.
|
|
14
|
+
- Read-only MCP annotations and structured results; installed CLI/MCP checks
|
|
15
|
+
cover the minimum supported SDK (1.12) and the current 1.x SDK.
|
|
16
|
+
- Standard `--version` shortcut and charger download timeout/cache-age flags.
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- Replace Alperia and Neogy tariff links that returned HTTP 404 with their
|
|
21
|
+
current official charging-offer and direct-payment pages.
|
|
22
|
+
- CLI and MCP searches reject non-finite or out-of-range coordinates,
|
|
23
|
+
nonpositive radii, and negative limits before fetching data. Invalid CLI
|
|
24
|
+
searches return exit code 2 instead of empty results or invalid JSON.
|
|
25
|
+
- Freshness filters exclude prices with missing, unparseable, or future update
|
|
26
|
+
dates. Unfiltered queries still include those reported prices.
|
|
27
|
+
- Charger municipality centers come from OSM administrative relations keyed by
|
|
28
|
+
ISTAT ID, correcting the misplaced Bolzano reference. Duplicate town names
|
|
29
|
+
require disambiguation instead of silently selecting a different province.
|
|
30
|
+
- Fuel queries no longer mutate shared station/price objects. Parsed datasets
|
|
31
|
+
and statistics are reused between MCP calls and invalidated after a refresh.
|
|
32
|
+
- Cache writes use unique temporary files; malformed Overpass caches are retried
|
|
33
|
+
and valid empty caches retain their provenance during an upstream failure.
|
|
34
|
+
- Charger results exclude invalid coordinates and centers outside the radius.
|
|
35
|
+
- Release workflows check out the requested tag and verify that tag, package,
|
|
36
|
+
and runtime versions agree before publication.
|
|
37
|
+
|
|
7
38
|
## [1.1.1] - 2026-09-07
|
|
8
39
|
|
|
9
40
|
### Fixed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pitstop-cli
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: JSON-first CLI + MCP server for Italian fuel-station prices and EV charging — MIMIT, OpenStreetMap, ISTAT.
|
|
5
5
|
Project-URL: Homepage, https://github.com/galjos/pitstop-cli
|
|
6
6
|
Project-URL: Repository, https://github.com/galjos/pitstop-cli
|
|
@@ -44,10 +44,10 @@ Classifier: Topic :: Scientific/Engineering :: GIS
|
|
|
44
44
|
Classifier: Topic :: Utilities
|
|
45
45
|
Requires-Python: >=3.10
|
|
46
46
|
Provides-Extra: dev
|
|
47
|
-
Requires-Dist: mcp
|
|
47
|
+
Requires-Dist: mcp>=1.12; extra == 'dev'
|
|
48
48
|
Requires-Dist: pytest>=7; extra == 'dev'
|
|
49
49
|
Provides-Extra: mcp
|
|
50
|
-
Requires-Dist: mcp
|
|
50
|
+
Requires-Dist: mcp>=1.12; extra == 'mcp'
|
|
51
51
|
Description-Content-Type: text/markdown
|
|
52
52
|
|
|
53
53
|
# pitstop
|
|
@@ -58,11 +58,11 @@ Description-Content-Type: text/markdown
|
|
|
58
58
|
|
|
59
59
|
A JSON-first CLI and MCP server for **Italian fuel-station prices** and **EV charging stations**, designed for AI agents, scripts, and humans.
|
|
60
60
|
|
|
61
|
-
Italy publishes per-station fuel prices daily (MIMIT *Osservaprezzi Carburanti* open data) and OpenStreetMap
|
|
61
|
+
Italy publishes per-station fuel prices daily (MIMIT *Osservaprezzi Carburanti* open data), and OpenStreetMap provides EV charger locations and capabilities. Raw access means downloading multi-megabyte CSVs, joining files, sorting through misreports, and translating municipality names. `pitstop` handles those steps locally and returns JSON or a readable table.
|
|
62
62
|
|
|
63
63
|
Built for questions like:
|
|
64
64
|
- *"What's the cheapest diesel near Rome right now?"* → `pitstop stations --fuel Gasolio --near 41.9,12.5 --cheapest`
|
|
65
|
-
- *"Where can I fast-charge my EV in Bolzano?"* → `pitstop chargers --
|
|
65
|
+
- *"Where can I fast-charge my EV in Bolzano?"* → `pitstop chargers --near 46.498,11.354 --fast`
|
|
66
66
|
- *"Are these station prices statistically reliable?"* → every price says whether it was screened against its local market; screened ones carry a `regional_median`, a `deviation_pct`, and `outlier: true` when the price looks like a misreport.
|
|
67
67
|
|
|
68
68
|
International city names work out of the box (`Rome`, `Milan`, `Bozen`, `Mailand`, `Venise`, …).
|
|
@@ -78,8 +78,9 @@ Unofficial community project. Not affiliated with or endorsed by MIMIT. Fuel dat
|
|
|
78
78
|
- **Coverage:** Italy only (by design, for now).
|
|
79
79
|
- **Known caveats:**
|
|
80
80
|
- Some operators report placeholder values (e.g. `1.000`); use `--min-price` (e.g. `1.2`) to drop them.
|
|
81
|
-
- Some price records are **stale** (a few were last updated years ago); use `--fresh-within-days` and check the `UPDATED` column / `updated` field.
|
|
82
|
-
- Some stations are **mis-geocoded** in the registry.
|
|
81
|
+
- Some price records are **stale** (a few were last updated years ago); use `--fresh-within-days` and check the `UPDATED` column / `updated` field. When enabled, the freshness filter also excludes missing, unparseable, and future update dates.
|
|
82
|
+
- Some stations are **mis-geocoded** in the registry. `pitstop` uses station clusters and a second coordinate reference from [opendatasicilia/comuni-italiani](https://github.com/opendatasicilia/comuni-italiani) to flag discrepancies over 30 km as `coordinate_suspect` (`*` in the table). `--near` also excludes stations whose declared comune is geographically too far from the query point. Pass `--no-comune-validate` to disable the second reference.
|
|
83
|
+
- **Municipality reference coordinates can also be wrong.** Charger searches resolve a municipality's ISTAT ID to its mapped OpenStreetMap administrative center. JSON includes the selected `location`, its source link, cache age, and warnings when it differs from the reference coordinates. Ambiguous names require `--provincia` or `--comune-id`. If no mapped center is available, supply `--near lat,lon`.
|
|
83
84
|
|
|
84
85
|
## Install
|
|
85
86
|
|
|
@@ -119,10 +120,19 @@ pitstop stations --near 46.498,11.354 --radius 5 --fuel Benzina --self --json
|
|
|
119
120
|
pitstop fuels
|
|
120
121
|
|
|
121
122
|
# Fast EV chargers (≥50 kW) within 5 km of Bolzano
|
|
122
|
-
pitstop chargers --
|
|
123
|
+
pitstop chargers --comune Bozen --radius 5 --fast --public --json
|
|
124
|
+
|
|
125
|
+
# Discover municipality IDs and disambiguate duplicate names
|
|
126
|
+
pitstop places Livo --json
|
|
127
|
+
pitstop chargers --comune Livo --provincia TN --json
|
|
128
|
+
pitstop chargers --comune-id 021008 --radius 5 --fast --json
|
|
123
129
|
```
|
|
124
130
|
|
|
125
|
-
`stations` flags: `--comune`, `--provincia`, `--brand`, `--near "lat,lon"`, `--radius`, `--fuel` (substring, case-insensitive), `--self`, `--served`, `--cheapest` (needs `--fuel`), `--min-price
|
|
131
|
+
`stations` flags: `--comune`, `--provincia`, `--brand`, `--near "lat,lon"`, `--radius`, `--fuel` (substring, case-insensitive), `--self`, `--served`, `--cheapest` (needs `--fuel`), `--min-price`, `--fresh-within-days`, `--max-deviation-pct`, `--drop-outliers`, `--no-comune-validate`, `--limit`, `--json`, `--geojson`. Choose one output format. `--limit 0` returns every match.
|
|
132
|
+
|
|
133
|
+
Distances and radii are straight-line measurements, not driving distances or travel times.
|
|
134
|
+
|
|
135
|
+
Loading flags (`--refresh`, `--max-age` in seconds, `--timeout` in seconds) apply to MIMIT commands and charger searches. The default caches last 24 hours for MIMIT, seven days for OSM, and 30 days for the municipality reference. `--refresh` also refreshes a charger's municipality lookup; `--max-age` controls its charger results. `--max-age 0` accepts cached files of any age. `places` supports `--refresh` and `--timeout` (no `--max-age`).
|
|
126
136
|
|
|
127
137
|
Every returned price carries a `median_basis`. A `screened` price also carries `regional_median` and `deviation_pct`, plus `outlier: true` when it is >15% below the local median **or** below the Tukey lower fence Q1−1.5·IQR (the Tukey rule catches misreports in tight markets that the percent rule alone misses). The `outlier` key is emitted **only when it is true**, so read it as optional. Pass `--drop-outliers` to remove flagged prices entirely.
|
|
128
138
|
|
|
@@ -130,7 +140,7 @@ A price is `unscreened` when its (fuel, provincia) bucket holds too few samples
|
|
|
130
140
|
|
|
131
141
|
## MCP server
|
|
132
142
|
|
|
133
|
-
For agents that speak MCP, the same data is exposed as tools (`list_fuels`, `find_stations`, `find_cheapest`, `find_chargers`, `get_stats`) over the shared core
|
|
143
|
+
For agents that speak MCP, the same data is exposed as six tools (`list_fuels`, `find_stations`, `find_cheapest`, `find_chargers`, `find_places`, `get_stats`) over the shared core. Tools advertise read-only behavior and return structured JSON alongside text. Repeated fuel searches reuse parsed files and provincial statistics until the cached files change.
|
|
134
144
|
|
|
135
145
|
```bash
|
|
136
146
|
pip install "pitstop-cli[mcp]" # or: uv tool install "pitstop-cli[mcp]"
|
|
@@ -150,19 +160,23 @@ Machine-readable command recipes, with the caveats that belong with each answer,
|
|
|
150
160
|
```bash
|
|
151
161
|
pip install -e ".[dev]"
|
|
152
162
|
pytest -q
|
|
163
|
+
python scripts/smoke-installed.py # installed entry points and stdio MCP, offline
|
|
153
164
|
```
|
|
154
165
|
|
|
155
166
|
## Automation contract
|
|
156
167
|
|
|
157
168
|
- `stdout` is command output; `stderr` is diagnostics.
|
|
158
|
-
-
|
|
169
|
+
- `stations --json` emits a stable object with `source`, `*_extraction_date`, `generated_at`, `query`, `count`, `quality`, `stations[]`, and `disclaimer`.
|
|
170
|
+
- Fuel and charger search envelopes include `coverage`: `fetched_count`, `matched_count` before the limit, `returned_count`, and `truncated`. These counts describe the downloaded data; OSM coverage is not an exhaustive charger inventory.
|
|
171
|
+
- `freshness` records local `fetched_at` and `age_seconds`: separately for the fuel registry and prices, or for the charger response. Charger `cache_status` is `hit`, `miss`, `stale_fallback`, `partial`, or `unavailable`. A partial/unavailable response has no successful fetch timestamp; an `error` explains degraded results. Fetch time does not establish current prices or charger availability.
|
|
172
|
+
- Charger municipality searches add `location` with the selected name, province, ISTAT ID, coordinates, provenance, and warnings. GeoJSON carries these envelope fields under `metadata`.
|
|
159
173
|
- Exit codes: `0` success, `1` runtime error, `2` usage error.
|
|
160
|
-
- Source files are cached
|
|
174
|
+
- Source files are cached under `$XDG_CACHE_HOME/pitstop` (or `~/.cache/pitstop`); use `--refresh` to bypass.
|
|
161
175
|
- Non-interactive; no hidden browser state or scraping.
|
|
162
176
|
|
|
163
177
|
## Status & roadmap
|
|
164
178
|
|
|
165
|
-
v1.
|
|
179
|
+
v1.2.0 adds municipality discovery, province and ISTAT-ID selection for chargers, search coverage and cache timestamps, and structured MCP results. Fuel prices, EV charger locations, statistics, navigation links, and GeoJSON remain available through the CLI and MCP server. See [CHANGELOG.md](CHANGELOG.md) for fixes and compatibility details.
|
|
166
180
|
|
|
167
181
|
Planned, roughly in order:
|
|
168
182
|
- per-station **EV tariff data** if a source `pitstop` can read starts publishing per-kWh prices (today it parses only OSM's `fee` yes/no flag, no price field);
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
A JSON-first CLI and MCP server for **Italian fuel-station prices** and **EV charging stations**, designed for AI agents, scripts, and humans.
|
|
8
8
|
|
|
9
|
-
Italy publishes per-station fuel prices daily (MIMIT *Osservaprezzi Carburanti* open data) and OpenStreetMap
|
|
9
|
+
Italy publishes per-station fuel prices daily (MIMIT *Osservaprezzi Carburanti* open data), and OpenStreetMap provides EV charger locations and capabilities. Raw access means downloading multi-megabyte CSVs, joining files, sorting through misreports, and translating municipality names. `pitstop` handles those steps locally and returns JSON or a readable table.
|
|
10
10
|
|
|
11
11
|
Built for questions like:
|
|
12
12
|
- *"What's the cheapest diesel near Rome right now?"* → `pitstop stations --fuel Gasolio --near 41.9,12.5 --cheapest`
|
|
13
|
-
- *"Where can I fast-charge my EV in Bolzano?"* → `pitstop chargers --
|
|
13
|
+
- *"Where can I fast-charge my EV in Bolzano?"* → `pitstop chargers --near 46.498,11.354 --fast`
|
|
14
14
|
- *"Are these station prices statistically reliable?"* → every price says whether it was screened against its local market; screened ones carry a `regional_median`, a `deviation_pct`, and `outlier: true` when the price looks like a misreport.
|
|
15
15
|
|
|
16
16
|
International city names work out of the box (`Rome`, `Milan`, `Bozen`, `Mailand`, `Venise`, …).
|
|
@@ -26,8 +26,9 @@ Unofficial community project. Not affiliated with or endorsed by MIMIT. Fuel dat
|
|
|
26
26
|
- **Coverage:** Italy only (by design, for now).
|
|
27
27
|
- **Known caveats:**
|
|
28
28
|
- Some operators report placeholder values (e.g. `1.000`); use `--min-price` (e.g. `1.2`) to drop them.
|
|
29
|
-
- Some price records are **stale** (a few were last updated years ago); use `--fresh-within-days` and check the `UPDATED` column / `updated` field.
|
|
30
|
-
- Some stations are **mis-geocoded** in the registry.
|
|
29
|
+
- Some price records are **stale** (a few were last updated years ago); use `--fresh-within-days` and check the `UPDATED` column / `updated` field. When enabled, the freshness filter also excludes missing, unparseable, and future update dates.
|
|
30
|
+
- Some stations are **mis-geocoded** in the registry. `pitstop` uses station clusters and a second coordinate reference from [opendatasicilia/comuni-italiani](https://github.com/opendatasicilia/comuni-italiani) to flag discrepancies over 30 km as `coordinate_suspect` (`*` in the table). `--near` also excludes stations whose declared comune is geographically too far from the query point. Pass `--no-comune-validate` to disable the second reference.
|
|
31
|
+
- **Municipality reference coordinates can also be wrong.** Charger searches resolve a municipality's ISTAT ID to its mapped OpenStreetMap administrative center. JSON includes the selected `location`, its source link, cache age, and warnings when it differs from the reference coordinates. Ambiguous names require `--provincia` or `--comune-id`. If no mapped center is available, supply `--near lat,lon`.
|
|
31
32
|
|
|
32
33
|
## Install
|
|
33
34
|
|
|
@@ -67,10 +68,19 @@ pitstop stations --near 46.498,11.354 --radius 5 --fuel Benzina --self --json
|
|
|
67
68
|
pitstop fuels
|
|
68
69
|
|
|
69
70
|
# Fast EV chargers (≥50 kW) within 5 km of Bolzano
|
|
70
|
-
pitstop chargers --
|
|
71
|
+
pitstop chargers --comune Bozen --radius 5 --fast --public --json
|
|
72
|
+
|
|
73
|
+
# Discover municipality IDs and disambiguate duplicate names
|
|
74
|
+
pitstop places Livo --json
|
|
75
|
+
pitstop chargers --comune Livo --provincia TN --json
|
|
76
|
+
pitstop chargers --comune-id 021008 --radius 5 --fast --json
|
|
71
77
|
```
|
|
72
78
|
|
|
73
|
-
`stations` flags: `--comune`, `--provincia`, `--brand`, `--near "lat,lon"`, `--radius`, `--fuel` (substring, case-insensitive), `--self`, `--served`, `--cheapest` (needs `--fuel`), `--min-price
|
|
79
|
+
`stations` flags: `--comune`, `--provincia`, `--brand`, `--near "lat,lon"`, `--radius`, `--fuel` (substring, case-insensitive), `--self`, `--served`, `--cheapest` (needs `--fuel`), `--min-price`, `--fresh-within-days`, `--max-deviation-pct`, `--drop-outliers`, `--no-comune-validate`, `--limit`, `--json`, `--geojson`. Choose one output format. `--limit 0` returns every match.
|
|
80
|
+
|
|
81
|
+
Distances and radii are straight-line measurements, not driving distances or travel times.
|
|
82
|
+
|
|
83
|
+
Loading flags (`--refresh`, `--max-age` in seconds, `--timeout` in seconds) apply to MIMIT commands and charger searches. The default caches last 24 hours for MIMIT, seven days for OSM, and 30 days for the municipality reference. `--refresh` also refreshes a charger's municipality lookup; `--max-age` controls its charger results. `--max-age 0` accepts cached files of any age. `places` supports `--refresh` and `--timeout` (no `--max-age`).
|
|
74
84
|
|
|
75
85
|
Every returned price carries a `median_basis`. A `screened` price also carries `regional_median` and `deviation_pct`, plus `outlier: true` when it is >15% below the local median **or** below the Tukey lower fence Q1−1.5·IQR (the Tukey rule catches misreports in tight markets that the percent rule alone misses). The `outlier` key is emitted **only when it is true**, so read it as optional. Pass `--drop-outliers` to remove flagged prices entirely.
|
|
76
86
|
|
|
@@ -78,7 +88,7 @@ A price is `unscreened` when its (fuel, provincia) bucket holds too few samples
|
|
|
78
88
|
|
|
79
89
|
## MCP server
|
|
80
90
|
|
|
81
|
-
For agents that speak MCP, the same data is exposed as tools (`list_fuels`, `find_stations`, `find_cheapest`, `find_chargers`, `get_stats`) over the shared core
|
|
91
|
+
For agents that speak MCP, the same data is exposed as six tools (`list_fuels`, `find_stations`, `find_cheapest`, `find_chargers`, `find_places`, `get_stats`) over the shared core. Tools advertise read-only behavior and return structured JSON alongside text. Repeated fuel searches reuse parsed files and provincial statistics until the cached files change.
|
|
82
92
|
|
|
83
93
|
```bash
|
|
84
94
|
pip install "pitstop-cli[mcp]" # or: uv tool install "pitstop-cli[mcp]"
|
|
@@ -98,19 +108,23 @@ Machine-readable command recipes, with the caveats that belong with each answer,
|
|
|
98
108
|
```bash
|
|
99
109
|
pip install -e ".[dev]"
|
|
100
110
|
pytest -q
|
|
111
|
+
python scripts/smoke-installed.py # installed entry points and stdio MCP, offline
|
|
101
112
|
```
|
|
102
113
|
|
|
103
114
|
## Automation contract
|
|
104
115
|
|
|
105
116
|
- `stdout` is command output; `stderr` is diagnostics.
|
|
106
|
-
-
|
|
117
|
+
- `stations --json` emits a stable object with `source`, `*_extraction_date`, `generated_at`, `query`, `count`, `quality`, `stations[]`, and `disclaimer`.
|
|
118
|
+
- Fuel and charger search envelopes include `coverage`: `fetched_count`, `matched_count` before the limit, `returned_count`, and `truncated`. These counts describe the downloaded data; OSM coverage is not an exhaustive charger inventory.
|
|
119
|
+
- `freshness` records local `fetched_at` and `age_seconds`: separately for the fuel registry and prices, or for the charger response. Charger `cache_status` is `hit`, `miss`, `stale_fallback`, `partial`, or `unavailable`. A partial/unavailable response has no successful fetch timestamp; an `error` explains degraded results. Fetch time does not establish current prices or charger availability.
|
|
120
|
+
- Charger municipality searches add `location` with the selected name, province, ISTAT ID, coordinates, provenance, and warnings. GeoJSON carries these envelope fields under `metadata`.
|
|
107
121
|
- Exit codes: `0` success, `1` runtime error, `2` usage error.
|
|
108
|
-
- Source files are cached
|
|
122
|
+
- Source files are cached under `$XDG_CACHE_HOME/pitstop` (or `~/.cache/pitstop`); use `--refresh` to bypass.
|
|
109
123
|
- Non-interactive; no hidden browser state or scraping.
|
|
110
124
|
|
|
111
125
|
## Status & roadmap
|
|
112
126
|
|
|
113
|
-
v1.
|
|
127
|
+
v1.2.0 adds municipality discovery, province and ISTAT-ID selection for chargers, search coverage and cache timestamps, and structured MCP results. Fuel prices, EV charger locations, statistics, navigation links, and GeoJSON remain available through the CLI and MCP server. See [CHANGELOG.md](CHANGELOG.md) for fixes and compatibility details.
|
|
114
128
|
|
|
115
129
|
Planned, roughly in order:
|
|
116
130
|
- per-station **EV tariff data** if a source `pitstop` can read starts publishing per-kWh prices (today it parses only OSM's `fee` yes/no flag, no price field);
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
"id": "cheapest-fuel-near-place",
|
|
25
|
-
"question_pattern": "Cheapest fuel within
|
|
25
|
+
"question_pattern": "Cheapest fuel within a straight-line radius of a coordinate.",
|
|
26
26
|
"commands": [
|
|
27
27
|
"pitstop stations --near 41.9028,12.4964 --radius 5 --fuel Gasolio --cheapest --min-price 1.2 --fresh-within-days 30 --limit 5 --json",
|
|
28
28
|
"pitstop stations --near 41.9028,12.4964 --radius 5 --fuel Gasolio --cheapest --min-price 1.2 --fresh-within-days 30 --drop-outliers --limit 5 --json"
|
|
@@ -43,7 +43,8 @@
|
|
|
43
43
|
"`--min-price 1.2` drops the 1.000 placeholder some operators report; leave it off for GPL, whose real prices sit below that floor.",
|
|
44
44
|
"`--fresh-within-days` drops prices whose `updated` timestamp is older than N days; without it a years-old row can win the ranking.",
|
|
45
45
|
"A station flagged `coordinate_suspect` sits more than 30 km from where its declared comune's other stations are (their median coordinate, or the ISTAT reference point when the comune has fewer than three stations), or outside Italy altogether. Its `distance_km` is unreliable even when its price is not.",
|
|
46
|
-
"Italy only."
|
|
46
|
+
"Italy only.",
|
|
47
|
+
"distance_km is straight-line distance, not a driving route or journey time."
|
|
47
48
|
]
|
|
48
49
|
},
|
|
49
50
|
{
|
|
@@ -130,14 +131,18 @@
|
|
|
130
131
|
"stations[].operator",
|
|
131
132
|
"stations[].access",
|
|
132
133
|
"stations[].distance_km",
|
|
133
|
-
"stations[].navigation_url"
|
|
134
|
+
"stations[].navigation_url",
|
|
135
|
+
"coverage",
|
|
136
|
+
"freshness",
|
|
137
|
+
"location.warnings[] (when a municipality was used)"
|
|
134
138
|
],
|
|
135
139
|
"caveats": [
|
|
136
140
|
"Source is OpenStreetMap via Overpass. Coverage, power, and plug fields are what mappers entered; present them as unverified and name OSM.",
|
|
137
141
|
"`--fast` is `--min-power 50` over the station's highest tagged socket output, so a charger whose mapper left the power untagged is filtered out rather than reported as slow.",
|
|
138
142
|
"A populated `error` means the Overpass query failed. With `count: 0` that is \"unknown\", never \"no chargers nearby\"; retry or say the lookup failed.",
|
|
139
|
-
"`--comune`
|
|
140
|
-
"Availability is not in this data: it says where chargers are, not whether one is free now."
|
|
143
|
+
"`--comune` resolves an ISTAT municipality ID to its mapped OSM administrative center. Inspect `location` and its warnings. Duplicate names need `--provincia` or `--comune-id`; use explicit `--near` when the intended point is known.",
|
|
144
|
+
"Availability is not in this data: it says where chargers are, not whether one is free now.",
|
|
145
|
+
"Surface cache age and upstream errors. Counts describe inspected OSM data, not an exhaustive or live inventory."
|
|
141
146
|
]
|
|
142
147
|
},
|
|
143
148
|
{
|
|
@@ -151,13 +156,36 @@
|
|
|
151
156
|
"stations[].tariff_info_url",
|
|
152
157
|
"stations[].operator",
|
|
153
158
|
"disclaimer",
|
|
154
|
-
"error"
|
|
159
|
+
"error",
|
|
160
|
+
"coverage",
|
|
161
|
+
"freshness",
|
|
162
|
+
"location.warnings[] (when a municipality was used)"
|
|
155
163
|
],
|
|
156
164
|
"caveats": [
|
|
157
165
|
"pitstop returns no per-kWh price for any charger: it parses OpenStreetMap's `fee` yes/no flag and no price field. There is no number to report and none to infer.",
|
|
158
|
-
"`fee` is absent when OSM carries no `fee` tag — that is unknown, not free. `--free`
|
|
166
|
+
"`fee` is absent when OSM carries no `fee` tag — that is unknown, not free. `--free` requires `fee=no`; unknown fees are excluded. This mapper-entered flag is not a current operator price quote.",
|
|
159
167
|
"`tariff_info_url` links to the operator's own tariff page and is present only for operators in pitstop's curated list; it is the honest answer to a price question.",
|
|
160
|
-
"Never carry a figure over from `stations`: fuel prices and charging tariffs are different data from different sources."
|
|
168
|
+
"Never carry a figure over from `stations`: fuel prices and charging tariffs are different data from different sources.",
|
|
169
|
+
"Surface cache age and upstream errors. Counts describe inspected OSM data, not an exhaustive or live inventory."
|
|
170
|
+
]
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"id": "municipality-discovery",
|
|
174
|
+
"question_pattern": "Find chargers in a municipality whose name may be shared by multiple provinces.",
|
|
175
|
+
"commands": [
|
|
176
|
+
"pitstop places Livo --json",
|
|
177
|
+
"pitstop chargers --comune Livo --provincia TN --limit 5 --json"
|
|
178
|
+
],
|
|
179
|
+
"parse": [
|
|
180
|
+
"places[].comune_id",
|
|
181
|
+
"places[].provincia",
|
|
182
|
+
"location",
|
|
183
|
+
"coverage",
|
|
184
|
+
"freshness"
|
|
185
|
+
],
|
|
186
|
+
"caveats": [
|
|
187
|
+
"Select the intended province before searching. An ambiguous name is a usage error.",
|
|
188
|
+
"A missing mapped center is reported; provide explicit coordinates rather than substituting another municipality."
|
|
161
189
|
]
|
|
162
190
|
}
|
|
163
191
|
]
|
|
@@ -197,8 +197,8 @@
|
|
|
197
197
|
],
|
|
198
198
|
"pass_criteria": [
|
|
199
199
|
"Checks each returned station's `fee` field instead of trusting the flag name.",
|
|
200
|
-
"States that `--free`
|
|
201
|
-
"
|
|
200
|
+
"States that `--free` requires an explicit `fee=no`; missing fees are excluded.",
|
|
201
|
+
"If comparing against the unfiltered query, labels missing fee tags as unknown.",
|
|
202
202
|
"Repeats that pitstop reports no per-kWh price and points at `tariff_info_url` where present."
|
|
203
203
|
],
|
|
204
204
|
"common_failures": [
|
|
@@ -207,6 +207,24 @@
|
|
|
207
207
|
"Promises a free charge from a mapper-entered flag with no date behind it.",
|
|
208
208
|
"Invents a tariff for the chargers that do charge."
|
|
209
209
|
]
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"id": "ambiguous-municipality",
|
|
213
|
+
"prompt": "Find fast public chargers near Livo in Trentino. Show the selected location and whether the results are complete.",
|
|
214
|
+
"expected_command_path": [
|
|
215
|
+
"pitstop places Livo --json",
|
|
216
|
+
"pitstop chargers --comune Livo --provincia TN --fast --public --limit 5 --json"
|
|
217
|
+
],
|
|
218
|
+
"pass_criteria": [
|
|
219
|
+
"Selects LIVO in TN, ISTAT 022106, rather than LIVO in CO.",
|
|
220
|
+
"Reads the resolved location and source; does not invent coordinates when resolution fails.",
|
|
221
|
+
"Reports coverage, cache age, and upstream errors without calling OSM exhaustive or live."
|
|
222
|
+
],
|
|
223
|
+
"common_failures": [
|
|
224
|
+
"Selects the first substring match without checking province.",
|
|
225
|
+
"Presents an empty degraded response as proof that no chargers exist.",
|
|
226
|
+
"Uses the old Bolzano reference coordinate as a standing workaround."
|
|
227
|
+
]
|
|
210
228
|
}
|
|
211
229
|
]
|
|
212
230
|
}
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pitstop-cli"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.3.0"
|
|
8
8
|
description = "JSON-first CLI + MCP server for Italian fuel-station prices and EV charging — MIMIT, OpenStreetMap, ISTAT."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -38,10 +38,11 @@ Changelog = "https://github.com/galjos/pitstop-cli/blob/main/CHANGELOG.md"
|
|
|
38
38
|
Issues = "https://github.com/galjos/pitstop-cli/issues"
|
|
39
39
|
|
|
40
40
|
[project.optional-dependencies]
|
|
41
|
-
#
|
|
42
|
-
#
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
# mcp_server.py imports MCPServer/FastMCP and ToolAnnotations through a
|
|
42
|
+
# version shim covering mcp 1.12+ and 2.x; keep the 1.12 floor (read-only
|
|
43
|
+
# annotations, structured output) on both extras.
|
|
44
|
+
mcp = ["mcp>=1.12"]
|
|
45
|
+
dev = ["pytest>=7", "mcp>=1.12"]
|
|
45
46
|
|
|
46
47
|
[project.scripts]
|
|
47
48
|
pitstop = "pitstop.cli:main"
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Geographic acceptance: municipality resolution and charger locations.
|
|
3
|
+
#
|
|
4
|
+
# Live-only (needs the comuni reference + Overpass). Runs in the weekly
|
|
5
|
+
# upstream-smoke workflow, not in PR CI.
|
|
6
|
+
#
|
|
7
|
+
# Exit 0 -> all location assertions passed, or the upstream was unreachable
|
|
8
|
+
# and that outage was reported honestly (GitHub ::warning, UPSTREAM-* lines).
|
|
9
|
+
# Exit 1 -> pitstop resolved a place it should have gotten right. Act on it.
|
|
10
|
+
#
|
|
11
|
+
# Distance budgets are generous on purpose: they catch a wrong-city regression
|
|
12
|
+
# (the 20 km Bolzano reference error this suite exists for) without paging on
|
|
13
|
+
# ordinary reference-vs-OSM drift of a few kilometres.
|
|
14
|
+
|
|
15
|
+
set -u
|
|
16
|
+
|
|
17
|
+
BIN="${PITSTOP_GEO_BIN:-pitstop}"
|
|
18
|
+
OUT="$(mktemp -d "${TMPDIR:-/tmp}/pitstop-geo-acceptance-XXXXXX")"
|
|
19
|
+
trap 'rm -rf "$OUT"' EXIT INT TERM
|
|
20
|
+
|
|
21
|
+
warn() {
|
|
22
|
+
echo "GEO-ACCEPTANCE: UPSTREAM-$1"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
check_charger_center() {
|
|
26
|
+
name="$1"; comune="$2"; lat="$3"; lon="$4"; budget_km="$5"
|
|
27
|
+
if ! "$BIN" chargers --comune "$comune" --radius 5 --limit 1 --json > "$OUT/center.json" 2>"$OUT/center.err"; then
|
|
28
|
+
if grep -qi "no unique mapped center\|could not fetch\|failed" "$OUT/center.err"; then
|
|
29
|
+
warn "DEGRADED charger center $name unverifiable: $(cat "$OUT/center.err")"
|
|
30
|
+
return 2
|
|
31
|
+
fi
|
|
32
|
+
echo "GEO-ACCEPTANCE: FAIL $name: chargers exited non-zero: $(cat "$OUT/center.err")"
|
|
33
|
+
return 1
|
|
34
|
+
fi
|
|
35
|
+
python3 - "$OUT/center.json" "$name" "$lat" "$lon" "$budget_km" <<'PY'
|
|
36
|
+
import json, math, sys
|
|
37
|
+
|
|
38
|
+
path, name, lat, lon, budget = sys.argv[1], sys.argv[2], float(sys.argv[3]), float(sys.argv[4]), float(sys.argv[5])
|
|
39
|
+
with open(path, encoding="utf-8") as fh:
|
|
40
|
+
payload = json.load(fh)
|
|
41
|
+
if payload.get("error"):
|
|
42
|
+
print(f"GEO-ACCEPTANCE: UPSTREAM-DEGRADED charger center {name}: {payload['error']}")
|
|
43
|
+
sys.exit(2)
|
|
44
|
+
loc = payload.get("location", {})
|
|
45
|
+
try:
|
|
46
|
+
got_lat, got_lon = float(loc["lat"]), float(loc["lon"])
|
|
47
|
+
except (KeyError, TypeError, ValueError):
|
|
48
|
+
print(f"GEO-ACCEPTANCE: FAIL {name}: no location in {payload}")
|
|
49
|
+
sys.exit(1)
|
|
50
|
+
|
|
51
|
+
r = 6371.0
|
|
52
|
+
p1, p2 = math.radians(lat), math.radians(got_lat)
|
|
53
|
+
h = math.sin(math.radians(got_lat - lat) / 2) ** 2 + math.cos(p1) * math.cos(p2) * math.sin(math.radians(got_lon - lon) / 2) ** 2
|
|
54
|
+
km = 2 * r * math.asin(math.sqrt(h))
|
|
55
|
+
if km > budget:
|
|
56
|
+
print(f"GEO-ACCEPTANCE: FAIL {name}: center {got_lat},{got_lon} ({km:.1f} km from {lat},{lon}, budget {budget} km)")
|
|
57
|
+
sys.exit(1)
|
|
58
|
+
print(f"GEO-ACCEPTANCE: ok {name} center -> {got_lat},{got_lon} ({km:.1f} km)")
|
|
59
|
+
PY
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
failures=0
|
|
63
|
+
unavailable=0
|
|
64
|
+
|
|
65
|
+
check_charger_center "Bozen" "Bozen" "46.498" "11.354" "25"; rc=$?
|
|
66
|
+
[ "$rc" -eq 1 ] && failures=$((failures + 1))
|
|
67
|
+
[ "$rc" -eq 2 ] && unavailable=$((unavailable + 1))
|
|
68
|
+
|
|
69
|
+
check_charger_center "Roma" "Roma" "41.903" "12.496" "30"; rc=$?
|
|
70
|
+
[ "$rc" -eq 1 ] && failures=$((failures + 1))
|
|
71
|
+
[ "$rc" -eq 2 ] && unavailable=$((unavailable + 1))
|
|
72
|
+
|
|
73
|
+
if "$BIN" places Livo --json > "$OUT/livo.json" 2>"$OUT/livo.err"; then
|
|
74
|
+
python3 - "$OUT/livo.json" <<'PY'
|
|
75
|
+
import json, sys
|
|
76
|
+
|
|
77
|
+
with open(sys.argv[1], encoding="utf-8") as fh:
|
|
78
|
+
payload = json.load(fh)
|
|
79
|
+
provs = {p.get("provincia") for p in payload.get("places", [])}
|
|
80
|
+
if not {"CO", "TN"} <= provs:
|
|
81
|
+
print(f"GEO-ACCEPTANCE: FAIL Livo: CO+TN missing from {sorted(provs)}")
|
|
82
|
+
sys.exit(1)
|
|
83
|
+
print("GEO-ACCEPTANCE: ok Livo -> CO+TN both listed")
|
|
84
|
+
PY
|
|
85
|
+
[ "$?" -ne 0 ] && failures=$((failures + 1))
|
|
86
|
+
# Ambiguous exact names must refuse to guess (exit 2), not pick a province.
|
|
87
|
+
"$BIN" chargers --comune Livo --json > "$OUT/livo-amb.json" 2>"$OUT/livo-amb.err"
|
|
88
|
+
rc=$?
|
|
89
|
+
if [ "$rc" -eq 2 ] && grep -qi "ambiguous\|disambiguat" "$OUT/livo-amb.err"; then
|
|
90
|
+
echo "GEO-ACCEPTANCE: ok Livo -> ambiguous --comune exits 2"
|
|
91
|
+
else
|
|
92
|
+
echo "GEO-ACCEPTANCE: FAIL Livo: ambiguous --comune exited $rc, want 2 with a disambiguation error: $(cat "$OUT/livo-amb.err")"
|
|
93
|
+
failures=$((failures + 1))
|
|
94
|
+
fi
|
|
95
|
+
else
|
|
96
|
+
warn "UNAVAILABLE places Livo exited non-zero: $(cat "$OUT/livo.err")"
|
|
97
|
+
unavailable=$((unavailable + 1))
|
|
98
|
+
fi
|
|
99
|
+
|
|
100
|
+
if "$BIN" chargers --near 46.498,11.354 --radius 5 --limit 5 --json > "$OUT/chargers.json" 2>"$OUT/chargers.err"; then
|
|
101
|
+
python3 - "$OUT/chargers.json" <<'PY'
|
|
102
|
+
import json, math, sys
|
|
103
|
+
|
|
104
|
+
with open(sys.argv[1], encoding="utf-8") as fh:
|
|
105
|
+
payload = json.load(fh)
|
|
106
|
+
if payload.get("error"):
|
|
107
|
+
print(f"GEO-ACCEPTANCE: UPSTREAM-DEGRADED chargers: {payload['error']}")
|
|
108
|
+
sys.exit(2)
|
|
109
|
+
qlat, qlon, radius = 46.498, 11.354, 5.0
|
|
110
|
+
for st in payload.get("stations", []):
|
|
111
|
+
try:
|
|
112
|
+
d = float(st.get("distance_km", "nan"))
|
|
113
|
+
except (TypeError, ValueError):
|
|
114
|
+
print(f"GEO-ACCEPTANCE: FAIL charger without distance: {st.get('name')}")
|
|
115
|
+
sys.exit(1)
|
|
116
|
+
if not (d <= radius + 1.0):
|
|
117
|
+
print(f"GEO-ACCEPTANCE: FAIL charger {st.get('name')} at {d} km, outside radius {radius} km + 1 km tolerance")
|
|
118
|
+
sys.exit(1)
|
|
119
|
+
print(f"GEO-ACCEPTANCE: ok chargers near 46.498,11.354 ({payload.get('count', 0)} returned)")
|
|
120
|
+
PY
|
|
121
|
+
rc=$?
|
|
122
|
+
[ "$rc" -eq 1 ] && failures=$((failures + 1))
|
|
123
|
+
[ "$rc" -eq 2 ] && unavailable=$((unavailable + 1))
|
|
124
|
+
else
|
|
125
|
+
warn "UNAVAILABLE chargers exited non-zero: $(cat "$OUT/chargers.err")"
|
|
126
|
+
unavailable=$((unavailable + 1))
|
|
127
|
+
fi
|
|
128
|
+
|
|
129
|
+
if [ "$failures" -gt 0 ]; then
|
|
130
|
+
echo "GEO-ACCEPTANCE: $failures failing check(s)"
|
|
131
|
+
exit 1
|
|
132
|
+
fi
|
|
133
|
+
if [ "$unavailable" -gt 0 ]; then
|
|
134
|
+
echo "::warning title=Geo acceptance skipped on unreachable upstream::$unavailable check(s) could not reach the comuni reference or Overpass; location assertions that ran passed."
|
|
135
|
+
fi
|
|
136
|
+
echo "GEO-ACCEPTANCE: passed"
|