scanline is an open source command line scanning utility for macOS that I maintain. Like most people here in 2025, I was thinking, “How can I add useless and invasive AI features to this product that my users will hate?” But then I thought about how everyone is doing that and instead added what I think are proper and useful AI features to scanline.

The use case for scanline (or at least, my use case) is to quickly scan in all my bills and important documents and archive them. Rather than click around an app for every document, scanline makes it simple to do this using only the keyboard. For example, if I’m scanning the receipt for my latest frivolous purchase, I can do:

$ scanline -name 'bob_ross_chia_pet_receipt' receipts

This will use the document feeder from my scanner to scan the document, title it as I’ve specified, and put it in ~/Archive/receipts/2025 for me, as I’ve configured in my .scanline.conf file.

A year or two ago, I thought it would be nice if the document name could be automatic, distilled from the content of the document. I also thought it would be nice to OCR the document so the text was searchable, and to output a summary of what the document is about. Then I quickly abandoned all that (except OCR) because doing so at the time meant taking what are likely highly sensitive documents and sending them to a third party API for analysis.

But then along came on-device Foundation Models.

Why Aren’t Foundation Models a Bigger Deal?

This isn’t where I explain why Foundation Models aren’t a bigger deal. I don’t know why they’re not a bigger deal. To be honest, when Apple announced that they would have an on-device LLM with an API, I thought it would make a huge splash. It didn’t seem to though. Maybe because the model is small or maybe people are using other solutions, but Foundation Models is perfect for scanline because:

  • It’s easy to use (minimizes my stress)
  • It’s all on-device (minimizes privacy concerns)
  • It seems to have some built-in prompt injection prevention
  • It seems to be excellent at summarizing

I thought Foundation Models would be as transformative as web views. I remember a time when Windows had a simple-to-use web view that could be embedded in an app, but macOS didn’t. To add web content in your app, you’d have to try to customize Mozilla or something. When Apple finally introduced a web view, it opened up so many opportunities for app developers. I assumed (and still hope) that on-device AI would be similar.

scanline with AI

scanline now has two new features, both using on-device Foundation Models: autoname and summarize. My command from above would now be:

$ scanline -autoname receipts

The naming works so well that I’ve added -autoname as a default argument in my .scanline.conf file, so I can just do this:

$ scanline receipts

Easy! And if I want a text file that summarizes the content of the file, I can just also pass -summarize

Adding the Functionality

Foundation Models are pretty easy to work with. The PR only adds 200 lines, and much of that is the new prompts.

Unfortunately, there doesn’t seem to be any way to specifically indicate that part of a prompt is UGC or coming from an untrusted source, so there’s likely a way to trick it into giving a bad name by scanning a document that tries to inject something into the prompt. I put forth that it’s not possible to do any real damage since the output of that prompt is just used to name a file and won’t even overwrite an existing file.

It also appears that Apple has some built-in techniques to avoid prompt injection since I was unable, in my testing, to influence the autoname feature in any malicious way.

I also had a concern with the -summarize feature outputting sensitive information (like if you scanned your passport or social security card) in plain text. While I still urge caution using this feature, this bit in the prompt seems to avoid most instances of leaking PII:

Try to avoid including sensitive content in your summary (e.g. SSN, phone numbers, etc.)

The Response Has Been Overwhelming(ly quiet)

There are a decent number of people using scanline, but I wasn’t exactly super vocal about introducing these new features. So I haven’t gotten much (any) feedback about whether people have concerns or even know they exist.

I’m eager to hear any feedback or (preferably) review any PRs that enhance these capabilities. Maybe someone wants to take a stab at automatically choosing the directory as well?

Leave A Comment

Recommended Posts