Welcome to the OpenAnalyst development guide! This document will help you set up your development environment and understand how to work with the codebase. Whether you're fixing bugs, adding features, or just exploring the code, this guide will get you started.
Before you begin, make sure you have the following installed:
-
Git - For version control
-
Node.js (version [v20.19.2] recommended)
For Windows: Using the Official Installer Go to the Node.js Downloads page https://nodejs.org/en/download Download the Windows Installer for version 20.19.2 (LTS recommended) Run the installer and follow the setup instructions After installation, open Command Prompt and verify:
node -v npm -v
For Mac:Using the Official Installer Go to the Node.js Downloads page - https://nodejs.org/en/download Download the macOS Installer for version 20.19.2 (LTS recommended) Open the downloaded file and follow the installation instructions After installation, verify:
node -v npm -v
-
pnpm - Package manager (https://pnpm.io/)
npm install -g pnpm
-
Visual Studio Code - Our recommended IDE for development https://code.visualstudio.com/
-
Fork and Clone the Repository:
- Fork the Repository:
- Visit the OpenAnalyst GitHub repository
- Click the "Fork" button in the top-right corner to create your own copy.
- Clone Your Fork:
Replace
git clone https://github.com/[YOUR-USERNAME]/OpenAnalyst.git cd OpenAnalyst[YOUR-USERNAME]with your actual GitHub username.
- Fork the Repository:
-
Install dependencies:
pnpm install
This command will install dependencies for the main extension, webview UI, and e2e tests.
While not strictly necessary for running the extension, these extensions are recommended for development:
- ESLint - Integrates ESLint into VS Code.
- Prettier - Code formatter - Integrates Prettier into VS Code.
The project is organized into several key directories:
src/- Core extension codecore/- Core functionality and toolsservices/- Service implementationsassets/- Static assets like images and icons
webview/- Frontend UI codescripts/- Utility scripts
To run the extension in development mode:
- Press
F5(or select Run → Start Debugging) in VSCode - This will open a new VSCode window with OpenAnalyst loaded.
- Webview UI changes: Changes to the webview UI will appear immediately without restarting
- Core extension changes: Changes to the core extension code will automatically reload the extension host
In development mode (NODE_ENV="development"), changing the core code will trigger a workbench.action.reloadWindow command, so it is no longer necessary to manually start/stop the debugger and tasks.
Important: In production builds, when making changes to the core extension, you need to:
- Stop the debugging process
- Kill any npm tasks running in the background (see screenshot below)
- Start debugging again
To build a production-ready .vsix file:
pnpm buildThis will:
- Build the webview UI
- Compile TypeScript
- Bundle the extension
- Create a
.vsixfile in thebin/directory
To install your built extension:
code --install-extension "$(ls -1v bin/oa-code-*.vsix | tail -n1)"Replace [version] with the current version number.
OpenAnalyst uses several types of tests to ensure quality:
Run unit tests with:
pnpm testThis runs both extension and webview tests.
For more details on E2E tests, see apps/vscode-e2e.
Ensure your code meets our quality standards:
pnpm lint # Run ESLint
pnpm check-types # Run TypeScript type checkingThis project uses Husky to manage Git hooks, which automate certain checks before commits and pushes. The hooks are located in the .husky/ directory.
Before a commit is finalized, the .husky/pre-commit hook runs:
- Branch Check: Prevents committing directly to the
mainbranch. - Type Generation: Runs
pnpm --filter oa-code generate-types. - Type File Check: Ensures that any changes made to
src/exports/roo-code.d.tsby the type generation are staged. - Linting: Runs
lint-stagedto lint and format staged files.
Before changes are pushed to the remote repository, the .husky/pre-push hook runs:
- Branch Check: Prevents pushing directly to the
mainbranch. - Compilation: Runs
pnpm run check-typesto ensure typing is correct. - Changeset Check: Checks if a changeset file exists in
.changeset/and reminds you to create one usingnpm run changesetif necessary.
These hooks help maintain code quality and consistency. If you encounter issues with commits or pushes, check the output from these hooks for error messages.
- Extension not loading: Check the VSCode Developer Tools (Help > Toggle Developer Tools) for errors
- Webview not updating: Try reloading the window (Developer: Reload Window)
- Build errors: Make sure all dependencies are installed with
pnpm install
- Use
console.log()statements in your code for debugging - Check the Output panel in VSCode (View > Output) and select "OpenAnalyst" from the dropdown
- For webview issues, use the browser developer tools in the webview (right-click > "Inspect Element")
We welcome contributions to OpenAnalyst! Here's how you can help:
- Report an issue using GitHub Issues
- Find an issue and submit a Pull Request with your fix
- Write tests to improve Code Coverage
- Want to implement something new? Awesome! We'd be glad to support you on Discord!
Your contributions are welcome! For questions or ideas, please join our Discord server: https://discord.gg/Nr9UTZub
We look forward to your contributions and feedback!