@kinloom/cli 0.1.0 → 0.2.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.
Files changed (102) hide show
  1. package/dist/assets/cached-ocr.py +556 -0
  2. package/dist/assets/ocr.md +52 -0
  3. package/dist/assets/prep-scan.md +59 -0
  4. package/dist/assets/prep-scan.py +891 -0
  5. package/dist/bundled-skills/acpl-persi/SKILL.md +94 -0
  6. package/dist/bundled-skills/acpl-persi/scripts/persi +268 -0
  7. package/dist/bundled-skills/archive-org/SKILL.md +129 -0
  8. package/dist/bundled-skills/archive-org/scripts/archive-org +879 -0
  9. package/dist/bundled-skills/blm-glo/SKILL.md +54 -0
  10. package/dist/bundled-skills/california-archives/SKILL.md +120 -0
  11. package/dist/bundled-skills/california-archives/scripts/ca-archives +373 -0
  12. package/dist/bundled-skills/chronicling-america/SKILL.md +100 -0
  13. package/dist/bundled-skills/chronicling-america/scripts/chronam +250 -0
  14. package/dist/bundled-skills/cyndis-list/SKILL.md +53 -0
  15. package/dist/bundled-skills/findagrave/SKILL.md +116 -0
  16. package/dist/bundled-skills/findagrave/scripts/findagrave +520 -0
  17. package/dist/bundled-skills/hathitrust/SKILL.md +110 -0
  18. package/dist/bundled-skills/hathitrust/scripts/hathi +194 -0
  19. package/dist/bundled-skills/kentucky-archives/SKILL.md +123 -0
  20. package/dist/bundled-skills/kentucky-archives/scripts/ky-archives +358 -0
  21. package/dist/bundled-skills/library-of-michigan/SKILL.md +111 -0
  22. package/dist/bundled-skills/library-of-michigan/scripts/michiganology +346 -0
  23. package/dist/bundled-skills/missouri-archives/SKILL.md +100 -0
  24. package/dist/bundled-skills/missouri-archives/scripts/mo-archives +528 -0
  25. package/dist/bundled-skills/nara-catalog-search/SKILL.md +118 -0
  26. package/dist/bundled-skills/nara-catalog-search/scripts/nara +934 -0
  27. package/dist/bundled-skills/narrative-audio/SKILL.md +103 -0
  28. package/dist/bundled-skills/narrative-audio/references/script-rules.md +109 -0
  29. package/dist/bundled-skills/narrative-audio/scripts/narrative-audio +290 -0
  30. package/dist/bundled-skills/new-jersey-archives/SKILL.md +118 -0
  31. package/dist/bundled-skills/new-jersey-archives/scripts/nj-archives +585 -0
  32. package/dist/bundled-skills/openarchieven/SKILL.md +90 -0
  33. package/dist/bundled-skills/openarchieven/scripts/openarchieven +432 -0
  34. package/dist/bundled-skills/texas-archives/SKILL.md +93 -0
  35. package/dist/bundled-skills/texas-archives/scripts/texas-archives +441 -0
  36. package/dist/bundled-skills/uk-archives/SKILL.md +101 -0
  37. package/dist/bundled-skills/uk-archives/scripts/uk-archives +391 -0
  38. package/dist/bundled-skills/usgs-gnis/SKILL.md +89 -0
  39. package/dist/bundled-skills/usgs-gnis/scripts/gnis +254 -0
  40. package/dist/bundled-skills/virginia-archives/SKILL.md +104 -0
  41. package/dist/bundled-skills/virginia-archives/scripts/va-archives +466 -0
  42. package/dist/bundled-skills/wikitree/SKILL.md +148 -0
  43. package/dist/bundled-skills/wikitree/scripts/wikitree +219 -0
  44. package/dist/cli.d.ts +1 -1
  45. package/dist/cli.d.ts.map +1 -1
  46. package/dist/cli.js +383 -26
  47. package/dist/cli.js.map +1 -1
  48. package/dist/client.js +1 -1
  49. package/dist/commands/init.js +3 -3
  50. package/dist/commands/ops/audit.d.ts +138 -0
  51. package/dist/commands/ops/audit.d.ts.map +1 -0
  52. package/dist/commands/ops/audit.js +867 -0
  53. package/dist/commands/ops/audit.js.map +1 -0
  54. package/dist/commands/ops/context.d.ts +100 -0
  55. package/dist/commands/ops/context.d.ts.map +1 -0
  56. package/dist/commands/ops/context.js +917 -0
  57. package/dist/commands/ops/context.js.map +1 -0
  58. package/dist/commands/ops/help.d.ts +6 -0
  59. package/dist/commands/ops/help.d.ts.map +1 -0
  60. package/dist/commands/ops/help.js +74 -0
  61. package/dist/commands/ops/help.js.map +1 -0
  62. package/dist/commands/ops/index.d.ts +6 -0
  63. package/dist/commands/ops/index.d.ts.map +1 -0
  64. package/dist/commands/ops/index.js +6 -0
  65. package/dist/commands/ops/index.js.map +1 -0
  66. package/dist/commands/ops/integrate.d.ts +56 -0
  67. package/dist/commands/ops/integrate.d.ts.map +1 -0
  68. package/dist/commands/ops/integrate.js +872 -0
  69. package/dist/commands/ops/integrate.js.map +1 -0
  70. package/dist/commands/ops/sync.d.ts +177 -0
  71. package/dist/commands/ops/sync.d.ts.map +1 -0
  72. package/dist/commands/ops/sync.js +1078 -0
  73. package/dist/commands/ops/sync.js.map +1 -0
  74. package/dist/commands/ops/telemetry.d.ts +79 -0
  75. package/dist/commands/ops/telemetry.d.ts.map +1 -0
  76. package/dist/commands/ops/telemetry.js +249 -0
  77. package/dist/commands/ops/telemetry.js.map +1 -0
  78. package/dist/commands/records/help.d.ts +18 -0
  79. package/dist/commands/records/help.d.ts.map +1 -0
  80. package/dist/commands/records/help.js +174 -0
  81. package/dist/commands/records/help.js.map +1 -0
  82. package/dist/commands/records/index.d.ts +5 -0
  83. package/dist/commands/records/index.d.ts.map +1 -0
  84. package/dist/commands/records/index.js +5 -0
  85. package/dist/commands/records/index.js.map +1 -0
  86. package/dist/commands/records/registry.d.ts +32 -0
  87. package/dist/commands/records/registry.d.ts.map +1 -0
  88. package/dist/commands/records/registry.js +227 -0
  89. package/dist/commands/records/registry.js.map +1 -0
  90. package/dist/commands/records/resolve.d.ts +14 -0
  91. package/dist/commands/records/resolve.d.ts.map +1 -0
  92. package/dist/commands/records/resolve.js +61 -0
  93. package/dist/commands/records/resolve.js.map +1 -0
  94. package/dist/commands/records/runner.d.ts +25 -0
  95. package/dist/commands/records/runner.d.ts.map +1 -0
  96. package/dist/commands/records/runner.js +224 -0
  97. package/dist/commands/records/runner.js.map +1 -0
  98. package/dist/index.d.ts +2 -0
  99. package/dist/index.d.ts.map +1 -1
  100. package/dist/index.js +2 -0
  101. package/dist/index.js.map +1 -1
  102. package/package.json +3 -3
