@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,219 @@
|
|
|
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
|
+
"""Compact CLI for the public WikiTree API (https://api.wikitree.com/api.php).
|
|
10
|
+
|
|
11
|
+
Read-only. No account or API key is needed for public profiles; every call
|
|
12
|
+
sends an appId (WikiTree rate-limits calls without one). See
|
|
13
|
+
skills/wikitree/SKILL.md for the API reference and rules.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import json
|
|
19
|
+
import os
|
|
20
|
+
import sys
|
|
21
|
+
|
|
22
|
+
import click
|
|
23
|
+
import httpx
|
|
24
|
+
|
|
25
|
+
API_BASE = "https://api.wikitree.com/api.php"
|
|
26
|
+
DEFAULT_APP_ID = "Kinloom"
|
|
27
|
+
DEFAULT_FIELDS = "Id,Name,FirstName,LastNameAtBirth,BirthDate,DeathDate,BirthLocation"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _app_id() -> str:
|
|
31
|
+
return os.environ.get("WIKITREE_APP_ID", DEFAULT_APP_ID)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def api_call(params: dict) -> list:
|
|
35
|
+
"""One GET against the WikiTree API; returns the decoded JSON array."""
|
|
36
|
+
params = {"appId": _app_id(), **params}
|
|
37
|
+
try:
|
|
38
|
+
resp = httpx.get(API_BASE, params=params, timeout=30.0)
|
|
39
|
+
resp.raise_for_status()
|
|
40
|
+
except httpx.HTTPError as exc:
|
|
41
|
+
raise click.ClickException(f"WikiTree API request failed: {exc}") from exc
|
|
42
|
+
try:
|
|
43
|
+
data = resp.json()
|
|
44
|
+
except ValueError as exc:
|
|
45
|
+
raise click.ClickException("WikiTree API returned non-JSON") from exc
|
|
46
|
+
if not isinstance(data, list):
|
|
47
|
+
raise click.ClickException(f"Unexpected API response: {data!r}")
|
|
48
|
+
return data
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def check_status(data: list, label: str) -> dict:
|
|
52
|
+
"""Raise on a non-zero status element; return the first element."""
|
|
53
|
+
if not data:
|
|
54
|
+
raise click.ClickException(f"{label}: empty response from WikiTree API")
|
|
55
|
+
first = data[0]
|
|
56
|
+
status = first.get("status", 0)
|
|
57
|
+
if status != 0 and status != "":
|
|
58
|
+
raise click.ClickException(f"{label}: {status}")
|
|
59
|
+
return first
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def show_person(person: dict) -> None:
|
|
63
|
+
"""One compact line per profile, with unknown dates shown as such."""
|
|
64
|
+
name = person.get("Name") or person.get("Id", "?")
|
|
65
|
+
first = person.get("FirstName", "")
|
|
66
|
+
last = person.get("LastNameAtBirth") or person.get("LastNameCurrent", "")
|
|
67
|
+
birth = person.get("BirthDate") or ""
|
|
68
|
+
death = person.get("DeathDate") or ""
|
|
69
|
+
birth = "" if birth in ("", "0000-00-00") else birth
|
|
70
|
+
death = "" if death in ("", "0000-00-00") else death
|
|
71
|
+
place = person.get("BirthLocation", "")
|
|
72
|
+
dates = f"b. {birth}" if birth else "b. ?"
|
|
73
|
+
if death:
|
|
74
|
+
dates += f" d. {death}"
|
|
75
|
+
line = f"{name}: {first} {last} ({dates})"
|
|
76
|
+
if place:
|
|
77
|
+
line += f", born {place}"
|
|
78
|
+
click.echo(line.strip())
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@click.group()
|
|
82
|
+
def cli() -> None:
|
|
83
|
+
"""Read public WikiTree profiles (search, person, ancestors, bio)."""
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@cli.command()
|
|
87
|
+
@click.option("--first", "first_name", default=None, help="First name.")
|
|
88
|
+
@click.option("--last", "last_name", default=None, help="Last name.")
|
|
89
|
+
@click.option("--birth-date", default=None, help="Birth date, YYYY-MM-DD.")
|
|
90
|
+
@click.option("--death-date", default=None, help="Death date, YYYY-MM-DD.")
|
|
91
|
+
@click.option("--birth-location", default=None, help="Birth location.")
|
|
92
|
+
@click.option("--death-location", default=None, help="Death location.")
|
|
93
|
+
@click.option("--date-include", type=click.Choice(["both", "neither"]),
|
|
94
|
+
default=None, help="'both' requires dates on matches.")
|
|
95
|
+
@click.option("--limit", type=click.IntRange(1, 100), default=10,
|
|
96
|
+
show_default=True, help="Results to return (1-100).")
|
|
97
|
+
@click.option("--start", type=int, default=0, show_default=True,
|
|
98
|
+
help="Result offset for paging.")
|
|
99
|
+
@click.option("--fields", default=DEFAULT_FIELDS, show_default=True,
|
|
100
|
+
help="Comma-separated profile fields, or '*'.")
|
|
101
|
+
@click.option("--json", "as_json", is_flag=True, help="Print raw JSON.")
|
|
102
|
+
def search(first_name, last_name, birth_date, death_date, birth_location,
|
|
103
|
+
death_location, date_include, limit, start, fields, as_json):
|
|
104
|
+
"""Search person profiles, e.g. search --first Abraham --last Lincoln."""
|
|
105
|
+
if not any([first_name, last_name, birth_date, death_date,
|
|
106
|
+
birth_location, death_location]):
|
|
107
|
+
raise click.BadParameter("give at least one of --first/--last/--birth-date/--death-date/--birth-location/--death-location.")
|
|
108
|
+
params: dict = {"action": "searchPerson", "limit": limit, "start": start,
|
|
109
|
+
"fields": fields}
|
|
110
|
+
if first_name:
|
|
111
|
+
params["FirstName"] = first_name
|
|
112
|
+
if last_name:
|
|
113
|
+
params["LastName"] = last_name
|
|
114
|
+
if birth_date:
|
|
115
|
+
params["BirthDate"] = birth_date
|
|
116
|
+
if death_date:
|
|
117
|
+
params["DeathDate"] = death_date
|
|
118
|
+
if birth_location:
|
|
119
|
+
params["BirthLocation"] = birth_location
|
|
120
|
+
if death_location:
|
|
121
|
+
params["DeathLocation"] = death_location
|
|
122
|
+
if date_include:
|
|
123
|
+
params["dateInclude"] = date_include
|
|
124
|
+
data = api_call(params)
|
|
125
|
+
first = check_status(data, "searchPerson")
|
|
126
|
+
if as_json:
|
|
127
|
+
click.echo(json.dumps(data, indent=2))
|
|
128
|
+
return
|
|
129
|
+
matches = first.get("matches", [])
|
|
130
|
+
click.echo(f"{first.get('total', len(matches))} match(es), showing {len(matches)}:")
|
|
131
|
+
for match in matches:
|
|
132
|
+
if "Name" in match or "FirstName" in match:
|
|
133
|
+
show_person(match)
|
|
134
|
+
else:
|
|
135
|
+
# Sparse match (Id only): flag it so the caller follows up.
|
|
136
|
+
click.echo(f"Id {match.get('Id')}: sparse match, run `person {match.get('Id')}` for details")
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
@cli.command()
|
|
140
|
+
@click.argument("key")
|
|
141
|
+
@click.option("--fields", default=DEFAULT_FIELDS, show_default=True,
|
|
142
|
+
help="Comma-separated profile fields, or '*'.")
|
|
143
|
+
@click.option("--bio-format", type=click.Choice(["wiki", "html", "both"]),
|
|
144
|
+
default=None, help="Include Bio in this format.")
|
|
145
|
+
@click.option("--resolve-redirect", is_flag=True,
|
|
146
|
+
help="Follow merged-profile redirects.")
|
|
147
|
+
@click.option("--json", "as_json", is_flag=True, help="Print raw JSON.")
|
|
148
|
+
def person(key, fields, bio_format, resolve_redirect, as_json):
|
|
149
|
+
"""Fetch one person by WikiTree ID (e.g. <Surname>-<Number>) or numeric Id."""
|
|
150
|
+
params: dict = {"action": "getPerson", "key": key, "fields": fields}
|
|
151
|
+
if bio_format:
|
|
152
|
+
params["bioFormat"] = bio_format
|
|
153
|
+
if "Bio" not in fields.split(",") and fields != "*":
|
|
154
|
+
params["fields"] = fields + ",Bio"
|
|
155
|
+
if resolve_redirect:
|
|
156
|
+
params["resolveRedirect"] = 1
|
|
157
|
+
data = api_call(params)
|
|
158
|
+
first = check_status(data, f"getPerson {key}")
|
|
159
|
+
if as_json:
|
|
160
|
+
click.echo(json.dumps(data, indent=2))
|
|
161
|
+
return
|
|
162
|
+
profile = first.get("person") or first.get("profile")
|
|
163
|
+
if not profile:
|
|
164
|
+
raise click.ClickException(f"getPerson {key}: no profile returned")
|
|
165
|
+
show_person(profile)
|
|
166
|
+
if bio_format and profile.get("Bio"):
|
|
167
|
+
click.echo(profile["Bio"])
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
@cli.command()
|
|
171
|
+
@click.argument("key")
|
|
172
|
+
@click.option("--depth", type=click.IntRange(1, 10), default=4,
|
|
173
|
+
show_default=True, help="Generations to follow (1-10).")
|
|
174
|
+
@click.option("--fields", default=DEFAULT_FIELDS, show_default=True,
|
|
175
|
+
help="Comma-separated profile fields, or '*'.")
|
|
176
|
+
@click.option("--json", "as_json", is_flag=True, help="Print raw JSON.")
|
|
177
|
+
def ancestors(key, depth, fields, as_json):
|
|
178
|
+
"""Fetch ancestors of KEY, following father and mother.
|
|
179
|
+
|
|
180
|
+
Uses getPeople with ancestors=N: the standalone getAncestors action
|
|
181
|
+
is deprecated (the API returns an error telling callers to use
|
|
182
|
+
getPeople instead). The people dict includes the subject profile
|
|
183
|
+
itself, so it is excluded from the listing.
|
|
184
|
+
"""
|
|
185
|
+
data = api_call({"action": "getPeople", "keys": key, "ancestors": depth,
|
|
186
|
+
"fields": fields})
|
|
187
|
+
first = check_status(data, f"getPeople {key}")
|
|
188
|
+
if as_json:
|
|
189
|
+
click.echo(json.dumps(data, indent=2))
|
|
190
|
+
return
|
|
191
|
+
people = first.get("people", {})
|
|
192
|
+
subject = (first.get("resultByKey") or {}).get(key, {})
|
|
193
|
+
subject_id = str(subject.get("Id", ""))
|
|
194
|
+
profiles = [p for pid, p in people.items() if pid != subject_id]
|
|
195
|
+
profiles.sort(key=lambda p: (p.get("BirthDate") or "9999",
|
|
196
|
+
p.get("Name") or ""))
|
|
197
|
+
click.echo(f"{len(profiles)} ancestor(s) within {depth} generation(s) of {key}:")
|
|
198
|
+
for profile in profiles:
|
|
199
|
+
show_person(profile)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
@cli.command()
|
|
203
|
+
@click.argument("key")
|
|
204
|
+
@click.option("--format", "bio_format", type=click.Choice(["wiki", "html", "both"]),
|
|
205
|
+
default="wiki", show_default=True, help="Biography format.")
|
|
206
|
+
@click.option("--json", "as_json", is_flag=True, help="Print raw JSON.")
|
|
207
|
+
def bio(key, bio_format, as_json):
|
|
208
|
+
"""Fetch the biography text of KEY (default wiki markup)."""
|
|
209
|
+
data = api_call({"action": "getBio", "key": key, "bioFormat": bio_format})
|
|
210
|
+
first = check_status(data, f"getBio {key}")
|
|
211
|
+
if as_json:
|
|
212
|
+
click.echo(json.dumps(data, indent=2))
|
|
213
|
+
return
|
|
214
|
+
text = first.get("bio") or ""
|
|
215
|
+
click.echo(text if text else "(no biography text returned)")
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
if __name__ == "__main__":
|
|
219
|
+
cli()
|
package/dist/cli.d.ts
CHANGED
|
@@ -8,6 +8,6 @@ export interface RunCliOptions {
|
|
|
8
8
|
io?: CliIo;
|
|
9
9
|
fetchImpl?: typeof fetch;
|
|
10
10
|
}
|
|
11
|
-
export declare const ROOT_HELP
|
|
11
|
+
export declare const ROOT_HELP: string;
|
|
12
12
|
export declare function runCli(argv: readonly string[], options?: RunCliOptions): Promise<CliExitCode>;
|
|
13
13
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAaA,OAAO,EAOL,KAAK,WAAW,EACjB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,KAAK;IACpB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,CAAC,EAAE,KAAK,CAAC;IACX,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAWD,eAAO,MAAM,SAAS,QAiC0B,CAAC;AA0RjD,wBAAsB,MAAM,CAC1B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,WAAW,CAAC,CA0jBtB"}
|