1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293 | README.md the user-facing overview: what this is, the Quickstart, hardware sizing
bench/ parser measurement (dev-only, not shipped) -- see "Benchmarking the parser"
above; corpus.json/sample*.json are generated and gitignored, results/ is
committed evidence
bench_docling.py backend extraction timings, one process
sweep_sync.py the real `python -m chitragupta.corpus sync` swept over worker/GPU counts -- the harness
every pool-level figure must come from
run_parallel.py independent-process baseline; answers a different question to sweep_sync.py
make_corpus.py builds the gitignored work lists from your own bib file
repro_check.py compares two parses at three levels (bytes, passage spans, passage texts)
and self-checks its own detector on every run
SOUL.md one page: why this exists, the one invariant, what it refuses to become
AGENTS.md instructions for agents drafting *with* the pipeline -- the citekey
invariant, the four layers, retrieval
DEVELOPER-AGENTS.md instructions for agents changing *this repo* -- install notes, dev
process, commit/PR/release conventions
DEVELOPER.md this file -- test running, repo layout, open questions
DOCKER.md how do I run this in a container -- the toolchain image and the agent image
DOCKER-DEVELOPER.md how the toolchain and agent images are built and verified before a release
.github/ CI/release workflows, plus the issue and PR templates GitHub picks up
automatically and RELEASE_TEMPLATE.md (copied by hand)
docs/ reference docs that ship in the release zip -- everything except the
root-level ones above, which stay put because they're what a reader looks
for first. README.md's Documentation tables and mkdocs.yml's nav index
them. Every file here carries a status line on its third line,
`Status: **<kind>.**`, so a reader can tell what they are holding before
reading it -- one of:
tutorial. a lesson a reader follows start to finish
how-to. a procedure for a task the reader already has
reference. what exists and how to look it up
implemented. a built subsystem, described as built
reasoning document. why a decision went the way it did, kept
because the reasoning outlives the decision
measurements. numbers from a real run on a named machine
proposal. nothing here is built; the decision is open
A new document picks one of those rather than inventing an eighth. The
line carries no date: git records when a file was written and revised
Not every file here is on the documentation site: mkdocs.yml's
exclude_docs keeps proposals, reasoning documents, developer-only pages
and the research surveys in git and out of the site, and pages that link
to them use GitHub URLs
DIAGRAMS.md the workflow drawn fourteen ways (off the site; read on GitHub)
diagrams/ every fenced mermaid block under docs/ as standalone files: DIAGRAMS.md's
fourteen, and the ones marked `<!-- diagram: <name> -->` in other pages
*.mmd mermaid sources with a title line
svg/*.svg the browser export; pdf/*.pdf the vector export for papers and slides.
Exports only -- edit the fenced block, run scripts/render_diagrams.py
--sync (house theme + .mmd copy), then re-render, which writes both
svg/sources.json which .mmd fingerprint each svg/pdf pair was rendered from; pinned by a
test, as is every export's width (at most 920px, to read on the site)
images/ demo recording (svg, mp4, webm, gif), the README's topic-map still, and
the topic-graph screenshots under discovery/ (captured at 2x density)
figure-checks/ one page per `figure check` rule family, with faulty/fixed examples
writing-standards/ the element and genre files the drafting skills read as rules
book/ the step-by-step pages of the book tutorial
examples/ the committed sample project and harness examples (examples/README.md)
stylesheets/ mermaid.css, generated by render_diagrams.py --sync
logo.svg, logo-dark.svg the README banner, light and dark
LICENSE MIT
THIRD-PARTY-NOTICES.md every shipped file written elsewhere: where it is, upstream, licence and
copyright line; tests/test_third_party_notices.py fails on one it misses
licenses/ the licence texts THIRD-PARTY-NOTICES.md links to
assets/ data files the pipeline reads at runtime, tracked and shipped
csl/ieee.csl the CSL style pandoc formats citations with ([render].csl default).
Vendored byte-identical to the CSL project's own release (CC BY-SA 3.0)
so it can be re-fetched and diffed -- do not edit it in place; the one
attribute this project needs is injected into a temp copy at render
time (see assets/csl/README.md and render_output._collapsed_csl)
csl/README.md the vendoring policy, upstream URL and sha256
webapp/app/ the webapp build from frontend/: gitignored, but shipped in the wheel,
the sdist and the release zip (docs/PACKAGING.md)
frontend/ the webapp's source: a Vue 3 + Vite app, its vitest tests and its
Puppeteer end-to-end test; never shipped (docs/PACKAGING.md)
.github/workflows/ ci.yml (on push/PR: test suite + coverage + uv lock --check on Linux and
Windows, the hook launchers, the lint job, the frontend job, the
webapp's end-to-end test, a Docker build and SonarQube),
commit-message.yml (checks a PR's squash-commit fence),
docs.yml (builds the documentation site on every PR, and publishes it on
every push to main, with no release needed) and release.yml
(on a vX.Y.0 tag: verifies tag matches pyproject.toml's version, builds
the webapp and scripts/release.py's zip, then the wheel and sdist;
publishes all three to a GitHub Release, and the wheel and sdist to
PyPI)
config.toml.example tracked template for the central config -- paths, parser backend, worker
count, embedding model. Copy to config.toml (gitignored, per-host) before
anything imports chitragupta.core.config; see docs/CONFIG.md
papers/ gitignored, per-host data -- not shipped in the repo
bibliography.bib BibTeX export -- source of truth for citekeys/metadata (config.toml's [bib].path default)
bibliography/ the export's companion attachment folder, referenced by each entry's file field
pyproject.toml PEP 621 project metadata -- a real, publishable package (name chitragupta-cli,
import package chitragupta, [build-system] = poetry-core, which decides the
files a wheel carries; docs/PACKAGING.md has the decision and the naming) +
uv/pytest/coverage tool config
uv.lock resolved dependency versions -- `uv lock` after editing a constraint
(re-resolves the whole graph in seconds; docs/UV-MIGRATION.md)
mkdocs.yml the documentation site published at prasad.talasila.in/chitragupta. `docs_dir: .`
on purpose: the site is this repository as it stands, so links between site
pages work unchanged and there is no staging step to keep in sync; a link to
a page in exclude_docs must be a GitHub URL. Built by
.github/workflows/docs.yml from pyproject.toml's optional `docs` extra
(`uv sync --extra docs`). Read its header before editing
chitragupta/ the package: the public entry points at the top level, every front end in
cli/, every module behind them in core/ (docs/ARCHITECTURE.md, "Where the
code lives")
__main__.py shim for the `chitragupta`/`cg` console scripts and `python -m chitragupta`,
whose code is cli/main.py
corpus.py, sync.py shims for `python -m chitragupta.corpus`, whose code is cli/corpus/, and for
the removed `chitragupta.sync`, which refuses with exit 64
draft.py shim for `python -m chitragupta.draft gate|dossier|retrieve|references|
render|...`, twelve verbs (see --help), whose code is cli/draft/
review.py, enrich.py, figure.py shims for `python -m chitragupta.review|enrich|figure`, whose code
is cli/review/, cli/enrich.py and cli/figure/
init.py, doctor.py, install.py shims for the package-level commands, whose code is
cli/init.py, cli/doctor.py and cli/install.py, over the core modules
of the same names (docs/PACKAGING.md)
webapp/ the loopback-only webapp (docs/SECURITY.md); serve.py refuses or starts the
server for cli/webapp.py
cli/ the command-line front ends: one module per verb, no `_cli` suffix and no
__main__ block
main.py the `chitragupta`/`cg` command tree: dispatches corpus, draft, review,
enrich, init, doctor, install, figure and the hidden webapp
command_help.py, help_format.py every layer's one-line help, read without importing the layers,
and the ClickParser every --help is laid out with
corpus/ the corpus layer's single entry point, `python -m chitragupta.corpus
sync|ledger|topics|discover`. Imports the verb it was given rather than both,
so asking for `ledger` never pays for sync's bibtexparser -- see
docs/ARCHITECTURE.md on why that one is not like the other dispatchers
sync.py orchestrates a sync over core/corpus/ -- the corpus layer's `sync` verb;
--remove-stale opts into deleting stale ledger rows (default: report only,
see docs/ZOTERO.md)
ledger.py the read-only `ledger` verb's parser and text; its views are
core/corpus/ledger_view.py's. No __main__ block, like sync.py
topics.py the read-only `topics` verb's parser and text, over core/corpus/seed_topics.py
discover.py the read-only `discover` verb's parser and text, over core/corpus/discover/
draft/ the drafting layer's single entry point; one module per verb with its own
parser (gate, dossier, retrieve, references, evidence, render, style, spec,
unit, registry, tldr, figures, diff), plus the book track's private
_book_run.py, _spec_lines.py and _registry_lines.py and dossier's
_dossier_*.py renderers. gate.py and its core import
only the standard library, so the gate runs under a bare python3
review/ the review layer's single entry point: one parser, eleven subcommands, each
wired to its aid's own build_parser()/run(): every aid has its module
here, over its core builder, with _emit.py printing it (verbatim's
four modes print through _verbatim_render.py) and _registry.py, the
one name->module map, keyed by review.AIDS.
No __main__ block of their own -- see docs/ARCHITECTURE.md on why a
layer's command surface stays one level deep
enrich.py the enrichment layer's entry point, `python -m chitragupta.enrich --stages โฆ`;
orchestrates the stages in core/corpus/enrich/, which carry no __main__
block of their own
figure/ `chitragupta figure sync|check|new|look`: the dispatcher's one parser, and
one module per verb with its subparser and text, over the builders in
core/figure/_commands.py and _look_command.py
webapp.py `chitragupta webapp`'s parser; imports chitragupta.webapp only inside main,
so parsing never loads the web stack
doctor.py, init.py, install.py the package commands' parsers and text, over the core modules
of the same names; install's child inherits the terminal
core/ every module behind the entry points, grouped by layer; the ones more
than one layer reads sit here directly
config.py every setting, as config.NAME; env var overrides
config_load.py the config.toml load and the typed getters config.py reads each setting through
config_enrich.py the [enrich]/[discover] knobs, re-exported by config.py as config.NAME
config_path.py whether a path lies inside content/, re-exported by config.py (docs/SECURITY.md)
version.py the installed distribution's version, for --version and the webapp's status
runlock.py one-writer-at-a-time lock over content/, held by `chitragupta.corpus sync` and
`chitragupta.enrich` -- the only two commands that write to it;
a dedicated sqlite file, so a killed holder releases it with no
staleness check and readers are never blocked
reference_entries.py citekey -> formatted IEEE entry from the ledger, and the refusal of a key it lacks;
shared by references.py, evidence_appendix.py and discover
overlap_index.py disk-cached word n-gram fingerprint index (content/overlap/) for
core/review/verbatim_check/'s overlap and scan modes -- one .fpr file per citekey plus
a merged, binary-searchable corpus-wide index.bin, both keyed by
(pdf_hash, parsed-file stat) so a re-run over an unchanged corpus costs no
re-fingerprinting. Read-only over the corpus layer, no writer lock
corpus/ the corpus layer (sync needs bibtexparser)
bib_reader.py parses bibliography.bib -- the only citekey source
ledger.py per-citekey status tracking (content/ledger.sqlite); find_stale/prune_missing
detect/remove rows for citekeys no longer in the bib file. Also persists each
entry's formatting-relevant BibTeX fields (bib_fields, JSON), so references.py
can build a full bibliography entry without reading the bib file itself
ledger_view.py `corpus ledger`'s five views of the ledger, as data; read-only, no lock
pdf_text/ PDF text extraction, dispatched to pdftotext/docling by config.PARSER; also the parse-quality guard
dedup.py advisory near-duplicate citekey detection (shared DOI/title), called from sync
reranker.py the cross-encoder loader, cached per model id; shared by enrich's search rerank
and discover's ladder, so neither imports the other's privates
discover/ `corpus discover`: the topic-graph walks, the HTML page and the offline app
enrich/ the enrichment layer (pyproject.toml's "enrich" extra), optional; its
entry point is cli/enrich.py
corpus.py the enrichment layer's view of the ledger -- one CorpusDoc per bib item,
so every enriched document is citable, keyed by its citekey
docling_parse.py, embed_index.py, topic_model.py, topic_seeding.py, topic_converge.py
draft/ the drafting layer (citation_gate/references need nothing)
retrieval.py BM25 search over the corpus layer, backed by a cached term-frequency index.
`search` ranks and returns a snippet -- the best-covering passage for the
query, and the same one every run; `evidence` (retrieve.py, beside the
`retrieve` verb's builders) reads more of one document when a snippet is
not enough to judge it. A lookup, not a stage: see docs/REJECTION.md for
the two-stage read that was built and withdrawn. `--log` records each
call's payload in the dossier
passages.py where a citekey's supporting text comes from (docling sidecar -> form-feed
pages -> pdftotext) and whether it may be quoted -- shared by the consumers
that need to point at part of a source rather than all of it
citation_gate.py hard citation-verification gate -- the drafting layer must pass this
dossier/ the working state behind a draft (reader, scope, kept evidence, rejected
candidates, steering, revision log) as Markdown under content/dossiers/,
mirroring the draft's path; plus tar.gz backup/restore. Read-only over the
corpus layer, never a gate -- see docs/DRAFT-ITERATION.md
references.py auto-generates a draft's "## References" section from its own cited citekeys,
as numbered IEEE entries ordered by first appearance -- the same order (and
so the same numbers) pandoc's citeproc assigns when the draft is rendered
render.py the `render` verb's builder: render_output's render, its figures' looks,
and every render failure raised as a refusal
render_output/ Pandoc/TeX Live rendering -- stdlib-only, no enrich group
needed, which is why it sits in the drafting layer and not in core/corpus/enrich/.
`--format md` on a Markdown draft skips pandoc entirely and emits
references.numbered_markdown's plain numbered copy instead
review/ the review layer -- one command, `python -m chitragupta.review <aid>`, eleven aids
__init__.py the layer's shared output contract -- report path (content/review/,
mirroring the draft), the "not a gate" banner, the header, and the
write-md-then-render routine all eleven aids use. No timestamp, so a
report diffs across revisions
citation_coverage.py `coverage` -- retrieval-candidates-vs-actually-cited report, not a gate
citation_provenance.py `provenance` -- what in each cited source supports the claim citing it,
not a gate (scores claims against passages.py's ladder; see
docs/CITATION-PROVENANCE.md)
synthesis.py `synthesis` -- how many sources each unit of the draft rests on, at the
unit its genre binds at (docs/WRITING-STANDARDS.md ยง11), not a gate
uncited_prose.py `uncited` -- which sentences carry no citation at all, the prose-side
question `coverage` does not answer. The one aid that reads no corpus
verbatim_check/ `verbatim` -- per-citekey overlap, whole-draft x whole-corpus scan, and
page-locating checks against sources
figure_layout/ `figure` -- a TikZ figure's own pre-flight defects (occlusion, chaotic
routing, illegible type, ...), not a gate -- see docs/TIKZ-STYLE.md
_blocks.py what a *block* is -- a table row, a list item, a heading -- in both
markups. Shared by provenance and uncited_prose; neither owns it
_aids.py each aid's builder by name, for a caller that runs an aid without its
command (agenda --baseline's refresh)
_claims.py which sentences of a draft carry a claim, and which are scaffolding.
Split from uncited_prose so the roadmap's C2 can share it
_units.py what a "unit" is per genre, and how each genre treats uncited prose --
the two per-genre policy tables, pinned against dossier.GENRES
_synthesis_render.py how a synthesis report reads; _uncited_render.py is the same for uncited
figure/ `chitragupta figure sync|check|new|look`, the figure-drawer toolkit
(docs/figure-checks/README.md)
scripts/ dev tooling only -- no layer entry point lives here
install_full_pipeline.sh single staged install path for host, Docker and CI: os-deps, python-deps,
dev-deps, all, plus the opt-in cpu-torch, gpu-torch, vale, actionlint, stix-two, frontend-deps
release.py bundles a distributable release/chitragupta-<version>.zip, dev files excluded
tests/ pytest suite -- unit tests per module + end-to-end feature tests (see "Running tests"),
mirroring the package: tests/core/<layer>/, tests/cli/<layer>/ and tests/webapp/;
tests of scripts/, hooks, skills and docs sit in tests/ itself, and tests/topic_app/
holds the topic app's node --test files
content/ generated, gitignored (regenerate with sync)
ledger.sqlite, parsed/<citekey>.txt, drafts/, dossiers/, rendered/, review/,
retrieval_index.json, overlap/,
docling/, chroma/, topics.json, topic_seeds.json, topic_set.json,
topic_embed_cache.json (chitragupta/core/corpus/enrich/ outputs)
logs/ gitignored -- pipeline.log, rotated at 5MB x 5 backups. Level from
config.toml's [logging]; relocate with the LOGS_DIR env var
.claude/skills/ drafting layer: six that write a draft (survey-writer,
thesis-chapter-writer, textbook-chapter-writer, tutorial-writer,
deep-research, review-digest), three that revise one that already exists
(draft-reviser, corpus-reviser, agenda-reviser), one that
assembles accepted units into a book (book-assembler), and one
that draws a figure for the others (figure-drawer). Each has a
SKILL.md and, where it needs one, a references/ folder read on
demand. Plus demo-recorder, which records the feature demo, and
skill-bench, which measures a skill change on three harnesses:
developer-only, so no distribution ships them (docs/HARNESS.md)
.claude/skills-common/ references/ shared by several skills (the genre writers' shared steps,
a book skill's shared steps, collection scoping, critique, render and references, prose check,
verbatim scan, mathematical prose, figures/tables/equations in a
revision, digest copying), kept once for all harnesses
.claude/agents/ deep-research's subagents: deep-research-interviewer, deep-research-writer, peer-reviewer
.claude/hooks/ citation_gate_hook.py and style_check_hook.py -- PostToolUse hooks,
mechanically enforcing the citation gate and the prose style check on
every Write/Edit under content/drafts/*.md and *.tex (see AGENTS.md);
code_standards_hook.py reports C1/C2 on a .py write in a checkout;
session_start_hook.py checks the project can draft at all; draft_target.py
is the shared "which file did this tool call touch" helper both PostToolUse
hooks use; safe_path.py decides whether their children may import
chitragupta from the project root (checkout) or not (installed project);
patch_paths.py reads the drafts an apply_patch payload touches (Codex, OpenCode)
.claude/settings.json wires the four hooks above into PostToolUse/SessionStart
.agents/skills/ Codex's copy of each skill's SKILL.md (references stay in .claude/);
.codex/hooks.json runs the same hooks on apply_patch
.opencode/ OpenCode's copy of each SKILL.md (-opencode suffix), its gate plugin, and
opencode.json's deny list for the unsuffixed names (docs/HARNESS.md)
docker/ Dockerfile (TeX Live/Pandoc/uv), Dockerfile.claude + docker-compose.yml +
entrypoint.sh + rc-daemon.sh/.env + .env.example (the Claude Code agent container, cpu/gpu profiles)
-- CI builds docker/Dockerfile (cpu variant) but never runs it, and does not
build Dockerfile.claude; see DOCKER-DEVELOPER.md
|