football-docs 0.12.0 → 0.12.2

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.
Files changed (104) hide show
  1. package/README.md +33 -19
  2. package/data/docs.db +0 -0
  3. package/dist/crawl.d.ts +55 -0
  4. package/dist/crawl.js +231 -0
  5. package/dist/tools.js +27 -6
  6. package/docs/besoccer/data-provenance.md +20 -0
  7. package/docs/driblab/data-provenance.md +21 -0
  8. package/docs/espn/api-access.md +8 -0
  9. package/docs/fmdb-pro/data-provenance.md +22 -0
  10. package/docs/fotmob/data-provenance.md +20 -0
  11. package/docs/free-sources/contextual-story-joins.md +4 -0
  12. package/docs/free-sources/data-provenance.md +83 -0
  13. package/docs/free-sources/overview.md +26 -21
  14. package/docs/impect/data-provenance.md +23 -0
  15. package/docs/opta/data-provenance.md +20 -0
  16. package/docs/reep/data-provenance.md +28 -0
  17. package/docs/skillcorner/data-provenance.md +19 -0
  18. package/docs/soccerdata/data-sources.md +1 -1
  19. package/docs/soccerdonna/data-provenance.md +19 -0
  20. package/docs/sportmonks/data-provenance.md +21 -0
  21. package/docs/sportradar/api-access.md +10 -0
  22. package/docs/sportradar/api-endpoints.md +0 -14
  23. package/docs/sportradar/data-provenance.md +19 -0
  24. package/docs/sportradar/monitoring-data-changes.md +310 -0
  25. package/docs/sportradar/soccer-api-vs-soccer-extended-api.md +194 -0
  26. package/docs/sportradar/soccer-extended-competition-info.md +23 -0
  27. package/docs/sportradar/soccer-extended-competition-seasons.md +31 -0
  28. package/docs/sportradar/soccer-extended-competitions.md +39 -0
  29. package/docs/sportradar/soccer-extended-competitor-mappings.md +27 -0
  30. package/docs/sportradar/soccer-extended-competitor-merge-mappings.md +28 -0
  31. package/docs/sportradar/soccer-extended-competitor-profile.md +115 -0
  32. package/docs/sportradar/soccer-extended-competitor-schedules.md +219 -0
  33. package/docs/sportradar/soccer-extended-competitor-summaries.md +150 -0
  34. package/docs/sportradar/soccer-extended-competitor-vs-competitor.md +39 -0
  35. package/docs/sportradar/soccer-extended-daily-schedules.md +23 -0
  36. package/docs/sportradar/soccer-extended-daily-summaries.md +23 -0
  37. package/docs/sportradar/soccer-extended-faq.md +1332 -0
  38. package/docs/sportradar/soccer-extended-fifa-rankings.md +56 -0
  39. package/docs/sportradar/soccer-extended-league-timeline.md +116 -0
  40. package/docs/sportradar/soccer-extended-live-schedules.md +23 -0
  41. package/docs/sportradar/soccer-extended-live-summaries.md +23 -0
  42. package/docs/sportradar/soccer-extended-live-timelines-delta.md +58 -0
  43. package/docs/sportradar/soccer-extended-live-timelines.md +65 -0
  44. package/docs/sportradar/soccer-extended-overview.md +241 -0
  45. package/docs/sportradar/soccer-extended-player-mappings.md +27 -0
  46. package/docs/sportradar/soccer-extended-player-merge-mappings.md +28 -0
  47. package/docs/sportradar/soccer-extended-player-profile.md +64 -0
  48. package/docs/sportradar/soccer-extended-player-schedules.md +23 -0
  49. package/docs/sportradar/soccer-extended-player-summaries.md +23 -0
  50. package/docs/sportradar/soccer-extended-push-events.md +252 -0
  51. package/docs/sportradar/soccer-extended-push-feeds.md +129 -0
  52. package/docs/sportradar/soccer-extended-push-statistics.md +258 -0
  53. package/docs/sportradar/soccer-extended-season-competitors.md +34 -0
  54. package/docs/sportradar/soccer-extended-season-form-standings.md +59 -0
  55. package/docs/sportradar/soccer-extended-season-info.md +146 -0
  56. package/docs/sportradar/soccer-extended-season-leaders.md +46 -0
  57. package/docs/sportradar/soccer-extended-season-lineups.md +86 -0
  58. package/docs/sportradar/soccer-extended-season-links.md +53 -0
  59. package/docs/sportradar/soccer-extended-season-missing-players.md +45 -0
  60. package/docs/sportradar/soccer-extended-season-overunder-statistics.md +36 -0
  61. package/docs/sportradar/soccer-extended-season-players.md +34 -0
  62. package/docs/sportradar/soccer-extended-season-schedule.md +50 -0
  63. package/docs/sportradar/soccer-extended-season-standings.md +77 -0
  64. package/docs/sportradar/soccer-extended-season-summaries.md +23 -0
  65. package/docs/sportradar/soccer-extended-season-transfers.md +61 -0
  66. package/docs/sportradar/soccer-extended-season-venues.md +31 -0
  67. package/docs/sportradar/soccer-extended-seasonal-competitor-extended-stati.md +398 -0
  68. package/docs/sportradar/soccer-extended-seasonal-competitor-players.md +48 -0
  69. package/docs/sportradar/soccer-extended-seasonal-competitor-statistics.md +143 -0
  70. package/docs/sportradar/soccer-extended-seasons-disabled.md +44 -0
  71. package/docs/sportradar/soccer-extended-seasons.md +32 -0
  72. package/docs/sportradar/soccer-extended-sport-event-extended-summary.md +712 -0
  73. package/docs/sportradar/soccer-extended-sport-event-extended-timeline.md +126 -0
  74. package/docs/sportradar/soccer-extended-sport-event-fun-facts.md +26 -0
  75. package/docs/sportradar/soccer-extended-sport-event-insights.md +32 -0
  76. package/docs/sportradar/soccer-extended-sport-event-lineups.md +23 -0
  77. package/docs/sportradar/soccer-extended-sport-event-momentum.md +39 -0
  78. package/docs/sportradar/soccer-extended-sport-event-summary.md +23 -0
  79. package/docs/sportradar/soccer-extended-sport-event-timeline.md +71 -0
  80. package/docs/sportradar/soccer-extended-sport-events-created.md +28 -0
  81. package/docs/sportradar/soccer-extended-sport-events-removed.md +27 -0
  82. package/docs/sportradar/soccer-extended-sport-events-updated.md +28 -0
  83. package/docs/sportradar/soccer-ig-api-basics.md +248 -0
  84. package/docs/sportradar/soccer-ig-data-coverage-tiers.md +399 -0
  85. package/docs/sportradar/soccer-ig-fixtures.md +1193 -0
  86. package/docs/sportradar/soccer-ig-historical-data.md +596 -0
  87. package/docs/sportradar/soccer-ig-id-handling.md +991 -0
  88. package/docs/sportradar/soccer-ig-live-match-retrieval.md +1078 -0
  89. package/docs/sportradar/soccer-ig-match-status-workflow.md +777 -0
  90. package/docs/sportradar/soccer-ig-overview.md +30 -0
  91. package/docs/sportradar/soccer-ig-push.md +515 -0
  92. package/docs/sportradar/soccer-ig-rosters-lineups-transfers.md +1400 -0
  93. package/docs/sportradar/soccer-ig-scenarios.md +17 -0
  94. package/docs/sportradar/soccer-ig-seasonal-stats.md +798 -0
  95. package/docs/sportradar/soccer-ig-tracking-standings.md +725 -0
  96. package/docs/sportradar/soccer-ig-tracking-tournaments.md +408 -0
  97. package/docs/sportradar/soccer-ig-update-frequencies.md +1313 -0
  98. package/docs/statsbomb/data-provenance.md +20 -0
  99. package/docs/thesportsdb/data-provenance.md +18 -0
  100. package/docs/transfermarkt/data-provenance.md +23 -0
  101. package/docs/transferroom/data-provenance.md +21 -0
  102. package/docs/wyscout/data-provenance.md +26 -0
  103. package/package.json +3 -8
  104. package/providers.json +24 -7
