Add comprehensive documentation and download feature (#83)

* fix: markdown files now default to rendered view and render properly

- Add .md and .mdx MIME type support in backend (files.ts, defaults.ts)
- Add key props to FilePreview components to force proper remounting when switching files
- Fix markdown file detection with case-insensitive extension check
- Reset markdownPreview state when file changes to ensure correct default view
- Add onContentLoaded callback to VirtualizedTextView for reactive content updates
- Add fullContent state to properly handle large markdown file rendering
- Add error handling for async content loading to prevent blank screens
- Reduce loading timeout from 50ms to 0ms for more responsive loading

Fixes issues where:
- Markdown files opened in raw view instead of rendered view
- Large markdown files (12k+ lines) showed blank after loading completed
- State persisted incorrectly when switching between different file types

* Add directory download feature with ZIP archive support

* Improve voice recording UX with loading states and better transcript handling

* Fix auth config for prod/dev ports and add documentation

Update AUTH_TRUSTED_ORIGINS and PASSKEY_ORIGIN to use backend port 5003 (frontend uses 5173 in dev). Add comprehensive auth documentation covering secrets, trusted origins, admin reset, and passkeys. Update README and add mkdocs config.

* Remove roadmap section from README
This commit is contained in:
Chris Scott authored and GitHub committed 2026-01-26 23:09:27 -05:00
1 parent 358abbf20e
commit da6cad8b3a
51 files changed
+4276 -353

No files matched your search

+190
View File
@@ -0,0 +1,190 @@
# Authentication
OpenCode Manager uses single-user authentication designed for personal deployments.
## Overview
The authentication system supports:
- Email/password login
- Passkey/WebAuthn authentication
- OAuth social login (optional)
- Session-based auth with secure cookies
## First-Run Setup
On first launch with no admin account:
1. You're redirected to the Setup page
2. Create your admin account
3. Optionally configure providers
4. Start using the application
## Pre-Configured Admin
Skip interactive setup for automated deployments:
```bash
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=your-secure-password
```
When set:
- Admin user is created automatically
- Setup wizard is skipped
- Registration is disabled
## Password Reset
If you forget your password:
1. Set environment variables:
```bash
ADMIN_EMAIL=your@email.com
ADMIN_PASSWORD=new-password
ADMIN_PASSWORD_RESET=true
```
2. Restart the application:
```bash
docker-compose restart
```
3. Log in with new password
4. Remove `ADMIN_PASSWORD_RESET=true` from environment
!!! warning
Remove the reset flag after successful reset to prevent accidental password changes.
## Session Security
### AUTH_SECRET
Required for production. Encrypts session data.
Generate:
```bash
openssl rand -base64 32
```
Configure:
```bash
AUTH_SECRET=your-generated-secret
```
### Session Duration
Sessions last until:
- User logs out
- Browser is closed (unless "Remember me")
- Session expires (configurable)
### Secure Cookies
By default, cookies require HTTPS in production:
```bash
# For HTTP on trusted networks only
AUTH_SECURE_COOKIES=false
```
## Remote Access
### Local Network (HTTP)
For accessing via IP on a local network:
```bash
# Include all access URLs (both frontend and backend)
AUTH_TRUSTED_ORIGINS=http://localhost:5173,http://localhost:5003,http://192.168.1.244:5003
# Disable secure cookies for HTTP
AUTH_SECURE_COOKIES=false
```
### Production (HTTPS)
For production with HTTPS:
```bash
AUTH_TRUSTED_ORIGINS=https://yourdomain.com
# AUTH_SECURE_COOKIES defaults to true
```
## Passkeys
Passwordless authentication using WebAuthn.
### Setup
Configure your domain:
```bash
# Local development (use backend port)
PASSKEY_RP_ID=localhost
PASSKEY_RP_NAME=OpenCode Manager
PASSKEY_ORIGIN=http://localhost:5003
# Production
PASSKEY_RP_ID=yourdomain.com
PASSKEY_RP_NAME=OpenCode Manager
PASSKEY_ORIGIN=https://yourdomain.com
# Local network access
PASSKEY_RP_ID=localhost
PASSKEY_RP_NAME=OpenCode Manager
PASSKEY_ORIGIN=http://192.168.1.244:5003
```
!!! note "Port Selection"
- Use the **backend** port (5003) for PASSKEY_ORIGIN
- Not the frontend port (5173)
- The origin must match where the auth API is served
### Adding a Passkey
1. Log in with password
2. Go to **Settings > Security**
3. Click **Add Passkey**
4. Follow browser/device prompts
5. Name your passkey
### Supported Authenticators
- Touch ID / Face ID (macOS, iOS)
- Windows Hello
- Hardware security keys (YubiKey, etc.)
- Android fingerprint/face
### Passkey Requirements
- RP ID must match the domain
- Origin must match exactly (including port)
- HTTPS recommended (required for some browsers)
## Troubleshooting
### Can't Log In
1. Clear browser cookies
2. Check credentials are correct
3. Verify AUTH_SECRET hasn't changed
4. Check AUTH_TRUSTED_ORIGINS includes your URL
### Session Keeps Expiring
1. Check AUTH_SECRET is persistent across restarts
2. Verify cookies aren't being blocked
3. Check AUTH_SECURE_COOKIES setting
### Passkey Not Working
1. Verify PASSKEY_RP_ID matches domain
2. Check PASSKEY_ORIGIN is exact
3. Try a different browser
4. Ensure WebAuthn is supported
+347
View File
@@ -0,0 +1,347 @@
# Docker Configuration
Advanced Docker setup and configuration options.
## Basic Setup
```bash
git clone https://github.com/chriswritescode-dev/opencode-manager.git
cd opencode-manager
docker-compose up -d
```
## docker-compose.yml
Default configuration:
```yaml
version: '3.8'
services:
opencode-manager:
build: .
container_name: opencode-manager
ports:
- "5003:5003" # OpenCode Manager
- "5100:5100" # Dev server 1
- "5101:5101" # Dev server 2
- "5102:5102" # Dev server 3
- "5103:5103" # Dev server 4
volumes:
- ./workspace:/workspace
- ./data:/app/data
- opencode-cache:/root/.opencode
environment:
- NODE_ENV=production
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5003/health"]
interval: 30s
timeout: 10s
retries: 3
volumes:
opencode-cache:
```
## Port Configuration
### Main Application
The application runs on port 5003 by default:
```yaml
ports:
- "5003:5003"
```
Change the host port if needed:
```yaml
ports:
- "8080:5003" # Access at localhost:8080
```
### Dev Server Ports
Ports 5100-5103 are exposed for running dev servers inside repositories:
```yaml
ports:
- "5100:5100"
- "5101:5101"
- "5102:5102"
- "5103:5103"
```
Configure your dev server to use one of these ports:
=== "Vite"
```typescript
// vite.config.ts
export default {
server: {
port: 5100,
host: '0.0.0.0'
}
}
```
=== "Next.js"
```bash
next dev -p 5100 -H 0.0.0.0
```
=== "Express"
```javascript
app.listen(5100, '0.0.0.0')
```
## Volume Mounts
### Workspace
Repository storage:
```yaml
volumes:
- ./workspace:/workspace
```
All cloned repositories are stored here. The directory is created automatically.
### Data
Database and configuration:
```yaml
volumes:
- ./data:/app/data
```
Contains:
- SQLite database
- User settings
- Session data
### OpenCode Cache
OpenCode runtime cache:
```yaml
volumes:
- opencode-cache:/root/.opencode
```
Using a named volume for better performance.
## Environment Variables
### Using .env File
Create `.env` in project root:
```bash
AUTH_SECRET=your-secret-here
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=secure-password
```
Reference in docker-compose.yml:
```yaml
env_file:
- .env
```
### Inline Environment
Set directly in docker-compose.yml:
```yaml
environment:
- NODE_ENV=production
- AUTH_SECRET=your-secret-here
- ADMIN_EMAIL=admin@example.com
```
## Health Checks
The container includes health checks:
```yaml
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5003/health"]
interval: 30s
timeout: 10s
retries: 3
```
Check health status:
```bash
docker inspect --format='{{.State.Health.Status}}' opencode-manager
```
## Resource Limits
Limit container resources:
```yaml
services:
opencode-manager:
# ... other config
deploy:
resources:
limits:
cpus: '2'
memory: 4G
reservations:
cpus: '0.5'
memory: 1G
```
## Networking
### Custom Network
Create an isolated network:
```yaml
services:
opencode-manager:
networks:
- opencode-net
networks:
opencode-net:
driver: bridge
```
### Host Network
Use host networking (Linux only):
```yaml
services:
opencode-manager:
network_mode: host
```
## Commands
### Basic Operations
```bash
# Start
docker-compose up -d
# Stop
docker-compose down
# Restart
docker-compose restart
# View logs
docker-compose logs -f
# View logs (last 100 lines)
docker-compose logs --tail 100
```
### Maintenance
```bash
# Rebuild image
docker-compose build
# Rebuild without cache
docker-compose build --no-cache
# Pull latest base images
docker-compose pull
# Update and restart
docker-compose pull && docker-compose up -d --build
```
### Debugging
```bash
# Access shell
docker exec -it opencode-manager sh
# View running processes
docker exec opencode-manager ps aux
# Check disk usage
docker exec opencode-manager df -h
# View environment
docker exec opencode-manager env
```
## Global Agent Instructions
The container creates a default `AGENTS.md` file at `/workspace/.config/opencode/AGENTS.md`.
### Default Content
Instructions for AI agents working in the container:
- Reserved ports information
- Available dev server ports
- Docker-specific guidelines
### Editing
**Via UI:** Settings > OpenCode > Global Agent Instructions
**Via File:**
```bash
docker exec -it opencode-manager vi /workspace/.config/opencode/AGENTS.md
```
### Precedence
Global instructions merge with repository-specific `AGENTS.md` files. Repository instructions take precedence.
## Troubleshooting
### Container Won't Start
```bash
# Check logs
docker-compose logs
# Check if port is in use
lsof -i :5003
# Try running in foreground
docker-compose up
```
### Permission Issues
```bash
# Fix workspace permissions
sudo chown -R $(id -u):$(id -g) ./workspace ./data
# Or run with specific user
docker-compose run --user $(id -u):$(id -g) opencode-manager
```
### Out of Disk Space
```bash
# Check Docker disk usage
docker system df
# Clean up unused resources
docker system prune -a
# Remove unused volumes
docker volume prune
```
+111
View File
@@ -0,0 +1,111 @@
# Environment Variables
Complete reference for all configuration options.
## Authentication
| Variable | Description | Default |
|----------|-------------|---------|
| `AUTH_SECRET` | Session encryption secret (required for production) | Auto-generated in dev |
| `ADMIN_EMAIL` | Pre-configured admin email | - |
| `ADMIN_PASSWORD` | Pre-configured admin password | - |
| `ADMIN_PASSWORD_RESET` | Set to `true` to reset admin password | `false` |
| `AUTH_TRUSTED_ORIGINS` | Comma-separated list of trusted origins (frontend + backend) | `http://localhost:5173,http://localhost:5003` |
| `AUTH_SECURE_COOKIES` | Use secure cookies (HTTPS only) | `true` in prod |
| `AUTH_SECURE_COOKIES` | Use secure cookies (HTTPS only) | `true` in prod |
## OAuth Providers
| Variable | Description |
|----------|-------------|
| `GITHUB_CLIENT_ID` | GitHub OAuth client ID |
| `GITHUB_CLIENT_SECRET` | GitHub OAuth client secret |
| `GOOGLE_CLIENT_ID` | Google OAuth client ID |
| `GOOGLE_CLIENT_SECRET` | Google OAuth client secret |
| `DISCORD_CLIENT_ID` | Discord OAuth client ID |
| `DISCORD_CLIENT_SECRET` | Discord OAuth client secret |
## Passkeys (WebAuthn)
| Variable | Description | Default |
|----------|-------------|---------|
| `PASSKEY_RP_ID` | Relying party ID (your domain) | `localhost` |
| `PASSKEY_RP_NAME` | Display name for passkey prompts | `OpenCode Manager` |
| `PASSKEY_ORIGIN` | Origin URL for WebAuthn (backend port) | `http://localhost:5003` |
!!! tip "IMPORTANT"
- `PASSKEY_ORIGIN` must use the **backend** port (5003), not the frontend port (5173)
- The origin must exactly match where the auth API is served
## Server
| Variable | Description | Default |
|----------|-------------|---------|
| `PORT` | Server port | `5003` |
| `NODE_ENV` | Environment (`development` or `production`) | `development` |
| `WORKSPACE_PATH` | Path to workspace directory | `/workspace` |
## Example .env File
```bash
# Required for production
AUTH_SECRET=generate-with-openssl-rand-base64-32
# Pre-configured admin (optional)
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=your-secure-password
# Remote access (optional - include both frontend and backend ports)
AUTH_TRUSTED_ORIGINS=http://localhost:5173,http://localhost:5003,http://192.168.1.244:5003
AUTH_SECURE_COOKIES=false
# OAuth providers (optional)
GITHUB_CLIENT_ID=your-client-id
GITHUB_CLIENT_SECRET=your-client-secret
# Passkeys (optional - use BACKEND port)
PASSKEY_RP_ID=localhost
PASSKEY_RP_NAME=OpenCode Manager
PASSKEY_ORIGIN=http://localhost:5003
```
## Generating Secrets
### AUTH_SECRET
Generate a secure random secret:
```bash
openssl rand -base64 32
```
Output example:
```
K7gNU3sdo+OL0wNhqoVWhr3g6s1xYv72ol/pe/Unols=
```
!!! warning "Security"
- Never commit AUTH_SECRET to version control
- Use different secrets for development and production
- Rotate secrets periodically
## Environment Precedence
Variables are loaded in this order (later overrides earlier):
1. System environment variables
2. `.env` file in project root
3. Docker Compose `environment` section
4. Docker Compose `env_file` reference
## Validating Configuration
Check your configuration:
```bash
# View current environment (inside container)
docker exec opencode-manager env | grep -E '^(AUTH|ADMIN|PASSKEY)'
# Check if secrets are set (without revealing values)
docker exec opencode-manager sh -c 'if [ -n "$AUTH_SECRET" ]; then echo "AUTH_SECRET: set"; else echo "AUTH_SECRET: NOT SET"; fi'
```
+172
View File
@@ -0,0 +1,172 @@
# OAuth Providers
Configure social login with OAuth providers.
## Supported Providers
| Provider | Purpose |
|----------|---------|
| GitHub | Social login |
| Google | Social login |
| Discord | Social login |
## GitHub OAuth
### Create OAuth App
1. Go to [GitHub Developer Settings](https://github.com/settings/developers)
2. Click **OAuth Apps** > **New OAuth App**
3. Fill in:
- **Application name**: `OpenCode Manager`
- **Homepage URL**: `http://localhost:5003`
- **Authorization callback URL**: `http://localhost:5003/api/auth/callback/github`
4. Click **Register application**
5. Copy **Client ID**
6. Generate and copy **Client Secret**
### Configure
```bash
GITHUB_CLIENT_ID=your-client-id
GITHUB_CLIENT_SECRET=your-client-secret
```
### Callback URL
Adjust the callback URL for your environment:
| Environment | Callback URL |
|-------------|--------------|
| Local | `http://localhost:5003/api/auth/callback/github` |
| Production | `https://yourdomain.com/api/auth/callback/github` |
## Google OAuth
### Create OAuth Client
1. Go to [Google Cloud Console](https://console.cloud.google.com/)
2. Create a new project or select existing
3. Go to **APIs & Services** > **Credentials**
4. Click **Create Credentials** > **OAuth client ID**
5. Select **Web application**
6. Configure:
- **Name**: `OpenCode Manager`
- **Authorized redirect URIs**: `http://localhost:5003/api/auth/callback/google`
7. Click **Create**
8. Copy **Client ID** and **Client Secret**
### Configure
```bash
GOOGLE_CLIENT_ID=your-client-id
GOOGLE_CLIENT_SECRET=your-client-secret
```
### Consent Screen
You may need to configure the OAuth consent screen:
1. Go to **APIs & Services** > **OAuth consent screen**
2. Select **External** (or Internal for Workspace)
3. Fill in required fields
4. Add scopes: `email`, `profile`
5. Save
## Discord OAuth
### Create Application
1. Go to [Discord Developer Portal](https://discord.com/developers/applications)
2. Click **New Application**
3. Name it `OpenCode Manager`
4. Go to **OAuth2** section
5. Add redirect: `http://localhost:5003/api/auth/callback/discord`
6. Copy **Client ID** and **Client Secret**
### Configure
```bash
DISCORD_CLIENT_ID=your-client-id
DISCORD_CLIENT_SECRET=your-client-secret
```
## Using OAuth Login
Once configured:
1. Go to the login page
2. Click the provider button (GitHub, Google, Discord)
3. Authorize in the popup
4. You're logged in
### First OAuth Login
On first OAuth login:
- Account is created automatically
- Email from provider is used
- No password is set (OAuth-only)
### Linking Accounts
If you have an existing password account:
1. Log in with password
2. Go to **Settings > Connected Accounts**
3. Click **Connect** for a provider
4. Authorize the connection
## Production Considerations
### Update Callback URLs
Before deploying, update OAuth apps with production URLs:
```
https://yourdomain.com/api/auth/callback/github
https://yourdomain.com/api/auth/callback/google
https://yourdomain.com/api/auth/callback/discord
```
### Verify Domains
Some providers require domain verification:
- Google requires verification for production
- Discord may require verification for many users
### Secrets Management
- Never commit OAuth secrets to version control
- Use environment variables or secrets management
- Rotate secrets periodically
## Troubleshooting
### Redirect URI Mismatch
Error: "redirect_uri_mismatch" or similar
**Solution:**
1. Check callback URL in provider settings
2. Ensure exact match (including trailing slash)
3. Verify protocol (http vs https)
4. Check port number
### Invalid Client
Error: "invalid_client" or "unauthorized_client"
**Solution:**
1. Verify Client ID is correct
2. Check Client Secret hasn't changed
3. Ensure OAuth app is not suspended
### Access Denied
Error: "access_denied" or user cancels
**Solution:**
1. User may have denied permission
2. Check required scopes are configured
3. Verify consent screen is configured properly
+214
View File
@@ -0,0 +1,214 @@
# Contributing
Guide for contributing to OpenCode Manager.
## Getting Started
1. Fork the repository
2. Clone your fork
3. Set up local development (see [Local Setup](setup.md))
4. Create a feature branch
5. Make changes
6. Submit a pull request
## Code Style
### General Guidelines
- **No comments** - Code should be self-documenting
- **No console.log** - Use proper logging
- **Strict TypeScript** - Proper typing everywhere
- **Named imports** - No default imports
- **DRY principles** - Don't repeat yourself
- **SOLID design** - Follow SOLID principles
### Backend (Bun + Hono)
```typescript
// Route handler
app.get('/api/repos', async (c) => {
const repos = await repoService.listAll()
return c.json(repos)
})
// Service
export const repoService = {
async listAll(): Promise<Repository[]> {
return db.query.repositories.findMany()
}
}
```
Guidelines:
- Use Zod for validation
- Async/await (no .then() chains)
- Structured error handling
- Follow existing patterns
### Frontend (React + Vite)
```typescript
import { useState } from 'react'
import { Button } from '@/components/ui/button'
import { useRepositories } from '@/hooks/useRepositories'
export function RepoList() {
const { data: repos } = useRepositories()
return (
<div>
{repos?.map(repo => (
<RepoCard key={repo.id} repo={repo} />
))}
</div>
)
}
```
Guidelines:
- Use `@/` alias for imports
- React Query for server state
- React Hook Form + Zod for forms
- Radix UI + Tailwind for components
## Pull Request Process
### Before Submitting
1. **Run linting**: `pnpm lint`
2. **Run tests**: `pnpm test`
3. **Check types**: `pnpm typecheck`
4. **Test manually**: Verify your changes work
### PR Guidelines
- Keep PRs focused on a single feature/fix
- Write clear commit messages
- Include tests for new functionality
- Update documentation if needed
- Reference related issues
### Commit Messages
Format: `type: brief description`
Types:
- `feat` - New feature
- `fix` - Bug fix
- `docs` - Documentation
- `refactor` - Code refactoring
- `test` - Adding tests
- `chore` - Maintenance
Examples:
```
feat: add file upload progress indicator
fix: resolve session expiry on mobile
docs: update installation guide
refactor: extract git service from routes
```
## Testing
### Writing Tests
```typescript
import { expect, test, describe, beforeEach } from 'bun:test'
describe('featureName', () => {
beforeEach(() => {
// Setup
})
test('should do something', async () => {
const result = await doSomething()
expect(result).toBe(expected)
})
})
```
### Coverage Requirements
- Minimum 80% coverage
- Cover edge cases
- Test error conditions
### Running Tests
```bash
# All tests
pnpm test
# With coverage
cd backend && bun test --coverage
# Single file
cd backend && bun test path/to/test.ts
```
## Architecture Decisions
### Why Bun?
- Fast startup and execution
- Built-in TypeScript support
- SQLite driver included
- Modern JavaScript runtime
### Why Hono?
- Lightweight and fast
- TypeScript-first
- Works with Bun natively
- Simple, Express-like API
### Why React Query?
- Automatic caching and refetching
- Server state management
- Optimistic updates
- SSE support for streaming
### Why Radix UI?
- Accessible by default
- Unstyled (pairs with Tailwind)
- Headless components
- Production-ready
## Adding Features
### New API Endpoint
1. Create route in `backend/src/routes/`
2. Add service logic in `backend/src/services/`
3. Define types in `shared/`
4. Add tests
5. Update API client in frontend
### New UI Component
1. Create component in `frontend/src/components/`
2. Use Radix UI primitives if applicable
3. Style with Tailwind
4. Add to relevant page
5. Test responsiveness
### New Feature Flag
1. Add to settings schema
2. Create migration if needed
3. Add UI toggle in settings
4. Check flag in relevant code
## Getting Help
- **Questions**: Open a GitHub Discussion
- **Bugs**: Open a GitHub Issue
- **Features**: Open a GitHub Issue with `feature` label
## License
By contributing, you agree that your contributions will be licensed under the MIT License.
+232
View File
@@ -0,0 +1,232 @@
# Local Development Setup
Guide for setting up a local development environment.
## Prerequisites
- [pnpm](https://pnpm.io/installation) - Package manager (required for workspaces)
- [Bun](https://bun.sh) - Backend runtime
- [OpenCode TUI](https://opencode.ai) - `npm install -g @opencode/tui`
- Node.js 18+
## Installation
```bash
# Clone the repository
git clone https://github.com/chriswritescode-dev/opencode-manager.git
cd opencode-manager
# Install dependencies
pnpm install
# Copy environment configuration
cp .env.example .env
# Start development servers
pnpm dev
```
This starts:
- **Backend** on http://localhost:5003
- **Frontend** on http://localhost:5173 (with HMR)
## Project Structure
```
opencode-manager/
├── backend/ # Bun + Hono API server
│ ├── src/
│ │ ├── routes/ # API route handlers
│ │ ├── services/ # Business logic
│ │ ├── db/ # Database schema and queries
│ │ └── index.ts # Entry point
│ └── tests/ # Backend tests
├── frontend/ # React + Vite SPA
│ ├── src/
│ │ ├── components/ # UI components
│ │ ├── pages/ # Page components
│ │ ├── hooks/ # Custom React hooks
│ │ ├── api/ # API client
│ │ └── lib/ # Utilities
│ └── public/ # Static assets
├── shared/ # Shared types and utilities
└── docker/ # Docker configuration
```
## Available Scripts
### Root Level
```bash
pnpm dev # Start both backend and frontend
pnpm build # Build both packages
pnpm lint # Lint both packages
pnpm test # Run all tests
```
### Backend
```bash
cd backend
bun run dev # Start with hot reload
bun test # Run tests
bun test <file> # Run single test file
bun run lint # ESLint
bun run typecheck # TypeScript check
```
### Frontend
```bash
cd frontend
pnpm dev # Start Vite dev server
pnpm build # Production build
pnpm lint # ESLint
pnpm typecheck # TypeScript check
```
## Database
Using Better SQLite3 with Drizzle ORM.
### Location
- **Development**: `./backend/data/opencode.db`
- **Docker**: `/app/data/opencode.db`
### Schema Changes
1. Edit schema in `backend/src/db/schema.ts`
2. Generate migration: `cd backend && bun run db:generate`
3. Apply migration: `cd backend && bun run db:migrate`
### Inspection
```bash
sqlite3 ./backend/data/opencode.db
# Useful commands
.tables # List tables
.schema users # Show table schema
SELECT * FROM users; # View data
```
## Testing
### Running Tests
```bash
# All tests
cd backend && bun test
# Single file
cd backend && bun test src/services/repo.test.ts
# With coverage
cd backend && bun test --coverage
```
### Writing Tests
```typescript
import { expect, test, describe } from 'bun:test'
import { repoService } from '../src/services/repo'
describe('repoService', () => {
test('listAll returns repositories', async () => {
const repos = await repoService.listAll()
expect(Array.isArray(repos)).toBe(true)
})
})
```
### Coverage Requirements
Minimum 80% coverage is enforced.
## Debugging
### Backend
Logs output to terminal when running `pnpm dev`.
For more detailed debugging:
```bash
cd backend
DEBUG=* bun run dev
```
### Frontend
1. Open browser DevTools (F12)
2. Check Console for errors
3. Check Network tab for API calls
4. Use React DevTools extension
### VS Code
Launch configurations are provided in `.vscode/launch.json`:
- **Debug Backend** - Attach debugger to backend
- **Debug Frontend** - Launch Chrome with debugging
## Building
### Development Build
```bash
pnpm build
```
### Production Build
```bash
NODE_ENV=production pnpm build
```
### Docker Build
```bash
docker build -t opencode-manager .
```
## Common Issues
### Port Already in Use
```bash
# Find process using port
lsof -i :5003
# Kill process
kill -9 <PID>
```
### Module Not Found
```bash
# Clear node_modules and reinstall
rm -rf node_modules
rm -rf */node_modules
pnpm install
```
### TypeScript Errors
```bash
# Check types
pnpm typecheck
# Clear TypeScript cache
rm -rf */tsconfig.tsbuildinfo
```
### Database Issues
```bash
# Reset database
rm -f backend/data/opencode.db
pnpm dev # Database is recreated
```
+147
View File
@@ -0,0 +1,147 @@
# AI Configuration
Configure AI models, providers, and custom agents.
## Model Selection
Browse and select from available AI models:
1. Go to **Settings > Models**
2. Browse models by provider
3. Filter by capability (chat, code, vision)
4. Click a model to set as default
### Model Capabilities
| Capability | Description |
|------------|-------------|
| Chat | General conversation |
| Code | Code generation and analysis |
| Vision | Image understanding |
| Function Calling | Tool use support |
### Changing Models Mid-Session
You can switch models during a chat session:
1. Click the model name in the chat header
2. Select a different model
3. Continue chatting with the new model
Context is preserved when switching models.
## Provider Credentials
Configure API keys or OAuth for AI providers.
### API Key Method
1. Go to **Settings > Provider Credentials**
2. Select a provider (OpenAI, Anthropic, etc.)
3. Enter your API key
4. Click **Save**
### OAuth Method
For providers that support OAuth (Anthropic, GitHub Copilot):
1. Go to **Settings > Provider Credentials**
2. Select a provider with the OAuth badge
3. Click **Add OAuth**
4. Choose authorization method:
- **Open Authorization Page** - Opens browser for sign-in
- **Use Authorization Code** - Provides code for manual entry
5. Complete the authorization flow
### Testing Credentials
After adding credentials:
1. Go to **Settings > Models**
2. Models from that provider should appear
3. Select a model and try sending a message
If models don't appear, verify your API key and check for errors.
## Custom Agents
Create specialized AI agents with custom configurations.
### Creating an Agent
1. Go to **Settings > Agents**
2. Click **Create Agent**
3. Configure:
- **Name** - Display name for the agent
- **Description** - What this agent does
- **System Prompt** - Instructions for the AI
- **Default Model** - Model to use
- **Allowed Tools** - Which MCP tools it can access
4. Click **Save**
### System Prompt Tips
Write effective system prompts:
```
You are a code review expert specializing in TypeScript and React.
When reviewing code:
1. Check for type safety issues
2. Look for potential bugs
3. Suggest performance improvements
4. Ensure consistent code style
Be concise but thorough. Prioritize issues by severity.
```
### Tool Permissions
Control which MCP tools an agent can use:
- **All Tools** - Access to everything
- **Selected Tools** - Only specific tools
- **No Tools** - Pure conversation, no tool access
This is useful for:
- Security-focused agents that shouldn't modify files
- Research agents that only need read access
- Specialized agents for specific tasks
### Using Custom Agents
1. Start a new session
2. Click the agent selector
3. Choose your custom agent
4. Chat with the specialized agent
## Context Usage
Monitor token usage with the context indicator:
- Progress bar shows current usage
- Updates as conversation grows
- Warning when approaching limits
### Managing Context
When context is running low:
1. Use `/compact` to summarize history
2. Start a new session with `/new`
3. Be more concise in prompts
4. Remove unnecessary file mentions
### Context Limits by Model
Different models have different context limits:
| Model | Context Limit |
|-------|---------------|
| GPT-4 | 8K - 128K tokens |
| Claude 3 | 200K tokens |
| GPT-3.5 | 4K - 16K tokens |
Check your model's documentation for exact limits.
+199
View File
@@ -0,0 +1,199 @@
# Chat & Sessions
Real-time chat interface for interacting with AI agents.
## Starting a Session
1. Select a repository from the sidebar
2. Click **New Session** or type `/new`
3. Type your message in the input field
4. Press **Enter** to send
Each session maintains its own conversation history and context.
## Real-time Streaming
Messages stream in real-time using Server-Sent Events (SSE):
- See responses as they're generated
- No waiting for complete responses
- Can interrupt generation if needed
## Slash Commands
Type `/` to see available commands:
### Built-in Commands
| Command | Description |
|---------|-------------|
| `/help` | Show available commands |
| `/new` | Start a new session |
| `/models` | List available AI models |
| `/export` | Export session history |
| `/compact` | Compact session context |
| `/clear` | Clear current session |
### Custom Commands
Create your own commands in **Settings > Custom Commands**:
```yaml
name: review
description: Request a code review
template: |
Please review the following code for:
- Security vulnerabilities
- Performance issues
- Best practices
- Code style
{{selection}}
```
Use with `/review` in chat.
#### Template Variables
| Variable | Description |
|----------|-------------|
| `{{selection}}` | Currently selected text |
| `{{file}}` | Current file path |
| `{{clipboard}}` | Clipboard contents |
## File Mentions
Reference files in your prompts with `@`:
1. Type `@` in the chat input
2. Start typing a filename
3. Select from the autocomplete dropdown
4. The file reference is inserted
When you send the message, the AI has access to that file's contents.
### Multiple Files
You can mention multiple files in one message:
```
@src/components/Button.tsx @src/styles/button.css
Can you refactor the Button component to use CSS modules?
```
### Folder Mentions
Mention entire folders to include all files:
```
@src/utils/
Review all utility functions for consistency
```
## Plan/Build Mode
Toggle between two operational modes:
### Plan Mode (Read-Only)
- AI can read and analyze files
- AI cannot modify, create, or delete files
- Safe for exploration and planning
### Build Mode (Full Access)
- AI can create new files
- AI can edit existing files
- AI can delete files
- Use for implementation tasks
Toggle modes using the mode selector in the chat header.
## Mermaid Diagrams
AI responses can include Mermaid diagrams that render automatically:
```mermaid
graph TD
A[User Request] --> B[AI Processing]
B --> C{Valid?}
C -->|Yes| D[Execute]
C -->|No| E[Error Response]
D --> F[Return Result]
```
Supported diagram types:
- Flowcharts
- Sequence diagrams
- Class diagrams
- State diagrams
- Entity-relationship diagrams
- Gantt charts
- And more...
## Session Management
### Viewing Sessions
Access your sessions from the sidebar:
- Sessions are organized by repository
- Most recent sessions appear first
- Click a session to resume
### Searching Sessions
Find sessions by content:
1. Click the search icon in the sessions panel
2. Type your search query
3. Results show sessions with matching content
### Deleting Sessions
Remove sessions you no longer need:
1. Hover over a session
2. Click the delete icon
3. Confirm deletion
### Bulk Delete
Remove multiple sessions at once:
1. Click **Select** in the sessions panel
2. Check sessions to delete
3. Click **Delete Selected**
4. Confirm deletion
## Context Management
Sessions maintain context of your conversation. As context grows, you may need to manage it:
### Compacting Context
Use `/compact` to reduce context size:
- Summarizes earlier messages
- Preserves important information
- Frees up context for new messages
### Starting Fresh
Use `/new` to start a new session when:
- Context is too large
- Topic has changed significantly
- You want a clean slate
## Keyboard Shortcuts
| Shortcut | Action |
|----------|--------|
| `Enter` | Send message |
| `Shift+Enter` | New line in message |
| `↑` | Edit last message |
| `/` | Open command menu |
| `@` | Open file mention menu |
| `Escape` | Close autocomplete menus |
+153
View File
@@ -0,0 +1,153 @@
# File Browser
Navigate, view, and manage files within your repositories.
## Directory Navigation
### Tree View
The file browser displays your repository as an expandable tree:
- Click folders to expand/collapse
- Click files to preview content
- Icons indicate file types
- Modified files are highlighted
### Breadcrumbs
Navigate quickly using the breadcrumb path at the top:
- Click any segment to jump to that directory
- Shows current location in the file tree
### Search
Filter files by name:
1. Click the search icon or press `/`
2. Type to filter visible files
3. Results update as you type
4. Press `Escape` to clear search
## File Preview
Click any file to preview with:
- **Syntax Highlighting** - Support for 100+ languages
- **Line Numbers** - Easy reference for code discussions
- **Large File Support** - Virtualization for files with many lines
### Supported Languages
Syntax highlighting is provided for common languages including:
- JavaScript, TypeScript, JSX, TSX
- Python, Ruby, Go, Rust
- HTML, CSS, SCSS, Sass
- JSON, YAML, TOML, XML
- Markdown, SQL, Shell scripts
- And many more...
## File Operations
### Create File
1. Right-click in the file browser
2. Select **New File**
3. Enter filename with extension
4. File is created and opened for editing
### Create Folder
1. Right-click in the file browser
2. Select **New Folder**
3. Enter folder name
4. Folder is created in current directory
### Rename
1. Right-click a file or folder
2. Select **Rename**
3. Enter new name
4. Press Enter to confirm
### Delete
1. Right-click a file or folder
2. Select **Delete**
3. Confirm deletion
!!! warning
Deletion is permanent and cannot be undone through the UI. Use git to recover deleted files if needed.
## File Upload
### Drag and Drop
Upload files by dragging them into the browser:
1. Open the target folder
2. Drag files from your computer
3. Drop into the file browser area
4. Files are uploaded to current directory
### Multiple Files
You can drag multiple files at once. They'll all be uploaded to the current directory.
### Upload Limitations
- Large files may take time to upload
- Binary files are supported
- File permissions are set by the server
## ZIP Download
Download directories or repositories as ZIP archives directly from the file browser:
### Download Options
Click the download icon in the file browser header to access download options:
**Current Directory**
- Downloads the folder you're currently viewing
- Includes all subfolders and files
- Useful for archiving specific parts of a project
**Entire Repository**
- Downloads the complete repository
- Same as the download button on repository cards
- Perfect for full repository backups
### Download Process
Both download options follow the same process:
1. Click the download icon in the file browser header
2. Choose **Current Directory** or **Entire Repository**
3. Review the confirmation dialog showing what will be downloaded
4. Click **Download** to begin
5. Wait while the ZIP archive is created (progress indicator shown)
6. ZIP automatically downloads to your computer
### Archive Features
The ZIP archives:
- Respects `.gitignore` - ignored files are excluded
- Excludes `.git` directory
- Uses compression to reduce file size
- Includes proper file permissions
- Preserves directory structure
!!! note
Download confirmation ensures you're downloading the correct content. Large repositories may take time to create the archive.
## Large File Handling
For files with many lines, the viewer uses virtualization:
- Only visible lines are rendered
- Smooth scrolling through large files
- Memory-efficient display
+133
View File
@@ -0,0 +1,133 @@
# Repository & Git
Comprehensive git integration for managing repositories and source control.
## Cloning Repositories
Clone any git repository:
1. Click the **Repositories** button in the sidebar
2. Click **Clone Repository**
3. Paste the repository URL
4. Click **Clone**
### Private Repositories
For private repositories, configure a GitHub Personal Access Token:
1. Go to **Settings > Credentials**
2. Enter your GitHub PAT
3. Ensure the token has `repo` scope
## Git Worktrees
Work on multiple branches simultaneously without switching:
1. Select a repository
2. Click **Create Worktree**
3. Enter branch name
4. A new workspace is created with that branch checked out
Worktrees share the same git history but have independent working directories. This is useful for:
- Comparing implementations across branches
- Working on a feature while keeping main branch accessible
- Testing changes without disrupting your main work
## Source Control Panel
Access comprehensive git operations via the source control button.
### Changes Tab
- View all modified, added, deleted, and untracked files
- Stage/unstage individual files or all changes
- Discard changes to revert modifications
- View diffs inline for any changed file
![Changes Tab](../images/git/git-changes.png)
### Commits Tab
- Browse commit history
- View commit details including message, author, and date
- See file changes in each commit
- Track ahead/behind status with remote
![Commits Tab](../images/git/git-commits.png)
### Branches Tab
- List all local and remote branches
- Create new branches from current HEAD
- Switch branches (checks out the branch)
- Delete local branches
![Branches Tab](../images/git/git-branch.png)
## Diff Viewer
View file changes with a unified diff format:
- **Line Numbers** - Both old and new line numbers displayed
- **Syntax Highlighting** - Code is highlighted based on file type
- **Change Markers** - Additions in green, deletions in red
- **Change Counts** - Summary of lines added/removed
### Accessing Diffs
- Click any changed file in the Source Control panel
- Diffs appear inline or in a modal depending on context
- Use the expand/collapse toggle for large diffs
![Diff Viewer](../images/git/git-diffview.png)
## Pull Requests
Create and push PRs directly from the UI:
1. Make your changes and commit them
2. Open **Source Control > Branches**
3. Click **Create PR**
4. Fill in:
- Title
- Description
- Target branch (usually `main`)
5. Click **Create**
The PR is created on GitHub and you'll receive a link to view it.
## Repository Actions
### Pull
Fetch and merge remote changes:
1. Select a repository
2. Click the **Pull** button
3. Changes are fetched and merged
### Fetch
Download remote changes without merging:
1. Select a repository
2. Click the **Fetch** button
3. Remote tracking branches are updated
### Delete Repository
Remove a repository from the workspace:
1. Select a repository
2. Click **Delete**
3. Confirm deletion
## Ahead/Behind Tracking
The UI shows your branch's relationship to its remote:
- **↑ N** - You have N commits not pushed to remote
- **↓ N** - Remote has N commits you haven't pulled
- **↑ N ↓ M** - Both local and remote have diverged
+216
View File
@@ -0,0 +1,216 @@
# MCP Servers
Configure Model Context Protocol (MCP) servers to extend AI capabilities.
## What is MCP?
MCP (Model Context Protocol) allows AI models to interact with external tools and data sources. Servers provide:
- **Tools** - Functions the AI can call
- **Resources** - Data the AI can access
- **Prompts** - Pre-defined prompt templates
## Adding Servers
### Local Servers (Command-based)
Local servers run as processes on your machine:
1. Go to **Settings > MCP Servers**
2. Click **Add Server**
3. Select **Local**
4. Configure:
```json
{
"name": "filesystem",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/workspace"]
}
```
| Field | Description |
|-------|-------------|
| `name` | Unique identifier |
| `command` | Executable to run |
| `args` | Command arguments |
| `env` | Environment variables (optional) |
### Remote Servers (HTTP)
Remote servers are accessed over HTTP/SSE:
1. Go to **Settings > MCP Servers**
2. Click **Add Server**
3. Select **Remote**
4. Configure:
```json
{
"name": "remote-tools",
"url": "https://mcp.example.com/sse"
}
```
| Field | Description |
|-------|-------------|
| `name` | Unique identifier |
| `url` | Server SSE endpoint |
| `headers` | HTTP headers (optional) |
## Server Templates
Pre-built configurations for common MCP servers:
### Filesystem
Access local files and directories:
```json
{
"name": "filesystem",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"]
}
```
### GitHub
Interact with GitHub repositories:
```json
{
"name": "github",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "your-token-here"
}
}
```
### PostgreSQL
Query PostgreSQL databases:
```json
{
"name": "postgres",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"DATABASE_URL": "postgres://user:pass@host:5432/db"
}
}
```
### Brave Search
Web search capabilities:
```json
{
"name": "brave-search",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-brave-search"],
"env": {
"BRAVE_API_KEY": "your-api-key"
}
}
```
## Managing Servers
### Enable/Disable
Toggle servers on/off:
1. Go to **Settings > MCP Servers**
2. Find the server
3. Click the toggle switch
Disabled servers won't be started or connected.
### Edit Configuration
Modify server settings:
1. Click the **Edit** button on a server
2. Update configuration
3. Click **Save**
4. Server will restart with new settings
### Delete Server
Remove a server:
1. Click the **Delete** button
2. Confirm deletion
### Restart Server
Force restart a server:
1. Click the **Restart** button
2. Server process is stopped and restarted
Useful after configuration changes or if a server becomes unresponsive.
## Server Status
Monitor server health:
| Status | Description |
|--------|-------------|
| Running | Server is active and connected |
| Starting | Server is launching |
| Stopped | Server is disabled |
| Error | Server failed to start |
Click on a server to see detailed status and logs.
## Tool Permissions
Control which tools AI can access:
### Global Settings
In **Settings > MCP Servers**:
- **Allow All Tools** - AI can use any tool
- **Require Confirmation** - Ask before using tools
- **Deny by Default** - Block tools unless allowed
### Per-Agent Settings
Configure tool access for custom agents:
1. Go to **Settings > Agents**
2. Edit an agent
3. Set **Allowed Tools**
4. Save changes
## Troubleshooting
### Server Won't Start
1. Check the command is installed: `npx -y @modelcontextprotocol/server-<name>`
2. Verify environment variables are set
3. Check server logs for errors
4. Try running the command manually
### Tools Not Appearing
1. Verify server status is "Running"
2. Check server provides the expected tools
3. Restart the server
4. Check AI model supports tool use
### Connection Issues
For remote servers:
1. Verify URL is correct
2. Check network connectivity
3. Verify authentication headers
4. Check server is running and accessible
+132
View File
@@ -0,0 +1,132 @@
# Mobile & PWA
OpenCode Manager is designed mobile-first and works as a Progressive Web App.
## Mobile-First Design
The UI is optimized for mobile devices:
- Touch-friendly controls
- Responsive layouts
- Adaptive components
- Gesture support
## Installing as PWA
### iOS
1. Open OpenCode Manager in **Safari**
2. Tap the **Share** button (square with arrow)
3. Scroll down and tap **Add to Home Screen**
4. Name the app and tap **Add**
!!! note
PWA installation only works in Safari on iOS. Chrome and other browsers don't support PWA on iOS.
### Android
1. Open OpenCode Manager in **Chrome**
2. Tap the **menu** (three dots)
3. Tap **Install app** or **Add to Home Screen**
4. Confirm installation
### Desktop
#### Chrome
1. Look for the install icon in the address bar
2. Click **Install**
3. App opens in its own window
#### Edge
1. Click the menu (three dots)
2. Select **Apps > Install this site as an app**
3. Name and install
## PWA Features
### Offline Support
Limited offline functionality:
- View cached sessions
- Browse cached files
- Queue messages for later
Full functionality requires network connection.
### Background Updates
The PWA updates automatically:
- New versions download in background
- Prompt to refresh when ready
- No manual update needed
### Native-Like Experience
- Runs in its own window
- No browser chrome
- App icon on home screen
- Task switcher integration
## Mobile Keyboard
### iOS Keyboard Handling
Special handling for iOS virtual keyboard:
- Input field stays above keyboard
- Viewport adjusts automatically
- No content hidden behind keyboard
### Enter Key Behavior
On mobile, pressing Enter:
1. Closes the virtual keyboard
2. Sends the message
Use **Shift+Enter** for new lines.
### Keyboard Shortcuts
Mobile keyboards have limited shortcut support. Use the toolbar buttons instead:
- Mention files with the **@** button
- Access commands with the **/** button
- Toggle modes with the mode selector
## Swipe Navigation
Navigate with gestures:
### Swipe Right
Swipe from the left edge to go back:
- Opens the sidebar
- Returns to previous view
- Works throughout the app
### Swipe Requirements
- Start from the left edge (first 20px)
- Swipe at least 50px right
- Swipe quickly (within 300ms)
## Touch Optimizations
### Larger Touch Targets
All interactive elements have minimum 44x44px touch targets for easy tapping.
### Long Press
Long press for context menus:
- Files: Rename, delete, copy path
- Messages: Copy, delete, regenerate
- Sessions: Rename, delete
+70
View File
@@ -0,0 +1,70 @@
# Features Overview
OpenCode Manager provides a comprehensive web interface for managing OpenCode AI agents.
## Core Features
### Repository & Git
- **Multi-Repository Support** - Clone and manage multiple git repos with private repo support via GitHub PAT
- **Git Worktrees** - Work on multiple branches simultaneously
- **Source Control Panel** - View changes, commits, and branches in a unified interface
- **Diff Viewer** - Unified diffs with line numbers and change counts
- **Push PRs** - Create and push pull requests directly from the UI
[Learn more →](git.md)
### File Management
- **Directory Browser** - Navigate files with tree view and search
- **Syntax Highlighting** - Code preview with highlighting for 100+ languages
- **File Operations** - Create, rename, delete, and drag-and-drop upload
- **ZIP Download** - Download repos as ZIP (respects .gitignore)
[Learn more →](files.md)
### Chat & Sessions
- **Real-time Streaming** - Live message streaming with SSE
- **Slash Commands** - Built-in (`/help`, `/new`, `/compact`) and custom commands
- **File Mentions** - Reference files with `@filename` autocomplete
- **Plan/Build Modes** - Toggle between read-only and file-change modes
- **Mermaid Diagrams** - Visual diagram rendering in chat
[Learn more →](chat.md)
### AI Configuration
- **Model Selection** - Browse and filter available AI models
- **Provider Management** - Configure API keys or OAuth for providers
- **OAuth Support** - Secure OAuth login for Anthropic and GitHub Copilot
- **Custom Agents** - Create agents with custom system prompts and tool permissions
[Learn more →](ai-config.md)
### MCP Servers
- **Local Servers** - Add command-based MCP servers
- **Remote Servers** - Connect to HTTP-based MCP servers
- **Templates** - Pre-built configurations for common servers
- **Management** - Enable, disable, and configure servers
[Learn more →](mcp.md)
### Text-to-Speech
- **Browser TTS** - Built-in Web Speech API support
- **External TTS** - Connect to OpenAI-compatible endpoints
- **Audio Caching** - 24-hour cache with 200MB limit
- **Voice Controls** - Configurable voice and speed settings
[Learn more →](tts.md)
### Mobile & PWA
- **Mobile-First Design** - Responsive UI optimized for mobile
- **PWA Installable** - Add to home screen on any device
- **iOS Optimized** - Proper keyboard handling and swipe navigation
[Learn more →](mobile.md)
+145
View File
@@ -0,0 +1,145 @@
# Text-to-Speech
Listen to AI responses with built-in or external TTS.
## Overview
OpenCode Manager supports two TTS providers:
1. **Built-in Browser** - Uses your browser's Web Speech API
2. **External API** - OpenAI-compatible TTS endpoints
## Built-in Browser TTS
Uses your browser's built-in speech synthesis via Web Speech API.
### Advantages
- No API key required
- Works offline
- No server communication needed
- Free to use
### Limitations
- Voice quality varies by browser/OS
- Limited voice selection
- No audio caching
- Requires browser support
### Browser Support
Works in modern browsers:
- Chrome, Edge, Safari, Firefox
### Setup
1. Go to **Settings > TTS**
2. Enable **TTS**
3. Select **Built-in Browser** provider
4. Choose a voice from available browser voices
5. Adjust speed if desired
6. Click **Test** to verify
### Voice Selection
Available voices depend on your operating system:
- **Chrome** - Google voices and system voices
- **Safari** - macOS voices (Alex, Samantha, etc.)
- **Firefox** - System voices
- **Edge** - Microsoft voices
### Web Speech API Detection
The system automatically detects if your browser supports Web Speech API. If not supported, you'll see a warning and should switch to External API.
## External API TTS
Connect to OpenAI-compatible TTS endpoints for higher quality voices.
### Advantages
- Higher quality voices
- Consistent across devices
- Audio caching on server
- More voice options
- Composite voice support
### Limitations
- Requires API key and endpoint
- Requires network connection
- Server-side processing
### Setup
1. Go to **Settings > TTS**
2. Enable **TTS**
3. Select **External API** provider
4. Enter the **TTS Server URL**:
- OpenAI: `https://api.openai.com`
- Kokoro: `https://your-kokoro-server.com:port`
5. Enter your **API Key**
6. Wait for voice/model discovery
7. Choose voice and model
8. Click **Test** to verify
### Compatible Services
Any OpenAI-compatible TTS API works:
- OpenAI TTS
- Kokoro TTS
- Azure OpenAI
- Local TTS servers
- Self-hosted alternatives
## Voice Configuration
### Voice Discovery
The system automatically discovers available voices and models:
1. On first connection with API key, voices/models are fetched
2. Voice list is cached for 1 hour
3. Click **Refresh** button to force re-discovery if voices change
### Composite Voices
Kokoro-style composite voices are supported. Combine multiple voices for unique effects:
- Example: `am_adam+am_echo`
- Example: `af_bella+af_nova`
## Audio Playback
### Playing Responses
To listen to an AI response:
1. Click the **Play** button on a message
2. Audio streams and plays
### Playback Controls
While audio is playing:
- **Stop** - End playback immediately
- Audio stops if you navigate away
## Markdown Sanitization
Before sending text to TTS, markdown is cleaned for better speech:
- Code blocks removed entirely
- Inline code: `code` → code
- Links: [text](url) → text
- Images: ![alt](url) → alt
- Bold/italic/strikethrough markers removed
- Headers: ### Header → Header
- List markers removed
- Tables converted to readable text
- HTML tags removed
- Whitespace cleaned up
This ensures natural, readable speech playback.
+104
View File
@@ -0,0 +1,104 @@
# First Run Setup
On your first visit to OpenCode Manager, you'll complete a guided setup process.
## Interactive Setup
When no admin account exists, you'll be automatically redirected to the setup page.
### Step 1: Create Admin Account
Fill in your account details:
- **Name** - Your display name
- **Email** - Used for login
- **Password** - Minimum 8 characters recommended
Click **Create Account** to continue.
### Step 2: Configure Provider (Optional)
After account creation, configure an AI provider:
1. Navigate to **Settings > Provider Credentials**
2. Select a provider
3. Enter API key or connect via OAuth
4. Save configuration
You can skip this and configure providers later.
## Pre-Configured Admin
For automated or headless deployments, skip interactive setup by setting environment variables:
```bash
# In docker-compose.yml or .env
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=your-secure-password
```
When these are set:
- Admin user is created automatically on first startup
- Setup wizard is skipped
- Users must log in with configured credentials
## Adding Passkeys
After initial setup, you can add passkey authentication for passwordless login:
1. Go to **Settings > Security**
2. Click **Add Passkey**
3. Follow your browser/device prompts
4. Name your passkey (e.g., "MacBook Touch ID")
Passkeys provide:
- Passwordless login
- Phishing-resistant authentication
- Biometric support (Touch ID, Face ID, Windows Hello)
## Password Reset
If you forget your password:
1. Set environment variables:
```bash
ADMIN_EMAIL=your@email.com
ADMIN_PASSWORD=new-password
ADMIN_PASSWORD_RESET=true
```
2. Restart the application
3. Log in with new password
4. **Important:** Remove `ADMIN_PASSWORD_RESET=true` after successful reset
## Security Recommendations
### Production Deployments
- Set a strong `AUTH_SECRET` for session encryption
- Use HTTPS with valid SSL certificate
- Use strong, unique passwords
- Enable passkey authentication
- Regularly rotate API keys
### Generate AUTH_SECRET
```bash
openssl rand -base64 32
```
Add to your environment:
```bash
AUTH_SECRET=your-generated-secret-here
```
## Next Steps
- [Configure OAuth Providers](../configuration/oauth.md) - Enable social login
- [Environment Variables](../configuration/environment.md) - All configuration options
- [Features Overview](../features/overview.md) - Explore capabilities
+101
View File
@@ -0,0 +1,101 @@
# Installation
Choose your preferred installation method.
## Docker (Recommended)
Docker is the fastest way to get started and recommended for production use.
```bash
git clone https://github.com/chriswritescode-dev/opencode-manager.git
cd opencode-manager
docker-compose up -d
```
Open [http://localhost:5003](http://localhost:5003) in your browser.
### What Docker Sets Up
The container automatically:
- Installs OpenCode if not present
- Builds and serves the frontend
- Creates persistent volumes for workspace and database
- Configures health checks and auto-restart
### Docker Commands
```bash
# Start the container
docker-compose up -d
# Stop and remove container
docker-compose down
# Rebuild the image
docker-compose build
# View logs
docker-compose logs -f
# Restart
docker-compose restart
# Access container shell
docker exec -it opencode-manager sh
```
### Volume Mounts
| Path | Purpose |
|------|---------|
| `./workspace` | Repository storage |
| `./data` | Database and config |
| `opencode-cache` | OpenCode cache |
## Local Development
For contributors who want to develop locally instead of using Docker.
### Prerequisites
- [pnpm](https://pnpm.io/installation) - Package manager (required for workspaces)
- [Bun](https://bun.sh) - Backend runtime
- [OpenCode TUI](https://opencode.ai) - `npm install -g @opencode/tui`
- Node.js 18+
### Setup
```bash
# Clone the repository
git clone https://github.com/chriswritescode-dev/opencode-manager.git
cd opencode-manager
# Install dependencies
pnpm install
# Copy environment configuration
cp .env.example .env
# Start development servers
pnpm dev
```
This starts:
- Backend on http://localhost:5003
- Frontend on http://localhost:5173 (with HMR)
## Verifying Installation
After starting the application:
1. Open your browser to the appropriate URL
2. You should see the login page or setup wizard
3. Check logs if you encounter issues: `docker-compose logs -f`
## Next Steps
- [Quick Start](quickstart.md) - First steps after installation
- [First Run Setup](first-run.md) - Creating your admin account
- [Docker Configuration](../configuration/docker.md) - Advanced Docker settings
+104
View File
@@ -0,0 +1,104 @@
# Quick Start
Get up and running with OpenCode Manager in minutes.
## 1. Start the Application
=== "Docker"
```bash
git clone https://github.com/chriswritescode-dev/opencode-manager.git
cd opencode-manager
docker-compose up -d
```
Open [http://localhost:5003](http://localhost:5003)
=== "Local Development"
```bash
git clone https://github.com/chriswritescode-dev/opencode-manager.git
cd opencode-manager
pnpm install
cp .env.example .env
pnpm dev
```
Open [http://localhost:5173](http://localhost:5173)
## 2. Create Admin Account
On first launch, you'll be redirected to the setup page:
1. Enter your **name**
2. Enter your **email**
3. Create a **password**
4. Click **Create Account**
!!! tip "Pre-configured Admin"
For automated deployments, you can skip this step by setting `ADMIN_EMAIL` and `ADMIN_PASSWORD` environment variables.
## 3. Configure AI Provider
Before chatting, you need to configure at least one AI provider:
1. Go to **Settings** (gear icon)
2. Select **Provider Credentials**
3. Choose a provider (e.g., Anthropic, OpenAI)
4. Enter your **API key** or click **Add OAuth** for supported providers
5. Click **Save**
## 4. Clone a Repository
1. Click the **folder icon** in the sidebar
2. Click **Clone Repository**
3. Paste a repository URL (HTTPS or SSH)
4. Click **Clone**
!!! note "Private Repositories"
For private repos, configure a GitHub Personal Access Token in Settings > Credentials first.
## 5. Start Chatting
1. Select your cloned repository from the sidebar
2. Click **New Session** or type `/new`
3. Type your message
4. Press **Enter** to send
### Useful Commands
| Command | Description |
|---------|-------------|
| `/help` | Show available commands |
| `/new` | Start a new session |
| `/models` | List available models |
| `/compact` | Reduce session context |
### File Mentions
Reference files in your prompts:
1. Type `@` in the chat input
2. Start typing a filename
3. Select from the autocomplete dropdown
4. The AI will have access to that file's contents
## 6. Explore Features
Now that you're set up, explore more features:
- **[Git Integration](../features/git.md)** - View diffs, manage branches
- **[File Browser](../features/files.md)** - Navigate and edit files
- **[MCP Servers](../features/mcp.md)** - Add tools and integrations
- **[Mobile PWA](../features/mobile.md)** - Install on your phone
## Keyboard Shortcuts
| Shortcut | Action |
|----------|--------|
| `Enter` | Send message |
| `Shift+Enter` | New line |
| `Ctrl+/` | Toggle sidebar |
| `Ctrl+K` | Command palette |
Customize shortcuts in Settings > Keyboard Shortcuts.
Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

+58
View File
@@ -0,0 +1,58 @@
# OpenCode Manager
Mobile-first web interface for [OpenCode](https://opencode.ai) AI agents. Manage, control, and code from any device - your phone, tablet, or desktop.
<!-- Replace with your hero GIF -->
![OpenCode Manager Demo](images/ocmgr-demo.gif)
## Quick Start
```bash
git clone https://github.com/chriswritescode-dev/opencode-manager.git
cd opencode-manager
docker-compose up -d
```
Open [http://localhost:5003](http://localhost:5003) and create your admin account. That's it!
## What is OpenCode Manager?
OpenCode Manager provides a web-based interface for OpenCode AI agents, allowing you to:
- **Manage repositories** - Clone, browse, and work with multiple git repos
- **Chat with AI** - Real-time streaming chat with file mentions and slash commands
- **View diffs** - See code changes with syntax highlighting
- **Control from anywhere** - Mobile-first PWA works on any device
- **Configure AI** - Manage models, providers, and MCP servers
## Key Features
- **Multi-Repository Support** - Clone and manage multiple git repos with private repo support
- **Git Integration** - View diffs, manage branches, create PRs directly from the UI
- **Real-time Chat** - Stream responses with file mentions and custom slash commands
- **Mobile-First PWA** - Install as an app on any device with offline support
- **AI Configuration** - Configure models, providers, OAuth, and custom agents
- **MCP Servers** - Add local or remote MCP servers with pre-built templates
## System Requirements
### Docker (Recommended)
- Docker Engine 20.10+
- Docker Compose v2+
- 2GB RAM minimum
- 5GB disk space
### Local Development
- [pnpm](https://pnpm.io) - Package manager
- [Bun](https://bun.sh) - Backend runtime
- [OpenCode TUI](https://opencode.ai) - `npm i -g @opencode/tui`
- Node.js 18+
## Next Steps
- [Installation Guide](getting-started/installation.md) - Detailed setup instructions
- [Quick Start](getting-started/quickstart.md) - Get up and running fast
- [Features Overview](features/overview.md) - Explore all features
- [Configuration](configuration/environment.md) - Environment variables and setup
+55
View File
@@ -0,0 +1,55 @@
.screenshot-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 1.5rem;
margin: 2rem 0;
}
.screenshot-grid figure {
margin: 0;
text-align: center;
}
.screenshot-grid img {
max-width: 100%;
border-radius: 8px;
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}
.md-typeset img {
max-width: 600px;
max-height: 800px;
height: auto;
object-fit: contain;
}
@keyframes progress {
0% {
width: 0%;
}
50% {
width: 70%;
}
100% {
width: 100%;
}
}
.animate-progress {
animation: progress 2s ease-in-out infinite;
}
.screenshot-grid figcaption {
margin-top: 0.5rem;
font-size: 0.875rem;
color: var(--md-default-fg-color--light);
}
.md-typeset table:not([class]) {
font-size: 0.8rem;
}
.md-typeset .admonition,
.md-typeset details {
font-size: 0.85rem;
}
+255
View File
@@ -0,0 +1,255 @@
# Troubleshooting
Common issues and their solutions.
## Installation Issues
### Docker Container Won't Start
**Symptoms:** Container exits immediately or fails health check
**Solutions:**
1. Check logs:
```bash
docker-compose logs -f
```
2. Verify Docker resources (2GB RAM minimum)
3. Check ports aren't in use:
```bash
lsof -i :5003
```
4. Rebuild without cache:
```bash
docker-compose build --no-cache
```
### Port Already in Use
**Symptoms:** Error about port 5003 being in use
**Solutions:**
1. Find process using port:
```bash
lsof -i :5003
```
2. Stop the process or change port in `docker-compose.yml`:
```yaml
ports:
- "8080:5003" # Use different host port
```
### Permission Denied Errors
**Symptoms:** Container can't write to volumes
**Solutions:**
1. Fix ownership:
```bash
sudo chown -R $(id -u):$(id -g) ./workspace ./data
```
## Authentication Issues
### Can't Log In
**Solutions:**
1. Clear browser cookies
2. Try incognito/private mode
3. Check `AUTH_SECRET` is set in production
4. Verify `AUTH_TRUSTED_ORIGINS` includes your URL
### Session Keeps Expiring
**Solutions:**
1. Ensure `AUTH_SECRET` is persistent across restarts
2. Check browser isn't blocking cookies
3. Verify `AUTH_SECURE_COOKIES=false` if using HTTP
### OAuth Redirect Error
**Solutions:**
1. Verify callback URL matches exactly in provider settings
2. Check for trailing slashes
3. Ensure protocol matches (http vs https)
### Passkey Not Working
**Solutions:**
1. Verify `PASSKEY_RP_ID` matches your domain
2. Check `PASSKEY_ORIGIN` includes correct protocol and port
3. Try a different browser
4. Ensure WebAuthn is supported
### Password Reset Not Working
**Solutions:**
1. Set all required variables:
```bash
ADMIN_EMAIL=your@email.com
ADMIN_PASSWORD=new-password
ADMIN_PASSWORD_RESET=true
```
2. Restart container
3. Remove `ADMIN_PASSWORD_RESET=true` after reset
## Git Issues
### Clone Fails for Private Repository
**Solutions:**
1. Configure GitHub PAT in Settings > Credentials
2. Ensure PAT has `repo` scope
3. Check PAT hasn't expired
### Push/Pull Fails
**Solutions:**
1. Verify GitHub PAT is valid
2. Check PAT has write permissions
3. Verify remote URL: `git remote -v`
### Worktree Creation Fails
**Solutions:**
1. Ensure branch doesn't already exist
2. Check disk space
3. Verify repo isn't in detached HEAD state
## Chat Issues
### Messages Not Sending
**Solutions:**
1. Check OpenCode server is running:
```bash
docker exec opencode-manager ps aux | grep opencode
```
2. Verify model is configured
3. Check API key is valid
### Streaming Stops Unexpectedly
**Solutions:**
1. Check network connection
2. Look for errors in browser console (F12)
3. Check container logs for errors
### File Mentions Not Working
**Solutions:**
1. Ensure repository is selected
2. Check file exists
3. Refresh the file browser
## File Browser Issues
### Files Not Loading
**Solutions:**
1. Refresh the page
2. Check repository is properly cloned
3. Verify workspace volume is mounted
### Upload Fails
**Solutions:**
1. Check file size
2. Verify write permissions
3. Check browser console for errors
## Performance Issues
### Slow Response Times
**Solutions:**
1. Check Docker resources:
```bash
docker stats
```
2. Clear old sessions
3. Use `/compact` to reduce session size
### High Memory Usage
**Solutions:**
1. Limit session count
2. Delete unused sessions
3. Restart container:
```bash
docker-compose restart
```
### Database Errors
**Solutions:**
1. Stop container
2. Backup database:
```bash
cp ./data/opencode.db ./data/opencode.db.bak
```
3. Restart container
## Mobile Issues
### Keyboard Doesn't Close
**Solutions:**
1. Tap outside input field
2. Update device OS
3. Try Safari on iOS
### PWA Won't Install
**Solutions:**
1. iOS: Must use Safari
2. Android: Must use Chrome
3. Check HTTPS is enabled
### Touch Gestures Not Working
**Solutions:**
1. Swipe from screen edge
2. Swipe faster (within 300ms)
3. Check no UI element is blocking
## Getting More Help
If your issue isn't covered:
1. Check [GitHub Issues](https://github.com/chriswritescode-dev/opencode-manager/issues)
2. Search [GitHub Discussions](https://github.com/chriswritescode-dev/opencode-manager/discussions)
3. Open a new issue with:
- Steps to reproduce
- Expected vs actual behavior
- Container logs: `docker-compose logs`
- Browser console errors
- Environment info (OS, browser, Docker version)