This guide is for developers who want to contribute to Harbor itself. If you're looking to build applications using Harbor, see Developer Guide instead.
- Getting Started
- Project Structure
- Development Workflow
- Testing
- Code Style
- How We Track Work
- Pull Request Process
Use the canonical Quickstart to install prerequisites, build the extension and the native bridge, load Firefox, configure and test a default model, and run the demos. Browser-specific instructions are linked from that guide.
Then continue below for source layout, watch mode and contribution checks.
harbor/
├── extension/ # Harbor Extension - Infrastructure (TypeScript + esbuild)
│ ├── src/
│ │ ├── background.ts # Native messaging, server management
│ │ ├── sidebar.ts # Main sidebar UI
│ │ ├── js-runtime/ # In-browser JS MCP runtime
│ │ ├── wasm/ # In-browser WASM MCP runtime
│ │ ├── llm/ # LLM provider abstraction
│ │ ├── mcp/ # MCP protocol & host
│ │ └── policy/ # Feature flags
│ ├── dist-firefox/ # Built output (Firefox, default)
│ └── dist-chrome/ # Built output (Chrome)
│
├── bridge-rs/ # Rust Native Messaging Bridge
│ ├── src/
│ │ ├── main.rs # Entry point
│ │ ├── native_messaging.rs # Stdin/stdout JSON framing
│ │ ├── rpc/ # RPC method handlers
│ │ ├── llm/ # LLM provider configuration
│ │ ├── js/ # QuickJS runtime for JS MCP servers
│ │ ├── oauth/ # OAuth flow handling
│ │ └── fs/ # Filesystem utilities
│ └── any-llm-rust/ # Multi-provider LLM library (submodule)
│
├── demo/ # Demo web pages
│ ├── web-agents/ # Web Agent API demos
│ └── web-agent-control/ # Browser interaction demos
│
├── mcp-servers/ # MCP server examples and templates
│ ├── builtin/ # Built-in servers (echo, time)
│ ├── examples/ # Example implementations
│ └── templates/ # Starter templates
│
├── docs/ # Documentation
│ ├── USER_GUIDE.md # End-user guide
│ ├── DEVELOPER_GUIDE.md # API reference for app developers
│ ├── LLMS.txt # AI agent reference
│ ├── JS_AI_PROVIDER_API.md
│ ├── MCP_HOST.md
│ └── TESTING_YOUR_APP.md # Testing apps that use the API
│
├── installer/ # Distributable packages
│ └── macos/ # macOS .pkg builder
│
├── ARCHITECTURE.md # System architecture
├── CONTRIBUTING.md # This file
└── README.md # Project overview
| Component | Path | Description |
|---|---|---|
| Web Agent API | extension/src/page-api/injected.ts |
LanguageModel/window.agent implementation |
| Permission System | extension/src/page-api/policy/ |
Origin permission grants |
| Native Messaging | bridge-rs/src/native_messaging.rs |
Stdin/stdout JSON framing |
| RPC Handlers | bridge-rs/src/rpc/ |
All bridge message types |
| LLM Config | bridge-rs/src/llm/ |
LLM provider configuration |
| QuickJS Runtime | bridge-rs/src/js/ |
Sandboxed JS MCP server execution |
| OAuth | bridge-rs/src/oauth/ |
OAuth flow handling |
| MCP Host | extension/src/mcp/ |
MCP server management |
After completing the Quickstart, build the extension and launch it in a fresh temporary Firefox profile:
npm install --prefix tests/e2e
npm run build
npm run dev:firefox
# Optional starting page:
npm run dev:firefox -- http://localhost:8000/web-agents/Start the demo server separately (cd demo && npm start). The launcher does not
build or watch files; restart it after rebuilding. Set FIREFOX to a Firefox
binary path if needed. The native bridge must already be built and registered.
Close the launched Firefox instance or press Ctrl+C to stop it. Your normal
Firefox profile is not used.
The browser test runner (cd tests/e2e && npm run test:browser) uses the same
launcher. --keep-open waits for you to close Firefox or press Ctrl+C after the
results arrive. Closing Firefox exits with the test result; Ctrl+C interrupts the run.
For active development:
# Terminal 1: Build bridge (rerun after changes)
cd bridge-rs
cargo build --release
# Terminal 2: Watch extension
cd extension
npm run devAfter each rebuild:
- Bridge: Changes take effect on next extension reload
- Extension: Go to
about:debuggingand click "Reload" on the Harbor extension
Extension (Browser Console):
Cmd+Shift+J (Mac) or Ctrl+Shift+J
Bridge (Logs): The bridge logs to a file. Check:
- macOS:
~/Library/Caches/harbor-bridge.log - Linux:
~/.cache/harbor-bridge.log
For development, you can run the bridge manually:
cd bridge-rs
echo '{"type":"hello","request_id":"1"}' | cargo runMCP Server Logs:
# View logs for a running server
# In the sidebar, click server name → "Logs"During development, Harbor stores data in ~/.harbor/:
| File | Purpose |
|---|---|
harbor.db |
Server configurations (SQLite) |
catalog.db |
Catalog cache (SQLite) |
installed_servers.json |
Installed servers |
secrets/credentials.json |
API keys |
sessions/*.json |
Chat sessions |
To reset all state:
rm -rf ~/.harbor| Package | Command | Coverage |
|---|---|---|
| Bridge | cd bridge-rs && cargo test |
RPC, LLM, JS runtime |
| Extension | cd extension && npm test |
Provider injection |
# Run Rust bridge tests
cd bridge-rs
cargo test
# Run extension tests
cd extension
npm testRun through key flows as needed: server installation and connection, permission prompts, tool invocation, rate limiting. See tests/README.md for E2E and manual test setup.
- Follow standard Rust conventions
- Use
cargo fmtfor formatting - Use
cargo clippyfor linting - Document public APIs with doc comments
- Use strict TypeScript (
strict: truein tsconfig) - Prefer
interfaceovertypefor object shapes - Use explicit return types on exported functions
- Document public APIs with JSDoc comments
The codebase contains console.log statements used for debugging during development. For production releases:
- Debug flags: Files with
const DEBUG = true/falseshould have DEBUG set tofalsebefore release - Console logging: Console statements are intentionally left in place for debugging. They appear in the browser's extension console and don't affect end users
- Bridge logging: The Rust bridge uses the
tracingcrate and logs to~/.cache/harbor-bridge.log
When adding new debugging output, prefer using the existing DEBUG flag pattern:
const DEBUG = false; // Set to true for development
if (DEBUG) console.log('Debug info:', data);| Type | Convention | Example |
|---|---|---|
| Rust files | snake_case.rs |
native_messaging.rs |
| TS files | kebab-case.ts |
tool-registry.ts |
| Rust structs | PascalCase |
LlmConfig |
| TS classes | PascalCase |
McpHost |
| Functions | snake_case (Rust) / camelCase (TS) |
list_tools() / listTools() |
Start the subject line with a short prefix, then say what changed. Most commits use a conventional commit type, optionally with a scope:
feat: add tool router for intelligent server selection
fix(extension): handle server crash during tool call
docs: update developer guide with new APIs
chore: upgrade dependencies
Naming the area you changed works too, especially for a series of commits in one area:
bridge: honor configured default model
permissions: sidebar Activity panel surfaces every policy decision
Use the body to explain why the change was needed and how you tested it.
The maintainers plan and track work in an internal tracker (Linear). Its tickets have IDs like HBR-123, and you'll see those IDs in PR descriptions and commits. You don't need access to that tracker to contribute, and nothing in this repo should depend on it.
- GitHub Issues are open. Bug reports and feature requests from anyone are welcome there.
- Ticket IDs go in the PR body, not the title. Put a line like
Fixes HBR-123in the description. This links the PR to the ticket without cluttering the title. Outside contributors can skip it. - Everything a reviewer needs lives in the PR. A ticket link supplements the description; it never replaces it. See Writing the Description.
A PR should make sense to someone who can't see any ticket, chat thread, or meeting notes. Write the description for that reader:
- The problem. What was broken or missing, and how it showed up. Include the error message or the steps that reproduce it.
- The change. What you changed and why you chose that approach. If the change touches several areas, group the explanation by file or component.
- The testing. What you actually ran and what happened, for example "
cargo testpasses" or "tried it in Firefox with llama3.2: 1 tool call instead of 5". Also say what you didn't test. - Also fixed. Any small flaw you fixed along the way, each with what was wrong and what changed. Skip this heading if there are none.
- What's left. Known limits and follow-ups that this PR doesn't fix.
If you mention another internal ticket, describe it in a few words, for example "(the Ollama provider drops tool_calls, HBR-10)", so the reference still means something to readers who can't open it.
- Base each PR on
mainand keep it to one change, so PRs can be reviewed and merged in any order. - If a PR has to build on another one, say so at the top of the description and target that PR's branch.
- Leave the code better than you found it. If you notice a small flaw while you work (a bug, a stale doc, dead code, a missing test), fix it in the same PR, list it under Also fixed, and give it its own
CHANGELOG.mdentry if users would notice it. Larger or riskier changes, such as new subsystems or changes to the permission model, get their own issue or PR.
AI-assisted contributions are welcome. AGENTS.md gives instructions to coding agents working in this repo.
The bar is the same as for any other PR. You're responsible for what you submit, so make sure you understand the change and have actually tested it. A Co-Authored-By trailer naming the tool is a welcome way to say a commit was AI-assisted.
-
Run tests:
cd bridge-rs && cargo test cd extension && npm test
-
Format and lint:
cd bridge-rs && cargo fmt && cargo clippy
-
Test manually:
- Load the extension in Firefox
- Verify your changes work as expected
- Check the Browser Console for errors
-
Update documentation if you're changing:
- APIs → Update
DEVELOPER_GUIDE.mdandLLMS.txt - Architecture → Update
ARCHITECTURE.md - User-facing features → Update
USER_GUIDE.md
- APIs → Update
## Description
<!-- What was wrong or missing, and what this PR changes. It should make sense without any linked ticket. -->
<!-- Maintainers: add "Fixes HBR-123" here if there's a ticket. -->
## Testing
<!-- What you ran and what happened. Also note what you didn't test. -->
## Checklist
- [ ] Tests pass (`cargo test`, `npm test`)
- [ ] Code formatted (`cargo fmt`)
- [ ] Extension loads without errors
- [ ] Documentation updated (if applicable)- Open a PR against
main - Wait for CI checks to pass
- Request review
- Address feedback
- Merge when approved
- Define the message type in
bridge-rs/src/rpc/mod.rs - Add handler function
- Add response handling in
extension/src/background.ts - Update documentation in
README.mdorDEVELOPER_GUIDE.md
- Add provider implementation in
bridge-rs/any-llm-rust/src/providers/ - Register in the provider registry
- Update detection logic in
bridge-rs/src/llm/
Before a release:
- All tests pass
- Manual QA completed (see tests/README.md)
- Version bumped
- CHANGELOG updated
- Documentation reviewed and up-to-date
- Extension signed (for production)
- Installer built and tested
- Architecture questions: Check
ARCHITECTURE.mdfirst - API questions: Check
DEVELOPER_GUIDE.md - Test questions: Check tests/README.md; for testing your own app that uses the API, see docs/TESTING_YOUR_APP.md
- File issues: For bugs or feature requests