package/README.md CHANGED
@@ -109,33 +109,33 @@ Provider filters use the indexed provider keys shown by `list_providers`, but co
109
109
  | Provider | Chunks | Categories |
110
110
  |----------|--------|------------|
111
111
  | fast-forward | 250 | overview, getting-started, data-model, coordinate-system, orientations, layouts, transformations, distributed-compute, api-reference, 12 provider format pages |
112
- | 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
+ | StatsBomb | 237 | event-types, data-model, coordinate-system, api-access, api-endpoints, charting-lineups, xg-model, iq-metrics, player/team stats, player-mapping, identity-surfaces, data-provenance |
113
113
  | unravelsports | 202 | overview, installation, quickstart, concepts, graph converters, pressing intensity, formation detection, models, utils, american-football |
114
- | Wyscout | 163 | event-types, data-model, coordinate-system, api-access, api-endpoints, charting-analysis-metrics, glossary, identity-surfaces |
114
+ | Wyscout | 165 | event-types, data-model, coordinate-system, api-access, api-endpoints, charting-analysis-metrics, glossary, identity-surfaces, data-provenance |
115
115
  | kloppy | 126 | data-model, usage, provider-mapping, tracking-rendering, event-derived-metrics |
116
116
  | floodlight | 144 | core data objects, io parsers (Tracab, DFL, Kinexon, Opta, SkillCorner, StatsBomb, StatsPerform, Second Spectrum), transforms, metrics, models, visualisation, guides |
117
- | SportMonks | 565 | full v3 endpoint reference (fixtures, livescores, leagues, seasons, states, types, statistics, brackets), syntax and includes, filtering, rate limits, error codes, changelog, plus curated event-types, data-model, api-access, charting-season-stories, identity-surfaces |
117
+ | SportMonks | 567 | full v3 endpoint reference (fixtures, livescores, leagues, seasons, states, types, statistics, brackets), syntax and includes, filtering, rate limits, error codes, changelog, plus curated event-types, data-model, api-access, charting-season-stories, identity-surfaces, data-provenance |
118
118
  | databallpy | 63 | data-model, overview, usage |
119
119
  | mplsoccer | 65 | overview, pitch-types, visualizations |
120
- | Impect | 77 | overview, data-model, event-types, coordinate-system, concepts, kpi-definitions, identity-surfaces |
121
- | SkillCorner | 49 | api-access, api-endpoints, data-model, physical-data, coordinate-system, concepts, identity-surfaces |
122
- | Free sources | 62 | overview, fbref, understat, contextual-story-joins, xg-timelines |
120
+ | Impect | 79 | overview, data-model, event-types, coordinate-system, concepts, kpi-definitions, identity-surfaces, data-provenance |
121
+ | SkillCorner | 51 | api-access, api-endpoints, data-model, physical-data, coordinate-system, concepts, identity-surfaces, data-provenance |
122
+ | Free sources | 65 | overview, fbref, understat, contextual-story-joins, xg-timelines, data-provenance |
123
123
  | soccerdata | 40 | overview, data-sources, usage |
