AGENTS.md instructions for E:\ai-stats-public <INSTRUCTIONS> Repository Guidelines…
- User
AGENTS.md instructions for E:\ai-stats-public
Project Structure & Module Organization
- Monorepo managed by pnpm + turbo:
apps/web(Next.js 15 App Router, Tailwind UI insrc/componentsandcomponents/ui),apps/api(Cloudflare Workers + Hono),apps/docs(Mintlify site). - SDKs:
packages/sdk-tsTypeScript client (src, generatedsrc/gen, builds todist);packages/sdk-pyPython client (src, tests inpackages/sdk-py/tests). - Shared tooling lives in
scripts/, release metadata in.changeset/; canonical data/benchmarks sit underpackages/data/catalog/src/datawith Jest cases nearby.
Build, Test, and Development Commands
- Install:
pnpm install(Node >=20). - Dev servers:
pnpm devto run everything, or scope withpnpm --filter @ai-stats/web dev,pnpm --filter @ai-stats/gateway-api dev,pnpm --filter @ai-stats/docs dev. - Quality gates:
pnpm lint,pnpm typecheck,pnpm build. - Data/doc checks:
pnpm validate:data,pnpm validate:pricing,pnpm validate:gateway; docs viapnpm docs:linksthenpnpm docs:build. - Tests:
pnpm --filter @ai-stats/web test; Python SDK viapnpm test:sdk-py(python -m pytest packages/sdk-py/tests); TS SDK smoke checkpnpm --filter @ai-stats/ts-sdk test:smoke(fullpnpm testruns SDK placeholders plus pytest).
Safety Notes
- Avoid bulk repo-wide search/replace or scripted mass edits; use targeted, file-scoped changes only.
Coding Style & Naming Conventions
- TypeScript-first (ES modules, absolute imports
@/...in the web app); Python for the SDK. Prefer named exports for shared utilities. - Components use PascalCase; hooks
useX; helpers/files camelCase. Keep shared UI pieces inapps/web/src/componentsbefore adding new primitives. - Styling via Tailwind; keep globals lean. Follow lint output for spacing/quotes since no repo-wide formatter is enforced.
Testing Guidelines
- Monorepo managed by pnpm + turbo:
- User
<environment_context> E:\ai-stats-public powershell <current_date>2026-04-17</current_date> Europe/London </environment_context>
- User
Audit caching key stability for public fetchers in apps/web/src/lib/fetchers and public pages. Find any patterns where dynamic arguments (timestamps, Date.now, headers/cookies, unsorted arrays) can fragment Next cache keys and cause frequent Supabase reads. Return precise callsites.
- Assistant
I’m going to inspect the web fetchers and public page data paths, then trace where cache inputs include unstable values like timestamps, request headers/cookies, or unsorted collections. After that I’ll return only the concrete callsites and why they can fragment cache keys.
- Assistant
rgis blocked in this environment, so I’m switching to targeted PowerShell searches and file reads. I’ll first map the fetcher files, then inspect the public-page callers around those paths. - Assistant
I’ve mapped the fetcher surface. Next I’m narrowing to files that actually participate in caching so I can separate harmless dynamic UI code from inputs that change the cache key.
- Assistant
I’ve found several fetchers that derive rolling time windows from
Date.now()and a few that normalize arrays. I’m now checking whether those values are part of the cache identity or only used after a stable cached read, because that determines whether they actually fragment Supabase cache keys. - Assistant
PowerShell treated the route-group parentheses as syntax, so I’m rerunning with literal paths. I’m focusing on pages that pass arrays or time-based args into cached fetchers, since those are the cache-key risks.
- Assistant
I’ve got one clear public page candidate already:
/compareforwardssearchParams.modelsas an array into a cached fetcher without canonicalizing order first. I’m checking whether the fetcher itself sorts IDs; if not, that is a real cache-key fragmentation path. - Assistant
The comparison and runtime-stat fetchers are already doing the right thing internally by sorting their list arguments before the cache boundary. I’m checking the remaining public fetchers for the ones that still trust caller order, because those are the ones that can actually split cache entries.
- Assistant
I’ve ruled out most of the date-driven internals: they change the returned data but not the cache key. The remaining high-signal area is visibility gating through
resolveIncludeHidden, because that can inject request-derived state into otherwise public fetches. I’m checking the public landing/auth entrypoints that use it. - Assistant
Finding
- [P2]
ModelPricingInsightsSectionis the only public callsite I found that can still fragment a Next cache key on logically identical data.- The callsite is
[apps/web/src/components/(data)/model/pricing/ModelPricingInsightsSection.tsx:52](E:/ai-stats-public/apps/web/src/components/(data)/model/pricing/ModelPricingInsightsSection.tsx:52), whereprovidersForDisplayis passed directly intogetModelPricingHistoryRules(...). - The cached boundary is
[apps/web/src/lib/fetchers/models/getModelPricingHistoryRules.ts:158](E:/ai-stats-public/apps/web/src/lib/fetchers/models/getModelPricingHistoryRules.ts:158), and it uses the fullargs.providersobject as part of the cache identity without canonicalizing order. - Upstream,
[apps/web/src/lib/fetchers/models/getModelPricing.ts:293](E:/ai-stats-public/apps/web/src/lib/fetchers/models/getModelPricing.ts:293)builds by appending rows in query order, and only the outer provider list is sorted at . That means the same logical provider set can serialize differently between requests, which will split the cache and trigger extra Supabase reads.
- The callsite is
- [P2]
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.