litschema 0.1.1__tar.gz

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 (43) hide show
  1. litschema-0.1.1/.gitignore +53 -0
  2. litschema-0.1.1/CITATION.cff +19 -0
  3. litschema-0.1.1/LICENSE +191 -0
  4. litschema-0.1.1/PKG-INFO +176 -0
  5. litschema-0.1.1/README.md +147 -0
  6. litschema-0.1.1/pyproject.toml +164 -0
  7. litschema-0.1.1/skills/extract-article/SKILL.md +188 -0
  8. litschema-0.1.1/skills/litschema-onboard/SKILL.md +218 -0
  9. litschema-0.1.1/src/litschema/__init__.py +5 -0
  10. litschema-0.1.1/src/litschema/agent/__init__.py +1 -0
  11. litschema-0.1.1/src/litschema/agent/prepare_schema_context.py +47 -0
  12. litschema-0.1.1/src/litschema/agent/reasoning.yaml +47 -0
  13. litschema-0.1.1/src/litschema/agent/reasoning_schema.py +11 -0
  14. litschema-0.1.1/src/litschema/agent/validate_reasoning.py +142 -0
  15. litschema-0.1.1/src/litschema/analysis/__init__.py +212 -0
  16. litschema-0.1.1/src/litschema/article_registry.py +22 -0
  17. litschema-0.1.1/src/litschema/articles.py +167 -0
  18. litschema-0.1.1/src/litschema/bib_metadata.py +104 -0
  19. litschema-0.1.1/src/litschema/cli.py +1410 -0
  20. litschema-0.1.1/src/litschema/config.py +234 -0
  21. litschema-0.1.1/src/litschema/explore/__init__.py +1 -0
  22. litschema-0.1.1/src/litschema/explore/loader.py +290 -0
  23. litschema-0.1.1/src/litschema/explore/server.py +153 -0
  24. litschema-0.1.1/src/litschema/export.py +48 -0
  25. litschema-0.1.1/src/litschema/ingest/__init__.py +24 -0
  26. litschema-0.1.1/src/litschema/ingest/article_assembly.py +193 -0
  27. litschema-0.1.1/src/litschema/ingest/openalex_harvest.py +367 -0
  28. litschema-0.1.1/src/litschema/ingest/pdf_to_markdown.py +180 -0
  29. litschema-0.1.1/src/litschema/ingest/validate_extraction.py +112 -0
  30. litschema-0.1.1/src/litschema/project.py +22 -0
  31. litschema-0.1.1/src/litschema/review_paths.py +155 -0
  32. litschema-0.1.1/src/litschema/reviews.py +638 -0
  33. litschema-0.1.1/src/litschema/runs.py +447 -0
  34. litschema-0.1.1/src/litschema/schema_resolution.py +619 -0
  35. litschema-0.1.1/src/litschema/schema_validation.py +65 -0
  36. litschema-0.1.1/src/litschema/templates/agriculture/README.md +119 -0
  37. litschema-0.1.1/src/litschema/templates/agriculture/agriculture_extraction.yaml +232 -0
  38. litschema-0.1.1/src/litschema/templates/agriculture/domain_context.md +73 -0
  39. litschema-0.1.1/src/litschema/version.py +153 -0
  40. litschema-0.1.1/src/litschema/webapp/__init__.py +0 -0
  41. litschema-0.1.1/src/litschema/webapp/app.py +1069 -0
  42. litschema-0.1.1/src/litschema/webapp/search.py +34 -0
  43. litschema-0.1.1/src/litschema/webapp/static/index.html +7017 -0
