tracecite 0.0.2__tar.gz → 0.0.3__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 (93) hide show
  1. tracecite-0.0.3/PKG-INFO +374 -0
  2. tracecite-0.0.3/README.md +334 -0
  3. {tracecite-0.0.2 → tracecite-0.0.3}/pyproject.toml +22 -6
  4. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/cli.py +180 -90
  5. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/docs/build.py +4 -3
  6. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/evidence/chunking.py +60 -13
  7. tracecite-0.0.3/src/tracecite/evidence/commands.py +730 -0
  8. tracecite-0.0.3/src/tracecite/evidence/embedding.py +100 -0
  9. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/evidence/manifest.py +17 -8
  10. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/evidence/page_extraction.py +3 -1
  11. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/evidence/page_output.py +2 -2
  12. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/evidence/page_selection.py +21 -46
  13. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/evidence/parsers/markdown.py +7 -1
  14. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/evidence/parsers/pdf.py +10 -4
  15. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/evidence/paths.py +24 -0
  16. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/evidence/schema.py +25 -19
  17. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/evidence/sync.py +450 -658
  18. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/evidence/vector_backend.py +10 -6
  19. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/evidence/verify.py +65 -97
  20. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/using-tracecite/SKILL.md +2 -2
  21. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/using-tracecite/references/pdf-and-assets.md +14 -7
  22. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/using-tracecite/references/schema-and-migrations.md +1 -1
  23. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/using-tracecite/references/synchronisation.md +3 -8
  24. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/writing-evidence-backed-reports/SKILL.md +1 -1
  25. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/writing-evidence-backed-reports/fixtures/validate_fixtures.py +1 -1
  26. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/writing-evidence-backed-reports/references/quotation-and-verification.md +2 -1
  27. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/tables/html.py +18 -85
  28. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/tables/models.py +93 -1
  29. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/tables/normalise.py +3 -2
  30. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/tables/pandoc.py +20 -96
  31. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/tables/publish.py +13 -3
  32. tracecite-0.0.3/src/tracecite.egg-info/PKG-INFO +374 -0
  33. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite.egg-info/requires.txt +9 -3
  34. {tracecite-0.0.2 → tracecite-0.0.3}/tests/test_bootstrap_docs.py +1 -1
  35. {tracecite-0.0.2 → tracecite-0.0.3}/tests/test_build_docs.py +1 -2
  36. {tracecite-0.0.2 → tracecite-0.0.3}/tests/test_docs.py +7 -5
  37. {tracecite-0.0.2 → tracecite-0.0.3}/tests/test_tables.py +7 -0
  38. tracecite-0.0.2/PKG-INFO +0 -320
  39. tracecite-0.0.2/README.md +0 -294
  40. tracecite-0.0.2/src/tracecite/evidence/commands.py +0 -552
  41. tracecite-0.0.2/src/tracecite/evidence/embedding.py +0 -59
  42. tracecite-0.0.2/src/tracecite.egg-info/PKG-INFO +0 -320
  43. {tracecite-0.0.2 → tracecite-0.0.3}/LICENSE +0 -0
  44. {tracecite-0.0.2 → tracecite-0.0.3}/setup.cfg +0 -0
  45. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/__init__.py +0 -0
  46. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/__main__.py +0 -0
  47. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/docs/__init__.py +0 -0
  48. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/docs/config.py +0 -0
  49. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/docs/contract.py +0 -0
  50. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/docs/modes.py +0 -0
  51. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/docs/stage.py +0 -0
  52. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/docs/vectorize.py +0 -0
  53. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/evidence/__init__.py +0 -0
  54. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/evidence/config.py +0 -0
  55. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/evidence/parsers/__init__.py +0 -0
  56. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/evidence/parsers/base.py +0 -0
  57. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/evidence/parsers/workbook.py +0 -0
  58. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/evidence/source_links.py +0 -0
  59. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/routing-documentation-source-links/SKILL.md +0 -0
  60. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/routing-documentation-source-links/agents/openai.yaml +0 -0
  61. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/routing-documentation-source-links/references/documenter-integration.md +0 -0
  62. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/routing-documentation-source-links/references/registry-contract.md +0 -0
  63. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/routing-documentation-source-links/references/staging-and-rewriting.md +0 -0
  64. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/routing-documentation-source-links/references/validation-and-failure-modes.md +0 -0
  65. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/using-tracecite/agents/openai.yaml +0 -0
  66. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/using-tracecite/references/architecture.md +0 -0
  67. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/using-tracecite/references/retrieval.md +0 -0
  68. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/using-tracecite/references/workspace-runtime.md +0 -0
  69. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/writing-evidence-backed-reports/agents/openai.yaml +0 -0
  70. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/writing-evidence-backed-reports/fixtures/README.md +0 -0
  71. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/writing-evidence-backed-reports/fixtures/reports/invalid-bad-path.md +0 -0
  72. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/writing-evidence-backed-reports/fixtures/reports/invalid-grammar.md +0 -0
  73. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/writing-evidence-backed-reports/fixtures/reports/invalid-missing-definition.md +0 -0
  74. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/writing-evidence-backed-reports/fixtures/reports/invalid-page-not-indexed.md +0 -0
  75. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/writing-evidence-backed-reports/fixtures/reports/invalid-unindexed-path.md +0 -0
  76. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/writing-evidence-backed-reports/fixtures/reports/valid-grammar.md +0 -0
  77. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/writing-evidence-backed-reports/fixtures/reports/valid-report.md +0 -0
  78. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/writing-evidence-backed-reports/fixtures/source-links.toml +0 -0
  79. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/writing-evidence-backed-reports/references/images-and-source-links.md +0 -0
  80. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/writing-evidence-backed-reports/references/reference-style-citations.md +0 -0
  81. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/skills/writing-evidence-backed-reports/references/report-structure.md +0 -0
  82. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/tables/__init__.py +0 -0
  83. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/tables/_text.py +0 -0
  84. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/tables/document.py +0 -0
  85. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/tables/render.py +0 -0
  86. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite/tables/site.py +0 -0
  87. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite.egg-info/SOURCES.txt +0 -0
  88. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite.egg-info/dependency_links.txt +0 -0
  89. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite.egg-info/entry_points.txt +0 -0
  90. {tracecite-0.0.2 → tracecite-0.0.3}/src/tracecite.egg-info/top_level.txt +0 -0
  91. {tracecite-0.0.2 → tracecite-0.0.3}/tests/test_repository_tree.py +0 -0
  92. {tracecite-0.0.2 → tracecite-0.0.3}/tests/test_skills.py +0 -0
  93. {tracecite-0.0.2 → tracecite-0.0.3}/tests/test_version.py +0 -0