@@ -0,0 +1,100 @@
1
+ ---
2
+ name: chronicling-america
3
+ description: Search, inspect, and download historic American newspaper pages from the Library of Congress Chronicling America collection via the bundled uv-based `chronam` CLI or the loc.gov JSON API. Covers CLI usage, query parameters, date and state filters, pagination, and worked examples. Use when hunting estate notices, land sales, court dockets, obituaries, or family visits in local weeklies, or verifying newspaper evidence for genealogy.
4
+ ---
5
+
6
+ # Chronicling America
7
+
8
+ This skill includes a standalone executable Python CLI at `skills/chronicling-america/scripts/chronam` using a PEP 723 `#!/usr/bin/env -S uv run --script` shebang with inline dependencies (`click`, `httpx`). No virtualenv setup or API key is required.
9
+
10
+ - **Coverage:** millions of digitized U.S. newspaper pages, 1736 through 1963 (per the collection record; the site describes it as "through 1963").
11
+ - **Access:** the public loc.gov JSON API. No key, no account, no sign-in.
12
+ - **Rate limits:** be gentle. LoC asks users to stay within limits; search queries returning more than 100,000 results are too big for the API, so narrow with dates and other filters first. Loc.gov is also slow from some networks; allow up to 90 seconds per request.
13
+
14
+ ## Bundled CLI (`scripts/chronam`)
15
+
16
+ Path: `skills/chronicling-america/scripts/chronam`
17
+
18
+ ### Search newspaper pages
19
+
20
+ ```bash
21
+ # Full-text search for a surname, page level, 10 results
22
+ skills/chronicling-america/scripts/chronam search Lincoln
23
+
24
+ # Surname search narrowed to 1860-1865
25
+ skills/chronicling-america/scripts/chronam search Lincoln --dates 1860/1865
26
+
27
+ # Illinois papers only (server-side state facet), JSON output
28
+ skills/chronicling-america/scripts/chronam search Lincoln --dates 1860/1865 --state Illinois --json
29
+
30
+ # One newspaper title only, by LCCN (Evening Star, Washington, D.C.)
31
+ skills/chronicling-america/scripts/chronam search "Clara Barton" --lccn sn83045462
32
+
33
+ # Second page of results, 25 per page
34
+ skills/chronicling-america/scripts/chronam search "Frederick Douglass" --dates 1870/1895 --limit 25 --page 2
35
+ ```
36
+
37
+ ### Inspect one page
38
+
39
+ ```bash
40
+ # By loc.gov resource URL (copy it from a search result)
41
+ skills/chronicling-america/scripts/chronam get "https://www.loc.gov/resource/<lccn>/<YYYY-MM-DD>/ed-1/?sp=<seq>"
42
+
43
+ # Or build the URL from LCCN + date + page sequence
44
+ skills/chronicling-america/scripts/chronam get --lccn sn83045462 --date 1865-04-15 --seq 1 --json
45
+ ```
46
+
47
+ `get` prints the paper title, date, place, and the download links: `pdf` (full page), `image` (IIIF rendition as served, reduced size), `fulltext_file` (ALTO XML word-coordinates file carrying the OCR text), and `iiif_manifest_url`.
48
+
49
+ ### Download a page
50
+
51
+ ```bash
52
+ # PDF + metadata JSON into ./downloads/chronam
53
+ skills/chronicling-america/scripts/chronam download --lccn sn83045462 --date 1865-04-15 --seq 1 --out ./downloads/chronam
54
+
55
+ # Also fetch the OCR (ALTO XML) and the image rendition
56
+ skills/chronicling-america/scripts/chronam download --lccn sn83045462 --date 1865-04-15 --seq 1 --out ./downloads/chronam --text --image
57
+ ```
58
+
59
+ Files are named `<lccn>_<date>_sp<seq>.pdf` (etc.) with a matching `<stem>.metadata.json`.
60
+
61
+ ### Build a website search URL
62
+
63
+ ```bash
64
+ skills/chronicling-america/scripts/chronam url "Susan B. Anthony" --dates 1870/1900
65
+ ```
66
+
67
+ ## Website search & API rules (verified live 2026-11-24)
68
+
69
+ - Collection site: `https://www.loc.gov/collections/chronicling-america/`
70
+ - JSON API base: `GET https://www.loc.gov/collections/chronicling-america/?{params}&fo=json`
71
+ - **Use `q=` for the search words.** `q` runs a full-text search over page OCR and populates `search.query` in the JSON response.
72
+ - **Do NOT use `qs=` on the JSON API.** The Library's own data-exploration README documents `qs=` (with `ops=`, `searchType=advanced`), but verified live 2026-11-24 it is ignored by the JSON endpoint: even the README's verbatim example URL (`qs=cat`, California, Oct-Dec 1924) returned the whole collection (23,852,658 hits, first result an unrelated 1913 Atlanta paper). `qs`/`ops` belong to the website's advanced-search form, not to the JSON API. Use the website for phrase/proximity searching, or test `ops` against `q` before relying on it.
73
+ - **Date filter `dates=YYYY/YYYY` works** to narrow large full-text result sets.
74
+ - **Display level `dl=`:** `page` (default for full-text page results), `issue`, `title`, `all`. Pass `dl=page` for OCR searching.
75
+ - **Pagination:** `c=` results per page, `sp=` page number (1-based). `sp` is also the page sequence inside an issue URL (`?sp=1` = 1st page of the issue).
76
+ - **Item JSON:** append `fo=json` to a resource URL, e.g. `https://www.loc.gov/resource/<lccn>/<YYYY-MM-DD>/ed-1/?sp=<seq>&fo=json`. The `resources[]` array holds `pdf`, `image`, `fulltext_file`, and `iiif_manifest_url` (`tile.loc.gov` hosts). Note: the storage-services `pdf` URL returns 403 without a `Referer: https://www.loc.gov/` header (verified 2026-11-24); the CLI sends one on downloads. The `image` and `fulltext_file` URLs fetch without it.
77
+ - **State / LCCN filters (verified live 2026-11-25):** server-side facets `fa=location_state:<lowercase-state>` (for example `fa=location_state:illinois`) and `fa=number_lccn:<lccn>` work on the `fo=json` endpoint; bare `location_state=<state>` is ignored. The CLI sends `fa=` filters server-side so common surnames are not hidden behind nationwide hits. Note two LoC quirks: `loc.gov` occasionally drops a connection or returns a transient 0-hit response under load (the CLI retries once on dropped connections and warns when `hits > 0` with empty `results`), and a handful of digitized titles carry an incorrect `location_state` in LoC's metadata even when `location_county` is right, so verify by `--lccn` when targeting a known local paper.
78
+ - **Multi-word queries:** `q` with several words was not verified for AND vs OR behavior; treat multi-word `q` as a broad match and verify the hit count before bulk work. For exact-phrase searching use the website's advanced search.
79
+
80
+ ### Example URL patterns
81
+
82
+ - Surname search, page level: `https://www.loc.gov/collections/chronicling-america/?dl=page&fo=json&q=Lincoln&c=3`
83
+ - Date-bounded search: `https://www.loc.gov/collections/chronicling-america/?dl=page&fo=json&q=Lincoln&c=1&dates=1860/1865`
84
+ - One page as JSON: `https://www.loc.gov/resource/<lccn>/<YYYY-MM-DD>/ed-1/?sp=<seq>&fo=json`
85
+
86
+ ## What is dead (verified 2026-11-24)
87
+
88
+ - The old Chronicling America API at `chroniclingamerica.loc.gov/search/pages/results/?...&format=json` returns **404**. Third-party API directories (publicapi.dev, publicapis.io) still document it, including claims that an API key is required. Both claims are wrong now: the endpoint is gone, and the loc.gov API never needs a key.
89
+ - `chroniclingamerica.loc.gov/about/api/` returns 403.
90
+ - The loc.gov HTML pages return 403 to plain scripted requests; use the `fo=json` endpoints for machine access.
91
+
92
+ ## Environment variables
93
+
94
+ - None. No key or account is needed.
95
+
96
+ ## Research workflow notes
97
+
98
+ - OCR is imperfect: try spelling variants and initials (for example `"S. L. Clemens"` and `"Samuel Clemens"`) as separate searches.
99
+ - Estate notices, land sales, and court dockets cluster in county-seat weeklies. Once a promising title is found, note its LCCN and re-run with `--lccn` plus a tight `--dates` window.
100
+ - A page hit is not a citation yet: open the PDF, confirm the name in context, and record the paper title, date, page (`sp=`), and LCCN alongside the quote.
@@ -0,0 +1,250 @@
1
+ #!/usr/bin/env -S uv run --script
2
+ # /// script
3
+ # requires-python = ">=3.11"
4
+ # dependencies = [
5
+ # "click>=8.1",
6
+ # "httpx>=0.27",
7
+ # ]
8
+ # ///
9
+ """Search Library of Congress Chronicling America historic newspapers.
10
+
11
+ Uses the public loc.gov JSON API (no key, no account). The retired
12
+ chroniclingamerica.loc.gov search API returns 404 as of 2026-11-24;
13
+ do not use it or third-party docs that describe it.
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ import json
19
+ import re
20
+ import sys
21
+ import time
22
+ from pathlib import Path
23
+ from urllib.parse import parse_qs, urlencode, urlparse, urlunparse
24
+
25
+ import click
26
+ import httpx
27
+
28
+ COLLECTION_BASE = "https://www.loc.gov/collections/chronicling-america/"
29
+ HEADERS = {"User-Agent": "kinloom/1.0 (genealogy research)"}
30
+ # tile.loc.gov (storage-services PDFs) rejects hotlinking: it requires a
31
+ # loc.gov Referer. Send one for all file downloads; harmless elsewhere.
32
+ DOWNLOAD_HEADERS = dict(HEADERS, Referer="https://www.loc.gov/")
33
+ TIMEOUT = 25.0
34
+
35
+
36
+ def _get_json(url: str, params: dict | list[tuple[str, str]] | None = None) -> dict:
37
+ last_exc: Exception | None = None
38
+ for attempt in range(2):
39
+ try:
40
+ with httpx.Client(headers=HEADERS, timeout=TIMEOUT, follow_redirects=True) as client:
41
+ resp = client.get(url, params=params)
42
+ resp.raise_for_status()
43
+ return resp.json()
44
+ except (httpx.RemoteProtocolError, httpx.ReadTimeout) as exc:
45
+ last_exc = exc
46
+ if attempt == 0:
47
+ time.sleep(1.5)
48
+ continue
49
+ raise click.ClickException(f"loc.gov request failed after retry: {exc}") from exc
50
+ raise click.ClickException(f"loc.gov request failed: {last_exc}")
51
+
52
+
53
+ def _as_jsonable(value):
54
+ return value
55
+
56
+
57
+ def _first(value):
58
+ if isinstance(value, list):
59
+ return value[0] if value else None
60
+ return value
61
+
62
+
63
+ def _compact_result(item: dict) -> dict:
64
+ return {
65
+ "title": _first(item.get("partof_title")) or item.get("title"),
66
+ "date": item.get("date"),
67
+ "state": _first(item.get("location_state")),
68
+ "county": _first(item.get("location_county")),
69
+ "city": _first(item.get("location_city")),
70
+ "lccn": item.get("number_lccn"),
71
+ "page": item.get("number_page"),
72
+ "url": item.get("url"),
73
+ "id": item.get("id"),
74
+ }
75
+
76
+
77
+ def _print_search(data: dict, as_json: bool) -> None:
78
+ search = data.get("search") or {}
79
+ hits = search.get("hits")
80
+ results = data.get("results") or []
81
+ if as_json:
82
+ click.echo(json.dumps(
83
+ {"hits": hits, "results": [_compact_result(r) for r in results]},
84
+ indent=2, ensure_ascii=False))
85
+ return
86
+ click.echo(f"hits: {hits} (showing {len(results)} on this page)")
87
+ for item in results:
88
+ c = _compact_result(item)
89
+ click.echo(f"- {c['date']} | {c['title']} | {c['state']} | {c['url']}")
90
+
91
+
92
+ def _resource_json(resource_url: str) -> dict:
93
+ parsed = urlparse(resource_url)
94
+ qs = parse_qs(parsed.query)
95
+ qs["fo"] = ["json"]
96
+ url = urlunparse(parsed._replace(query=urlencode(qs, doseq=True)))
97
+ return _get_json(url)
98
+
99
+
100
+ def _build_resource_url(lccn: str, date: str, edition: str, seq: str) -> str:
101
+ return f"https://www.loc.gov/resource/{lccn}/{date}/ed-{edition}/?sp={seq}"
102
+
103
+
104
+ @click.group()
105
+ def cli() -> None:
106
+ """Search Chronicling America historic newspapers (Library of Congress)."""
107
+
108
+
109
+ @cli.command()
110
+ @click.argument("query")
111
+ @click.option("--dates", default=None, help="Date range YYYY/YYYY, e.g. 1880/1920.")
112
+ @click.option("--level", default="page", type=click.Choice(["page", "issue", "title", "all"]),
113
+ show_default=True, help="Display level (dl=).")
114
+ @click.option("--limit", "-n", default=10, show_default=True, help="Results per page (c=).")
115
+ @click.option("--page", "-p", default=1, show_default=True, help="Results page (sp=).")
116
+ @click.option("--state", default=None, help="Filter by state server-side via fa=location_state:<state>.")
117
+ @click.option("--lccn", default=None, help="Filter by newspaper LCCN server-side via fa=number_lccn:<lccn>.")
118
+ @click.option("--json", "as_json", is_flag=True, help="Emit JSON instead of compact text.")
119
+ def search(query, dates, level, limit, page, state, lccn, as_json):
120
+ """Search newspaper pages for QUERY (full-text, e.g. a surname)."""
121
+ params: list[tuple[str, str]] = [
122
+ ("q", query),
123
+ ("fo", "json"),
124
+ ("c", str(limit)),
125
+ ("sp", str(page)),
126
+ ]
127
+ if level != "all":
128
+ params.append(("dl", level))
129
+ if dates:
130
+ params.append(("dates", dates))
131
+ if state:
132
+ params.append(("fa", f"location_state:{state.strip().lower()}"))
133
+ if lccn:
134
+ params.append(("fa", f"number_lccn:{lccn.strip()}"))
135
+ data = _get_json(COLLECTION_BASE, params=params)
136
+ results = data.get("results") or []
137
+ hits = (data.get("search") or {}).get("hits")
138
+ if hits and not results:
139
+ click.echo(
140
+ f"Warning: loc.gov reported {hits} total hits but returned 0 rows on page {page}. "
141
+ "Check --page or retry once if loc.gov dropped facet results.",
142
+ err=True,
143
+ )
144
+ data["results"] = results
145
+ _print_search(data, as_json)
146
+
147
+
148
+ @cli.command()
149
+ @click.argument("resource_url", required=False)
150
+ @click.option("--lccn", default=None, help="Newspaper LCCN, e.g. sn83045462.")
151
+ @click.option("--date", default=None, help="Issue date YYYY-MM-DD.")
152
+ @click.option("--edition", default="1", show_default=True)
153
+ @click.option("--seq", default="1", show_default=True, help="Page sequence within the issue (?sp=).")
154
+ @click.option("--json", "as_json", is_flag=True, help="Emit the raw item JSON.")
155
+ def get(resource_url, lccn, date, edition, seq, as_json):
156
+ """Show metadata and download links for one newspaper page.
157
+
158
+ Give a loc.gov resource URL, or build one with --lccn --date [--edition --seq].
159
+ """
160
+ if resource_url is None:
161
+ if not lccn or not date:
162
+ raise click.UsageError("Give a resource URL or both --lccn and --date.")
163
+ resource_url = _build_resource_url(lccn, date, edition, seq)
164
+ data = _resource_json(resource_url)
165
+ if as_json:
166
+ click.echo(json.dumps(data, indent=2, ensure_ascii=False))
167
+ return
168
+ item = data.get("item") or {}
169
+ resource = data.get("resource") or {}
170
+ click.echo(f"title: {resource.get('title') or item.get('title')}")
171
+ click.echo(f"date: {item.get('date')}")
172
+ click.echo(f"lccn: {_first(item.get('number_lccn')) or item.get('lccn')}")
173
+ click.echo(f"place: {_first(item.get('location_city'))}, {_first(item.get('location_state'))}")
174
+ click.echo(f"url: {resource_url}")
175
+ for res in data.get("resources") or []:
176
+ for key in ("pdf", "image", "fulltext_file", "iiif_manifest_url"):
177
+ if res.get(key):
178
+ click.echo(f"{key}: {res[key]}")
179
+
180
+
181
+ @cli.command()
182
+ @click.argument("resource_url", required=False)
183
+ @click.option("--lccn", default=None)
184
+ @click.option("--date", default=None, help="Issue date YYYY-MM-DD.")
185
+ @click.option("--edition", default="1", show_default=True)
186
+ @click.option("--seq", default="1", show_default=True)
187
+ @click.option("--out", "-o", default=".", show_default=True, help="Output directory.")
188
+ @click.option("--pdf/--no-pdf", default=True, show_default=True, help="Download the page PDF.")
189
+ @click.option("--image/--no-image", default=False, show_default=True,
190
+ help="Download the IIIF image URL as served (reduced-size rendition).")
191
+ @click.option("--text/--no-text", default=False, show_default=True,
192
+ help="Download the ALTO XML word-coordinates file (OCR full text).")
193
+ def download(resource_url, lccn, date, edition, seq, out, pdf, image, text):
194
+ """Download a newspaper page (PDF, image, OCR) plus metadata.json."""
195
+ if resource_url is None:
196
+ if not lccn or not date:
197
+ raise click.UsageError("Give a resource URL or both --lccn and --date.")
198
+ resource_url = _build_resource_url(lccn, date, edition, seq)
199
+ data = _resource_json(resource_url)
200
+ item = data.get("item") or {}
201
+ outdir = Path(out)
202
+ outdir.mkdir(parents=True, exist_ok=True)
203
+ stem = re.sub(r"[^A-Za-z0-9._-]+", "_",
204
+ f"{_first(item.get('number_lccn')) or 'loc'}_{item.get('date') or 'nodate'}_sp{seq}")
205
+ resources = (data.get("resources") or [{}])[0]
206
+ jobs = []
207
+ if pdf and resources.get("pdf"):
208
+ jobs.append(("pdf", resources["pdf"], f"{stem}.pdf"))
209
+ if image and resources.get("image"):
210
+ jobs.append(("image", resources["image"], f"{stem}.jpg"))
211
+ if text and resources.get("fulltext_file"):
212
+ jobs.append(("text", resources["fulltext_file"], f"{stem}.alto.xml"))
213
+ if not jobs:
214
+ click.echo("No downloadable resources found for this page.", err=True)
215
+ sys.exit(1)
216
+ with httpx.Client(headers=DOWNLOAD_HEADERS, timeout=TIMEOUT, follow_redirects=True) as client:
217
+ for kind, url, filename in jobs:
218
+ resp = client.get(url)
219
+ resp.raise_for_status()
220
+ (outdir / filename).write_bytes(resp.content)
221
+ click.echo(f"{kind}: {outdir / filename} ({len(resp.content)} bytes)")
222
+ (outdir / f"{stem}.metadata.json").write_text(
223
+ json.dumps({"resource_url": resource_url, "item": item,
224
+ "resources": data.get("resources")}, indent=2, ensure_ascii=False))
225
+ click.echo(f"metadata: {outdir / (stem + '.metadata.json')}")
226
+
227
+
228
+ @cli.command()
229
+ @click.argument("query")
230
+ @click.option("--dates", default=None, help="Date range YYYY/YYYY.")
231
+ @click.option("--level", default="page", type=click.Choice(["page", "issue", "title", "all"]),
232
+ show_default=True)
233
+ @click.option("--state", default=None, help="Filter by state via fa=location_state:<state>.")
234
+ @click.option("--lccn", default=None, help="Filter by newspaper LCCN via fa=number_lccn:<lccn>.")
235
+ def url(query, dates, level, state, lccn):
236
+ """Print the loc.gov website search URL for QUERY (open in a browser)."""
237
+ params: list[tuple[str, str]] = [("q", query)]
238
+ if level != "all":
239
+ params.append(("dl", level))
240
+ if dates:
241
+ params.append(("dates", dates))
242
+ if state:
243
+ params.append(("fa", f"location_state:{state.strip().lower()}"))
244
+ if lccn:
245
+ params.append(("fa", f"number_lccn:{lccn.strip()}"))
246
+ click.echo(COLLECTION_BASE + "?" + urlencode(params))
247
+
248
+
249
+ if __name__ == "__main__":
250
+ cli()
@@ -0,0 +1,53 @@
1
+ ---
2
+ name: cyndis-list
3
+ description: Use Cyndi's List, the free categorized directory of 332,000+ genealogy links, to find niche county-specific transcription sites (USGenWeb county pages, volunteer marriage indexes, church registers, cemetery surveys) across US states, counties, and international localities. Covers the category structure, stable URL patterns for US states and counties, the site search, and how to judge a linked site before citing it. Skill-only: there is no CLI, because Cyndi's List is a directory of links, not a records database. Use when you know the county and record type but not which volunteer site holds the transcription.
4
+ ---
5
+
6
+ # Cyndi's List
7
+
8
+ **Skill-only: no CLI.** Cyndi's List is a categorized directory of links, not a records database. There is no API, no search endpoint that returns records, and no stable result set to script against. A CLI would only re-print links a browser visit already shows. What this skill gives instead is the verified URL structure and a repeatable county-first workflow, so a researcher (or an agent with a browser) lands on the right category page in one step.
9
+
10
+ ## What it is
11
+
12
+ - Cyndi's List of Genealogy Sites on the Internet, `https://www.cyndislist.com/`, maintained by Cyndi Howells for more than 25 years. Free for everyone, no account.
13
+ - Roughly 332,000 links in 200+ categories, cross-referenced. Submitters write their own descriptions; Cyndi categorizes them. The waiting list for uncategorized submissions has historically run years, so the newest volunteer sites may not be listed yet.
14
+ - Think card catalog, not library: every entry points somewhere else. The value is discovery of small volunteer sites a search engine buries, especially USGenWeb county pages, local society transcription projects, and personal home pages.
15
+
16
+ ## Structure (verified live 2026-11-24)
17
+
18
+ - **Categories index:** `https://www.cyndislist.com/categories` lists every category with stable slug URLs (`/cemeteries/`, `/marriages/`, `/census-worldwide/`, `/surnames/`, `/maps/`, `/newspapers/`, `/obituaries/`, `/land/`, and more).
19
+ - **Top-level divisions:** Localities (by country, then state/province, then county), Records (by type: births, marriages, deaths, cemeteries, census, land, military, newspapers, obituaries), Religions, Ethnic Groups, Occupations, Research Tools, and more.
20
+ - **United States index:** `https://www.cyndislist.com/us/` with a page per state, e.g. Michigan at `https://www.cyndislist.com/us/mi/` or Illinois at `https://www.cyndislist.com/us/il/`.
21
+ - **State pages** split into record-type subpages: `/us/<st>/bmd/`, `/us/<st>/cemeteries/`, `/us/<st>/census/`, `/us/<st>/counties/`, `/us/<st>/directories/`, `/us/<st>/history/`, `/us/<st>/land/`, `/us/<st>/libraries/`, `/us/<st>/maps/`, `/us/<st>/military/`, `/us/<st>/newspapers/`, `/us/<st>/obituaries/`, `/us/<st>/periodicals/`, `/us/<st>/photos/`, and others.
22
+ - **County pages** follow one pattern: `https://www.cyndislist.com/us/<st>/counties/<county>/`, e.g. `https://www.cyndislist.com/us/mi/counties/wayne/`. Each county page links to topic subpages such as `bmd/`, `cemeteries/`, `census/`, `general/`. The counties index for a state lives at `https://www.cyndislist.com/us/<st>/counties/`.
23
+ - **Site search:** the search box is a Google Custom Search (Google CSE) over cyndislist.com, not a native index. It finds category pages and link descriptions, not the contents of linked sites. Prefer navigating the category tree over searching when you know the county and record type.
24
+
25
+ ## County-first workflow
26
+
27
+ 1. Start at the county page, not the homepage: `https://www.cyndislist.com/us/<st>/counties/<county>/` (using the two-letter state code and lowercase county name with no spaces, e.g. `/us/il/counties/sangamon/` or `/us/ny/counties/monroe/`). Verify the county page exists before citing it, since county coverage varies by state.
28
+ 2. On the county page, open the topic subpage matching the record you need: `bmd` for births/marriages/deaths, `cemeteries` for cemetery surveys and tombstone transcriptions, `census` for census transcriptions and indexes, `general` for the county's USGenWeb page and society sites.
29
+ 3. If the county page is thin, step up to the state record-type page (e.g. `/us/<st>/cemeteries/`) and to the national record-type category (e.g. `/cemeteries/`, `/marriages/`), which list statewide and national transcription projects that cover the county.
30
+ 4. For surname-specific sites, check `/surnames/`; for church registers, check the religion categories (`/catholic/`, `/baptist/`, `/methodist/`, `/quaker/`, and others).
31
+
32
+ ## Judging a linked site before citing it
33
+
34
+ Cyndi's List does not vet the contents of linked sites, and links rot. Before citing anything found through it:
35
+
36
+ - Open the link and confirm it still resolves and the transcription is actually there; dead or hijacked links are common on a directory this old.
37
+ - Note who transcribed it, from what source, and when. A volunteer transcription is a finding aid, not a primary source; cite the transcription as a pointer and verify against the original record (county clerk, FamilySearch image, or archive) before recording it as fact in `data/`.
38
+ - Prefer links to USGenWeb county pages, county genealogical societies, and library digital collections over undated personal home pages with no source notes.
39
+ - If a link is dead, try the Wayback Machine for the URL, then search the county name plus the record type; the project often moved to a new host.
40
+
41
+ ## What Cyndi's List cannot do
42
+
43
+ - It holds no records itself. Searching it for a surname finds pages that mention that surname in a link description, not individuals in records.
44
+ - It has no API and no bulk data download. Do not scrape it wholesale; it is one person's curated directory, and heavy crawling is poor citizenship toward the maintainer.
45
+ - Coverage is uneven: a county with an active USGenWeb volunteer has a rich page; a county without one may have almost nothing. An empty county page means "nothing catalogued here", not "no records exist".
46
+
47
+ ## Why there is no CLI
48
+
49
+ A CLI needs a machine interface: a public API, a stable search URL pattern returning records, or downloadable data. Cyndi's List has none of these. Its pages are hand-curated HTML link lists behind a Google Custom Search box, and the useful output (a handful of links on a county topic page) is read once by a human in a browser. Shipping a CLI that fetches and prints those links would add a tool that saves no work over opening the page, and it would go stale the moment Cyndi recategorizes a page. Skill-only is the honest shape.
50
+
51
+ ## Verified-live note
52
+
53
+ Homepage, categories index, state pages, counties index, and county topic subpages (`bmd`, `cemeteries`, `census`, and `general`) were verified live returning HTTP 200 on 2026-11-24.
@@ -0,0 +1,116 @@
1
+ ---
2
+ name: findagrave
3
+ description: Search and read Find a Grave memorials, cemeteries, and places via the bundled uv-based `findagrave` CLI, the website search, or the site's own GraphQL API. Covers CLI usage, memorial and cemetery URL patterns, search filters, photo downloads, and what works vs what does not. Use when finding burial records, birth/death dates and places, cemetery details, linked family, or gravestone photos for genealogy research.
4
+ ---
5
+
6
+ # Find a Grave
7
+
8
+ This skill includes a standalone executable Python CLI at `skills/findagrave/scripts/findagrave` using a PEP 723 `#!/usr/bin/env -S uv run --script` shebang with inline dependencies (`click`, `httpx`). No virtualenv setup or API key is required.
9
+
10
+ ## Bundled CLI (`scripts/findagrave`)
11
+
12
+ Path: `skills/findagrave/scripts/findagrave`
13
+
14
+ ### Search memorials
15
+
16
+ ```bash
17
+ # Search memorials by first and last name
18
+ skills/findagrave/scripts/findagrave search --first Abraham --last Lincoln
19
+
20
+ # Narrow by years and place
21
+ skills/findagrave/scripts/findagrave search --first Clara --last Barton --birth-year 1821 --year-range 2
22
+ skills/findagrave/scripts/findagrave search --last Douglass --death-year 1895 --death-year-filter exact
23
+
24
+ # In one cemetery, or in one place (place id from the place command)
25
+ skills/findagrave/scripts/findagrave search --last Lincoln --cemetery-id <cemetery-id>
26
+ skills/findagrave/scripts/findagrave search --last Lincoln --location-id <location-id>
27
+
28
+ # Biography text, any-text, or a linked relative; full JSON output
29
+ skills/findagrave/scripts/findagrave search --last Lincoln --bio president --limit 5
30
+ skills/findagrave/scripts/findagrave search --first Harriet --last Tubman --json
31
+ ```
32
+
33
+ Names match the site's default matching unless `--exact` is passed. Married women are also found under their maiden name by default (`--no-include-maiden` turns that off). A search returns at most 50 rows per call; use `--limit` and `--offset` to page. The site only reaches the first 10,000 results of a search, so narrow by place, years, or cemetery when totals are large.
34
+
35
+ ### Read one or more memorials in full
36
+
37
+ ```bash
38
+ # Read one memorial by id from search output
39
+ skills/findagrave/scripts/findagrave get <memorial-id>
40
+
41
+ # Full bio/inscription text, photo list, and JSON output
42
+ skills/findagrave/scripts/findagrave get <memorial-id> --full --photos
43
+ skills/findagrave/scripts/findagrave get <memorial-id-1> <memorial-id-2> --json
44
+ ```
45
+
46
+ A `get` returns name (with maiden name separate), birth/death dates and places, cemetery, plot, inscription, bio, veteran flag, grave-photo flag, photo count, linked relationships (each with its own memorial id to read next), and created/modified dates. `familyRelations` is usually null in search-shaped responses; use `relationships` for linked family. In `--json` output, `bio` and `inscription` are returned as `{"value": "..."}` objects or `null` (matching the GraphQL schema).
47
+
48
+ ### Cemeteries and places
49
+
50
+ ```bash
51
+ # Cemeteries by name
52
+ skills/findagrave/scripts/findagrave cemetery --name "Oak Ridge"
53
+ skills/findagrave/scripts/findagrave cemetery --name "Oak Ridge" --place "Sangamon County, Illinois"
54
+
55
+ # One cemetery by id
56
+ skills/findagrave/scripts/findagrave cemetery --id <cemetery-id>
57
+
58
+ # Resolve a place name to ids (for use with search --location-id)
59
+ skills/findagrave/scripts/findagrave place --name Springfield
60
+ ```
61
+
62
+ Place ids look like `city_<id>`, `county_<id>`, or a plain cemetery id. Resolve the name first and check it before using an id: the typeahead ranks by its own relevance, and a name can fit several places.
63
+
64
+ ### Download photos
65
+
66
+ ```bash
67
+ # Downloads a memorial's photos into ./photos
68
+ skills/findagrave/scripts/findagrave photo <memorial-id> --out ./photos
69
+ skills/findagrave/scripts/findagrave photo <memorial-id> --type Grave --out ./photos
70
+
71
+ # Add a self-describing filename prefix and a provenance sidecar JSON file
72
+ skills/findagrave/scripts/findagrave photo <memorial-id> --type Grave --prefix lincoln-abraham --metadata --out ./photos
73
+ ```
74
+
75
+ Files are saved as `<photo-id>.jpg` by default, or `<prefix>_<photo-id>.jpg` when `--prefix` is set (`--metadata` writes `<prefix>_<memorial-id>.metadata.json`). Read a gravestone photo before trusting a memorial's transcribed dates: the stone is the better source.
76
+
77
+ ### Build a website search URL offline
78
+
79
+ ```bash
80
+ skills/findagrave/scripts/findagrave url --first Abraham --last Lincoln --birth-year 1809
81
+ ```
82
+
83
+ ## Website search & URL patterns (verified live 2026-11-24)
84
+
85
+ - Memorial page: `https://www.findagrave.com/memorial/<memorial-id>` (name slug optional after the id, e.g. `https://www.findagrave.com/memorial/<memorial-id>/abraham-lincoln`)
86
+ - Cemetery page: `https://www.findagrave.com/cemetery/<cemetery-id>`
87
+ - Website search: `https://www.findagrave.com/memorial/search?firstname=Abraham&lastname=Lincoln&birthyear=1809&deathyear=1865`
88
+ - No sign-in is needed to search or read public memorials. Signed-in-only features (virtual cemeteries, flower leaving, edit requests, photo requests) are out of scope for this skill.
89
+
90
+ ## GraphQL API rules (verified live 2026-11-24)
91
+
92
+ There is no public Find a Grave API. The CLI uses the site's own undocumented internal GraphQL API, which answers anonymously with no key, login, or cookies:
93
+
94
+ - Endpoint: `POST https://www.findagrave.com/orc/graphql`
95
+ - Headers: `Content-Type: application/json` plus a browser `User-Agent`. No auth headers.
96
+ - Top-level queries used by the CLI: `memorialSearch(search: MemorialSearchInput)`, `memorialsById(ids: [ID!]!)`, `cemeteries(ids:, search: CemeterySearchInput)`, `locationsByTypeahead(search: LocationSearchInput)`.
97
+ - `memorialSearch` returns `{ total, memorials }`. `MemorialSearchInput` fields verified live include `firstName`, `lastName`, `birthYear`, `deathYear`, `birthYearFilter`, `deathYearFilter`, `birthYearRange`, `deathYearRange`, `locationId`, `cemeteryIds`, `bio`, `fullText`, `linkedToName`, `exactName`, `includeMaidenName`, `from`, `size`. Year filters use the `MemorialSearchYearFilter` enum (`before`, `after`, `exact`, `unknown`).
98
+ - `Memorial` fields verified live include `id`, `name { first last maiden }`, `birth { date { year month day circa } place { names { name } } }`, `death` (same shape), `cemetery { id names { name } memorialCount }`, `plot`, `inscription { value }`, `bio { value }`, `isVeteran`, `hasGravePhoto`, `dateCreated`, `dateModified`, `relationships { type yearMarried memorial { id name { first last } } }`, `photos { total photos { id path caption type } }`.
99
+ - `Place` is a union of `Location` and `Cemetery`; use inline fragments (`... on Location`, `... on Cemetery`) when querying it.
100
+ - Full schema introspection is disabled, but `{ __type(name: "Memorial") { fields { name } } }` lists a type's fields, and `{ __type(name: "Query") { fields { name } } }` lists top-level queries. That is how the field lists above were verified.
101
+ - Because the API is undocumented, it can change without notice. If a query starts failing with `GRAPHQL_VALIDATION_FAILED`, re-probe the type with `__type` before assuming the data is gone.
102
+
103
+ ## What works vs what does not
104
+
105
+ - Works: anonymous GraphQL `search`/`get`/`cemetery`/`place`/`photo` reads, and plain `curl` fetches of the website search HTML (verified live 2026-11-24).
106
+ - IP sensitivity: automated fetches can occasionally receive HTTP 403 depending on originating IP reputation; when that happens, fall back to a live browser.
107
+ - Cloudflare challenges bursts: space requests at least 250 ms apart (the CLI waits 0.3 s per request). If a 403 appears, wait a few minutes and retry once; if it persists, fall back to the website in a real browser.
108
+ - No bulk export: there is no dump or bulk-download endpoint. Work memorial by memorial and cite each one.
109
+
110
+ ## Data quality: treat memorials as leads
111
+
112
+ Find a Grave is contributor-written. Dates, family links, and biographies are claims, often unsourced and sometimes copied from online trees. Prefer what a stone in a photo shows, cross-check dates against vital records and census data, and cite the memorial (id and URL) for every fact taken from it. A recently deceased person's memorial can show limited details.
113
+
114
+ ## Environment variables
115
+
116
+ None. No key, login, or account is needed for anything in this skill.