124
- | TransferRoom | 43 | api-access, api-endpoints, charting-availability, data-model, identity-surfaces |
125
- | Opta | 71 | event-types, qualifiers, coordinate-system, api-access, charting-game-state, charting-lineups, charting-passmaps, charting-set-pieces, charting-shot-placement, identity-surfaces |
126
- | FMDB Pro | 35 | api-access, api-endpoints, data-model, identity-surfaces |
127
- | Sportradar | 30 | api-access, api-endpoints, data-model, charting-and-stories, integration-notes |
124
+ | TransferRoom | 45 | api-access, api-endpoints, charting-availability, data-model, identity-surfaces, data-provenance |
125
+ | Opta | 73 | event-types, qualifiers, coordinate-system, api-access, charting-game-state, charting-lineups, charting-passmaps, charting-set-pieces, charting-shot-placement, identity-surfaces, data-provenance |
126
+ | FMDB Pro | 37 | api-access, api-endpoints, data-model, identity-surfaces, data-provenance |
127
+ | Sportradar | 480 | integration guide (API basics, coverage tiers, ID handling, match status, update frequencies, push, historical data), Soccer Extended v4 endpoint reference with data-point tables, FAQ, plus curated api-access, api-endpoints, data-model, charting-and-stories, integration-notes, data-provenance |
128
128
  | socceraction | 34 | SPADL format, VAEP, Expected Threat |
129
- | BeSoccer | 14 | api-access, api-endpoints |
130
- | Driblab | 30 | api-access, api-endpoints, data-model |
131
- | ESPN | 20 | api-access, scoreboard, match-summary, teams-and-standings, identity-and-coverage |
132
- | Reep | 26 | overview, identity-and-ids, download-duckdb-csv, api |
133
- | TheSportsDB | 18 | api-access, api-endpoints, livescore, identity-surfaces |
134
- | FotMob | 3 | identity-surfaces |
135
- | Soccerdonna | 3 | identity-surfaces |
136
- | Transfermarkt | 3 | identity-surfaces |
129
+ | BeSoccer | 16 | api-access, api-endpoints, data-provenance |
130
+ | Driblab | 32 | api-access, api-endpoints, data-model, data-provenance |
131
+ | ESPN | 21 | api-access, scoreboard, match-summary, teams-and-standings, identity-and-coverage |
132
+ | Reep | 28 | overview, identity-and-ids, download-duckdb-csv, api, data-provenance |
133
+ | TheSportsDB | 20 | api-access, api-endpoints, livescore, identity-surfaces, data-provenance |
134
+ | FotMob | 5 | identity-surfaces, data-provenance |
135
+ | Soccerdonna | 5 | identity-surfaces, data-provenance |
136
+ | Transfermarkt | 5 | identity-surfaces, data-provenance |
137
137
 
138
- **2,371 searchable chunks** across 26 providers and tools.
138
+ **2,855 searchable chunks** across 26 providers and tools.
139
139
 
140
140
  ESPN coverage consists of curated, dated observations of ESPN-hosted soccer
141
141
  endpoints, checked for eng.1 and esp.1. These observations are not an official API
@@ -180,6 +180,18 @@ Reep's snapshots age weekly, as a new release is cut each week. Run
180
180
  `python3 scripts/check_reep_live.py` to check every download link and list what
