# mde — the Workbench CLI

Zero dependencies, one file. Install (no sudo — picks /usr/local/bin or ~/.local/bin):

    curl -fsSL https://workbench.md/install | sh

(`GET /cli` is the raw executable itself, `GET /install` the installer script.)

```
mde — collaborative markdown docs, from the terminal

Setup
  mde login [url]            sign in — approve in your browser, no token hunting
                             (scripts: mde login --token <token>; token in the account menu)
  mde whoami                 show who you are

Documents
  mde ls [--json]            list your documents
  mde new <title> [-f file]  create a doc (markdown from -f or stdin)
                             works logged-out too: creates an anonymous doc at a secret link
  mde cat <doc>              print a doc as markdown (pending suggestions excluded)
  mde pull <doc> [-o file]   fetch a doc and remember its version for safe pushes
  mde push <doc> -f file     replace a doc's content (also reads stdin)
                             refuses if the doc changed since your last pull
                             --force  overwrite anyway    --label "msg"  name the version
  mde open <doc>             open a doc in the browser
  mde share <doc> [role]     get a share link (view|comment|suggest|edit, default view)
                             works on an edit-key share URL too, not just your own docs
  mde rm <doc>               delete a doc (by id, share URL, or exact title)
                             anonymous docs delete via their edit-key share URL

Collaboration
  mde comments <doc> [--json]           list comments (and suggestions)
  mde comment <doc> <text> [--line N]   add a comment
  mde reply <doc> <commentId> <text>    reply to a comment
  mde resolve <doc> <commentId>         resolve a comment
  mde suggest <doc> --replace <old> --with <new>   propose an edit (creates a delete+insert pair)
  mde suggest <doc> --delete <text>                propose removing text
  mde suggest <doc> --append <text>                propose adding text at the end
  mde accept <doc> <id...>              accept suggestion(s)
  mde reject <doc> <id...>              reject suggestion(s)
  mde history <doc> [--json]            list saved versions
  mde events <doc> [--since N] [--json]   list recent activity (comments, suggestions, edits, versions)
  mde watch <doc> [--since N] [--json]    follow activity live (long-polls; Ctrl-C to stop)
                             retries network/5xx blips; exits non-zero on a permanent
                             error (auth, not found, bad request)
    --exec <cmd>             run a command per event batch (env: MDE_EVENTS json,
                             MDE_DOC, MDE_LATEST) — re-read doc state in the command,
                             don't replay events
    --skip-self              drop your own echoes (your username / --author name,
                             and writes labeled "you: …")
    --cursor                 persist the last-seen seq per doc; restarts resume
    --daemon                 install all of the above as a background service
                             (launchd on macOS, systemd --user on Linux) with logs
                             in ~/.config/mde/logs; remove with --daemon-off

<doc> may be a doc id, a share URL, or a (partial) title.
Share URLs work without login: mde cat "https://host/d/abc?key=…"

Environment
  MDE_URL, MDE_TOKEN         override the saved server/token (great for CI and agents)
  MDE_AUTHOR                 attribution name when acting via a share URL without a token
                             (also: --author <name> on push/comment/reply/suggest)
                             with no name set, mde asks once and saves it; in scripts it
                             signs as "agent". Names are marked "guest" and can't match an
                             account username — use the account's token to write as it.
```

Full agent API (HTTP): [/agents.md](/agents.md)
