From 5856c883559764e75b7305384a3a6cd2e5972337 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Thu, 18 Sep 2025 02:09:48 -0700 Subject: [PATCH 1/5] Integrate the README.md into the CONTRIBUTING.md --- CONTRIBUTING.md | 108 ++++++++++++++++++++++++++++++++++- browser-extension/README.md | 110 ------------------------------------ 2 files changed, 105 insertions(+), 113 deletions(-) delete mode 100644 browser-extension/README.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 428a70f..d807cfd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,9 +11,111 @@ By submitting a Pull Request, you agree that your contributions are licensed und This extension ***must never transmit any data outside the browser***. - it adds syntax highlighting by running local scripts -- it stores unfinished comments in local storage +- it stores finished and unfinished comments in local storage - there is no need to initiate an outbound network request, no features will be added which require outbound network requests -## How to +## Developer quickstart -- `browser-extension` is the primary project. Go to [its README.md](browser-extension/README.md) for development info. +### Hotreload development + +- `pnpm install` +- `pnpm run dev` +- open [`chrome://extensions`](chrome://extensions) +- toggle **Developer mode** (top-right) +- click "Load unpacked" (far left) + - `.output/chrome-mv3-dev` + - if you can't find `.output`, it's probably hidden, `command+shift+period` will show it +- click the puzzle icon next to the url bar, then pin the Gitcasso icon + +### Testing and quality +- `pnpm biome` - runs `biome check` (lint & formatting) +- `pnpm biome:fix` - fixes most of what `biome check` finds +- `pnpm typecheck` - typechecking +- `pnpm test` - vitest +- `pnpm test -u` - updates all snapshots + +## How it works + +This is a [WXT](https://wxt.dev/)-based browser extension that + +- finds `textarea` components and decorates them with [overtype](https://overtype.dev/) and [highlight.js](https://highlightjs.org/) +- stores unposted comment drafts, and makes them easy to find via the extension popup + +### Entry points + +- [`src/entrypoints/content.ts`](src/entrypoints/content.ts) - injected into every webpage +- [`src/entrypoints/background.ts`](src/entrypoints/background.ts) - service worker that manages state and handles messages +- [`src/entrypoints/popup/popup.tsx`](src/entrypoints/popup/popup.tsx) - popup (html/css/tsx) with shadcn/ui table components + +```mermaid +graph TD + Content[Content Script
content.ts] + Background[Background Script
background.ts] + Popup[Popup Script
popup/popup.tsx] + + Content -->|ENHANCED/DESTROYED
CommentEvent| Background + Popup -->|GET_OPEN_SPOTS
SWITCH_TO_TAB| Background + Background -->|GetOpenSpotsResponse
spots array| Popup + + Background -.->|manages| Storage[Comment State Storage
openSpots JsonMap] + Content -.->|enhances| TextArea[textarea elements
on web pages] + Popup -.->|displays| UI[Extension UI
list of comment spots] + + classDef entrypoint fill:#e1f5fe + classDef storage fill:#f3e5f5 + classDef ui fill:#e8f5e8 + + class Content,Background,Popup entrypoint + class Storage storage + class TextArea,UI ui +``` + +Every time a `textarea` shows up on a page, on initial load or later on, it gets passed to a list of `CommentEnhancer`s. Each one gets a turn to say "I can enhance this box!". They show that they can enhance it by returning something non-null in the method `tryToEnhance(textarea: HTMLTextAreaElement): Spot | null`. Later on, that same `Spot` data will be used by the `tableRow(spot: Spot): ReactNode` method to create React components for rich formatting in the popup table. + +Those `Spot` values get bundled up with the `HTMLTextAreaElement` itself into an `EnhancedTextarea`, which gets added to the `TextareaRegistry`. At some interval, draft edits get saved by the browser extension. + +When the `textarea` gets removed from the page, the `TextareaRegistry` is notified so that the `CommentSpot` can be marked as abandoned or submitted as appropriate. + +## Testing + +- `pnpm playground` gives you a test environment where you can tinker with the popup with various test data, supports hot reload +- `pnpm corpus:view` gives you recordings of various web pages which you can see with and without enhancement by the browser extension + +### Test Corpus + +We maintain a corpus of test pages in two formats for testing the browser extension: + +#### HAR Corpus (Automated) + +- For testing initial page loads and network requests +- HAR recordings live in `tests/corpus/*.har`, complete recordings of the network requests of a single page load +- You can add or change URLs in `tests/corpus/_corpus-index.ts` +- **Recording new HAR files:** + - `npx playwright codegen https://github.com/login --save-storage=playwright/.auth/gh.json` will store new auth tokens + - login manually, then close the browser + - ***these cookies are very sensitive! we only run this script using a test account that has no permissions or memberships to anything, recommend you do the same!*** + - `pnpm run corpus:har:record` records new HAR files using those auth tokens (it needs args, run it with no args for docs) + - DO NOT COMMIT AND PUSH NEW OR CHANGED HAR files! + - we try to sanitize these (see `corpus-har-record.ts` for details) but there may be important PII in them + - if you need new HAR files for something, let us know and we will generate them ourselves using a dummy account + - IF YOUR PR CHANGES OR ADDS HAR FILES WE WILL CLOSE IT. Ask for HAR files and we'll be happy to generate clean ones you can test against. + +#### HTML Corpus (Manual) + +- For testing post-interaction states (e.g., expanded textareas, modal dialogs, dynamic content) +- HTML snapshots live in `tests/corpus/*.html`, manually captured using SingleFile browser extension +- All assets are inlined in a single HTML file by SingleFile +- **Creating new HTML corpus files:** + 1. Navigate to the desired page state (click buttons, expand textareas, etc.) + 2. Use SingleFile browser extension to save the complete page + 3. Save the `.html` file to `tests/corpus/html/` with a descriptive name + 4. Add an entry to `tests/corpus/_corpus-index.ts` with `type: 'html'` and a description of the captured state + 5. Feel free to contribute these if you want, but be mindful that they will be part of our immutable git history + +#### Viewing Corpus Files + +- Run `pnpm corpus:view` to start the test server at http://localhost:3001 +- Select any corpus file to view in two modes: + - **Clean**: Original page without extension + - **Gitcasso**: Page with extension injected for testing +- Both HAR and HTML corpus types are supported diff --git a/browser-extension/README.md b/browser-extension/README.md deleted file mode 100644 index 1b3afb5..0000000 --- a/browser-extension/README.md +++ /dev/null @@ -1,110 +0,0 @@ -# Gitcasso browser extension - -## Developer quickstart - -### Hotreload development - -- `pnpm install` -- `pnpm run dev` -- open [`chrome://extensions`](chrome://extensions) -- toggle **Developer mode** (top-right) -- click "Load unpacked" (far left) - - `browser-extension/.output/chrome-mv3-dev` - - if you can't find `.output`, it's probably hidden, `command+shift+period` will show it -- click the puzzle icon next to the url bar, then pin the Gitcasso icon - -### Testing and quality -- `pnpm run biome` - runs `biome check` (lint & formatting) -- `pnpm run biome:fix` - fixes most of what `biome check` finds -- `pnpm run compile` - typechecking -- `pnpm test` - vitest -- `pnpm test -- -u` updates all the snapshots - -### Deployment -- `pnpm run build` - build for mv3 for most browsers -- `pnpm run build:firefox` - build mv2 specifically for Firefox - -## How it works - -This is a [WXT](https://wxt.dev/)-based browser extension that - -- finds `textarea` components and decorates them with [overtype](https://overtype.dev/) and [highlight.js](https://highlightjs.org/) -- stores unposted comment drafts, and makes them easy to find via the extension popup - -### Entry points - -- [`src/entrypoints/content.ts`](src/entrypoints/content.ts) - injected into every webpage -- [`src/entrypoints/background.ts`](src/entrypoints/background.ts) - service worker that manages state and handles messages -- [`src/entrypoints/popup/popup.tsx`](src/entrypoints/popup/popup.tsx) - popup (html/css/tsx) with shadcn/ui table components - -```mermaid -graph TD - Content[Content Script
content.ts] - Background[Background Script
background.ts] - Popup[Popup Script
popup/popup.tsx] - - Content -->|ENHANCED/DESTROYED
CommentEvent| Background - Popup -->|GET_OPEN_SPOTS
SWITCH_TO_TAB| Background - Background -->|GetOpenSpotsResponse
spots array| Popup - - Background -.->|manages| Storage[Comment State Storage
openSpots JsonMap] - Content -.->|enhances| TextArea[textarea elements
on web pages] - Popup -.->|displays| UI[Extension UI
list of comment spots] - - classDef entrypoint fill:#e1f5fe - classDef storage fill:#f3e5f5 - classDef ui fill:#e8f5e8 - - class Content,Background,Popup entrypoint - class Storage storage - class TextArea,UI ui -``` - -Every time a `textarea` shows up on a page, on initial load or later on, it gets passed to a list of `CommentEnhancer`s. Each one gets a turn to say "I can enhance this box!". They show that they can enhance it by returning something non-null in the method `tryToEnhance(textarea: HTMLTextAreaElement): Spot | null`. Later on, that same `Spot` data will be used by the `tableRow(spot: Spot): ReactNode` method to create React components for rich formatting in the popup table. - -Those `Spot` values get bundled up with the `HTMLTextAreaElement` itself into an `EnhancedTextarea`, which gets added to the `TextareaRegistry`. At some interval, draft edits get saved by the browser extension. - -When the `textarea` gets removed from the page, the `TextareaRegistry` is notified so that the `CommentSpot` can be marked as abandoned or submitted as appropriate. - -## Testing - -- `npm run playground` gives you a test environment where you can tinker with the popup with various test data, supports hot reload -- `npm run corpus:view` gives you recordings of various web pages which you can see with and without enhancement by the browser extension - -### Test Corpus - -We maintain a corpus of test pages in two formats for testing the browser extension: - -#### HAR Corpus (Automated) - -- For testing initial page loads and network requests -- HAR recordings live in `tests/corpus/har/`, complete recordings of the network requests of a single page load -- You can add or change URLs in `tests/corpus/_corpus-index.ts` -- **Recording new HAR files:** - - `npx playwright codegen https://github.com/login --save-storage=playwright/.auth/gh.json` will store new auth tokens - - login manually, then close the browser - - ***these cookies are very sensitive! we only run this script using a test account that has no permissions or memberships to anything, recommend you do the same!*** - - `pnpm run corpus:har:record` records new HAR files using those auth tokens (it needs args, run it with no args for docs) - - DO NOT COMMIT AND PUSH NEW OR CHANGED HAR files! - - we try to sanitize these (see `corpus-har-record.ts` for details) but there may be important PII in them - - if you need new HAR files for something, let us know and we will generate them ourselves using a dummy account - - IF YOUR PR CHANGES OR ADDS HAR FILES WE WILL CLOSE IT. Ask for HAR files and we'll be happy to generate clean ones you can test against. - -#### HTML Corpus (Manual) - -- For testing post-interaction states (e.g., expanded textareas, modal dialogs, dynamic content) -- HTML snapshots live in `tests/corpus/html/`, manually captured using SingleFile browser extension -- All assets are inlined in a single HTML file by SingleFile -- **Creating new HTML corpus files:** - 1. Navigate to the desired page state (click buttons, expand textareas, etc.) - 2. Use SingleFile browser extension to save the complete page - 3. Save the `.html` file to `tests/corpus/html/` with a descriptive name - 4. Add an entry to `tests/corpus/_corpus-index.ts` with `type: 'html'` and a description of the captured state - -#### Viewing Corpus Files - -- Run `pnpm run corpus:view` to start the test server at http://localhost:3001 -- Select any corpus file to view in two modes: - - **Clean**: Original page without extension - - **Gitcasso**: Page with extension injected for testing -- Both HAR and HTML corpus types are supported From c0c667c667f771594b677c7db44d10674c1702ae Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Thu, 18 Sep 2025 02:17:05 -0700 Subject: [PATCH 2/5] Migrate browser-extension to project root MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Move all browser-extension files to root directory with git history preserved - Merge package.json files and update scripts to include build:overtype - Update pnpm-workspace.yaml to remove browser-extension entry - Remove working-directory references from GitHub Actions workflow - Update documentation paths and agent descriptions - Simplify development workflow by eliminating subdirectory navigation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .claude/agents/corpus-fixer.md | 2 +- .github/workflows/browser-extension.yml | 5 +- README.md | 2 +- browser-extension/biome.json => biome.json | 0 browser-extension/package.json | 70 ---------------- package.json | 79 +++++++++++++++--- ...aywright.config.ts => playwright.config.ts | 0 pnpm-workspace.yaml | 1 - .../public => public}/icons/icon-128.png | Bin .../public => public}/icons/icon-16.png | Bin .../public => public}/icons/icon-48.png | Bin .../src => src}/components/Badge.tsx | 0 .../src => src}/components/MultiSegment.tsx | 0 .../src => src}/components/PopupRoot.tsx | 0 .../src => src}/components/design.tsx | 0 .../src => src}/components/misc.ts | 0 .../src => src}/entrypoints/background.ts | 0 .../src => src}/entrypoints/content.ts | 0 .../src => src}/entrypoints/popup/index.html | 0 .../src => src}/entrypoints/popup/popup.tsx | 0 .../src => src}/entrypoints/popup/style.css | 0 {browser-extension/src => src}/lib/config.ts | 0 .../src => src}/lib/enhancer.ts | 0 .../lib/enhancers/CommentEnhancerMissing.tsx | 0 .../src => src}/lib/enhancers/draftStats.ts | 0 .../lib/enhancers/github/ghOptions.ts | 0 .../enhancers/github/githubEditComment.tsx | 0 .../lib/enhancers/github/githubHighlighter.ts | 0 .../github/githubIssueAddComment.tsx | 0 .../github/githubIssueNewComment.tsx | 0 .../enhancers/github/githubPRAddComment.tsx | 0 .../enhancers/github/githubPRNewComment.tsx | 0 .../lib/enhancers/github/githubSpotTypes.ts | 0 .../src => src}/lib/enhancers/modifyDOM.ts | 0 {browser-extension/src => src}/lib/logger.ts | 0 .../src => src}/lib/messages.ts | 0 .../src => src}/lib/registries.ts | 0 .../tests => tests}/background.test.ts | 0 .../tests => tests}/corpus-fixture.ts | 0 .../tests => tests}/corpus-har-record.ts | 0 .../tests => tests}/corpus-utils.ts | 0 .../tests => tests}/corpus-view.ts | 0 .../tests => tests}/corpus/_corpus-index.ts | 0 .../tests => tests}/corpus/gh_issue.har | 0 .../tests => tests}/corpus/gh_issue_edit.html | 0 .../corpus/gh_issue_populated_comment.html | 0 .../tests => tests}/corpus/gh_new_issue.har | 0 .../tests => tests}/corpus/gh_new_pr.har | 0 .../tests => tests}/corpus/gh_pr.har | 0 .../tests => tests}/corpus/gh_pr_edit.html | 0 .../tests => tests}/corpus/gh_project.html | 0 .../corpus/gh_project_draft.html | 0 .../corpus/gh_project_draft_edit.html | 0 .../corpus/gh_project_issue.html | 0 .../corpus/gh_project_issue_edit.html | 0 .../lib/enhancers/draftStats.test.ts | 0 .../lib/enhancers/github.test.ts | 0 .../tests => tests}/playground/claude.tsx | 0 .../tests => tests}/playground/index.html | 0 .../playground/playground-styles.css | 0 .../tests => tests}/playground/playground.tsx | 0 .../tests => tests}/playground/replica.tsx | 0 .../playground/replicaData.tsx | 0 .../tsconfig.json => tsconfig.json | 0 ...und.config.ts => vite.playground.config.ts | 0 .../vitest.config.ts => vitest.config.ts | 0 .../wxt.config.ts => wxt.config.ts | 0 67 files changed, 72 insertions(+), 87 deletions(-) rename browser-extension/biome.json => biome.json (100%) delete mode 100644 browser-extension/package.json rename browser-extension/playwright.config.ts => playwright.config.ts (100%) rename {browser-extension/public => public}/icons/icon-128.png (100%) rename {browser-extension/public => public}/icons/icon-16.png (100%) rename {browser-extension/public => public}/icons/icon-48.png (100%) rename {browser-extension/src => src}/components/Badge.tsx (100%) rename {browser-extension/src => src}/components/MultiSegment.tsx (100%) rename {browser-extension/src => src}/components/PopupRoot.tsx (100%) rename {browser-extension/src => src}/components/design.tsx (100%) rename {browser-extension/src => src}/components/misc.ts (100%) rename {browser-extension/src => src}/entrypoints/background.ts (100%) rename {browser-extension/src => src}/entrypoints/content.ts (100%) rename {browser-extension/src => src}/entrypoints/popup/index.html (100%) rename {browser-extension/src => src}/entrypoints/popup/popup.tsx (100%) rename {browser-extension/src => src}/entrypoints/popup/style.css (100%) rename {browser-extension/src => src}/lib/config.ts (100%) rename {browser-extension/src => src}/lib/enhancer.ts (100%) rename {browser-extension/src => src}/lib/enhancers/CommentEnhancerMissing.tsx (100%) rename {browser-extension/src => src}/lib/enhancers/draftStats.ts (100%) rename {browser-extension/src => src}/lib/enhancers/github/ghOptions.ts (100%) rename {browser-extension/src => src}/lib/enhancers/github/githubEditComment.tsx (100%) rename {browser-extension/src => src}/lib/enhancers/github/githubHighlighter.ts (100%) rename {browser-extension/src => src}/lib/enhancers/github/githubIssueAddComment.tsx (100%) rename {browser-extension/src => src}/lib/enhancers/github/githubIssueNewComment.tsx (100%) rename {browser-extension/src => src}/lib/enhancers/github/githubPRAddComment.tsx (100%) rename {browser-extension/src => src}/lib/enhancers/github/githubPRNewComment.tsx (100%) rename {browser-extension/src => src}/lib/enhancers/github/githubSpotTypes.ts (100%) rename {browser-extension/src => src}/lib/enhancers/modifyDOM.ts (100%) rename {browser-extension/src => src}/lib/logger.ts (100%) rename {browser-extension/src => src}/lib/messages.ts (100%) rename {browser-extension/src => src}/lib/registries.ts (100%) rename {browser-extension/tests => tests}/background.test.ts (100%) rename {browser-extension/tests => tests}/corpus-fixture.ts (100%) rename {browser-extension/tests => tests}/corpus-har-record.ts (100%) rename {browser-extension/tests => tests}/corpus-utils.ts (100%) rename {browser-extension/tests => tests}/corpus-view.ts (100%) rename {browser-extension/tests => tests}/corpus/_corpus-index.ts (100%) rename {browser-extension/tests => tests}/corpus/gh_issue.har (100%) rename {browser-extension/tests => tests}/corpus/gh_issue_edit.html (100%) rename {browser-extension/tests => tests}/corpus/gh_issue_populated_comment.html (100%) rename {browser-extension/tests => tests}/corpus/gh_new_issue.har (100%) rename {browser-extension/tests => tests}/corpus/gh_new_pr.har (100%) rename {browser-extension/tests => tests}/corpus/gh_pr.har (100%) rename {browser-extension/tests => tests}/corpus/gh_pr_edit.html (100%) rename {browser-extension/tests => tests}/corpus/gh_project.html (100%) rename {browser-extension/tests => tests}/corpus/gh_project_draft.html (100%) rename {browser-extension/tests => tests}/corpus/gh_project_draft_edit.html (100%) rename {browser-extension/tests => tests}/corpus/gh_project_issue.html (100%) rename {browser-extension/tests => tests}/corpus/gh_project_issue_edit.html (100%) rename {browser-extension/tests => tests}/lib/enhancers/draftStats.test.ts (100%) rename {browser-extension/tests => tests}/lib/enhancers/github.test.ts (100%) rename {browser-extension/tests => tests}/playground/claude.tsx (100%) rename {browser-extension/tests => tests}/playground/index.html (100%) rename {browser-extension/tests => tests}/playground/playground-styles.css (100%) rename {browser-extension/tests => tests}/playground/playground.tsx (100%) rename {browser-extension/tests => tests}/playground/replica.tsx (100%) rename {browser-extension/tests => tests}/playground/replicaData.tsx (100%) rename browser-extension/tsconfig.json => tsconfig.json (100%) rename browser-extension/vite.playground.config.ts => vite.playground.config.ts (100%) rename browser-extension/vitest.config.ts => vitest.config.ts (100%) rename browser-extension/wxt.config.ts => wxt.config.ts (100%) diff --git a/.claude/agents/corpus-fixer.md b/.claude/agents/corpus-fixer.md index 44ede88..6125f20 100644 --- a/.claude/agents/corpus-fixer.md +++ b/.claude/agents/corpus-fixer.md @@ -4,7 +4,7 @@ description: Use this agent when you need to fix or improve the detection logic model: inherit --- -You are an expert Gitcasso corpus debugging specialist with deep knowledge of browser extension development. You operate exclusively within the `browser-extension` directory and specialize in using the corpus:view development environment to diagnose and fix detection logic issues. +You are an expert Gitcasso corpus debugging specialist with deep knowledge of browser extension development. You operate within the root project directory and specialize in using the corpus:view development environment to diagnose and fix detection logic issues. Your primary workflow: diff --git a/.github/workflows/browser-extension.yml b/.github/workflows/browser-extension.yml index 6b8d132..ee64b2f 100644 --- a/.github/workflows/browser-extension.yml +++ b/.github/workflows/browser-extension.yml @@ -22,8 +22,5 @@ jobs: cache: 'pnpm' - run: pnpm install --frozen-lockfile - run: pnpm run biome - working-directory: browser-extension - run: pnpm test - working-directory: browser-extension - - run: pnpm run typecheck - working-directory: browser-extension \ No newline at end of file + - run: pnpm run typecheck \ No newline at end of file diff --git a/README.md b/README.md index 3204ae5..fc10683 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Gitcasso +# Gitcasso *Syntax highlighting and autosave for comments on GitHub (and other other markdown-friendly websites).* diff --git a/browser-extension/biome.json b/biome.json similarity index 100% rename from browser-extension/biome.json rename to biome.json diff --git a/browser-extension/package.json b/browser-extension/package.json deleted file mode 100644 index 1ffb822..0000000 --- a/browser-extension/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "author": "DiffPlug", - "dependencies": { - "@primer/octicons-react": "^19.18.0", - "@types/react": "^19.1.12", - "@types/react-dom": "^19.1.9", - "@wxt-dev/webextension-polyfill": "^1.0.0", - "highlight.js": "^11.11.1", - "lucide-react": "^0.543.0", - "overtype": "workspace:*", - "react": "^19.1.1", - "react-dom": "^19.1.1", - "tailwind-merge": "^3.3.1", - "tailwind-variants": "^3.1.1", - "webextension-polyfill": "^0.12.0" - }, - "description": "Syntax highlighting and autosave for comments on GitHub (and other other markdown-friendly websites).", - "devDependencies": { - "@biomejs/biome": "^2.1.2", - "@playwright/test": "^1.46.0", - "@tailwindcss/vite": "^4.1.13", - "@testing-library/jest-dom": "^6.6.4", - "@types/express": "^4.17.21", - "@types/har-format": "^1.2.16", - "@types/node": "^22.16.5", - "@vitejs/plugin-react": "^5.0.2", - "@vitest/coverage-v8": "^3.2.4", - "@vitest/ui": "^3.2.4", - "express": "^4.19.2", - "linkedom": "^0.18.12", - "postcss": "^8.5.6", - "tailwindcss": "^4.1.13", - "tsx": "^4.19.1", - "typescript": "^5.8.3", - "vite": "^7.1.5", - "vitest": "^3.2.4", - "wxt": "^0.20.7" - }, - "keywords": [ - "browser-extension", - "chrome-extension", - "firefox-addon", - "github", - "gitlab", - "bitbucket", - "syntax highlighting" - ], - "license": "MIT", - "name": "gitcasso", - "scripts": { - "biome": "biome check .", - "biome:fix": "biome check --write .", - "biome:fix:unsafe": "biome check --write --unsafe .", - "build": "wxt build", - "build:dev": "wxt build --mode development", - "build:firefox": "wxt build -b firefox", - "precommit": "npm run biome:fix && npm run typecheck && npm run test", - "typecheck": "tsc --noEmit", - "dev": "wxt", - "dev:firefox": "wxt -b firefox", - "postinstall": "wxt prepare", - "test": "vitest run", - "playground": "vite --config vite.playground.config.ts", - "playground:build": "vite build --config vite.playground.config.ts", - "corpus:har:record": "tsx tests/corpus-har-record.ts", - "corpus:view": "tsx tests/corpus-view.ts" - }, - "type": "module", - "version": "0.0.1" -} diff --git a/package.json b/package.json index dc8404b..f83d4b4 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,71 @@ { - "name": "gitcasso-workspace", - "private": true, + "author": "DiffPlug", + "dependencies": { + "@primer/octicons-react": "^19.18.0", + "@types/react": "^19.1.12", + "@types/react-dom": "^19.1.9", + "@wxt-dev/webextension-polyfill": "^1.0.0", + "highlight.js": "^11.11.1", + "lucide-react": "^0.543.0", + "overtype": "workspace:*", + "react": "^19.1.1", + "react-dom": "^19.1.1", + "tailwind-merge": "^3.3.1", + "tailwind-variants": "^3.1.1", + "webextension-polyfill": "^0.12.0" + }, + "description": "Syntax highlighting and autosave for comments on GitHub (and other other markdown-friendly websites).", + "devDependencies": { + "@biomejs/biome": "^2.1.2", + "@playwright/test": "^1.46.0", + "@tailwindcss/vite": "^4.1.13", + "@testing-library/jest-dom": "^6.6.4", + "@types/express": "^4.17.21", + "@types/har-format": "^1.2.16", + "@types/node": "^22.16.5", + "@vitejs/plugin-react": "^5.0.2", + "@vitest/coverage-v8": "^3.2.4", + "@vitest/ui": "^3.2.4", + "express": "^4.19.2", + "linkedom": "^0.18.12", + "postcss": "^8.5.6", + "tailwindcss": "^4.1.13", + "tsx": "^4.19.1", + "typescript": "^5.8.3", + "vite": "^7.1.5", + "vitest": "^3.2.4", + "wxt": "^0.20.7" + }, + "keywords": [ + "browser-extension", + "chrome-extension", + "firefox-addon", + "github", + "gitlab", + "bitbucket", + "syntax highlighting" + ], + "license": "MIT", + "name": "gitcasso", "scripts": { - "build:overtype": "pnpm --filter=overtype run build", - "typecheck": "pnpm --filter=gitcasso run typecheck", - "build": "pnpm run build:overtype && pnpm --filter=gitcasso run build", - "build:dev": "pnpm run build:overtype && pnpm --filter=gitcasso run build:dev", - "har:view": "pnpm --filter=gitcasso run har:view", - "postinstall": "pnpm run build:overtype" - } -} \ No newline at end of file + "biome": "biome check .", + "biome:fix": "biome check --write .", + "biome:fix:unsafe": "biome check --write --unsafe .", + "build:overtype": "pnpm -r --filter=overtype run build", + "build": "pnpm run build:overtype && wxt build", + "build:dev": "pnpm run build:overtype && wxt build --mode development", + "build:firefox": "wxt build -b firefox", + "precommit": "npm run biome:fix && npm run typecheck && npm run test", + "typecheck": "tsc --noEmit", + "dev": "wxt", + "dev:firefox": "wxt -b firefox", + "postinstall": "pnpm run build:overtype && wxt prepare", + "test": "vitest run", + "playground": "vite --config vite.playground.config.ts", + "playground:build": "vite build --config vite.playground.config.ts", + "corpus:har:record": "tsx tests/corpus-har-record.ts", + "corpus:view": "tsx tests/corpus-view.ts" + }, + "type": "module", + "version": "0.0.1" +} diff --git a/browser-extension/playwright.config.ts b/playwright.config.ts similarity index 100% rename from browser-extension/playwright.config.ts rename to playwright.config.ts diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index d20149b..4340350 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,3 +1,2 @@ packages: - - 'browser-extension' - 'packages/*' \ No newline at end of file diff --git a/browser-extension/public/icons/icon-128.png b/public/icons/icon-128.png similarity index 100% rename from browser-extension/public/icons/icon-128.png rename to public/icons/icon-128.png diff --git a/browser-extension/public/icons/icon-16.png b/public/icons/icon-16.png similarity index 100% rename from browser-extension/public/icons/icon-16.png rename to public/icons/icon-16.png diff --git a/browser-extension/public/icons/icon-48.png b/public/icons/icon-48.png similarity index 100% rename from browser-extension/public/icons/icon-48.png rename to public/icons/icon-48.png diff --git a/browser-extension/src/components/Badge.tsx b/src/components/Badge.tsx similarity index 100% rename from browser-extension/src/components/Badge.tsx rename to src/components/Badge.tsx diff --git a/browser-extension/src/components/MultiSegment.tsx b/src/components/MultiSegment.tsx similarity index 100% rename from browser-extension/src/components/MultiSegment.tsx rename to src/components/MultiSegment.tsx diff --git a/browser-extension/src/components/PopupRoot.tsx b/src/components/PopupRoot.tsx similarity index 100% rename from browser-extension/src/components/PopupRoot.tsx rename to src/components/PopupRoot.tsx diff --git a/browser-extension/src/components/design.tsx b/src/components/design.tsx similarity index 100% rename from browser-extension/src/components/design.tsx rename to src/components/design.tsx diff --git a/browser-extension/src/components/misc.ts b/src/components/misc.ts similarity index 100% rename from browser-extension/src/components/misc.ts rename to src/components/misc.ts diff --git a/browser-extension/src/entrypoints/background.ts b/src/entrypoints/background.ts similarity index 100% rename from browser-extension/src/entrypoints/background.ts rename to src/entrypoints/background.ts diff --git a/browser-extension/src/entrypoints/content.ts b/src/entrypoints/content.ts similarity index 100% rename from browser-extension/src/entrypoints/content.ts rename to src/entrypoints/content.ts diff --git a/browser-extension/src/entrypoints/popup/index.html b/src/entrypoints/popup/index.html similarity index 100% rename from browser-extension/src/entrypoints/popup/index.html rename to src/entrypoints/popup/index.html diff --git a/browser-extension/src/entrypoints/popup/popup.tsx b/src/entrypoints/popup/popup.tsx similarity index 100% rename from browser-extension/src/entrypoints/popup/popup.tsx rename to src/entrypoints/popup/popup.tsx diff --git a/browser-extension/src/entrypoints/popup/style.css b/src/entrypoints/popup/style.css similarity index 100% rename from browser-extension/src/entrypoints/popup/style.css rename to src/entrypoints/popup/style.css diff --git a/browser-extension/src/lib/config.ts b/src/lib/config.ts similarity index 100% rename from browser-extension/src/lib/config.ts rename to src/lib/config.ts diff --git a/browser-extension/src/lib/enhancer.ts b/src/lib/enhancer.ts similarity index 100% rename from browser-extension/src/lib/enhancer.ts rename to src/lib/enhancer.ts diff --git a/browser-extension/src/lib/enhancers/CommentEnhancerMissing.tsx b/src/lib/enhancers/CommentEnhancerMissing.tsx similarity index 100% rename from browser-extension/src/lib/enhancers/CommentEnhancerMissing.tsx rename to src/lib/enhancers/CommentEnhancerMissing.tsx diff --git a/browser-extension/src/lib/enhancers/draftStats.ts b/src/lib/enhancers/draftStats.ts similarity index 100% rename from browser-extension/src/lib/enhancers/draftStats.ts rename to src/lib/enhancers/draftStats.ts diff --git a/browser-extension/src/lib/enhancers/github/ghOptions.ts b/src/lib/enhancers/github/ghOptions.ts similarity index 100% rename from browser-extension/src/lib/enhancers/github/ghOptions.ts rename to src/lib/enhancers/github/ghOptions.ts diff --git a/browser-extension/src/lib/enhancers/github/githubEditComment.tsx b/src/lib/enhancers/github/githubEditComment.tsx similarity index 100% rename from browser-extension/src/lib/enhancers/github/githubEditComment.tsx rename to src/lib/enhancers/github/githubEditComment.tsx diff --git a/browser-extension/src/lib/enhancers/github/githubHighlighter.ts b/src/lib/enhancers/github/githubHighlighter.ts similarity index 100% rename from browser-extension/src/lib/enhancers/github/githubHighlighter.ts rename to src/lib/enhancers/github/githubHighlighter.ts diff --git a/browser-extension/src/lib/enhancers/github/githubIssueAddComment.tsx b/src/lib/enhancers/github/githubIssueAddComment.tsx similarity index 100% rename from browser-extension/src/lib/enhancers/github/githubIssueAddComment.tsx rename to src/lib/enhancers/github/githubIssueAddComment.tsx diff --git a/browser-extension/src/lib/enhancers/github/githubIssueNewComment.tsx b/src/lib/enhancers/github/githubIssueNewComment.tsx similarity index 100% rename from browser-extension/src/lib/enhancers/github/githubIssueNewComment.tsx rename to src/lib/enhancers/github/githubIssueNewComment.tsx diff --git a/browser-extension/src/lib/enhancers/github/githubPRAddComment.tsx b/src/lib/enhancers/github/githubPRAddComment.tsx similarity index 100% rename from browser-extension/src/lib/enhancers/github/githubPRAddComment.tsx rename to src/lib/enhancers/github/githubPRAddComment.tsx diff --git a/browser-extension/src/lib/enhancers/github/githubPRNewComment.tsx b/src/lib/enhancers/github/githubPRNewComment.tsx similarity index 100% rename from browser-extension/src/lib/enhancers/github/githubPRNewComment.tsx rename to src/lib/enhancers/github/githubPRNewComment.tsx diff --git a/browser-extension/src/lib/enhancers/github/githubSpotTypes.ts b/src/lib/enhancers/github/githubSpotTypes.ts similarity index 100% rename from browser-extension/src/lib/enhancers/github/githubSpotTypes.ts rename to src/lib/enhancers/github/githubSpotTypes.ts diff --git a/browser-extension/src/lib/enhancers/modifyDOM.ts b/src/lib/enhancers/modifyDOM.ts similarity index 100% rename from browser-extension/src/lib/enhancers/modifyDOM.ts rename to src/lib/enhancers/modifyDOM.ts diff --git a/browser-extension/src/lib/logger.ts b/src/lib/logger.ts similarity index 100% rename from browser-extension/src/lib/logger.ts rename to src/lib/logger.ts diff --git a/browser-extension/src/lib/messages.ts b/src/lib/messages.ts similarity index 100% rename from browser-extension/src/lib/messages.ts rename to src/lib/messages.ts diff --git a/browser-extension/src/lib/registries.ts b/src/lib/registries.ts similarity index 100% rename from browser-extension/src/lib/registries.ts rename to src/lib/registries.ts diff --git a/browser-extension/tests/background.test.ts b/tests/background.test.ts similarity index 100% rename from browser-extension/tests/background.test.ts rename to tests/background.test.ts diff --git a/browser-extension/tests/corpus-fixture.ts b/tests/corpus-fixture.ts similarity index 100% rename from browser-extension/tests/corpus-fixture.ts rename to tests/corpus-fixture.ts diff --git a/browser-extension/tests/corpus-har-record.ts b/tests/corpus-har-record.ts similarity index 100% rename from browser-extension/tests/corpus-har-record.ts rename to tests/corpus-har-record.ts diff --git a/browser-extension/tests/corpus-utils.ts b/tests/corpus-utils.ts similarity index 100% rename from browser-extension/tests/corpus-utils.ts rename to tests/corpus-utils.ts diff --git a/browser-extension/tests/corpus-view.ts b/tests/corpus-view.ts similarity index 100% rename from browser-extension/tests/corpus-view.ts rename to tests/corpus-view.ts diff --git a/browser-extension/tests/corpus/_corpus-index.ts b/tests/corpus/_corpus-index.ts similarity index 100% rename from browser-extension/tests/corpus/_corpus-index.ts rename to tests/corpus/_corpus-index.ts diff --git a/browser-extension/tests/corpus/gh_issue.har b/tests/corpus/gh_issue.har similarity index 100% rename from browser-extension/tests/corpus/gh_issue.har rename to tests/corpus/gh_issue.har diff --git a/browser-extension/tests/corpus/gh_issue_edit.html b/tests/corpus/gh_issue_edit.html similarity index 100% rename from browser-extension/tests/corpus/gh_issue_edit.html rename to tests/corpus/gh_issue_edit.html diff --git a/browser-extension/tests/corpus/gh_issue_populated_comment.html b/tests/corpus/gh_issue_populated_comment.html similarity index 100% rename from browser-extension/tests/corpus/gh_issue_populated_comment.html rename to tests/corpus/gh_issue_populated_comment.html diff --git a/browser-extension/tests/corpus/gh_new_issue.har b/tests/corpus/gh_new_issue.har similarity index 100% rename from browser-extension/tests/corpus/gh_new_issue.har rename to tests/corpus/gh_new_issue.har diff --git a/browser-extension/tests/corpus/gh_new_pr.har b/tests/corpus/gh_new_pr.har similarity index 100% rename from browser-extension/tests/corpus/gh_new_pr.har rename to tests/corpus/gh_new_pr.har diff --git a/browser-extension/tests/corpus/gh_pr.har b/tests/corpus/gh_pr.har similarity index 100% rename from browser-extension/tests/corpus/gh_pr.har rename to tests/corpus/gh_pr.har diff --git a/browser-extension/tests/corpus/gh_pr_edit.html b/tests/corpus/gh_pr_edit.html similarity index 100% rename from browser-extension/tests/corpus/gh_pr_edit.html rename to tests/corpus/gh_pr_edit.html diff --git a/browser-extension/tests/corpus/gh_project.html b/tests/corpus/gh_project.html similarity index 100% rename from browser-extension/tests/corpus/gh_project.html rename to tests/corpus/gh_project.html diff --git a/browser-extension/tests/corpus/gh_project_draft.html b/tests/corpus/gh_project_draft.html similarity index 100% rename from browser-extension/tests/corpus/gh_project_draft.html rename to tests/corpus/gh_project_draft.html diff --git a/browser-extension/tests/corpus/gh_project_draft_edit.html b/tests/corpus/gh_project_draft_edit.html similarity index 100% rename from browser-extension/tests/corpus/gh_project_draft_edit.html rename to tests/corpus/gh_project_draft_edit.html diff --git a/browser-extension/tests/corpus/gh_project_issue.html b/tests/corpus/gh_project_issue.html similarity index 100% rename from browser-extension/tests/corpus/gh_project_issue.html rename to tests/corpus/gh_project_issue.html diff --git a/browser-extension/tests/corpus/gh_project_issue_edit.html b/tests/corpus/gh_project_issue_edit.html similarity index 100% rename from browser-extension/tests/corpus/gh_project_issue_edit.html rename to tests/corpus/gh_project_issue_edit.html diff --git a/browser-extension/tests/lib/enhancers/draftStats.test.ts b/tests/lib/enhancers/draftStats.test.ts similarity index 100% rename from browser-extension/tests/lib/enhancers/draftStats.test.ts rename to tests/lib/enhancers/draftStats.test.ts diff --git a/browser-extension/tests/lib/enhancers/github.test.ts b/tests/lib/enhancers/github.test.ts similarity index 100% rename from browser-extension/tests/lib/enhancers/github.test.ts rename to tests/lib/enhancers/github.test.ts diff --git a/browser-extension/tests/playground/claude.tsx b/tests/playground/claude.tsx similarity index 100% rename from browser-extension/tests/playground/claude.tsx rename to tests/playground/claude.tsx diff --git a/browser-extension/tests/playground/index.html b/tests/playground/index.html similarity index 100% rename from browser-extension/tests/playground/index.html rename to tests/playground/index.html diff --git a/browser-extension/tests/playground/playground-styles.css b/tests/playground/playground-styles.css similarity index 100% rename from browser-extension/tests/playground/playground-styles.css rename to tests/playground/playground-styles.css diff --git a/browser-extension/tests/playground/playground.tsx b/tests/playground/playground.tsx similarity index 100% rename from browser-extension/tests/playground/playground.tsx rename to tests/playground/playground.tsx diff --git a/browser-extension/tests/playground/replica.tsx b/tests/playground/replica.tsx similarity index 100% rename from browser-extension/tests/playground/replica.tsx rename to tests/playground/replica.tsx diff --git a/browser-extension/tests/playground/replicaData.tsx b/tests/playground/replicaData.tsx similarity index 100% rename from browser-extension/tests/playground/replicaData.tsx rename to tests/playground/replicaData.tsx diff --git a/browser-extension/tsconfig.json b/tsconfig.json similarity index 100% rename from browser-extension/tsconfig.json rename to tsconfig.json diff --git a/browser-extension/vite.playground.config.ts b/vite.playground.config.ts similarity index 100% rename from browser-extension/vite.playground.config.ts rename to vite.playground.config.ts diff --git a/browser-extension/vitest.config.ts b/vitest.config.ts similarity index 100% rename from browser-extension/vitest.config.ts rename to vitest.config.ts diff --git a/browser-extension/wxt.config.ts b/wxt.config.ts similarity index 100% rename from browser-extension/wxt.config.ts rename to wxt.config.ts From 298278db17d55ffb0fe7fa19031e32b16a5cf259 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Thu, 18 Sep 2025 02:18:51 -0700 Subject: [PATCH 3/5] reorder CI a bit --- .github/workflows/browser-extension.yml | 4 ++-- pnpm-lock.yaml | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/browser-extension.yml b/.github/workflows/browser-extension.yml index ee64b2f..35685d8 100644 --- a/.github/workflows/browser-extension.yml +++ b/.github/workflows/browser-extension.yml @@ -21,6 +21,6 @@ jobs: node-version-file: '.nvmrc' cache: 'pnpm' - run: pnpm install --frozen-lockfile - - run: pnpm run biome - run: pnpm test - - run: pnpm run typecheck \ No newline at end of file + - run: pnpm biome + - run: pnpm typecheck \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f05be97..96125a4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,9 +6,7 @@ settings: importers: - .: {} - - browser-extension: + .: dependencies: '@primer/octicons-react': specifier: ^19.18.0 @@ -30,7 +28,7 @@ importers: version: 0.543.0(react@19.1.1) overtype: specifier: workspace:* - version: link:../packages/overtype + version: link:packages/overtype react: specifier: ^19.1.1 version: 19.1.1 From 01de86a1baaf5041face6d912560c70b0b1dd858 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Thu, 18 Sep 2025 02:21:58 -0700 Subject: [PATCH 4/5] update vitest config. --- vitest.config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/vitest.config.ts b/vitest.config.ts index d545330..71ca1ff 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -6,6 +6,7 @@ export default defineConfig({ test: { environment: 'node', globals: true, + include: ['tests/**/*.test.{ts,tsx}'], pool: 'threads', }, }) From 8eaa0b622a657d6a1cfe755e6be7ddc1edfd1a92 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Thu, 18 Sep 2025 02:28:29 -0700 Subject: [PATCH 5/5] Fixup some nits in the CONTRIBUTING instructions. --- CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d807cfd..7541f49 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,7 +19,7 @@ This extension ***must never transmit any data outside the browser***. ### Hotreload development - `pnpm install` -- `pnpm run dev` +- `pnpm dev` - open [`chrome://extensions`](chrome://extensions) - toggle **Developer mode** (top-right) - click "Load unpacked" (far left) @@ -45,7 +45,7 @@ This is a [WXT](https://wxt.dev/)-based browser extension that - [`src/entrypoints/content.ts`](src/entrypoints/content.ts) - injected into every webpage - [`src/entrypoints/background.ts`](src/entrypoints/background.ts) - service worker that manages state and handles messages -- [`src/entrypoints/popup/popup.tsx`](src/entrypoints/popup/popup.tsx) - popup (html/css/tsx) with shadcn/ui table components +- [`src/entrypoints/popup/popup.tsx`](src/entrypoints/popup/popup.tsx) - popup (react html + TailwindCSS) ```mermaid graph TD @@ -94,7 +94,7 @@ We maintain a corpus of test pages in two formats for testing the browser extens - `npx playwright codegen https://github.com/login --save-storage=playwright/.auth/gh.json` will store new auth tokens - login manually, then close the browser - ***these cookies are very sensitive! we only run this script using a test account that has no permissions or memberships to anything, recommend you do the same!*** - - `pnpm run corpus:har:record` records new HAR files using those auth tokens (it needs args, run it with no args for docs) + - `pnpm corpus:har:record` records new HAR files using those auth tokens (it needs args, run it with no args for docs) - DO NOT COMMIT AND PUSH NEW OR CHANGED HAR files! - we try to sanitize these (see `corpus-har-record.ts` for details) but there may be important PII in them - if you need new HAR files for something, let us know and we will generate them ourselves using a dummy account