181
181
  has changed since the snapshots; the refresh steps are in [specs/README.md](specs/README.md#reep).
182
182
 
183
+ `pnpm check:upstream` runs every upstream check in one report: pinned package
184
+ versions against PyPI, npm and GitHub, each spec snapshot against its public URL,
185
+ BeSoccer's and Driblab's truth regenerated from their Postman collection and Notion
186
+ page, and the free-source and Reep live checks below. It runs by hand, never in CI, and
187
+ lists what to review.
188
+
189
+ Free sources have no spec, and they tend to fail quietly: a page still answers
190
+ 200 after the data has gone. Run `python3 scripts/check_free_sources_live.py` to
191
+ request each access path documented in `docs/free-sources/` and check that the
192
+ response still carries the data the doc describes. When a doc's access recipe
193
+ changes, change its check in the same commit.
194
+
183
195
  Truth files live in `data/provider-truth/` and are generated, not hand-written:
184
196
 
185
197
  ```bash
@@ -224,6 +236,8 @@ Contributions are welcome from everyone. There are three ways to help:
224
236
 
225
237
  Provider doc sources are tracked in `providers.json`. The crawl pipeline discovers the best doc source (llms.txt > ReadTheDocs > GitHub README) and writes markdown with provenance frontmatter.
226
238
 
239
+ Two registry fields narrow a crawl. `llms_indexes` lists llms.txt files that link to pages rather than contain them; the crawler follows those links (and nested indexes) to each page's markdown copy instead of running discovery. Sportradar uses it for its integration guide and Soccer Extended reference. `exclude_categories` skips whole pages, and `exclude_sections` drops named `##`/`###` sections from pages that are otherwise kept, for content INCLUSION.md keeps out, such as odds. Pages crawled through an index are not byte-for-byte copies: the crawler drops the OpenAPI definition ReadMe appends and SVG diagrams, cuts example payloads over 3 KB with a note, replaces a data-point table repeated from an earlier page with a line naming that page, and marks a split long section "(continued)". It adds no other text.
240
+
227
241
  ```bash
228
242
  npm run discover # probe sources without crawling
229
243
  npm run crawl # crawl all providers with sources
package/data/docs.db CHANGED
Binary file
package/dist/crawl.d.ts CHANGED
@@ -8,6 +8,14 @@
8
8
  * paraphrase, summarise, or interpret. The content in the output files should
9
9
  * be directly traceable to the source URL.
10
10
  *
11
+ * One exception, for pages reached through an llms.txt index (llms_indexes):
12
+ * the crawler removes markup and bulk, and marks each removal in the text.
13
+ * It drops the OpenAPI definition ReadMe appends and SVG diagrams, cuts long
14
+ * example payloads with a note, replaces a data-point table repeated from an
15
+ * earlier page with a line naming that page, and repeats a heading with
16
+ * "(continued)" where it splits a long section. Every sentence that remains is
17
+ * the source's own.
18
+ *
11
19
  * Usage:
12
20
  * npm run crawl # crawl all providers with sources
13
21
  * npm run crawl -- --provider kloppy # crawl one provider
@@ -37,5 +45,52 @@ export declare function applyCategoryExclusions<T extends {
37
45
  * Already structured for LLM consumption — chunk by top-level heading.
38
46
  */
39
47
  export declare function crawlLlmsTxt(content: string, sourceUrl: string): CrawledDoc[];
48
+ /**
49
+ * Read the links out of an llms.txt index. Page links point at a page's
50
+ * markdown copy (`.md`); index links point at a further `llms.txt`. Links to
51
+ * another host are ignored, so an index cannot send the crawl off-site.
52
+ */
53
+ export declare function parseLlmsIndex(content: string, indexUrl: string): {
54
+ pages: string[];
55
+ indexes: string[];
56
+ };
57
+ /** The category a page is stored under: the last path segment, without `.md`. */
58
+ export declare function llmsPageCategory(pageUrl: string): string;
59
+ /**
60
+ * Turn a ReadMe-hosted page's markdown copy into plain markdown.
61
+ *
62
+ * ReadMe appends the endpoint's full OpenAPI definition to every reference page;
63
+ * the spec is mirrored separately (specs/), so everything from that heading on is
64
+ * dropped. Accordions become `###` headings, because their titles are where one
65
+ * data-point table ends and the next begins. Other MDX components and list markup
66
+ * are unwrapped to their text. Long example payloads are cut to their opening.
67
+ */
68
+ export declare function cleanLlmsPage(text: string): string;
69
+ /**
70
+ * Split any `##`/`###` section longer than `max` at paragraph breaks, repeating
71
+ * its heading with "(continued)" so each piece is still a searchable section.
72
+ */
73
+ export declare function splitOversizedSections(text: string, max?: number): string;
74
+ /**
75
+ * Reference pages repeat the same data-point tables (the competition, the
76
+ * season, the venue) on every endpoint that returns them. Keep the first copy
77
+ * of each `###` section and replace later identical copies with one line per
78
+ * page naming where the table is.
79
+ */
80
+ export declare function dedupeSharedSections<T extends {
81
+ category: string;
82
+ content: string;
83
+ }>(docs: T[]): T[];
84
+ /**
85
+ * Drop each `##`/`###` section whose heading is listed, with any deeper
86
+ * sections nested under it. Headings match case-insensitively.
87
+ */
88
+ export declare function dropSections(text: string, headings: string[] | undefined): string;
89
+ /**
90
+ * Crawl the pages listed by one or more llms.txt indexes, following nested
91
+ * indexes. Excluded categories are skipped before they are fetched, and
92
+ * excluded sections are dropped from the pages that are kept.
93
+ */
94
+ export declare function crawlLlmsIndexes(indexUrls: string[], excluded: string[] | undefined, fetcher?: (url: string) => Promise<string | null>, pauseMs?: number, excludedSections?: string[]): Promise<CrawledDoc[]>;
40
95
  export declare function slugify(text: string): string;
41
96
  export {};
package/dist/crawl.js CHANGED
@@ -8,6 +8,14 @@
8
8
  * paraphrase, summarise, or interpret. The content in the output files should
9
9
  * be directly traceable to the source URL.
10
10
  *
11
+ * One exception, for pages reached through an llms.txt index (llms_indexes):
12
+ * the crawler removes markup and bulk, and marks each removal in the text.
13
+ * It drops the OpenAPI definition ReadMe appends and SVG diagrams, cuts long
14
+ * example payloads with a note, replaces a data-point table repeated from an
15
+ * earlier page with a line naming that page, and repeats a heading with
16
+ * "(continued)" where it splits a long section. Every sentence that remains is
17
+ * the source's own.
18
+ *
11
19
  * Usage:
12
20
  * npm run crawl # crawl all providers with sources
13
21
  * npm run crawl -- --provider kloppy # crawl one provider
@@ -336,6 +344,215 @@ export function crawlLlmsTxt(content, sourceUrl) {
336
344
  }
337
345
  return sections;
338
346
  }
