distill-llm 0.0.0-stage → 0.1.2

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 (103) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +272 -2
  3. package/dist/chunk-FBCOKT2K.js +11 -0
  4. package/dist/chunk-Q5CAXHFO.js +721 -0
  5. package/dist/chunk-ROC3I56H.js +8 -0
  6. package/dist/chunk-RTN2Y4DU.js +15 -0
  7. package/dist/chunk-SQZKYQKD.js +209 -0
  8. package/dist/chunk-UVRKYYN3.js +54 -0
  9. package/dist/chunk-Y4YPRDH4.js +36 -0
  10. package/dist/cli.js +1146 -0
  11. package/dist/distill-N6M4JVDW.js +107 -0
  12. package/dist/http-FBJI242Y.js +110 -0
  13. package/dist/server-3URWVN27.js +124 -0
  14. package/dist/start-E2GNRY52.js +331 -0
  15. package/dist/stdio-UK54TTMU.js +12 -0
  16. package/dist/web/assets/distill.worker-hV97YZ73.js +3310 -0
  17. package/dist/web/assets/index-CtYIsavR.css +1 -0
  18. package/dist/web/assets/index-riXuPwDr.js +26 -0
  19. package/dist/web/assets/inter-cyrillic-400-normal-HOLc17fK.woff +0 -0
  20. package/dist/web/assets/inter-cyrillic-400-normal-obahsSVq.woff2 +0 -0
  21. package/dist/web/assets/inter-cyrillic-500-normal-BasfLYem.woff2 +0 -0
  22. package/dist/web/assets/inter-cyrillic-500-normal-CxZf_p3X.woff +0 -0
  23. package/dist/web/assets/inter-cyrillic-600-normal-4D_pXhcN.woff +0 -0
  24. package/dist/web/assets/inter-cyrillic-600-normal-CWCymEST.woff2 +0 -0
  25. package/dist/web/assets/inter-cyrillic-700-normal-CjBOestx.woff2 +0 -0
  26. package/dist/web/assets/inter-cyrillic-700-normal-DrXBdSj3.woff +0 -0
  27. package/dist/web/assets/inter-cyrillic-ext-400-normal-BQZuk6qB.woff2 +0 -0
  28. package/dist/web/assets/inter-cyrillic-ext-400-normal-DQukG94-.woff +0 -0
  29. package/dist/web/assets/inter-cyrillic-ext-500-normal-B0yAr1jD.woff2 +0 -0
  30. package/dist/web/assets/inter-cyrillic-ext-500-normal-BmqWE9Dz.woff +0 -0
  31. package/dist/web/assets/inter-cyrillic-ext-600-normal-Bcila6Z-.woff +0 -0
  32. package/dist/web/assets/inter-cyrillic-ext-600-normal-Dfes3d0z.woff2 +0 -0
  33. package/dist/web/assets/inter-cyrillic-ext-700-normal-BjwYoWNd.woff2 +0 -0
  34. package/dist/web/assets/inter-cyrillic-ext-700-normal-LO58E6JB.woff +0 -0
  35. package/dist/web/assets/inter-greek-400-normal-B4URO6DV.woff2 +0 -0
  36. package/dist/web/assets/inter-greek-400-normal-q2sYcFCs.woff +0 -0
  37. package/dist/web/assets/inter-greek-500-normal-BIZE56-Y.woff2 +0 -0
  38. package/dist/web/assets/inter-greek-500-normal-Xzm54t5V.woff +0 -0
  39. package/dist/web/assets/inter-greek-600-normal-BZpKdvQh.woff +0 -0
  40. package/dist/web/assets/inter-greek-600-normal-plRanbMR.woff2 +0 -0
  41. package/dist/web/assets/inter-greek-700-normal-BUv2fZ6O.woff +0 -0
  42. package/dist/web/assets/inter-greek-700-normal-C3JjAnD8.woff2 +0 -0
  43. package/dist/web/assets/inter-greek-ext-400-normal-DGGRlc-M.woff2 +0 -0
  44. package/dist/web/assets/inter-greek-ext-400-normal-KugGGMne.woff +0 -0
  45. package/dist/web/assets/inter-greek-ext-500-normal-2j5mBUwD.woff +0 -0
  46. package/dist/web/assets/inter-greek-ext-500-normal-C4iEst2y.woff2 +0 -0
  47. package/dist/web/assets/inter-greek-ext-600-normal-B8X0CLgF.woff +0 -0
  48. package/dist/web/assets/inter-greek-ext-600-normal-DRtmH8MT.woff2 +0 -0
  49. package/dist/web/assets/inter-greek-ext-700-normal-BoQ6DsYi.woff +0 -0
  50. package/dist/web/assets/inter-greek-ext-700-normal-qfdV9bQt.woff2 +0 -0
  51. package/dist/web/assets/inter-latin-400-normal-C38fXH4l.woff2 +0 -0
  52. package/dist/web/assets/inter-latin-400-normal-CyCys3Eg.woff +0 -0
  53. package/dist/web/assets/inter-latin-500-normal-BL9OpVg8.woff +0 -0
  54. package/dist/web/assets/inter-latin-500-normal-Cerq10X2.woff2 +0 -0
  55. package/dist/web/assets/inter-latin-600-normal-CiBQ2DWP.woff +0 -0
  56. package/dist/web/assets/inter-latin-600-normal-LgqL8muc.woff2 +0 -0
  57. package/dist/web/assets/inter-latin-700-normal-BLAVimhd.woff +0 -0
  58. package/dist/web/assets/inter-latin-700-normal-Yt3aPRUw.woff2 +0 -0
  59. package/dist/web/assets/inter-latin-ext-400-normal-77YHD8bZ.woff +0 -0
  60. package/dist/web/assets/inter-latin-ext-400-normal-C1nco2VV.woff2 +0 -0
  61. package/dist/web/assets/inter-latin-ext-500-normal-BxGbmqWO.woff +0 -0
  62. package/dist/web/assets/inter-latin-ext-500-normal-CV4jyFjo.woff2 +0 -0
  63. package/dist/web/assets/inter-latin-ext-600-normal-CIVaiw4L.woff +0 -0
  64. package/dist/web/assets/inter-latin-ext-600-normal-D2bJ5OIk.woff2 +0 -0
  65. package/dist/web/assets/inter-latin-ext-700-normal-Ca8adRJv.woff2 +0 -0
  66. package/dist/web/assets/inter-latin-ext-700-normal-TidjK2hL.woff +0 -0
  67. package/dist/web/assets/inter-vietnamese-400-normal-Bbgyi5SW.woff +0 -0
  68. package/dist/web/assets/inter-vietnamese-400-normal-DMkecbls.woff2 +0 -0
  69. package/dist/web/assets/inter-vietnamese-500-normal-DOriooB6.woff2 +0 -0
  70. package/dist/web/assets/inter-vietnamese-500-normal-mJboJaSs.woff +0 -0
  71. package/dist/web/assets/inter-vietnamese-600-normal-BuLX-rYi.woff +0 -0
  72. package/dist/web/assets/inter-vietnamese-600-normal-Cc8MFFhd.woff2 +0 -0
  73. package/dist/web/assets/inter-vietnamese-700-normal-BZaoP0fm.woff +0 -0
  74. package/dist/web/assets/inter-vietnamese-700-normal-DlLaEgI2.woff2 +0 -0
  75. package/dist/web/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
  76. package/dist/web/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
  77. package/dist/web/assets/jetbrains-mono-cyrillic-700-normal-BWTpRfYl.woff2 +0 -0
  78. package/dist/web/assets/jetbrains-mono-cyrillic-700-normal-CEoEElIJ.woff +0 -0
  79. package/dist/web/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
  80. package/dist/web/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
  81. package/dist/web/assets/jetbrains-mono-greek-700-normal-C6CZE3T8.woff2 +0 -0
  82. package/dist/web/assets/jetbrains-mono-greek-700-normal-DEigVDxa.woff +0 -0
  83. package/dist/web/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
  84. package/dist/web/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  85. package/dist/web/assets/jetbrains-mono-latin-700-normal-BYuf6tUa.woff2 +0 -0
  86. package/dist/web/assets/jetbrains-mono-latin-700-normal-D3wTyLJW.woff +0 -0
  87. package/dist/web/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
  88. package/dist/web/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
  89. package/dist/web/assets/jetbrains-mono-latin-ext-700-normal-CZipNAKV.woff2 +0 -0
  90. package/dist/web/assets/jetbrains-mono-latin-ext-700-normal-CxPITLHs.woff +0 -0
  91. package/dist/web/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
  92. package/dist/web/assets/jetbrains-mono-vietnamese-700-normal-BDLVIk2r.woff +0 -0
  93. package/dist/web/assets/space-grotesk-latin-700-normal-CwsQ-cCU.woff +0 -0
  94. package/dist/web/assets/space-grotesk-latin-700-normal-RjhwGPKo.woff2 +0 -0
  95. package/dist/web/assets/space-grotesk-latin-ext-700-normal-BQnZhY3m.woff2 +0 -0
  96. package/dist/web/assets/space-grotesk-latin-ext-700-normal-HVCqSBdx.woff +0 -0
  97. package/dist/web/assets/space-grotesk-vietnamese-700-normal-DMty7AZE.woff2 +0 -0
  98. package/dist/web/assets/space-grotesk-vietnamese-700-normal-Duxec5Rn.woff +0 -0
  99. package/dist/web/favicon.png +0 -0
  100. package/dist/web/index.html +15 -0
  101. package/lingua-runtime/package-lock.json +1028 -0
  102. package/lingua-runtime/package.json +13 -0
  103. package/package.json +99 -4
