Imported from luchopcerra/ascii-ticker (
AGENTS.md). Install upstream withnpx skills add luchopcerra/ascii-ticker. Copyright stays with the author.
AGENTS.md
Runtime
- This is a Cloudflare Worker, not a Node/Express server. The deployed entrypoint is
src/worker.ts, configured bywrangler.jsonc. - Runtime env comes from Worker bindings in
wrangler.jsonc(CACHE_TTL_MS,COINGECKO_API_URL); do not useprocess.envin Worker code. - Use Worker/web APIs (
Request,Response,fetch,URL) and keep Cloudflare compatibility in mind.
Commands
- Install:
npm install - Local dev:
npm run dev(wrangler dev; local URL is usuallyhttp://localhost:8787, not3000). - Typecheck/test/build:
npm run check,npm test -- --run, andnpm run build. - Deploy dry run:
npx wrangler deploy --dry-run. - Deploy for real:
npm run deployafter Cloudflare auth (npx wrangler login). - Manage secrets:
npx wrangler secret put <NAME>.
Verification
- Baseline verification is
npm run check,npm test -- --run,npm run build, andnpx wrangler deploy --dry-run. - For a focused smoke test, run
npm run devand hitcurl "http://localhost:8787/btc?format=json". - The app fetches live CoinGecko data, so smoke tests depend on network access and upstream API availability.
Code Map
src/worker.tsowns routing:/,/:asset,/api/prices,/api/assets,/health,/x-webhook.src/assets.tsis the supported asset registry and alias lookup; add new symbols there using CoinGecko ids.src/coingecko.tsfetches and normalizes upstream market data and keeps a per-isolate in-memory cache.src/render.tsowns terminal/plain-text rendering; preserve curl-friendly text output when changing responses.src/x-bot.tsowns the X/Twitter bot webhook: CRC challenge-response, mention parsing, OAuth 1.0a signing, and posting replies.
X Bot (Webhook)
- The webhook endpoint is
GET/POST /x-webhook. X sends GET for CRC validation and POST for mention events. - All X API credentials deployed via
wrangler secret put:X_BEARER_TOKEN,X_CONSUMER_KEY,X_CONSUMER_SECRET,X_ACCESS_TOKEN,X_ACCESS_TOKEN_SECRET. - Vars in
wrangler.jsonc:X_BOT_USER_ID(only non-secret). scripts/x-setup.mjshandles one-time webhook registration + subscription via the X API v2 Account Activity API.- X_BEARER_TOKEN must use URL-encoded form (
%2Bfor+,%3Dfor=) because X rejects the decoded value.
Gotchas
package.jsonhas no runtime dependencies; avoid adding Node-only packages unless they work in Workers.dist/is generated by TypeScript and ignored; Wrangler deploys fromsrc/worker.ts.- Text responses intentionally add ANSI color only for curl/httpie/wget user agents; JSON is selected with
?format=jsonorAccept: application/json. - Bearer Token has URL-encoded characters (
%2B,%3D) — keep them encoded everywhere (.dev.vars, secrets, scripts). X rejects the decoded form.