@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.
Files changed (111) hide show
  1. package/dist/assets/cached-ocr.py +786 -0
  2. package/dist/assets/ocr.md +76 -0
  3. package/dist/assets/prep-scan.md +97 -0
  4. package/dist/assets/prep-scan.py +1313 -0
  5. package/dist/bundled-skills/acpl-persi/SKILL.md +103 -0
  6. package/dist/bundled-skills/acpl-persi/scripts/persi +539 -0
  7. package/dist/bundled-skills/archive-org/SKILL.md +162 -0
  8. package/dist/bundled-skills/archive-org/scripts/archive-org +1576 -0
  9. package/dist/bundled-skills/blm-glo/SKILL.md +54 -0
  10. package/dist/bundled-skills/california-archives/SKILL.md +130 -0
  11. package/dist/bundled-skills/california-archives/scripts/ca-archives +614 -0
  12. package/dist/bundled-skills/chronicling-america/SKILL.md +120 -0
  13. package/dist/bundled-skills/chronicling-america/scripts/chronam +553 -0
  14. package/dist/bundled-skills/cyndis-list/SKILL.md +53 -0
  15. package/dist/bundled-skills/findagrave/SKILL.md +129 -0
  16. package/dist/bundled-skills/findagrave/scripts/findagrave +965 -0
  17. package/dist/bundled-skills/hathitrust/SKILL.md +117 -0
  18. package/dist/bundled-skills/hathitrust/scripts/hathi +379 -0
  19. package/dist/bundled-skills/kentucky-archives/SKILL.md +124 -0
  20. package/dist/bundled-skills/kentucky-archives/scripts/ky-archives +646 -0
  21. package/dist/bundled-skills/library-of-michigan/SKILL.md +118 -0
  22. package/dist/bundled-skills/library-of-michigan/scripts/michiganology +515 -0
  23. package/dist/bundled-skills/missouri-archives/SKILL.md +109 -0
  24. package/dist/bundled-skills/missouri-archives/scripts/mo-archives +751 -0
  25. package/dist/bundled-skills/nara-catalog-search/SKILL.md +130 -0
  26. package/dist/bundled-skills/nara-catalog-search/scripts/nara +1387 -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 +135 -0
  31. package/dist/bundled-skills/new-jersey-archives/scripts/nj-archives +869 -0
  32. package/dist/bundled-skills/openarchieven/SKILL.md +97 -0
  33. package/dist/bundled-skills/openarchieven/scripts/openarchieven +624 -0
  34. package/dist/bundled-skills/texas-archives/SKILL.md +102 -0
  35. package/dist/bundled-skills/texas-archives/scripts/texas-archives +666 -0
  36. package/dist/bundled-skills/uk-archives/SKILL.md +110 -0
  37. package/dist/bundled-skills/uk-archives/scripts/uk-archives +631 -0
  38. package/dist/bundled-skills/usgs-gnis/SKILL.md +99 -0
  39. package/dist/bundled-skills/usgs-gnis/scripts/gnis +418 -0
  40. package/dist/bundled-skills/virginia-archives/SKILL.md +144 -0
  41. package/dist/bundled-skills/virginia-archives/scripts/va-archives +1039 -0
  42. package/dist/bundled-skills/wikitree/SKILL.md +154 -0
  43. package/dist/bundled-skills/wikitree/scripts/wikitree +455 -0
  44. package/dist/cli.d.ts +1 -1
  45. package/dist/cli.d.ts.map +1 -1
  46. package/dist/cli.js +488 -26
  47. package/dist/cli.js.map +1 -1
  48. package/dist/client.d.ts.map +1 -1
  49. package/dist/client.js +30 -5
  50. package/dist/client.js.map +1 -1
  51. package/dist/commands/ops/audit.d.ts +138 -0
  52. package/dist/commands/ops/audit.d.ts.map +1 -0
  53. package/dist/commands/ops/audit.js +872 -0
  54. package/dist/commands/ops/audit.js.map +1 -0
  55. package/dist/commands/ops/context.d.ts +100 -0
  56. package/dist/commands/ops/context.d.ts.map +1 -0
  57. package/dist/commands/ops/context.js +917 -0
  58. package/dist/commands/ops/context.js.map +1 -0
  59. package/dist/commands/ops/dates.d.ts +87 -0
  60. package/dist/commands/ops/dates.d.ts.map +1 -0
  61. package/dist/commands/ops/dates.js +228 -0
  62. package/dist/commands/ops/dates.js.map +1 -0
  63. package/dist/commands/ops/help.d.ts +8 -0
  64. package/dist/commands/ops/help.d.ts.map +1 -0
  65. package/dist/commands/ops/help.js +107 -0
  66. package/dist/commands/ops/help.js.map +1 -0
  67. package/dist/commands/ops/index.d.ts +8 -0
  68. package/dist/commands/ops/index.d.ts.map +1 -0
  69. package/dist/commands/ops/index.js +8 -0
  70. package/dist/commands/ops/index.js.map +1 -0
  71. package/dist/commands/ops/integrate.d.ts +61 -0
  72. package/dist/commands/ops/integrate.d.ts.map +1 -0
  73. package/dist/commands/ops/integrate.js +1063 -0
  74. package/dist/commands/ops/integrate.js.map +1 -0
  75. package/dist/commands/ops/sync.d.ts +194 -0
  76. package/dist/commands/ops/sync.d.ts.map +1 -0
  77. package/dist/commands/ops/sync.js +1251 -0
  78. package/dist/commands/ops/sync.js.map +1 -0
  79. package/dist/commands/ops/telemetry.d.ts +79 -0
  80. package/dist/commands/ops/telemetry.d.ts.map +1 -0
  81. package/dist/commands/ops/telemetry.js +249 -0
  82. package/dist/commands/ops/telemetry.js.map +1 -0
  83. package/dist/commands/ops/verify.d.ts +76 -0
  84. package/dist/commands/ops/verify.d.ts.map +1 -0
  85. package/dist/commands/ops/verify.js +325 -0
  86. package/dist/commands/ops/verify.js.map +1 -0
  87. package/dist/commands/records/help.d.ts +18 -0
  88. package/dist/commands/records/help.d.ts.map +1 -0
  89. package/dist/commands/records/help.js +174 -0
  90. package/dist/commands/records/help.js.map +1 -0
  91. package/dist/commands/records/index.d.ts +5 -0
  92. package/dist/commands/records/index.d.ts.map +1 -0
  93. package/dist/commands/records/index.js +5 -0
  94. package/dist/commands/records/index.js.map +1 -0
  95. package/dist/commands/records/registry.d.ts +32 -0
  96. package/dist/commands/records/registry.d.ts.map +1 -0
  97. package/dist/commands/records/registry.js +227 -0
  98. package/dist/commands/records/registry.js.map +1 -0
  99. package/dist/commands/records/resolve.d.ts +14 -0
  100. package/dist/commands/records/resolve.d.ts.map +1 -0
  101. package/dist/commands/records/resolve.js +61 -0
  102. package/dist/commands/records/resolve.js.map +1 -0
  103. package/dist/commands/records/runner.d.ts +27 -0
  104. package/dist/commands/records/runner.d.ts.map +1 -0
  105. package/dist/commands/records/runner.js +255 -0
  106. package/dist/commands/records/runner.js.map +1 -0
  107. package/dist/index.d.ts +2 -0
  108. package/dist/index.d.ts.map +1 -1
  109. package/dist/index.js +2 -0
  110. package/dist/index.js.map +1 -1
  111. package/package.json +3 -3
