Spaces:
Running
Running
CUGA Frontend Workspaces
Monorepo for the CUGA browser extension and frontend tooling, managed with pnpm workspaces.
π¦ Workspace Packages
extension: Browser extension (Chrome/Edge/Firefox) that serves as the entry point to CUGAruntime: DOM/content-script runtime used by the extension and librariesshared(@uiagent/shared): Shared TypeScript utilities and types consumed by other packagesagentic_chat: React-based frontend for the extension's side panelfrontend: Alternative frontend implementation
π§ Prerequisites
- Node.js 18+
- pnpm 8+ (Package manager - install with
npm install -g pnpm) - Chromium-based browser (Chrome or Edge). Firefox supported via dedicated scripts.
π Quick Start
1. Install Dependencies
From the workspace root (frontend-workspaces/):
pnpm install
This installs all workspace dependencies and runs post-install steps (e.g., wxt prepare in the extension).
2. Start the Backend Server
- Add
use_extension = trueto yoursettings.tomlfile underadvanced_features - Run the debug VS Code configuration or start the server through the main entrypoint
3. Run the Extension
Copy the environment file and start development:
cd extension
cp .env-example .env # Edit as needed
cd ..
pnpm --filter extension run dev
WXT will automatically open Chrome with the extension loaded.
π pnpm Commands Reference
Core Commands
| Task | Command |
|---|---|
| Install all dependencies | pnpm install |
| Build all workspaces | pnpm -r build |
| Clean all node_modules | pnpm -r clean |
Extension Commands
| Task | Command |
|---|---|
| Development (Chrome) | pnpm --filter extension run dev |
| Development (Firefox) | pnpm --filter extension run dev:firefox |
| Build for production | pnpm --filter extension run build |
| Build for Firefox | pnpm --filter extension run build:firefox |
| Release build (copy to releases/) | pnpm --filter extension run release |
| Release build for Firefox | pnpm --filter extension run release:firefox |
| Create distribution zip | pnpm --filter extension run zip |
| Run E2E tests | pnpm --filter extension run e2etest |
| Type checking | pnpm --filter extension run compile |
Frontend Commands
| Task | Command |
|---|---|
| Development server | pnpm --filter frontend run dev |
| Build for production | pnpm --filter frontend run build |
| Start production server | pnpm --filter frontend run start |
Agentic Chat Commands
| Task | Command |
|---|---|
| Development server | pnpm --filter agentic_chat run dev |
| Build for production | pnpm --filter agentic_chat run build |
| Run tests | pnpm --filter agentic_chat run test |
| Type checking | pnpm --filter agentic_chat run compile |
Shared Library Commands
| Task | Command |
|---|---|
| Build shared library | pnpm --filter @uiagent/shared run build |
| Watch mode | pnpm --filter @uiagent/shared run watch |
| Clean build | pnpm --filter @uiagent/shared run clean |
Runtime Commands
| Task | Command |
|---|---|
| Run tests | pnpm --filter runtime run test |
ποΈ Build Process
Extension Build
Prepare environment:
cd extension cp .env-example .env # Edit values as neededBuild the extension:
pnpm --filter extension run buildLoad in browser:
- Open Chrome/Edge β Manage Extensions
- Enable Developer mode
- Load Unpacked β select
extension/.output/chrome-mv3/
Release Build
Build and copy to releases folder for distribution:
# Chrome/Edge release
pnpm --filter extension run release
# Firefox release
pnpm --filter extension run release:firefox
This builds the extension, cleans the releases folder, and copies the fresh output to:
extension/releases/chrome-mv3/(Chrome/Edge)extension/releases/firefox-mv2/(Firefox)
Distribution Build
Create a distributable zip file:
pnpm --filter extension run zip
Output will be in extension/.output/
π Development Tips
Working with Multiple Packages
# Run command in specific workspace
pnpm --filter extension run [command]
# Run command in all workspaces
pnpm -r run [command]
# Run command in workspaces matching pattern
pnpm --filter "*chat*" run build
Dependency Management
# Add dependency to specific workspace
pnpm --filter extension add [package]
# Add dev dependency
pnpm --filter extension add -D [package]
# Add workspace dependency
pnpm --filter extension add agentic_chat@workspace:*
Debugging
# Watch mode for shared library
pnpm --filter @uiagent/shared run watch
# Development with hot reload
pnpm --filter extension run dev -- --watch --mode development
π Browser Support
Chrome/Edge
- Full support with Manifest V3
- Hot reload during development
- Production builds ready for store submission
Firefox
- Beta support with Manifest V2
- Requires manual
:haspseudo-selector enablement - Use
*:firefoxscript variants
π Troubleshooting
Common Issues
Extension not appearing after build:
- Check terminal output for build directory
- Verify you're loading the correct
.output/folder
Type errors in shared library:
pnpm --filter @uiagent/shared run build
# Then restart dev servers
Dependency resolution issues:
# Clean and reinstall
rm -rf node_modules pnpm-lock.yaml
find . -name "node_modules" -type d -exec rm -rf {} +
pnpm install
Build failures:
- Ensure all workspace dependencies use
workspace:*protocol - Check that shared library is built before extension
- Verify environment files are properly configured
Firefox Specific
- Enable
:haspseudo-selector:about:configβlayout.css.has-selector.enabledβtrue - Full support coming in Firefox 121+
π Project Structure
frontend-workspaces/
βββ pnpm-workspace.yaml # pnpm workspace configuration
βββ package.json # Root package.json
βββ extension/ # Browser extension
β βββ src/
β βββ wxt.config.ts # WXT configuration
β βββ .output/ # Build output
βββ agentic_chat/ # React frontend
β βββ src/
β βββ dist/
βββ frontend/ # Alternative frontend
βββ shared/ # Shared utilities
β βββ src/
β βββ dist/
βββ runtime/ # Runtime utilities
π Workflow Examples
Full Development Setup
# 1. Install everything
pnpm install
# 2. Build shared library first
pnpm --filter @uiagent/shared run build
# 3. Start extension development
pnpm --filter extension run dev
Production Build
# Build all packages
pnpm -r build
# Or build specific packages in order
pnpm --filter @uiagent/shared run build
pnpm --filter agentic_chat run build
pnpm --filter extension run build
Testing
# Run all tests
pnpm -r test
# Test specific package
pnpm --filter extension run e2etest