@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.
Files changed (101) 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/ops/audit.d.ts +138 -0
  50. package/dist/commands/ops/audit.d.ts.map +1 -0
  51. package/dist/commands/ops/audit.js +867 -0
  52. package/dist/commands/ops/audit.js.map +1 -0
  53. package/dist/commands/ops/context.d.ts +100 -0
  54. package/dist/commands/ops/context.d.ts.map +1 -0
  55. package/dist/commands/ops/context.js +917 -0
  56. package/dist/commands/ops/context.js.map +1 -0
  57. package/dist/commands/ops/help.d.ts +6 -0
  58. package/dist/commands/ops/help.d.ts.map +1 -0
  59. package/dist/commands/ops/help.js +74 -0
  60. package/dist/commands/ops/help.js.map +1 -0
  61. package/dist/commands/ops/index.d.ts +6 -0
  62. package/dist/commands/ops/index.d.ts.map +1 -0
  63. package/dist/commands/ops/index.js +6 -0
  64. package/dist/commands/ops/index.js.map +1 -0
  65. package/dist/commands/ops/integrate.d.ts +56 -0
  66. package/dist/commands/ops/integrate.d.ts.map +1 -0
  67. package/dist/commands/ops/integrate.js +872 -0
  68. package/dist/commands/ops/integrate.js.map +1 -0
  69. package/dist/commands/ops/sync.d.ts +177 -0
  70. package/dist/commands/ops/sync.d.ts.map +1 -0
  71. package/dist/commands/ops/sync.js +1078 -0
  72. package/dist/commands/ops/sync.js.map +1 -0
  73. package/dist/commands/ops/telemetry.d.ts +79 -0
  74. package/dist/commands/ops/telemetry.d.ts.map +1 -0
  75. package/dist/commands/ops/telemetry.js +249 -0
  76. package/dist/commands/ops/telemetry.js.map +1 -0
  77. package/dist/commands/records/help.d.ts +18 -0
  78. package/dist/commands/records/help.d.ts.map +1 -0
  79. package/dist/commands/records/help.js +174 -0
  80. package/dist/commands/records/help.js.map +1 -0
  81. package/dist/commands/records/index.d.ts +5 -0
  82. package/dist/commands/records/index.d.ts.map +1 -0
  83. package/dist/commands/records/index.js +5 -0
  84. package/dist/commands/records/index.js.map +1 -0
  85. package/dist/commands/records/registry.d.ts +32 -0
  86. package/dist/commands/records/registry.d.ts.map +1 -0
  87. package/dist/commands/records/registry.js +227 -0
  88. package/dist/commands/records/registry.js.map +1 -0
  89. package/dist/commands/records/resolve.d.ts +14 -0
  90. package/dist/commands/records/resolve.d.ts.map +1 -0
  91. package/dist/commands/records/resolve.js +61 -0
  92. package/dist/commands/records/resolve.js.map +1 -0
  93. package/dist/commands/records/runner.d.ts +25 -0
  94. package/dist/commands/records/runner.d.ts.map +1 -0
  95. package/dist/commands/records/runner.js +224 -0
  96. package/dist/commands/records/runner.js.map +1 -0
  97. package/dist/index.d.ts +2 -0
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/index.js +2 -0
  100. package/dist/index.js.map +1 -1
  101. package/package.json +3 -3
