# AGENTS.md

## Build Commands

```bash
bun run dev              # Development: runs build.js + tailwindcss --watch
bun run build            # Production build → extension/output
bun run package:chrome   # Creates extension/releases/nostrconnect_chrome.zip
bun run package:firefox  # Creates extension/releases/nostrconnect_firefox.xpi
bun run lint             # Run Biome linter
bun run format           # Format with Biome (auto-fix)
bun run test             # Run tests with Vitest
bun run test:watch       # Run tests in watch mode
```

## Key Facts

- **Package manager**: bun (preferred) or pnpm. Uses `@jsr` registry for `@nostr/tools`
- **Build output**: `extension/output/` (not `dist/`)
- **Ignore `extension/output/`**: It contains generated JS/HTML/CSS and is gitignored
- **Tailwind source**: `extension/style.css` → `extension/output/style.css`

## Architecture

| File                                     | Purpose                                                   |
| ---------------------------------------- | --------------------------------------------------------- |
| `background.js`                          | Core logic: state, permissions, crypto (signEvent, nip04) |
| `nostr-provider.js`                      | Injected into web pages, provides `window.nostr`          |
| `content-script.js`                      | Bridges provider ↔ background via postMessage             |
| `popup.jsx`, `prompt.jsx`, `options.jsx` | React UI components                                       |
| `extension/chrome/manifest.json`         | Chrome Manifest V3 config                                 |
| `extension/firefox/manifest.json`        | Firefox Manifest V2 config                                |

The build script (`build.js`) auto-selects the correct manifest based on `prod`/`firefox` args.

## Code Style

- No semicolons
- Single quotes
- Biome (configured in `biome.json`)
