docs(agents): make AGENTS.md the maintained cross-session memory

- Add a 'this file is the ONLY persistent memory' directive: record non-obvious
  learnings in the same session, fix stale entries immediately, date claims
- Add a 'Project map' (HashRouter, custom kinds, marketplace/wallet/DM/lazy
  routes, npm test baselines, untracked-junk list)
- Fix stale facts: BrowserRouter -> HashRouter; /src/pages + /src/lib were
  understated; describe the smoke test's hash routes + crash-screen detection
- Strengthen System Prompt Management to treat AGENTS.md as long-term memory
This commit is contained in:
SkateSpots 2026-09-26 20:51:12 +07:00
parent b91df1b4b0
commit 8255d9d5e8

View file

@ -9,10 +9,54 @@ This project is a Nostr client application built with React 18.x, TailwindCSS 3.
- **Vite**: Fast build tool and development server
- **shadcn/ui**: Unstyled, accessible UI components built with Radix UI and Tailwind
- **Nostrify**: Nostr protocol framework for Deno and web
- **React Router**: For client-side routing with BrowserRouter and ScrollToTop functionality
- **React Router**: `react-router-dom` with **HashRouter** (routes live in the URL hash, e.g. `/#/settings`) and ScrollToTop functionality
- **TanStack Query**: For data fetching, caching, and state management
- **TypeScript**: For type-safe JavaScript development
## 🧠 This file is the ONLY persistent memory — keep it in sync
`AGENTS.md` is the single thing carried across sessions; a model starts every
session with **no other memory of this project**. So:
- **Write important things down here in the same session you learn them.** If it
isn't in this file, the next agent doesn't know it and will re-derive (or get)
it wrong.
- **Record the non-obvious**: exact commands + flags, file paths, gotchas,
environment quirks, verified facts, and *why* a decision was made. Skip what
anyone can read from the code.
- **Fix stale entries immediately.** A wrong note here makes every future session
go off the rails — check claims against the repo before trusting them.
- **Keep it tight and factual**: commands/paths over prose, no essays.
- When you change something this file describes (scripts, kinds, deploy, hooks),
update that section as part of the same change. Date non-trivial claims:
`(verified 2026-09-26)`.
### Project map (what exists right now)
- **Router**: `react-router-dom` **HashRouter** — real routes live in the URL
hash (`/#/settings`, `/#/marketplace`). A bare `/settings` renders the
homepage (this silently broke the boot smoke test once). `src/AppRouter.tsx`.
- **Custom protocol**: `NIP.md` is the source of truth for every custom/adopted
kind; the constants live in `src/lib/types.ts`. Highlights:
- `30818` skate spot · `30017` shop · `31923`/`31925` events + RSVP · `30823` tours
- `30402` NIP-99 listing = marketplace item, and the **Assertion Event** for trades
- `31871` trade attestation (sale/purchase) · `31872` trade confirmation request
→ `src/hooks/useTradeAttestations.ts`; reputation UI in `TradeReputationCard`
- `35000–35012` role profiles (skater/filmer/coach/…) · `35006` crews · `30003` spot collections
- `24899` spot chat · `2259` spot status · `32671` Sasquatch Pro · `7103` event updates
- **Marketplace**: `GearSwapPage` + `MarketplaceItemCard`. Buyer/seller trade
attestations build mutual, WoT-weighted reputation. **No payments are
implemented** — "Buy" is intentionally absent; only Contact/Offer/Trade.
- **Wallet**: `useCashu` (coco-cashu) is **native-only** — it returns early on
web (mints are CORS-blocked). Zap rails are NWC + WebLN + Cashu melt (`useZaps`).
- **Group DMs**: NIP-17 (`useDirectMessages`, `GroupConversationPage`).
- **Lazy routes**: every route uses `lazyWithRetry` (`src/lib/lazyWithRetry.ts`) —
retries, then one full reload per session, so a chunk-load failure self-heals
instead of showing the error boundary.
- **Baselines** (verified 2026-09-26): `npm test` → 0 errors, **182 warnings**,
**86 tests**, build ok. `package.json` version **1.4.5**.
- **Untracked local junk — do NOT commit**: `assets/`, `resources/`,
`cvm-server/`, `bun.lock`.
## Local Dev Environment, Build & Release (project-specific — read first)
Machine-specific, verified operational notes. Use these instead of re-deriving workflows from scratch.
@ -66,8 +110,11 @@ Rules:
- **Do not re-introduce custom `manualChunks`** without a boot test. Rollup's
default splitting is cycle-safe.
- `scripts/smoke-test.mjs` boots the built `dist/` in headless Chromium and
fails if `#root` doesn't mount. `scripts/auto-deploy.sh` runs it before every
deploy and **aborts the deploy** if it fails.
fails if `#root` doesn't mount **or** if any route shows the "This page
slammed" error boundary. It walks each route **in the URL hash** (HashRouter!):
`/`, `/marketplace`, `/leaderboards`, `/bounties`, `/settings`, `/stash`,
`/collections`, `/stats`, `/messages/group/abc123`. `scripts/auto-deploy.sh`
runs it before every deploy and **aborts the deploy** if it fails.
- Any time the deploy output isn't verified by the smoke test, run
`node scripts/smoke-test.mjs` manually before shipping.
@ -114,9 +161,12 @@ Rules:
- `useWallet`: Unified wallet detection (WebLN + NWC)
- `useNWC`: Nostr Wallet Connect connection management
- `useNWCContext`: Access NWC context provider
- `/src/pages/`: Page components used by React Router (Index, NotFound)
- `/src/lib/`: Utility functions and shared logic
- `/src/contexts/`: React context providers (AppContext, NWCContext)
- `/src/pages/`: ~50 route pages (MapPage is the homepage; see `AppRouter.tsx`)
- `/src/lib/`: shared logic — `types.ts` (custom kind constants), `lazyWithRetry.ts`, `queryPersister.ts`, helpers
- `/src/contexts/`: React context providers (AppContext, LanguageContext, NWCContext)
- `NIP.md`: **source of truth** for every custom/adopted Nostr kind and its schema
- `AGENTS.md` (this file): the only cross-session memory — keep it current
- `UX_AUDIT.md`, `GROUP_MESSAGING.md`: feature decision/backlog docs
- `/src/test/`: Testing utilities including TestApp component
- `/public/`: Static assets
- `App.tsx`: Main app component with provider setup (**CRITICAL**: this file is **already configured** with `QueryClientProvider`, `NostrProvider`, `UnheadProvider` and other important providers - **read this file before making changes**. Changes are usually not necessary unless adding new providers. Changing this file may break the application)
@ -215,10 +265,15 @@ The project includes a **`skills/`** directory containing specialized implementa
## System Prompt Management
The AI assistant's behavior and knowledge is defined by the AGENTS.md file, which serves as the system prompt. To modify the assistant's instructions or add new project-specific guidelines:
`AGENTS.md` is the assistant's system prompt **and its only persistent memory**.
Future sessions start with nothing but this file, so treat it as the project's
long-term memory:
1. Edit AGENTS.md directly
2. The changes take effect in the next session
1. Edit `AGENTS.md` directly when you learn something important or when a
described detail has changed.
2. Changes take effect in the next session — so record now, not "later".
3. Re-read the relevant section before relying on it; if it's out of date, fix it
in the same session rather than working around it.
## "Vibed with MKStack"
@ -960,17 +1015,24 @@ function SettingsPage() {
## Routing
The project uses React Router with a centralized routing configuration in `AppRouter.tsx`. To add new routes:
The project uses `react-router-dom`'s **HashRouter** with a centralized
configuration in `AppRouter.tsx`. Because it's a hash router, the route is the
part after `#` — `https://skate-spots.org/#/settings`. Links must use `<Link>`
(a bare `<a href="/settings">` or a plain path loads the homepage / 404s). To add
a route:
1. Create your page component in `/src/pages/`
2. Import it in `AppRouter.tsx`
3. Add the route above the catch-all `*` route:
2. Add it with **`lazyWithRetry`** (not bare `lazy`) and a `<Route>` above the
catch-all `*` route:
```tsx
<Route path="/your-path" element={<YourComponent />} />
const YourPage = lazyWithRetry(() => import("./pages/YourPage"));
// …
<Route path="/your-path" element={<YourPage />} />
```
The router includes automatic scroll-to-top functionality and a 404 NotFound page for unmatched routes.
The router includes automatic scroll-to-top functionality and a 404 NotFound
page for unmatched routes.
## Development Practices