@@ -0,0 +1,90 @@
1
+ ---
2
+ name: openarchieven
3
+ description: Search and inspect Dutch and Belgian genealogical archives via the bundled uv-based `openarchieven` CLI or the public OpenArchieven 1.0 JSON API (`api.openarch.nl`). Covers Dutch civil registration (`BS Geboorte`, `BS Huwelijk`, `BS Overlijden`), municipal population registers (`Bevolkingsregisters`), DTB parish registers, and Rotterdam Holland America Line passenger lists (`Passagiersregisters`). Use when researching Dutch or Belgian ancestors, tracing emigrants departing Rotterdam, or verifying primary vital records across Netherlands regional archives.
4
+ ---
5
+
6
+ # OpenArchieven
7
+
8
+ This skill includes a standalone executable Python CLI at `skills/openarchieven/scripts/openarchieven` using a PEP 723 `#!/usr/bin/env -S uv run --script` shebang with inline dependencies (`click`, `httpx`). No virtualenv setup, account, or API key is required for read queries.
9
+
10
+ OpenArchieven (`https://www.openarchieven.nl/`) aggregates hundreds of millions of indexed person mentions from Dutch and Belgian municipal and regional archives (including Brabants Historisch Informatie Centrum, West-Brabants Archief, Stadsarchief Rotterdam, Stadsarchief Amsterdam, Zeeuws Archief, Regionaal Historisch Centrum Eindhoven, and Gelders Archief).
11
+
12
+ ## Bundled CLI (`scripts/openarchieven`)
13
+
14
+ Path: `skills/openarchieven/scripts/openarchieven`
15
+
16
+ ### Search records
17
+
18
+ ```bash
19
+ # Search by person name, place, and year (Vincent van Gogh's 1853 Zundert birth)
20
+ skills/openarchieven/scripts/openarchieven search --name "Vincent van Gogh" --place Zundert --year 1853
21
+
22
+ # Filter by Dutch civil registration source type or event type
23
+ skills/openarchieven/scripts/openarchieven search --name "Vincent van Gogh" --event-type "BS Geboorte" --place Zundert
24
+ skills/openarchieven/scripts/openarchieven search --name "Johannes Vermeer" --event-type Overlijden --limit 5
25
+
26
+ # Search municipal population registers (Bevolkingsregisters)
27
+ skills/openarchieven/scripts/openarchieven search --name "Vincent van Gogh" --source-type Bevolkingsregister --limit 10
28
+
29
+ # Search Holland America Line passenger lists at Stadsarchief Rotterdam (archive code: srt)
30
+ skills/openarchieven/scripts/openarchieven search --name "van Dijk" --source-type Passagiersregisters --archive srt --limit 5
31
+
32
+ # Year range filter and full JSON output
33
+ skills/openarchieven/scripts/openarchieven search --name "Vincent van Gogh" --year 1850-1855 --json
34
+ ```
35
+
36
+ `search` also accepts a positional name (`openarchieven search "Vincent van Gogh" --place Zundert`).
37
+
38
+ ### Inspect one full record (`show`)
39
+
40
+ ```bash
41
+ # By archive code and UUID from search output
42
+ skills/openarchieven/scripts/openarchieven show bhi 78a37833-d731-ffe5-184c-f9f424826871
43
+
44
+ # Or by compact archive:uuid token or full OpenArchieven URL
45
+ skills/openarchieven/scripts/openarchieven show "bhi:78a37833-d731-ffe5-184c-f9f424826871"
46
+ skills/openarchieven/scripts/openarchieven show "https://www.openarchieven.nl/bhi:78a37833-d731-ffe5-184c-f9f424826871" --json
47
+ ```
48
+
49
+ `show` queries `show.json` and parses the returned A2A (Archives-to-Archives) record: source type, archive institution, inventory/book/document numbers, event date and place, every person named on the deed with their role (`Kind`, `Vader`, `Moeder`, `Bruid`, `Bruidegom`, `Overledene`, `Geregistreerde`), scan image URLs, and the digital original link.
50
+
51
+ ### Build a shareable website URL offline
52
+
53
+ ```bash
54
+ skills/openarchieven/scripts/openarchieven url --name "Vincent van Gogh" --place Zundert --year 1853
55
+ skills/openarchieven/scripts/openarchieven url --record "bhi:78a37833-d731-ffe5-184c-f9f424826871"
56
+ ```
57
+
58
+ ## API rules and quirks (verified live 2026-11-25)
59
+
60
+ - **Search endpoint:** `GET https://api.openarch.nl/1.0/records/search.json`
61
+ - **Record detail endpoint:** `GET https://api.openarch.nl/1.0/records/show.json?archive=<code>&identifier=<uuid>`
62
+ - **Auth:** none for read methods (`search.json`, `show.json`). Only comment write endpoints require an API key.
63
+ - **Rate limit:** 4 requests per second per IP address. The CLI sleeps 0.25 s per request and sends a `kinloom` User-Agent header.
64
+ - **Year and range filtering:** OpenArchieven's `search.json` ignores `eventyear=`, `year=`, and `period=` parameters. Pass a single year (`1853`) or range (`1850-1860`) inside the `name` query string (the CLI appends `--year` to `name` automatically).
65
+ - **Archive code parameter on v1.0:** Pass the short `archive_code` (such as `bhi`, `wba`, `srt`, `rhe`, `saa`, `zal`), not the full institution name, to `archive=` on both `1.0/records/search.json` and `1.0/records/show.json`. (OpenArchieven's newer OpenAPI spec documents `archive_code` for v1.1, while v1.0 reads `archive`.)
66
+ - **`sourcetype` vs `eventtype`:** Civil registration categories such as `BS Geboorte`, `BS Huwelijk`, `BS Overlijden`, `Bevolkingsregister`, and `Passagiersregisters` belong in `sourcetype`, while event verbs such as `Geboorte`, `Huwelijk`, `Overlijden`, `Registratie`, and `Vertrek` belong in `eventtype`. The CLI routes `BS ...`, `DTB ...`, and known source-type labels passed via `--event-type` to `sourcetype` automatically so queries do not silently return zero hits.
67
+ - **Error signaling:** Invalid archive codes or identifiers can return HTTP 200 with `{"error_code": 1, "error_description": "Invalid archive"}`; the CLI checks for `error_code` and exits non-zero.
68
+ - **Paging cap:** `number_show` accepts up to 100 rows per call; `start` accepts offsets up to 10,000.
69
+
70
+ ## Key Dutch record types for genealogy
71
+
72
+ | Source type | Dutch label | Typical coverage | Value |
73
+ |---|---|---|---|
74
+ | Civil birth | `BS Geboorte` | 1811 to ~1925 (100-year privacy rule) | Exact birth date/time, place, parents' names, father's occupation and age |
75
+ | Civil marriage | `BS Huwelijk` | 1811 to ~1950 (75-year privacy rule) | Bride/groom ages, birthplaces, occupations, and both sets of parents |
76
+ | Civil death | `BS Overlijden` | 1811 to ~1975 (50-year privacy rule) | Death date, age, spouse, and parents' names |
77
+ | Population register | `Bevolkingsregister` | ca. 1850 to 1939 | Household composition, birth dates/places, religion, moves in and out (including emigration dates) |
78
+ | Parish registers (pre-1811) | `DTB Dopen`, `DTB Trouwen`, `DTB Begraven` | ca. 1580 to 1811 | Baptisms, marriage banns, and burials before civil registration |
79
+ | Passenger lists | `Passagiersregisters` | late 1800s to 1969 | Holland America Line departures at Stadsarchief Rotterdam (`srt`), ship name, departure date, destination |
80
+
81
+ ## Research workflow notes
82
+
83
+ - **Search two people at once with `&`:** OpenArchieven supports combining two names in `--name`, such as `"Theodorus van Gogh & Anna Cornelia Carbentus"`, to pull every civil record naming a married couple together.
84
+ - **Mind Dutch tussenvoegsels and patronymics:** Prefixes (`van`, `van der`, `de`, `den`) are indexed alongside the surname; pre-1811 DTB records often index people by patronymic rather than a fixed surname (for example, 17th-century Leiden records before hereditary surnames became mandatory in 1811).
85
+ - **Follow `Bevolkingsregisters` across municipalities:** When a civil record shows a move or emigration, inspect the household entry with `show` to capture destination columns (`vertrokken naar`) before checking Rotterdam `Passagiersregisters` (`--archive srt`).
86
+ - **Verify against the original scan:** Indexed A2A transcripts occasionally misread handwritten dates or ages; open the `a2a_SourceAvailableScans` or `Original` URL from `show` before treating a date as final.
87
+
88
+ ## Environment variables
89
+
90
+ None. No key or account is needed for OpenArchieven read queries.
@@ -0,0 +1,432 @@
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 and inspect Dutch and Belgian genealogical records via OpenArchieven.
10
+
11
+ Uses the public OpenArchieven 1.0 JSON API (https://api.openarch.nl/1.0/records/):
12
+ no API key or login is required for read access. Requests are spaced to respect
13
+ the 4 requests/second IP rate limit.
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ import json
19
+ import re
20
+ import time
21
+ from typing import Any
22
+ from urllib.parse import urlencode
23
+
24
+ import click
25
+ import httpx
26
+
27
+ API_BASE = "https://api.openarch.nl/1.0/records"
28
+ WEB_BASE = "https://www.openarchieven.nl"
29
+ USER_AGENT = "kinloom/1.0 (genealogy research; https://github.com/tiberriver256/kinloom)"
30
+ MIN_INTERVAL_S = 0.25
31
+ TIMEOUT = 30.0
32
+
33
+ KNOWN_SOURCE_TYPES = {
34
+ "bevolkingsregister",
35
+ "passagiersregisters",
36
+ "notariële archieven",
37
+ "militieregisters",
38
+ "bidprentjes",
39
+ "familienamen",
40
+ "gezinskaarten",
41
+ "persoonskaarten",
42
+ "woningkaarten",
43
+ "memorie van successie",
44
+ }
45
+
46
+
47
+ def _fail(message: str) -> None:
48
+ click.echo(message, err=True)
49
+ raise SystemExit(1)
50
+
51
+
52
+ def _get_json(endpoint: str, params: dict[str, Any]) -> Any:
53
+ """Fetch one JSON response from api.openarch.nl with boundary validation."""
54
+ time.sleep(MIN_INTERVAL_S)
55
+ url = f"{API_BASE}/{endpoint}"
56
+ try:
57
+ with httpx.Client(
58
+ timeout=TIMEOUT,
59
+ follow_redirects=True,
60
+ headers={"User-Agent": USER_AGENT, "Accept": "application/json"},
61
+ ) as client:
62
+ resp = client.get(url, params=params)
63
+ except httpx.HTTPError as exc:
64
+ _fail(f"OpenArchieven request failed: {exc}")
65
+ if resp.status_code != 200:
66
+ _fail(f"HTTP {resp.status_code} from {url}")
67
+ try:
68
+ data = resp.json()
69
+ except ValueError as exc:
70
+ _fail(f"Invalid JSON from {url}: {exc}")
71
+ if isinstance(data, dict) and data.get("error_code") is not None:
72
+ desc = data.get("error_description") or data.get("error") or "Unknown API error"
73
+ _fail(f"OpenArchieven API error {data['error_code']}: {desc}")
74
+ return data
75
+
76
+
77
+ def _is_source_type(value: str) -> bool:
78
+ low = value.strip().lower()
79
+ return low.startswith("bs ") or low.startswith("dtb ") or low in KNOWN_SOURCE_TYPES
80
+
81
+
82
+ def _fmt_eventdate(date_obj: Any) -> str:
83
+ if not isinstance(date_obj, dict):
84
+ return ""
85
+ year = date_obj.get("year")
86
+ month = date_obj.get("month")
87
+ day = date_obj.get("day")
88
+ if year is None:
89
+ return ""
90
+ if month and day:
91
+ return f"{int(year):04d}-{int(month):02d}-{int(day):02d}"
92
+ if month:
93
+ return f"{int(year):04d}-{int(month):02d}"
94
+ return f"{int(year):04d}"
95
+
96
+
97
+ def _a2a_text(node: Any) -> str:
98
+ """Unwrap OpenArchieven's nested A2A JSON single-key string wrappers."""
99
+ if node is None:
100
+ return ""
101
+ if isinstance(node, str):
102
+ return node.strip()
103
+ if isinstance(node, (int, float)):
104
+ return str(node)
105
+ if isinstance(node, dict):
106
+ for key, val in node.items():
107
+ if isinstance(val, (str, int, float)):
108
+ return str(val).strip()
109
+ if isinstance(val, dict) and key in val:
110
+ return _a2a_text(val[key])
111
+ for val in node.values():
112
+ found = _a2a_text(val)
113
+ if found:
114
+ return found
115
+ return ""
116
+
117
+
118
+ def _as_list(val: Any) -> list[Any]:
119
+ if val is None:
120
+ return []
121
+ return val if isinstance(val, list) else [val]
122
+
123
+
124
+ def _fmt_a2a_date(date_node: Any) -> str:
125
+ if not isinstance(date_node, dict):
126
+ return _a2a_text(date_node)
127
+ year = _a2a_text(date_node.get("a2a_Year"))
128
+ month = _a2a_text(date_node.get("a2a_Month"))
129
+ day = _a2a_text(date_node.get("a2a_Day"))
130
+ if year and month and day:
131
+ try:
132
+ return f"{int(year):04d}-{int(month):02d}-{int(day):02d}"
133
+ except ValueError:
134
+ pass
135
+ if year and month:
136
+ try:
137
+ return f"{int(year):04d}-{int(month):02d}"
138
+ except ValueError:
139
+ pass
140
+ if year:
141
+ return year
142
+ return _a2a_text(date_node.get("a2a_LiteralDate"))
143
+
144
+
145
+ def _fmt_a2a_person_name(name_node: Any) -> str:
146
+ if not isinstance(name_node, dict):
147
+ return _a2a_text(name_node)
148
+ parts = [
149
+ _a2a_text(name_node.get("a2a_PersonNameFirstName")),
150
+ _a2a_text(name_node.get("a2a_PersonNamePatronym")),
151
+ _a2a_text(name_node.get("a2a_PersonNamePrefixLastName")),
152
+ _a2a_text(name_node.get("a2a_PersonNameLastName")),
153
+ ]
154
+ return " ".join(p for p in parts if p)
155
+
156
+
157
+ def _parse_record_ref(archive: str, identifier: str | None) -> tuple[str, str]:
158
+ """Accept either (archive, identifier), 'archive:identifier', or an openarchieven.nl URL."""
159
+ if identifier:
160
+ return archive.strip(), identifier.strip()
161
+ match = re.search(r"openarchieven\.nl/([a-z0-9_-]+):([A-Za-z0-9-]+)", archive, re.I)
162
+ if match:
163
+ return match.group(1), match.group(2)
164
+ if ":" in archive:
165
+ code, ident = archive.split(":", 1)
166
+ if code.strip() and ident.strip():
167
+ return code.strip(), ident.strip()
168
+ raise click.UsageError(
169
+ "Pass ARCHIVE and IDENTIFIER, an 'archive:uuid' token, or an openarchieven.nl record URL."
170
+ )
171
+
172
+
173
+ def _format_a2a_record(archive: str, identifier: str, record: dict[str, Any]) -> str:
174
+ lines = [
175
+ f"Record: {archive}:{identifier}",
176
+ f" URL: {WEB_BASE}/{archive}:{identifier}",
177
+ ]
178
+ source = record.get("a2a_Source") or {}
179
+ source_type = _a2a_text(source.get("a2a_SourceType"))
180
+ source_place = _a2a_text((source.get("a2a_SourcePlace") or {}).get("a2a_Place"))
181
+ ref = source.get("a2a_SourceReference") or {}
182
+ inst = _a2a_text(ref.get("a2a_InstitutionName"))
183
+ book = _a2a_text(ref.get("a2a_Book"))
184
+ collection = _a2a_text(ref.get("a2a_Collection"))
185
+ doc_num = _a2a_text(ref.get("a2a_DocumentNumber"))
186
+ archive_num = _a2a_text(ref.get("a2a_Archive"))
187
+ reg_num = _a2a_text(ref.get("a2a_RegistryNumber"))
188
+
189
+ if source_type:
190
+ lines.append(f" Source type: {source_type}")
191
+ if inst:
192
+ lines.append(f" Institution: {inst}")
193
+ if source_place:
194
+ lines.append(f" Source place: {source_place}")
195
+ ref_parts = [
196
+ f"Archive {archive_num}" if archive_num else "",
197
+ f"Registry {reg_num}" if reg_num else "",
198
+ book,
199
+ collection,
200
+ f"Document {doc_num}" if doc_num else "",
201
+ ]
202
+ ref_line = " | ".join(p for p in ref_parts if p)
203
+ if ref_line:
204
+ lines.append(f" Reference: {ref_line}")
205
+
206
+ events = _as_list(record.get("a2a_Event"))
207
+ for ev in events:
208
+ if not isinstance(ev, dict):
209
+ continue
210
+ ev_type = _a2a_text(ev.get("a2a_EventType"))
211
+ ev_date = _fmt_a2a_date(ev.get("a2a_EventDate"))
212
+ ev_place = _a2a_text((ev.get("a2a_EventPlace") or {}).get("a2a_Place"))
213
+ summary = " | ".join(p for p in (ev_type, ev_date, ev_place) if p)
214
+ if summary:
215
+ lines.append(f" Event: {summary}")
216
+
217
+ roles_by_pid: dict[str, list[str]] = {}
218
+ for rel in _as_list(record.get("a2a_RelationEP")):
219
+ if not isinstance(rel, dict):
220
+ continue
221
+ pid = _a2a_text(rel.get("a2a_PersonKeyRef"))
222
+ role = _a2a_text(rel.get("a2a_RelationType"))
223
+ if pid and role:
224
+ roles_by_pid.setdefault(pid, []).append(role)
225
+
226
+ persons = _as_list(record.get("a2a_Person"))
227
+ if persons:
228
+ lines.append(" Persons:")
229
+ for person in persons:
230
+ if not isinstance(person, dict):
231
+ continue
232
+ pid = str(person.get("pid") or "")
233
+ name = _fmt_a2a_person_name(person.get("a2a_PersonName")) or "(unnamed)"
234
+ role_str = ", ".join(roles_by_pid.get(pid, []))
235
+ bdate = _fmt_a2a_date(person.get("a2a_BirthDate"))
236
+ bplace = _a2a_text((person.get("a2a_BirthPlace") or {}).get("a2a_Place"))
237
+ res = _a2a_text((person.get("a2a_Residence") or {}).get("a2a_Place"))
238
+ occ = _a2a_text(person.get("a2a_Profession"))
239
+ details = []
240
+ if role_str:
241
+ details.append(role_str)
242
+ if bdate or bplace:
243
+ details.append("b. " + ", ".join(p for p in (bdate, bplace) if p))
244
+ if res:
245
+ details.append(f"res. {res}")
246
+ if occ:
247
+ details.append(f"occ. {occ}")
248
+ suffix = f" ({'; '.join(details)})" if details else ""
249
+ lines.append(f" - {name}{suffix}")
250
+
251
+ scans_block = source.get("a2a_SourceAvailableScans") or {}
252
+ scans = _as_list(scans_block.get("a2a_Scan")) if isinstance(scans_block, dict) else []
253
+ scan_uris = [_a2a_text(s.get("a2a_Uri")) for s in scans if isinstance(s, dict)]
254
+ scan_uris = [u for u in scan_uris if u]
255
+ if scan_uris:
256
+ lines.append(" Scans:")
257
+ for uri in scan_uris[:5]:
258
+ lines.append(f" - {uri}")
259
+ if len(scan_uris) > 5:
260
+ lines.append(f" - (+{len(scan_uris) - 5} more)")
261
+
262
+ orig = _a2a_text(source.get("a2a_SourceDigitalOriginal"))
263
+ if orig:
264
+ lines.append(f" Original: {orig}")
265
+
266
+ return "\n".join(lines)
267
+
268
+
269
+ @click.group(context_settings={"help_option_names": ["-h", "--help"]})
270
+ def cli() -> None:
271
+ """Search and inspect Dutch and Belgian archive records on OpenArchieven."""
272
+
273
+
274
+ @cli.command()
275
+ @click.argument("name_arg", required=False, default=None)
276
+ @click.option("--name", "name_opt", default=None, help="Person name query (may include '&' for two names).")
277
+ @click.option("--place", default=None, help="Filter by event place (eventplace), e.g. Zundert or Rotterdam.")
278
+ @click.option("--birth-place", default=None, help="Filter by person birth place (birthplace).")
279
+ @click.option(
280
+ "--event-type",
281
+ default=None,
282
+ help="Event type (e.g. Geboorte, Huwelijk, Overlijden) or source type (e.g. 'BS Geboorte', Bevolkingsregister).",
283
+ )
284
+ @click.option(
285
+ "--source-type",
286
+ default=None,
287
+ help="Explicit OpenArchieven source type (e.g. 'BS Geboorte', 'BS Huwelijk', 'BS Overlijden', Bevolkingsregister, Passagiersregisters).",
288
+ )
289
+ @click.option(
290
+ "--year",
291
+ default=None,
292
+ help="Year or year range (e.g. 1853 or 1850-1860), appended to the name query as required by the API.",
293
+ )
294
+ @click.option("--archive", default=None, help="Archive code filter, e.g. bhi, wba, srt, saa, zal.")
295
+ @click.option("--relation", default=None, help="Relation/role filter, e.g. Kind, Vader, Bruid, Geregistreerde.")
296
+ @click.option("--country", default=None, help="Country code filter, e.g. nl, be, fr.")
297
+ @click.option(
298
+ "--lang",
299
+ default="nl",
300
+ show_default=True,
301
+ type=click.Choice(["nl", "en", "de", "fr"]),
302
+ help="Language for returned archive and type labels.",
303
+ )
304
+ @click.option("--limit", "-n", type=int, default=10, show_default=True, help="Results to return (max 100).")
305
+ @click.option("--start", type=int, default=0, show_default=True, help="Offset for paging (max 10000).")
306
+ @click.option("--json", "as_json", is_flag=True, help="Emit raw API JSON output.")
307
+ def search(
308
+ name_arg: str | None,
309
+ name_opt: str | None,
310
+ place: str | None,
311
+ birth_place: str | None,
312
+ event_type: str | None,
313
+ source_type: str | None,
314
+ year: str | None,
315
+ archive: str | None,
316
+ relation: str | None,
317
+ country: str | None,
318
+ lang: str,
319
+ limit: int,
320
+ start: int,
321
+ as_json: bool,
322
+ ) -> None:
323
+ """Search OpenArchieven records.
324
+
325
+ Example: openarchieven search --name "Vincent van Gogh" --place Zundert --year 1853
326
+ """
327
+ raw_name = (name_opt or name_arg or "").strip()
328
+ if not raw_name:
329
+ raise click.UsageError("Provide a name via --name or a positional argument.")
330
+ if year:
331
+ raw_name = f"{raw_name} {year.strip()}"
332
+
333
+ params: dict[str, Any] = {
334
+ "name": raw_name,
335
+ "number_show": max(1, min(limit, 100)),
336
+ "start": max(0, min(start, 10000)),
337
+ "lang": lang,
338
+ }
339
+ if place:
340
+ params["eventplace"] = place
341
+ if birth_place:
342
+ params["birthplace"] = birth_place
343
+ if source_type:
344
+ params["sourcetype"] = source_type
345
+ if event_type:
346
+ if _is_source_type(event_type) and "sourcetype" not in params:
347
+ params["sourcetype"] = event_type
348
+ else:
349
+ params["eventtype"] = event_type
350
+ if archive:
351
+ params["archive"] = archive
352
+ if relation:
353
+ params["relationtype"] = relation
354
+ if country:
355
+ params["country_code"] = country
356
+
357
+ data = _get_json("search.json", params)
358
+ if as_json:
359
+ click.echo(json.dumps(data, indent=2, ensure_ascii=False))
360
+ return
361
+
362
+ resp = data.get("response") or {}
363
+ total = resp.get("number_found", 0)
364
+ docs = resp.get("docs") or []
365
+ click.echo(f"Found {total} records (showing {len(docs)} from offset {start})")
366
+ for doc in docs:
367
+ code = doc.get("archive_code") or ""
368
+ ident = doc.get("identifier") or ""
369
+ person = doc.get("personname") or "(unnamed)"
370
+ role = doc.get("relationtype") or ""
371
+ stype = doc.get("sourcetype") or doc.get("eventtype") or ""
372
+ date_str = _fmt_eventdate(doc.get("eventdate"))
373
+ places = doc.get("eventplace") or []
374
+ place_str = ", ".join(places) if isinstance(places, list) else str(places)
375
+ url = doc.get("url") or f"{WEB_BASE}/{code}:{ident}"
376
+ click.echo(
377
+ f"- {code}:{ident} | {person} ({role}) | {stype} | {date_str} | {place_str}\n"
378
+ f" {url}"
379
+ )
380
+
381
+
382
+ @cli.command()
383
+ @click.argument("archive")
384
+ @click.argument("identifier", required=False, default=None)
385
+ @click.option(
386
+ "--lang",
387
+ default="nl",
388
+ show_default=True,
389
+ type=click.Choice(["nl", "en", "de", "fr"]),
390
+ help="Language for returned labels.",
391
+ )
392
+ @click.option("--json", "as_json", is_flag=True, help="Emit raw A2A JSON output.")
393
+ def show(archive: str, identifier: str | None, lang: str, as_json: bool) -> None:
394
+ """Fetch full A2A details for one record by ARCHIVE IDENTIFIER, archive:uuid, or URL."""
395
+ code, ident = _parse_record_ref(archive, identifier)
396
+ data = _get_json("show.json", {"archive": code, "identifier": ident, "lang": lang})
397
+ if as_json:
398
+ click.echo(json.dumps(data, indent=2, ensure_ascii=False))
399
+ return
400
+ records = data if isinstance(data, list) else [data]
401
+ if not records:
402
+ click.echo("No record data returned.")
403
+ return
404
+ for idx, rec in enumerate(records):
405
+ if idx > 0:
406
+ click.echo("")
407
+ if isinstance(rec, dict):
408
+ click.echo(_format_a2a_record(code, ident, rec))
409
+
410
+
411
+ @cli.command()
412
+ @click.option("--name", default=None, help="Person name query.")
413
+ @click.option("--place", default=None, help="Event place.")
414
+ @click.option("--year", default=None, help="Year or year range (e.g. 1853 or 1850-1860).")
415
+ @click.option("--record", default=None, help="Record token 'archive:uuid' to build a direct record URL.")
416
+ def url(name: str | None, place: str | None, year: str | None, record: str | None) -> None:
417
+ """Print a shareable OpenArchieven website URL offline."""
418
+ if record:
419
+ code, ident = _parse_record_ref(record, None)
420
+ click.echo(f"{WEB_BASE}/{code}:{ident}")
421
+ return
422
+ if not name:
423
+ raise click.UsageError("Pass --name or --record.")
424
+ q = f"{name.strip()} {year.strip()}" if year else name.strip()
425
+ params = [("name", q)]
426
+ if place:
427
+ params.append(("eventplace", place.strip()))
428
+ click.echo(f"{WEB_BASE}/search.php?{urlencode(params)}")
429
+
430
+
431
+ if __name__ == "__main__":
432
+ cli()
@@ -0,0 +1,93 @@
1
+ ---
2
+ name: texas-archives
3
+ description: Research historical and genealogical records in Texas through the Portal to Texas History (UNT), the Texas State Library and Archives Commission Texas Digital Archive (Preservica), and Texas General Land Office land-grant lookup, using the bundled `texas-archives` CLI. Covers Texas county newspapers and local histories, Texas Ranger research pointers, and what is browser-only (Portal HTML, GLO grant search, Ranger muster rolls). Use when tracing ancestors in Texas counties, searching Texas newspapers, local histories, photographs, or state land grants.
4
+ ---
5
+
6
+ # Texas Archives
7
+
8
+ Texas genealogical research splits across three primary repositories. This skill matches the sibling state archive CLIs (`virginia-archives`, `california-archives`, `kentucky-archives`).
9
+
10
+ Portal: https://texashistory.unt.edu/
11
+ TSLAC Texas Digital Archive: https://tsl.access.preservica.com/
12
+ Texas GLO land grants (state, not federal): https://s3.glo.texas.gov/lookup/index.php
13
+ TSLAC home: https://www.tsl.texas.gov/
14
+
15
+ No account or API key is needed for anything the CLI runs. Texas was not a U.S. public-land state, so federal BLM GLO patents do not cover antebellum Texas land. Use the Texas GLO lookup for Spanish and Mexican grants and republic-era patents, and county deed books for later transfers.
16
+
17
+ ## Bundled CLI (`scripts/texas-archives`)
18
+
19
+ Path: `skills/texas-archives/scripts/texas-archives`
20
+
21
+ Executable Python CLI with PEP 723 `#!/usr/bin/env -S uv run --script`, dependencies `click` and `httpx`. Run from the repo root, for example:
22
+
23
+ ```bash
24
+ skills/texas-archives/scripts/texas-archives portal search "Sam Houston" --county Travis --limit 5
25
+ skills/texas-archives/scripts/texas-archives portal search Houston --county Harris --limit 5 --json
26
+ skills/texas-archives/scripts/texas-archives portal search "Texas Rangers" --type text_newspaper --limit 5
27
+ skills/texas-archives/scripts/texas-archives portal item <metapth-id> --json
28
+ skills/texas-archives/scripts/texas-archives tda Houston --limit 10
29
+ skills/texas-archives/scripts/texas-archives url Austin
30
+ ```
31
+
32
+ | Command | Machine interface (verified 2026-11-24) |
33
+ |---|---|
34
+ | `portal search QUERY... [--county] [--date-from] [--date-to] [--type] [--limit N] [--pages N] [--json]` | `GET https://texashistory.unt.edu/search/opensearch/?q=<query>&format=json&pw=<page>` — 100 hits per page, `opensearch:totalResults` in JSON |
35
+ | `portal item ARK [--json]` | `GET https://texashistory.unt.edu/oai/?verb=GetRecord&identifier=ark:/67531/<id>&metadataPrefix=oai_dc` |
36
+ | `tda QUERY [--limit N] [--json]` | `GET https://tsl.access.preservica.com/search/<term>/feed/rss2/` fetched with **curl** (httpx gets HTTP 403 on this host) |
37
+ | `url [QUERY] [--portal] [--tda] [--glo] [--rangers] [--tslac]` | Prints verified URLs only; no HTTP search |
38
+
39
+ `portal search` accepts multiple words (`Texas Rangers`). `--county` adds the county name to the OpenSearch query and filters hits whose title or description mentions that county. `--date-from` / `--date-to` filter on the OpenSearch `dc:date` field after pages are fetched. `--type` filters `dc:type` (for example `text_newspaper`). OpenSearch query parameters for county or type were **not** verified on the server side. The CLI applies filters locally.
40
+
41
+ ## Portal to Texas History (UNT)
42
+
43
+ The Portal holds digitized newspapers, local histories, maps, photographs, and yearbooks from Texas partners across the state.
44
+
45
+ **Search (CLI):** OpenSearch JSON is public. No ALTCHA and no API key. `portal search` returns up to 100 hits per OpenSearch page along with `opensearch:totalResults`, titles, dates, types, and ARK identifiers.
46
+
47
+ **Item metadata (CLI):** OAI-PMH `GetRecord` with `identifier=ark:/67531/<metapth...>` returns Dublin Core metadata (titles, creators, dates, subjects, types, and descriptions).
48
+
49
+ **Browser-only:** HTML search at `/search/?q=...&t=fulltext` redirects to `/dam/` (ALTCHA challenge). Item landing pages, page images (`/m1/`), and per-page OCR URLs return the same challenge or 404 to plain HTTP. Read newspapers and books in the browser after the CLI gives you the ARK and URL.
50
+
51
+ **OCR / IIIF:** No public OCR download URL or IIIF manifest was verified live for sample ARKs (`ocr.txt`, `iiif/manifest`, `mets.xml` returned 404). Use the item page in the browser for full text where the Portal provides it.
52
+
53
+ ## Texas State Library and Archives Commission (TSLAC)
54
+
55
+ **Texas Digital Archive (TDA):** Preservica Universal Access at `tsl.access.preservica.com`. The WordPress search RSS feed lists up to about 25 hits per query. The CLI uses **curl** for that feed because **httpx receives HTTP 403** on this host while curl receives HTTP 200 (verified same day). Full-text search in the feed covers titles, descriptions, and (per TSLAC) document content, so open each hit to see why it matched.
56
+
57
+ Ranger pensions and Adjutant General muster rolls are **not** fully exposed through this RSS route. Use open-records or reading-room paths documented on `tsl.texas.gov`.
58
+
59
+ **Texas Rangers:** Collection pointer `https://www.tsl.texas.gov/agency/items/texas-rangers`. Muster rolls and service files require a specific record series citation from TSLAC or the Adjutant General, then mail or an in-person visit.
60
+
61
+ ## Texas General Land Office (state grants)
62
+
63
+ `https://s3.glo.texas.gov/lookup/index.php` returned HTTP 200 with a Salesforce/semantic UI shell (live 2026-11-24). A POST with name and county fields did not return a parseable results table to the CLI. Treat grant search as **browser-only**. Federal patents belong in the `blm-glo` skill only for public-land states, not for republic-era or state Texas land.
64
+
65
+ ## Research workflow
66
+
67
+ Worked order for tracing a person or family in Texas:
68
+
69
+ 1. `portal search "<Full Name>" --county <County>` and `portal search <Surname> --county <County> --type text_newspaper` for local newspapers and county histories.
70
+ 2. Search name variants (initials, spouse's maiden name, and town names) with `--county` or `--date-from` / `--date-to`.
71
+ 3. For Texas Ranger service claims, search background material in the Portal, then follow TSLAC Ranger collection pointers and open-records request paths for muster rolls.
72
+ 4. Run `portal item <ark>` on promising hits to pull Dublin Core metadata, then open the Portal URL in a browser to read scans.
73
+ 5. Run `tda <Surname>` and `tda <Town>` for state-archive newspapers and agency records not duplicated on the Portal.
74
+ 6. Search the Texas GLO lookup in the browser for land grants, then follow up in county clerk deed books and vital records.
75
+
76
+ ## Verification log (verified live 2026-11-24)
77
+
78
+ - `https://texashistory.unt.edu/` — HTTP 200.
79
+ - OpenSearch JSON (`?q=<query>&format=json`) — HTTP 200, `application/json`, `opensearch:totalResults` present.
80
+ - OAI `ListSets` and `GetRecord` (`metadataPrefix=oai_dc`) — HTTP 200, valid Dublin Core XML.
81
+ - Portal HTML search (`/search/?q=...&t=fulltext`) and item image views (`/ark:/67531/.../m1/`) — HTTP 302 to `/dam/?next=...` (ALTCHA). Browser-only for HTML UI and images.
82
+ - `https://tsl.access.preservica.com/` — HTTP 200.
83
+ - TDA RSS (`/search/<term>/feed/rss2/`) — HTTP 200 via curl (up to 25 `<item>` elements); HTTP 403 via httpx 0.27 (same User-Agent).
84
+ - `https://s3.glo.texas.gov/lookup/index.php` — HTTP 200 SPA shell; no verified machine search API.
85
+ - `https://www.tsl.texas.gov/` — HTTP 200.
86
+ - CLI `texas-archives --help`, `portal search`, `portal item`, `tda`, `url` — all exited 0 on verification runs.
87
+
88
+ ## What this skill does not cover
89
+
90
+ - Federal BLM GLO (public-land states) — see `blm-glo`; Texas state land is separate.
91
+ - FamilySearch, Ancestry, or Fold3 indexes; cite them only when a Texas portal points there.
92
+ - County clerk vital records and deed books. The Portal and TDA may name people in newspapers or books, but they do not replace certified copies.
93
+ - Do not claim a machine API for Portal HTML, GLO grant search, or Ranger muster rolls without a live verified endpoint.