create-addfox-app 0.1.1-beta.7 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/README.md +18 -18
  2. package/dist/cli.js +259 -102
  3. package/package.json +9 -8
  4. package/templates/README.md +3 -0
  5. package/templates/template-preact-js/AGENTS.md +54 -0
  6. package/templates/template-preact-js/addfox.config.js +27 -0
  7. package/templates/template-preact-js/app/background/index.js +8 -0
  8. package/templates/template-preact-js/app/content/index.js +1 -0
  9. package/templates/template-preact-js/app/options/App.jsx +5 -0
  10. package/templates/template-preact-js/app/options/index.jsx +5 -0
  11. package/templates/template-preact-js/app/popup/App.jsx +31 -0
  12. package/templates/template-preact-js/app/popup/index.jsx +5 -0
  13. package/templates/template-preact-js/app/sidepanel/App.jsx +5 -0
  14. package/templates/template-preact-js/app/sidepanel/index.jsx +5 -0
  15. package/templates/template-preact-js/package.json +18 -0
  16. package/templates/template-preact-js/public/icons/icon_128.png +0 -0
  17. package/templates/template-preact-js/public/welcome.html +20 -0
  18. package/templates/template-preact-ts/AGENTS.md +61 -0
  19. package/templates/template-preact-ts/addfox.config.ts +27 -0
  20. package/templates/template-preact-ts/app/background/index.ts +8 -0
  21. package/templates/template-preact-ts/app/content/index.ts +1 -0
  22. package/templates/template-preact-ts/app/options/App.tsx +5 -0
  23. package/templates/template-preact-ts/app/options/index.tsx +5 -0
  24. package/templates/template-preact-ts/app/popup/App.tsx +31 -0
  25. package/templates/template-preact-ts/app/popup/index.tsx +5 -0
  26. package/templates/template-preact-ts/app/sidepanel/App.tsx +5 -0
  27. package/templates/template-preact-ts/app/sidepanel/index.tsx +5 -0
  28. package/templates/template-preact-ts/package.json +20 -0
  29. package/templates/template-preact-ts/public/icons/icon_128.png +0 -0
  30. package/templates/template-preact-ts/public/welcome.html +20 -0
  31. package/templates/template-preact-ts/tsconfig.json +19 -0
  32. package/templates/template-react-js/AGENTS.md +66 -0
  33. package/templates/template-react-js/addfox.config.js +27 -0
  34. package/templates/template-react-js/app/background/index.js +8 -0
  35. package/templates/template-react-js/app/content/index.js +1 -0
  36. package/templates/template-react-js/app/options/App.jsx +3 -0
  37. package/templates/template-react-js/app/options/index.jsx +5 -0
  38. package/templates/template-react-js/app/popup/App.jsx +29 -0
  39. package/templates/template-react-js/app/popup/index.jsx +5 -0
  40. package/templates/template-react-js/app/sidepanel/App.jsx +3 -0
  41. package/templates/template-react-js/app/sidepanel/index.jsx +5 -0
  42. package/templates/template-react-js/package.json +19 -0
  43. package/templates/template-react-js/public/icons/icon_128.png +0 -0
  44. package/templates/template-react-js/public/welcome.html +20 -0
  45. package/templates/template-react-ts/AGENTS.md +93 -0
  46. package/templates/template-react-ts/addfox.config.ts +27 -0
  47. package/templates/template-react-ts/app/background/index.ts +8 -0
  48. package/templates/template-react-ts/app/content/index.ts +1 -0
  49. package/templates/template-react-ts/app/options/App.tsx +3 -0
  50. package/templates/template-react-ts/app/options/index.tsx +5 -0
  51. package/templates/template-react-ts/app/popup/App.tsx +29 -0
  52. package/templates/template-react-ts/app/popup/index.tsx +5 -0
  53. package/templates/template-react-ts/app/sidepanel/App.tsx +3 -0
  54. package/templates/template-react-ts/app/sidepanel/index.tsx +5 -0
  55. package/templates/template-react-ts/package.json +23 -0
  56. package/templates/template-react-ts/public/icons/icon_128.png +0 -0
  57. package/templates/template-react-ts/public/welcome.html +20 -0
  58. package/templates/template-react-ts/tsconfig.json +19 -0
  59. package/templates/template-solid-js/AGENTS.md +54 -0
  60. package/templates/template-solid-js/addfox.config.js +28 -0
  61. package/templates/template-solid-js/app/background/index.js +8 -0
  62. package/templates/template-solid-js/app/content/index.js +1 -0
  63. package/templates/template-solid-js/app/options/App.jsx +3 -0
  64. package/templates/template-solid-js/app/options/index.jsx +5 -0
  65. package/templates/template-solid-js/app/popup/App.jsx +34 -0
  66. package/templates/template-solid-js/app/popup/index.jsx +5 -0
  67. package/templates/template-solid-js/app/sidepanel/App.jsx +3 -0
  68. package/templates/template-solid-js/app/sidepanel/index.jsx +5 -0
  69. package/templates/template-solid-js/package.json +19 -0
  70. package/templates/template-solid-js/public/icons/icon_128.png +0 -0
  71. package/templates/template-solid-js/public/welcome.html +20 -0
  72. package/templates/template-solid-ts/AGENTS.md +61 -0
  73. package/templates/template-solid-ts/addfox.config.ts +28 -0
  74. package/templates/template-solid-ts/app/background/index.ts +8 -0
  75. package/templates/template-solid-ts/app/content/index.ts +1 -0
  76. package/templates/template-solid-ts/app/options/App.tsx +3 -0
  77. package/templates/template-solid-ts/app/options/index.tsx +5 -0
  78. package/templates/template-solid-ts/app/popup/App.tsx +34 -0
  79. package/templates/template-solid-ts/app/popup/index.tsx +5 -0
  80. package/templates/template-solid-ts/app/sidepanel/App.tsx +3 -0
  81. package/templates/template-solid-ts/app/sidepanel/index.tsx +5 -0
  82. package/templates/template-solid-ts/package.json +21 -0
  83. package/templates/template-solid-ts/public/icons/icon_128.png +0 -0
  84. package/templates/template-solid-ts/public/welcome.html +20 -0
  85. package/templates/template-solid-ts/tsconfig.json +19 -0
  86. package/templates/template-svelte-js/AGENTS.md +54 -0
  87. package/templates/template-svelte-js/addfox.config.js +27 -0
  88. package/templates/template-svelte-js/app/background/index.js +8 -0
  89. package/templates/template-svelte-js/app/content/index.js +1 -0
  90. package/templates/template-svelte-js/app/options/App.svelte +4 -0
  91. package/templates/template-svelte-js/app/options/index.js +4 -0
  92. package/templates/template-svelte-js/app/popup/App.svelte +30 -0
  93. package/templates/template-svelte-js/app/popup/index.js +4 -0
  94. package/templates/template-svelte-js/app/sidepanel/App.svelte +4 -0
  95. package/templates/template-svelte-js/app/sidepanel/index.js +4 -0
  96. package/templates/template-svelte-js/package.json +18 -0
  97. package/templates/template-svelte-js/public/icons/icon_128.png +0 -0
  98. package/templates/template-svelte-js/public/welcome.html +20 -0
  99. package/templates/template-svelte-ts/AGENTS.md +61 -0
  100. package/templates/template-svelte-ts/addfox.config.ts +27 -0
  101. package/templates/template-svelte-ts/app/background/index.ts +8 -0
  102. package/templates/template-svelte-ts/app/content/index.ts +1 -0
  103. package/templates/template-svelte-ts/app/options/App.svelte +4 -0
  104. package/templates/template-svelte-ts/app/options/index.ts +4 -0
  105. package/templates/template-svelte-ts/app/popup/App.svelte +30 -0
  106. package/templates/template-svelte-ts/app/popup/index.ts +4 -0
  107. package/templates/template-svelte-ts/app/sidepanel/App.svelte +4 -0
  108. package/templates/template-svelte-ts/app/sidepanel/index.ts +4 -0
  109. package/templates/template-svelte-ts/package.json +20 -0
  110. package/templates/template-svelte-ts/public/icons/icon_128.png +0 -0
  111. package/templates/template-svelte-ts/public/welcome.html +20 -0
  112. package/templates/template-svelte-ts/tsconfig.json +19 -0
  113. package/templates/template-vanilla-js/AGENTS.md +52 -0
  114. package/templates/template-vanilla-js/addfox.config.js +25 -0
  115. package/templates/template-vanilla-js/app/background/index.js +8 -0
  116. package/templates/template-vanilla-js/app/content/index.js +1 -0
  117. package/templates/template-vanilla-js/app/options/index.js +2 -0
  118. package/templates/template-vanilla-js/app/popup/index.js +48 -0
  119. package/templates/template-vanilla-js/app/sidepanel/index.js +2 -0
  120. package/templates/template-vanilla-js/package.json +13 -0
  121. package/templates/template-vanilla-js/public/icons/icon_128.png +0 -0
  122. package/templates/template-vanilla-js/public/welcome.html +20 -0
  123. package/templates/template-vanilla-ts/AGENTS.md +59 -0
  124. package/templates/template-vanilla-ts/addfox.config.ts +25 -0
  125. package/templates/template-vanilla-ts/app/background/index.ts +8 -0
  126. package/templates/template-vanilla-ts/app/content/index.ts +1 -0
  127. package/templates/template-vanilla-ts/app/options/index.ts +2 -0
  128. package/templates/template-vanilla-ts/app/popup/index.ts +48 -0
  129. package/templates/template-vanilla-ts/app/sidepanel/index.ts +2 -0
  130. package/templates/template-vanilla-ts/package.json +14 -0
  131. package/templates/template-vanilla-ts/public/icons/icon_128.png +0 -0
  132. package/templates/template-vanilla-ts/public/welcome.html +20 -0
  133. package/templates/template-vanilla-ts/tsconfig.json +17 -0
  134. package/templates/template-vue-js/AGENTS.md +60 -0
  135. package/templates/template-vue-js/addfox.config.js +27 -0
  136. package/templates/template-vue-js/app/background/index.js +8 -0
  137. package/templates/template-vue-js/app/content/index.js +1 -0
  138. package/templates/template-vue-js/app/options/App.vue +6 -0
  139. package/templates/template-vue-js/app/options/index.js +5 -0
  140. package/templates/template-vue-js/app/popup/App.vue +34 -0
  141. package/templates/template-vue-js/app/popup/index.js +5 -0
  142. package/templates/template-vue-js/app/sidepanel/App.vue +6 -0
  143. package/templates/template-vue-js/app/sidepanel/index.js +5 -0
  144. package/templates/template-vue-js/package.json +18 -0
  145. package/templates/template-vue-js/public/icons/icon_128.png +0 -0
  146. package/templates/template-vue-js/public/welcome.html +20 -0
  147. package/templates/template-vue-ts/AGENTS.md +65 -0
  148. package/templates/template-vue-ts/addfox.config.ts +27 -0
  149. package/templates/template-vue-ts/app/background/index.ts +8 -0
  150. package/templates/template-vue-ts/app/content/index.ts +1 -0
  151. package/templates/template-vue-ts/app/options/App.vue +6 -0
  152. package/templates/template-vue-ts/app/options/index.ts +5 -0
  153. package/templates/template-vue-ts/app/popup/App.vue +32 -0
  154. package/templates/template-vue-ts/app/popup/index.ts +5 -0
  155. package/templates/template-vue-ts/app/sidepanel/App.vue +6 -0
  156. package/templates/template-vue-ts/app/sidepanel/index.ts +5 -0
  157. package/templates/template-vue-ts/package.json +20 -0
  158. package/templates/template-vue-ts/public/icons/icon_128.png +0 -0
  159. package/templates/template-vue-ts/public/welcome.html +20 -0
  160. package/templates/template-vue-ts/tsconfig.json +19 -0
