# Pushdoc

> Pushdoc publishes Markdown docs (with Mermaid diagrams) and self-contained HTML prototypes as clean, shareable links — straight from a coding agent via the `pushdoc` CLI.

If a user pointed you (a coding agent: Claude Code, Codex, Copilot, Cursor, Antigravity, etc.) at https://pushdoc.dev and asked you to "onboard", "set up", or "connect" Pushdoc, follow the steps below exactly. The only thing the human needs to do is approve one browser sign-in.

## Agent onboarding

Requirements: `curl` and Node.js >= 18 on the machine where you run shell commands.

1. **Check whether it's already set up.** Run:
   ```bash
   pushdoc whoami || ~/.local/bin/pushdoc whoami
   ```
   If this prints an email address, onboarding is already complete — skip to step 6.

2. **Install the CLI and the agent skill:**
   ```bash
   curl -fsSL https://pushdoc.dev/install.sh | sh
   ```
   This installs `~/.local/bin/pushdoc` and a `SKILL.md` for Claude Code, Codex, Cursor, Antigravity and `~/.agents/skills`. If `pushdoc` is not on `PATH`, use `~/.local/bin/pushdoc` for every command below.

3. **Start sign-in without blocking:**
   ```bash
   ~/.local/bin/pushdoc login --no-wait
   ```
   It prints a verification URL and a short code, then exits immediately.

4. **Hand off to the user.** Show them the verification URL and code verbatim and ask them to open the URL, sign in (GitHub or Google), check that the code matches, and click **Approve**. Never ask for their password.

5. **Finish sign-in:**
   ```bash
   ~/.local/bin/pushdoc login --wait --timeout 90
   ```
   - Exit code `0`: signed in.
   - Exit code `2`: still waiting for approval — re-run the same command (the pending code stays valid for 10 minutes).
   - Expired: start again from step 3.

6. **Verify and confirm:**
   ```bash
   ~/.local/bin/pushdoc whoami
   ```
   Tell the user Pushdoc is connected. Optionally, with their OK, publish a test doc and return the URL:
   ```bash
   printf '# Hello from my agent\n\nPushdoc is connected.\n' | ~/.local/bin/pushdoc push - --title "Hello Pushdoc"
   ```

### No browser / cloud or sandboxed agents

If the user can't approve a device code (e.g. a CI-style or cloud agent), ask them to sign in at https://pushdoc.dev, open **CLI & Tokens**, create a token, and give it to you (or set it as the `PUSHDOC_TOKEN` secret/environment variable). Then run:

```bash
~/.local/bin/pushdoc login --token "$PUSHDOC_TOKEN"   # or: pushdoc login --token <token>
```

With `PUSHDOC_TOKEN` set, the CLI works without `login`. Do not echo the token back into chat or logs. If network access is restricted, `https://pushdoc.dev` must be allow-listed.

## Publishing

```bash
pushdoc push ./report.md --title "Architecture RFC"          # prints the shareable URL
pushdoc push ./prototype.html --visibility private            # owner-only link
pushdoc push ./report.md --id <id>                            # update in place, same URL
pushdoc push ./report.md --json                               # structured output incl. id
pushdoc list                                                 # recent docs
pushdoc delete <id>
```

- Markdown: GFM, syntax-highlighted code fences, and ` ```mermaid ` diagrams.
- HTML: one self-contained file (inline CSS/JS or CDN links), served from a cookie-less sandbox origin.
- Always return the printed URL to the user.

## Resources

- [Agent skill (SKILL.md)](https://pushdoc.dev/skill.md): drop-in skill for publishing workflows
- [Installer](https://pushdoc.dev/install.sh): installs the CLI and skill
- REST API: `POST https://pushdoc.dev/api/artifacts` with `Authorization: Bearer <token>` and JSON `{title, type: "markdown"|"html", visibility: "public"|"private", content}`
