Skip to content

Commands

One freehand command fronts every piece that runs on your computer or in CI. Each subcommand runs one script as it is and passes your arguments straight through, so freehand marks proof.pdf --out x is exactly python3 skills/apply/read-marks.py proof.pdf --out x.

freehand list the commands
freehand <command> [args] run one
freehand --version print the version

Python is a detail. The three commands that read Supernote files (fetch, pages, marks) use supernotelib, a Python library. With uv installed they just run: each script names its own packages and uv installs them the first time. Without uv they run with python3 and need the requirements files installed with pip. FREEHAND_PYTHON picks another Python (a virtualenv’s, say) and wins over uv.

Command What it does Runs on
render a markdown file to a PDF for the e-ink device, with its record Node
clip a web article to clean markdown, ready for render Node
paper this repo’s paper.yml: what is due (–plan), or render it (–out) Node
watch watch the synced folders on this computer, and run a command when pages arrive Node
fetch download the notebooks that changed in Google Drive Python
pages notebook pages: what’s new, changed and left to read, drawn for your AI Python
marks the marks on a PDF, each marked page drawn with its ink Python
init start local: write the config for watch, and send a test page Node
add-repo add Send to paper to a repo checkout Node
check-settings check a freehand settings.json before it goes into Drive Node

freehand render — a markdown file to a PDF for the e-ink device, with its record.

The script’s own notes:

freehand-send's renderer for markdown: one file in, one PDF out, shaped for marking up by hand.
node skills/send/render.ts <file.md> --mode proof|copy --title <title> --source <label> --version <id>
--source-ref <json> [--images <tag,tag,...>] [--round <n>] [--date YYYY-MM-DD] [--out <dir>]
[--place <drive> [--settings <file>] [--folder <path>]]
For markdown (in git or anywhere), and as an agent's fallback for a Google Doc when the person
hasn't installed the freehand script (export the Doc as markdown first). With the script, a
Doc's PDF comes from Google's own export instead (script/main.ts); both follow src/core.ts, so
they're named, labelled, laid out and recorded alike.
Writes three files to --out with the record's base name, and prints the record as one line:
<pdf> a proof: "<title> (proof <n>, <date>).pdf"; a copy: "<title>.pdf"
<name>.json the record (src/core.ts, SentRecord)
<name>.md the snapshot: the words as the pages show them, images as {{image:<tag>}}
Same input and date, same PDF bytes. Exits 1 if an image didn't load.
--place puts the PDF straight on the device, through the folders a sync app keeps on disk (where
the top of the drive is, for example ~/Library/CloudStorage/GoogleDrive-<account>/My Drive): a proof
in the proofs folder, a copy in the copies folder or in --folder under the documents folder, and
the record and snapshot in sent/. The rules are the freehand script's own (cli/place.ts).

freehand clip — a web article to clean markdown, ready for render.

The script’s own notes:

freehand-clip: a web article in, clean markdown out, ready for render.ts.
node skills/send/clip.ts <url> --out <dir> [--html <saved page.html>] [--date YYYY-MM-DD]
1. Loads the page in Chromium with Ghostery's ad blocker (EasyList and friends), so ads,
trackers, cookie banners and pop-ups never load. If the filter lists can't be fetched (a
locked-down network), it carries on without them: step 2 still strips the clutter.
With --html, reads a page you saved from your own browser instead (a paywalled site you
subscribe to, read signed in), and fetches nothing but its images.
2. Pulls out the article with Defuddle (the engine of the Obsidian Web Clipper): the body as
markdown, plus title, author, site, date and lead image.
3. Saves the images beside the markdown (assets/), so the PDF never depends on the web, and
drops tracking pixels and icons. Links stay as links: render.ts keeps them tappable.
4. Writes <out>/<slug>.md with a citation header, <out>/page.png (the page as a reader saw it,
for an agent to check the extraction against), and prints a JSON summary.
It never works around a paywall or a bot check: it keeps what the page shows its reader. A page
that ends in a subscribe box is reported as `looks_truncated`, and a site that answers with an
error or a captcha is reported as `blocked` (exit 3), so the agent asks for the page saved from
the person's own browser.

