Skip to content

AGENTS.md

103 lines · 3.2 KB · Markdown
Raw

@kody/reddit — agent notes

Human setup and intent live in README.md. This file is for agents: imports, smoke/dryRun execute snippets, and edge cases. Never paste OAuth client secrets or access tokens. Do not disable live webhooks or jobs (this package declares none).

Auth

ItemValue
Integrationreddit (or reddit-<purpose> via account)
API basehttps://oauth.reddit.com
Reconnecthttps://kody.codes/connect/oauth?provider=reddit
Hostsoauth.reddit.com, www.reddit.com
User-Agentpackage sends web:kody.reddit:1.0.0 (https://kody.codes/@kody/reddit)

Transport uses createAuthenticatedFetch('reddit'). There is no usable public Reddit OpenAPI for the full OAuth surface — prefer named helpers, then ./request.

Import paths

ExportImport
root overviewkody:@kody/reddit
accountskody:@kody/reddit/accounts
smoke-testkody:@kody/reddit/smoke-test
get-mekody:@kody/reddit/get-me
get-subredditkody:@kody/reddit/get-subreddit
get-listingkody:@kody/reddit/get-listing
searchkody:@kody/reddit/search
get-userkody:@kody/reddit/get-user
get-postkody:@kody/reddit/get-post
requestkody:@kody/reddit/request
submit-postkody:@kody/reddit/submit-post
submit-commentkody:@kody/reddit/submit-comment
votekody:@kody/reddit/vote

Prefer static kody:@kody/reddit/... imports from execute. Do not lead with packages.invoke.

Smoke test (read-only)

Run on the forked package after connect. Does not return the username.

import smokeTest from 'kody:@kody/reddit/smoke-test'

export default async function main() {
	return await smokeTest()
	// => { ok: true, integration: 'reddit', hasId: true, hasName: true }
}

Common snippets

import getListing from 'kody:@kody/reddit/get-listing'

export default async function main() {
	return await getListing({ subreddit: 'programming', sort: 'hot', limit: 5 })
}
import search from 'kody:@kody/reddit/search'

export default async function main() {
	return await search({ query: 'kody agents', limit: 5 })
}

dryRun / confirm (writes)

submit-post, submit-comment, and vote never mutate when dryRun: true. A live write requires a fresh confirm: true after the user approved the exact payload.

import submitPost from 'kody:@kody/reddit/submit-post'

export default async function main() {
	return await submitPost({
		subreddit: 'test',
		title: 'Draft title',
		text: 'Draft body',
		dryRun: true,
	})
}

Edge cases / fork notes

  • Jobs are off — do not add scrapers or 24/7 bots in forks without explicit ask.
  • HTTP 401 / 403: reconnect; confirm Reddit app is a web app and redirect is exactly https://kody.codes/connect/oauth.
  • HTTP 429: unique User-Agent is required; this package sets one. If token exchange itself is blocked, reconnect after the connect page UA is fixed — never paste tokens into chat.
  • ./request uses whatever scopes the saved token already has.
  • Pass account: '<purpose>' for reddit-<purpose>; never hard-code a username.
  • Never paste Reddit client secrets or access tokens into chat or logs.