@kinloom/cli 0.1.1 → 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.
- package/dist/assets/cached-ocr.py +556 -0
- package/dist/assets/ocr.md +52 -0
- package/dist/assets/prep-scan.md +59 -0
- package/dist/assets/prep-scan.py +891 -0
- package/dist/bundled-skills/acpl-persi/SKILL.md +94 -0
- package/dist/bundled-skills/acpl-persi/scripts/persi +268 -0
- package/dist/bundled-skills/archive-org/SKILL.md +129 -0
- package/dist/bundled-skills/archive-org/scripts/archive-org +879 -0
- package/dist/bundled-skills/blm-glo/SKILL.md +54 -0
- package/dist/bundled-skills/california-archives/SKILL.md +120 -0
- package/dist/bundled-skills/california-archives/scripts/ca-archives +373 -0
- package/dist/bundled-skills/chronicling-america/SKILL.md +100 -0
- package/dist/bundled-skills/chronicling-america/scripts/chronam +250 -0
- package/dist/bundled-skills/cyndis-list/SKILL.md +53 -0
- package/dist/bundled-skills/findagrave/SKILL.md +116 -0
- package/dist/bundled-skills/findagrave/scripts/findagrave +520 -0
- package/dist/bundled-skills/hathitrust/SKILL.md +110 -0
- package/dist/bundled-skills/hathitrust/scripts/hathi +194 -0
- package/dist/bundled-skills/kentucky-archives/SKILL.md +123 -0
- package/dist/bundled-skills/kentucky-archives/scripts/ky-archives +358 -0
- package/dist/bundled-skills/library-of-michigan/SKILL.md +111 -0
- package/dist/bundled-skills/library-of-michigan/scripts/michiganology +346 -0
- package/dist/bundled-skills/missouri-archives/SKILL.md +100 -0
- package/dist/bundled-skills/missouri-archives/scripts/mo-archives +528 -0
- package/dist/bundled-skills/nara-catalog-search/SKILL.md +118 -0
- package/dist/bundled-skills/nara-catalog-search/scripts/nara +934 -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 +118 -0
- package/dist/bundled-skills/new-jersey-archives/scripts/nj-archives +585 -0
- package/dist/bundled-skills/openarchieven/SKILL.md +90 -0
- package/dist/bundled-skills/openarchieven/scripts/openarchieven +432 -0
- package/dist/bundled-skills/texas-archives/SKILL.md +93 -0
- package/dist/bundled-skills/texas-archives/scripts/texas-archives +441 -0
- package/dist/bundled-skills/uk-archives/SKILL.md +101 -0
- package/dist/bundled-skills/uk-archives/scripts/uk-archives +391 -0
- package/dist/bundled-skills/usgs-gnis/SKILL.md +89 -0
- package/dist/bundled-skills/usgs-gnis/scripts/gnis +254 -0
- package/dist/bundled-skills/virginia-archives/SKILL.md +104 -0
- package/dist/bundled-skills/virginia-archives/scripts/va-archives +466 -0
- package/dist/bundled-skills/wikitree/SKILL.md +148 -0
- package/dist/bundled-skills/wikitree/scripts/wikitree +219 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +383 -26
- package/dist/cli.js.map +1 -1
- package/dist/client.js +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 +867 -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/help.d.ts +6 -0
- package/dist/commands/ops/help.d.ts.map +1 -0
- package/dist/commands/ops/help.js +74 -0
- package/dist/commands/ops/help.js.map +1 -0
- package/dist/commands/ops/index.d.ts +6 -0
- package/dist/commands/ops/index.d.ts.map +1 -0
- package/dist/commands/ops/index.js +6 -0
- package/dist/commands/ops/index.js.map +1 -0
- package/dist/commands/ops/integrate.d.ts +56 -0
- package/dist/commands/ops/integrate.d.ts.map +1 -0
- package/dist/commands/ops/integrate.js +872 -0
- package/dist/commands/ops/integrate.js.map +1 -0
- package/dist/commands/ops/sync.d.ts +177 -0
- package/dist/commands/ops/sync.d.ts.map +1 -0
- package/dist/commands/ops/sync.js +1078 -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/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 +25 -0
- package/dist/commands/records/runner.d.ts.map +1 -0
- package/dist/commands/records/runner.js +224 -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,346 @@
|
|
|
1
|
+
#!/usr/bin/env -S uv run --script
|
|
2
|
+
# /// script
|
|
3
|
+
# requires-python = ">=3.11"
|
|
4
|
+
# dependencies = [
|
|
5
|
+
# "click>=8.1",
|
|
6
|
+
# ]
|
|
7
|
+
# ///
|
|
8
|
+
"""Search Michiganology, the Archives of Michigan digital collections
|
|
9
|
+
(Preservica Universal Access), from the command line.
|
|
10
|
+
|
|
11
|
+
Simple search is a stable GET: https://michigan.access.preservica.com/?s=<query>
|
|
12
|
+
Results are server-rendered, so plain HTTP works, no browser and no key.
|
|
13
|
+
Transport note: Preservica's front door 403s Python httpx requests (TLS
|
|
14
|
+
fingerprint) while curl succeeds with any User-Agent, so this CLI shells out
|
|
15
|
+
to curl for the fetch. curl must be installed; it is on any normal Unix box.
|
|
16
|
+
Verified live 2026-11-24: simple search returns server-rendered HTML results.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
import html as htmlmod
|
|
22
|
+
import json
|
|
23
|
+
import re
|
|
24
|
+
import shutil
|
|
25
|
+
import subprocess
|
|
26
|
+
import tempfile
|
|
27
|
+
from html.parser import HTMLParser
|
|
28
|
+
from pathlib import Path
|
|
29
|
+
from urllib.parse import quote_plus, unquote
|
|
30
|
+
|
|
31
|
+
import click
|
|
32
|
+
|
|
33
|
+
BASE = "https://michigan.access.preservica.com"
|
|
34
|
+
# Preservica 403s python-httpx's default header set. Plain curl-style headers
|
|
35
|
+
# (short UA, Accept */*) return 200 consistently.
|
|
36
|
+
USER_AGENT = "Mozilla/5.0"
|
|
37
|
+
|
|
38
|
+
COLLECTIONS = [
|
|
39
|
+
("Death Certificates, 1897-1952", BASE + "/death-certificates-1897-1952/"),
|
|
40
|
+
("Michigan State Census, 1827-1894", BASE + "/michigan-state-census/"),
|
|
41
|
+
("Naturalization Records", BASE + "/naturalization-records/"),
|
|
42
|
+
("World War I, Service Cards", BASE + "/world-war-i-service-cards/"),
|
|
43
|
+
("Surveyor Field Notebooks, 1815-1918", BASE + "/surveyor-field-notebooks/"),
|
|
44
|
+
("Surveyor Maps, 1816-1860", BASE + "/surveyor-maps/"),
|
|
45
|
+
("General Photograph Collection, ca. 1860-1990", BASE + "/general-photograph-collection/"),
|
|
46
|
+
("Archives of Michigan Map Collection, ca. 1810-1970", BASE + "/archives-of-michigan-map-collection/"),
|
|
47
|
+
("Corporation Annual Reports, 1997-2006", BASE + "/corporation-annual-reports/"),
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class ResultParser(HTMLParser):
|
|
52
|
+
"""Collect result-item blocks: first link href plus its text."""
|
|
53
|
+
|
|
54
|
+
def __init__(self) -> None:
|
|
55
|
+
super().__init__(convert_charrefs=True)
|
|
56
|
+
self.depth = 0
|
|
57
|
+
self.results: list[dict] = []
|
|
58
|
+
self.current: dict | None = None
|
|
59
|
+
self.in_link = False
|
|
60
|
+
self.link_text = ""
|
|
61
|
+
|
|
62
|
+
def handle_starttag(self, tag, attrs):
|
|
63
|
+
attrs = dict(attrs)
|
|
64
|
+
classes = attrs.get("class", "")
|
|
65
|
+
if tag == "div" and "result-item" in classes and self.depth == 0:
|
|
66
|
+
self.depth = 1
|
|
67
|
+
self.current = {"title": "", "url": ""}
|
|
68
|
+
return
|
|
69
|
+
if self.depth > 0:
|
|
70
|
+
if tag == "div":
|
|
71
|
+
self.depth += 1
|
|
72
|
+
elif tag == "a" and not self.current["url"]:
|
|
73
|
+
href = attrs.get("href", "")
|
|
74
|
+
if href:
|
|
75
|
+
self.current["url"] = href
|
|
76
|
+
self.in_link = True
|
|
77
|
+
self.link_text = ""
|
|
78
|
+
|
|
79
|
+
def handle_endtag(self, tag):
|
|
80
|
+
if self.depth > 0 and tag == "div":
|
|
81
|
+
self.depth -= 1
|
|
82
|
+
if self.depth == 0 and self.current:
|
|
83
|
+
self.current["title"] = " ".join(self.link_text.split()) or "(no title)"
|
|
84
|
+
if self.current["url"]:
|
|
85
|
+
self.results.append(self.current)
|
|
86
|
+
self.current = None
|
|
87
|
+
if tag == "a" and self.in_link:
|
|
88
|
+
self.in_link = False
|
|
89
|
+
|
|
90
|
+
def handle_data(self, data):
|
|
91
|
+
if self.in_link:
|
|
92
|
+
self.link_text += data
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class ItemMetadataParser(HTMLParser):
|
|
96
|
+
"""Parse Preservica item page title, Item Data fields, and download link."""
|
|
97
|
+
|
|
98
|
+
def __init__(self) -> None:
|
|
99
|
+
super().__init__(convert_charrefs=True)
|
|
100
|
+
self.in_h1 = False
|
|
101
|
+
self.title = ""
|
|
102
|
+
self.in_key = False
|
|
103
|
+
self.in_val = False
|
|
104
|
+
self.cur_key = ""
|
|
105
|
+
self.cur_val = ""
|
|
106
|
+
self.fields: list[tuple[str, str]] = []
|
|
107
|
+
self.download_url: str | None = None
|
|
108
|
+
|
|
109
|
+
def handle_starttag(self, tag, attrs):
|
|
110
|
+
attr_map = dict(attrs)
|
|
111
|
+
classes = attr_map.get("class", "")
|
|
112
|
+
if tag == "h1" and not self.title:
|
|
113
|
+
self.in_h1 = True
|
|
114
|
+
elif tag == "span" and "metadata-title" in classes:
|
|
115
|
+
self.in_key = True
|
|
116
|
+
self.cur_key = ""
|
|
117
|
+
elif tag == "span" and "metadata-content" in classes:
|
|
118
|
+
self.in_val = True
|
|
119
|
+
self.cur_val = ""
|
|
120
|
+
elif tag == "a":
|
|
121
|
+
href = attr_map.get("href", "")
|
|
122
|
+
if "/download/file/" in href and not self.download_url:
|
|
123
|
+
self.download_url = href
|
|
124
|
+
|
|
125
|
+
def handle_endtag(self, tag):
|
|
126
|
+
if tag == "h1" and self.in_h1:
|
|
127
|
+
self.in_h1 = False
|
|
128
|
+
elif tag == "span" and self.in_key:
|
|
129
|
+
self.in_key = False
|
|
130
|
+
elif tag == "span" and self.in_val:
|
|
131
|
+
self.in_val = False
|
|
132
|
+
key = " ".join(self.cur_key.split()).strip(":")
|
|
133
|
+
val = " ".join(self.cur_val.split())
|
|
134
|
+
if key:
|
|
135
|
+
self.fields.append((key, val))
|
|
136
|
+
|
|
137
|
+
def handle_data(self, data):
|
|
138
|
+
if self.in_h1:
|
|
139
|
+
self.title += data
|
|
140
|
+
elif self.in_key:
|
|
141
|
+
self.cur_key += data
|
|
142
|
+
elif self.in_val:
|
|
143
|
+
self.cur_val += data
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def _require_curl() -> str:
|
|
147
|
+
curl = shutil.which("curl")
|
|
148
|
+
if not curl:
|
|
149
|
+
raise click.ClickException("curl is required but was not found on PATH.")
|
|
150
|
+
return curl
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _curl_get_text(url: str) -> str:
|
|
154
|
+
curl = _require_curl()
|
|
155
|
+
try:
|
|
156
|
+
proc = subprocess.run(
|
|
157
|
+
[curl, "-sSL", "-A", USER_AGENT, "--max-time", "60", url],
|
|
158
|
+
capture_output=True,
|
|
159
|
+
text=True,
|
|
160
|
+
timeout=70,
|
|
161
|
+
)
|
|
162
|
+
except (subprocess.SubprocessError, OSError) as exc:
|
|
163
|
+
raise click.ClickException(f"Michiganology request failed: {exc}") from exc
|
|
164
|
+
if proc.returncode != 0:
|
|
165
|
+
raise click.ClickException(
|
|
166
|
+
f"Michiganology request failed (curl exit {proc.returncode}): "
|
|
167
|
+
f"{proc.stderr.strip()[:300]}"
|
|
168
|
+
)
|
|
169
|
+
return proc.stdout
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def _resolve_item_ref(url_or_id: str) -> tuple[str, str]:
|
|
173
|
+
"""Return (item_id, item_page_url) from a Preservica URL or IO_/SO_ identifier."""
|
|
174
|
+
raw = url_or_id.strip()
|
|
175
|
+
match = re.search(r"((?:IO|SO)_[A-Za-z0-9-]+)", raw)
|
|
176
|
+
if match:
|
|
177
|
+
item_id = match.group(1)
|
|
178
|
+
if raw.startswith("http://") or raw.startswith("https://"):
|
|
179
|
+
return item_id, raw
|
|
180
|
+
return item_id, f"{BASE}/uncategorized/{item_id}/"
|
|
181
|
+
if raw.startswith("http://") or raw.startswith("https://"):
|
|
182
|
+
return raw.rstrip("/").rsplit("/", 1)[-1], raw
|
|
183
|
+
raise click.UsageError(
|
|
184
|
+
"Pass a Michiganology item URL or a Preservica ID starting with IO_ or SO_."
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def _filename_from_headers(headers_text: str, fallback: str) -> str:
|
|
189
|
+
match_star = re.search(r"filename\*\s*=\s*UTF-8''([^\r\n;]+)", headers_text, re.I)
|
|
190
|
+
if match_star:
|
|
191
|
+
candidate = Path(unquote(match_star.group(1).strip().strip('"'))).name
|
|
192
|
+
if candidate:
|
|
193
|
+
return candidate
|
|
194
|
+
match_plain = re.search(r'filename\s*=\s*"?([^"\r\n;]+)"?', headers_text, re.I)
|
|
195
|
+
if match_plain:
|
|
196
|
+
candidate = Path(match_plain.group(1).strip()).name
|
|
197
|
+
if candidate:
|
|
198
|
+
return candidate
|
|
199
|
+
return fallback
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def fetch_search(query: str) -> str:
|
|
203
|
+
return _curl_get_text(f"{BASE}/?s={quote_plus(query)}")
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def total_results(page: str) -> int | None:
|
|
207
|
+
match = re.search(r"([\d,]+)\s+total results", page)
|
|
208
|
+
return int(match.group(1).replace(",", "")) if match else None
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
@click.group()
|
|
212
|
+
def cli() -> None:
|
|
213
|
+
"""Search Michiganology (Archives of Michigan digital collections)."""
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
@cli.command()
|
|
217
|
+
@click.argument("query")
|
|
218
|
+
@click.option("--limit", default=10, show_default=True, help="Max results to show (first page only).")
|
|
219
|
+
@click.option("--json", "as_json", is_flag=True, help="Emit JSON.")
|
|
220
|
+
def search(query: str, limit: int, as_json: bool) -> None:
|
|
221
|
+
"""Search all Michiganology collections, e.g. michiganology search Lincoln."""
|
|
222
|
+
page = fetch_search(query)
|
|
223
|
+
parser = ResultParser()
|
|
224
|
+
parser.feed(page)
|
|
225
|
+
total = total_results(page)
|
|
226
|
+
results = parser.results[:limit]
|
|
227
|
+
if as_json:
|
|
228
|
+
click.echo(json.dumps({"query": query, "total": total, "results": results}, indent=2))
|
|
229
|
+
return
|
|
230
|
+
click.echo(f"Query: {query} | Total results: {total if total is not None else 'unknown'}")
|
|
231
|
+
if not results:
|
|
232
|
+
click.echo("No results on the first page.")
|
|
233
|
+
return
|
|
234
|
+
for item in results:
|
|
235
|
+
click.echo(f"- {item['title']}\n {item['url']}")
|
|
236
|
+
click.echo(f"({len(results)} of {total} shown; first page only)")
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
@cli.command()
|
|
240
|
+
@click.argument("url_or_id")
|
|
241
|
+
@click.option("--json", "as_json", is_flag=True, help="Emit JSON.")
|
|
242
|
+
def get(url_or_id: str, as_json: bool) -> None:
|
|
243
|
+
"""Inspect a Michiganology item page (Item Data fields and file download URL)."""
|
|
244
|
+
item_id, item_url = _resolve_item_ref(url_or_id)
|
|
245
|
+
page = _curl_get_text(item_url)
|
|
246
|
+
parser = ItemMetadataParser()
|
|
247
|
+
parser.feed(page)
|
|
248
|
+
title = " ".join(parser.title.split()) or item_id
|
|
249
|
+
download_url = parser.download_url
|
|
250
|
+
if not download_url and item_id.startswith("IO_"):
|
|
251
|
+
download_url = f"{BASE}/download/file/{item_id}"
|
|
252
|
+
metadata: dict[str, str | list[str]] = {}
|
|
253
|
+
for key, val in parser.fields:
|
|
254
|
+
if key in metadata:
|
|
255
|
+
prev = metadata[key]
|
|
256
|
+
metadata[key] = [*prev, val] if isinstance(prev, list) else [prev, val]
|
|
257
|
+
else:
|
|
258
|
+
metadata[key] = val
|
|
259
|
+
payload = {
|
|
260
|
+
"id": item_id,
|
|
261
|
+
"title": title,
|
|
262
|
+
"url": item_url,
|
|
263
|
+
"download_url": download_url,
|
|
264
|
+
"metadata": metadata,
|
|
265
|
+
}
|
|
266
|
+
if as_json:
|
|
267
|
+
click.echo(json.dumps(payload, indent=2, ensure_ascii=False))
|
|
268
|
+
return
|
|
269
|
+
click.echo(f"Item {item_id}: {title}")
|
|
270
|
+
click.echo(f" URL: {item_url}")
|
|
271
|
+
if download_url:
|
|
272
|
+
click.echo(f" Download: {download_url}")
|
|
273
|
+
for key, val in parser.fields:
|
|
274
|
+
click.echo(f" {key}: {val}")
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
@cli.command()
|
|
278
|
+
@click.argument("url_or_id")
|
|
279
|
+
@click.option("--out", "-o", default=".", show_default=True, help="Output directory.")
|
|
280
|
+
@click.option("--filename", default=None, help="Override output filename (default: from Content-Disposition).")
|
|
281
|
+
def download(url_or_id: str, out: str, filename: str | None) -> None:
|
|
282
|
+
"""Download the full-resolution file for a Michiganology IO_ item."""
|
|
283
|
+
item_id, item_url = _resolve_item_ref(url_or_id)
|
|
284
|
+
if not item_id.startswith("IO_"):
|
|
285
|
+
raise click.ClickException(
|
|
286
|
+
f"{item_id} is a folder/collection object (SO_); pass an IO_ item URL or ID to download."
|
|
287
|
+
)
|
|
288
|
+
download_url = f"{BASE}/download/file/{item_id}"
|
|
289
|
+
curl = _require_curl()
|
|
290
|
+
out_dir = Path(out)
|
|
291
|
+
out_dir.mkdir(parents=True, exist_ok=True)
|
|
292
|
+
with tempfile.TemporaryDirectory() as tmp_dir:
|
|
293
|
+
hdr_path = Path(tmp_dir) / "headers.txt"
|
|
294
|
+
body_path = Path(tmp_dir) / "body.bin"
|
|
295
|
+
try:
|
|
296
|
+
proc = subprocess.run(
|
|
297
|
+
[
|
|
298
|
+
curl, "-sSL", "-A", USER_AGENT, "--max-time", "120",
|
|
299
|
+
"-D", str(hdr_path), "-o", str(body_path),
|
|
300
|
+
"-w", "%{http_code}", download_url,
|
|
301
|
+
],
|
|
302
|
+
capture_output=True,
|
|
303
|
+
text=True,
|
|
304
|
+
timeout=130,
|
|
305
|
+
)
|
|
306
|
+
except (subprocess.SubprocessError, OSError) as exc:
|
|
307
|
+
raise click.ClickException(f"Michiganology download failed: {exc}") from exc
|
|
308
|
+
if proc.returncode != 0:
|
|
309
|
+
raise click.ClickException(
|
|
310
|
+
f"Michiganology download failed (curl exit {proc.returncode}): "
|
|
311
|
+
f"{proc.stderr.strip()[:300]}"
|
|
312
|
+
)
|
|
313
|
+
status = proc.stdout.strip()
|
|
314
|
+
if status != "200":
|
|
315
|
+
raise click.ClickException(
|
|
316
|
+
f"Michiganology download returned HTTP {status} for {download_url} (source page: {item_url})"
|
|
317
|
+
)
|
|
318
|
+
headers_text = hdr_path.read_text(encoding="utf-8", errors="replace")
|
|
319
|
+
chosen_name = filename or _filename_from_headers(headers_text, f"{item_id}.bin")
|
|
320
|
+
dest = out_dir / Path(chosen_name).name
|
|
321
|
+
dest.write_bytes(body_path.read_bytes())
|
|
322
|
+
click.echo(f"{dest} ({dest.stat().st_size} bytes)")
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
@cli.command()
|
|
326
|
+
@click.option("--json", "as_json", is_flag=True, help="Emit JSON.")
|
|
327
|
+
def collections(as_json: bool) -> None:
|
|
328
|
+
"""List the Michiganology digital collections (verified 2026-11-24)."""
|
|
329
|
+
if as_json:
|
|
330
|
+
click.echo(json.dumps(
|
|
331
|
+
[{"name": name, "url": url} for name, url in COLLECTIONS], indent=2
|
|
332
|
+
))
|
|
333
|
+
return
|
|
334
|
+
for name, url in COLLECTIONS:
|
|
335
|
+
click.echo(f"- {name}\n {url}")
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
@cli.command()
|
|
339
|
+
@click.argument("query")
|
|
340
|
+
def url(query: str) -> None:
|
|
341
|
+
"""Print the shareable Michiganology search URL for a query."""
|
|
342
|
+
click.echo(f"{BASE}/?s={quote_plus(query)}")
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
if __name__ == "__main__":
|
|
346
|
+
cli()
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: missouri-archives
|
|
3
|
+
description: Search Missouri State Archives vital records through the bundled `mo-archives` CLI: Missouri Death Certificates 1910-1975 with certificate images, and the pre-1910 Birth and Death Records Database with full abstracts. Also gives the browser-only path for Missouri Digital Heritage collections (soldiers, land patents, naturalization, newspapers, plat books) and the State Historical Society of Missouri. Use when tracing ancestors in Missouri, finding a Missouri death certificate or pre-1910 birth or death abstract, or deciding whether a Missouri record is online, orderable, or visit-only.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Missouri Archives
|
|
7
|
+
|
|
8
|
+
This skill includes a standalone executable Python CLI at `skills/missouri-archives/scripts/mo-archives` 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. Run it from the repo root with `uv` on `PATH`.
|
|
9
|
+
|
|
10
|
+
## Bundled CLI (`scripts/mo-archives`)
|
|
11
|
+
|
|
12
|
+
### Search death certificates, 1910-1975
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Search death certificates by name and year
|
|
16
|
+
skills/missouri-archives/scripts/mo-archives death --last Clemens --first Samuel --begin-year 1910 --end-year 1920
|
|
17
|
+
|
|
18
|
+
# All deaths for a surname in a county and decade, as JSON
|
|
19
|
+
skills/missouri-archives/scripts/mo-archives death --last Clemens --county Marion --begin-year 1910 --end-year 1939 --json
|
|
20
|
+
|
|
21
|
+
# Search by a parent's name (1953-1975 certificates only, see below)
|
|
22
|
+
skills/missouri-archives/scripts/mo-archives death --last Clemens --role father --begin-year 1953 --end-year 1975
|
|
23
|
+
|
|
24
|
+
# Download the certificate PDFs for the hits
|
|
25
|
+
skills/missouri-archives/scripts/mo-archives death --last Clemens --county Marion --begin-year 1910 --end-year 1920 --download ./downloads/mo-certs
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Options: `--first`, `--middle`, `--role deceased|spouse|father|mother` (default deceased), `--match contains|starts-with|ends-with` (default contains, applied to every name field given), `--county` (spelled as on the site, default all counties), `--begin-year` / `--end-year` (default 1910-1975), `--begin-month` / `--end-month` (1-12, 0 means all, default 0), `--limit` (default 50, one results page), `--json`, `--download DIR`.
|
|
29
|
+
|
|
30
|
+
### Search pre-1910 births and deaths
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Deaths before 1910 (abstracts, no images)
|
|
34
|
+
skills/missouri-archives/scripts/mo-archives pre1910 --type death --name Clemens
|
|
35
|
+
|
|
36
|
+
# Births before 1910, in one county
|
|
37
|
+
skills/missouri-archives/scripts/mo-archives pre1910 --type birth --name Clemens --county Marion --json
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Options: `--type birth|death` (default death), `--name` (required; the site recommends last name only), `--county` (default all counties), `--limit` (default 50), `--json`.
|
|
41
|
+
|
|
42
|
+
### Fetch a pre-1910 full abstract
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
skills/missouri-archives/scripts/mo-archives detail <detail-id>
|
|
46
|
+
skills/missouri-archives/scripts/mo-archives detail <detail-id-1> <detail-id-2> --json
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Takes one or more detail IDs from `pre1910` output. Returns county, microfilm roll and page, dates, birthplace, cause of death, and the other abstract fields.
|
|
50
|
+
|
|
51
|
+
### Download certificate PDFs by image URL
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
skills/missouri-archives/scripts/mo-archives download "https://www.sos.mo.gov/images/archives/deathcerts/<year>/<filename>.PDF" --out ./downloads/mo-certs
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Always take the image URL from `death` output. The PDF filename is not derivable from the certificate number, so do not construct it by hand.
|
|
58
|
+
|
|
59
|
+
### Missouri Digital Heritage (browser only)
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
skills/missouri-archives/scripts/mo-archives mdh
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Prints the MDH home page, Advanced Search, and Archives URLs. MDH has no verified machine interface; do the search in the browser.
|
|
66
|
+
|
|
67
|
+
## Verified interface (verified live 2026-11-24)
|
|
68
|
+
|
|
69
|
+
- Portal: https://www.sos.mo.gov/mdh. Missouri State Archives: https://www.sos.mo.gov/archives. Address: 600 West Main Street, Jefferson City, MO 65102. Research room open Monday-Friday 8:00 AM-5:00 PM. Email archref@sos.mo.gov.
|
|
70
|
+
- MDH home page states that more than 9 million records can be accessed through it, including the collections of the Archives, the State Library, and other institutions across the state. No login or subscription is required.
|
|
71
|
+
- Both vital-records databases are plain HTML POST forms on `s1.sos.mo.gov`, no API and no key. The CLI GETs the form page first (session cookies plus the `__ncforminfo` token), then POSTs the search. The POST also succeeds without the token, but the CLI sends it when the page provides one.
|
|
72
|
+
- A browser User-Agent is required. Direct curl with the default User-Agent returns 403 on `sos.mo.gov` (bot protection, not an outage); with a browser User-Agent the same requests return 200. The CLI sends a Chrome User-Agent on every request.
|
|
73
|
+
- Death Certificates search posts to `https://s1.sos.mo.gov/records/Archives/ArchivesMvc/` with fields `DeathCertNameSearchType` (Deceased/Spouse/Father/Mother), `LastName`, `FirstName`, `MiddleName`, `LNSearchMethod` / `FNSearchMethod` / `MNSearchMethod` (Contains/StartsWith/EndsWith), `BeginMonth` / `BeginYear`, `EndMonth` / `EndYear`, `CountyName` (`-- Search All --` for all counties), `Search`. Years are required in practice: an empty year range silently returns no results (verified live).
|
|
74
|
+
- Results are paged 50 per page in the cookie session. The CLI follows the session pager (`DeathCertificates/Results?PageNumber=N&recordsPerPage=50`, same pattern for `birthdeath/Results`) until `--limit` or the total is reached. The total comes from the page text `Showing records 1 to 50 of N`.
|
|
75
|
+
- Death result columns: Name, Age, Date of Death, County, Certificate Number, Last Four SSN, Image. The image is a direct PDF link, `https://www.sos.mo.gov/images/archives/deathcerts/<year>/<file>.PDF`, and downloads with a plain GET (verified live).
|
|
76
|
+
- Pre-1910 search posts to `https://s1.sos.mo.gov/records/archives/ArchivesMVC/birthdeath/` with `BirthCounty` / `BirthNameSearch` / `BirthSubmit` or `DeathCounty` / `DeathNameSearch` / `DeathSubmit` (`-- All Counties --` for all counties). Death columns: Name, Age, Sex, Color, Date Of Death, County, Details. Birth columns: Name, Place, County, Date, Father, Mother, Attendant, Details. Details links are `Detail?id=<n>` on the same path; the detail page gives county, roll number, page, number, dates, birthplace, cause of death, and related fields.
|
|
77
|
+
- MDH Advanced Search is hosted at https://mdh.deepwebaccess.com/mdh/ (linked from the MDH home page). No stable GET search URL for it was verified; do not invent one. The MDH digital collections run on CONTENTdm (`cdm16795.contentdm.oclc.org`); a direct request to its `dmwebservices` query endpoint returned 403 (Cloudflare) on 2026-11-24, so the CLI does not use it.
|
|
78
|
+
- Inferred, not verified: the county lists in the forms are taken as given by the site; the CLI passes any county string through and lets the site validate it.
|
|
79
|
+
|
|
80
|
+
## What is searchable online
|
|
81
|
+
|
|
82
|
+
- Missouri Death Certificates, 1910-1975: https://s1.sos.mo.gov/records/Archives/ArchivesMvc/DeathCertificates/. Search by first, middle, and last name, county, year, and month. Digitized images of the original certificates link directly from the results. Spouse, father, and mother name search is available for 1953-1975 (the page says 1953-1975 in one place and 1954-1975 in another; try both ranges when searching parents). Death certificates are closed for 50 years before transfer to the Archives, which is why the online run advances one year at a time. A certificate typically gives date and place of birth, parents' names, spouse, cause of death, occupation, funeral home, and burial place.
|
|
83
|
+
- Missouri Birth and Death Records Database, Pre-1910: https://s1.sos.mo.gov/records/archives/ArchivesMVC/birthdeath/. An abstract of birth, stillbirth, and death records recorded before 1909, transcribed by volunteers from microfilm. Over 185,000 records from 87 counties. Coverage is incomplete because statewide reporting was not required before 1910. Search by all or part of a name; the site recommends entering just the last name. A birth search can match on a parent's name as well as the child's, so check the Father and Mother columns before counting a hit. All records for a county can be listed by selecting the county and leaving the name blank. For a death before 1910, this is the first check; for a birth, remember the abstract gives date, place, parents, and attendant, not a certificate image.
|
|
84
|
+
- Soldiers' Records, War of 1812-World War I. Nearly 1.5 million pages of service cards, muster rolls, special orders, and reports. Also on MDH: World War I Biography and Service Records. Browser only.
|
|
85
|
+
- Land Patent Records, 1820-1969 (the Archives' land patents run 1831-1969 in some listings; use the database's own date range when searching). Browser only.
|
|
86
|
+
- Naturalization Records, 1816-1955. Browser only.
|
|
87
|
+
- Coroner's Inquest Database, Judicial Records, Supreme Court Historical Records, Missouri State Penitentiary records, and Census Records and Tax Lists. Browser only; the death-certificate and pre-1910 databases above are the two whose URLs and machine interfaces were verified live.
|
|
88
|
+
- Missouri County History Project, Missouri County Plat Books, Missouri City Directories, and Missouri Newspapers, all through MDH. Plat books show landowner names on each parcel and place a family on the map between censuses. The Local Records Program's County and Municipal Records Database tells which county books are available on microfilm at the Archives. Browser only.
|
|
89
|
+
|
|
90
|
+
## What is in-person or order-only
|
|
91
|
+
|
|
92
|
+
- The Archives cannot issue certified copies of vital records. For certified copies of births or deaths filed after 1909, contact the Missouri Bureau of Vital Records at 573-751-6387.
|
|
93
|
+
- County records on microfilm, court files, and un-digitized collections require a visit or a reference request to archref@sos.mo.gov.
|
|
94
|
+
- The State Historical Society of Missouri (SHSMO, shsmo.org, digital collections at digital.shsmo.org) holds Missouri newspapers from about 1800, manuscripts, maps, and finding aids. Its research centers are FamilySearch Affiliate Libraries, giving in-person visitors access to otherwise restricted FamilySearch collections. Check SHSMO when MDH has no newspaper or manuscript hit.
|
|
95
|
+
|
|
96
|
+
## Research workflow
|
|
97
|
+
|
|
98
|
+
1. For a Missouri death between 1910 and 1975, search the Death Certificates database by surname, county if known, and year range. Open the linked certificate PDF and record parents' names, birthplace, spouse, burial place, and informant; the informant is often a close relative.
|
|
99
|
+
2. For a death or birth before 1910, search the pre-1910 Birth and Death Records database by surname only, then fetch the detail abstract with `mo-archives detail <id>` to confirm county, microfilm roll, and page before ordering microfilm or visiting. Note the pre-1910 index can list the same person twice from overlapping abstracts; check the detail page before counting two entries as two people.
|
|
100
|
+
3. For landowners, follow up in the Land Patent Records and Missouri County Plat Books on MDH in the browser, and cross-check federal patents with the `blm-glo` skill.
|