@@ -0,0 +1,374 @@
1
+ Metadata-Version: 2.4
2
+ Name: tracecite
3
+ Version: 0.0.3
4
+ Summary: Source-linked table normalisation and evidence retrieval for executable documentation
5
+ Author: ARPST-UniMelb
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/yasirroni/tracecite
8
+ Project-URL: Documentation, https://yasirroni.github.io/tracecite/
9
+ Project-URL: Issues, https://github.com/yasirroni/tracecite/issues
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Operating System :: MacOS
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Scientific/Engineering
16
+ Classifier: Topic :: Text Processing :: Indexing
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: beautifulsoup4>=4.12
21
+ Requires-Dist: PyYAML>=6.0
22
+ Requires-Dist: tabulate>=0.9
23
+ Provides-Extra: docs
24
+ Requires-Dist: ipykernel>=7.3; extra == "docs"
25
+ Requires-Dist: nbclient>=0.11; extra == "docs"
26
+ Requires-Dist: nbformat>=5.10; extra == "docs"
27
+ Requires-Dist: tracecite[pandas]; extra == "docs"
28
+ Provides-Extra: evidence
29
+ Requires-Dist: huggingface-hub<2,>=1.23; extra == "evidence"
30
+ Requires-Dist: pymupdf<2,>=1.28; extra == "evidence"
31
+ Requires-Dist: sentence-transformers<6,>=5.6; extra == "evidence"
32
+ Requires-Dist: sqlite-vec<0.2,>=0.1.9; extra == "evidence"
33
+ Provides-Extra: pandas
34
+ Requires-Dist: pandas>=2.0; extra == "pandas"
35
+ Provides-Extra: test
36
+ Requires-Dist: build>=1.2; extra == "test"
37
+ Requires-Dist: pytest<9,>=8.4; extra == "test"
38
+ Requires-Dist: tracecite[pandas]; extra == "test"
39
+ Dynamic: license-file
40
+
41
+ # TraceCite
42
+
43
+ TraceCite lets people and AI agents search their documents, cite the exact page or cell, and check that a quote matches its source.
44
+
45
+ Its core is source-linked table normalisation. Tables in rendered Python or Julia documentation stay unchanged as the original evidence, and TraceCite derives deterministic, self-describing row text from them for search.
46
+
47
+ TraceCite also indexes Markdown, PDF, `.xlsx`, and `.xlsm` files. It stores retained text, source hashes, full-text and vector search records, and locators (PDF pages, Markdown lines, and worksheet ranges), and verifies quotations and report citations against them.
48
+
49
+ `tracecite docs index` adds a project's retained documentation and its normalised tables to an evidence index. `tracecite docs stage` routes source links to local files or public URLs.
50
+
51
+ ## Core architecture
52
+
53
+ ```text
54
+ Python or Julia executable page
55
+ -> Quarto retained Pandoc Markdown
56
+ -> raw table evidence
57
+ -> HTML site
58
+
59
+ retained Markdown
60
+ -> `tracecite prepare` CLI/package
61
+ -> canonical table model
62
+ -> row-oriented retrieval text
63
+ -> diagnostics
64
+ -> optional embedding-inspection website copy
65
+ ```
66
+
67
+ The normal site is pure Quarto output. The inspection copy, which doubles each table, is generated only on request.
68
+
69
+ `tracecite docs build docs` discovers configured executable inputs, builds the complete site when both runtimes are available or falls back to the available one with a warning naming each skipped file, stages retained Markdown, and optionally renders the inspection site. `tracecite prepare` does the table normalisation.
70
+
71
+ The evidence path is separate from the documentation renderer:
72
+
73
+ ```text
74
+ declared PDF, Markdown, or workbook sources
75
+ -> retained source extraction
76
+ -> locator-aware chunks
77
+ -> SQLite FTS5 and sqlite-vec
78
+ -> ranked JSON results with source identity and evidence locators
79
+ ```
80
+
81
+ ## Prerequisites
82
+
83
+ - Python 3.11 or newer;
84
+ - Pandoc, standalone or bundled with Quarto;
85
+ - Quarto for documentation-site renders;
86
+ - Julia 1.10 or newer, only for Julia documentation pages.
87
+
88
+ The Python normaliser and CLI work without Julia. Automatic builds fall back to the Python overlay when configured Julia inputs cannot run; `--only julia` builds need Julia.
89
+
90
+ Install TraceCite from PyPI. Evidence synchronisation and hybrid search need the `evidence` extra; Quarto documentation builds with Python pages also need the `docs` extra. `knowledge_table` and `computed_first_row_summary` take a pandas DataFrame, which the `pandas` extra installs:
91
+
92
+ ```sh
93
+ pip install "tracecite[evidence]"
94
+ pip install "tracecite[evidence,docs]"
95
+ ```
96
+
97
+ The `evidence` extra installs PyTorch through `sentence-transformers`. On Linux, pip installs the CUDA build by default, a download of several gigabytes. On a machine without a GPU, install the CPU build first:
98
+
99
+ ```sh
100
+ pip install torch --index-url https://download.pytorch.org/whl/cpu
101
+ ```
102
+
103
+ Workbook parsing reads OOXML packages with only the Python standard library, without Excel, Julia, Quarto, or third-party workbook readers.
104
+
105
+ ## Usage
106
+
107
+ The `tracecite` CLI normalises tables and documents, builds documentation, and syncs and searches source evidence. `prepare` reads retained Markdown after a Quarto render and creates the optional inspection copy.
108
+
109
+ ### Public API
110
+
111
+ ```python
112
+ from tracecite.tables import (
113
+ normalise_pandoc_table,
114
+ normalise_html_table,
115
+ normalise_document_tables,
116
+ )
117
+ ```
118
+
119
+ `normalise_pandoc_table()` is the core contract. It accepts one Pandoc table and returns raw evidence, canonical Markdown, normalised text, row records, diagnostics, hashes, and version metadata.
120
+
121
+ Each row gets a deterministic `row_id`, which follows the logical row rather than its rank or position when `row_identity` metadata is supplied.
122
+
123
+ `normalise_html_table()` supports Literate.jl, Documenter.jl, PrettyTables, notebook HTML MIME, row spans, and column spans through an HTML-to-canonical-Markdown adapter.
124
+
125
+ ### Normalise one table
126
+
127
+ ```sh
128
+ tracecite table normalise table.md --to text
129
+ tracecite table normalise table.html --from html --to debug-markdown
130
+ ```
131
+
132
+ ### Normalise one document
133
+
134
+ ```sh
135
+ tracecite document normalise report.md --to jsonl
136
+ tracecite document normalise report.md --to embedding-markdown --output report.embedding.md
137
+ ```
138
+
139
+ ### Index and search source evidence
140
+
141
+ List sources in a manifest by explicit path or by include and exclude globs over `.pdf`, `.md`, `.xlsx`, and `.xlsm` files.
142
+
143
+ ```toml
144
+ schema_version = 1
145
+
146
+ [[source]]
147
+ path = "2023-iasr-ev-workbook.xlsx"
148
+ ```
149
+
150
+ Sync the sources into a database, search it lexically and semantically, then check its integrity:
151
+
152
+ ```sh
153
+ tracecite sync \
154
+ --root sources \
155
+ --manifest tracecite-sources.toml \
156
+ --database .tracecite/evidence.sqlite \
157
+ --model-cache-dir .tracecite/model-cache
158
+
159
+ tracecite search \
160
+ "weekday versus weekend electric vehicle charging behaviour" \
161
+ --database .tracecite/evidence.sqlite \
162
+ --model-cache-dir .tracecite/model-cache
163
+
164
+ tracecite doctor --database .tracecite/evidence.sqlite
165
+ ```
166
+
167
+ #### Sync
168
+
169
+ - `sync` needs at least one `[[source]]` or `[[include]]` rule; without one, it stops without creating or changing the database.
170
+ - It prints one line per added, reparsed, renamed, missing, or unselected path; `--json` prints the full report.
171
+ - A declared `[[source]]` missing under the root is listed under `missing-sources`. A selected file that sync cannot read or parse, or that is a symlink, is listed under `skipped` with the reason; a skipped file indexed earlier keeps its previous rows. Either case ends with `status: incomplete` and exit 1, and the other sources still sync. A sync of one path checks only that path.
172
+ - A second `sync` or `prune --apply` of the same database waits for the first to finish. The wait uses an empty `<database>.lock` file beside the database.
173
+ - PDF pages without text, such as blank or scanned pages, are listed under `pages-without-text` when they are parsed, and `doctor` lists them on every run. Scanned pages need [Tesseract](https://github.com/tesseract-ocr/tesseract) for OCR; without it, sync stores those pages without text. After installing it, run `tracecite sync --full` to extract their text.
174
+ - `sync` is incremental and non-pruning. Sources that are gone or no longer selected stay searchable and citable until you preview and apply `tracecite prune`.
175
+
176
+ #### Prune
177
+
178
+ `prune` needs the source root (`--root` or a profile). It targets indexed sources the rules no longer select or whose file is gone from the root; the preview lists the latter under `missing_paths`. `--all` targets every indexed source and needs no root. `prune --apply` also compacts the database file.
179
+
180
+ #### Doctor
181
+
182
+ `doctor` warns about PDF pages without text, and with `--root <dir>` about sources that changed or disappeared since the last sync. Only database, vector, and asset integrity issues change its exit status; the last line counts the warnings.
183
+
184
+ #### Search
185
+
186
+ `search --source-type` (`pdf`, `markdown`, or `workbook`; repeatable) filters lexical and vector candidates before ranking and the `--limit` cut, not after:
187
+
188
+ ```sh
189
+ tracecite search "coal retirement" \
190
+ --database .tracecite/evidence.sqlite \
191
+ --source-type pdf
192
+ ```
193
+
194
+ - An empty query exits with status 2.
195
+ - `--lexical-only` uses full-text search alone and skips loading the embedding model.
196
+ - Chinese, Japanese, and Korean (CJK) text has no spaces, so lexical search also matches each CJK run of the query as a substring of the indexed text. This reads every passage, so it is slower than ordinary full-text search on a large database.
197
+ - The embedding model is English-only, so vector search leaves out the CJK text of a query. A query with only CJK text uses lexical search only.
198
+ - Byte-identical files at different paths give one hit, under the shortest path (then the first in sort order), with the others in `duplicate_paths`.
199
+
200
+ Each result includes retrieval provenance and a source-specific locator. This abbreviated workbook result shows the stable fields; the worksheet and ranges vary with the workbook and chunk settings:
201
+
202
+ ```json
203
+ {
204
+ "source_path": "inputs-and-assumptions.xlsx",
205
+ "source_type": "workbook",
206
+ "source_sha256": "<64-character SHA-256>",
207
+ "locator": {
208
+ "kind": "excel-range",
209
+ "sheet": "<worksheet name>",
210
+ "range": "<bounding A1 range>",
211
+ "range_kind": "bounding",
212
+ "exact_ranges": ["<exact A1 range>"]
213
+ },
214
+ "provenance": ["lexical", "vector"]
215
+ }
216
+ ```
217
+
218
+ The path and SHA-256 identify the workbook version, and the worksheet and `exact_ranges` identify the passage's cells. `range` is only the bounding rectangle and can include other cells. Rank only marks candidate evidence, so inspect the returned cells before citing a result.
219
+
220
+ A portable workbook citation is the path, SHA-256, worksheet, and A1 ranges. Opening the exact range needs a workbook viewer or a separate provider-specific link.
221
+
222
+ #### Workbook boundaries
223
+
224
+ - The parser supports `.xlsx` and `.xlsm` OOXML packages, not legacy binary `.xls`.
225
+ - It keeps stored text, numeric, Boolean, error, formula, and cached formula values. Cached values reflect the workbook's stored state; formulae are not recalculated.
226
+ - It reads stored package content only and does not run VBA or refresh external links, Power Query, pivot caches, or data connections.
227
+ - It ignores style-only empty cells and does not reconstruct display formatting, so styled dates and times can stay numeric serials.
228
+ - It chunks workbooks by row and does not yet infer formal Excel tables or carry complex multi-row headers into every row.
229
+
230
+ ### Retrieve retained pages and visual evidence
231
+
232
+ `tracecite page` prints retained PDF page text from the SQLite evidence database, physical page 1 by default. Selectors combine pages and closed or open ranges; overlaps are merged and pages come back in ascending physical order.
233
+
234
+ ```sh
235
+ tracecite page reports/example.pdf --database evidence.sqlite
236
+ tracecite page reports/example.pdf 5,12-15,20 --database evidence.sqlite
237
+ tracecite page reports/example.pdf 97- --database evidence.sqlite
238
+ tracecite page reports/example.pdf -20 --database evidence.sqlite
239
+ tracecite page reports/example.pdf all --database evidence.sqlite
240
+ ```
241
+
242
+ Only `all` implicitly selects the whole source, and it must stand alone. Multi-page text output marks each physical page, and a page with no text, such as a scanned page synced without OCR, adds a note on stderr. `--format json` returns an ordered array of retained text, extraction metadata, a citation link, and validated paths to the indexed page render and figure crops. Search results carry the same render and crop fields for page-local PDF matches.
243
+
244
+ `extract-pages` takes the same selectors and writes a derivative PDF and provenance manifest from the indexed source PDF. The output directory must already exist outside the source root; stale sources, symlinked output directories, overlap, and overwrites are refused.
245
+
246
+ ```sh
247
+ mkdir -p ../tracecite-exports
248
+ tracecite extract-pages reports/example.pdf 5,12-15,20 \
249
+ --database evidence.sqlite \
250
+ --output-dir ../tracecite-exports
251
+ ```
252
+
253
+ Answer page-local questions from database text or indexed page assets; select `all` only when you need the whole source.
254
+
255
+ ### Verify quotations
256
+
257
+ `tracecite verify quote` checks a quotation against the retained text of one physical page, or a contiguous range such as `4-5` for a quotation that crosses a page break:
258
+
259
+ ```sh
260
+ tracecite verify quote reports/example.pdf 4-5 "Exact quotation" --database evidence.sqlite
261
+ ```
262
+
263
+ - `exact`: the quotation occurs verbatim.
264
+ - `normalised`: matches after collapsing whitespace, straightening curly quotes and apostrophes, and ignoring case.
265
+ - `not-found`: anything else, including one changed word.
266
+ - `page-not-indexed` or `source-not-indexed`: the page range or the source is not in the database; these exit 2, other failures exit 1.
267
+
268
+ Verification reads only the indexed text, so run `tracecite sync` after a file changes to check against the new version.
269
+
270
+ ### Build the documentation
271
+
272
+ ```sh
273
+ uv run tracecite docs build docs
274
+ uv run tracecite docs build docs_quarto_py --only python
275
+ uv run tracecite docs build docs_quarto_jl --only julia
276
+ ```
277
+
278
+ <!-- TODO:
279
+ Explain the expected `[WARNING] Could not fetch resource`
280
+ -->
281
+
282
+ Without Julia, the builder names each Julia source it skips and renders the Python overlay, leaving Julia sources untouched. `--only python` or `--only julia` builds one language. Projects with their own Quarto render can run `tracecite prepare` on their staged retained Markdown.
283
+
284
+ `docs/examples/report-adoption/aemo-isp-comparison/` is a complete author -> check -> index -> search -> doctor -> publish-only example using two AEMO Integrated System Plan reports.
285
+
286
+ `docs/examples/report-adoption/aemo-isp-comparison/docs/tracecite.toml` demonstrates the documentation evidence contract. Schema version 1 defines exactly `authored_root`, `retained_root`, `staged_root`, `source_links`, `index_output`, `publication_exclude`, and optional `host_render_command` under `[docs]`. Contract paths are repository-relative and stay inside the repository.
287
+
288
+ Open the built site:
289
+
290
+ ```sh
291
+ open docs/build/index.html
292
+ ```
293
+
294
+ ### Direct preparation command
295
+
296
+ ```sh
297
+ tracecite prepare docs/build \
298
+ --project-config docs/_quarto.yml \
299
+ --project-profile python \
300
+ --source-project docs \
301
+ --keep-embedding-markdown .tracecite/embedding-site \
302
+ --render-embedding-site
303
+ ```
304
+
305
+ The copy includes `_tracecite/tables.jsonl` and `_tracecite/manifest.json`, and its `_quarto.yml` keeps the selected profile's theme and navigation without execution engines or build hooks. It is disposable, gitignored, and excluded from recursive ingestion.
306
+
307
+ Its Markdown keeps each original table for audit and appends the normalised form for inspection. Normal indexing reads `tables.jsonl` or `NormalisedTable` objects directly and needs no copy.
308
+
309
+ ### Install the agent skills
310
+
311
+ TraceCite bundles three AI agent skills: `using-tracecite`, `writing-evidence-backed-reports`, and `routing-documentation-source-links`. Copy them into the project's `.agents/skills/` directory:
312
+
313
+ ```sh
314
+ tracecite skills install
315
+ ```
316
+
317
+ `--target` picks another directory, such as Claude Code's personal skills:
318
+
319
+ ```sh
320
+ tracecite skills install --target ~/.claude/skills
321
+ ```
322
+
323
+ Rerunning it replaces the copies with the installed version's skills.
324
+
325
+ ## Contributing
326
+
327
+ ### Environment
328
+
329
+ The core package needs only Python.
330
+
331
+ ```sh
332
+ uv venv
333
+ source .venv/bin/activate
334
+ uv pip install -e ".[docs,evidence,test]"
335
+ ```
336
+
337
+ `requirements.txt` pins runtime and evidence dependencies to the newest versions `pyproject.toml` allows; install it for a reproducible environment. Refresh it with [`pru`](https://github.com/yasirroni/pru); installing `-e ".[evidence]"` in the same command keeps upgrades within `pyproject.toml` bounds:
338
+
339
+ ```sh
340
+ uv pip install -r requirements.txt
341
+ pru -r requirements.txt upgrade_requirements --cmd 'uv pip install --upgrade -e ".[evidence]"'
342
+ ```
343
+
344
+ Building the whole `docs/` also needs the Julia environment:
345
+
346
+ ```sh
347
+ julia --project=. -e 'using Pkg; Pkg.instantiate()'
348
+ ```
349
+
350
+ ### Lint and format
351
+
352
+ On each commit, [pre-commit](https://pre-commit.com/) runs [Ruff](https://docs.astral.sh/ruff/) on changed Python files and [ty](https://github.com/astral-sh/ty) on the whole project. Install it once and enable the hook:
353
+
354
+ ```sh
355
+ uv tool install pre-commit
356
+ pre-commit install
357
+ ```
358
+
359
+ `pre-commit run --all-files` checks every file. [Pyright](https://github.com/microsoft/pyright), the checker behind Pylance, runs only on request with `pre-commit run --hook-stage manual pyright --all-files`.
360
+
361
+ ### Test
362
+
363
+ Python tests and build:
364
+
365
+ ```sh
366
+ python -m pytest
367
+ uv build
368
+ ```
369
+
370
+ The Julia package is tested by `docs/examples/julia/dirty_dataframe.jl`, which the documentation build runs with its hidden checks:
371
+
372
+ ```sh
373
+ tracecite docs build docs
374
+ ```