Vai al contenuto principale
D

dsh-qrcode

douglas-fly/dsh-qrcode

Generates a QR code from any text and reads one back out of a PNG or JPEG. Also scans images sent in a message automatically and adds a select-text button in the Web UI. The QR encoder is built in, and the plugin makes no network requests.

Installazione

dsh plugin --profile web add github:douglas-fly/dsh-qrcode

README

dsh-qrcode

Generate and decode QR codes inside DeepSeek Harness — two agent tools, no network, no API key, no native build.

Ask in chat; the agent calls the tools:

  • "Make a QR code for https://example.com" → qr_generate writes a PNG (or SVG) into the workspace and returns the path.
  • "What is in this QR code?" with an image path → qr_decode reads the text back out of the PNG/JPEG.

Both tools run locally. Nothing is uploaded anywhere.

In the conversation

Two conveniences ride on top of the tools:

  • Select any text → make a QR code. A small button appears above the selection; clicking it renders the code in place, with a download link. Works over message text, tool output, or the sidebar — it reads the document selection, not any feature's DOM.
  • Images are scanned for QR codes. When a message carries an image, the plugin decodes it before the request is assembled and hands the decoded text to the model as context, so the agent can answer from a pasted screenshot without being asked to open a file. Decoding runs locally and only on images in the current turn. The content is labelled untrusted in the context it adds.
  • One switch for that scanning, on Plugins → QR codes: on by default. It is also the autoDecode field of the qr-code row in the profile's cordis.patch.yml.

Tools

ToolArgumentsResult
qr_generatetext (required), output_path?, format? (png/svg), size? (64–2048 px), margin? (0–16 modules), error_correction? (L/M/Q/H)Absolute path of the written image, plus file size, pixel size, QR version, module count and error-correction level
qr_decodefile_path (required; path or data:image/...;base64 URI)The decoded text, its byte length, and the image dimensions

Defaults: PNG, 512 px, quiet zone of 2 modules, error correction M. Output goes to qr-<timestamp>.png in the session working directory unless output_path says otherwise.

Behavior worth knowing

  • Content capacity is about 2953 bytes (level L, largest version); an over-long input fails with the byte count and the fix, instead of writing a broken image.
  • Encoding is UTF-8, so Chinese, emoji and every other script round-trip.
  • Decoding accepts PNG and JPEG, including screenshots and phone photos. Large photos are subsampled before scanning so a 12-megapixel photo does not stall the turn.
  • One symbol per image. A picture with several QR codes returns the first one it can read.
  • Sandbox-aware: the plugin writes through the session's file policy. Under workspace-write it refuses a destination outside the workspace instead of writing around the sandbox; under read-only it refuses to write at all; under danger-full-access any path you name is allowed.
  • Shown to the user by the agent, not by the tool: ask the agent to present the generated file, or open it from the path.

Install

From the plugin market inside DSH (Plugins → Discover), search for QR codes.

From npm into a profile:

dsh plugin add dsh-qrcode --profile <profile>

From a local directory: copy this folder somewhere, then Plugins → Add plugin and pick the directory (or plugin_manager install_bundle with its absolute path). The bundle inserts one row, qr-code.

Scope

The Host half registers two model tools, one agent/pre-step hook, one runtime-context contribution, and two authenticated routes under /api/qr-code/ that the browser half uses. The browser half adds the selection button and the plugin page's switch. Neither touches other plugins' DOM: the button reads the document selection and renders into the frame-wide overlay.

Image scanning costs nothing when it is off, does nothing for images that hold no QR code, and decodes each attachment once per session.

License

MIT. The QR encoder is implemented in this package — ISO/IEC 18004 byte mode: version selection, Reed-Solomon over GF(256), block interleaving, function patterns, the eight masks and the penalty rule that picks one. The test suite compares every symbol module for module against the reference qrcode implementation (dev dependency only) and reads each one back with an independent decoder.

Writing the image needs nothing beyond Node's zlib. Reading one uses jsqr for detection, plus pngjs and jpeg-js to unpack PNG/JPEG. Those three are the only runtime dependencies, and detection is the part that is genuinely hard to own.

Plugin correlati