347
+ // ── llms.txt indexes ────────────────────────────────────────────────
348
+ /** Most pages a single llms.txt index crawl will fetch. */
349
+ const LLMS_INDEX_MAX_PAGES = 200;
350
+ /** A code fence longer than this is cut, with a note of how much was dropped. */
351
+ const MAX_FENCE_CHARS = 3000;
352
+ /** A section longer than this is split, so no chunk swamps an agent's context. */
353
+ const MAX_SECTION_CHARS = 30000;
354
+ /** A repeated section shorter than this is left in place; it costs little. */
355
+ const MIN_SHARED_SECTION_CHARS = 300;
356
+ /**
357
+ * Read the links out of an llms.txt index. Page links point at a page's
358
+ * markdown copy (`.md`); index links point at a further `llms.txt`. Links to
359
+ * another host are ignored, so an index cannot send the crawl off-site.
360
+ */
361
+ export function parseLlmsIndex(content, indexUrl) {
362
+ const host = new URL(indexUrl).hostname;
363
+ const pages = [];
364
+ const indexes = [];
365
+ for (const match of content.matchAll(/\]\((https?:\/\/[^)\s]+)\)/g)) {
366
+ let url;
367
+ try {
368
+ url = new URL(match[1]);
369
+ }
370
+ catch {
371
+ continue;
372
+ }
373
+ if (url.hostname !== host)
374
+ continue;
375
+ url.hash = "";
376
+ if (url.pathname.endsWith("/llms.txt"))
377
+ indexes.push(url.href);
378
+ else if (url.pathname.endsWith(".md"))
379
+ pages.push(url.href);
380
+ }
381
+ return { pages: [...new Set(pages)], indexes: [...new Set(indexes)] };
382
+ }
383
+ /** The category a page is stored under: the last path segment, without `.md`. */
384
+ export function llmsPageCategory(pageUrl) {
385
+ const segment = new URL(pageUrl).pathname.split("/").pop() ?? "";
386
+ return slugify(segment.replace(/\.md$/, ""));
387
+ }
388
+ /**
389
+ * Turn a ReadMe-hosted page's markdown copy into plain markdown.
390
+ *
391
+ * ReadMe appends the endpoint's full OpenAPI definition to every reference page;
392
+ * the spec is mirrored separately (specs/), so everything from that heading on is
393
+ * dropped. Accordions become `###` headings, because their titles are where one
394
+ * data-point table ends and the next begins. Other MDX components and list markup
395
+ * are unwrapped to their text. Long example payloads are cut to their opening.
396
+ */
397
+ export function cleanLlmsPage(text) {
398
+ let out = text.replace(/^---\n[\s\S]*?\n---\n/, "");
399
+ out = out.split(/\n# OpenAPI definition\b/)[0];
400
+ out = out.replace(/^Fetch the complete documentation index.*\n/m, "");
401
+ out = out.replace(/<HTMLBlock>\{`([\s\S]*?)`\}<\/HTMLBlock>/g, (_m, html) => html.includes("<svg")
402
+ ? "_(Diagram omitted: see the source page.)_"
403
+ : html.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim());
404
+ out = out.replace(/<Accordion\b[^>]*\btitle="([^"]+)"[^>]*>/g, (_m, title) => `### ${title}`);
405
+ out = out.replace(/<li\b[^>]*>([\s\S]*?)<\/li>/g, (_m, item) => `- ${item.replace(/<[^>]+>/g, "").trim()}`);
406
+ out = out.replace(/<\/?(?:AccordionGroup|Accordion|Callout|Tabs|Tab|Cards|Card|Columns|Column|Anchor|Image|Embed|Recipe|Glossary|div|ul|ol|span)\b[^>]*>/g, "");
407
+ out = out.replace(/\n[ \t]+- /g, "\n- ");
408
+ out = out.replace(/```(\w*)\n[\s\S]*?\n```/g, (fence, lang) => {
409
+ if (fence.length <= MAX_FENCE_CHARS)
410
+ return fence;
411
+ const kept = fence.slice(lang.length + 4, MAX_FENCE_CHARS).trimEnd();
412
+ const kb = Math.round(fence.length / 1024);
413
+ return `\`\`\`${lang}\n${kept}\n... (example cut here; ${kb} KB in the source page)\n\`\`\``;
414
+ });
415
+ return `${out.replace(/\n{3,}/g, "\n\n").trim()}\n`;
416
+ }
417
+ /**
418
+ * Split any `##`/`###` section longer than `max` at paragraph breaks, repeating
419
+ * its heading with "(continued)" so each piece is still a searchable section.
420
+ */
421
+ export function splitOversizedSections(text, max = MAX_SECTION_CHARS) {
422
+ const sections = text.split(/(?=^#{2,3} )/m);
423
+ return sections
424
+ .map((section) => {
425
+ if (section.length <= max)
426
+ return section;
427
+ const heading = section.match(/^(#{2,3}) (.+)\n/);
428
+ const level = heading?.[1] ?? "###";
429
+ const title = heading?.[2] ?? "Section";
430
+ const pieces = [];
431
+ let current = "";
432
+ for (const paragraph of section.split(/\n\n/)) {
433
+ const insideFence = (current.match(/^```/gm)?.length ?? 0) % 2 === 1;
434
+ if (current && !insideFence && current.length + paragraph.length > max) {
435
+ pieces.push(current);
436
+ current = `${level} ${title} (continued)\n\n`;
437
+ }
438
+ current += `${paragraph}\n\n`;
439
+ }
440
+ pieces.push(current);
441
+ return pieces.join("");
442
+ })
443
+ .join("");
444
+ }
445
+ /**
446
+ * Reference pages repeat the same data-point tables (the competition, the
447
+ * season, the venue) on every endpoint that returns them. Keep the first copy
448
+ * of each `###` section and replace later identical copies with one line per
449
+ * page naming where the table is.
450
+ */
451
+ export function dedupeSharedSections(docs) {
452
+ const firstSeen = new Map();
453
+ return docs.map((doc) => {
454
+ const kept = [];
455
+ const shared = [];
456
+ for (const section of doc.content.split(/(?=^#{2,3} )/m)) {
457
+ const heading = section.match(/^### (.+)\n/);
458
+ if (heading) {
459
+ const body = section.slice(heading[0].length).replace(/\s+/g, " ").trim();
460
+ const key = `${heading[1]}\u0000${body}`;
461
+ const owner = firstSeen.get(key);
462
+ if (body.length >= MIN_SHARED_SECTION_CHARS && owner && owner !== doc.category) {
463
+ shared.push(`${heading[1]} (\`${owner}\`)`);
464
+ continue;
465
+ }
466
+ if (!owner)
467
+ firstSeen.set(key, doc.category);
468
+ }
469
+ kept.push(section);
470
+ }
471
+ let content = kept.join("").trimEnd();
472
+ if (shared.length > 0) {
473
+ content += `\n\nAlso returns these data points, documented on the page named in brackets: ${shared.join(", ")}.`;
474
+ }
475
+ return { ...doc, content: `${content}\n` };
476
+ });
477
+ }
478
+ /**
479
+ * Drop each `##`/`###` section whose heading is listed, with any deeper
480
+ * sections nested under it. Headings match case-insensitively.
481
+ */
482
+ export function dropSections(text, headings) {
483
+ if (!headings?.length)
484
+ return text;
485
+ const drop = new Set(headings.map((h) => h.trim().toLowerCase()));
486
+ const kept = [];
487
+ let droppingLevel = 0;
488
+ let fenced = false;
489
+ for (const line of text.split("\n")) {
490
+ if (/^ {0,3}(`{3,}|~{3,})/.test(line))
491
+ fenced = !fenced;
492
+ const heading = fenced ? null : line.match(/^(#{2,3}) (.+?)\s*$/);
493
+ if (heading) {
494
+ const level = heading[1].length;
495
+ if (droppingLevel && level <= droppingLevel)
496
+ droppingLevel = 0;
497
+ if (!droppingLevel && drop.has(heading[2].toLowerCase()))
498
+ droppingLevel = level;
499
+ }
500
+ if (!droppingLevel)
501
+ kept.push(line);
502
+ }
503
+ return kept.join("\n");
504
+ }
505
+ /**
506
+ * Crawl the pages listed by one or more llms.txt indexes, following nested
507
+ * indexes. Excluded categories are skipped before they are fetched, and
508
+ * excluded sections are dropped from the pages that are kept.
509
+ */
510
+ export async function crawlLlmsIndexes(indexUrls, excluded, fetcher = fetchText, pauseMs = 250, excludedSections) {
511
+ const skip = new Set(excluded ?? []);
512
+ const pageUrls = [];
513
+ const queue = [...indexUrls];
514
+ const visited = new Set();
515
+ while (queue.length > 0) {
516
+ const indexUrl = queue.shift();
517
+ if (visited.has(indexUrl))
518
+ continue;
519
+ visited.add(indexUrl);
520
+ const content = await fetcher(indexUrl);
521
+ if (!content)
522
+ continue;
523
+ const { pages, indexes } = parseLlmsIndex(content, indexUrl);
524
+ pageUrls.push(...pages);
525
+ queue.push(...indexes);
526
+ }
527
+ const docs = [];
528
+ const categories = new Set();
529
+ for (const pageUrl of [...new Set(pageUrls)]) {
530
+ if (docs.length >= LLMS_INDEX_MAX_PAGES)
531
+ break;
532
+ const category = llmsPageCategory(pageUrl);
533
+ if (!category || skip.has(category) || categories.has(category))
534
+ continue;
535
+ if (pauseMs > 0)
536
+ await new Promise((done) => setTimeout(done, pauseMs));
537
+ const markdown = await fetcher(pageUrl);
538
+ if (!markdown)
539
+ continue;
540
+ const content = dropSections(cleanLlmsPage(markdown), excludedSections);
541
+ if (content.length < 100)
542
+ continue;
543
+ categories.add(category);
544
+ docs.push({
545
+ category,
546
+ content,
547
+ source_url: pageUrl.replace(/\.md$/, ""),
548
+ source_type: "llms_txt",
549
+ });
550
+ }
551
+ return dedupeSharedSections(docs).map((doc) => ({
552
+ ...doc,
553
+ content: splitOversizedSections(doc.content),
554
+ }));
555
+ }
339
556
  /**
340
557
  * Crawl a documentation website by fetching linked pages from the index.
341
558
  * Works with Sphinx/RTD, MkDocs, GitBook HTML, Docusaurus, and most
@@ -617,6 +834,20 @@ async function main() {
617
834
  for (const [name, config] of Object.entries(targets)) {
618
835
  if (!config)
619
836
  continue;
837
+ if (config.llms_indexes?.length) {
838
+ console.log(`\n${name}: following ${config.llms_indexes.length} llms.txt index(es)`);
839
+ for (const url of config.llms_indexes)
840
+ console.log(` ${url}`);
841
+ if (discoverOnly)
842
+ continue;
843
+ const docs = await crawlLlmsIndexes(config.llms_indexes, config.exclude_categories, fetchText, 250, config.exclude_sections);
844
+ for (const doc of docs) {
845
+ writeCrawledDoc(name, doc, config.version);
846
+ console.log(` wrote ${name}/${doc.category}.md (${doc.content.length} chars) [${doc.source_type}]`);
847
+ }
848
+ console.log(` → ${docs.length} doc(s) written`);
849
+ continue;
850
+ }
620
851
  const sources = config.sources
621
852
  .filter((s) => !!s.url)
622
853
  .map((s) => ({
package/dist/tools.js CHANGED
@@ -181,6 +181,27 @@ function searchRows(db, matchQuery, provider, limit) {
181
181
  params.push(limit);
182
182
  return db.prepare(sql).all(...params);
183
183
  }
184
+ /**
185
+ * The strict query needs every term to match, so it finds the most specific
186
+ * chunks but can find very few. Keep its matches first, then fill the remaining
187
+ * slots from the relaxed query, skipping chunks already listed. Returning only
188
+ * the strict matches let one chunk that happened to contain every term crowd
189
+ * out the rest of the answer.
190
+ */
191
+ function topUpRows(strict, relaxed, limit) {
192
+ const key = (row) => `${row.provider}\u0000${row.category}\u0000${row.title}\u0000${row.content}`;
193
+ const seen = new Set(strict.map(key));
194
+ const rows = [...strict];
195
+ for (const row of relaxed) {
196
+ if (rows.length >= limit)
197
+ break;
198
+ if (seen.has(key(row)))
199
+ continue;
200
+ seen.add(key(row));
201
+ rows.push(row);
202
+ }
203
+ return rows;
204
+ }
184
205
  function compareRows(db, matchQuery, providers) {
185
206
  let sql = `
186
207
  SELECT d.provider, d.category, d.title, d.content,
@@ -327,8 +348,8 @@ export function getProviderDocs(db, args) {
327
348
  const strictQuery = args.topic ? sanitiseFtsQuery(args.topic) : undefined;
328
349
  const fallbackQuery = args.topic ? relaxedFtsQuery(args.topic) : undefined;
329
350
  let rows = providerDocsRows(db, provider, strictQuery, category, limit);
330
- if (rows.length === 0 && fallbackQuery && fallbackQuery !== strictQuery) {
331
- rows = providerDocsRows(db, provider, fallbackQuery, category, limit);
351
+ if (rows.length < limit && fallbackQuery && fallbackQuery !== strictQuery) {
352
+ rows = topUpRows(rows, providerDocsRows(db, provider, fallbackQuery, category, limit), limit);
332
353
  }
333
354
  if (rows.length === 0) {
334
355
  return textResult(`No provider docs found for "${providerFilterLabel(args.provider, provider)}"${category ? ` in category "${category}"` : ""}${args.topic ? ` matching "${args.topic}"` : ""}. Call resolve_provider_id or list_providers to inspect available coverage.`);
@@ -353,8 +374,8 @@ export function searchDocs(db, args) {
353
374
  }
354
375
  }
355
376
  let rows = searchRows(db, strictQuery, provider, limit);
356
- if (rows.length === 0 && fallbackQuery !== strictQuery) {
357
- rows = searchRows(db, fallbackQuery, provider, limit);
377
+ if (rows.length < limit && fallbackQuery !== strictQuery) {
378
+ rows = topUpRows(rows, searchRows(db, fallbackQuery, provider, limit), limit);
358
379
  }
359
380
  if (rows.length === 0) {
360
381
  const providerLabel = providerFilterLabel(args.provider, provider);
@@ -403,9 +424,9 @@ export function compareProviders(db, args) {
403
424
  if (!providerSet.has(provider))
404
425
  return [];
405
426
  const strictRows = compareRowsForProvider(db, strictQuery, provider, 3);
406
- if (strictRows.length > 0 || fallbackQuery === strictQuery)
427
+ if (strictRows.length >= 3 || fallbackQuery === strictQuery)
407
428
  return strictRows;
408
- return compareRowsForProvider(db, fallbackQuery, provider, 3);
429
+ return topUpRows(strictRows, compareRowsForProvider(db, fallbackQuery, provider, 3), 3);
409
430
  });
410
431
  }
411
432
  else {
@@ -0,0 +1,20 @@
1
+ ---
2
+ source_type: curated
3
+ source_url: https://api.besoccer.com/en/aboutus
4
+ upstream_version: null
5
+ crawled_at: 2026-09-24
6
+ ---
7
+
8
+ # BeSoccer data provenance
9
+
10
+ ## BeSoccer data sources
11
+
12
+ **Category:** not publicly documented.
13
+
14
+ BeSoccer's public pages describe the size of its database (competitions, teams
15
+ and matches) but do not say how the data is collected, whether by its own
16
+ staff, under licence or from contributors.
17
+
18
+ Pages checked on 2026-09-24: [besoccer.com](https://www.besoccer.com/),
19
+ [API about page](https://api.besoccer.com/en/aboutus),
20
+ [company page](https://company.besoccer.com/en/besoccer).
@@ -0,0 +1,21 @@
1
+ ---
2
+ source_type: curated
3
+ source_url: https://www.driblab.com/tracking
4
+ upstream_version: null
5
+ crawled_at: 2026-09-24
6
+ ---
7
+
8
+ # Driblab data provenance
9
+
10
+ ## Driblab data sources
11
+
12
+ **Category:** first-party (tracking); not publicly documented (other data).
13
+
14
+ Driblab's tracking data comes from its own optical tracking system, which uses
15
+ computer vision on match video. The page does not say which video it uses.
16
+ Driblab does not publicly document where its other statistics come from.
17
+
18
+ Source: [Driblab tracking](https://www.driblab.com/tracking): "Our AI football
19
+ optical tracking system follows the position of the 22 players and the ball
20
+ every tenth of a second" and "Through computer vision techniques, the system
21
+ detects and extracts key game features automatically." Checked 2026-09-24.
@@ -62,3 +62,11 @@ not exist.
62
62
 
63
63
  Stop on access denial rather than trying to bypass it. An application that needs
64
64
  guaranteed availability needs a licensed data supplier.
65
+
66
+ ## ESPN data sources
67
+
68
+ **Category:** not publicly documented.
69
+
70
+ ESPN does not document where the data behind its public soccer endpoints comes
71
+ from. Some ESPN editorial articles credit individual statistics to Opta, but
72
+ that does not establish the source of the endpoint data. Checked 2026-09-24.
@@ -0,0 +1,22 @@
1
+ ---
2
+ source_type: curated
3
+ source_url: https://www.hudl.com/blog/hudl-sports-interactive-partnership-fmdb-pro
4
+ upstream_version: null
5
+ crawled_at: 2026-09-24
6
+ ---
7
+
8
+ # FMDB Pro data provenance
9
+
10
+ ## FMDB Pro data sources
11
+
12
+ **Category:** first-party and licensed.
13
+
14
+ FMDB Pro is built on Sports Interactive's network of trained evaluators, the
15
+ research network behind Football Manager. Event data and physical metrics are
16
+ licensed from Hudl, which is Sports Interactive's exclusive provider for them.
17
+
18
+ Source: [Hudl and Sports Interactive partnership](https://www.hudl.com/blog/hudl-sports-interactive-partnership-fmdb-pro):
19
+ "Powered by a network of 1,600+ trained evaluators, it translates human-led
20
+ evaluation into comparable, actionable insight." and "Hudl becomes SI's
21
+ exclusive provider for event data and physical metrics for their new
22
+ professional football intelligence platform, FMDB Pro." Checked 2026-09-24.
@@ -0,0 +1,20 @@
1
+ ---
2
+ source_type: curated
3
+ source_url: https://www.fotmob.com/en/topnews/22634-statement-physical-metrics-feature-outage
4
+ upstream_version: null
5
+ crawled_at: 2026-09-24
6
+ ---
7
+
8
+ # FotMob data provenance
9
+
10
+ ## FotMob data sources
11
+
12
+ **Category:** licensed (physical metrics); not publicly documented (other data).
13
+
14
+ FotMob says it buys official data for its physical metrics feature, and that an
15
+ outage in that data affected all score providers. It does not name the supplier,
16
+ or say where its scores, events and other statistics come from.
17
+
18
+ Source: [FotMob statement on physical metrics](https://www.fotmob.com/en/topnews/22634-statement-physical-metrics-feature-outage):
19
+ "after purchasing the official data and spending the summer building this
20
+ feature" and "This affects all score providers, not just FotMob." Checked 2026-09-24.
@@ -31,6 +31,10 @@ away_elo = ClubElo(away_team, fixture_date)
31
31
  elo_diff = home_elo - away_elo
32
32
  ```
33
33
 
34
+ The ClubElo CSV API moved behind authentication in September 2026, so a
35
+ lookup by date now needs API access, or ratings taken from the club pages (about
36
+ four years of history). See the ClubElo section of `overview.md`.
37
+
34
38
  ClubElo names are not guaranteed to match provider team labels. Keep the alias
35
39
  map in project code, and treat promoted, renamed, and abbreviated clubs as normal
36
40
  data-quality cases.
@@ -0,0 +1,83 @@
1
+ ---
2
+ source_type: curated
3
+ source_url: null
4
+ upstream_version: null
5
+ crawled_at: 2026-09-24
6
+ ---
7
+
8
+ # Free sources data provenance
9
+
10
+ Each free source has its own origin. Check it before you build on the data.
11
+
12
+ ## StatsBomb Open Data data sources
13
+
14
+ **Category:** first-party.
15
+
16
+ StatsBomb Open Data is a subset of StatsBomb's own collected event data,
17
+ exported from the StatsBomb Data API. Credit StatsBomb as the source when you
18
+ publish work based on it.
19
+
20
+ Source: [hudl/open-data README](https://github.com/hudl/open-data): the data are
21
+ "JSON files exported from the StatsBomb Data API". Checked 2026-09-24.
22
+
23
+ ## FBref data sources
24
+
25
+ **Category:** licensed (until January 2026).
26
+
27
+ FBref's advanced statistics came from a licensed feed (Opta, from Stats
28
+ Perform), which ended in January 2026. See `fbref.md`. FBref does not publicly
29
+ document the source of the basic results and statistics it still shows.
30
+
31
+ ## Understat data sources
32
+
33
+ **Category:** derived (xG model); not publicly documented (shot data).
34
+
35
+ Understat's xG values come from its own neural-network model, trained on more
36
+ than 100,000 shots. Understat does not say where the underlying match and shot
37
+ data comes from.
38
+
39
+ Source: [Understat](https://understat.com/): "we trained neural network
40
+ prediction algorithms with the large dataset (>100,000 shots, over 10 parameters
41
+ for each)". Checked 2026-09-24.
42
+
43
+ ## ClubElo data sources
44
+
45
+ **Category:** derived.
46
+
47
+ ClubElo computes its own Elo ratings from match results. Its pages show each
48
+ rating change per match. The site does not currently publish a methodology page
49
+ or name its source of results.
50
+
51
+ Source: [ClubElo](https://clubelo.com/). Checked 2026-09-24.
52
+
53
+ ## football-data.co.uk data sources
54
+
55
+ **Category:** aggregated.
56
+
57
+ football-data.co.uk compiles its files from named public sources: XScores for
58
+ results, and the BBC, Flashscore, ESPN Soccer, Bundesliga.de, Gazzetta.it and
59
+ Football.fr for match statistics.
60
+
61
+ Source: [football-data.co.uk notes](https://football-data.co.uk/notes.txt).
62
+ Checked 2026-09-24.
63
+
64
+ ## engsoccerdata data sources
65
+
66
+ **Category:** aggregated.
67
+
68
+ engsoccerdata is compiled by James Curley from sources listed in its README,
69
+ including footballcsv, Wikipedia, RSSSF, 11v11, worldfootball.net and
70
+ football-data.co.uk.
71
+
72
+ Source: [jalapic/engsoccerdata README](https://github.com/jalapic/engsoccerdata)
73
+ ("List of Sources", "Compiled by James Curley"). Checked 2026-09-24.
74
+
75
+ ## European Football Statistics data sources
76
+
77
+ **Category:** aggregated; sources not publicly documented.
78
+
79
+ The site collects European football statistics "which are not easily found on
80
+ internet", but does not name its sources.
81
+
82
+ Source: [european-football-statistics.co.uk](https://www.european-football-statistics.co.uk/).
83
+ Checked 2026-09-24.