zotcli 0.1.0__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 (47) hide show
  1. zotcli-0.1.0/.github/workflows/docs.yml +31 -0
  2. zotcli-0.1.0/.gitignore +35 -0
  3. zotcli-0.1.0/PKG-INFO +538 -0
  4. zotcli-0.1.0/README.md +517 -0
  5. zotcli-0.1.0/SKILL.md +225 -0
  6. zotcli-0.1.0/docs/api_reference.md +33 -0
  7. zotcli-0.1.0/docs/cli_reference.md +11 -0
  8. zotcli-0.1.0/docs/commands.md +182 -0
  9. zotcli-0.1.0/docs/data_models.md +23 -0
  10. zotcli-0.1.0/docs/getting_started.md +64 -0
  11. zotcli-0.1.0/docs/index.md +19 -0
  12. zotcli-0.1.0/mkdocs.yml +32 -0
  13. zotcli-0.1.0/pyproject.toml +51 -0
  14. zotcli-0.1.0/src/zotcli/__init__.py +3 -0
  15. zotcli-0.1.0/src/zotcli/__main__.py +4 -0
  16. zotcli-0.1.0/src/zotcli/cli/__init__.py +0 -0
  17. zotcli-0.1.0/src/zotcli/cli/attachments.py +125 -0
  18. zotcli-0.1.0/src/zotcli/cli/collections.py +100 -0
  19. zotcli-0.1.0/src/zotcli/cli/export.py +111 -0
  20. zotcli-0.1.0/src/zotcli/cli/items.py +111 -0
  21. zotcli-0.1.0/src/zotcli/cli/main.py +71 -0
  22. zotcli-0.1.0/src/zotcli/cli/render.py +93 -0
  23. zotcli-0.1.0/src/zotcli/cli/search.py +82 -0
  24. zotcli-0.1.0/src/zotcli/cli/stats.py +156 -0
  25. zotcli-0.1.0/src/zotcli/config.py +78 -0
  26. zotcli-0.1.0/src/zotcli/db.py +127 -0
  27. zotcli-0.1.0/src/zotcli/export/__init__.py +0 -0
  28. zotcli-0.1.0/src/zotcli/export/bibtex.py +136 -0
  29. zotcli-0.1.0/src/zotcli/export/csv_.py +55 -0
  30. zotcli-0.1.0/src/zotcli/export/json_.py +16 -0
  31. zotcli-0.1.0/src/zotcli/export/markdown.py +51 -0
  32. zotcli-0.1.0/src/zotcli/models.py +145 -0
  33. zotcli-0.1.0/src/zotcli/queries/__init__.py +0 -0
  34. zotcli-0.1.0/src/zotcli/queries/attachments.py +115 -0
  35. zotcli-0.1.0/src/zotcli/queries/collections.py +137 -0
  36. zotcli-0.1.0/src/zotcli/queries/items.py +309 -0
  37. zotcli-0.1.0/src/zotcli/queries/search.py +133 -0
  38. zotcli-0.1.0/src/zotcli/queries/tags.py +41 -0
  39. zotcli-0.1.0/test_script.py +23 -0
  40. zotcli-0.1.0/tests/__init__.py +0 -0
  41. zotcli-0.1.0/tests/conftest.py +140 -0
  42. zotcli-0.1.0/tests/test_cli.py +106 -0
  43. zotcli-0.1.0/tests/test_db.py +46 -0
  44. zotcli-0.1.0/tests/test_export.py +57 -0
  45. zotcli-0.1.0/tests/test_queries.py +137 -0
  46. zotcli-0.1.0/zot.png +0 -0
  47. zotcli-0.1.0/zotcli.code-workspace +17 -0