@@ -0,0 +1 @@
1
+ console.log("Content script loaded");
@@ -0,0 +1,5 @@
1
+ import { h } from "preact";
2
+
3
+ export default function App() {
4
+ return <div>Hello from Preact</div>;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { render, h } from "preact";
2
+ import App from "./App";
3
+
4
+ const root = document.getElementById("root");
5
+ if (root) render(h(App, null), root);
@@ -0,0 +1,31 @@
1
+ import { h } from "preact";
2
+
3
+ export default function App() {
4
+ const popupStyle = {
5
+ width: 320,
6
+ minHeight: 200,
7
+ padding: 16,
8
+ boxSizing: "border-box",
9
+ display: "flex",
10
+ flexDirection: "column",
11
+ alignItems: "center",
12
+ justifyContent: "center",
13
+ gap: 12,
14
+ fontFamily: 'system-ui, -apple-system, "Segoe UI", sans-serif',
15
+ };
16
+
17
+ return (
18
+ <div style={popupStyle}>
19
+ <img src="/icons/icon_128.png" alt="" width={64} height={64} />
20
+ <div style={{ fontSize: 18, fontWeight: 600 }}>AddFox Preact</div>
21
+ <a
22
+ href="https://addfox.dev/"
23
+ target="_blank"
24
+ rel="noopener noreferrer"
25
+ style={{ fontSize: 13, color: "#2563eb" }}
26
+ >
27
+ addfox.dev
28
+ </a>
29
+ </div>
30
+ );
31
+ }
@@ -0,0 +1,5 @@
1
+ import { render, h } from "preact";
2
+ import App from "./App";
3
+
4
+ const root = document.getElementById("root");
5
+ if (root) render(h(App, null), root);
@@ -0,0 +1,5 @@
1
+ import { h } from "preact";
2
+
3
+ export default function App() {
4
+ return <div>Hello from Preact</div>;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { render, h } from "preact";
2
+ import App from "./App";
3
+
4
+ const root = document.getElementById("root");
5
+ if (root) render(h(App, null), root);
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "my-extension",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "addfox dev",
8
+ "build": "addfox build"
9
+ },
10
+ "dependencies": {
11
+ "@addfox/utils": "0.1.1",
12
+ "preact": "^10.29.0"
13
+ },
14
+ "devDependencies": {
15
+ "addfox": "0.1.1",
16
+ "@rsbuild/plugin-preact": "1.7.2"
17
+ }
18
+ }
@@ -0,0 +1,20 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Welcome - Addfox + Preact</title>
7
+ <style>
8
+ body { font-family: system-ui, sans-serif; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; margin: 0; background: #fafafa; color: #1a1a1a; }
9
+ h1 { font-size: 1.75rem; font-weight: 700; margin: 0 0 0.5rem; }
10
+ p { font-size: 1rem; color: #666; margin: 0; }
11
+ .welcome-icon { width: 96px; height: 96px; margin-bottom: 1rem; object-fit: contain; border-radius: 12px; }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <img class="welcome-icon" src="/icons/icon_128.png" alt="" width="96" height="96" />
16
+ <h1>Addfox + Preact</h1>
17
+ <p>Your extension is ready. Happy building!</p>
18
+ <p style="margin-top: 1rem;"><a href="https://addfox.dev/" target="_blank" rel="noopener noreferrer">addfox.dev</a></p>
19
+ </body>
20
+ </html>
@@ -0,0 +1,61 @@
1
+ # AI Agent Guide - Preact Addfox Extension
2
+
3
+ > **Priority**: Follow `.agents/skills/` first, then this guide, then [official docs](https://addfox.dev)
4
+
5
+ ## Project Overview
6
+
7
+ Preact browser extension using Addfox build tool. Uses `@rsbuild/plugin-preact` for JSX support.
8
+
9
+ ## Key Configuration Fields (addfox.config.ts)
10
+
11
+ ### Required Fields
12
+
13
+ - **`manifest`** - Extension manifest.json content
14
+ - Supports `chromium` and `firefox` variants
15
+ - Addfox auto-injects entry paths
16
+
17
+ - **`plugins`** - Rsbuild plugins array
18
+ - Must include `pluginPreact()` for JSX support
19
+
20
+ ### Optional Fields (use when needed)
21
+
22
+ - **`appDir`** - Source directory (default: "app")
23
+ - **`outDir`** - Build output directory
24
+ - **`entry`** - Manual entry mapping
25
+ - **`hotReload`** - Dev server settings
26
+ - **`debug`** - Enable debug logging
27
+ - **`zip`** - Output zip configuration
28
+ - **`rsbuild`** - Override Rsbuild configuration
29
+
30
+ ## Entry Structure
31
+
32
+ Entries auto-discovered from `appDir` subdirectories:
33
+
34
+ - `app/background/` → Service Worker (index.ts)
35
+ - `app/content/` → Content Script (index.ts)
36
+ - `app/popup/` → Popup page (index.tsx + App.tsx)
37
+ - `app/options/` → Options page
38
+ - `app/sidepanel/` → Side panel
39
+
40
+ ## Framework-Specific Notes
41
+
42
+ ### Preact
43
+
44
+ - JSX-based (`.tsx` files)
45
+ - React-compatible API with smaller bundle size
46
+ - TypeScript support enabled
47
+
48
+ ### Browser Extension APIs
49
+
50
+ - Install `webextension-polyfill` for cross-browser compatibility
51
+
52
+ ### Styling
53
+
54
+ - Supports CSS Modules
55
+ - Content scripts: use `@addfox/utils` with Shadow DOM
56
+
57
+ ## Resources
58
+
59
+ - Addfox docs: https://addfox.dev
60
+ - Rsbuild Preact plugin: https://rsbuild.dev/plugins/list/plugin-preact
61
+ - Preact docs: https://preactjs.com
@@ -0,0 +1,27 @@
1
+ import { defineConfig } from "addfox";
2
+ import { pluginPreact } from "@rsbuild/plugin-preact";
3
+
4
+ const manifest = {
5
+ name: "My Extension",
6
+ version: "1.0.0",
7
+ manifest_version: 3,
8
+ description: "Browser extension built with addfox",
9
+ permissions: ["activeTab"],
10
+ icons: {
11
+ "16": "icons/icon_128.png",
12
+ "48": "icons/icon_128.png",
13
+ "128": "icons/icon_128.png",
14
+ },
15
+ action: {
16
+ default_icon: {
17
+ "16": "icons/icon_128.png",
18
+ "48": "icons/icon_128.png",
19
+ "128": "icons/icon_128.png",
20
+ },
21
+ },
22
+ };
23
+
24
+ export default defineConfig({
25
+ manifest: { chromium: manifest, firefox: { ...manifest } },
26
+ plugins: [pluginPreact()],
27
+ });
@@ -0,0 +1,8 @@
1
+ function openWelcomePage() {
2
+ chrome.tabs.create({ url: chrome.runtime.getURL("welcome.html") });
3
+ }
4
+
5
+ chrome.runtime.onInstalled.addListener((details) => {
6
+ if (details.reason === "install" || details.reason === "update") openWelcomePage();
7
+ console.log("Extension installed");
8
+ });
@@ -0,0 +1 @@
1
+ console.log("Content script loaded");
@@ -0,0 +1,5 @@
1
+ import { h } from "preact";
2
+
3
+ export default function App() {
4
+ return <div>Hello from Preact</div>;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { createRoot } from "react-dom/client";
2
+ import App from "./App";
3
+
4
+ const root = document.getElementById("root");
5
+ if (root) createRoot(root).render(<App />);
@@ -0,0 +1,31 @@
1
+ import { h } from "preact";
2
+
3
+ export default function App() {
4
+ const popupStyle = {
5
+ width: 320,
6
+ minHeight: 200,
7
+ padding: 16,
8
+ boxSizing: "border-box" as const,
9
+ display: "flex",
10
+ flexDirection: "column" as const,
11
+ alignItems: "center",
12
+ justifyContent: "center",
13
+ gap: 12,
14
+ fontFamily: 'system-ui, -apple-system, "Segoe UI", sans-serif',
15
+ };
16
+
17
+ return (
18
+ <div style={popupStyle}>
19
+ <img src="/icons/icon_128.png" alt="" width={64} height={64} />
20
+ <div style={{ fontSize: 18, fontWeight: 600 }}>AddFox Preact</div>
21
+ <a
22
+ href="https://addfox.dev/"
23
+ target="_blank"
24
+ rel="noopener noreferrer"
25
+ style={{ fontSize: 13, color: "#2563eb" }}
26
+ >
27
+ addfox.dev
28
+ </a>
29
+ </div>
30
+ );
31
+ }
@@ -0,0 +1,5 @@
1
+ import { createRoot } from "react-dom/client";
2
+ import App from "./App";
3
+
4
+ const root = document.getElementById("root");
5
+ if (root) createRoot(root).render(<App />);
@@ -0,0 +1,5 @@
1
+ import { h } from "preact";
2
+
3
+ export default function App() {
4
+ return <div>Hello from Preact</div>;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { createRoot } from "react-dom/client";
2
+ import App from "./App";
3
+
4
+ const root = document.getElementById("root");
5
+ if (root) createRoot(root).render(<App />);
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "my-extension",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "addfox dev",
8
+ "build": "addfox build"
9
+ },
10
+ "dependencies": {
11
+ "@addfox/utils": "0.1.1",
12
+ "preact": "^10.29.0"
13
+ },
14
+ "devDependencies": {
15
+ "addfox": "0.1.1",
16
+ "@rsbuild/plugin-preact": "1.7.2",
17
+ "typescript": "^5.9.3",
18
+ "@types/chrome": "^0.1.38"
19
+ }
20
+ }
@@ -0,0 +1,20 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Welcome - Addfox + Preact</title>
7
+ <style>
8
+ body { font-family: system-ui, sans-serif; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; margin: 0; background: #fafafa; color: #1a1a1a; }
9
+ h1 { font-size: 1.75rem; font-weight: 700; margin: 0 0 0.5rem; }
10
+ p { font-size: 1rem; color: #666; margin: 0; }
11
+ .welcome-icon { width: 96px; height: 96px; margin-bottom: 1rem; object-fit: contain; border-radius: 12px; }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <img class="welcome-icon" src="/icons/icon_128.png" alt="" width="96" height="96" />
16
+ <h1>Addfox + Preact</h1>
17
+ <p>Your extension is ready. Happy building!</p>
18
+ <p style="margin-top: 1rem;"><a href="https://addfox.dev/" target="_blank" rel="noopener noreferrer">addfox.dev</a></p>
19
+ </body>
20
+ </html>
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "jsx": "react-jsx",
8
+ "resolveJsonModule": true,
9
+ "isolatedModules": true,
10
+ "noEmit": true,
11
+ "skipLibCheck": true,
12
+ "types": [
13
+ "chrome"
14
+ ]
15
+ },
16
+ "include": [
17
+ "app"
18
+ ]
19
+ }
@@ -0,0 +1,66 @@
1
+ # AI Agent Guide - React Addfox Extension
2
+
3
+ > **Priority**: Follow `.agents/skills/` first, then this guide, then [official docs](https://addfox.dev)
4
+
5
+ ## Project Overview
6
+
7
+ React-based browser extension using Addfox build tool. Uses `@rsbuild/plugin-react` for JSX support and React Fast Refresh.
8
+
9
+ ## Key Configuration Fields (addfox.config.js)
10
+
11
+ ### Required Fields
12
+
13
+ - **`manifest`** - Extension manifest.json content
14
+ - Supports `chromium` and `firefox` variants for browser-specific differences
15
+ - Addfox auto-injects entry paths - don't hardcode them
16
+
17
+ - **`plugins`** - Rsbuild plugins array
18
+ - Must include `pluginReact()` for JSX support
19
+
20
+ ### Optional Fields (use when needed)
21
+
22
+ - **`appDir`** - Source directory (default: "app")
23
+ - **`outDir`** - Build output directory (default: ".addfox/extension")
24
+ - **`entry`** - Manual entry mapping (when auto-discovery fails)
25
+ - **`hotReload`** - Dev server settings (port, auto-refresh)
26
+ - **`debug`** - Enable debug logging
27
+ - **`zip`** - Output zip configuration
28
+ - **`rsbuild`** - Override Rsbuild configuration
29
+
30
+ ## Entry Structure
31
+
32
+ Entries auto-discovered from `appDir` subdirectories:
33
+
34
+ - `app/background/` → Service Worker
35
+ - `app/content/` → Content Script
36
+ - `app/popup/` → Popup page
37
+ - `app/options/` → Options page
38
+ - `app/sidepanel/` → Side panel
39
+ - `app/devtools/` → DevTools page
40
+
41
+ Each needs `index.jsx` as entry point.
42
+
43
+ ## Framework-Specific Notes
44
+
45
+ ### React/JSX
46
+
47
+ - Files use `.jsx` extension
48
+ - React Fast Refresh enabled in dev mode
49
+ - JSX transform automatic
50
+
51
+ ### Browser Extension APIs
52
+
53
+ - Install `webextension-polyfill` for cross-browser compatibility
54
+ - Import: `import browser from "webextension-polyfill"`
55
+
56
+ ### Styling
57
+
58
+ - Supports CSS Modules
59
+ - Supports Tailwind if configured
60
+ - Content scripts: use `@addfox/utils` with Shadow DOM for isolation
61
+
62
+ ## Resources
63
+
64
+ - Addfox docs: https://addfox.dev
65
+ - Rsbuild React plugin: https://rsbuild.dev/plugins/list/plugin-react
66
+ - WebExtension API: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API
@@ -0,0 +1,27 @@
1
+ import { defineConfig } from "addfox";
2
+ import { pluginReact } from "@rsbuild/plugin-react";
3
+
4
+ const manifest = {
5
+ name: "My Extension",
6
+ version: "1.0.0",
7
+ manifest_version: 3,
8
+ description: "Browser extension built with addfox",
9
+ permissions: ["activeTab"],
10
+ icons: {
11
+ "16": "icons/icon_128.png",
12
+ "48": "icons/icon_128.png",
13
+ "128": "icons/icon_128.png",
14
+ },
15
+ action: {
16
+ default_icon: {
17
+ "16": "icons/icon_128.png",
18
+ "48": "icons/icon_128.png",
19
+ "128": "icons/icon_128.png",
20
+ },
21
+ },
22
+ };
23
+
24
+ export default defineConfig({
25
+ manifest: { chromium: manifest, firefox: { ...manifest } },
26
+ plugins: [pluginReact()],
27
+ });
@@ -0,0 +1,8 @@
1
+ function openWelcomePage() {
2
+ chrome.tabs.create({ url: chrome.runtime.getURL("welcome.html") });
3
+ }
4
+
5
+ chrome.runtime.onInstalled.addListener((details) => {
6
+ if (details.reason === "install" || details.reason === "update") openWelcomePage();
7
+ console.log("Extension installed");
8
+ });
@@ -0,0 +1 @@
1
+ console.log("Content script loaded");
@@ -0,0 +1,3 @@
1
+ export default function App() {
2
+ return <div>Hello from React</div>;
3
+ }
@@ -0,0 +1,5 @@
1
+ import { createRoot } from "react-dom/client";
2
+ import App from "./App";
3
+
4
+ const root = document.getElementById("root");
5
+ if (root) createRoot(root).render(<App />);
@@ -0,0 +1,29 @@
1
+ export default function App() {
2
+ const popupStyle = {
3
+ width: 320,
4
+ minHeight: 200,
5
+ padding: 16,
6
+ boxSizing: "border-box",
7
+ display: "flex",
8
+ flexDirection: "column",
9
+ alignItems: "center",
10
+ justifyContent: "center",
11
+ gap: 12,
12
+ fontFamily: 'system-ui, -apple-system, "Segoe UI", sans-serif',
13
+ };
14
+
15
+ return (
16
+ <div style={popupStyle}>
17
+ <img src="/icons/icon_128.png" alt="" width={64} height={64} />
18
+ <div style={{ fontSize: 18, fontWeight: 600 }}>AddFox React</div>
19
+ <a
20
+ href="https://addfox.dev/"
21
+ target="_blank"
22
+ rel="noopener noreferrer"
23
+ style={{ fontSize: 13, color: "#2563eb" }}
24
+ >
25
+ addfox.dev
26
+ </a>
27
+ </div>
28
+ );
29
+ }
@@ -0,0 +1,5 @@
1
+ import { createRoot } from "react-dom/client";
2
+ import App from "./App";
3
+
4
+ const root = document.getElementById("root");
5
+ if (root) createRoot(root).render(<App />);
@@ -0,0 +1,3 @@
1
+ export default function App() {
2
+ return <div>Hello from React</div>;
3
+ }
@@ -0,0 +1,5 @@
1
+ import { createRoot } from "react-dom/client";
2
+ import App from "./App";
3
+
4
+ const root = document.getElementById("root");
5
+ if (root) createRoot(root).render(<App />);
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "my-extension",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "addfox dev",
8
+ "build": "addfox build"
9
+ },
10
+ "dependencies": {
11
+ "@addfox/utils": "0.1.1",
12
+ "react": "^19.2.4",
13
+ "react-dom": "^19.2.4"
14
+ },
15
+ "devDependencies": {
16
+ "addfox": "0.1.1",
17
+ "@rsbuild/plugin-react": "2.0.0"
18
+ }
19
+ }
@@ -0,0 +1,20 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Welcome - Addfox + React</title>
7
+ <style>
8
+ body { font-family: system-ui, sans-serif; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; margin: 0; background: #fafafa; color: #1a1a1a; }
9
+ h1 { font-size: 1.75rem; font-weight: 700; margin: 0 0 0.5rem; }
10
+ p { font-size: 1rem; color: #666; margin: 0; }
11
+ .welcome-icon { width: 96px; height: 96px; margin-bottom: 1rem; object-fit: contain; border-radius: 12px; }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <img class="welcome-icon" src="/icons/icon_128.png" alt="" width="96" height="96" />
16
+ <h1>Addfox + React</h1>
17
+ <p>Your extension is ready. Happy building!</p>
18
+ <p style="margin-top: 1rem;"><a href="https://addfox.dev/" target="_blank" rel="noopener noreferrer">addfox.dev</a></p>
19
+ </body>
20
+ </html>
@@ -0,0 +1,93 @@
1
+ # AI Agent Guide - React Addfox Extension
2
+
3
+ > **Priority**: Follow `.agents/skills/` first, then this guide, then [official docs](https://addfox.dev)
4
+
5
+ ## Project Overview
6
+
7
+ React-based browser extension using Addfox build tool. Uses `@rsbuild/plugin-react` for JSX/TSX support and React Fast Refresh.
8
+
9
+ ## Key Configuration Fields (addfox.config.ts)
10
+
11
+ ### Required Fields
12
+
13
+ - **`manifest`** - Extension manifest.json content
14
+ - Supports `chromium` and `firefox` variants for browser-specific differences
15
+ - Addfox auto-injects entry paths (popup, background, etc.) - don't hardcode them
16
+
17
+ - **`plugins`** - Rsbuild plugins array
18
+ - Must include `pluginReact()` for JSX/TSX support
19
+ - Add other Rsbuild plugins as needed
20
+
21
+ ### Optional Fields (use when needed)
22
+
23
+ - **`appDir`** - Source directory (default: "app")
24
+ - Change if source files are in a different folder
25
+
26
+ - **`outDir`** - Build output directory (default: ".addfox/extension")
27
+ - Change for custom output location
28
+
29
+ - **`entry`** - Manual entry point mapping
30
+ - Only needed when auto-discovery fails or custom structure
31
+
32
+ - **`hotReload`** - Dev server settings
33
+ - `port`: WebSocket port (default: 23333)
34
+ - `autoRefreshContentPage`: Auto-refresh on content changes
35
+
36
+ - **`debug`** - Enable debug logging (default: false)
37
+
38
+ - **`zip`** - Output zip configuration for distribution
39
+
40
+ - **`rsbuild`** - Override Rsbuild configuration directly
41
+
42
+ ## Entry Structure
43
+
44
+ Entries auto-discovered from `appDir` subdirectories:
45
+
46
+ - `app/background/` → Service Worker
47
+ - `app/content/` → Content Script
48
+ - `app/popup/` → Popup page
49
+ - `app/options/` → Options page
50
+ - `app/sidepanel/` → Side panel
51
+ - `app/devtools/` → DevTools page
52
+
53
+ Each needs `index.tsx` as entry point.
54
+
55
+ ## Framework-Specific Notes
56
+
57
+ ### React/JSX
58
+
59
+ - Files use `.tsx` extension
60
+ - React Fast Refresh enabled in dev mode
61
+ - JSX transform automatic (no need to import React)
62
+
63
+ ### Browser Extension APIs
64
+
65
+ - Install `webextension-polyfill` for cross-browser compatibility
66
+ - Import: `import browser from "webextension-polyfill"`
67
+
68
+ ### Styling
69
+
70
+ - Supports CSS Modules: `import styles from "./App.module.css"`
71
+ - Supports Tailwind if configured
72
+ - For content scripts: use `@addfox/utils` with Shadow DOM for isolation
73
+
74
+ ## Common Tasks
75
+
76
+ Adding a new entry:
77
+ 1. Create `app/<entry-name>/index.tsx`
78
+ 2. Addfox auto-detects - no config change needed
79
+ 3. Reference in manifest if needed (paths auto-injected)
80
+
81
+ Adding permissions:
82
+ 1. Edit `manifest.permissions` in config
83
+ 2. Firefox may need different permission format
84
+
85
+ Cross-browser manifest differences:
86
+ - Use `manifest.chromium` and `manifest.firefox` objects
87
+ - Common fields go in both, differences separated
88
+
89
+ ## Resources
90
+
91
+ - Addfox docs: https://addfox.dev
92
+ - Rsbuild React plugin: https://rsbuild.dev/plugins/list/plugin-react
93
+ - WebExtension API: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API