-
-
Notifications
You must be signed in to change notification settings - Fork 226
Add Chrome extension #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jamesvclements
wants to merge
13
commits into
benjitaylor:main
Choose a base branch
from
jamesvclements:feat/chrome-extension
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add Chrome extension #121
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d8e7de0
Add freehand drawing mode to toolbar
benjitaylor a547e77
Block drawing while annotation popup is open, improve hover glow
benjitaylor 2ba64e0
Animate drawing glow highlight, hide drawings with markers
benjitaylor c373186
Revert "Animate drawing glow highlight, hide drawings with markers"
benjitaylor 46b6ce4
Animate drawing glow in/out, hide drawings with markers
benjitaylor ec2b54d
Replace glow with shadowBlur, animate via rAF
benjitaylor 298b279
Drawing animation overhaul: dim instead of glow, tooltip exit, canvas…
benjitaylor 5374444
Fix drawing deletion bugs, revert pointer events to mouse events
benjitaylor 2798e79
Add Chrome extension workspace package
jamesvclements cf3812d
Polish popup: light mode, fix toolbar status detection
jamesvclements 06a5b1e
Add MCP status to popup, fix default endpoint port
jamesvclements 43494f9
Add Chrome Extension section to README
jamesvclements 9d5d071
Move Chrome extension instructions to extension/README.md
jamesvclements File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| node_modules/.claude/settings.local.json | ||
| node_modules | ||
| mcp/dist | ||
| extension/dist | ||
| .DS_Store |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| node_modules/ | ||
| dist/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # Chrome Extension | ||
|
|
||
| Use Agentation on any localhost page without adding it to your project. | ||
|
|
||
| ## Install from release | ||
|
|
||
| Download `agentation-extension.zip` from [Releases](https://github.com/benjitaylor/agentation/releases), unzip, then: | ||
| `chrome://extensions` → Developer mode → Load unpacked → select the folder. | ||
|
|
||
| ## Build from source | ||
|
|
||
| ```bash | ||
| pnpm extension:build | ||
| ``` | ||
|
|
||
| Then load `extension/` as an unpacked extension. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| import * as esbuild from "esbuild"; | ||
| import * as sass from "sass"; | ||
| import postcss from "postcss"; | ||
| import postcssModules from "postcss-modules"; | ||
| import * as path from "path"; | ||
| import * as fs from "fs"; | ||
| import { fileURLToPath } from "url"; | ||
|
|
||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
| const watch = process.argv.includes("--watch"); | ||
|
|
||
| const pkg = JSON.parse( | ||
| fs.readFileSync(path.resolve(__dirname, "../package/package.json"), "utf-8") | ||
| ); | ||
| const VERSION = pkg.version; | ||
|
|
||
| // SCSS CSS Modules plugin — mirrors package/tsup.config.ts exactly | ||
| function scssModulesPlugin() { | ||
| return { | ||
| name: "scss-modules", | ||
| setup(build) { | ||
| build.onLoad({ filter: /\.scss$/ }, async (args) => { | ||
| const isModule = args.path.includes(".module."); | ||
| const parentDir = path.basename(path.dirname(args.path)); | ||
| const baseName = path.basename( | ||
| args.path, | ||
| isModule ? ".module.scss" : ".scss" | ||
| ); | ||
| const styleId = `${parentDir}-${baseName}`; | ||
|
|
||
| const result = sass.compile(args.path); | ||
| let css = result.css; | ||
|
|
||
| if (isModule) { | ||
| let classNames = {}; | ||
| const postcssResult = await postcss([ | ||
| postcssModules({ | ||
| getJSON(cssFileName, json) { | ||
| classNames = json; | ||
| }, | ||
| generateScopedName: "[name]__[local]___[hash:base64:5]", | ||
| }), | ||
| ]).process(css, { from: args.path }); | ||
| css = postcssResult.css; | ||
|
|
||
| return { | ||
| contents: ` | ||
| const css = ${JSON.stringify(css)}; | ||
| const classNames = ${JSON.stringify(classNames)}; | ||
| if (typeof document !== 'undefined') { | ||
| let style = document.getElementById('feedback-tool-styles-${styleId}'); | ||
| if (!style) { | ||
| style = document.createElement('style'); | ||
| style.id = 'feedback-tool-styles-${styleId}'; | ||
| style.textContent = css; | ||
| document.head.appendChild(style); | ||
| } | ||
| } | ||
| export default classNames; | ||
| `, | ||
| loader: "js", | ||
| }; | ||
| } else { | ||
| return { | ||
| contents: ` | ||
| const css = ${JSON.stringify(css)}; | ||
| if (typeof document !== 'undefined') { | ||
| let style = document.getElementById('feedback-tool-styles-${styleId}'); | ||
| if (!style) { | ||
| style = document.createElement('style'); | ||
| style.id = 'feedback-tool-styles-${styleId}'; | ||
| style.textContent = css; | ||
| document.head.appendChild(style); | ||
| } | ||
| } | ||
| export default {}; | ||
| `, | ||
| loader: "js", | ||
| }; | ||
| } | ||
| }); | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| const ctx = await esbuild.context({ | ||
| entryPoints: [path.resolve(__dirname, "src/content.tsx")], | ||
| bundle: true, | ||
| outfile: path.resolve(__dirname, "dist/content.js"), | ||
| format: "iife", | ||
| target: "chrome120", | ||
| jsx: "automatic", | ||
| jsxImportSource: "react", | ||
| plugins: [scssModulesPlugin()], | ||
| alias: { | ||
| agentation: path.resolve(__dirname, "../package/src/index.ts"), | ||
| }, | ||
| define: { | ||
| "process.env.NODE_ENV": '"production"', | ||
| __VERSION__: JSON.stringify(VERSION), | ||
| }, | ||
| }); | ||
|
|
||
| if (watch) { | ||
| await ctx.watch(); | ||
| console.log("Watching for changes..."); | ||
| } else { | ||
| await ctx.rebuild(); | ||
| await ctx.dispose(); | ||
| console.log("Built extension/dist/content.js"); | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| { | ||
| "manifest_version": 3, | ||
| "name": "Agentation", | ||
| "description": "Visual feedback tool for AI coding agents. Annotate elements, add notes, copy structured output.", | ||
| "version": "0.1.0", | ||
| "permissions": ["storage", "activeTab", "tabs"], | ||
| "content_scripts": [ | ||
| { | ||
| "matches": [ | ||
| "http://localhost/*", | ||
| "http://127.0.0.1/*", | ||
| "https://localhost/*" | ||
| ], | ||
| "js": ["dist/content.js"], | ||
| "run_at": "document_idle" | ||
| } | ||
| ], | ||
| "action": { | ||
| "default_popup": "popup.html", | ||
| "default_icon": { | ||
| "16": "icons/icon-16.png", | ||
| "48": "icons/icon-48.png", | ||
| "128": "icons/icon-128.png" | ||
| } | ||
| }, | ||
| "icons": { | ||
| "16": "icons/icon-16.png", | ||
| "48": "icons/icon-48.png", | ||
| "128": "icons/icon-128.png" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "name": "agentation-extension", | ||
| "version": "0.1.0", | ||
| "private": true, | ||
| "type": "module", | ||
| "scripts": { | ||
| "build": "node build.mjs", | ||
| "watch": "node build.mjs --watch", | ||
| "zip": "zip -r agentation-extension.zip manifest.json popup.html popup.js icons/ dist/content.js" | ||
| }, | ||
| "dependencies": { | ||
| "agentation": "workspace:*" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/react": "^18.2.0", | ||
| "@types/react-dom": "^18.2.0", | ||
| "esbuild": "^0.27.0", | ||
| "postcss": "^8.5.6", | ||
| "postcss-modules": "^6.0.1", | ||
| "react": "^18.2.0", | ||
| "react-dom": "^18.2.0", | ||
| "sass": "^1.97.2" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <style> | ||
| * { margin: 0; padding: 0; box-sizing: border-box; } | ||
| body { | ||
| width: 260px; | ||
| padding: 16px; | ||
| font-family: system-ui, -apple-system, sans-serif; | ||
| background: #fff; | ||
| color: #111; | ||
| /* outer_radius = inner_radius (8px) + padding (16px) = 24px */ | ||
| border-radius: 24px; | ||
| } | ||
| h1 { | ||
| font-size: 14px; | ||
| font-weight: 600; | ||
| margin-bottom: 4px; | ||
| } | ||
| p { | ||
| font-size: 12px; | ||
| color: rgba(0,0,0,0.5); | ||
| line-height: 1.5; | ||
| margin-bottom: 12px; | ||
| } | ||
| .status { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 6px; | ||
| font-size: 12px; | ||
| padding: 8px 10px; | ||
| background: rgba(0,0,0,0.03); | ||
| border-radius: 8px; | ||
| margin-bottom: 6px; | ||
| } | ||
| .status:last-of-type { margin-bottom: 0; } | ||
| .dot { | ||
| width: 8px; | ||
| height: 8px; | ||
| border-radius: 50%; | ||
| flex-shrink: 0; | ||
| } | ||
| .dot.active { background: #34c759; } | ||
| .dot.inactive { background: rgba(0,0,0,0.15); } | ||
| .label { color: rgba(0,0,0,0.5); } | ||
| .value { color: #111; margin-left: auto; } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <h1>Agentation</h1> | ||
| <p>Visual feedback for AI coding agents</p> | ||
|
|
||
| <div class="status" id="toolbar-status"> | ||
| <span class="dot inactive" id="toolbar-dot"></span> | ||
| <span class="label">Toolbar</span> | ||
| <span class="value" id="toolbar-value">Checking...</span> | ||
| </div> | ||
| <div class="status" id="mcp-status"> | ||
| <span class="dot inactive" id="mcp-dot"></span> | ||
| <span class="label">MCP Server</span> | ||
| <span class="value" id="mcp-value">Checking...</span> | ||
| </div> | ||
|
|
||
| <script src="popup.js"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| const toolbarDot = document.getElementById("toolbar-dot"); | ||
| const toolbarValue = document.getElementById("toolbar-value"); | ||
| const mcpStatus = document.getElementById("mcp-status"); | ||
| const mcpDot = document.getElementById("mcp-dot"); | ||
| const mcpValue = document.getElementById("mcp-value"); | ||
|
|
||
| // Check if the toolbar is active on the current tab by matching | ||
| // against the content script patterns from manifest.json | ||
| const CONTENT_SCRIPT_PATTERNS = [ | ||
| /^http:\/\/localhost(:\d+)?\//, | ||
| /^http:\/\/127\.0\.0\.1(:\d+)?\//, | ||
| /^https:\/\/localhost(:\d+)?\//, | ||
| ]; | ||
|
|
||
| chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { | ||
| const url = tabs[0]?.url || ""; | ||
| const isActive = CONTENT_SCRIPT_PATTERNS.some((p) => p.test(url)); | ||
|
|
||
| if (isActive) { | ||
| toolbarDot.className = "dot active"; | ||
| toolbarValue.textContent = "Active"; | ||
| checkMcpHealth(); | ||
| } else { | ||
| toolbarDot.className = "dot inactive"; | ||
| toolbarValue.textContent = "Inactive"; | ||
| mcpStatus.style.display = "none"; | ||
| } | ||
| }); | ||
|
|
||
| function checkMcpHealth() { | ||
| fetch("http://localhost:4747/health") | ||
| .then((res) => { | ||
| if (res.ok) { | ||
| mcpDot.className = "dot active"; | ||
| mcpValue.textContent = "Connected"; | ||
| } else { | ||
| mcpDot.className = "dot inactive"; | ||
| mcpValue.textContent = "Not responding"; | ||
| } | ||
| }) | ||
| .catch(() => { | ||
| mcpDot.className = "dot inactive"; | ||
| mcpValue.textContent = "Not running"; | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import React from "react"; | ||
| import ReactDOM from "react-dom/client"; | ||
| import { Agentation } from "agentation"; | ||
|
|
||
| const MCP_DEFAULT_ENDPOINT = "http://localhost:4747"; | ||
|
|
||
| function AgentationExtension() { | ||
| const [endpoint, setEndpoint] = React.useState<string | undefined>(undefined); | ||
|
|
||
| React.useEffect(() => { | ||
| fetch(`${MCP_DEFAULT_ENDPOINT}/health`) | ||
| .then((res) => { | ||
| if (res.ok) { | ||
| setEndpoint(MCP_DEFAULT_ENDPOINT); | ||
| } | ||
| }) | ||
| .catch(() => { | ||
| // MCP server not available — run in local-only mode | ||
| }); | ||
| }, []); | ||
|
|
||
| return <Agentation endpoint={endpoint} />; | ||
| } | ||
|
|
||
| function mount() { | ||
| const container = document.createElement("div"); | ||
| container.id = "agentation-extension-root"; | ||
| document.body.appendChild(container); | ||
|
|
||
| const root = ReactDOM.createRoot(container); | ||
| root.render( | ||
| <React.StrictMode> | ||
| <AgentationExtension /> | ||
| </React.StrictMode> | ||
| ); | ||
| } | ||
|
|
||
| if (document.body) { | ||
| mount(); | ||
| } else { | ||
| document.addEventListener("DOMContentLoaded", mount); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice to have a sticker version of this (where the white background is the shape of the bunny) and the rest is transparent, instead of the white rounded rectangle