@@ -0,0 +1,31 @@
1
+ name: Docs Deployment
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ - main
8
+
9
+ permissions:
10
+ contents: write
11
+
12
+ jobs:
13
+ deploy:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - name: Checkout code
17
+ uses: actions/checkout@v4
18
+
19
+ - name: Set up Python
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: '3.11'
23
+
24
+ - name: Install dependencies
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ pip install -e .
28
+ pip install "mkdocs<2" mkdocs-material "mkdocstrings[python]" mkdocs-click
29
+
30
+ - name: Deploy Documentation to GitHub Pages
31
+ run: mkdocs gh-deploy --force
@@ -0,0 +1,35 @@
1
+ .pytest_cache/
2
+ .claude/
3
+
4
+ PLAN.md
5
+ Instructions.md
6
+
7
+ site/
8
+
9
+ tests/__pycache__/*
10
+
11
+ # Comprehensive Python ignore
12
+ **/__pycache__/
13
+ *.pyc
14
+ *.pyo
15
+ *.pyd
16
+
17
+ src/zoterocli/__pycache__/__init__.cpython-310.pyc
18
+ src/zoterocli/__pycache__/config.cpython-310.pyc
19
+ src/zoterocli/__pycache__/db.cpython-310.pyc
20
+ src/zoterocli/__pycache__/models.cpython-310.pyc
21
+ src/zoterocli/cli/__pycache__/__init__.cpython-310.pyc
22
+ src/zoterocli/cli/__pycache__/attachments.cpython-310.pyc
23
+ src/zoterocli/cli/__pycache__/collections.cpython-310.pyc
24
+ src/zoterocli/cli/__pycache__/export.cpython-310.pyc
25
+ src/zoterocli/cli/__pycache__/items.cpython-310.pyc
26
+ src/zoterocli/cli/__pycache__/main.cpython-310.pyc
27
+ src/zoterocli/cli/__pycache__/render.cpython-310.pyc
28
+ src/zoterocli/cli/__pycache__/search.cpython-310.pyc
29
+ src/zoterocli/cli/__pycache__/stats.cpython-310.pyc
30
+ src/zoterocli/queries/__pycache__/__init__.cpython-310.pyc
31
+ src/zoterocli/queries/__pycache__/attachments.cpython-310.pyc
32
+ src/zoterocli/queries/__pycache__/collections.cpython-310.pyc
33
+ src/zoterocli/queries/__pycache__/items.cpython-310.pyc
34
+ src/zoterocli/queries/__pycache__/search.cpython-310.pyc
35
+ src/zoterocli/queries/__pycache__/tags.cpython-310.pyc
zotcli-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,538 @@
1
+ Metadata-Version: 2.4
2
+ Name: zotcli
3
+ Version: 0.1.0
4
+ Summary: A read-only CLI for browsing and exporting a Zotero library
5
+ Author-email: MohamedNumair <mo7amednumair@gmail.com>
6
+ License: MIT
7
+ Requires-Python: >=3.10
8
+ Requires-Dist: click>=8.1
9
+ Requires-Dist: platformdirs>=4.0
10
+ Requires-Dist: pydantic>=2.0
11
+ Requires-Dist: python-dateutil>=2.9
12
+ Requires-Dist: rich>=13.0
13
+ Provides-Extra: all
14
+ Requires-Dist: jinja2>=3.1; extra == 'all'
15
+ Requires-Dist: pybtex>=0.24; extra == 'all'
16
+ Provides-Extra: bibtex
17
+ Requires-Dist: pybtex>=0.24; extra == 'bibtex'
18
+ Provides-Extra: export
19
+ Requires-Dist: jinja2>=3.1; extra == 'export'
20
+ Description-Content-Type: text/markdown
21
+
22
+ # zotcli (`zot`)
23
+ ![alt text](zot.png)
24
+
25
+ A "crazy" good read-only command-line interface for your local [Zotero](https://www.zotero.org/) library. Queries `zotero.sqlite` directly — no Zotero app running, no API key, no internet required. Never writes to the database.
26
+
27
+ **Library stats on this machine:** 3,771 items · 200 collections · 3,201 tags · 6.2 GB storage
28
+
29
+ ---
30
+
31
+ ## Installation
32
+
33
+ ```bash
34
+ pip install zotcli
35
+ ```
36
+
37
+ Verify:
38
+ ```bash
39
+ zot --help
40
+ ```
41
+
42
+ The database at `~/Zotero/zotero.sqlite` is auto-detected on WSL. Override anytime with `--db PATH`.
43
+
44
+ ---
45
+
46
+ ## Repository layout
47
+
48
+ ```
49
+ zotcli/
50
+ ├── PLAN.md # Original design document
51
+ ├── SKILL.md # Agent skill descriptor
52
+ ├── pyproject.toml # Package metadata and dependencies
53
+ ├── docs/
54
+ │ └── commands.md # Full command reference
55
+ ├── src/
56
+ │ └── zotcli/
57
+ │ ├── __init__.py
58
+ │ ├── __main__.py # python -m zotcli entrypoint
59
+ │ ├── db.py # Read-only SQLite connection + auto-discovery
60
+ │ ├── config.py # TOML config (~/.config/zotcli/config.toml)
61
+ │ ├── models.py # Pydantic v2 models: Item, Collection, Creator, Attachment, Note
62
+ │ ├── queries/
63
+ │ │ ├── items.py # Core item fetch (_build_items — fields, creators, tags,
64
+ │ │ │ # collections, attachments, notes in one go)
65
+ │ │ ├── collections.py # Collection tree queries
66
+ │ │ ├── attachments.py # Attachment path resolution helpers
67
+ │ │ ├── tags.py # Tag queries
68
+ │ │ └── search.py # Field search, author search, DOI, year, fulltext
69
+ │ ├── export/
70
+ │ │ ├── json_.py # Full-fidelity JSON dump
71
+ │ │ ├── csv_.py # Flat CSV (one row per item)
72
+ │ │ ├── bibtex.py # BibTeX with auto citation keys
73
+ │ │ └── markdown.py # Markdown table report
74
+ │ └── cli/
75
+ │ ├── main.py # Root Click group + global options
76
+ │ ├── render.py # Shared Rich helpers (tables, panels, trees)
77
+ │ ├── collections.py # `zot collections` subcommands
78
+ │ ├── items.py # `zot items` subcommands
79
+ │ ├── attachments.py # `zot attachments` subcommands
80
+ │ ├── search.py # `zot search`
81
+ │ ├── stats.py # `zot stats` subcommands
82
+ │ └── export.py # `zot export` subcommands
83
+ └── tests/
84
+ ├── conftest.py # In-memory SQLite fixture with seeded test data
85
+ ├── test_db.py # Database layer tests
86
+ ├── test_queries.py # Query layer tests (items, collections, search, tags)
87
+ ├── test_export.py # Export format tests (JSON, CSV, BibTeX, Markdown)
88
+ └── test_cli.py # CLI integration tests via CliRunner
89
+ ```
90
+
91
+ ---
92
+
93
+ ## Architecture
94
+
95
+ ```
96
+ CLI layer (cli/)
97
+ ↓ Click commands call query functions
98
+ Query layer (queries/)
99
+ ↓ Batch SQL via sqlite3.Row
100
+ Database layer (db.py) ← read-only URI: file:zotero.sqlite?mode=ro
101
+
102
+ zotero.sqlite
103
+ ```
104
+
105
+ Every item fetch runs 6 batched queries in one call — fields, creators, tags, collection memberships, attachments (with resolved absolute paths), and notes — so all data is available everywhere without extra round-trips.
106
+
107
+ ---
108
+
109
+ ## Global options
110
+
111
+ These go **before** the subcommand:
112
+
113
+ ```
114
+ zot [--db PATH] [--library ID] [--format table|json|csv] [--no-color] <command>
115
+ ```
116
+
117
+ ---
118
+
119
+ ## Examples with output
120
+
121
+ ### `zot stats` — library overview
122
+
123
+ ```bash
124
+ zot stats
125
+ ```
126
+ ```
127
+ Library Summary
128
+ ┌─────────────┬──────┐
129
+ │ Items │ 3771 │
130
+ │ Collections │ 200 │
131
+ │ Tags │ 3201 │
132
+ │ Creators │ 3959 │
133
+ └─────────────┴──────┘
134
+ Items by Type
135
+ ┏━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
136
+ ┃ Type ┃ Count ┃
137
+ ┡━━━━━━━━━━━━━━━━━━╇━━━━━━━┩
138
+ │ annotation │ 2188 │
139
+ │ journalArticle │ 864 │
140
+ │ conferencePaper │ 234 │
141
+ │ webpage │ 179 │
142
+ │ book │ 77 │
143
+ │ report │ 75 │
144
+ │ preprint │ 43 │
145
+ │ thesis │ 32 │
146
+ │ bookSection │ 25 │
147
+ └──────────────────┴───────┘
148
+ ```
149
+
150
+ ```bash
151
+ zot stats years
152
+ ```
153
+ ```
154
+ Publications by Year
155
+ ┏━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
156
+ ┃ Year ┃ Count ┃ Bar ┃
157
+ ┡━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
158
+ │ 2026 │ 10 │ │
159
+ │ 2025 │ 36 │ ██ │
160
+ │ 2024 │ 110 │ █████████ │
161
+ │ 2023 │ 361 │ ██████████████████████████████ │
162
+ │ 2022 │ 144 │ ███████████ │
163
+ │ 2021 │ 120 │ █████████ │
164
+ │ 2020 │ 101 │ ████████ │
165
+ │ 2019 │ 96 │ ███████ │
166
+ └──────┴───────┴────────────────────────────────┘
167
+ ```
168
+
169
+ ```bash
170
+ zot stats tags --top 10
171
+ ```
172
+ ```
173
+ Top 10 Tags
174
+ ┏━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
175
+ ┃ Tag ┃ Items ┃
176
+ ┡━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━┩
177
+ │ Topology │ 89 │
178
+ │ Voltage measurement │ 77 │
179
+ │ Network topology │ 75 │
180
+ │ State estimation │ 65 │
181
+ │ Distribution networks │ 53 │
182
+ │ thesis │ 50 │
183
+ │ Smart meters │ 48 │
184
+ │ notion │ 47 │
185
+ │ Real-time systems │ 46 │
186
+ │ _EndnoteXML import │ 38 │
187
+ └───────────────────────┴───────┘
188
+ ```
189
+
190
+ ---
191
+
192
+ ### `zot collections` — browse the library tree
193
+
194
+ ```bash
195
+ zot collections list
196
+ ```
197
+ ```
198
+ Collections
199
+ ├── 00_Reading Tracker (2)
200
+ │ ├── Read (12)
201
+ │ ├── Reading (15)
202
+ │ └── To Read (31)
203
+ ├── Energy Management (6)
204
+ │ ├── AI based Energy Management (2)
205
+ │ ├── Demand Response (14)
206
+ │ │ └── Home Energy Management System (3)
207
+ │ ├── Energy Market (75)
208
+ │ ├── Energy Storage (4)
209
+ │ ├── Felixibility (8)
210
+ │ └── Power Flow (16)
211
+ ├── PhD Research (...)
212
+ │ ├── Distribution Systems (...)
213
+ │ └── State Estimation (...)
214
+ └── ...
215
+ ```
216
+
217
+ ```bash
218
+ zot collections items "Energy Market"
219
+ ```
220
+ ```
221
+ Energy Market (73 items)
222
+ ┏━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┓
223
+ ┃ # ┃ Key ┃ Type ┃ Title ┃ Authors ┃ Year ┃
224
+ ┡━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━┩
225
+ │ 1 │ RBUU6AM2 │ journalArticle │ New coordination framework for │ Hussain │ 2023 │
226
+ │ │ │ │ smart home peer-to-peer trading… │ et al. │ │
227
+ │ 2 │ 8DE2V7ZZ │ journalArticle │ Integrating Distributed Flexibility │ Tsaousoglou │ 2023 │
228
+ │ │ │ │ into TSO-DSO Coordinated Markets… │ et al. │ │
229
+ │ 3 │ GKG9XUBE │ thesis │ Adoption of Blockchain in European │ Meyer │ 2023 │
230
+ │ │ │ │ Electricity Markets │ │ │
231
+ └────┴───────────┴────────────────────┴─────────────────────────────────────┴──────────────┴────────┘
232
+ ```
233
+
234
+ Include all sub-collections recursively:
235
+ ```bash
236
+ zot collections items "Energy Management" --recursive
237
+ ```
238
+
239
+ ---
240
+
241
+ ### `zot items` — inspect individual items
242
+
243
+ ```bash
244
+ zot items list --limit 5
245
+ ```
246
+ ```
247
+ ┏━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━┓
248
+ ┃ # ┃ Key ┃ Type ┃ Title ┃ Authors ┃ Year ┃
249
+ ┡━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━┩
250
+ │ 1 │ L54VEEWV │ journalArticle │ Three-phase feeder parameter estimation… │ Yang et al. │ 2026 │
251
+ │ 2 │ B8CNX4LI │ journalArticle │ Coordinated State Estimation of Power… │ Sharma │ 2025 │
252
+ │ 3 │ MXYF8V3J │ journalArticle │ Towards Digital Twin of Distribution… │ Idlbi │ 2026 │
253
+ │ 4 │ YN89DKH4 │ book │ 41st European Photovoltaic Solar Energy… │ │ 2024 │
254
+ │ 5 │ 5UFZMSLU │ journalArticle │ UNLOCKING DATA CENTRE HOSTING CAPACITY… │ Smith │ 2026 │
255
+ └────┴───────────┴────────────────────┴─────────────────────────────────────────────┴─────────────┴────────┘
256
+ ```
257
+
258
+ ```bash
259
+ zot items show 5UFZMSLU
260
+ ```
261
+ ```
262
+ ╭────────────────── journalArticle #6439 5UFZMSLU ──────────────────╮
263
+ │ Title UNLOCKING DATA CENTRE HOSTING CAPACITY AND FLEXIBILITY │
264
+ │ THROUGH DYNAMIC CABLE RATING │
265
+ │ Authors Smith, John; ElKholy, Ahmed M; Martins-Britto, │
266
+ │ Amauri G; Hertem, Dirk Van; Vanin, Marta │
267
+ │ Year 2026 │
268
+ │ abstractNote The unprecedented pace of Distributed Energy │
269
+ │ Resource (DER) integration and electr… │
270
+ │ language en │
271
+ │ │
272
+ │ Attachments │
273
+ │ ✓ Smith et al. - 2026 - UNLOCKING DATA CENTRE…pdf │
274
+ │ │
275
+ │ Notes (1) │
276
+ │ • Annotations(2/25/2026) (Smith et al., 2026, p. 1) … │
277
+ ╰─────────────────────────────────────────────────────────────────────╯
278
+ ```
279
+
280
+ ---
281
+
282
+ ### `zot search` — find items
283
+
284
+ **By title keyword:**
285
+ ```bash
286
+ zot search "bayesian" --field title
287
+ ```
288
+ ```
289
+ 5 result(s)
290
+ ┏━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━┓
291
+ ┃ # ┃ Key ┃ Type ┃ Title ┃ Authors ┃ Year ┃
292
+ ┡━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━┩
293
+ │ 1 │ LVTG4KLQ │ journalArticle │ An Improved Recursive Bayesian Approach │ Chen et al. │ 2013 │
294
+ │ │ │ │ for Transformer Tap Position Estimation │ │ │
295
+ │ 2 │ 6BR3CYQA │ conferencePaper │ Bayesian distribution system state │ Angioni et al. │ 2016 │
296
+ │ │ │ │ estimation in presence of non-Gaussian… │ │ │
297
+ │ 3 │ K2YXXPX7 │ journalArticle │ A Recursive Bayesian Approach for │ Singh et al. │ 2010 │
298
+ │ │ │ │ Identification of Network Configuration… │ │ │
299
+ │ 4 │ CRJWMH2X │ journalArticle │ Real-Time Topology Estimation Using │ Liu et al. │ 2023 │
300
+ │ │ │ │ Graph-Bank Transformer… │ │ │
301
+ │ 5 │ TJH8CGUT │ conferencePaper │ Bayesian Methods for the Identification │ Brouillon │ 2021 │
302
+ │ │ │ │ of Distribution Networks │ et al. │ │
303
+ └────┴───────────┴─────────────────┴───────────────────────────────────────────┴────────────────┴────────┘
304
+ ```
305
+
306
+ **By author name** (queries the creators table, partial match):
307
+ ```bash
308
+ zot search --author "Smith"
309
+ ```
310
+ ```
311
+ 12 result(s)
312
+ ┏━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━┓
313
+ ┃ # ┃ Key ┃ Type ┃ Title ┃ Authors ┃ Year ┃
314
+ ┡━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━┩
315
+ │ 1 │ MDLX3G4P │ conferencePaper │ A Proposed IoT Architecture for Effective │ Smith et al. │ 2020 │
316
+ │ │ │ │ Energy Management in Smart Microgrids │ │ │
317
+ │ 2 │ W3P98AE9 │ conferencePaper │ On the UK smart metering system and value │ Smith et al. │ 2023 │
318
+ │ │ │ │ of data for distribution system… │ │ │
319
+ │ 3 │ UIMHSHNV │ journalArticle │ Fault Detection and Localisation in LV │ Smith et al. │ 2023 │
320
+ │ │ │ │ Distribution Networks Using Smart Meter… │ │ │
321
+ │ 4 │ TAVRNAY6 │ bookSection │ Infrastructure for the 4th Industrial │ Smith et al. │ 2024 │
322
+ │ │ │ │ Revolution Technologies │ │ │
323
+ │ 5 │ 5UFZMSLU │ journalArticle │ UNLOCKING DATA CENTRE HOSTING CAPACITY… │ Smith et al. │ 2026 │
324
+ │ … │ … │ … │ … │ … │ … │
325
+ └────┴───────────┴─────────────────┴───────────────────────────────────────────┴───────────────┴────────┘
326
+ ```
327
+
328
+ **By DOI:**
329
+ ```bash
330
+ zot search --doi "10.1016/j.epsr.2020.106394"
331
+ ```
332
+ ```
333
+ 1 result(s)
334
+ ┏━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━┓
335
+ ┃ # ┃ Key ┃ Type ┃ Title ┃ Authors ┃ Year ┃
336
+ ┡━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━┩
337
+ │ 1 │ ZGYGL35J │ journalArticle │ Preventative high impedance fault │ Langeroudi │ 2020 │
338
+ │ │ │ │ detection using distribution system… │ et al. │ │
339
+ └────┴───────────┴────────────────┴───────────────────────────────────────────┴──────────────────┴────────┘
340
+ ```
341
+
342
+ **By year range:**
343
+ ```bash
344
+ zot search --year 2023 --type conferencePaper
345
+ ```
346
+ ```
347
+ 361 result(s) [truncated to first 5 shown]
348
+ ┏━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━┓
349
+ ┃ # ┃ Key ┃ Type ┃ Title ┃ Authors ┃ Year ┃
350
+ ┡━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━┩
351
+ │ 1 │ ZRF8IFPI │ journalArticle │ Fault Location Method for an Active │ Zhao et al. │ 2023 │
352
+ │ │ │ │ Distribution Network Based on… │ │ │
353
+ │ 2 │ G3USAIB9 │ journalArticle │ PMU Measurements-Based Short-Term │ Li et al. │ 2023 │
354
+ │ │ │ │ Voltage Stability Assessment… │ │ │
355
+ │ 3 │ RBUU6AM2 │ journalArticle │ New coordination framework for smart │ Hussain et al. │ 2023 │
356
+ │ │ │ │ home peer-to-peer trading… │ │ │
357
+ └────┴───────────┴─────────────────┴───────────────────────────────────────────┴─────────────────┴────────┘
358
+ ```
359
+
360
+ ---
361
+
362
+ ### `zot attachments` — locate files
363
+
364
+ **Get the PDF path for a single item:**
365
+ ```bash
366
+ zot attachments path 5UFZMSLU
367
+ ```
368
+ ```
369
+ ~/Zotero/storage/RIB344FW/Smith et al. - 2026 - UNLOCKING DATA CENTRE HOSTING CAPACITY AND FLEXIBILITY THROUGH DYNAMIC CABLE RATING.pdf
370
+ ```
371
+
372
+ **List all attachments for an item (with existence check):**
373
+ ```bash
374
+ zot items attachments W3P98AE9
375
+ ```
376
+ ```
377
+ Attachments for W3P98AE9
378
+ ┏━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
379
+ ┃ Key ┃ Type ┃ Mode ┃ Exists ┃ Path ┃
380
+ ┡━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
381
+ │ GKHSKIP4 │ text/html │ imported_url │ ✓ │ …/storage/GKHSKIP4/10136487.html │
382
+ │ 7PZKGWIJ │ application/pdf │ imported_url │ ✓ │ …/storage/7PZKGWIJ/Smith et al. - 2023… │
383
+ └──────────┴─────────────────┴──────────────┴────────┴───────────────────────────────────────────┘
384
+ ```
385
+
386
+ **Find all missing attachments:**
387
+ ```bash
388
+ zot attachments list --missing
389
+ ```
390
+
391
+ **Open a PDF in the system viewer:**
392
+ ```bash
393
+ zot attachments open 5UFZMSLU
394
+ # Opening: ~/Zotero/storage/RIB344FW/Smith et al. - 2026 - ...pdf
395
+ ```
396
+
397
+ ---
398
+
399
+ ### `zot export` — export to files
400
+
401
+ **BibTeX:**
402
+ ```bash
403
+ zot export bib --collection "Energy Market" --output refs.bib
404
+ ```
405
+ ```bibtex
406
+ @article{hussain_new_2023,
407
+ title = {New coordination framework for smart home peer-to-peer trading…},
408
+ author = {Hussain, Sadam and Azim, M. Imran and Lai, Chunyan and Eicker, Ursula},
409
+ year = {2023},
410
+ journal = {Energy},
411
+ volume = {284},
412
+ pages = {129297},
413
+ doi = {10.1016/j.energy.2023.129297},
414
+ }
415
+
416
+ @article{tsaousoglou_integrating_2023,
417
+ title = {Integrating Distributed Flexibility into TSO-DSO Coordinated Electricity Markets},
418
+ author = {Tsaousoglou, Georgios and Junker, Rune and …},
419
+ year = {2023},
420
+ doi = {10.1109/TEMPR.2023.3319673},
421
+ }
422
+
423
+ ```
424
+
425
+ **CSV:**
426
+ ```bash
427
+ zot export csv --collection "Energy Market" --output refs.csv
428
+ ```
429
+ ```
430
+ item_id,key,item_type,title,year,doi,journal,…,author_1,author_2,…,tags
431
+ 10,RBUU6AM2,journalArticle,New coordination framework…,2023,10.1016/…,Energy,…,"Hussain, Sadam","Azim, M. Imran",…,Smart grid;Flexibility
432
+ 18,8DE2V7ZZ,journalArticle,Integrating Distributed Flexibility…,2023,10.1109/…,…
433
+ ```
434
+
435
+ **JSON** (includes fully resolved attachment paths and notes):
436
+ ```bash
437
+ zot export json --collection "Energy Market" --output refs.json
438
+ ```
439
+ ```json
440
+ [
441
+ {
442
+ "item_id": 10,
443
+ "key": "RBUU6AM2",
444
+ "item_type": "journalArticle",
445
+ "title": "New coordination framework for smart home peer-to-peer trading…",
446
+ "year": "2023",
447
+ "attachments": [
448
+ {
449
+ "key": "PXW7M26P",
450
+ "content_type": "application/pdf",
451
+ "file_exists": true,
452
+ "absolute_path": "~/Zotero/storage/PXW7M26P/Hussain et al. - 2023 - …pdf"
453
+ }
454
+ ],
455
+ "notes": [],
456
+ "tags": ["Smart grid", "Distribution transformer", "Flexibility"],
457
+
458
+ }
459
+ ]
460
+ ```
461
+
462
+ **Markdown:**
463
+ ```bash
464
+ zot export markdown --collection "Energy Market" --output refs.md
465
+ zot export markdown --all --notes --output full-library.md # include notes sections
466
+ ```
467
+
468
+ ---
469
+
470
+ ### Workflow: search → get attachment paths
471
+
472
+ Find all papers with "bayesian" in the title **or** authored by "Smith", then print the PDF path for each:
473
+
474
+ ```python
475
+ from zotcli.db import ZoteroDatabase
476
+ from zotcli.queries.search import search_items, search_by_author
477
+
478
+ DB = "~/Zotero/zotero.sqlite"
479
+
480
+ with ZoteroDatabase(DB) as db:
481
+ bayesian = search_items(db, "bayesian", fields=["title"])
482
+ numair = search_by_author(db, "Smith")
483
+
484
+ seen = set()
485
+ for item in bayesian + numair:
486
+ if item.item_id in seen:
487
+ continue
488
+ seen.add(item.item_id)
489
+ for att in item.attachments:
490
+ if att.file_exists and "pdf" in att.content_type.lower():
491
+ print(f"{item.key}\t{att.absolute_path}")
492
+ ```
493
+
494
+ ```
495
+ LVTG4KLQ ~/Zotero/storage/LVTG4KLQ/Chen2013_BayesianTap.pdf
496
+ 5UFZMSLU ~/Zotero/storage/RIB344FW/Smith et al. - 2026 - UNLOCKING DATA CENTRE…pdf
497
+ W3P98AE9 ~/Zotero/storage/7PZKGWIJ/Smith et al. - 2023 - On the UK smart metering…pdf
498
+
499
+ ```
500
+
501
+ ---
502
+
503
+ ## Running tests
504
+
505
+ ```bash
506
+ python3 -m pytest tests/ -q
507
+ ```
508
+ ```
509
+ ........................................
510
+ 40 passed in 31s
511
+ ```
512
+
513
+ Tests use an in-memory SQLite fixture seeded with synthetic Zotero data. No real database needed.
514
+
515
+ ---
516
+
517
+ ## Configuration
518
+
519
+ Optional persistent config at `~/.config/zotcli/config.toml`:
520
+
521
+ ```toml
522
+ [database]
523
+ path = "~/Zotero/zotero.sqlite"
524
+ library_id = 1
525
+
526
+ [output]
527
+ default_format = "table"
528
+ color = true
529
+ page_size = 50
530
+ ```
531
+
532
+ ---
533
+
534
+ ## Safety
535
+
536
+ - Database opened with `sqlite3://…?mode=ro` — the OS-level read-only URI flag makes writes impossible
537
+ - WAL journal detection warns if Zotero is currently open (pending writes may not be visible yet)
538
+ - No network calls, no Zotero API, no authentication