|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Build Commands |
| 6 | + |
| 7 | +```sh |
| 8 | +npm ci # Install dependencies |
| 9 | +npm run build # Build both Chrome and Firefox extensions |
| 10 | +npm run build-chrome # Build Chrome extension only |
| 11 | +npm run build-firefox # Build Firefox extension only |
| 12 | +npm run watch-chrome # Watch mode for Chrome development |
| 13 | +npm run watch-firefox # Watch mode for Firefox development |
| 14 | +npm run format # Format code with Biome |
| 15 | +npm run lint # Check code with Biome |
| 16 | +npm test # Run linter (alias for npm run lint) |
| 17 | +``` |
| 18 | + |
| 19 | +Build outputs go to `built/kagi_{browser}_{version}.zip`. |
| 20 | + |
| 21 | +## Architecture |
| 22 | + |
| 23 | +This is a monorepo containing Kagi Search browser extensions for Chrome, Firefox, and Safari. |
| 24 | + |
| 25 | +### Code Sharing Model |
| 26 | + |
| 27 | +- **`shared/`** - Common code used by both Chrome and Firefox extensions |
| 28 | + - `src/background.js` - Service worker: session token management, auth header injection, context menus |
| 29 | + - `src/popup.js` - Extension popup UI and settings management |
| 30 | + - `src/summarize_result.js` - Universal Summarizer feature |
| 31 | + - `src/lib/utils.js` - Shared utilities (API calls, storage, permissions) |
| 32 | + - `icons/` - Extension icons |
| 33 | +- **`chrome/`** - Chrome-specific manifest only |
| 34 | +- **`firefox/`** - Firefox-specific manifest only |
| 35 | +- **`safari/`** - Separate Swift-based implementations (not part of JS build) |
| 36 | + |
| 37 | +The build script (`build.js`) combines `shared/*` with browser-specific manifests into zip files. |
| 38 | + |
| 39 | +### Safari Extensions |
| 40 | + |
| 41 | +Safari extensions are Swift-based native apps, separate from the npm build system. Built with Xcode. |
| 42 | + |
| 43 | +- **`safari/Universal/`** - Universal extension for iOS + macOS (MV3). Still under development - background scripts are unreliable and may be killed or fail to load. |
| 44 | +- **`safari/Legacy iOS/`** - Legacy iOS implementation |
| 45 | +- **`safari/Legacy macOS/`** - Legacy macOS implementation (minimum macOS 10.14) |
| 46 | + |
| 47 | +The iOS extension is published at: https://apps.apple.com/us/app/kagi-search-for-safari/id1607766153 |
| 48 | + |
| 49 | +### Browser Detection |
| 50 | + |
| 51 | +```javascript |
| 52 | +IS_CHROME = typeof browser.runtime.getBrowserInfo !== 'function' |
| 53 | +``` |
| 54 | + |
| 55 | +### Key APIs |
| 56 | + |
| 57 | +- `kagi.com/api/v0/summarize` - API-based summarization |
| 58 | +- `kagisuggest.com` - Search autocomplete |
| 59 | + |
| 60 | +## Code Style |
| 61 | + |
| 62 | +- Biome for linting/formatting (2-space indent, single quotes) |
| 63 | +- Safari code is excluded from linting |
| 64 | +- Node 20.x, npm 10.x required |
| 65 | + |
| 66 | +## Contributing |
| 67 | + |
| 68 | +Bugfixes and improvements are welcome. New features require prior approval via the issue tracker. |
0 commit comments