nanocoder
nanocoder copied to clipboard
[Feature] Make the PDF/DOCX stack of `@nanocollective/get-md` optional (110 MB of the 218 MB install)
Description
Half of the install is one dependency. @nanocollective/get-md is used only by fetch_url (HTML to markdown) and when reading PDF/DOCX files. It is already imported lazily, so it costs nothing at runtime, but every user pays the disk space and install time. That hurts on small SSDs, slow networks and CI.
Environment
- OS: Windows 11 (10.0.26300)
- Node version: 22.22.3
- Nanocoder version: 1.31.0 (main at 5c2e6935)
Evidence
- Production closure: 337 packages, 217.8 MB.
get-mdaccounts for 110.2 MB (50.6%):@napi-rs/canvas-win32-x64-msvc35.0 MB (per-OS binary),pdfjs-dist34.9 MB,pdf-parse20.3 MB,@mixmark-io/domino7.4 MB,happy-dom-without-node4.3 MB, and a secondundici(7.29.1, 1.6 MB). - Only two call sites, both
await import('@nanocollective/get-md'):source/tools/fetch-url.tsx:105andsource/utils/file-cache.ts:159. get-mdis owned by the same organisation, so the split can be done upstream.
Proposed Change
- Preferred: upstream
get-mdinto a core (HTML) entry and a separate optional PDF entry, withpdfjs-dist,pdf-parseand@napi-rs/canvasas optional peers. - In nanocoder, treat the PDF path as optional. When a PDF/DOCX is read without the extra packages, return a clear message with the install command, or add a
nanocoder add pdfhelper. - Alternative:
optionalDependencies, so a failed native install does not break installs.
Expected Behavior
- A default install is at least 100 MB smaller.
fetch_urlstill converts HTML pages with the default install.- Reading a PDF works when the extra package is installed; without it the message is clear.
Additional Context
- Effort: M. Start with
package.json,source/tools/fetch-url.tsx,source/utils/file-cache.ts, and theNano-Collective/get-mdrepo. - User-facing change: PDF/DOCX readers need an extra install step. Needs a docs update and a maintainer decision.
- Exact savings differ per platform because
@napi-rs/canvasships a per-OS binary.
@addyCooks assign me please i fix it tomorrow