@@ -0,0 +1,53 @@
1
+ # Python
2
+ __pycache__/
3
+ *.pyc
4
+ *.egg-info/
5
+ .venv/
6
+ .env
7
+
8
+ # Build/test outputs
9
+ dist/
10
+ build/
11
+ .pytest_cache/
12
+ .ruff_cache/
13
+ .mypy_cache/
14
+ site/
15
+ static-site/
16
+ .litschema/
17
+
18
+ # Local agent/editor state
19
+ .claude/
20
+ .codex/
21
+ .idea/
22
+ .DS_Store
23
+
24
+ # Project data generated by users
25
+ papers/
26
+ data/
27
+ *.pdf
28
+
29
+ # ...but test fixture projects are source, not user data. Without this the
30
+ # `data/` rule silently drops fixture files, and tests that pass locally on
31
+ # untracked files fail in CI with nothing to point at.
32
+ #
33
+ # Negate only the three rules above that wrongly catch fixture content, rather
34
+ # than the whole subtree: `!tests/fixtures/**` would also un-ignore every
35
+ # generated and private file that happens to land there.
36
+ !tests/fixtures/**/data/
37
+ !tests/fixtures/**/data/**
38
+ !tests/fixtures/**/papers/
39
+ !tests/fixtures/**/papers/**
40
+ !tests/fixtures/**/*.pdf
41
+
42
+ # Generated or private files stay ignored wherever they land, including inside
43
+ # a fixture — they are rebuilt or personal, not authored.
44
+ tests/fixtures/**/.litschema/
45
+ tests/fixtures/**/__pycache__/
46
+ tests/fixtures/**/.venv/
47
+ tests/fixtures/**/.env
48
+ tests/fixtures/**/.claude/
49
+ tests/fixtures/**/.codex/
50
+ tests/fixtures/**/.DS_Store
51
+
52
+ # AI tooling
53
+ .roborev.toml
@@ -0,0 +1,19 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use litschema in your research, please cite it as below."
3
+ type: software
4
+ title: "litschema"
5
+ abstract: "Schema-driven extraction of structured data from PDFs, with line-cited evidence and per-field human review."
6
+ authors:
7
+ - family-names: Levinson
8
+ given-names: Cory
9
+ orcid: "https://orcid.org/0009-0009-8902-102X"
10
+ repository-code: "https://github.com/clevinson/litschema"
11
+ license: Apache-2.0
12
+ version: 0.1.1
13
+ date-released: 2026-09-27
14
+ keywords:
15
+ - linkml
16
+ - systematic-review
17
+ - meta-analysis
18
+ - data-extraction
19
+ - provenance
@@ -0,0 +1,191 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to the Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by the Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding any notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2025 Cory Grinstead
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
@@ -0,0 +1,176 @@
1
+ Metadata-Version: 2.5
2
+ Name: litschema
3
+ Version: 0.1.1
4
+ Summary: Schema-driven, agentic extraction of structured data from scientific literature. LinkML-native, local-first, with bundled agent skills.
5
+ Project-URL: Homepage, https://github.com/clevinson/litschema
6
+ Project-URL: Repository, https://github.com/clevinson/litschema
7
+ Project-URL: Issues, https://github.com/clevinson/litschema/issues
8
+ Project-URL: Changelog, https://github.com/clevinson/litschema/blob/main/CHANGELOG.md
9
+ Project-URL: Documentation, https://github.com/clevinson/litschema#readme
10
+ Author-email: Cory Levinson <cjlevinson@gmail.com>
11
+ License-Expression: Apache-2.0
12
+ License-File: LICENSE
13
+ Keywords: extraction,linkml,meta-analysis,pdf,schema,systematic-review
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
18
+ Classifier: Topic :: Text Processing :: Markup
19
+ Requires-Python: >=3.13
20
+ Requires-Dist: duckdb>=1.0.0
21
+ Requires-Dist: fastapi[standard]>=0.115
22
+ Requires-Dist: linkml>=1.10.0
23
+ Requires-Dist: mcp>=1.27.0
24
+ Requires-Dist: pymupdf4llm<1.29,>=1.28.0
25
+ Requires-Dist: pyyaml>=6.0
26
+ Requires-Dist: requests>=2.31.0
27
+ Requires-Dist: typer>=0.12.0
28
+ Description-Content-Type: text/markdown
29
+
30
+ # litschema
31
+
32
+ **Turn a folder of PDFs into a dataset you can defend.**
33
+
34
+ Extraction gets you structured data. `litschema` gets you structured data where
35
+ every value carries the lines it came from, a record of which model produced
36
+ it, and a human's verdict on whether it's right — because in a systematic
37
+ review or meta-analysis, "the model said so" is not a citation.
38
+
39
+ Everything runs on your machine. The only network calls are optional DOI
40
+ lookups and the verifier's ORCID name resolution.
41
+
42
+ ## What you get
43
+
44
+ For each document, three artifacts that stay in step:
45
+
46
+ ```text
47
+ data/papers/<article-id>/
48
+ article-metadata.json identity + bibliographic block
49
+ <article-id>.pdf
50
+ article.md prepared full text
51
+ active-run.json which extraction is current
52
+ extraction-runs/<run-id>/
53
+ agent-extraction.json what the document SAYS (schema-valid)
54
+ agent-reasoning.json why — per-field evidence, line-cited
55
+ run.json inputs hashed, model recorded
56
+ review.json your verdicts on this run
57
+ ```
58
+
59
+ Plain JSON on disk, one directory per document, diffable in git. A run is
60
+ immutable once published: its extraction, reasoning, and `run.json` never
61
+ change, so a review written against it stays meaningful forever. Re-extracting
62
+ creates a new run rather than overwriting the old one.
63
+
64
+ ## Alpha Software
65
+
66
+ **litschema is early software. Extracted data may need regenerating
67
+ when updating litschema versions.**
68
+
69
+ One limit qualifies the line-level citations promised above: PDF conversion
70
+ collapses some tables onto a single line, so a citation into a table can name
71
+ the table but not the row. This matters most for measurement-heavy schemas.
72
+
73
+ Each release documents its breaking changes and known limits in the
74
+ [CHANGELOG.md](https://github.com/clevinson/litschema/blob/main/CHANGELOG.md).
75
+
76
+ ## Specs
77
+
78
+ The [specs](https://github.com/clevinson/litschema/blob/main/specs/README.md) describe what is currently implemented; anything
79
+ deferred says so and names where it is tracked.
80
+
81
+ ## The flow
82
+
83
+ ```bash
84
+ litschema init my-project # scaffold a project
85
+ # drop PDFs into papers-inbox/
86
+ /litschema-onboard # agent: drafts your schema, extracts, pilots
87
+ litschema verify # you: check what was extracted
88
+ litschema export # the reviewed data, ready for analysis
89
+ ```
90
+
91
+ `/litschema-onboard` is a bundled agent skill, installed into `.claude/skills/`
92
+ by `init`. It interviews you to draft a LinkML schema from your own papers,
93
+ runs intake, extracts one article as a pilot so you can course-correct, then
94
+ batches the rest.
95
+
96
+ ## Install
97
+
98
+ ```bash
99
+ uv tool install litschema # or: pip install litschema
100
+ litschema --version
101
+ ```
102
+
103
+ `init` pins each project to the version that created it (`litschema_version`
104
+ in `litschema.yaml`), and commands refuse to run under any other. To move a
105
+ project to a new release, install it and edit the pin.
106
+
107
+ To try an unreleased tag or work on litschema itself:
108
+
109
+ ```bash
110
+ uv tool install "litschema @ git+https://github.com/clevinson/litschema@v0.1.1" --force
111
+ uv tool install --editable path/to/litschema --force # edits take effect immediately
112
+ ```
113
+
114
+ ## Commands
115
+
116
+ ```bash
117
+ litschema init <dir> scaffold a project; installs agent skills locally
118
+ litschema doctor diagnose config, schema, and skill installation
119
+ litschema status counts: inbox, articles, runs, reviews
120
+ litschema assemble papers-inbox PDFs -> per-article folders (offline)
121
+ litschema prepare-text <id>|--all PDF -> article.md (offline)
122
+ litschema meta show|set|sync <id> bibliographic metadata, provenance-tagged
123
+ litschema validate [target] validate extractions against the schema
124
+ litschema runs list|activate inspect published runs; choose the active one
125
+ litschema verify [--port 8000] local review webapp (loopback only)
126
+ litschema export [-f jsonl|csv] reviewed data as flat files (pandas/R/jq-ready)
127
+ litschema mcp DuckDB store served over MCP (experimental)
128
+ litschema skills install install the agent skills globally
129
+ litschema agent ... deterministic steps the extraction skill calls
130
+ ```
131
+
132
+ There is no `litschema extract`: extraction is judgment work, so it runs as an
133
+ agent skill (`/extract-article <id>`) with the framework checking the output.
134
+ The verb exists only to say so.
135
+
136
+ ## How it works
137
+
138
+ **Intake is offline and content-addressed.** `assemble` derives a stable
139
+ article id from each PDF's filename, moves the PDF into the store, and writes a
140
+ minimal manifest. No DOI, bibliography file, or network access is needed to
141
+ reach extraction, and re-dropping the same PDF is a no-op.
142
+
143
+ **Extraction is agent-executed, framework-checked.** The agent reads only the
144
+ prepared text, writes an extraction plus a line-cited reasoning file, and loops
145
+ until both validate. Validation is closed-world — nothing the schema doesn't
146
+ define gets in — and citations must resolve to real lines in the prepared text,
147
+ so a reference to a line that doesn't exist fails rather than shipping.
148
+
149
+ **Runs are immutable and provenance-bearing.** Publishing records the SHA-256
150
+ of every input — prepared text, domain context, and the skill that conducted
151
+ the extraction — alongside the schema hash and what produced it. Reproduction
152
+ data is computed by the publisher; attribution is recorded as asserted, since
153
+ an agent cannot verify its own model. Nothing is overwritten.
154
+
155
+ **Bibliographic metadata is provenance-locked.** Values fetched from a DOI
156
+ registry are marked and locked; machine-written values may be upgraded but
157
+ human edits are never overwritten without explicit consent. Documents with no
158
+ DOI flow through unchanged.
159
+
160
+ **Review is field-by-field and git-native.** `litschema verify` shows every
161
+ extracted value beside its cited source lines, with the model and effort that
162
+ produced it. You verify a value, correct it, or remove it — one entry per
163
+ field, stored inside the run it reviews. Diffs of `review.json` are the audit
164
+ log. Because a run's payload can never change, a review never goes stale.
165
+
166
+ **Use the reviewed truth.** `export` writes the review-applied extractions as
167
+ JSONL or CSV for pandas, R, or jq. `mcp` (experimental) derives a DuckDB
168
+ database from your schema and serves it read-only. Both apply overrides and
169
+ skip error markers, so they agree.
170
+
171
+ ## Project layout
172
+
173
+ - `src/litschema/` — package code and CLI
174
+ - `specs/` — capability specs and decision logs; start at `specs/README.md`
175
+ - `skills/` — the agent-facing extraction and onboarding instructions
176
+ - `tests/` — framework tests and small project fixtures
@@ -0,0 +1,147 @@
1
+ # litschema
2
+
3
+ **Turn a folder of PDFs into a dataset you can defend.**
4
+
5
+ Extraction gets you structured data. `litschema` gets you structured data where
6
+ every value carries the lines it came from, a record of which model produced
7
+ it, and a human's verdict on whether it's right — because in a systematic
8
+ review or meta-analysis, "the model said so" is not a citation.
9
+
10
+ Everything runs on your machine. The only network calls are optional DOI
11
+ lookups and the verifier's ORCID name resolution.
12
+
13
+ ## What you get
14
+
15
+ For each document, three artifacts that stay in step:
16
+
17
+ ```text
18
+ data/papers/<article-id>/
19
+ article-metadata.json identity + bibliographic block
20
+ <article-id>.pdf
21
+ article.md prepared full text
22
+ active-run.json which extraction is current
23
+ extraction-runs/<run-id>/
24
+ agent-extraction.json what the document SAYS (schema-valid)
25
+ agent-reasoning.json why — per-field evidence, line-cited
26
+ run.json inputs hashed, model recorded
27
+ review.json your verdicts on this run
28
+ ```
29
+
30
+ Plain JSON on disk, one directory per document, diffable in git. A run is
31
+ immutable once published: its extraction, reasoning, and `run.json` never
32
+ change, so a review written against it stays meaningful forever. Re-extracting
33
+ creates a new run rather than overwriting the old one.
34
+
35
+ ## Alpha Software
36
+
37
+ **litschema is early software. Extracted data may need regenerating
38
+ when updating litschema versions.**
39
+
40
+ One limit qualifies the line-level citations promised above: PDF conversion
41
+ collapses some tables onto a single line, so a citation into a table can name
42
+ the table but not the row. This matters most for measurement-heavy schemas.
43
+
44
+ Each release documents its breaking changes and known limits in the
45
+ [CHANGELOG.md](https://github.com/clevinson/litschema/blob/main/CHANGELOG.md).
46
+
47
+ ## Specs
48
+
49
+ The [specs](https://github.com/clevinson/litschema/blob/main/specs/README.md) describe what is currently implemented; anything
50
+ deferred says so and names where it is tracked.
51
+
52
+ ## The flow
53
+
54
+ ```bash
55
+ litschema init my-project # scaffold a project
56
+ # drop PDFs into papers-inbox/
57
+ /litschema-onboard # agent: drafts your schema, extracts, pilots
58
+ litschema verify # you: check what was extracted
59
+ litschema export # the reviewed data, ready for analysis
60
+ ```
61
+
62
+ `/litschema-onboard` is a bundled agent skill, installed into `.claude/skills/`
63
+ by `init`. It interviews you to draft a LinkML schema from your own papers,
64
+ runs intake, extracts one article as a pilot so you can course-correct, then
65
+ batches the rest.
66
+
67
+ ## Install
68
+
69
+ ```bash
70
+ uv tool install litschema # or: pip install litschema
71
+ litschema --version
72
+ ```
73
+
74
+ `init` pins each project to the version that created it (`litschema_version`
75
+ in `litschema.yaml`), and commands refuse to run under any other. To move a
76
+ project to a new release, install it and edit the pin.
77
+
78
+ To try an unreleased tag or work on litschema itself:
79
+
80
+ ```bash
81
+ uv tool install "litschema @ git+https://github.com/clevinson/litschema@v0.1.1" --force
82
+ uv tool install --editable path/to/litschema --force # edits take effect immediately
83
+ ```
84
+
85
+ ## Commands
86
+
87
+ ```bash
88
+ litschema init <dir> scaffold a project; installs agent skills locally
89
+ litschema doctor diagnose config, schema, and skill installation
90
+ litschema status counts: inbox, articles, runs, reviews
91
+ litschema assemble papers-inbox PDFs -> per-article folders (offline)
92
+ litschema prepare-text <id>|--all PDF -> article.md (offline)
93
+ litschema meta show|set|sync <id> bibliographic metadata, provenance-tagged
94
+ litschema validate [target] validate extractions against the schema
95
+ litschema runs list|activate inspect published runs; choose the active one
96
+ litschema verify [--port 8000] local review webapp (loopback only)
97
+ litschema export [-f jsonl|csv] reviewed data as flat files (pandas/R/jq-ready)
98
+ litschema mcp DuckDB store served over MCP (experimental)
99
+ litschema skills install install the agent skills globally
100
+ litschema agent ... deterministic steps the extraction skill calls
101
+ ```
102
+
103
+ There is no `litschema extract`: extraction is judgment work, so it runs as an
104
+ agent skill (`/extract-article <id>`) with the framework checking the output.
105
+ The verb exists only to say so.
106
+
107
+ ## How it works
108
+
109
+ **Intake is offline and content-addressed.** `assemble` derives a stable
110
+ article id from each PDF's filename, moves the PDF into the store, and writes a
111
+ minimal manifest. No DOI, bibliography file, or network access is needed to
112
+ reach extraction, and re-dropping the same PDF is a no-op.
113
+
114
+ **Extraction is agent-executed, framework-checked.** The agent reads only the
115
+ prepared text, writes an extraction plus a line-cited reasoning file, and loops
116
+ until both validate. Validation is closed-world — nothing the schema doesn't
117
+ define gets in — and citations must resolve to real lines in the prepared text,
118
+ so a reference to a line that doesn't exist fails rather than shipping.
119
+
120
+ **Runs are immutable and provenance-bearing.** Publishing records the SHA-256
121
+ of every input — prepared text, domain context, and the skill that conducted
122
+ the extraction — alongside the schema hash and what produced it. Reproduction
123
+ data is computed by the publisher; attribution is recorded as asserted, since
124
+ an agent cannot verify its own model. Nothing is overwritten.
125
+
126
+ **Bibliographic metadata is provenance-locked.** Values fetched from a DOI
127
+ registry are marked and locked; machine-written values may be upgraded but
128
+ human edits are never overwritten without explicit consent. Documents with no
129
+ DOI flow through unchanged.
130
+
131
+ **Review is field-by-field and git-native.** `litschema verify` shows every
132
+ extracted value beside its cited source lines, with the model and effort that
133
+ produced it. You verify a value, correct it, or remove it — one entry per
134
+ field, stored inside the run it reviews. Diffs of `review.json` are the audit
135
+ log. Because a run's payload can never change, a review never goes stale.
136
+
137
+ **Use the reviewed truth.** `export` writes the review-applied extractions as
138
+ JSONL or CSV for pandas, R, or jq. `mcp` (experimental) derives a DuckDB
139
+ database from your schema and serves it read-only. Both apply overrides and
140
+ skip error markers, so they agree.
141
+
142
+ ## Project layout
143
+
144
+ - `src/litschema/` — package code and CLI
145
+ - `specs/` — capability specs and decision logs; start at `specs/README.md`
146
+ - `skills/` — the agent-facing extraction and onboarding instructions
147
+ - `tests/` — framework tests and small project fixtures