package/LICENSE ADDED
@@ -0,0 +1,202 @@
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 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 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 those 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
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Jesus Nieves
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,273 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <img src=".github/assets/banner.png" alt="distill: Documents in. Fewer tokens out." width="100%">
3
+ </p>
2
4
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
5
+ <p align="center">
6
+ <b>Turn PDFs, Office files and scans into token-lean Markdown for your LLM and your coding agent.</b><br>
7
+ Local-first. No telemetry. Web app, desktop app, CLI, MCP server and Claude Code / OpenCode hooks.
8
+ </p>
9
+
10
+ <p align="center">
11
+ <a href="https://github.com/nievesjesus/distill/actions/workflows/ci.yml"><img src="https://github.com/nievesjesus/distill/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
12
+ <a href="https://www.npmjs.com/package/distill-llm"><img src="https://img.shields.io/npm/v/distill-llm?color=C8F53C&labelColor=0B0B10" alt="npm"></a>
13
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-C8F53C?labelColor=0B0B10" alt="License: Apache-2.0"></a>
14
+ <img src="https://img.shields.io/badge/node-%E2%89%A522.12-C8F53C?labelColor=0B0B10" alt="Node 22.12+">
15
+ <img src="https://img.shields.io/badge/runs-100%25%20local-C8F53C?labelColor=0B0B10" alt="Runs 100% local">
16
+ </p>
17
+
18
+ <p align="center">
19
+ <a href="https://nievesjesus.github.io/distill/">Website</a> ·
20
+ <a href=".github/assets/distill-launch.mp4">Launch video</a> ·
21
+ <a href="#quick-start">Quick start</a> ·
22
+ <a href="#use-it-from-your-agent">Agents (MCP + hooks)</a> ·
23
+ <a href="#faq">FAQ</a>
24
+ </p>
25
+
26
+ <p align="center">
27
+ <img src=".github/assets/demo.gif" alt="Dropping five PDFs into distill and watching the token counts drop" width="720">
28
+ </p>
29
+
30
+ ## Why
31
+
32
+ Coding agents read PDFs the expensive way. We asked Anthropic's token counting API how many input tokens Claude needs for five demo PDFs, once as the raw PDF and once as distill's Markdown:
33
+
34
+ | Document | Pages | Raw PDF | distill Markdown | Saved |
35
+ |---|---:|---:|---:|---:|
36
+ | `vendor-contract.pdf` | 7 | 14,021 | 2,829 | **−80%** |
37
+ | `product-roadmap.pdf` | 8 | 16,518 | 3,870 | **−77%** |
38
+ | `q3-financial-report.pdf` | 12 | 24,978 | 6,357 | **−75%** |
39
+ | `inventory-export.pdf` | 9 | 24,091 | 9,871 | **−59%** |
40
+ | `sales-ledger.pdf` | 7 | 18,693 | 8,066 | **−57%** |
41
+ | **Total** | 43 | **98.3k** | **31.0k** | **−68%** |
42
+
43
+ <sub>Measured on 2026-11-07 with <code>POST /v1/messages/count_tokens</code> and <code>claude-sonnet-5-5</code>. The documents are generated by <code>scripts/marketing/make-demo-docs.mjs</code> and the numbers are reproducible with <code>npm run marketing:measure</code>. Your files will differ.</sub>
44
+
45
+ On top of that, distill's lossless boosters trim another 10% from LiteParse's Markdown on the same files (24.9k → 22.4k `o200k_base` tokens). LiteParse already returns clean Markdown, so that extra step is modest; it is bigger on table- and link-heavy documents.
46
+
47
+ ## Features
48
+
49
+ - **One engine, many doors.** The same local pipeline behind a web app, a desktop app, a Docker image, a CLI, an MCP server and hooks for Claude Code and OpenCode.
50
+ - **Real parsing.** [LiteParse](https://github.com/run-llama/liteparse) by LlamaIndex reads PDFs, DOCX, PPTX, XLSX, ODF and images (with OCR).
51
+ - **Lossless boosters.** Small, deterministic passes drop repeated boilerplate, image paths and link targets, table padding and extra whitespace. Content words stay.
52
+ - **Optional LLMLingua-2.** A local model for when you want to go further and accept a lossy result. Off by default, installed on demand.
53
+ - **Honest numbers.** Every file's before and after token counts come from a real tokenizer, live in the UI.
54
+ - **Private by design.** Files are parsed on your machine. No telemetry, no analytics, no CDN.
55
+
56
+ ## Quick start
57
+
58
+ ```bash
59
+ npx distill-llm
60
+ ```
61
+
62
+ This starts a local server at `http://127.0.0.1:4321` and opens the web UI. Drop files in, read the Markdown, copy it or download it (one `.md` or a ZIP of all of them).
63
+
64
+ <p align="center">
65
+ <img src=".github/assets/screenshot-compact.png" alt="Compact view with five files and their token savings" width="45%">
66
+ &nbsp;
67
+ <img src=".github/assets/screenshot-detailed.png" alt="Detailed view with the booster switches" width="45%">
68
+ </p>
69
+
70
+ ## Use it from your agent
71
+
72
+ ### MCP server
73
+
74
+ Give any MCP client three tools: `distill_file`, `distill_files` and `distill_capabilities`.
75
+
76
+ ```bash
77
+ claude mcp add distill -- npx -y distill-llm mcp
78
+ ```
79
+
80
+ Any other client:
81
+
82
+ ```json
83
+ {
84
+ "mcpServers": {
85
+ "distill": { "command": "npx", "args": ["-y", "distill-llm", "mcp"] }
86
+ }
87
+ }
88
+ ```
89
+
90
+ `distill_file({ path, boosters?, lingua? })` returns the Markdown plus `{ tokens: { raw, out }, pages, kind }`. `distill_files` takes up to 20 paths and reports a per-file error instead of failing the whole call.
91
+
92
+ For clients that speak HTTP, `distill-llm mcp --http` serves Streamable HTTP at `http://127.0.0.1:4322/mcp`. Over HTTP the server only reads files inside the directories you pass with `--root` (repeatable, default: the current directory) and compares real paths, so symlinks cannot escape. It rejects cross-site requests and answers only to loopback names, IP addresses and the hostnames you list with `--allowed-hosts`, which blocks DNS rebinding.
93
+
94
+ <details>
95
+ <summary>Remote clients such as ChatGPT connectors</summary>
96
+
97
+ The HTTP server has **no authentication**: anyone who can reach it can read every file under `--root`. Never publish it directly to the internet. To use it from a remote client:
98
+
99
+ 1. Point `--root` at a folder that holds only the documents you want to share.
100
+ 2. Put an HTTPS tunnel **with authentication** in front of it (for example Cloudflare Tunnel with Cloudflare Access, or Tailscale Funnel restricted to your tailnet).
101
+ 3. Allow the tunnel's hostname, or every request gets 403:
102
+
103
+ ```bash
104
+ distill-llm mcp --http --root ~/shared-docs --allowed-hosts distill.example.com
105
+ ```
106
+
107
+ 4. Add `https://distill.example.com/mcp` as the connector URL in your client.
108
+ </details>
109
+
110
+ ### Hooks: make your agent read Markdown instead of the binary
111
+
112
+ ```bash
113
+ npm i -g distill-llm
114
+ distill-llm hooks install --claude # Claude Code
115
+ distill-llm hooks install --opencode # OpenCode
116
+ ```
117
+
118
+ - **Claude Code:** adds a `PreToolUse` hook on `Read` to `~/.claude/settings.json` (or your personal `.claude/settings.local.json` with `--project`). When Claude reads a PDF or Office file inside the project it is working in, the hook converts it once, caches it by content hash in `~/.cache/distill-llm/out/` (private to your user) and points the read at the Markdown. It also adds the permission rule `Read(~/.cache/distill-llm/out/**)` so those reads do not prompt.
119
+ - **OpenCode** (experimental): writes a plugin to `~/.config/opencode/plugins/distill.js` (or `.opencode/plugins/` with `--project`) that does the same on `tool.execute.before` for `read`. OpenCode's plugin API is changing; if the plugin does not apply, OpenCode simply reads the original file.
120
+
121
+ The installer shows the exact change and asks before writing (`--yes` skips the question). It keeps your other settings, follows symlinked dotfiles, keeps the file mode, and masks existing values in the diff it prints. `distill-llm hooks uninstall --claude|--opencode` removes only what it added. Install it globally first: a command written from a temporary `npx` run would disappear.
122
+
123
+ The hooks respect your permissions and never block a read:
124
+
125
+ - Files outside the project the agent works in are not converted, so Claude Code asks you about them as usual.
126
+ - If any `deny` or `ask` rule for `Read` exists in your user, project (any parent folder or `CLAUDE_PROJECT_DIR`), local or managed settings, or one of those files can't be read, the Claude Code hook stays out of the way entirely. Rules passed on the command line (`--settings`, `--disallowedTools`) are invisible to hooks.
127
+ - Images and CSV files are left alone.
128
+ - If anything fails (a missing file, a timeout, a password-protected PDF, a scan with no text), the agent reads the original file.
129
+
130
+ Set `DISTILL_HOOK=off` to disable the Claude Code hook for a session.
131
+
132
+ ### CLI
133
+
134
+ ```bash
135
+ npx distill-llm convert report.pdf deck.pptx --out md/
136
+ ```
137
+
138
+ | Option | Does |
139
+ |---|---|
140
+ | `--out <dir>` | Write the `.md` files into a directory (default: next to each input) |
141
+ | `--boosters <list>` | Only these boosters: `dedupe`, `media`, `tables`, `ws` |
142
+ | `--no-optimize` | Plain LiteParse Markdown, no boosters |
143
+ | `--lingua [--rate 0.5]` | Add LLMLingua-2 (must be installed from the web app first) |
144
+ | `--json` | Print a JSON array with tokens, pages and timings per file |
145
+ | `--stdout` | Print the Markdown of a single file instead of writing it |
146
+
147
+ Each file prints a summary such as `report.pdf → report.md 5.7k → 4.6k tokens (−19%)`. The exit code is 1 if any file failed; the others are still converted.
148
+
149
+ ## Desktop app and Docker
150
+
151
+ **Desktop:** installers for macOS (arm64, x64), Windows (x64) and Linux (x64) are on [GitHub Releases](https://github.com/nievesjesus/distill/releases). They are named without a version (`Distill-lite-mac-arm64.dmg`, `Distill-lite-mac-x64.dmg`, `Distill-lite-win-x64.exe`, `Distill-lite-linux-x86_64.AppImage`), so `https://github.com/nievesjesus/distill/releases/latest/download/<file>` always points at the newest release. `Distill-lite-*` has everything except LLMLingua-2; `Distill-full-*` bundles its runtime and is published for Apple Silicon, Windows x64 and Linux x64. Intel Macs get the lite build only.
152
+
153
+ <details>
154
+ <summary>Unsigned installers: how to open them the first time</summary>
155
+
156
+ - **macOS 15 and later:** open the app once and dismiss the warning, then go to System Settings > Privacy & Security and click **Open Anyway**.
157
+ - **macOS 14 and earlier:** right-click the app, choose **Open**, then confirm **Open**.
158
+ - **"The app is damaged":** run `xattr -dr com.apple.quarantine /Applications/distill.app` and open it again.
159
+ - **Windows:** in the SmartScreen dialog click **More info**, then **Run anyway**.
160
+
161
+ Release builds are signed when the signing certificates are configured; if your installer is unsigned, the steps above apply. The desktop app has no auto-update. OCR data is bundled; Office files still need LibreOffice installed.
162
+ </details>
163
+
164
+ **Docker:** LibreOffice and the English OCR data are included, so every format works out of the box.
165
+
166
+ ```bash
167
+ docker run --rm -p 4321:4321 -v distill-cache:/home/node/.cache ghcr.io/nievesjesus/distill
168
+ ```
169
+
170
+ Open it as `http://localhost:4321` or by IP, or pass `-e DISTILL_ALLOWED_HOSTS=<name>` to reach it by hostname. Build it yourself with `docker build -t distill .`.
171
+
172
+ ## How it works
173
+
174
+ ```mermaid
175
+ flowchart LR
176
+ A[PDF · DOCX · PPTX · XLSX · images] --> B[LiteParse<br/>local parse + OCR]
177
+ B --> C[Boosters<br/>dedupe · media · tables · ws]
178
+ C --> D{LLMLingua-2?<br/>optional, lossy}
179
+ D --> E[Markdown + token counts]
180
+ E --> F[Web · Desktop · CLI · MCP · Hooks]
181
+ ```
182
+
183
+ | Booster | What it does | Loss |
184
+ |---|---|---|
185
+ | Drop repeated boilerplate | Removes identical running header/footer lines (4+ words, 25+ chars, 3+ repeats) and page-number lines such as `Page 3 of 12`. Lines that differ in any character are kept. | None |
186
+ | Slim images and links | `![alt](path)` becomes `[alt]`, `[text](url)` becomes `text` | Drops image paths and URLs |
187
+ | Compact tables | Removes alignment padding from GFM tables | None |
188
+ | Collapse whitespace | Collapses blank-line runs, trailing and double spaces outside code | None |
189
+ | LLMLingua-2 | A local model removes low-value words | **Lossy**, off by default |
190
+
191
+ Boosters are pure, idempotent functions and never touch fenced code blocks or front matter. In the web app they run in your browser, so switching one on or off updates the counts instantly. If you need link targets, turn off "Slim images and links".
192
+
193
+ <details>
194
+ <summary>LLMLingua-2 details</summary>
195
+
196
+ LLMLingua-2 is optional and experimental. It needs Apple Silicon, Windows x64 or Linux x64: its ONNX runtime has no Intel Mac build, so on Intel Macs the row explains this instead of offering an install. When `npm` is available, its row shows **Install (~520 MB)**: one click runs `npm ci --omit=dev --include=peer --ignore-scripts` against a lockfile with pinned versions and integrity hashes and installs the runtime into `~/.cache/distill-llm/lingua`. The first use downloads the model (TinyBERT, about 57 MB) from Hugging Face into `~/.cache/distill-llm/models`; after that it runs offline. Behind a proxy that intercepts HTTPS, give Node your organization's CA with `NODE_EXTRA_CA_CERTS=/path/to/ca.pem`. Never turn off certificate checks.
197
+ </details>
198
+
199
+ ## Supported formats
200
+
201
+ | Format | Needs |
202
+ |---|---|
203
+ | PDF | nothing else |
204
+ | PNG, JPG, TIFF, WebP | nothing else (OCR built in; English data is downloaded once, about 15 MB) |
205
+ | DOCX, PPTX, XLSX, ODF | [LibreOffice](https://www.libreoffice.org/download/) on your `PATH` (`soffice`); included in Docker |
206
+
207
+ Password-protected PDFs are reported as an error. Parsing quality is whatever LiteParse gives you: it varies on dense tables and complex scans, and distill does not try to hide that.
208
+
209
+ ## Privacy
210
+
211
+ Files are parsed locally and never leave your machine. There is no telemetry, no analytics and no CDN: fonts are bundled. distill makes at most three one-time downloads, all of data and never of your documents: the Tesseract English data for the first OCR (skip it with `DISTILL_TESSDATA` or `TESSDATA_PREFIX`; `DISTILL_OCR_LANG` sets the language), and, only if you enable LLMLingua-2, its runtime from npm and its model from Hugging Face.
212
+
213
+ Uploaded files go to a temporary directory and are deleted after parsing. Results stay in a small in-memory cache so the JSON view can be requested later. The hooks write converted Markdown to `~/.cache/distill-llm/out/`. API responses are sent with `Cache-Control: no-store`.
214
+
215
+ <details>
216
+ <summary>Network exposure</summary>
217
+
218
+ The web server only listens on loopback by default. `--host 0.0.0.0` exposes it to your network and disables the loopback check, so only do that on a network you trust: there is no authentication. On every host, state-changing `/api` requests are rejected when the browser marks them cross-site or when their `Origin` differs from the `Host`. When exposed, the server only answers to loopback names, IP addresses and the hostnames you list with `--allowed-hosts` or `DISTILL_ALLOWED_HOSTS`, which blocks DNS rebinding. A reverse proxy must keep the original `Host` header.
219
+ </details>
220
+
221
+ ## How tokens are counted
222
+
223
+ The app and the CLI count with `o200k_base` (via `gpt-tokenizer`). Claude and Gemini tokenize differently, so absolute counts are approximate, while the percentage saved is comparable across tokenizers. The Claude numbers at the top of this page come from Anthropic's own token counting API.
224
+
225
+ ## FAQ
226
+
227
+ **Is it free?** Yes. Apache-2.0, no account, no paid tier.
228
+
229
+ **Does anything leave my machine?** Your documents never do. See [Privacy](#privacy) for the optional one-time data downloads.
230
+
231
+ **Why not just give the PDF to the model?** You can, and for charts and layout-heavy pages you sometimes should. For text, the same content as Markdown costs a fraction of the tokens: about a third on our demo files.
232
+
233
+ **Will the hook break my agent?** No. It only touches PDF and Office reads inside your project, never blocks a read, respects your permission rules, and falls back to the original file on any error.
234
+
235
+ **Is LLMLingua-2 safe to use on contracts?** It is lossy by design: it removes words. Keep it off when every word matters.
236
+
237
+ ## Roadmap
238
+
239
+ - [x] Web app, desktop app and Docker image
240
+ - [x] CLI (`distill-llm convert`)
241
+ - [x] MCP server (stdio and HTTP)
242
+ - [x] Hooks for Claude Code and OpenCode
243
+ - [ ] Signed and notarized desktop builds
244
+ - [ ] Hooks for more agents as their hook APIs settle (Codex, Gemini CLI)
245
+ - [ ] Password-protected PDFs
246
+
247
+ Ideas and votes are welcome in [Issues](https://github.com/nievesjesus/distill/issues).
248
+
249
+ ## Contributing
250
+
251
+ ```bash
252
+ git clone https://github.com/nievesjesus/distill && cd distill
253
+ npm ci
254
+ npm test # unit tests
255
+ npm run typecheck
256
+ npm run build
257
+ npm run test:e2e # Playwright, web app
258
+ npm run test:smoke # built CLI: convert, MCP, hooks
259
+ ```
260
+
261
+ See [CONTRIBUTING.md](CONTRIBUTING.md). `npm run marketing` regenerates the demo documents, screenshots and banner from the real app.
262
+
263
+ <details>
264
+ <summary>Building the desktop app</summary>
265
+
266
+ Build one architecture per host: `npm run dist:full -- --arm64` on Apple Silicon or `npm run dist:full -- --x64` on Windows or Linux (Intel Macs only get `dist:lite`). `build/lingua` holds only the sharp binary of the machine that ran `npm ci`, so a cross-architecture installer would ship the wrong native module. Re-running the release workflow for a tag whose draft release already exists does not replace its installers; delete the draft first.
267
+ </details>
268
+
269
+ ## License
270
+
271
+ [Apache-2.0](LICENSE). Built on [LiteParse](https://github.com/run-llama/liteparse) by LlamaIndex.
272
+
273
+ If distill saves you tokens, a ⭐ helps other people find it.
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/core/loopback.ts
4
+ var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["127.0.0.1", "localhost", "::1"]);
5
+ function isLoopbackHost(host) {
6
+ return LOOPBACK_HOSTS.has(host.toLowerCase().replace(/^\[|\]$/g, ""));
7
+ }
8
+
9
+ export {
10
+ isLoopbackHost
11
+ };