From de2328b6fa84623c3ab284da132b30652d0f508c Mon Sep 17 00:00:00 2001 From: Ratik Sharma Date: Tue, 6 Jan 2026 00:54:17 +0530 Subject: [PATCH 1/2] docs: add CLAUDE.md for Claude Code guidance --- CLAUDE.md | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..23e8e96 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,68 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Build Commands + +```sh +npm ci # Install dependencies +npm run build # Build both Chrome and Firefox extensions +npm run build-chrome # Build Chrome extension only +npm run build-firefox # Build Firefox extension only +npm run watch-chrome # Watch mode for Chrome development +npm run watch-firefox # Watch mode for Firefox development +npm run format # Format code with Biome +npm run lint # Check code with Biome +npm test # Run linter (alias for npm run lint) +``` + +Build outputs go to `built/kagi_{browser}_{version}.zip`. + +## Architecture + +This is a monorepo containing Kagi Search browser extensions for Chrome, Firefox, and Safari. + +### Code Sharing Model + +- **`shared/`** - Common code used by both Chrome and Firefox extensions + - `src/background.js` - Service worker: session token management, auth header injection, context menus + - `src/popup.js` - Extension popup UI and settings management + - `src/summarize_result.js` - Universal Summarizer feature + - `src/lib/utils.js` - Shared utilities (API calls, storage, permissions) + - `icons/` - Extension icons +- **`chrome/`** - Chrome-specific manifest only +- **`firefox/`** - Firefox-specific manifest only +- **`safari/`** - Separate Swift-based implementations (not part of JS build) + +The build script (`build.js`) combines `shared/*` with browser-specific manifests into zip files. + +### Safari Extensions + +Safari extensions are Swift-based native apps, separate from the npm build system. Built with Xcode. + +- **`safari/Universal/`** - Universal extension for iOS + macOS (MV3). Still under development - background scripts are unreliable and may be killed or fail to load. +- **`safari/Legacy iOS/`** - Legacy iOS implementation +- **`safari/Legacy macOS/`** - Legacy macOS implementation (minimum macOS 10.14) + +The iOS extension is published at: https://apps.apple.com/us/app/kagi-search-for-safari/id1607766153 + +### Browser Detection + +```javascript +IS_CHROME = typeof browser.runtime.getBrowserInfo !== 'function' +``` + +### Key APIs + +- `kagi.com/api/v0/summarize` - API-based summarization +- `kagisuggest.com` - Search autocomplete + +## Code Style + +- Biome for linting/formatting (2-space indent, single quotes) +- Safari code is excluded from linting +- Node 20.x, npm 10.x required + +## Contributing + +Bugfixes and improvements are welcome. New features require prior approval via the issue tracker. From b80727caecee02cb0c21c534b760f072de708844 Mon Sep 17 00:00:00 2001 From: Ratik Sharma Date: Tue, 6 Jan 2026 00:54:30 +0530 Subject: [PATCH 2/2] fix(safari): upgrade macOS extension to manifest v3 - Add rule-builder.js to background scripts (fixes background not loading) - Add missing permissions: declarativeNetRequestWithHostAccess, activeTab - Add host_permissions for - Add content scripts matching iOS configuration - Update manifest_version from 2 to 3 - Bump version to 2.2.4 --- .../Universal/macOS (Extension)/manifest.json | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/safari/Universal/macOS (Extension)/manifest.json b/safari/Universal/macOS (Extension)/manifest.json index 88e1341..ac9ac2b 100644 --- a/safari/Universal/macOS (Extension)/manifest.json +++ b/safari/Universal/macOS (Extension)/manifest.json @@ -1,10 +1,10 @@ { - "manifest_version": 2, + "manifest_version": 3, "default_locale": "en", "name": "__MSG_extension_name__", "description": "__MSG_extension_description__", - "version": "2.2.3", + "version": "2.2.4", "icons": { "512": "images/Icon.png" @@ -12,12 +12,24 @@ "background": { "scripts": [ + "rule-builder.js", "background.js" ], "persistent": false }, - "browser_action": { + "content_scripts": [{ + "js": [ "content-script.js" ], + "matches": [ "" ], + "exclude_matches" : ["*://*.kagi.com/*"], + "run_at": "document_start" + }, { + "js": ["kagi-content-script.js"], + "matches": ["*://*.kagi.com/*"], + "run_at": "document_start" + }], + + "action": { "default_popup": "popup.html", "default_icon": { "128": "images/ToolbarItemIcon.pdf" @@ -27,8 +39,14 @@ "permissions": [ "nativeMessaging", "webNavigation", - "storage" + "declarativeNetRequestWithHostAccess", + "storage", + "activeTab" + ], + + "host_permissions": [ + "" ], - + "optional_permissions": [] }