openquack

SPEC-005 — Paste at cursor

Status: ratified — shipped 2026-04-27 (Sources/OpenQuackKit/Output/PasteService.swift) Owner: OpenQuackKit/Output/ Last updated: 2026-04-26

Goal

After the active agent returns .text(String), deposit the text at the cursor position in whatever app is currently focused — the same UX as a system paste.

Non-goals

Public surface

public enum PasteService {
    /// Set the text on the general pasteboard, then post a synthetic ⌘V event.
    /// Restores the previous pasteboard contents after a short delay.
    public static func paste(_ text: String) async throws

    /// Just put text on the pasteboard — for the "clipboard-only" Settings option.
    public static func copyToClipboard(_ text: String)
}

Behaviour

paste(_:):

  1. Snapshot the current NSPasteboard.general contents (string variant; we accept that we can’t perfectly preserve rich types).
  2. Write text to the pasteboard.
  3. Post a kCGEventKeyDown for V with .maskCommand, then the matching kCGEventKeyUp.
  4. After ~600 ms, restore the snapshot.

The 600 ms delay covers normal apps; some sluggish ones may miss the restore. Document this and provide a “clipboard-only” mode as an escape hatch.

Permissions

Open questions

References