Development Setup
This guide covers setting up a development environment for contributing to Kuse Cowork.
Prerequisites
Required Tools
| Tool | Version | Purpose |
|---|---|---|
| Node.js | 18+ | Frontend runtime |
| pnpm | 8+ | Package manager |
| Rust | 1.70+ | Backend language |
| Docker | 20+ | Container runtime |
Platform-Specific Setup
bash
# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install dependencies
brew install node pnpm rust
# Install Tauri CLI
cargo install tauri-cli
# Install Docker Desktop
brew install --cask dockerbash
# Install system dependencies
sudo apt update
sudo apt install -y \
libwebkit2gtk-4.1-dev \
build-essential \
curl \
wget \
libssl-dev \
libgtk-3-dev \
libayatana-appindicator3-dev \
librsvg2-dev
# Install Node.js
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
# Install pnpm
npm install -g pnpm
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
# Install Tauri CLI
cargo install tauri-cli
# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USERpowershell
# 1. Install Node.js from https://nodejs.org/ (LTS version)
# 2. Install pnpm:
npm install -g pnpm
# 3. Install Rust from https://rustup.rs/
# 4. Install Visual Studio Build Tools with C++ workload
# 5. Install Docker Desktop from https://www.docker.com/products/docker-desktop
# 6. Install Tauri CLI:
cargo install tauri-cliClone and Setup
bash
# Clone the repository
git clone https://github.com/kuse-ai/kuse_cowork.git
cd kuse_cowork
# Install frontend dependencies
pnpm install
# Verify Rust setup
cd src-tauri
cargo check
cd ..Development Mode
Start Development Server
bash
# Start with hot reload
pnpm tauri devThis will:
- Start the Vite dev server (port 1420)
- Compile the Rust backend
- Launch the application with DevTools
Frontend Only
For faster iteration on UI changes:
bash
# Start Vite dev server only
pnpm devAccess at http://localhost:1420
Web Mode Limitations
Without Tauri, some features are unavailable:
- Tool execution
- Docker integration
- MCP connections
- Local file access
Backend Only
To work on Rust code:
bash
cd src-tauri
# Check compilation
cargo check
# Run tests
cargo test
# Format code
cargo fmt
# Lint
cargo clippyProject Structure
kuse_cowork/
├── src/ # Frontend source
│ ├── App.tsx
│ ├── components/
│ ├── stores/
│ └── lib/
├── src-tauri/ # Backend source
│ ├── Cargo.toml
│ ├── tauri.conf.json
│ └── src/
├── docs/ # Documentation
├── public/ # Static assets
├── package.json
├── pnpm-lock.yaml
├── tsconfig.json
└── vite.config.tsIDE Setup
VS Code (Recommended)
Install extensions:
- rust-analyzer: Rust language support
- Tauri: Tauri development tools
- SolidJS: SolidJS snippets and highlighting
- ESLint: JavaScript linting
- Prettier: Code formatting
Settings (.vscode/settings.json):
json
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer"
},
"rust-analyzer.checkOnSave.command": "clippy"
}JetBrains IDEs
- Install Rust plugin
- Install Tauri plugin
- Configure TypeScript for SolidJS JSX
Environment Variables
Create .env for development:
bash
# .env
VITE_DEV_MODE=true
RUST_LOG=debugTesting
Frontend Tests
bash
# Run tests
pnpm test
# Run with coverage
pnpm test -- --coverageBackend Tests
bash
cd src-tauri
# Run all tests
cargo test
# Run specific test
cargo test test_name
# Run with output
cargo test -- --nocaptureE2E Tests
bash
# Run E2E tests (requires built app)
pnpm tauri build
pnpm test:e2eDebugging
Frontend Debugging
- Open DevTools in the app (Cmd+Option+I / Ctrl+Shift+I)
- Use Console for logs
- Use Sources for breakpoints
- Use Network for API calls
Backend Debugging
Add logging:
rust
use log::{debug, info, error};
info!("Starting agent loop");
debug!("Tool use: {:?}", tool_use);
error!("Failed: {}", err);Run with debug logging:
bash
RUST_LOG=debug pnpm tauri devVS Code Debugging
Launch config (.vscode/launch.json):
json
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug Tauri",
"cargo": {
"args": ["build", "--manifest-path=./src-tauri/Cargo.toml"]
},
"preLaunchTask": "ui:dev"
}
]
}Code Style
TypeScript/JavaScript
- Use ESLint and Prettier
- Follow SolidJS conventions
- Prefer functional components
typescript
// Good
const Component: Component<Props> = (props) => {
const [state, setState] = createSignal(0);
return <div>{state()}</div>;
};
// Avoid
class Component extends SolidComponent { }Rust
- Use
cargo fmtfor formatting - Use
cargo clippyfor linting - Follow Rust API guidelines
rust
// Good
pub fn process_item(item: &Item) -> Result<Output, Error> {
// ...
}
// Avoid
pub fn ProcessItem(item: Item) -> Output { }Common Tasks
Add a New Tool
- Create
src-tauri/src/tools/my_tool.rs - Add to
src-tauri/src/tools/mod.rs - Register in tool executor
- Add to allowed tools list
Add a New Provider
- Add format to
ApiFormatenum - Implement in
LLMClient - Add to provider detection
- Update frontend settings
Add a Frontend Component
- Create
src/components/MyComponent.tsx - Create
src/components/MyComponent.css - Import and use in parent component
Troubleshooting
Cargo build fails
bash
# Clean and rebuild
cd src-tauri
cargo clean
cargo buildpnpm install fails
bash
# Clear cache and reinstall
rm -rf node_modules
pnpm store prune
pnpm installTauri dev crashes
- Check Rust compilation:
cd src-tauri && cargo check - Check Vite:
pnpm dev - Check logs for errors
Docker not working
- Ensure Docker Desktop is running
- Check Docker socket:
docker ps - On Linux:
sudo chmod 666 /var/run/docker.sock