@kinloom/cli 0.1.1 → 0.3.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/dist/assets/cached-ocr.py +786 -0
- package/dist/assets/ocr.md +76 -0
- package/dist/assets/prep-scan.md +97 -0
- package/dist/assets/prep-scan.py +1313 -0
- package/dist/bundled-skills/acpl-persi/SKILL.md +103 -0
- package/dist/bundled-skills/acpl-persi/scripts/persi +539 -0
- package/dist/bundled-skills/archive-org/SKILL.md +162 -0
- package/dist/bundled-skills/archive-org/scripts/archive-org +1576 -0
- package/dist/bundled-skills/blm-glo/SKILL.md +54 -0
- package/dist/bundled-skills/california-archives/SKILL.md +130 -0
- package/dist/bundled-skills/california-archives/scripts/ca-archives +614 -0
- package/dist/bundled-skills/chronicling-america/SKILL.md +120 -0
- package/dist/bundled-skills/chronicling-america/scripts/chronam +553 -0
- package/dist/bundled-skills/cyndis-list/SKILL.md +53 -0
- package/dist/bundled-skills/findagrave/SKILL.md +129 -0
- package/dist/bundled-skills/findagrave/scripts/findagrave +965 -0
- package/dist/bundled-skills/hathitrust/SKILL.md +117 -0
- package/dist/bundled-skills/hathitrust/scripts/hathi +379 -0
- package/dist/bundled-skills/kentucky-archives/SKILL.md +124 -0
- package/dist/bundled-skills/kentucky-archives/scripts/ky-archives +646 -0
- package/dist/bundled-skills/library-of-michigan/SKILL.md +118 -0
- package/dist/bundled-skills/library-of-michigan/scripts/michiganology +515 -0
- package/dist/bundled-skills/missouri-archives/SKILL.md +109 -0
- package/dist/bundled-skills/missouri-archives/scripts/mo-archives +751 -0
- package/dist/bundled-skills/nara-catalog-search/SKILL.md +130 -0
- package/dist/bundled-skills/nara-catalog-search/scripts/nara +1387 -0
- package/dist/bundled-skills/narrative-audio/SKILL.md +103 -0
- package/dist/bundled-skills/narrative-audio/references/script-rules.md +109 -0
- package/dist/bundled-skills/narrative-audio/scripts/narrative-audio +290 -0
- package/dist/bundled-skills/new-jersey-archives/SKILL.md +135 -0
- package/dist/bundled-skills/new-jersey-archives/scripts/nj-archives +869 -0
- package/dist/bundled-skills/openarchieven/SKILL.md +97 -0
- package/dist/bundled-skills/openarchieven/scripts/openarchieven +624 -0
- package/dist/bundled-skills/texas-archives/SKILL.md +102 -0
- package/dist/bundled-skills/texas-archives/scripts/texas-archives +666 -0
- package/dist/bundled-skills/uk-archives/SKILL.md +110 -0
- package/dist/bundled-skills/uk-archives/scripts/uk-archives +631 -0
- package/dist/bundled-skills/usgs-gnis/SKILL.md +99 -0
- package/dist/bundled-skills/usgs-gnis/scripts/gnis +418 -0
- package/dist/bundled-skills/virginia-archives/SKILL.md +144 -0
- package/dist/bundled-skills/virginia-archives/scripts/va-archives +1039 -0
- package/dist/bundled-skills/wikitree/SKILL.md +154 -0
- package/dist/bundled-skills/wikitree/scripts/wikitree +455 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +488 -26
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +30 -5
- package/dist/client.js.map +1 -1
- package/dist/commands/ops/audit.d.ts +138 -0
- package/dist/commands/ops/audit.d.ts.map +1 -0
- package/dist/commands/ops/audit.js +872 -0
- package/dist/commands/ops/audit.js.map +1 -0
- package/dist/commands/ops/context.d.ts +100 -0
- package/dist/commands/ops/context.d.ts.map +1 -0
- package/dist/commands/ops/context.js +917 -0
- package/dist/commands/ops/context.js.map +1 -0
- package/dist/commands/ops/dates.d.ts +87 -0
- package/dist/commands/ops/dates.d.ts.map +1 -0
- package/dist/commands/ops/dates.js +228 -0
- package/dist/commands/ops/dates.js.map +1 -0
- package/dist/commands/ops/help.d.ts +8 -0
- package/dist/commands/ops/help.d.ts.map +1 -0
- package/dist/commands/ops/help.js +107 -0
- package/dist/commands/ops/help.js.map +1 -0
- package/dist/commands/ops/index.d.ts +8 -0
- package/dist/commands/ops/index.d.ts.map +1 -0
- package/dist/commands/ops/index.js +8 -0
- package/dist/commands/ops/index.js.map +1 -0
- package/dist/commands/ops/integrate.d.ts +61 -0
- package/dist/commands/ops/integrate.d.ts.map +1 -0
- package/dist/commands/ops/integrate.js +1063 -0
- package/dist/commands/ops/integrate.js.map +1 -0
- package/dist/commands/ops/sync.d.ts +194 -0
- package/dist/commands/ops/sync.d.ts.map +1 -0
- package/dist/commands/ops/sync.js +1251 -0
- package/dist/commands/ops/sync.js.map +1 -0
- package/dist/commands/ops/telemetry.d.ts +79 -0
- package/dist/commands/ops/telemetry.d.ts.map +1 -0
- package/dist/commands/ops/telemetry.js +249 -0
- package/dist/commands/ops/telemetry.js.map +1 -0
- package/dist/commands/ops/verify.d.ts +76 -0
- package/dist/commands/ops/verify.d.ts.map +1 -0
- package/dist/commands/ops/verify.js +325 -0
- package/dist/commands/ops/verify.js.map +1 -0
- package/dist/commands/records/help.d.ts +18 -0
- package/dist/commands/records/help.d.ts.map +1 -0
- package/dist/commands/records/help.js +174 -0
- package/dist/commands/records/help.js.map +1 -0
- package/dist/commands/records/index.d.ts +5 -0
- package/dist/commands/records/index.d.ts.map +1 -0
- package/dist/commands/records/index.js +5 -0
- package/dist/commands/records/index.js.map +1 -0
- package/dist/commands/records/registry.d.ts +32 -0
- package/dist/commands/records/registry.d.ts.map +1 -0
- package/dist/commands/records/registry.js +227 -0
- package/dist/commands/records/registry.js.map +1 -0
- package/dist/commands/records/resolve.d.ts +14 -0
- package/dist/commands/records/resolve.d.ts.map +1 -0
- package/dist/commands/records/resolve.js +61 -0
- package/dist/commands/records/resolve.js.map +1 -0
- package/dist/commands/records/runner.d.ts +27 -0
- package/dist/commands/records/runner.d.ts.map +1 -0
- package/dist/commands/records/runner.js +255 -0
- package/dist/commands/records/runner.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
- **Latency (measured 2026-11-25):** every loc.gov collection search takes **20-45 s** on the server side. Connect + TLS take under 0.1 s, but time-to-first-byte was 19-43 s for every query shape tried (with or without `q`, `dates`, `fa=location_state`, `dl=page`, `at=results` vs `at=search,results`, HTTP/1.1 vs HTTP/2, kinloom vs browser User-Agent). One probe under 6 parallel requests took 70 s. The old 8 s default timeout therefore failed 80%+ of searches. The default `--timeout` is now **120 s**. `/newspapers/?fo=json` returned 0 hits for the same query, and `/search/?fa=partof:chronicling+america` 302-redirects to the collection endpoint, so neither is faster.
|
|
13
|
+
- **Disk cache:** every successful search (and every `get`/`download` item lookup) is cached, so a repeat returns in well under a second with no network call. See [Disk cache](#disk-cache).
|
|
14
|
+
- **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`, `--state`, or `--lccn` first. The CLI retries HTTP 429/503 once after the `Retry-After` delay (capped at 30 s) and retries 5xx and dropped connections once.
|
|
15
|
+
- **Unstable hit counts (measured 2026-11-25):** loc.gov can return very different `hits` for byte-identical requests. `Merced` + California + 1900/1920 returned 32, then 34,133, then 35,404. `Abraham Lincoln` returned 0, then 25,392, then 77,301. So a low or zero count is **not** evidence of absence. The CLI never caches a zero-hit answer. To recheck a suspiciously low count, rerun with `--refresh`.
|
|
16
|
+
|
|
17
|
+
## Bundled CLI (`scripts/chronam`)
|
|
18
|
+
|
|
19
|
+
Path: `skills/chronicling-america/scripts/chronam`
|
|
20
|
+
|
|
21
|
+
### Search newspaper pages
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Full-text search for a surname, page level, 10 results
|
|
25
|
+
skills/chronicling-america/scripts/chronam search Lincoln
|
|
26
|
+
|
|
27
|
+
# Multi-word queries need no quotes; postal codes work for --state
|
|
28
|
+
skills/chronicling-america/scripts/chronam search Abraham Lincoln --state IL --dates 1860/1865
|
|
29
|
+
|
|
30
|
+
# Surname search narrowed to 1860-1865 (or --date-from 1860 --date-to 1865)
|
|
31
|
+
skills/chronicling-america/scripts/chronam search Lincoln --dates 1860/1865
|
|
32
|
+
|
|
33
|
+
# Illinois papers only (server-side state facet), JSON output
|
|
34
|
+
skills/chronicling-america/scripts/chronam search Lincoln --dates 1860/1865 --state Illinois --json
|
|
35
|
+
|
|
36
|
+
# One newspaper title only, by LCCN (Evening Star, Washington, D.C.)
|
|
37
|
+
# Use one distinctive word with --lccn: measured 2026-11-25, "Clara Barton" + this LCCN
|
|
38
|
+
# returned 0 hits on three tries, while "Barton" + the same LCCN returned 38,628.
|
|
39
|
+
skills/chronicling-america/scripts/chronam search Barton --lccn sn83045462
|
|
40
|
+
|
|
41
|
+
# Second page of results, 25 per page (--per-page is an alias for --limit)
|
|
42
|
+
skills/chronicling-america/scripts/chronam search "Frederick Douglass" --dates 1870/1895 --limit 25 --page 2
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Options: `--dates YYYY/YYYY` or `YYYY` (or `--date-from`/`--from-year`/`--date1`/`--year1` and `--date-to`/`--to-year`/`--date2`/`--year2`), `--state` (name or postal code), `--lccn`, `--level` (`page`/`issue`/`title`/`all`), `--limit` / `--per-page` / `--rows` / `-n`, `--page` / `-p`, `--timeout` (seconds, default `120`), `--terms` / `--query` / `-q` (alias for positional query), `--refresh`, `--cache-ttl-hours`, `--json`. JSON output carries `"cache_hit": true|false`; text output marks hits with `[cache]`.
|
|
46
|
+
|
|
47
|
+
### Disk cache
|
|
48
|
+
|
|
49
|
+
- Location: `~/.cache/kinloom-chronam/` (override with `KINLOOM_CHRONAM_CACHE_DIR`). One JSON file per request, keyed by the SHA-256 of the URL and sorted query parameters.
|
|
50
|
+
- TTL: 168 hours (override with `--cache-ttl-hours` or `KINLOOM_CHRONAM_CACHE_TTL_HOURS`; `0` disables reads).
|
|
51
|
+
- `--refresh` re-queries loc.gov and rewrites the entry.
|
|
52
|
+
- Zero-hit answers are never cached (see unstable hit counts above).
|
|
53
|
+
- Writes are atomic (temp file + rename). A per-query `flock` makes concurrent agents that run the same search wait for the first one and then read its file, so loc.gov sees one request.
|
|
54
|
+
|
|
55
|
+
### Inspect one page
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# By loc.gov resource URL (copy it from a search result)
|
|
59
|
+
skills/chronicling-america/scripts/chronam get "https://www.loc.gov/resource/<lccn>/<YYYY-MM-DD>/ed-1/?sp=<seq>"
|
|
60
|
+
|
|
61
|
+
# Or build the URL from LCCN + date + page sequence
|
|
62
|
+
skills/chronicling-america/scripts/chronam get --lccn sn83045462 --date 1865-04-15 --seq 1 --json
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`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`.
|
|
66
|
+
|
|
67
|
+
### Download a page
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# PDF + metadata JSON into ./downloads/chronam
|
|
71
|
+
skills/chronicling-america/scripts/chronam download --lccn sn83045462 --date 1865-04-15 --seq 1 --out ./downloads/chronam
|
|
72
|
+
|
|
73
|
+
# Also fetch the OCR (ALTO XML) and the image rendition
|
|
74
|
+
skills/chronicling-america/scripts/chronam download --lccn sn83045462 --date 1865-04-15 --seq 1 --out ./downloads/chronam --text --image
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Files are named `<lccn>_<date>_sp<seq>.pdf` (etc.) with a matching `<stem>.metadata.json`.
|
|
78
|
+
|
|
79
|
+
### Build a website search URL
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
skills/chronicling-america/scripts/chronam url "Susan B. Anthony" --dates 1870/1900
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Website search & API rules (verified live 2026-11-24)
|
|
86
|
+
|
|
87
|
+
- Collection site: `https://www.loc.gov/collections/chronicling-america/`
|
|
88
|
+
- JSON API base: `GET https://www.loc.gov/collections/chronicling-america/?{params}&fo=json`
|
|
89
|
+
- **Use `q=` for the search words.** `q` runs a full-text search over page OCR and populates `search.query` in the JSON response.
|
|
90
|
+
- **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.
|
|
91
|
+
- **Date filter `dates=YYYY/YYYY` works** to narrow large full-text result sets.
|
|
92
|
+
- **Display level `dl=`:** `page` (default for full-text page results), `issue`, `title`, `all`. Pass `dl=page` for OCR searching.
|
|
93
|
+
- **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).
|
|
94
|
+
- **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.
|
|
95
|
+
- **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.
|
|
96
|
+
- **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.
|
|
97
|
+
|
|
98
|
+
### Example URL patterns
|
|
99
|
+
|
|
100
|
+
- Surname search, page level: `https://www.loc.gov/collections/chronicling-america/?dl=page&fo=json&q=Lincoln&c=3`
|
|
101
|
+
- Date-bounded search: `https://www.loc.gov/collections/chronicling-america/?dl=page&fo=json&q=Lincoln&c=1&dates=1860/1865`
|
|
102
|
+
- One page as JSON: `https://www.loc.gov/resource/<lccn>/<YYYY-MM-DD>/ed-1/?sp=<seq>&fo=json`
|
|
103
|
+
|
|
104
|
+
## What is dead (verified 2026-11-24)
|
|
105
|
+
|
|
106
|
+
- The old Chronicling America API at `chroniclingamerica.loc.gov/search/pages/results/?...&format=json` returned **404** on 2026-11-24 and a Cloudflare **308** redirect on 2026-11-25. 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.
|
|
107
|
+
- `chroniclingamerica.loc.gov/about/api/` returns 403.
|
|
108
|
+
- The loc.gov HTML pages return 403 to plain scripted requests; use the `fo=json` endpoints for machine access.
|
|
109
|
+
|
|
110
|
+
## Environment variables
|
|
111
|
+
|
|
112
|
+
- No key or account is needed.
|
|
113
|
+
- `KINLOOM_CHRONAM_CACHE_DIR` (optional): cache directory (default `~/.cache/kinloom-chronam`).
|
|
114
|
+
- `KINLOOM_CHRONAM_CACHE_TTL_HOURS` (optional): cache TTL in hours (default `168`).
|
|
115
|
+
|
|
116
|
+
## Research workflow notes
|
|
117
|
+
|
|
118
|
+
- OCR is imperfect: try spelling variants and initials (for example `"S. L. Clemens"` and `"Samuel Clemens"`) as separate searches.
|
|
119
|
+
- 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.
|
|
120
|
+
- 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.
|