aldus-pdf 0.3.0

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.
package/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # aldus-pdf
2
+
3
+ A **framework for building PDF apps** on a PDF's real content graph: parse the
4
+ content-stream operators into an editable model, mutate them from code, the
5
+ `aldus` CLI, or an **LLM agent**, and splice the result back byte-for-byte — no
6
+ rasterizing, no white boxes, no approximated fonts. Read/edit/move text,
7
+ highlight, link, place images, and **read/fill/build forms & signature fields**.
8
+
9
+ > Bundled build of the [`aldus`](https://github.com/bernatch22/aldus) monorepo
10
+ > (`@aldus/core` + `@aldus/agent`) → one self-contained package.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npm i aldus-pdf # library + the `aldus` CLI
16
+ ```
17
+
18
+ ## CLI
19
+
20
+ ```bash
21
+ aldus doc.pdf # opens the VISUAL EDITOR + AI in your browser
22
+ aldus doc.pdf "Describe the content" # one-shot agent (LLM)
23
+ aldus doc.pdf "Highlight the totals" -o out.pdf --open
24
+ aldus doc.pdf --chat # interactive chat in the terminal
25
+ aldus form.pdf --fields # dump fields + values + positions (no LLM)
26
+ aldus form.pdf --fill '{"name":"Ana"}' -o filled.pdf # fill by field name (no LLM)
27
+ ```
28
+
29
+ `aldus file.pdf` with no prompt boots a local server (editor + CASPER agent) and
30
+ opens the browser — no database, no accounts. `--fields` / `--fill` are
31
+ **deterministic** (no LLM). Agentic prompts run on the auth below.
32
+
33
+ ## Auth (agent)
34
+
35
+ Two-level agent (cheap chat/router → strong editor). Two providers:
36
+
37
+ **Claude Code subscription** (default) — no per-token bill:
38
+ - Interactive / your machine: just run **without** `ANTHROPIC_API_KEY`.
39
+ - Headless / servers: set `CLAUDE_CODE_OAUTH_TOKEN` (from `claude setup-token`).
40
+ - Models: `ALDUS_MODEL` (editor, `claude-sonnet-5`), `ALDUS_CHAT_MODEL` (router, `claude-haiku-4-5`).
41
+
42
+ **OpenRouter** (`ALDUS_PROVIDER=openrouter`, `OPENROUTER_API_KEY`) — for hosted
43
+ demos / cheaper runs. **Recommended: Gemini.** Put the cheap model on the chat
44
+ (it reads every page) and the good one on the editor:
45
+ - `ALDUS_OPENROUTER_CHAT_MODEL=google/gemini-3.1-flash-lite` (router)
46
+ - `ALDUS_OPENROUTER_MODEL=google/gemini-3.5-flash` (editor)
47
+
48
+ That combo (the default) is ~1.8¢/turn on a 9-page doc and ~3–9s per turn.
49
+
50
+ ## Library
51
+
52
+ ```ts
53
+ import { loadDoc, EditSession, runTurn, serializeDoc } from 'aldus-pdf';
54
+ import { readFormFields, setFieldValues } from 'aldus-pdf'; // deterministic form I/O
55
+
56
+ const doc = await loadDoc('form.pdf');
57
+ const session = new EditSession(doc);
58
+ await runTurn({ doc, session, prompt: 'Fill the form: name Ana, plan Pro' });
59
+ await session.save('filled.pdf');
60
+ ```
61
+
62
+ ## What the agent can do
63
+
64
+ Text edit/move/color/size/delete · images move/delete/insert · highlight (create/
65
+ recolor/remove) · links · watermark · header/footer · **form fields**: create any
66
+ type (text/checkbox/radio/select/list/button/signature), move/delete, **read
67
+ values + positions**, and **fill** (by field name or by the `[[id]]` of the
68
+ reading view). It's aware of the full geometry & style of every element.
69
+
70
+ MIT · [source](https://github.com/bernatch22/aldus)