football-docs 0.4.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -51
- package/bin/serve.js +6 -1
- package/data/docs.db +0 -0
- package/dist/crawl.js +59 -1
- package/dist/impect-truth.d.ts +61 -0
- package/dist/impect-truth.js +250 -0
- package/dist/index.d.ts +11 -6
- package/dist/index.js +104 -304
- package/dist/ingest.js +5 -2
- package/dist/provider-truth.d.ts +122 -0
- package/dist/provider-truth.js +290 -0
- package/dist/tools.d.ts +63 -0
- package/dist/tools.js +526 -0
- package/docs/_reference/skillcorner-crunch-help/getting-started-api-access-dynamic-events.md +134 -0
- package/docs/_reference/skillcorner-crunch-help/getting-started-api-access-our-tracking-data.md +160 -0
- package/docs/_reference/skillcorner-crunch-help/getting-started-best-practice-analysis-guidance.md +16 -0
- package/docs/_reference/skillcorner-crunch-help/getting-started-dynamic-events-check.md +33 -0
- package/docs/_reference/skillcorner-crunch-help/getting-started-explore-game-intelligence-data-1.md +37 -0
- package/docs/_reference/skillcorner-crunch-help/getting-started-explore-game-intelligence-data.md +29 -0
- package/docs/_reference/skillcorner-crunch-help/getting-started-first-requests.md +99 -0
- package/docs/_reference/skillcorner-crunch-help/getting-started-generate-visual-reports.md +90 -0
- package/docs/_reference/skillcorner-crunch-help/getting-started-make-your-first-queries.md +92 -0
- package/docs/_reference/skillcorner-crunch-help/getting-started-off-ball-run-sportscode-xml.md +32 -0
- package/docs/_reference/skillcorner-crunch-help/getting-started-on-ball-engagement-video-definitio.md +15 -0
- package/docs/_reference/skillcorner-crunch-help/getting-started-python-retrieve-dynamic-events-fil.md +102 -0
- package/docs/_reference/skillcorner-crunch-help/getting-started-python-retrieve-game-intelligence-.md +158 -0
- package/docs/_reference/skillcorner-crunch-help/getting-started-python-sync-your-database-with-ski.md +192 -0
- package/docs/_reference/skillcorner-crunch-help/getting-started-run-detection-and-classification.md +131 -0
- package/docs/_reference/skillcorner-crunch-help/getting-started-skill-corner-tracking-data.md +82 -0
- package/docs/_reference/skillcorner-crunch-help/getting-started-skillcorner-python-client.md +70 -0
- package/docs/_reference/skillcorner-crunch-help/getting-started-using-skillcorner-api.md +146 -0
- package/docs/_reference/skillcorner-crunch-help/getting-started.md +43 -0
- package/docs/_reference/skillcorner-crunch-help/glossaries-coordinates-distance-speeds-and-directi.md +149 -0
- package/docs/_reference/skillcorner-crunch-help/glossaries-dynamic-events-csv-specifications.md +15 -0
- package/docs/_reference/skillcorner-crunch-help/glossaries-forward-momentum.md +13 -0
- package/docs/_reference/skillcorner-crunch-help/glossaries-game-intelligence-v2-metrics.md +17 -0
- package/docs/_reference/skillcorner-crunch-help/glossaries-in-possession-package-content.md +19 -0
- package/docs/_reference/skillcorner-crunch-help/glossaries-line-breaking-passes.md +103 -0
- package/docs/_reference/skillcorner-crunch-help/glossaries-off-ball-run-dynamic-events.md +197 -0
- package/docs/_reference/skillcorner-crunch-help/glossaries-overcoming-pressure.md +105 -0
- package/docs/_reference/skillcorner-crunch-help/glossaries-passing-metrics-1.md +144 -0
- package/docs/_reference/skillcorner-crunch-help/glossaries-passing-moment-frame-selection.md +19 -0
- package/docs/_reference/skillcorner-crunch-help/glossaries-peak-sprint-velocity.md +26 -0
- package/docs/_reference/skillcorner-crunch-help/glossaries-phases-of-play-video-definitions.md +15 -0
- package/docs/_reference/skillcorner-crunch-help/glossaries-physical-data-glossary.md +127 -0
- package/docs/_reference/skillcorner-crunch-help/glossaries-running-off-ball-metrics-1.md +135 -0
- package/docs/_reference/skillcorner-crunch-help/glossaries.md +43 -0
- package/docs/_reference/skillcorner-crunch-help/index.md +33 -0
- package/docs/_reference/skillcorner-crunch-help/models-general-concepts-pass-completion-probabilit.md +15 -0
- package/docs/_reference/skillcorner-crunch-help/models-general-concepts-passing-option.md +30 -0
- package/docs/_reference/skillcorner-crunch-help/models-general-concepts-physical-load-prediction-m.md +63 -0
- package/docs/_reference/skillcorner-crunch-help/models-general-concepts-pressure-detection.md +46 -0
- package/docs/_reference/skillcorner-crunch-help/models-general-concepts-pressure-intensity.md +80 -0
- package/docs/_reference/skillcorner-crunch-help/models-general-concepts-threat.md +40 -0
- package/docs/_reference/skillcorner-crunch-help/models-general-concepts.md +37 -0
- package/docs/_reference/skillcorner-crunch-help/product-updates-1-changelog-2025.md +57 -0
- package/docs/_reference/skillcorner-crunch-help/product-updates-1-game-intelligence-v2-migration.md +64 -0
- package/docs/_reference/skillcorner-crunch-help/product-updates-1-product-updates.md +200 -0
- package/docs/_reference/skillcorner-crunch-help/product-updates-1.md +25 -0
- package/docs/_reference/skillcorner-crunch-help/tool-box-api-data-version.md +255 -0
- package/docs/_reference/skillcorner-crunch-help/tool-box-data-availability.md +55 -0
- package/docs/_reference/skillcorner-crunch-help/tool-box-python-event-tracking-synchronization-1.md +442 -0
- package/docs/_reference/skillcorner-crunch-help/tool-box-python-event-tracking-synchronization.md +276 -0
- package/docs/_reference/skillcorner-crunch-help/tool-box-python-off-ball-runs-radar-plots.md +69 -0
- package/docs/_reference/skillcorner-crunch-help/tool-box-rule-based-event-synchronisation.md +44 -0
- package/docs/_reference/skillcorner-crunch-help/tool-box.md +35 -0
- package/docs/_reference/skillcorner-crunch-help/working-with-the-data-averaging-per-match-per-even.md +179 -0
- package/docs/_reference/skillcorner-crunch-help/working-with-the-data-benchmarking-normalisation.md +27 -0
- package/docs/_reference/skillcorner-crunch-help/working-with-the-data-data-quality-standards.md +45 -0
- package/docs/_reference/skillcorner-crunch-help/working-with-the-data-physical-data-glossary-1-1.md +54 -0
- package/docs/_reference/skillcorner-crunch-help/working-with-the-data-physical-data-glossary-1.md +25 -0
- package/docs/_reference/skillcorner-crunch-help/working-with-the-data-pitch-modelisation.md +27 -0
- package/docs/_reference/skillcorner-crunch-help/working-with-the-data-playing-time-info.md +133 -0
- package/docs/_reference/skillcorner-crunch-help/working-with-the-data.md +43 -0
- package/docs/besoccer/api-access.md +84 -0
- package/docs/besoccer/api-endpoints.md +131 -0
- package/docs/databallpy/data-model.md +6 -6
- package/docs/databallpy/overview.md +1 -1
- package/docs/floodlight/compendium-0-compendium.md +21 -0
- package/docs/floodlight/compendium-1-data.md +54 -0
- package/docs/floodlight/compendium-2-design.md +49 -0
- package/docs/floodlight/compendium-3-time.md +57 -0
- package/docs/floodlight/compendium-4-space.md +137 -0
- package/docs/floodlight/compendium-5-identifier.md +63 -0
- package/docs/floodlight/core-code.md +85 -0
- package/docs/floodlight/core-core.md +39 -0
- package/docs/floodlight/core-definitions.md +128 -0
- package/docs/floodlight/core-events.md +177 -0
- package/docs/floodlight/core-pitch.md +87 -0
- package/docs/floodlight/core-property.md +107 -0
- package/docs/floodlight/core-teamsheet.md +86 -0
- package/docs/floodlight/core-xy.md +192 -0
- package/docs/floodlight/guides-contrib-manual.md +462 -0
- package/docs/floodlight/guides-getting-started.md +194 -0
- package/docs/floodlight/guides-tutorial-analysis.md +245 -0
- package/docs/floodlight/guides-tutorial-matchsheets.md +439 -0
- package/docs/floodlight/index.md +17 -0
- package/docs/floodlight/io-datasets.md +365 -0
- package/docs/floodlight/io-dfl.md +107 -0
- package/docs/floodlight/io-io.md +131 -0
- package/docs/floodlight/io-kinexon.md +119 -0
- package/docs/floodlight/io-opta.md +49 -0
- package/docs/floodlight/io-secondspectrum.md +121 -0
- package/docs/floodlight/io-skillcorner.md +40 -0
- package/docs/floodlight/io-sportradar.md +35 -0
- package/docs/floodlight/io-statsbomb.md +61 -0
- package/docs/floodlight/io-statsperform.md +239 -0
- package/docs/floodlight/io-tracab.md +78 -0
- package/docs/floodlight/io-utils.md +59 -0
- package/docs/floodlight/metrics-entropy.md +36 -0
- package/docs/floodlight/metrics-metrics.md +15 -0
- package/docs/floodlight/metrics-trajectory-clustering.md +51 -0
- package/docs/floodlight/metrics-zone-aggregation.md +116 -0
- package/docs/floodlight/models-geometry.md +411 -0
- package/docs/floodlight/models-kinematics.md +251 -0
- package/docs/floodlight/models-kinetics.md +137 -0
- package/docs/floodlight/models-models.md +89 -0
- package/docs/floodlight/models-space.md +202 -0
- package/docs/floodlight/transforms-filter.md +412 -0
- package/docs/floodlight/transforms-interpolation.md +230 -0
- package/docs/floodlight/transforms-permutation.md +36 -0
- package/docs/floodlight/transforms-spatial.md +54 -0
- package/docs/floodlight/transforms-temporal.md +42 -0
- package/docs/floodlight/transforms-transforms.md +57 -0
- package/docs/floodlight/utils-types.md +13 -0
- package/docs/floodlight/utils-utils.md +17 -0
- package/docs/floodlight/vis-pitches.md +111 -0
- package/docs/floodlight/vis-positions.md +129 -0
- package/docs/floodlight/vis-vis.md +19 -0
- package/docs/fmdb-pro/api-access.md +120 -0
- package/docs/fmdb-pro/api-endpoints.md +123 -0
- package/docs/fmdb-pro/data-model.md +124 -0
- package/docs/fmdb-pro/identity-surfaces.md +108 -0
- package/docs/fotmob/identity-surfaces.md +16 -44
- package/docs/free-sources/contextual-story-joins.md +110 -0
- package/docs/free-sources/fbref.md +17 -5
- package/docs/free-sources/overview.md +73 -17
- package/docs/free-sources/understat.md +15 -6
- package/docs/free-sources/xg-timelines.md +123 -0
- package/docs/impect/concepts.md +183 -0
- package/docs/impect/coordinate-system.md +136 -0
- package/docs/impect/data-model.md +276 -0
- package/docs/impect/event-types.md +226 -0
- package/docs/impect/identity-surfaces.md +123 -51
- package/docs/impect/kpi-definitions.md +154 -0
- package/docs/impect/overview.md +152 -0
- package/docs/kloppy/data-model.md +68 -43
- package/docs/kloppy/event-derived-metrics.md +337 -0
- package/docs/kloppy/provider-mapping.md +30 -51
- package/docs/kloppy/tracking-rendering.md +420 -0
- package/docs/kloppy/usage.md +61 -49
- package/docs/mplsoccer/overview.md +1 -1
- package/docs/mplsoccer/pitch-types.md +3 -3
- package/docs/mplsoccer/visualizations.md +363 -6
- package/docs/opta/api-access.md +6 -1
- package/docs/opta/charting-game-state.md +216 -0
- package/docs/opta/charting-lineups.md +90 -0
- package/docs/opta/charting-passmaps.md +130 -0
- package/docs/opta/charting-set-pieces.md +106 -0
- package/docs/opta/charting-shot-placement.md +233 -0
- package/docs/opta/event-types.md +44 -0
- package/docs/opta/identity-surfaces.md +31 -59
- package/docs/opta/qualifiers.md +16 -7
- package/docs/skillcorner/api-access.md +68 -0
- package/docs/skillcorner/api-endpoints.md +79 -0
- package/docs/skillcorner/concepts.md +58 -0
- package/docs/skillcorner/coordinate-system.md +34 -0
- package/docs/skillcorner/data-model.md +79 -0
- package/docs/skillcorner/identity-surfaces.md +26 -43
- package/docs/skillcorner/physical-data.md +106 -0
- package/docs/socceraction/spadl.md +37 -11
- package/docs/socceraction/vaep-xt.md +23 -6
- package/docs/soccerdata/data-sources.md +7 -5
- package/docs/soccerdata/overview.md +7 -6
- package/docs/soccerdata/usage.md +1 -1
- package/docs/soccerdonna/identity-surfaces.md +16 -45
- package/docs/sportmonks/api-access.md +18 -6
- package/docs/sportmonks/charting-season-stories.md +125 -0
- package/docs/sportmonks/data-model.md +35 -12
- package/docs/sportmonks/event-types.md +1 -1
- package/docs/sportmonks/identity-surfaces.md +33 -56
- package/docs/sportradar/api-access.md +75 -0
- package/docs/sportradar/api-endpoints.md +92 -0
- package/docs/sportradar/charting-and-stories.md +57 -0
- package/docs/sportradar/data-model.md +84 -0
- package/docs/sportradar/integration-notes.md +58 -0
- package/docs/statsbomb/charting-lineups.md +79 -0
- package/docs/statsbomb/event-types.md +50 -32
- package/docs/statsbomb/identity-surfaces.md +33 -61
- package/docs/statsbomb/player-mapping.md +9 -10
- package/docs/thesportsdb/api-access.md +68 -0
- package/docs/thesportsdb/api-endpoints.md +60 -0
- package/docs/thesportsdb/identity-surfaces.md +48 -0
- package/docs/thesportsdb/livescore.md +70 -0
- package/docs/transfermarkt/identity-surfaces.md +23 -53
- package/docs/transferroom/api-access.md +91 -0
- package/docs/transferroom/api-endpoints.md +268 -0
- package/docs/transferroom/charting-availability.md +74 -0
- package/docs/transferroom/data-model.md +143 -0
- package/docs/transferroom/identity-surfaces.md +132 -0
- package/docs/wyscout/api-access.md +86 -127
- package/docs/wyscout/api-endpoints.md +136 -0
- package/docs/wyscout/charting-analysis-metrics.md +124 -0
- package/docs/wyscout/coordinate-system.md +35 -107
- package/docs/wyscout/data-model.md +185 -231
- package/docs/wyscout/event-types.md +59 -180
- package/docs/wyscout/glossary-events.md +1956 -0
- package/docs/wyscout/glossary-metrics-concepts.md +812 -0
- package/docs/wyscout/identity-surfaces.md +26 -43
- package/package.json +10 -15
- package/providers.json +186 -66
package/README.md
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
# football-docs
|
|
2
2
|
|
|
3
|
-
Searchable football data provider documentation for AI coding agents. Like [Context7](https://context7.com) for football data.
|
|
3
|
+
Searchable football data provider and tooling documentation for AI coding agents. Like [Context7](https://context7.com) for football data.
|
|
4
4
|
|
|
5
|
-
**Who it's for:** Developers and analysts who use AI coding tools (Claude Code, Cursor, VS Code Copilot
|
|
5
|
+
**Who it's for:** Developers and analysts who use AI coding tools (Claude Code, Cursor, VS Code Copilot) to work with football data. Works with any tool that supports MCP.
|
|
6
6
|
|
|
7
|
-
**What it does:** Gives your AI agent a searchable index of documentation for
|
|
7
|
+
**What it does:** Gives your AI agent a searchable index of documentation for 21 football data providers and tools — event types, qualifier IDs, coordinate systems, API endpoints, data models, identity surfaces, and cross-provider comparisons for the data providers (StatsBomb, Opta, Wyscout, Impect, SkillCorner, Sportradar, TheSportsDB, FMDB Pro, TransferRoom, and more), plus the open-source libraries people build with (kloppy, mplsoccer, socceraction, soccerdata, floodlight, and more). Your agent looks up the real docs instead of guessing from training data.
|
|
8
8
|
|
|
9
9
|
**Why not just let the AI figure it out?** LLMs get football data specifics wrong constantly — Opta qualifier IDs, StatsBomb coordinate ranges, API endpoint URLs, library method signatures. These are mutable facts that change across versions. football-docs gives the agent verified, sourced documentation with provenance tracking so you know where every answer came from.
|
|
10
10
|
|
|
11
|
+
## Strategy
|
|
12
|
+
|
|
13
|
+
football-docs is intended to be a community-owned, source-transparent Context7
|
|
14
|
+
for football data. The public operating contract is in
|
|
15
|
+
[STRATEGY.md](STRATEGY.md): what belongs here, what must stay out, how we handle
|
|
16
|
+
public-safe provider facts, and how contributors should prove retrieval quality.
|
|
17
|
+
|
|
11
18
|
## Provider identity facts
|
|
12
19
|
|
|
13
20
|
football-docs is the public source for provider identity-surface facts: access
|
|
14
21
|
shape, ID schemes, matching fields, provider quirks, and provenance rules.
|
|
15
|
-
Curated
|
|
16
|
-
|
|
17
|
-
page evidence, licensed feed shape, or a reviewed public-safe
|
|
18
|
-
must not include
|
|
19
|
-
|
|
22
|
+
Curated provider identity notes belong here when they can be stated as public
|
|
23
|
+
facts about the provider. They should say whether a fact comes from public docs,
|
|
24
|
+
public page evidence, licensed feed shape, or a reviewed public-safe
|
|
25
|
+
observation, and must not include credentials, local paths, internal tooling
|
|
26
|
+
details, or restricted payloads from any private project.
|
|
20
27
|
|
|
21
28
|
MCP ([Model Context Protocol](https://modelcontextprotocol.io)) is a standard for connecting AI coding tools to external data sources.
|
|
22
29
|
|
|
@@ -58,21 +65,6 @@ Add to `.vscode/mcp.json`:
|
|
|
58
65
|
}
|
|
59
66
|
```
|
|
60
67
|
|
|
61
|
-
### Windsurf
|
|
62
|
-
|
|
63
|
-
Add to `~/.codeium/windsurf/mcp_config.json`:
|
|
64
|
-
|
|
65
|
-
```json
|
|
66
|
-
{
|
|
67
|
-
"mcpServers": {
|
|
68
|
-
"football-docs": {
|
|
69
|
-
"command": "npx",
|
|
70
|
-
"args": ["-y", "football-docs"]
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
```
|
|
75
|
-
|
|
76
68
|
### Claude Desktop
|
|
77
69
|
|
|
78
70
|
Add to `claude_desktop_config.json`:
|
|
@@ -93,16 +85,21 @@ Add to `claude_desktop_config.json`:
|
|
|
93
85
|
| Tool | Description |
|
|
94
86
|
|------|-------------|
|
|
95
87
|
| `search_docs` | Full-text search across all provider docs. Filter by provider. Results include provenance (source URL, version). |
|
|
88
|
+
| `resolve_provider_id` | Resolve provider names and aliases to canonical indexed provider keys before searching. |
|
|
89
|
+
| `get_provider_docs` | Retrieve docs for a resolved provider, optionally filtered by topic or category. |
|
|
96
90
|
| `list_providers` | List all indexed providers and their doc coverage. |
|
|
97
91
|
| `compare_providers` | Compare how different providers handle the same concept. |
|
|
98
|
-
| `request_update` | Request a new provider, flag outdated docs, or suggest a better doc source.
|
|
92
|
+
| `request_update` | Request a new provider, flag outdated docs, or suggest a better doc source. Queues locally and points to the matching public GitHub issue template. |
|
|
93
|
+
| `resolve_entity` | Resolve players, teams, or coaches to cross-provider IDs via the Reep API. |
|
|
94
|
+
|
|
95
|
+
Provider filters use the indexed provider keys shown by `list_providers`, but common aliases are accepted. Examples: `fbref`, `understat`, `ClubElo`, `football-data.co.uk`, and `engsoccerdata` search `free-sources`; `Sofascore` and `ESPN` search `soccerdata`; `FMDB` searches `fmdb-pro`; `Transfer Room` searches `transferroom`; `Hudl Wyscout` searches `wyscout`; `Stats Perform` / `Opta F24` / `WhoScored` search `opta`; `Metrica`, `Sportec` / `DFL`, and `TRACAB` search `databallpy`; `Second Spectrum` searches `kloppy`; `SportRadar API` / `Soccer Extended` search `sportradar`; `The Sports DB` / `TSDB` search `thesportsdb`; `StatsBomb Open Data` searches `statsbomb`.
|
|
99
96
|
|
|
100
97
|
## Example queries
|
|
101
98
|
|
|
102
99
|
- "What is Opta qualifier 76?" (big chance)
|
|
103
100
|
- "How does StatsBomb represent shot events?"
|
|
104
101
|
- "Compare Opta and Wyscout coordinate systems"
|
|
105
|
-
- "
|
|
102
|
+
- "What player ID fields does Transfermarkt expose?"
|
|
106
103
|
- "Does SportMonks have xG data?"
|
|
107
104
|
- "What event types does kloppy map to GenericEvent?"
|
|
108
105
|
- "How does SPADL represent a tackle?"
|
|
@@ -111,45 +108,84 @@ Add to `claude_desktop_config.json`:
|
|
|
111
108
|
|
|
112
109
|
| Provider | Chunks | Categories |
|
|
113
110
|
|----------|--------|------------|
|
|
114
|
-
| StatsBomb |
|
|
115
|
-
|
|
|
116
|
-
|
|
|
111
|
+
| StatsBomb | 235 | event-types, data-model, coordinate-system, api-access, api-endpoints, charting-lineups, xg-model, iq-metrics, player/team stats, player-mapping, identity-surfaces |
|
|
112
|
+
| Wyscout | 161 | event-types, data-model, coordinate-system, api-access, api-endpoints, charting-analysis-metrics, glossary, identity-surfaces |
|
|
113
|
+
| kloppy | 126 | data-model, usage, provider-mapping, tracking-rendering, event-derived-metrics |
|
|
114
|
+
| floodlight | 145 | core data objects, io parsers (Tracab, DFL, Kinexon, Opta, SkillCorner, StatsBomb, StatsPerform, Second Spectrum), transforms, metrics, models, visualisation, guides |
|
|
115
|
+
| SportMonks | 82 | event-types, data-model, api-access, charting-season-stories, identity-surfaces |
|
|
117
116
|
| databallpy | 63 | data-model, overview, usage |
|
|
118
|
-
| mplsoccer |
|
|
119
|
-
|
|
|
120
|
-
|
|
|
117
|
+
| mplsoccer | 64 | overview, pitch-types, visualizations |
|
|
118
|
+
| Impect | 77 | overview, data-model, event-types, coordinate-system, concepts, kpi-definitions, identity-surfaces |
|
|
119
|
+
| SkillCorner | 48 | api-access, api-endpoints, data-model, physical-data, coordinate-system, concepts, identity-surfaces |
|
|
120
|
+
| Free sources | 62 | overview, fbref, understat, contextual-story-joins, xg-timelines |
|
|
121
121
|
| soccerdata | 40 | overview, data-sources, usage |
|
|
122
|
-
|
|
|
123
|
-
|
|
|
124
|
-
|
|
|
125
|
-
|
|
|
126
|
-
|
|
|
127
|
-
|
|
|
128
|
-
|
|
|
122
|
+
| TransferRoom | 43 | api-access, api-endpoints, charting-availability, data-model, identity-surfaces |
|
|
123
|
+
| Opta | 71 | event-types, qualifiers, coordinate-system, api-access, charting-game-state, charting-lineups, charting-passmaps, charting-set-pieces, charting-shot-placement, identity-surfaces |
|
|
124
|
+
| FMDB Pro | 35 | api-access, api-endpoints, data-model, identity-surfaces |
|
|
125
|
+
| Sportradar | 29 | api-access, api-endpoints, data-model, charting-and-stories, integration-notes |
|
|
126
|
+
| socceraction | 34 | SPADL format, VAEP, Expected Threat |
|
|
127
|
+
| BeSoccer | 14 | api-access, api-endpoints |
|
|
128
|
+
| TheSportsDB | 18 | api-access, api-endpoints, livescore, identity-surfaces |
|
|
129
|
+
| FotMob | 3 | identity-surfaces |
|
|
130
|
+
| Soccerdonna | 3 | identity-surfaces |
|
|
131
|
+
| Transfermarkt | 3 | identity-surfaces |
|
|
132
|
+
|
|
133
|
+
**1,356 searchable chunks** across 21 providers and tools.
|
|
134
|
+
|
|
135
|
+
> **Impect** documentation is built solely from the public
|
|
136
|
+
> [ImpectAPI/open-data](https://github.com/ImpectAPI/open-data) repository — a
|
|
137
|
+
> static Bundesliga 2023/24 snapshot, representative of Impect's structure and
|
|
138
|
+
> metric definitions rather than a complete or current mirror. Impect's
|
|
139
|
+
> commercial API is deliberately not documented here. Every enum value, KPI name
|
|
140
|
+
> and field name in `docs/impect/` is validated against that repository in CI
|
|
141
|
+
> (`pnpm impect:truth`, `src/__tests__/impect-open-data-validation.test.ts`).
|
|
142
|
+
> Data source: **Impect**; use is subject to the repository's own Terms of Use.
|
|
143
|
+
|
|
144
|
+
## Documentation validation
|
|
145
|
+
|
|
146
|
+
Docs for AI agents are only useful if they are correct, and prose about an API is
|
|
147
|
+
exactly the kind of thing that drifts or gets invented. Where a machine-readable
|
|
148
|
+
source of truth exists, this repo checks the docs against it in CI rather than
|
|
149
|
+
trusting them.
|
|
150
|
+
|
|
151
|
+
| Providers | Ground truth | Checked by |
|
|
152
|
+
|---|---|---|
|
|
153
|
+
| kloppy, socceraction, soccerdata, mplsoccer, floodlight, databallpy, skillcorner | The installed package itself — enum members, importable symbols, class constants | `src/__tests__/provider-truth.test.ts` |
|
|
154
|
+
| Wyscout, SkillCorner, FMDB Pro, Sportradar | The vendor's own publicly published OpenAPI spec — endpoint paths and methods | `src/__tests__/provider-truth.test.ts` |
|
|
155
|
+
| BeSoccer | The vendor's published Postman collection — request vocabulary and parameters | `src/__tests__/provider-truth.test.ts` |
|
|
156
|
+
| Impect | The public [open-data](https://github.com/ImpectAPI/open-data) repository | `src/__tests__/impect-open-data-validation.test.ts` |
|
|
157
|
+
|
|
158
|
+
Truth files live in `data/provider-truth/` and are generated, not hand-written:
|
|
129
159
|
|
|
130
|
-
|
|
160
|
+
```bash
|
|
161
|
+
pnpm provider:truth # rebuild every package truth file (needs python3.11)
|
|
162
|
+
pnpm openapi:truth # rebuild every spec-derived truth file
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
The specs those derive from are snapshots of **publicly published, unauthenticated**
|
|
166
|
+
vendor documentation. Source URLs, fetch dates and refresh instructions are in
|
|
167
|
+
[`specs/README.md`](specs/README.md). Wyscout's three API versions merge into one
|
|
168
|
+
truth file, because its docs legitimately span v2, v3 and v4.
|
|
169
|
+
|
|
170
|
+
Each package gets its own pinned venv — co-installing them makes pip silently
|
|
171
|
+
downgrade conflicting versions, which would produce truth that disagrees with the
|
|
172
|
+
docs. Bump a pin in `scripts/gen_all_truth.sh` and the matching `version` in
|
|
173
|
+
`providers.json` together, then re-run and fix whatever the tests flag.
|
|
174
|
+
|
|
175
|
+
A doc that names an enum member or importable symbol which does not exist in the
|
|
176
|
+
real package fails the build. `scripts/gen_openapi_truth.py` derives the same kind
|
|
177
|
+
of facts from a vendor OpenAPI spec, for providers documented that way.
|
|
131
178
|
|
|
132
179
|
## Contributing
|
|
133
180
|
|
|
134
181
|
Contributions are welcome from everyone. There are three ways to help:
|
|
135
182
|
|
|
136
183
|
1. **Open an issue** — [request a new provider](https://github.com/withqwerty/football-docs/issues/new/choose), [flag outdated docs](https://github.com/withqwerty/football-docs/issues/new/choose), or [suggest a better doc source](https://github.com/withqwerty/football-docs/issues/new/choose)
|
|
137
|
-
2. **Use the `request_update` tool** — AI agents can flag outdated or missing docs directly via the MCP server, which queues requests
|
|
184
|
+
2. **Use the `request_update` tool** — AI agents can flag outdated or missing docs directly via the MCP server, which queues requests locally and points to the matching public GitHub issue template
|
|
138
185
|
3. **Open a PR** — fix errors, add new providers, or improve existing docs
|
|
139
186
|
|
|
140
187
|
**You don't need to be an expert.** See **[CONTRIBUTING.md](CONTRIBUTING.md)** for the full guide.
|
|
141
188
|
|
|
142
|
-
### What we especially need
|
|
143
|
-
|
|
144
|
-
| Provider | Priority | Source material to start from |
|
|
145
|
-
|----------|----------|-------------------------------|
|
|
146
|
-
| FPL (Fantasy Premier League) | High | [FPL APIs Explained](https://www.oliverlooney.com/blogs/FPL-APIs-Explained) |
|
|
147
|
-
| API-Football (RapidAPI) | High | [API-Football docs](https://www.api-football.com/documentation-v3) |
|
|
148
|
-
| Football-data.org | Medium | [Football-data.org docs](https://www.football-data.org/documentation/api) |
|
|
149
|
-
| TheSportsDB | Medium | [TheSportsDB API](https://www.thesportsdb.com/api.php) |
|
|
150
|
-
| WhoScored | Medium | Based on Opta F24, community-documented |
|
|
151
|
-
| Sofascore | Medium | Unofficial API, community-documented |
|
|
152
|
-
|
|
153
189
|
## For maintainers
|
|
154
190
|
|
|
155
191
|
### Crawl pipeline
|
package/bin/serve.js
CHANGED
|
@@ -3,4 +3,9 @@ import { resolve, dirname } from "node:path";
|
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
4
|
|
|
5
5
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
|
-
await import(pathToFileURL(resolve(__dirname, "..", "dist", "index.js")).href);
|
|
6
|
+
const { main } = await import(pathToFileURL(resolve(__dirname, "..", "dist", "index.js")).href);
|
|
7
|
+
|
|
8
|
+
main().catch((error) => {
|
|
9
|
+
console.error("Failed to start football-docs MCP server:", error);
|
|
10
|
+
process.exit(1);
|
|
11
|
+
});
|
package/data/docs.db
CHANGED
|
Binary file
|
package/dist/crawl.js
CHANGED
|
@@ -30,6 +30,58 @@ const turndown = new TurndownService({
|
|
|
30
30
|
codeBlockStyle: "fenced",
|
|
31
31
|
bulletListMarker: "-",
|
|
32
32
|
});
|
|
33
|
+
// Sphinx (and other Pygments-based renderers) mark up code blocks as bare
|
|
34
|
+
// <pre> containing syntax-highlighting <span>s, not <pre><code>. Turndown's
|
|
35
|
+
// built-in fenced-code rule only matches <pre><code>, so these fall through
|
|
36
|
+
// to plain-text handling where markdown-escaping mangles identifiers (e.g.
|
|
37
|
+
// `read_position_data_json` becomes `read\_position\_data\_json`). Read
|
|
38
|
+
// textContent directly to bypass that escaping.
|
|
39
|
+
turndown.addRule("preBlock", {
|
|
40
|
+
filter: "pre",
|
|
41
|
+
replacement: (_content, node) => {
|
|
42
|
+
const code = node.textContent?.replace(/\n+$/, "") ?? "";
|
|
43
|
+
if (!code.trim())
|
|
44
|
+
return "";
|
|
45
|
+
const parentClass = node.parentElement?.getAttribute?.("class") ?? "";
|
|
46
|
+
const langMatch = parentClass.match(/highlight-(\w+)/);
|
|
47
|
+
const lang = langMatch && langMatch[1] !== "default" ? langMatch[1] : "";
|
|
48
|
+
return `\n\n\`\`\`${lang}\n${code}\n\`\`\`\n\n`;
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
// Sphinx marks up identifiers/parameter names/default values in signatures
|
|
52
|
+
// with <span class="pre"> (a "don't word-wrap" hint, not semantic <code>).
|
|
53
|
+
// Same escaping problem as above — render as inline code instead.
|
|
54
|
+
turndown.addRule("sphinxPreSpan", {
|
|
55
|
+
filter: (node) => node.nodeName === "SPAN" &&
|
|
56
|
+
(node.getAttribute?.("class") ?? "")
|
|
57
|
+
.split(/\s+/)
|
|
58
|
+
.includes("pre"),
|
|
59
|
+
replacement: (_content, node) => `\`${node.textContent ?? ""}\``,
|
|
60
|
+
});
|
|
61
|
+
// Turndown escapes every underscore in plain text nodes by default (guarding
|
|
62
|
+
// against accidental markdown emphasis), including identifiers that carry no
|
|
63
|
+
// code markup at all — e.g. Sphinx renders parameter/return names in
|
|
64
|
+
// "Variables:" lists as plain `<strong>essential_missing</strong>`, no <code>
|
|
65
|
+
// or .pre span in sight. Since this corpus exists for full-text search rather
|
|
66
|
+
// than pixel-perfect rendering, an escaped underscore that breaks substring
|
|
67
|
+
// matches on the real identifier is worse than the rare accidental italics.
|
|
68
|
+
const defaultEscape = turndown.escape.bind(turndown);
|
|
69
|
+
turndown.escape = (text) => defaultEscape(text).replace(/\\_/g, "_");
|
|
70
|
+
// Turndown's built-in image rule escapes alt text via a private module-level
|
|
71
|
+
// helper, not the overridable `escape` method above, so alt text (often just
|
|
72
|
+
// the image's own filename, e.g. "pitch_positive.png") still comes out with
|
|
73
|
+
// escaped underscores. Same fix, applied to this one rule directly.
|
|
74
|
+
turndown.addRule("unescapedImageAlt", {
|
|
75
|
+
filter: "img",
|
|
76
|
+
replacement: (_content, node) => {
|
|
77
|
+
const el = node;
|
|
78
|
+
const alt = el.getAttribute?.("alt") ?? "";
|
|
79
|
+
const src = el.getAttribute?.("src") ?? "";
|
|
80
|
+
const title = el.getAttribute?.("title");
|
|
81
|
+
const titlePart = title ? ` "${title.replace(/"/g, '\\"')}"` : "";
|
|
82
|
+
return src ? `` : "";
|
|
83
|
+
},
|
|
84
|
+
});
|
|
33
85
|
// ── HTML → Markdown ──────────────────────────────────────────────────
|
|
34
86
|
/**
|
|
35
87
|
* Extract main content from an HTML page and convert to markdown.
|
|
@@ -43,7 +95,13 @@ export function htmlToMarkdown(html, url) {
|
|
|
43
95
|
? html
|
|
44
96
|
: html.replace(/(<head[^>]*>)/i, `$1<base href="${url}">`);
|
|
45
97
|
const { document } = parseHTML(htmlWithBase);
|
|
46
|
-
|
|
98
|
+
// classesToPreserve keeps class="pre" (Sphinx's no-wrap marker for inline
|
|
99
|
+
// literals) alive through Readability's cleanup, so the sphinxPreSpan
|
|
100
|
+
// Turndown rule above can still detect and unescape it.
|
|
101
|
+
const reader = new Readability(document, {
|
|
102
|
+
charThreshold: 100,
|
|
103
|
+
classesToPreserve: ["pre"],
|
|
104
|
+
});
|
|
47
105
|
const article = reader.parse();
|
|
48
106
|
if (!article?.content)
|
|
49
107
|
return null;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ground-truth validation for the Impect documentation set.
|
|
3
|
+
*
|
|
4
|
+
* The Impect corpus is built from one source only: the public open-data
|
|
5
|
+
* repository at https://github.com/ImpectAPI/open-data. Everything in
|
|
6
|
+
* docs/impect/ must be traceable to it — enum members, KPI names and IDs, and
|
|
7
|
+
* field names all appear in that repository, so anything else in the docs is an
|
|
8
|
+
* invention and should fail the build.
|
|
9
|
+
*
|
|
10
|
+
* Two halves:
|
|
11
|
+
*
|
|
12
|
+
* 1. A generator (CLI) that reads a local clone of the open-data repository
|
|
13
|
+
* and writes data/impect-open-data-truth.json. Maintainer-only; needs the
|
|
14
|
+
* clone, so it is not run in CI.
|
|
15
|
+
*
|
|
16
|
+
* 2. validateImpectDocs(), a pure function run by the test suite against the
|
|
17
|
+
* committed truth file. No clone required.
|
|
18
|
+
*
|
|
19
|
+
* Usage:
|
|
20
|
+
* pnpm impect:truth # uses IMPECT_OPEN_DATA_DIR
|
|
21
|
+
* pnpm impect:truth -- --dir /path/to/open-data
|
|
22
|
+
*/
|
|
23
|
+
export declare const OPEN_DATA_REPO = "https://github.com/ImpectAPI/open-data";
|
|
24
|
+
export interface ImpectTruth {
|
|
25
|
+
source: {
|
|
26
|
+
repo: string;
|
|
27
|
+
commit: string;
|
|
28
|
+
generated_at: string;
|
|
29
|
+
matches: number;
|
|
30
|
+
events: number;
|
|
31
|
+
};
|
|
32
|
+
/** Enum members observed in the snapshot, by field name. */
|
|
33
|
+
enums: Record<string, string[]>;
|
|
34
|
+
/** KPI id (as string) -> machine name, from kpi_definitions.json. */
|
|
35
|
+
kpis: Record<string, string>;
|
|
36
|
+
/** ISO and FIFA country codes from countries.json. */
|
|
37
|
+
countryCodes: string[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Guards against Impect's commercial API surface reappearing in the corpus.
|
|
41
|
+
* Assembled patterns rather than literal strings: this file is the enforcement
|
|
42
|
+
* mechanism, so it should not carry a copy of what it exists to keep out.
|
|
43
|
+
*/
|
|
44
|
+
export declare const FORBIDDEN_PATTERNS: Array<{
|
|
45
|
+
label: string;
|
|
46
|
+
pattern: RegExp;
|
|
47
|
+
}>;
|
|
48
|
+
/** Build the truth file from a local clone of the open-data repository. */
|
|
49
|
+
export declare function generateTruth(openDataDir: string, commit: string, generatedAt: string): ImpectTruth;
|
|
50
|
+
export interface DocFile {
|
|
51
|
+
file: string;
|
|
52
|
+
text: string;
|
|
53
|
+
}
|
|
54
|
+
/** Every SCREAMING_SNAKE_CASE token inside a backtick code span. */
|
|
55
|
+
export declare function extractUppercaseTokens(text: string): string[];
|
|
56
|
+
/**
|
|
57
|
+
* Check the Impect docs against the open-data ground truth.
|
|
58
|
+
* Returns a list of human-readable violations; empty means clean.
|
|
59
|
+
*/
|
|
60
|
+
export declare function validateImpectDocs(docs: DocFile[], truth: ImpectTruth): string[];
|
|
61
|
+
export declare function loadTruth(path?: string): ImpectTruth;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ground-truth validation for the Impect documentation set.
|
|
3
|
+
*
|
|
4
|
+
* The Impect corpus is built from one source only: the public open-data
|
|
5
|
+
* repository at https://github.com/ImpectAPI/open-data. Everything in
|
|
6
|
+
* docs/impect/ must be traceable to it — enum members, KPI names and IDs, and
|
|
7
|
+
* field names all appear in that repository, so anything else in the docs is an
|
|
8
|
+
* invention and should fail the build.
|
|
9
|
+
*
|
|
10
|
+
* Two halves:
|
|
11
|
+
*
|
|
12
|
+
* 1. A generator (CLI) that reads a local clone of the open-data repository
|
|
13
|
+
* and writes data/impect-open-data-truth.json. Maintainer-only; needs the
|
|
14
|
+
* clone, so it is not run in CI.
|
|
15
|
+
*
|
|
16
|
+
* 2. validateImpectDocs(), a pure function run by the test suite against the
|
|
17
|
+
* committed truth file. No clone required.
|
|
18
|
+
*
|
|
19
|
+
* Usage:
|
|
20
|
+
* pnpm impect:truth # uses IMPECT_OPEN_DATA_DIR
|
|
21
|
+
* pnpm impect:truth -- --dir /path/to/open-data
|
|
22
|
+
*/
|
|
23
|
+
import { readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
24
|
+
import { dirname, resolve } from "node:path";
|
|
25
|
+
import { fileURLToPath } from "node:url";
|
|
26
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
27
|
+
const TRUTH_PATH = resolve(__dirname, "..", "data", "impect-open-data-truth.json");
|
|
28
|
+
export const OPEN_DATA_REPO = "https://github.com/ImpectAPI/open-data";
|
|
29
|
+
/**
|
|
30
|
+
* Documented in the repository's Documentation.pdf but not present in the
|
|
31
|
+
* snapshot, so the generator cannot observe them. Editorial, not derived from
|
|
32
|
+
* the data — which is why these live here rather than in the truth file.
|
|
33
|
+
*/
|
|
34
|
+
const DOCUMENTED_ONLY = [
|
|
35
|
+
// dataV4+ woodwork enum
|
|
36
|
+
"LEFT_POST",
|
|
37
|
+
"RIGHT_POST",
|
|
38
|
+
"CROSSBAR",
|
|
39
|
+
"CROSSBAR_LEFT_POST",
|
|
40
|
+
"CROSSBAR_RIGHT_POST",
|
|
41
|
+
// dataV4+ card action / actionType
|
|
42
|
+
"YELLOW_CARD",
|
|
43
|
+
// appendix 3 documents GROUND_DUEL as an action; the data emits DUEL there
|
|
44
|
+
"GROUND_DUEL",
|
|
45
|
+
// appendix 8 prints the pxT identity with this spelling; the KPI is PXT_NO_VIDEO
|
|
46
|
+
"PXT_NOVIDEO",
|
|
47
|
+
// documented enum members outside this snapshot's coverage (men's club league)
|
|
48
|
+
"FEMALE",
|
|
49
|
+
"NATIONAL_TEAM",
|
|
50
|
+
];
|
|
51
|
+
/** Values the docs name only to rule them out, as negative examples. */
|
|
52
|
+
const NON_MEMBERS = ["BUILD_UP", "COUNTER_ATTACK"];
|
|
53
|
+
/** Tokens that are not Impect data values at all. */
|
|
54
|
+
const ALLOWLIST = [
|
|
55
|
+
"OPP_", // the bare prefix, discussed as a prefix
|
|
56
|
+
"STATIC_HOME_AWAY", // kloppy orientation, in the loading example
|
|
57
|
+
];
|
|
58
|
+
/**
|
|
59
|
+
* Guards against Impect's commercial API surface reappearing in the corpus.
|
|
60
|
+
* Assembled patterns rather than literal strings: this file is the enforcement
|
|
61
|
+
* mechanism, so it should not carry a copy of what it exists to keep out.
|
|
62
|
+
*/
|
|
63
|
+
export const FORBIDDEN_PATTERNS = [
|
|
64
|
+
{ label: "Impect API hostname", pattern: /\b(?:api|login)\.impect\.com\b/i },
|
|
65
|
+
{ label: "Impect commercial API path", pattern: /\bcustomer[-_]?api\b/i },
|
|
66
|
+
{ label: "bundled Impect OpenAPI spec", pattern: /impect[-_]?openapi/i },
|
|
67
|
+
];
|
|
68
|
+
/** Collect every distinct non-null value at a dotted path across an array of records. */
|
|
69
|
+
function collect(records, path) {
|
|
70
|
+
const parts = path.split(".");
|
|
71
|
+
const out = new Set();
|
|
72
|
+
for (const record of records) {
|
|
73
|
+
let value = record;
|
|
74
|
+
for (const part of parts) {
|
|
75
|
+
if (value === null || typeof value !== "object") {
|
|
76
|
+
value = null;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
value = value[part];
|
|
80
|
+
}
|
|
81
|
+
if (typeof value === "string")
|
|
82
|
+
out.add(value);
|
|
83
|
+
}
|
|
84
|
+
return [...out].sort();
|
|
85
|
+
}
|
|
86
|
+
function readJson(path) {
|
|
87
|
+
return JSON.parse(readFileSync(path, "utf-8"));
|
|
88
|
+
}
|
|
89
|
+
/** Build the truth file from a local clone of the open-data repository. */
|
|
90
|
+
export function generateTruth(openDataDir, commit, generatedAt) {
|
|
91
|
+
const dataDir = resolve(openDataDir, "data");
|
|
92
|
+
const eventFiles = readdirSync(resolve(dataDir, "events")).filter((f) => f.endsWith(".json"));
|
|
93
|
+
const enums = {};
|
|
94
|
+
const add = (field, values) => {
|
|
95
|
+
enums[field] ??= new Set();
|
|
96
|
+
for (const v of values)
|
|
97
|
+
enums[field].add(v);
|
|
98
|
+
};
|
|
99
|
+
let eventCount = 0;
|
|
100
|
+
for (const file of eventFiles) {
|
|
101
|
+
const events = readJson(resolve(dataDir, "events", file));
|
|
102
|
+
eventCount += events.length;
|
|
103
|
+
add("actionType", collect(events, "actionType"));
|
|
104
|
+
add("action", collect(events, "action"));
|
|
105
|
+
add("result", collect(events, "result"));
|
|
106
|
+
add("phase", collect(events, "phase"));
|
|
107
|
+
add("bodyPart", collect(events, "bodyPart"));
|
|
108
|
+
add("bodyPartExtended", collect(events, "bodyPartExtended"));
|
|
109
|
+
add("previousPassHeight", collect(events, "previousPassHeight"));
|
|
110
|
+
add("distanceToOpponent", collect(events, "distanceToOpponent"));
|
|
111
|
+
add("duelType", collect(events, "duel.duelType"));
|
|
112
|
+
add("receiverType", collect(events, "pass.receiver.type"));
|
|
113
|
+
add("position", collect(events, "player.position"));
|
|
114
|
+
add("positionSide", collect(events, "player.positionSide"));
|
|
115
|
+
for (const end of ["start", "end"]) {
|
|
116
|
+
add("packingZone", collect(events, `${end}.packingZone`));
|
|
117
|
+
add("lane", collect(events, `${end}.lane`));
|
|
118
|
+
add("pitchPosition", collect(events, `${end}.pitchPosition`));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// BANK and UNKNOWN appear only in lineups, never on events.
|
|
122
|
+
for (const file of readdirSync(resolve(dataDir, "lineups")).filter((f) => f.endsWith(".json"))) {
|
|
123
|
+
const lineup = readJson(resolve(dataDir, "lineups", file));
|
|
124
|
+
for (const side of ["squadHome", "squadAway"]) {
|
|
125
|
+
const squad = lineup[side];
|
|
126
|
+
if (!squad)
|
|
127
|
+
continue;
|
|
128
|
+
const starting = (squad.startingPositions ?? []);
|
|
129
|
+
const subs = (squad.substitutions ?? []);
|
|
130
|
+
add("position", collect(starting, "position"));
|
|
131
|
+
add("position", collect(subs, "toPosition"));
|
|
132
|
+
add("position", collect(subs, "fromPosition"));
|
|
133
|
+
add("positionSide", collect(starting, "positionSide"));
|
|
134
|
+
add("positionSide", collect(subs, "positionSide"));
|
|
135
|
+
add("positionSide", collect(subs, "fromPositionSide"));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const iterationDir = resolve(dataDir, "players");
|
|
139
|
+
const players = readdirSync(iterationDir)
|
|
140
|
+
.filter((f) => f.endsWith(".json"))
|
|
141
|
+
.flatMap((f) => readJson(resolve(iterationDir, f)));
|
|
142
|
+
add("leg", collect(players, "leg"));
|
|
143
|
+
add("gender", collect(players, "gender"));
|
|
144
|
+
const squads = readdirSync(resolve(dataDir, "squads"))
|
|
145
|
+
.filter((f) => f.endsWith(".json"))
|
|
146
|
+
.flatMap((f) => readJson(resolve(dataDir, "squads", f)));
|
|
147
|
+
add("squadType", collect(squads, "type"));
|
|
148
|
+
const iterations = readJson(resolve(dataDir, "iterations.json"));
|
|
149
|
+
add("dataVersion", collect(iterations, "dataVersion"));
|
|
150
|
+
const kpiDefs = readJson(resolve(dataDir, "kpi_definitions.json"));
|
|
151
|
+
const kpis = {};
|
|
152
|
+
for (const kpi of kpiDefs)
|
|
153
|
+
kpis[String(kpi.id)] = kpi.name;
|
|
154
|
+
const countries = readJson(resolve(dataDir, "countries.json"));
|
|
155
|
+
const countryCodes = [
|
|
156
|
+
...new Set([...collect(countries, "isoCode"), ...collect(countries, "fifaCode")]),
|
|
157
|
+
].sort();
|
|
158
|
+
const matches = readdirSync(resolve(dataDir, "matches"))
|
|
159
|
+
.filter((f) => f.endsWith(".json"))
|
|
160
|
+
.flatMap((f) => readJson(resolve(dataDir, "matches", f)));
|
|
161
|
+
return {
|
|
162
|
+
source: {
|
|
163
|
+
repo: OPEN_DATA_REPO,
|
|
164
|
+
commit,
|
|
165
|
+
generated_at: generatedAt,
|
|
166
|
+
matches: matches.length,
|
|
167
|
+
events: eventCount,
|
|
168
|
+
},
|
|
169
|
+
enums: Object.fromEntries(Object.entries(enums)
|
|
170
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
171
|
+
.map(([field, values]) => [field, [...values].sort()])),
|
|
172
|
+
kpis,
|
|
173
|
+
countryCodes,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/** Every SCREAMING_SNAKE_CASE token inside a backtick code span. */
|
|
177
|
+
export function extractUppercaseTokens(text) {
|
|
178
|
+
const out = new Set();
|
|
179
|
+
for (const match of text.matchAll(/`([A-Z][A-Z0-9_]{2,})`/g)) {
|
|
180
|
+
out.add(match[1]);
|
|
181
|
+
}
|
|
182
|
+
return [...out];
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Check the Impect docs against the open-data ground truth.
|
|
186
|
+
* Returns a list of human-readable violations; empty means clean.
|
|
187
|
+
*/
|
|
188
|
+
export function validateImpectDocs(docs, truth) {
|
|
189
|
+
const violations = [];
|
|
190
|
+
const known = new Set([
|
|
191
|
+
...Object.values(truth.enums).flat(),
|
|
192
|
+
...Object.values(truth.kpis),
|
|
193
|
+
...truth.countryCodes,
|
|
194
|
+
...DOCUMENTED_ONLY,
|
|
195
|
+
...NON_MEMBERS,
|
|
196
|
+
...ALLOWLIST,
|
|
197
|
+
]);
|
|
198
|
+
for (const { file, text } of docs) {
|
|
199
|
+
for (const { label, pattern } of FORBIDDEN_PATTERNS) {
|
|
200
|
+
if (pattern.test(text)) {
|
|
201
|
+
violations.push(`${file}: contains forbidden commercial-API reference (${label})`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
for (const token of extractUppercaseTokens(text)) {
|
|
205
|
+
if (!known.has(token)) {
|
|
206
|
+
violations.push(`${file}: "${token}" is not present in the open-data repository — invented, renamed, or needs an explicit entry in impect-truth.ts`);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
// The KPI index table maps ID -> name; both must match the source file.
|
|
210
|
+
for (const row of text.matchAll(/^\|\s*`(\d+)`\s*\|\s*`([A-Z][A-Z0-9_]*)`\s*\|/gm)) {
|
|
211
|
+
const [, id, name] = row;
|
|
212
|
+
const actual = truth.kpis[id];
|
|
213
|
+
if (actual === undefined) {
|
|
214
|
+
violations.push(`${file}: KPI id ${id} does not exist in kpi_definitions.json`);
|
|
215
|
+
}
|
|
216
|
+
else if (actual !== name) {
|
|
217
|
+
violations.push(`${file}: KPI id ${id} is "${actual}" in the source, documented as "${name}"`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return violations;
|
|
222
|
+
}
|
|
223
|
+
export function loadTruth(path = TRUTH_PATH) {
|
|
224
|
+
return JSON.parse(readFileSync(path, "utf-8"));
|
|
225
|
+
}
|
|
226
|
+
function main() {
|
|
227
|
+
const dirArg = process.argv.indexOf("--dir");
|
|
228
|
+
const openDataDir = dirArg >= 0 ? process.argv[dirArg + 1] : process.env.IMPECT_OPEN_DATA_DIR;
|
|
229
|
+
if (!openDataDir) {
|
|
230
|
+
console.error(`Need a local clone of ${OPEN_DATA_REPO}.\n` +
|
|
231
|
+
` git clone ${OPEN_DATA_REPO}.git\n` +
|
|
232
|
+
" pnpm impect:truth -- --dir /path/to/open-data\n" +
|
|
233
|
+
"or set IMPECT_OPEN_DATA_DIR.");
|
|
234
|
+
process.exit(1);
|
|
235
|
+
}
|
|
236
|
+
const commit = process.env.IMPECT_OPEN_DATA_COMMIT ?? "unknown";
|
|
237
|
+
const generatedAt = new Date().toISOString().slice(0, 10);
|
|
238
|
+
console.log(`Reading open data from ${openDataDir}...`);
|
|
239
|
+
const truth = generateTruth(openDataDir, commit, generatedAt);
|
|
240
|
+
writeFileSync(TRUTH_PATH, `${JSON.stringify(truth, null, 2)}\n`);
|
|
241
|
+
const enumCount = Object.values(truth.enums).reduce((n, v) => n + v.length, 0);
|
|
242
|
+
console.log(`Wrote ${TRUTH_PATH}\n` +
|
|
243
|
+
` ${truth.source.events} events across ${truth.source.matches} matches\n` +
|
|
244
|
+
` ${Object.keys(truth.enums).length} enums, ${enumCount} members\n` +
|
|
245
|
+
` ${Object.keys(truth.kpis).length} KPI definitions`);
|
|
246
|
+
}
|
|
247
|
+
const isDirectRun = process.argv[1]?.endsWith("impect-truth.ts") || process.argv[1]?.endsWith("impect-truth.js");
|
|
248
|
+
if (isDirectRun) {
|
|
249
|
+
main();
|
|
250
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,11 +3,16 @@
|
|
|
3
3
|
*
|
|
4
4
|
* A Context7-style searchable index of football data provider documentation.
|
|
5
5
|
* Exposes tools for searching docs, listing providers, comparing providers,
|
|
6
|
-
*
|
|
6
|
+
* requesting documentation updates, and resolving football entities.
|
|
7
7
|
*
|
|
8
|
-
* Data is stored in a SQLite FTS5 index for fast offline search.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Data is stored in a SQLite FTS5 index for fast offline search. Update
|
|
9
|
+
* requests are stored in a separate writable SQLite DB in a user-writable
|
|
10
|
+
* location (XDG_DATA_HOME or ~/.local/share).
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
13
|
+
import Database from "better-sqlite3";
|
|
14
|
+
export { sanitiseFtsQuery } from "./tools.js";
|
|
15
|
+
export declare function openDb(): Database.Database;
|
|
16
|
+
export declare function openQueueDb(): Database.Database;
|
|
17
|
+
export declare function createFootballDocsServer(): McpServer;
|
|
18
|
+
export declare function main(): Promise<void>;
|