# @kody/twitch — agent notes Human setup and intent live in [`README.md`](./README.md). This file is for agents: imports, smoke/dryRun execute snippets, and edge cases. Auth is the saved OAuth integration named **`twitch`** — never paste tokens. Do not disable live webhooks or jobs (this package declares none). No `/account/secrets/new` token path for this package. ## Auth | Item | Value | | --- | --- | | Integration | `twitch` (or `twitch-` via `integration`) | | API base | `https://api.twitch.tv/helix` | | Reconnect | `https://kody.codes/connect/oauth?provider=twitch` | | Hosts | `api.twitch.tv`, `id.twitch.tv` | | Headers | `Authorization` + `Client-Id` from the saved integration | Transport uses `createAuthenticatedFetch('twitch')`. Prefer named helpers, then `./request`. ## Import paths | Export | Import | | --- | --- | | overview / connect URL / scopes | `kody:@kody/twitch` | | smoke-test | `kody:@kody/twitch/smoke-test` | | get-me | `kody:@kody/twitch/get-me` | | get-user | `kody:@kody/twitch/get-user` | | get-channel | `kody:@kody/twitch/get-channel` | | get-stream | `kody:@kody/twitch/get-stream` | | list-follows | `kody:@kody/twitch/list-follows` | | list-followers | `kody:@kody/twitch/list-followers` | | list-followed-streams | `kody:@kody/twitch/list-followed-streams` | | list-chatters | `kody:@kody/twitch/list-chatters` | | send-chat-message | `kody:@kody/twitch/send-chat-message` | | update-channel-info | `kody:@kody/twitch/update-channel-info` | | request | `kody:@kody/twitch/request` | Prefer static `kody:@kody/twitch/...` imports from `execute`. Do not lead with `packages.invoke`. For smoke against a **forked** package runtime that must bind the caller's OAuth grant, a dynamic invoke of bare kody id `twitch` is acceptable — prefer the fork's published export once connected. ## Smoke test (read-only) Run on the **forked** package after connect. Does not return login, display name, or email. ```js import smokeTest from 'kody:@kody/twitch/smoke-test' export default async function main() { return await smokeTest() // => { ok: true, integration: 'twitch', hasUserId: true, hasLogin: true } } ``` ## Common snippets ```js import getUser from 'kody:@kody/twitch/get-user' import getStream from 'kody:@kody/twitch/get-stream' export default async function main() { const [user] = await getUser({ login: 'twitchdev' }) const [stream] = await getStream({ login: user.login }) return { user, stream } } ``` ```js import listFollows from 'kody:@kody/twitch/list-follows' export default async function main() { return await listFollows({ limit: 20 }) } ``` ## dryRun / confirm (writes) `./send-chat-message`, `./update-channel-info`, and non-GET `./request` never mutate Twitch when `dryRun: true`. A live write requires a fresh `confirm: true` after the user approved the exact payload. ```js import sendChatMessage from 'kody:@kody/twitch/send-chat-message' export default async function main() { return await sendChatMessage({ broadcasterLogin: 'twitchdev', message: 'Hello from Kody', dryRun: true, }) } ``` ## Edge cases / fork notes - Fork first; connect **the caller's** Twitch app. Do not treat the live `@kody/twitch` integration as theirs. - Helix `GET /channels/followers` returns only the follower **total** unless the token user is the broadcaster or a moderator **and** the token includes `moderator:read:followers`. The old `GET /users/follows` endpoint is gone. - HTTP 401: reconnect at `/connect/oauth?provider=twitch`. - HTTP 403 / missing scope: add the scope on the Twitch app, then reconnect. - `redirect_uri` must be exactly `https://kody.codes/connect/oauth`. - Never treat smoke success as permission to chat or change channel settings. - Keep `LICENSE` (MIT), `## Intent`, and `community-icon.svg` for community listing.