freehand paper — this repo’s paper.yml: what is due (–plan), or render it (–out).

The script’s own notes:

send-to-paper: markdown in git to the e-ink device, with no computer on. The "Send to paper" workflow
(.github/workflows/send-to-paper.yml) runs this from the root of the repo it was called for. It reads
that repo's paper.yml, finds the reading copies whose words, pictures or renderer changed since they
were last sent and the proofs waiting in the queue, renders each with render.ts, and writes batch
folders: the PDFs, their records and snapshots, and paper-batch.json saying where each goes in Drive.
The workflow uploads each folder as an artifact named paper-<commit>-<n>; the freehand script, which
runs as the person, downloads it within a minute, places everything (script/paper.ts) and deletes the
artifact. Pull, not push: the workflow needs no Google account and no secrets.
What was sent is committed back to the repo: freehand/paper.json (each copy's fingerprint, each
title's last round) and paper.yml without the proofs that went out.
node skills/send/send-to-paper.ts --plan what is due; writes copies=, proofs=, live= to GITHUB_OUTPUT
node skills/send/send-to-paper.ts --out <dir> --prefix <p> render into <dir>/1, <dir>/2, ... and record it
node skills/send/send-to-paper.ts --place <drive> [--settings <file>]
on a computer, no CI: render and save straight into the device's folders on disk, where
<drive> is the top of the synced drive (folders come from <drive>/freehand/settings.json)
Who places a repo's PDFs is paper.yml's placed_by: workflow (the default: CI renders, the freehand
script places) or local (`--place`, as `freehand paper --place` and `freehand watch` run it). Each
only sends a repo that names it, so a repo is never sent twice.
Settings come from the environment: PAPER_MANIFEST (default freehand/paper.json), PAPER_TIME_ZONE
(the person's, for the date on the pages; default UTC, or settings.json's timeZone with --place)
and GITHUB_REPOSITORY (owner/name; on a computer, the origin remote's).

freehand watch — watch the synced folders on this computer, and run a command when pages arrive.

The script’s own notes:

freehand watch: the watcher, on your computer. It watches the e-ink device's folders as Google
Drive for desktop (or any sync app) keeps them on disk, and when new pages or marks have synced
and the folder has gone quiet, it runs your command: read the pages, start an agent, anything.
Nothing goes through GitHub, and no token is needed. The rules are the freehand script's own
(src/watch.ts), so both watchers behave alike.
freehand watch [--config <file>] [--once | --install | --status]
from a config (default ~/.freehand/config.yml; cli/config.ts says what goes in it): notebooks,
marks and repos, each with its own step (cli/steps.ts). This is the way to start: with a
repo's paper.yml saying placed_by: local, sending and reading back both run here.
freehand watch <folder>... --run "<command>" [--state <file>] [--quiet <minutes>] [--every <seconds>]
[--exclude a.note,b.note] [--alive <inbox folder>] [--once | --install]
one command for any change, for wiring things yourself
freehand watch --uninstall
--install macOS: the same watch, one check a minute in the background (a launch agent)
--status what a config watches, and what it has handled so far
<folder> a folder of notebooks or marked PDFs, on disk (for a Supernote syncing to Google
Drive: Supernote/Note, and the Document folders you mark PDFs in). Its own files
only, not its subfolders, as with the script's FOLDER_IDS.
--run run by /bin/sh once per batch of changes, with FREEHAND_CHANGED (a JSON list of the
paths that changed) and FREEHAND_TEXT (the same in words) in its environment.
Exit 0 and the changes are handled; anything else and they're tried again after
five minutes.
--state where it remembers the last change handled (default ~/.freehand/watch-run.json; a
config's watch keeps its own in ~/.freehand/watch.json)
--alive your freehand inbox folder, on disk: while this watcher runs it keeps a small
freehand-watcher.json there, and the freehand script leaves the pages to it
--once one check, then exit (for cron or launchd); otherwise every --every seconds (30)
Stopping: Ctrl-C or SIGTERM stops the whole watcher. A check under way ends its command (and
whatever that started), removes its scratch folder, and saves no state, so the same changes are
handled on the next start. The exit code is 130 for Ctrl-C and 143 for SIGTERM (128 plus the
signal, as a shell reports it); a second Ctrl-C exits at once, whatever is still running.
It polls instead of waiting for file-system events: a sync app's events are unreliable (Drive
for desktop's streaming mode shows files before their contents arrive), events are lost while a
laptop sleeps, and listing a few folders every 30 seconds costs nothing.

freehand fetch — download the notebooks that changed in Google Drive.

  • Runs: Python, through uv (or python3, or FREEHAND_PYTHON): skills/read/fetch-notebooks.py
  • Python packages: google-api-python-client>=2.150, google-auth>=2.35, installed by uv on first use

The script’s own notes:

Download the notebooks that changed in Google Drive since the last time, ready for read-pages.py.
python3 skills/read/fetch-notebooks.py --folder <Drive folder id> --state <dir> --out <dir> [--all] [--exclude a.note,b.note]
Lists the `.note` files in the notebooks folder (for a Supernote, `Supernote/Note`), compares each
one's Drive modified time with the one recorded in `<state>/_drive.json`, and downloads only the
ones that changed into `--out`. It prints each downloaded path, one per line, records the new
times, and, in GitHub Actions, writes `changed=true` or `changed=false` to the step's output so later
steps can be skipped. `--all` downloads every notebook again. Conflict copies the e-ink device makes
(`_CONFLICT_` in the name) are skipped.
Credentials, read-only: a Google service account that the notebooks folder is shared with (as a
Viewer). In GitHub Actions, sign it in without a key through Workload Identity Federation
(google-github-actions/auth), or put a key's JSON in GOOGLE_SERVICE_ACCOUNT_JSON. Locally,
`gcloud auth application-default login` works too.
Needs: pip install -r skills/read/requirements.txt -r skills/read/requirements-fetch.txt

freehand pages — notebook pages: what’s new, changed and left to read, drawn for your AI.

  • Runs: Python, through uv (or python3, or FREEHAND_PYTHON): skills/read/read-pages.py
  • Python packages: supernotelib==0.7.3, pillow>=10, installed by uv on first use

The script’s own notes:

Track a Supernote's notebooks page by page: what's new, what changed, and what's left to read.
python3 skills/read/read-pages.py --state <dir> scan <file.note>... [--out <dir>] [--since YYYY-MM-DD]
python3 skills/read/read-pages.py --state <dir> status [<notebook>]
python3 skills/read/read-pages.py --state <dir> set <notebook> <page>... <status>
`--state` is a folder you keep, for example in your notes repo. It holds one small JSON file per
notebook with each page's id, creation date, a fingerprint of its ink and its status, and nothing
about what the page says, so it's safe to commit. The pictures and the e-ink device's handwriting
recognition are only ever written to `--out`, a scratch folder (by default a new temporary one),
for your AI to read and then delete.
`scan` records every page and draws each page still waiting to be read, new or changed, as
`<out>/<notebook>/p<page>.png`, with `p<page>.json` beside it (keywords, titles and handwriting
recognition from the e-ink device). It prints JSON: every notebook, its counts, and the pages waiting.
Statuses: unparsed (never read) -> parsed (transcribed) -> processed (filed into your notes).
A page whose ink, keywords or titles change after it was read becomes `changed`, so it is read
again. `blank` pages need nothing. `removed` pages were deleted on the e-ink device. `archived` and
`skipped` are set aside on purpose; `--since` skips pages created before a date, for a first
scan of an old notebook.
A page is a page number or a page id. A .mark (marks on a PDF) is not a notebook: use
skills/apply/read-marks.py for those.
Python, unlike the rest of Freehand, because supernotelib, the only maintained parser for
Supernote files, is a Python library. Needs: pip install -r skills/read/requirements.txt

freehand marks — the marks on a PDF, each marked page drawn with its ink.

  • Runs: Python, through uv (or python3, or FREEHAND_PYTHON): skills/apply/read-marks.py
  • Python packages: supernotelib==0.7.3, pymupdf>=1.24, pillow>=10, installed by uv on first use

The script’s own notes:

Read the marks on a PDF from a Supernote: each marked page, with the ink drawn over the PDF's own page.
A Supernote keeps your handwriting on a PDF in a `<name>.pdf.mark` file beside it. The .mark holds
ink only, for the pages you marked; this puts each of those pages back together (the PDF page,
fitted to the screen as the e-ink device showed it, with your pen in red and your highlighter as a yellow
tint) and pulls out what text can be read mechanically. Your AI reads the rest from the pictures.
python3 skills/apply/read-marks.py <file.pdf> [--mark <file.pdf.mark>] [--done-page <n>] --out <dir>
Writes `<dir>/page-<n>.png` for each marked page (n is the PDF's page number) and prints JSON:
{"pdf": ..., "pages": [{"page": 3, "picture": "<dir>/page-3.png", "page_text": "...",
"marked": [{"kind": "underline", "text": "..."}], "handwriting": "..."}],
"done_page": 12, "done_page_marked": true}
`marked` finds underlines and highlights from where the ink sits; strike-throughs, carets, circles,
arrows, ticks and margin notes are not detected, so read those from the picture. `handwriting` is
the e-ink device's own handwriting recognition of the ink, when it has any: a hint, never the source.
`done_page_marked` says only that the Done page has ink on it; look at its picture to see whether
the box is ticked.
Python, unlike the rest of Freehand, because the only maintained parser for Supernote files,
supernotelib, is a Python library. Needs: pip install -r skills/apply/requirements.txt

freehand init — start local: write the config for watch, and send a test page.

The script’s own notes:

freehand init: the start-local setup, in three questions. It writes ~/.freehand/config.yml for
`freehand watch`, checks it, and sends a test page to the device.
freehand init [--drive <path>] [--device supernote] [--repo <path>]... [--config <file>]
[--force] [--no-test-page]
--drive where the synced drive is on disk. Default: Google Drive for desktop's, found in
~/Library/CloudStorage (asked if there are several)
--device which e-ink device: its folders inside the drive (only supernote, for now)
--repo a repo whose paper.yml should be sent from this computer; repeat for more
--force write over an existing config
Anything not given is asked for, in a terminal. Nothing here needs a Drive ID, Apps Script or a
GitHub token: without a freehand/settings.json in the drive, it writes one of folder paths only.

freehand add-repo — add Send to paper to a repo checkout.

The script’s own notes:

Add Send to paper to a repo: writes paper.yml (if it has none) and the small workflow that calls
Freehand's shared one, into a local checkout. It commits nothing: the agent commits the way that
repo wants (a pull request, or straight to main), then adds the repo to freehand/repos.json in
Drive and asks the script whether it can reach it (skills/setup/SKILL.md, "Add a repo").
node skills/setup/add-repo.ts <checkout> [--time-zone America/Los_Angeles] [--branch main] [--force]
Prints one JSON line: { repo, owner, wrote: [...], kept: [...] }. An existing paper.yml is never
changed; an existing workflow is kept unless --force.

freehand check-settings — check a freehand settings.json before it goes into Drive.

The script’s own notes:

Checks a freehand settings.json before it goes into Drive, so a typo is caught here and not as a
script error a minute later.
node skills/setup/check-settings.ts <settings.json> prints "ok" or one line per problem, exits 1 on problems