# Hubfluencer agent kit for OpenCode

Teach [OpenCode](https://opencode.ai) to generate videos with Hubfluencer.
Prompt in, finished MP4 out.

This kit has two files:

- **`AGENTS.md`** — the usage guide OpenCode loads into its context.
- **`README.md`** — this setup guide.

## 1. Connect your account

Pick one (you only do this once):

**Option A — access token**

1. In the Hubfluencer app, **buy credits**.
2. Go to **Settings → Access tokens** and create an access token with the
   **Generate videos** scope (`video:generate` + `video:read`).
3. Copy the token — you'll paste it into the config in step 2.

**Option B — device link (no copy-paste)**

```bash
npx -y @hubfluencer/mcp login
```

It prints a URL and a short code. Approve the connection in the signed-in
Hubfluencer app. A scoped token is saved to `~/.hubfluencer/credentials.json`
and the MCP server picks it up automatically — you can skip the `environment`
block in step 2.

## 2. Register the MCP server in OpenCode

OpenCode has no `mcp add` command — you register servers by editing the JSON
config. Add the `hubfluencer` entry to **`opencode.json`** in your project root,
or to the global **`~/.config/opencode/opencode.json`**.

```json
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "hubfluencer": {
      "type": "local",
      "command": ["npx", "-y", "@hubfluencer/mcp"],
      "enabled": true,
      "environment": {
        "HUBFLUENCER_API_TOKEN": "YOUR_ACCESS_TOKEN"
      }
    }
  }
}
```

Notes:

- The MCP server runs as a local stdio process, so `type` is **`"local"`** (not
  `"stdio"`), and env vars go under **`"environment"`** (not `"env"`).
- If you connected with **Option B** (`npx -y @hubfluencer/mcp login`), drop the
  `environment` block entirely — the server reads the saved token automatically.
- Optional env vars (add inside `environment`):
  - `HUBFLUENCER_BASE_URL` — default `https://hubfluencer.com`.
  - `HUBFLUENCER_OUTPUT_DIR` — confines where downloaded MP4 files are written.
- Prefer comments? Use `opencode.jsonc` instead.
- **Restart OpenCode** after editing the config so it re-reads the MCP servers.

## 3. Where the instructions file goes

Put **`AGENTS.md`** in your project root (OpenCode's native instruction file),
or in the global `~/.config/opencode/AGENTS.md`.

Alternatively, keep this file wherever you like and point OpenCode at it via the
top-level `instructions` array in `opencode.json` (it accepts local paths, glob
patterns, and remote URLs):

```json
{
  "$schema": "https://opencode.ai/config.json",
  "instructions": ["priv/agent_kits/opencode/AGENTS.md"]
}
```

All listed files are concatenated with `AGENTS.md` into the model context.

## 4. Try it

Ask your agent:

> Use Hubfluencer to make me a 15s ad for my cold-brew coffee brand.

OpenCode will call `make_video`, wait for the render, and hand you back the
finished MP4 plus a ready-to-paste caption.