@@ -0,0 +1,130 @@
1
+ ---
2
+ name: nara-catalog-search
3
+ description: Search, inspect, and download records from the National Archives Catalog via the bundled uv-based `nara` CLI, website advanced search, or v2 API. Covers CLI usage, query-string syntax, q operators, fielded parameters, filters, date and Congress ranges, pagination, and worked examples. Use when querying NARA, inspecting NAIDs, downloading digitized archival scans, or verifying genealogy records.
4
+ ---
5
+
6
+ # NARA Catalog Search
7
+
8
+ This skill includes a standalone executable Python CLI at `skills/nara-catalog-search/scripts/nara` using a PEP 723 `#!/usr/bin/env -S uv run --script` shebang with inline dependencies (`click`, `httpx`, `playwright`). No virtualenv setup or API key is required.
9
+
10
+ - **Without `NARA_API_KEY` (default):** runs headless Chromium (auto-detecting system `chromium` or `google-chrome`) against `catalog.archives.gov` and reads the structured Catalog JSON responses.
11
+ - **With `NARA_API_KEY`:** queries the official v2 API (`https://catalog.archives.gov/api/v2/records/search`) over HTTP directly. Pass `--browser` to force website mode.
12
+ - **Compact output by default:** JSON and text outputs keep only non-empty archival citation fields (`naId`, `title`, `url`, `level`, `rg`, `series`, `dates`, `microform`, `access`, `use`, `location`, `scope`, `objectCount`). Full digital object URL lists are excluded unless `--objects` is passed (and can be sliced with `--pages`).
13
+
14
+ ## Bundled CLI (`scripts/nara`)
15
+
16
+ Path: `skills/nara-catalog-search/scripts/nara`
17
+
18
+ ### Persistent local disk cache
19
+
20
+ `search`, `get`, and `download` cache responses atomically under `~/.cache/kinloom-nara/` (overrideable via `KINLOOM_NARA_CACHE_DIR`) using advisory file locks (`fcntl.flock` on POSIX, safe fallback elsewhere) so concurrent research threads never duplicate downloads and repeat calls make zero HTTP requests. Pass `--refresh` on `search`, `get`, or `download` to bypass the cache and fetch fresh data.
21
+
22
+ Cache layout:
23
+
24
+ - `records/<naid>.json`: full record metadata and digital object inventory shared by `get` and `download` (upgraded automatically if `--text` is requested later).
25
+ - `objects/<naid>/<page>_<safe_filename>`: individual downloaded page scans, so overlapping page slices (for example `--pages 315-350` followed by `--pages 340-360` or another biographer working the same census roll) reuse already-fetched pages straight from disk.
26
+ - `_queries/<sha256>.json`: cached `search` query payloads keyed by canonical query parameters with a 168-hour (7-day) default TTL (`--cache-ttl-hours` or `KINLOOM_NARA_QUERY_TTL_HOURS`).
27
+
28
+ ### Search records (single or batched in one browser session)
29
+
30
+ ```bash
31
+ # Single exact-phrase search in Record Group 15 (Department of Veterans Affairs pension files)
32
+ skills/nara-catalog-search/scripts/nara search '"Harriet Tubman"' --rg 15
33
+
34
+ # Batch multiple queries sharing one headless Chromium session (fast)
35
+ skills/nara-catalog-search/scripts/nara search '"Clara Barton"' '"Frederick Douglass"' 'Gettysburg AND Lincoln' --online --json
36
+
37
+ # Digital records only, filtered by level, date range, and material type
38
+ skills/nara-catalog-search/scripts/nara search '"Abraham Lincoln"' --level fileUnit,item --online --start-date 1860 --end-date 1865 --type "Textual Records"
39
+ ```
40
+
41
+ ### Inspect one or more NAIDs
42
+
43
+ ```bash
44
+ # Compact metadata and file counts for multiple NAIDs (reuses one browser)
45
+ skills/nara-catalog-search/scripts/nara get <naid-1> <naid-2> --json
46
+
47
+ # Include sliced digital object URLs for large rolls
48
+ skills/nara-catalog-search/scripts/nara get <naid> --objects --pages 1-10 --json
49
+
50
+ # Print extracted OCR or community transcriptions if available
51
+ skills/nara-catalog-search/scripts/nara get <naid> --text
52
+ ```
53
+
54
+ Note on large multi-page file units: `nara get --text` prints text only when NARA's record object stores `extractedText`, `otherExtractedText`, or community transcriptions, and NARA's catalog search proxy response does not include page-level match highlights. When a search matches inside a large digitized file unit (for example hundreds of pages) with no `extractedText` returned by `get --text`, open `https://catalog.archives.gov/id/<naId>` in a browser to locate the matching page.
55
+
56
+ ### Download digitized scans with compact provenance metadata
57
+
58
+ ```bash
59
+ # Download selected 1-based pages plus compact metadata.json
60
+ skills/nara-catalog-search/scripts/nara download <naid> --pages 1-5 --out ./downloads/nara-<naid>
61
+
62
+ # Download all images in a file unit
63
+ skills/nara-catalog-search/scripts/nara download <naid> --out ./downloads/nara-<naid>
64
+ ```
65
+
66
+ ### Build verified search URLs offline
67
+
68
+ ```bash
69
+ skills/nara-catalog-search/scripts/nara url '"Harriet Tubman"' --rg 15 --online
70
+ skills/nara-catalog-search/scripts/nara url '"Clara Barton"' --level item --api
71
+ ```
72
+
73
+ ### Environment variables
74
+
75
+ - `NARA_API_KEY`: optional NARA Catalog v2 API key for direct HTTP queries.
76
+ - `NARA_BROWSER`: optional path to a Chromium or Chrome binary (defaults to `chromium`, `chromium-browser`, `google-chrome`, or Playwright's bundled browser).
77
+ - `KINLOOM_NARA_CACHE_DIR`: optional override for the local disk cache directory (default `~/.cache/kinloom-nara`).
78
+ - `KINLOOM_NARA_QUERY_TTL_HOURS`: optional override for the `search` query cache TTL in hours (default `168`).
79
+
80
+ ## Website search & query string rules (verified live 2026-11-23)
81
+
82
+ - Basic: `https://catalog.archives.gov/search?q=<query>&page=<n>`
83
+ - Advanced builder: `https://catalog.archives.gov/advanced-search` (submits to `/search`)
84
+ - Record page: `https://catalog.archives.gov/id/<naId>`
85
+ - Help: `https://www.archives.gov/research/catalog/help/using`
86
+ - No sign-in or API key is needed for the website.
87
+
88
+ Rules:
89
+ - The search goes to `/search`, with `q=` first.
90
+ - Filters are separate parameters joined by `&`.
91
+ - Defaults add nothing: "All Archival Descriptions" and "All fields" produce no parameter.
92
+ - Multiple values in one filter are comma-separated inside a single parameter, never repeated keys. Example: `levelOfDescription=item%2CfileUnit`.
93
+ - URL encoding: space `%20`, double quote `%22`, comma `%2C`.
94
+ - Level values are lowercase camelCase: `recordGroup`, `collection`, `series`, `fileUnit`, `item`.
95
+
96
+ ### Example URL patterns
97
+
98
+ - Exact phrase, item level: `https://catalog.archives.gov/search?q=%22Clara%20Barton%22&levelOfDescription=item`
99
+ - Keyword, digital content only: `https://catalog.archives.gov/search?q=Harriet%20Tubman&availableOnline=true&dataSource=description`
100
+ - Two levels: `https://catalog.archives.gov/search?q=Frederick%20Douglass&levelOfDescription=item%2CfileUnit`
101
+
102
+ ## `q` syntax
103
+
104
+ - Boolean operators `AND`, `OR`, `NOT`; wildcard `*`; exact phrase with double quotes: `"Clara Barton"`.
105
+ - Plain keywords match broadly (`Clara Barton` unquoted matches either word anywhere). Quote exact names to narrow results.
106
+ - Wildcards: `photo*`, `WJC*`, `4*`.
107
+ - Comma-separated lists in control-number fields: `21-A-1, 5635483`; record group: `255, 404`; collection: `WJC-FCIP, WJC-WHOO`.
108
+
109
+ ## Field-selector mapping to API parameters
110
+
111
+ - All fields -> `q` (verified)
112
+ - Title -> `title` (exact: `title_is`)
113
+ - Creator -> `creators`
114
+ - Person or Organization -> `personOrOrg`
115
+ - Geographic Reference -> `geographicReference`
116
+ - Tags -> `tagContribution`; Transcriptions -> `transcriptionContribution`; Comments -> `commentContribution`
117
+ - Local Identifier -> `localIdentifier` (`localIdentifier_is`); National Archives Identifier -> `naId` (`naId_is`); Record Group Number -> `recordGroupNumber`; Collection Identifier -> `collectionIdentifier`
118
+ - Location -> `referenceUnits`
119
+ - Type of Material -> `typeOfMaterials` (`Textual Records`, `Photographs and other Graphic Materials`, `Moving Images`, `Maps and Charts`, `Architectural and Engineering Drawings`, `Data Files`, `Sound Recordings`, `Artifacts`)
120
+ - Beginning/Ending Date -> `startDate` / `endDate` (`YYYY`, `YYYY-MM`, or `YYYY-MM-DD`); exact date -> `exactDate`
121
+ - Beginning/Ending Congress -> `beginCongress` / `endCongress` / `congressNumber`
122
+
123
+ ## API v2 reference (optional key)
124
+
125
+ - Base: `GET https://catalog.archives.gov/api/v2/records/search`
126
+ - Auth: `x-api-key` header (request a free read-only key by emailing `Catalog_API@nara.gov`; limit 10,000 queries/month; never commit keys).
127
+ - Docs: `https://catalog.archives.gov/api/v2/api-docs/` (`swagger.json` at `https://catalog.archives.gov/api/v2/swagger.json`).
128
+ - Other endpoints: `/records/parentNaId/{parentNaId}`, `/extractedText/{naId}`, `/records/stats`, `/records/search/by-tag`, `/by-transcription`, `/by-comment`.
129
+ - Attribution: services using the API must display "This product uses the National Archives Catalog API but is not endorsed or certified by the National Archives and Records Administration."
130
+ - Terms note: do not scrape or bulk-mirror the whole Catalog; use the AWS Registry of Open Data dataset for bulk transfers.