mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
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:
1 parent
358abbf20e
commit
da6cad8b3a
51 files changed
+4276
-353
No files matched your search
+2
-2
@@ -55,7 +55,7 @@ DEBUG=false
|
||||
|
||||
# Trusted origins for authentication (comma-separated)
|
||||
# Add your server's external URL when accessing remotely
|
||||
# AUTH_TRUSTED_ORIGINS=http://localhost:5003,http://192.168.1.244:5003
|
||||
# AUTH_TRUSTED_ORIGINS=http://localhost:5173,http://localhost:5003
|
||||
|
||||
# Admin Account (optional - for pre-configured single-user mode)
|
||||
# When set, admin user is created on first startup and self-registration is disabled
|
||||
@@ -81,7 +81,7 @@ DEBUG=false
|
||||
# Passkey/WebAuthn Configuration
|
||||
PASSKEY_RP_ID=localhost
|
||||
PASSKEY_RP_NAME=OpenCode Manager
|
||||
PASSKEY_ORIGIN=http://localhost:5173
|
||||
PASSKEY_ORIGIN=http://localhost:5003
|
||||
|
||||
# ============================================
|
||||
# Frontend Configuration (Vite)
|
||||
|
||||
@@ -1,353 +1,187 @@
|
||||
# OpenCode Manager
|
||||
|
||||
Mobile-first web interface for OpenCode AI agents. Manage, control, and code with OpenCode from any device - your phone, tablet, or desktop. Features Git integration, file management, and real-time chat in a responsive PWA. Deploy with Docker for instant setup. View diffs, edit files and much more.
|
||||
Mobile-first web interface for [OpenCode](https://opencode.ai) AI agents. Manage, control, and code from any device - your phone, tablet, or desktop.
|
||||
|
||||
## Features
|
||||
<!-- Replace with your hero GIF showing the main workflow -->
|
||||

|
||||
|
||||
### Repository Management
|
||||
- **Multi-Repository Support** - Clone and manage multiple git repos/worktrees in local workspaces
|
||||
- **Private Repository Support** - GitHub PAT configuration for cloning private repos
|
||||
- **Worktree Support** - Create and manage Git worktrees for working on multiple branches
|
||||
## Quick Start
|
||||
|
||||
### Git Integration
|
||||
- **Source Control Panel** - Comprehensive Git operations in a modal interface with tabs for Changes, Commits, and Branches
|
||||
- **Git Diff Viewer** - View file changes with unified diff, line numbers, and addition/deletion counts
|
||||
- **Git Status Panel** - See all uncommitted changes (modified, added, deleted, renamed, untracked)
|
||||
- **Branch Management** - Switch, create, and manage branches through the Source Control Panel
|
||||
- **Branch/Worktree Creation** - Create new branch workspaces from any repository
|
||||
- **Ahead/Behind Tracking** - Shows commits ahead/behind remote
|
||||
- **Push PRs to GitHub** - Create and push pull requests directly from your phone
|
||||
```bash
|
||||
git clone https://github.com/chriswritescode-dev/opencode-manager.git
|
||||
cd opencode-manager
|
||||
docker-compose up -d
|
||||
# Open http://localhost:5003
|
||||
```
|
||||
|
||||
### File Browser
|
||||
- **Directory Navigation** - Browse files and folders with tree view
|
||||
- **File Search** - Search files within directories
|
||||
- **Syntax Highlighting** - Code preview with syntax highlighting
|
||||
- **File Operations** - Create files/folders, rename, delete
|
||||
- **Drag-and-Drop Upload** - Upload files by dragging into the browser
|
||||
- **Large File Support** - Virtualization for large files
|
||||
- **ZIP Download** - Download repos as ZIP excluding gitignored files
|
||||
|
||||
### Chat & Session Features
|
||||
- **Slash Commands** - Built-in commands (`/help`, `/new`, `/models`, `/export`, `/compact`, etc.)
|
||||
- **Custom Commands** - Create custom slash commands with templates
|
||||
- **File Mentions** - Reference files with `@filename` autocomplete
|
||||
- **Plan/Build Mode Toggle** - Switch between read-only and file-change modes
|
||||
- **Mermaid Diagram Support** - Visual diagram rendering in chat messages
|
||||
- **Session Management** - Create, search, delete, and bulk delete sessions
|
||||
- **Real-time Streaming** - Live message streaming with SSE
|
||||
|
||||
### AI Model & Provider Configuration
|
||||
- **Model Selection** - Browse and select from available AI models with filtering
|
||||
- **Provider Management** - Configure multiple AI providers with API keys or OAuth
|
||||
- **OAuth Authentication** - Secure OAuth login for supported providers (Anthropic, GitHub Copilot)
|
||||
- **Context Usage Indicator** - Visual progress bar showing token usage
|
||||
- **Agent Configuration** - Create custom agents with system prompts and tool permissions
|
||||
|
||||
### MCP Server Management
|
||||
- **MCP Server Configuration** - Add local (command-based) or remote (HTTP) MCP servers
|
||||
- **Server Templates** - Pre-built templates for common MCP servers
|
||||
- **Enable/Disable Servers** - Toggle servers on/off with auto-restart
|
||||
|
||||
### Authentication
|
||||
- **Single-User Mode** - Designed for personal/single-user deployments
|
||||
- **First-Run Setup** - Guided admin account creation on first launch
|
||||
- **Passkey Support** - WebAuthn/passkey authentication for passwordless login
|
||||
- **OAuth Providers** - Optional GitHub, Google, Discord login (requires configuration)
|
||||
- **Environment-Based Admin** - Pre-configure admin credentials via environment variables
|
||||
- **Password Reset** - Reset password via environment variable flag
|
||||
|
||||
### Settings & Customization
|
||||
- **Theme Selection** - Dark, Light, or System theme
|
||||
- **Keyboard Shortcuts** - Customizable keyboard shortcuts
|
||||
- **OpenCode Config Editor** - Raw JSON editor for advanced configuration
|
||||
|
||||
### Mobile & PWA
|
||||
- **Mobile-First Design** - Responsive UI optimized for mobile use
|
||||
- **PWA Support** - Installable as Progressive Web App
|
||||
- **iOS Keyboard Support** - Proper keyboard handling on iOS
|
||||
- **Enter Key Send** - Press Enter to automatically close keyboard and send messages
|
||||
- **Swipe-to-Navigate** - Swipe right from left edge to navigate back
|
||||
|
||||
### Text-to-Speech (TTS)
|
||||
- **Dual Provider Support** - Browser-native Web Speech API + external OpenAI-compatible endpoints
|
||||
- **Browser-Native TTS** - Built-in Web Speech API for instant playback without API keys
|
||||
- **AI Message Playback** - Listen to assistant responses with TTS
|
||||
- **OpenAI-Compatible** - Works with any OpenAI-compatible TTS endpoint
|
||||
- **Voice & Speed Discovery** - Automatic voice detection with caching (1hr TTL)
|
||||
- **Voice & Speed Controls** - Configurable voice selection and playback speed
|
||||
- **Audio Caching** - 24-hour cache with 200MB limit for performance
|
||||
- **Markdown Sanitization** - Filters unreadable symbols for smooth playback
|
||||
- **Floating Controls** - Persistent stop button for audio control
|
||||
- **Custom Endpoints** - Connect to local or self-hosted TTS services
|
||||
On first launch, you'll be prompted to create an admin account. That's it!
|
||||
|
||||
## Screenshots
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><strong>Files (Mobile)</strong></td>
|
||||
<td><strong>Files (Desktop)</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://github.com/user-attachments/assets/24243e5e-ab02-44ff-a719-263f61c3178b" alt="files-mobile" /></td>
|
||||
<td><img src="https://github.com/user-attachments/assets/0a37feb0-391c-48a1-8bda-44a046aad913" alt="files-desktop" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Chat (Mobile)</strong></td>
|
||||
<td><strong>Chat (Desktop)</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://github.com/user-attachments/assets/a48cc728-e540-4247-879a-c5f36c3fd6de" alt="chat-mobile" width="250" /></td>
|
||||
<td><img src="https://github.com/user-attachments/assets/5fe34443-1d06-4847-a397-ef472aae0932" alt="chat-desktop" width="600" /></td>
|
||||
<td><img src="https://github.com/user-attachments/assets/a48cc728-e540-4247-879a-c5f36c3fd6de" alt="chat-mobile" width="200" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>File Browser (Mobile)</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://github.com/user-attachments/assets/24243e5e-ab02-44ff-a719-263f61c3178b" alt="files-mobile" width="200" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Inline Diff View</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://github.com/user-attachments/assets/b94c0ca0-d960-4888-8a25-a31ed6d5068d" alt="inline-diff-view" width="250" /></td>
|
||||
<td></td>
|
||||
<td><img src="https://github.com/user-attachments/assets/b94c0ca0-d960-4888-8a25-a31ed6d5068d" alt="inline-diff-view" width="300" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
See the [Roadmap](ROADMAP.md) for planned features and future development.
|
||||
## 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
|
||||
|
||||
### File Management
|
||||
- **Directory Browser** - Navigate files with tree view and search
|
||||
- **Syntax Highlighting** - Code preview with highlighting for all major languages
|
||||
- **File Operations** - Create, rename, delete, and drag-and-drop upload
|
||||
- **ZIP Download** - Download repos as ZIP (respects .gitignore)
|
||||
|
||||
### 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
|
||||
- **Text-to-Speech** - Listen to AI responses with browser or OpenAI-compatible TTS
|
||||
|
||||
### 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
|
||||
- **MCP Servers** - Add local or remote MCP servers with pre-built templates
|
||||
|
||||
### 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
|
||||
|
||||
## Installation
|
||||
|
||||
### Option 1: Docker (Recommended for Production)
|
||||
### Docker (Recommended)
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone https://github.com/chriswritescode-dev/opencode-manager.git
|
||||
cd opencode-manager
|
||||
|
||||
# Start with Docker Compose (single container)
|
||||
docker-compose up -d
|
||||
|
||||
# Access the application at http://localhost:5001
|
||||
```
|
||||
|
||||
The Docker setup automatically:
|
||||
- Installs OpenCode if not present
|
||||
- Builds and serves frontend from backend
|
||||
- Sets up persistent volumes for workspace and database
|
||||
- Includes health checks and auto-restart
|
||||
The container automatically installs OpenCode, builds the frontend, and sets up persistent volumes.
|
||||
|
||||
**Docker Commands:**
|
||||
**Common commands:**
|
||||
```bash
|
||||
# Start container
|
||||
docker-compose up -d
|
||||
|
||||
# Stop and remove container
|
||||
docker-compose down
|
||||
|
||||
# Rebuild image
|
||||
docker-compose build
|
||||
|
||||
# View logs
|
||||
docker-compose logs -f
|
||||
|
||||
# Restart container
|
||||
docker-compose restart
|
||||
|
||||
# Access container shell
|
||||
docker exec -it opencode-manager sh
|
||||
docker-compose up -d # Start
|
||||
docker-compose down # Stop
|
||||
docker-compose logs -f # View logs
|
||||
docker-compose restart # Restart
|
||||
```
|
||||
|
||||
### Dev Server Ports
|
||||
### Local Development
|
||||
|
||||
The Docker container exposes ports `5100-5103` for running dev servers inside your repositories. Configure your project's dev server to use one of these ports and access it directly from your browser.
|
||||
|
||||
**Example usage:**
|
||||
```bash
|
||||
# Vite (vite.config.ts)
|
||||
server: { port: 5100, host: '0.0.0.0' }
|
||||
|
||||
# Next.js
|
||||
next dev -p 5100 -H 0.0.0.0
|
||||
|
||||
# Express/Node
|
||||
app.listen(5100, '0.0.0.0')
|
||||
```
|
||||
|
||||
Access your dev server at `http://localhost:5100` (or your Docker host IP).
|
||||
|
||||
To customize the exposed ports, edit `docker-compose.yml`:
|
||||
```yaml
|
||||
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
|
||||
```
|
||||
|
||||
### Global Agent Instructions (AGENTS.md)
|
||||
|
||||
OpenCode Manager creates a default `AGENTS.md` file in the workspace config directory (`/workspace/.config/opencode/AGENTS.md`). This file provides global instructions to AI agents working within the container.
|
||||
|
||||
**Default instructions include:**
|
||||
- Reserved ports (5003 for OpenCode Manager, 5551 for OpenCode server)
|
||||
- Available dev server ports (5100-5103)
|
||||
- Guidelines for binding to `0.0.0.0` for Docker accessibility
|
||||
|
||||
**Editing AGENTS.md:**
|
||||
- Via UI: Settings > OpenCode > Global Agent Instructions
|
||||
- Via file: Edit `/workspace/.config/opencode/AGENTS.md` directly
|
||||
|
||||
This file is merged with any repository-specific `AGENTS.md` files, with repository instructions taking precedence for their respective codebases.
|
||||
|
||||
### Authentication Setup
|
||||
|
||||
OpenCode Manager uses a single-user authentication system. On first launch, you'll be prompted to create an admin account.
|
||||
|
||||
#### AUTH_SECRET (Required for Production)
|
||||
|
||||
The `AUTH_SECRET` environment variable is required for production deployments for session encryption and security. Generate a secure random secret:
|
||||
For contributors who want to develop locally:
|
||||
|
||||
```bash
|
||||
# Generate a secure random secret
|
||||
openssl rand -base64 32
|
||||
# Prerequisites: pnpm, Bun, OpenCode TUI (npm i -g @opencode/tui)
|
||||
|
||||
git clone https://github.com/chriswritescode-dev/opencode-manager.git
|
||||
cd opencode-manager
|
||||
pnpm install
|
||||
cp .env.example .env
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
Then add it to your environment configuration:
|
||||
## Configuration
|
||||
|
||||
### Authentication
|
||||
|
||||
OpenCode Manager uses single-user authentication. Create your admin account on first launch, or pre-configure via environment variables:
|
||||
|
||||
```bash
|
||||
# In docker-compose.yml or .env
|
||||
AUTH_SECRET=your-secure-random-secret-here
|
||||
```
|
||||
|
||||
**Important:** Never commit the AUTH_SECRET to version control. Use different secrets for development and production environments.
|
||||
|
||||
#### First-Run Setup (Interactive)
|
||||
|
||||
1. Start the application
|
||||
2. Navigate to the web interface
|
||||
3. You'll be redirected to the Setup page
|
||||
4. Create your admin account with name, email, and password
|
||||
5. Optionally add a passkey for passwordless login in Settings
|
||||
|
||||
#### Pre-Configured Admin (Environment Variables)
|
||||
|
||||
For automated deployments, you can pre-configure the admin account:
|
||||
|
||||
```bash
|
||||
# In docker-compose.yml or .env
|
||||
# Pre-configured admin (optional)
|
||||
ADMIN_EMAIL=admin@example.com
|
||||
ADMIN_PASSWORD=your-secure-password
|
||||
|
||||
# Required for production
|
||||
AUTH_SECRET=your-secure-random-secret # Generate with: openssl rand -base64 32
|
||||
```
|
||||
|
||||
When these are set:
|
||||
- The admin user is created automatically on first startup
|
||||
- Self-registration is disabled (single-user mode)
|
||||
- Users must log in with the configured credentials
|
||||
### Remote/LAN Access
|
||||
|
||||
#### Password Reset
|
||||
|
||||
If you forget your password, reset it via environment variables:
|
||||
For HTTP access on local networks:
|
||||
|
||||
```bash
|
||||
# Set the new password and enable reset
|
||||
ADMIN_EMAIL=admin@example.com
|
||||
ADMIN_PASSWORD=new-secure-password
|
||||
ADMIN_PASSWORD_RESET=true
|
||||
AUTH_TRUSTED_ORIGINS=http://localhost:5003
|
||||
AUTH_SECURE_COOKIES=false # Required when not using HTTPS (cookies won't work over plain HTTP otherwise)
|
||||
```
|
||||
|
||||
1. Set `ADMIN_PASSWORD_RESET=true` along with the new password
|
||||
2. Restart the application
|
||||
3. Log in with the new password
|
||||
4. **Important:** Remove `ADMIN_PASSWORD_RESET=true` from your environment after resetting
|
||||
### OAuth Providers (Optional)
|
||||
|
||||
#### Remote/LAN Access (HTTP)
|
||||
|
||||
When deploying OpenCode Manager on a local network without HTTPS (e.g., accessing via `http://192.168.1.*:5003`), configure these environment variables:
|
||||
Enable social login by configuring OAuth credentials:
|
||||
|
||||
```bash
|
||||
# Trusted origins for authentication (comma-separated)
|
||||
# Include all URLs you'll use to access the application
|
||||
AUTH_TRUSTED_ORIGINS=http://localhost:5003,http://192.168.1.*:5003
|
||||
# GitHub
|
||||
GITHUB_CLIENT_ID=...
|
||||
GITHUB_CLIENT_SECRET=...
|
||||
|
||||
# Disable secure cookies for HTTP (required for non-HTTPS)
|
||||
AUTH_SECURE_COOKIES=false
|
||||
# Google
|
||||
GOOGLE_CLIENT_ID=...
|
||||
GOOGLE_CLIENT_SECRET=...
|
||||
|
||||
# Discord
|
||||
DISCORD_CLIENT_ID=...
|
||||
DISCORD_CLIENT_SECRET=...
|
||||
```
|
||||
|
||||
**Defaults:**
|
||||
- `AUTH_TRUSTED_ORIGINS`: `http://localhost:5003`
|
||||
- `AUTH_SECURE_COOKIES`: `true` in production, `false` in development
|
||||
### Passkeys
|
||||
|
||||
**Important:** For production deployments with HTTPS, leave `AUTH_SECURE_COOKIES` at its default (`true`) for security. Only set to `false` when using HTTP on a trusted local network.
|
||||
|
||||
#### OAuth Providers (Optional)
|
||||
|
||||
To enable social login, configure OAuth credentials:
|
||||
For WebAuthn/passkey support:
|
||||
|
||||
```bash
|
||||
# GitHub OAuth
|
||||
GITHUB_CLIENT_ID=your-client-id
|
||||
GITHUB_CLIENT_SECRET=your-client-secret
|
||||
|
||||
# Google OAuth
|
||||
GOOGLE_CLIENT_ID=your-client-id
|
||||
GOOGLE_CLIENT_SECRET=your-client-secret
|
||||
|
||||
# Discord OAuth
|
||||
DISCORD_CLIENT_ID=your-client-id
|
||||
DISCORD_CLIENT_SECRET=your-client-secret
|
||||
```
|
||||
|
||||
#### Passkey Configuration
|
||||
|
||||
For passkey/WebAuthn support, configure your domain:
|
||||
|
||||
```bash
|
||||
# Production example
|
||||
PASSKEY_RP_ID=yourdomain.com
|
||||
PASSKEY_RP_NAME=OpenCode Manager
|
||||
PASSKEY_ORIGIN=https://yourdomain.com
|
||||
```
|
||||
|
||||
### Option 2: Local Development (Contributors)
|
||||
### Dev Server Ports
|
||||
|
||||
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`
|
||||
The Docker container exposes ports `5100-5103` for running dev servers inside repositories:
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone https://github.com/chriswritescode-dev/opencode-manager.git
|
||||
cd opencode-manager
|
||||
# Example: Vite
|
||||
server: { port: 5100, host: '0.0.0.0' }
|
||||
|
||||
# Install dependencies (uses pnpm workspaces)
|
||||
pnpm install
|
||||
|
||||
# Copy environment configuration
|
||||
cp .env.example .env
|
||||
|
||||
# Start development servers (backend + frontend)
|
||||
pnpm dev
|
||||
# Access at http://localhost:5100
|
||||
```
|
||||
|
||||
## OAuth Provider Setup
|
||||
## Documentation
|
||||
|
||||
OpenCode WebUI supports OAuth authentication for select providers, offering a more secure and convenient alternative to API keys.
|
||||
For detailed guides and configuration reference, see the **[Documentation Site](https://chriswritescode-dev.github.io/opencode-manager)**.
|
||||
|
||||
### Supported OAuth Providers
|
||||
|
||||
- **Anthropic (Claude)** - OAuth login with Claude Pro/Max accounts
|
||||
- **GitHub Copilot** - OAuth device flow authentication
|
||||
|
||||
### Setting Up OAuth
|
||||
|
||||
1. **Navigate to Settings → Provider Credentials**
|
||||
2. **Select a provider** that shows the "OAuth" badge
|
||||
3. **Click "Add OAuth"** to start the authorization flow
|
||||
4. **Choose authentication method:**
|
||||
- **"Open Authorization Page"** - Opens browser for sign-in
|
||||
- **"Use Authorization Code"** - Provides code for manual entry
|
||||
5. **Complete authorization** in the browser or enter the provided code
|
||||
6. **Connection status** will show as "Configured" when successful
|
||||
- [Getting Started](https://chriswritescode-dev.github.io/opencode-manager/getting-started/installation/) - Installation and first-run setup
|
||||
- [Features](https://chriswritescode-dev.github.io/opencode-manager/features/overview/) - Deep dive on all features
|
||||
- [Configuration](https://chriswritescode-dev.github.io/opencode-manager/configuration/environment/) - Environment variables and advanced setup
|
||||
- [Troubleshooting](https://chriswritescode-dev.github.io/opencode-manager/troubleshooting/) - Common issues and solutions
|
||||
- [Development](https://chriswritescode-dev.github.io/opencode-manager/development/setup/) - Contributing and local development
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
@@ -1,12 +1,52 @@
|
||||
import { Hono } from 'hono'
|
||||
import type { ContentfulStatusCode } from 'hono/utils/http-status'
|
||||
import * as fileService from '../services/files'
|
||||
import * as archiveService from '../services/archive'
|
||||
import { logger } from '../utils/logger'
|
||||
import { getErrorMessage, getStatusCode } from '../utils/error-utils'
|
||||
|
||||
export function createFileRoutes() {
|
||||
const app = new Hono()
|
||||
|
||||
app.get('/*/download-zip', async (c) => {
|
||||
try {
|
||||
const userPath = c.req.path.replace(/^\/api\/files\/(.*)\/download-zip$/, '$1')
|
||||
|
||||
if (!userPath) {
|
||||
return c.json({ error: 'No path provided' }, 400)
|
||||
}
|
||||
|
||||
logger.info(`Starting ZIP archive creation for ${userPath}`)
|
||||
|
||||
const archivePath = await archiveService.createDirectoryArchive(userPath)
|
||||
const archiveSize = await archiveService.getArchiveSize(archivePath)
|
||||
const archiveStream = archiveService.getArchiveStream(archivePath)
|
||||
const dirName = userPath.split('/').pop() || 'download'
|
||||
|
||||
logger.info(`ZIP archive created: ${archivePath} (${archiveSize} bytes)`)
|
||||
|
||||
archiveStream.on('end', () => {
|
||||
archiveService.deleteArchive(archivePath)
|
||||
})
|
||||
|
||||
archiveStream.on('error', () => {
|
||||
archiveService.deleteArchive(archivePath)
|
||||
})
|
||||
|
||||
return new Response(archiveStream as unknown as ReadableStream, {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Content-Type': 'application/zip',
|
||||
'Content-Disposition': `attachment; filename="${dirName}.zip"`,
|
||||
'Content-Length': archiveSize.toString(),
|
||||
},
|
||||
})
|
||||
} catch (error: unknown) {
|
||||
logger.error('Failed to create directory archive:', error)
|
||||
return c.json({ error: getErrorMessage(error) || 'Failed to create archive' }, getStatusCode(error) as ContentfulStatusCode)
|
||||
}
|
||||
})
|
||||
|
||||
app.get('/*', async (c) => {
|
||||
try {
|
||||
const userPath = c.req.path.replace(/^\/api\/files\//, '') || ''
|
||||
|
||||
@@ -153,6 +153,44 @@ export async function createRepoArchive(repoPath: string): Promise<string> {
|
||||
})
|
||||
}
|
||||
|
||||
export async function createDirectoryArchive(directoryPath: string, archiveName?: string): Promise<string> {
|
||||
const dirName = archiveName || path.basename(directoryPath)
|
||||
const tempFile = path.join(os.tmpdir(), `${dirName}-${Date.now()}.zip`)
|
||||
|
||||
logger.info(`Creating archive for directory ${directoryPath} at ${tempFile}`)
|
||||
|
||||
const allPaths = await collectFiles(directoryPath)
|
||||
|
||||
const filteredPaths = await filterIgnoredPaths(directoryPath, allPaths)
|
||||
|
||||
const output = createWriteStream(tempFile)
|
||||
const archive = archiver('zip', { zlib: { level: 5 } })
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
output.on('close', () => {
|
||||
logger.info(`Archive created: ${tempFile} (${archive.pointer()} bytes)`)
|
||||
resolve(tempFile)
|
||||
})
|
||||
|
||||
archive.on('error', (err) => {
|
||||
logger.error('Archive error:', err)
|
||||
reject(err)
|
||||
})
|
||||
|
||||
archive.pipe(output)
|
||||
|
||||
for (const relativePath of filteredPaths) {
|
||||
if (relativePath.endsWith('/')) continue
|
||||
|
||||
const fullPath = path.join(directoryPath, relativePath)
|
||||
const archivePath = path.join(dirName, relativePath)
|
||||
archive.file(fullPath, { name: archivePath })
|
||||
}
|
||||
|
||||
archive.finalize()
|
||||
})
|
||||
}
|
||||
|
||||
export async function deleteArchive(filePath: string): Promise<void> {
|
||||
try {
|
||||
await unlink(filePath)
|
||||
|
||||
@@ -267,6 +267,8 @@ function getMimeType(filePath: string): AllowedMimeType {
|
||||
'.svg': 'image/svg+xml',
|
||||
'.pdf': 'application/pdf',
|
||||
'.zip': 'application/zip',
|
||||
'.md': 'text/markdown',
|
||||
'.mdx': 'text/markdown',
|
||||
}
|
||||
|
||||
return mimeTypes[ext] || 'text/plain'
|
||||
|
||||
@@ -0,0 +1,521 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { createFileRoutes } from '../../src/routes/files'
|
||||
import { Hono } from 'hono'
|
||||
import type { ReadStream } from 'fs'
|
||||
import * as fileService from '../../src/services/files'
|
||||
import * as archiveService from '../../src/services/archive'
|
||||
import type { FileInfo, ChunkedFileInfo, PatchOperation } from '@opencode-manager/shared'
|
||||
|
||||
interface FileUploadResult {
|
||||
name: string
|
||||
path: string
|
||||
size: number
|
||||
mimeType: string
|
||||
}
|
||||
|
||||
const getFile = vi.fn()
|
||||
const getRawFileContent = vi.fn()
|
||||
const getFileRange = vi.fn()
|
||||
const uploadFile = vi.fn()
|
||||
const createFileOrFolder = vi.fn()
|
||||
const deleteFileOrFolder = vi.fn()
|
||||
const renameOrMoveFile = vi.fn()
|
||||
const applyFilePatches = vi.fn()
|
||||
|
||||
const createDirectoryArchive = vi.fn()
|
||||
const getArchiveSize = vi.fn()
|
||||
const getArchiveStream = vi.fn()
|
||||
const deleteArchive = vi.fn()
|
||||
|
||||
vi.mock('../../src/utils/logger', () => ({
|
||||
logger: {
|
||||
info: vi.fn(),
|
||||
error: vi.fn(),
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock('@opencode-manager/shared/config/env', () => ({
|
||||
getReposPath: vi.fn(() => '/test/repos'),
|
||||
FILE_LIMITS: {
|
||||
MAX_SIZE_BYTES: 1024 * 1024,
|
||||
MAX_UPLOAD_SIZE_BYTES: 10 * 1024 * 1024,
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock('../../src/services/files', () => ({
|
||||
getFile,
|
||||
getRawFileContent,
|
||||
getFileRange,
|
||||
uploadFile,
|
||||
createFileOrFolder,
|
||||
deleteFileOrFolder,
|
||||
renameOrMoveFile,
|
||||
applyFilePatches,
|
||||
}))
|
||||
|
||||
vi.mock('../../src/services/archive', () => ({
|
||||
createDirectoryArchive,
|
||||
getArchiveSize,
|
||||
getArchiveStream,
|
||||
deleteArchive,
|
||||
}))
|
||||
|
||||
describe('File Routes', () => {
|
||||
let app: Hono
|
||||
let filesApp: Hono
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
filesApp = createFileRoutes()
|
||||
app = new Hono()
|
||||
app.route('/api/files', filesApp)
|
||||
})
|
||||
|
||||
describe('GET /*/download-zip - Route Order Regression Test', () => {
|
||||
it('should route to archive service for directory download, not file service', async () => {
|
||||
const mockStream = {
|
||||
on: vi.fn(),
|
||||
} as unknown as ReadStream
|
||||
|
||||
createDirectoryArchive.mockResolvedValue('/tmp/test-repo-123.zip')
|
||||
getArchiveSize.mockResolvedValue(1024)
|
||||
getArchiveStream.mockReturnValue(mockStream)
|
||||
|
||||
const response = await app.request('/api/files/test-repo/src/download-zip')
|
||||
|
||||
expect(createDirectoryArchive).toHaveBeenCalledWith('test-repo/src')
|
||||
expect(getArchiveSize).toHaveBeenCalledWith('/tmp/test-repo-123.zip')
|
||||
expect(getArchiveStream).toHaveBeenCalledWith('/tmp/test-repo-123.zip')
|
||||
expect(getFile).not.toHaveBeenCalled()
|
||||
|
||||
expect(mockStream.on).toHaveBeenCalledWith('end', expect.any(Function))
|
||||
expect(mockStream.on).toHaveBeenCalledWith('error', expect.any(Function))
|
||||
})
|
||||
|
||||
it('should return 400 when no path provided', async () => {
|
||||
const response = await app.request('/api/files/download-zip')
|
||||
const body = await response.json() as { error: string }
|
||||
|
||||
expect(response.status).toBe(400)
|
||||
expect(body).toHaveProperty('error', 'No path provided')
|
||||
expect(createDirectoryArchive).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should return 500 when archive creation fails', async () => {
|
||||
createDirectoryArchive.mockRejectedValue(new Error('Directory not found'))
|
||||
|
||||
const response = await app.request('/api/files/non-repo/download-zip')
|
||||
const body = await response.json() as { error: string }
|
||||
|
||||
expect(response.status).toBe(500)
|
||||
expect(body).toHaveProperty('error')
|
||||
})
|
||||
})
|
||||
|
||||
describe('GET /* - File/Directory Lookup', () => {
|
||||
const mockFileInfo: FileInfo = {
|
||||
name: 'test.txt',
|
||||
path: 'test-repo/test.txt',
|
||||
isDirectory: false,
|
||||
size: 100,
|
||||
mimeType: 'text/plain',
|
||||
content: Buffer.from('test content').toString('base64'),
|
||||
lastModified: new Date(),
|
||||
}
|
||||
|
||||
const mockDirInfo: FileInfo = {
|
||||
name: 'src',
|
||||
path: 'test-repo/src',
|
||||
isDirectory: true,
|
||||
size: 0,
|
||||
children: [
|
||||
{
|
||||
name: 'file.ts',
|
||||
path: 'test-repo/src/file.ts',
|
||||
isDirectory: false,
|
||||
size: 200,
|
||||
lastModified: new Date(),
|
||||
},
|
||||
],
|
||||
lastModified: new Date(),
|
||||
}
|
||||
|
||||
it('should return directory listing when path is directory', async () => {
|
||||
getFile.mockResolvedValue(mockDirInfo)
|
||||
|
||||
const response = await app.request('/api/files/test-repo/src')
|
||||
const body = await response.json() as FileInfo
|
||||
|
||||
expect(response.status).toBe(200)
|
||||
expect(body).toHaveProperty('isDirectory', true)
|
||||
expect(body).toHaveProperty('children')
|
||||
expect(Array.isArray(body.children)).toBe(true)
|
||||
expect(getFile).toHaveBeenCalledWith('test-repo/src')
|
||||
})
|
||||
|
||||
it('should return file info when no query params', async () => {
|
||||
getFile.mockResolvedValue(mockFileInfo)
|
||||
|
||||
const response = await app.request('/api/files/test-repo/test.txt')
|
||||
const body = await response.json() as FileInfo
|
||||
|
||||
expect(response.status).toBe(200)
|
||||
expect(body).toHaveProperty('isDirectory', false)
|
||||
expect(body).toHaveProperty('content')
|
||||
expect(getFile).toHaveBeenCalledWith('test-repo/test.txt')
|
||||
})
|
||||
|
||||
it('should return 404 when path does not exist', async () => {
|
||||
getFile.mockRejectedValue({ message: 'File or directory not found', statusCode: 404 })
|
||||
|
||||
const response = await app.request('/api/files/test-repo/nonexistent.txt')
|
||||
const body = await response.json() as { error: string }
|
||||
|
||||
expect(response.status).toBe(404)
|
||||
expect(body).toHaveProperty('error')
|
||||
})
|
||||
})
|
||||
|
||||
describe('GET /* with ?startLine&endLine - File Range', () => {
|
||||
const mockChunkedInfo: ChunkedFileInfo = {
|
||||
name: 'test.ts',
|
||||
path: 'test-repo/test.ts',
|
||||
isDirectory: false,
|
||||
size: 500,
|
||||
mimeType: 'text/typescript',
|
||||
lines: ['line 5', 'line 6', 'line 7', 'line 8', 'line 9'],
|
||||
totalLines: 100,
|
||||
startLine: 5,
|
||||
endLine: 10,
|
||||
hasMore: true,
|
||||
lastModified: new Date(),
|
||||
}
|
||||
|
||||
it('should return file range for valid parameters', async () => {
|
||||
getFileRange.mockResolvedValue(mockChunkedInfo)
|
||||
|
||||
const response = await app.request('/api/files/test-repo/test.ts?startLine=5&endLine=10')
|
||||
const body = await response.json() as ChunkedFileInfo
|
||||
|
||||
expect(response.status).toBe(200)
|
||||
expect(body).toHaveProperty('startLine', 5)
|
||||
expect(body).toHaveProperty('endLine', 10)
|
||||
expect(body).toHaveProperty('lines')
|
||||
expect(body).toHaveProperty('totalLines', 100)
|
||||
expect(getFileRange).toHaveBeenCalledWith('test-repo/test.ts', 5, 10)
|
||||
})
|
||||
|
||||
it('should return 400 for invalid startLine', async () => {
|
||||
const response = await app.request('/api/files/test-repo/test.ts?startLine=invalid&endLine=10')
|
||||
const body = await response.json() as { error: string }
|
||||
|
||||
expect(response.status).toBe(400)
|
||||
expect(body).toHaveProperty('error', 'Invalid line range parameters')
|
||||
})
|
||||
|
||||
it('should return 400 for invalid endLine', async () => {
|
||||
const response = await app.request('/api/files/test-repo/test.ts?startLine=0&endLine=invalid')
|
||||
const body = await response.json() as { error: string }
|
||||
|
||||
expect(response.status).toBe(400)
|
||||
expect(body).toHaveProperty('error', 'Invalid line range parameters')
|
||||
})
|
||||
|
||||
it('should return 400 when startLine equals endLine', async () => {
|
||||
const response = await app.request('/api/files/test-repo/test.ts?startLine=10&endLine=10')
|
||||
const body = await response.json() as { error: string }
|
||||
|
||||
expect(response.status).toBe(400)
|
||||
expect(body).toHaveProperty('error', 'Invalid line range parameters')
|
||||
})
|
||||
|
||||
it('should return 400 for negative startLine', async () => {
|
||||
const response = await app.request('/api/files/test-repo/test.ts?startLine=-5&endLine=10')
|
||||
const body = await response.json() as { error: string }
|
||||
|
||||
expect(response.status).toBe(400)
|
||||
expect(body).toHaveProperty('error', 'Invalid line range parameters')
|
||||
})
|
||||
})
|
||||
|
||||
describe('POST /* - File Upload', () => {
|
||||
it('should upload file successfully', async () => {
|
||||
const mockResult: FileUploadResult = {
|
||||
name: 'test.txt',
|
||||
path: 'test-repo/test.txt',
|
||||
size: 100,
|
||||
mimeType: 'text/plain',
|
||||
}
|
||||
uploadFile.mockResolvedValue(mockResult)
|
||||
|
||||
const file = new File(['content'], 'test.txt', { type: 'text/plain' })
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
|
||||
const response = await app.request('/api/files/test-repo', {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
const body = await response.json() as FileUploadResult
|
||||
|
||||
expect(response.status).toBe(200)
|
||||
expect(body).toHaveProperty('name', 'test.txt')
|
||||
expect(body).toHaveProperty('path', 'test-repo/test.txt')
|
||||
expect(uploadFile).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should return 400 when no file provided', async () => {
|
||||
const formData = new FormData()
|
||||
|
||||
const response = await app.request('/api/files/test-repo', {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
const body = await response.json() as { error: string }
|
||||
|
||||
expect(response.status).toBe(400)
|
||||
expect(body).toHaveProperty('error', 'No file provided')
|
||||
expect(uploadFile).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should handle file too large error', async () => {
|
||||
uploadFile.mockRejectedValue(new Error('File too large'))
|
||||
|
||||
const file = new File(['content'], 'large.bin', { type: 'application/octet-stream' })
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
|
||||
const response = await app.request('/api/files/test-repo', {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
const body = await response.json() as { error: string }
|
||||
|
||||
expect(response.status).toBe(500)
|
||||
expect(body).toHaveProperty('error', 'File too large')
|
||||
})
|
||||
})
|
||||
|
||||
describe('PUT /* - Create File/Folder', () => {
|
||||
const mockFileResult: FileInfo = {
|
||||
name: 'newfile.ts',
|
||||
path: 'test-repo/newfile.ts',
|
||||
isDirectory: false,
|
||||
size: 50,
|
||||
lastModified: new Date(),
|
||||
}
|
||||
|
||||
const mockFolderResult: FileInfo = {
|
||||
name: 'newfolder',
|
||||
path: 'test-repo/newfolder',
|
||||
isDirectory: true,
|
||||
size: 0,
|
||||
lastModified: new Date(),
|
||||
}
|
||||
|
||||
it('should create file successfully', async () => {
|
||||
createFileOrFolder.mockResolvedValue(mockFileResult)
|
||||
|
||||
const response = await app.request('/api/files/test-repo/newfile.ts', {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ type: 'file', content: 'export const x = 1' }),
|
||||
})
|
||||
const body = await response.json() as FileInfo
|
||||
|
||||
expect(response.status).toBe(200)
|
||||
expect(body).toHaveProperty('isDirectory', false)
|
||||
expect(body).toHaveProperty('size', 50)
|
||||
expect(createFileOrFolder).toHaveBeenCalledWith('test-repo/newfile.ts', {
|
||||
type: 'file',
|
||||
content: 'export const x = 1',
|
||||
})
|
||||
})
|
||||
|
||||
it('should create folder successfully', async () => {
|
||||
createFileOrFolder.mockResolvedValue(mockFolderResult)
|
||||
|
||||
const response = await app.request('/api/files/test-repo/newfolder', {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ type: 'folder' }),
|
||||
})
|
||||
const body = await response.json() as FileInfo
|
||||
|
||||
expect(response.status).toBe(200)
|
||||
expect(body).toHaveProperty('isDirectory', true)
|
||||
expect(createFileOrFolder).toHaveBeenCalledWith('test-repo/newfolder', {
|
||||
type: 'folder',
|
||||
})
|
||||
})
|
||||
|
||||
it('should return 500 when creation fails', async () => {
|
||||
createFileOrFolder.mockRejectedValue(new Error('Permission denied'))
|
||||
|
||||
const response = await app.request('/api/files/test-repo/newfile.ts', {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ type: 'file' }),
|
||||
})
|
||||
const body = await response.json() as { error: string }
|
||||
|
||||
expect(response.status).toBe(500)
|
||||
expect(body).toHaveProperty('error')
|
||||
})
|
||||
})
|
||||
|
||||
describe('DELETE /* - Delete File/Folder', () => {
|
||||
it('should delete file successfully', async () => {
|
||||
deleteFileOrFolder.mockResolvedValue(undefined)
|
||||
|
||||
const response = await app.request('/api/files/test-repo/oldfile.ts', {
|
||||
method: 'DELETE',
|
||||
})
|
||||
const body = await response.json() as { success: boolean }
|
||||
|
||||
expect(response.status).toBe(200)
|
||||
expect(body).toEqual({ success: true })
|
||||
expect(deleteFileOrFolder).toHaveBeenCalledWith('test-repo/oldfile.ts')
|
||||
})
|
||||
|
||||
it('should delete folder successfully', async () => {
|
||||
deleteFileOrFolder.mockResolvedValue(undefined)
|
||||
|
||||
const response = await app.request('/api/files/test-repo/oldfolder', {
|
||||
method: 'DELETE',
|
||||
})
|
||||
const body = await response.json() as { success: boolean }
|
||||
|
||||
expect(response.status).toBe(200)
|
||||
expect(body).toEqual({ success: true })
|
||||
})
|
||||
|
||||
it('should return error when deletion fails', async () => {
|
||||
deleteFileOrFolder.mockRejectedValue(new Error('File not found'))
|
||||
|
||||
const response = await app.request('/api/files/test-repo/nonexistent.ts', {
|
||||
method: 'DELETE',
|
||||
})
|
||||
const body = await response.json() as { error: string }
|
||||
|
||||
expect(response.status).toBe(404)
|
||||
expect(body).toHaveProperty('error')
|
||||
})
|
||||
})
|
||||
|
||||
describe('PATCH /* - File Operations', () => {
|
||||
const mockRenameResult: FileInfo = {
|
||||
name: 'renamed.ts',
|
||||
path: 'test-repo/renamed.ts',
|
||||
isDirectory: false,
|
||||
size: 200,
|
||||
lastModified: new Date(),
|
||||
}
|
||||
|
||||
describe('Apply Patches', () => {
|
||||
it('should apply patches successfully', async () => {
|
||||
applyFilePatches.mockResolvedValue({ success: true, totalLines: 150 })
|
||||
|
||||
const response = await app.request('/api/files/test-repo/test.ts', {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
patches: [
|
||||
{ type: 'replace' as const, startLine: 10, content: 'new line\n' },
|
||||
],
|
||||
}),
|
||||
})
|
||||
const body = await response.json() as { success: boolean; totalLines: number }
|
||||
|
||||
expect(response.status).toBe(200)
|
||||
expect(body).toHaveProperty('success', true)
|
||||
expect(body).toHaveProperty('totalLines', 150)
|
||||
expect(applyFilePatches).toHaveBeenCalledWith('test-repo/test.ts', [
|
||||
{ type: 'replace', startLine: 10, content: 'new line\n' },
|
||||
])
|
||||
})
|
||||
|
||||
it('should return error when patch application fails', async () => {
|
||||
applyFilePatches.mockRejectedValue(new Error('Invalid patch'))
|
||||
|
||||
const response = await app.request('/api/files/test-repo/test.ts', {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
patches: [{ type: 'replace' as const, startLine: 999 }],
|
||||
}),
|
||||
})
|
||||
const body = await response.json() as { error: string }
|
||||
|
||||
expect(response.status).toBe(404)
|
||||
expect(body).toHaveProperty('error')
|
||||
})
|
||||
})
|
||||
|
||||
describe('Rename/Move', () => {
|
||||
it('should rename file successfully', async () => {
|
||||
renameOrMoveFile.mockResolvedValue(mockRenameResult)
|
||||
|
||||
const response = await app.request('/api/files/test-repo/old.ts', {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ newPath: 'test-repo/renamed.ts' }),
|
||||
})
|
||||
const body = await response.json() as FileInfo
|
||||
|
||||
expect(response.status).toBe(200)
|
||||
expect(body).toHaveProperty('name', 'renamed.ts')
|
||||
expect(body).toHaveProperty('path', 'test-repo/renamed.ts')
|
||||
expect(renameOrMoveFile).toHaveBeenCalledWith('test-repo/old.ts', {
|
||||
newPath: 'test-repo/renamed.ts',
|
||||
})
|
||||
})
|
||||
|
||||
it('should return error when rename fails', async () => {
|
||||
renameOrMoveFile.mockRejectedValue(new Error('File not found'))
|
||||
|
||||
const response = await app.request('/api/files/test-repo/nonexistent.ts', {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ newPath: 'test-repo/new.ts' }),
|
||||
})
|
||||
const body = await response.json() as { error: string }
|
||||
|
||||
expect(response.status).toBe(404)
|
||||
expect(body).toHaveProperty('error')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('Path Traversal Protection', () => {
|
||||
const mockFileInfo: FileInfo = {
|
||||
name: 'test.txt',
|
||||
path: 'safe-path/test.txt',
|
||||
isDirectory: false,
|
||||
size: 100,
|
||||
mimeType: 'text/plain',
|
||||
content: '',
|
||||
lastModified: new Date(),
|
||||
}
|
||||
|
||||
it('should reject path with ../ segments via service error', async () => {
|
||||
getFile.mockRejectedValue({ message: 'Path traversal detected', statusCode: 403 })
|
||||
|
||||
const response = await app.request('/api/files/../../../etc/passwd')
|
||||
const body = await response.json() as { error: string }
|
||||
|
||||
expect(response.status).toBe(403)
|
||||
expect(body.error).toContain('Path traversal detected')
|
||||
})
|
||||
|
||||
it('should reject encoded path traversal attempts', async () => {
|
||||
getFile.mockRejectedValue({ message: 'Path traversal detected', statusCode: 403 })
|
||||
|
||||
const response = await app.request('/api/files/test-repo/..%2Fetc')
|
||||
const body = await response.json() as { error: string }
|
||||
|
||||
expect(response.status).toBe(403)
|
||||
expect(body.error).toContain('Path traversal detected')
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -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
|
||||
@@ -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
|
||||
```
|
||||
@@ -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'
|
||||
```
|
||||
@@ -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
|
||||
@@ -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.
|
||||
@@ -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
|
||||
```
|
||||
@@ -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.
|
||||
@@ -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 |
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||

|
||||
|
||||
### 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
|
||||
|
||||

|
||||
|
||||
### Branches Tab
|
||||
|
||||
- List all local and remote branches
|
||||
- Create new branches from current HEAD
|
||||
- Switch branches (checks out the branch)
|
||||
- Delete local branches
|
||||
|
||||

|
||||
|
||||
## 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
|
||||
|
||||

|
||||
|
||||
## 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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
- 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.
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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 |
@@ -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 -->
|
||||

|
||||
|
||||
## 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
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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)
|
||||
@@ -42,4 +42,24 @@ export async function applyFilePatches(path: string, patches: PatchOperation[]):
|
||||
}
|
||||
|
||||
return response.json()
|
||||
}
|
||||
|
||||
export async function downloadDirectoryAsZip(path: string): Promise<void> {
|
||||
const response = await fetch(`${API_BASE_URL}/api/files/${path}/download-zip`)
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json()
|
||||
throw new Error(error.error || 'Failed to download directory')
|
||||
}
|
||||
|
||||
const blob = await response.blob()
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
const dirName = path.split('/').pop() || 'download'
|
||||
a.download = `${dirName}.zip`
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
document.body.removeChild(a)
|
||||
window.URL.revokeObjectURL(url)
|
||||
}
|
||||
@@ -534,7 +534,7 @@ useEffect(() => {
|
||||
{!isMobile && (
|
||||
<div className="flex-1 overflow-y-auto min-h-0 h-full">
|
||||
{selectedFile && !selectedFile.isDirectory ? (
|
||||
<FilePreview file={selectedFile} />
|
||||
<FilePreview key={selectedFile.path} file={selectedFile} />
|
||||
) : (
|
||||
<div className="flex items-center justify-center h-full text-muted-foreground">
|
||||
Select a file to preview
|
||||
@@ -633,7 +633,7 @@ useEffect(() => {
|
||||
{!isMobile && (
|
||||
<div className="flex-1 overflow-y-auto min-h-0 ">
|
||||
{selectedFile && !selectedFile.isDirectory ? (
|
||||
<FilePreview file={selectedFile} />
|
||||
<FilePreview key={selectedFile.path} file={selectedFile} />
|
||||
) : (
|
||||
<div className="flex items-center justify-center h-64 text-muted-foreground">
|
||||
Select a file to preview
|
||||
|
||||
@@ -3,23 +3,35 @@ import { FileBrowser } from './FileBrowser'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { PathDisplay } from '@/components/ui/path-display'
|
||||
import { FullscreenSheet, FullscreenSheetHeader, FullscreenSheetContent } from '@/components/ui/fullscreen-sheet'
|
||||
import { X } from 'lucide-react'
|
||||
import { DownloadDialog } from '@/components/ui/download-dialog'
|
||||
import { X, Download } from 'lucide-react'
|
||||
import { GPU_ACCELERATED_STYLE, MODAL_TRANSITION_MS } from '@/lib/utils'
|
||||
import { useSwipeBack } from '@/hooks/useMobile'
|
||||
import { downloadDirectoryAsZip } from '@/api/files'
|
||||
import { downloadRepo } from '@/api/repos'
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu'
|
||||
|
||||
interface FileBrowserSheetProps {
|
||||
isOpen: boolean
|
||||
onClose: () => void
|
||||
basePath?: string
|
||||
repoName?: string
|
||||
repoId?: number
|
||||
initialSelectedFile?: string
|
||||
}
|
||||
|
||||
export const FileBrowserSheet = memo(function FileBrowserSheet({ isOpen, onClose, basePath = '', repoName, initialSelectedFile }: FileBrowserSheetProps) {
|
||||
export const FileBrowserSheet = memo(function FileBrowserSheet({ isOpen, onClose, basePath = '', repoName, repoId, initialSelectedFile }: FileBrowserSheetProps) {
|
||||
const normalizedBasePath = basePath || '.'
|
||||
const [isEditing, setIsEditing] = useState(false)
|
||||
const [displayPath, setDisplayPath] = useState<string>('/')
|
||||
const [shouldRender, setShouldRender] = useState(false)
|
||||
const [currentPath, setCurrentPath] = useState<string>(basePath || '.')
|
||||
const [downloadDialog, setDownloadDialog] = useState<{ type: 'directory' | 'repository' } | null>(null)
|
||||
const containerRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
const { bind, swipeStyles } = useSwipeBack(onClose, {
|
||||
@@ -42,11 +54,14 @@ export const FileBrowserSheet = memo(function FileBrowserSheet({ isOpen, onClose
|
||||
const handleDirectoryLoad = useCallback((info: { workspaceRoot?: string; currentPath: string }) => {
|
||||
if (!info.currentPath || info.currentPath === '.' || info.currentPath === '') {
|
||||
setDisplayPath('/')
|
||||
setCurrentPath(basePath || '.')
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
setCurrentPath(info.currentPath)
|
||||
|
||||
const pathParts = info.currentPath.split('/').filter(Boolean)
|
||||
|
||||
|
||||
if (repoName) {
|
||||
const repoIndex = pathParts.findIndex(p => p === repoName || p.startsWith(repoName + '-'))
|
||||
if (repoIndex >= 0) {
|
||||
@@ -58,7 +73,21 @@ export const FileBrowserSheet = memo(function FileBrowserSheet({ isOpen, onClose
|
||||
} else {
|
||||
setDisplayPath('/' + pathParts.join('/'))
|
||||
}
|
||||
}, [repoName])
|
||||
}, [repoName, basePath])
|
||||
|
||||
const handleDownloadDirectory = useCallback(async () => {
|
||||
if (!currentPath) return
|
||||
await downloadDirectoryAsZip(currentPath)
|
||||
}, [currentPath])
|
||||
|
||||
const handleDownloadRepo = useCallback(async () => {
|
||||
if (!repoId || !repoName) return
|
||||
await downloadRepo(repoId, repoName)
|
||||
}, [repoId, repoName])
|
||||
|
||||
const handleOpenDownloadDialog = (type: 'directory' | 'repository') => {
|
||||
setDownloadDialog({ type })
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const handleEscape = (e: KeyboardEvent) => {
|
||||
@@ -98,30 +127,55 @@ export const FileBrowserSheet = memo(function FileBrowserSheet({ isOpen, onClose
|
||||
>
|
||||
<FullscreenSheet style={{ ...GPU_ACCELERATED_STYLE, ...swipeStyles }}>
|
||||
<FullscreenSheetHeader className="px-4 py-1">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
{(displayPath === '/' || !repoName) && (
|
||||
<h1 className="text-sm font-semibold text-foreground">
|
||||
{repoName || 'Workspace Files'}
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<div className="flex items-center gap-2 min-w-0 flex-1 overflow-hidden">
|
||||
{(displayPath === '/' || !repoName) && repoName && (
|
||||
<h1 className="text-sm font-semibold text-foreground shrink-0 truncate max-w-[150px]">
|
||||
{repoName}
|
||||
</h1>
|
||||
)}
|
||||
<PathDisplay path={displayPath} maxSegments={3} />
|
||||
<PathDisplay path={displayPath} maxSegments={2} className="truncate" />
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{repoId && !isEditing && (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="text-muted-foreground hover:text-foreground hover:bg-muted transition-all duration-200"
|
||||
>
|
||||
<Download className="w-5 h-5" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem onClick={() => handleOpenDownloadDialog('directory')}>
|
||||
<Download className="w-4 h-4 mr-2" />
|
||||
Current Directory
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => handleOpenDownloadDialog('repository')}>
|
||||
<Download className="w-4 h-4 mr-2" />
|
||||
Entire Repository
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
)}
|
||||
{!isEditing && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={onClose}
|
||||
className="text-muted-foreground hover:text-foreground hover:bg-muted transition-all duration-200"
|
||||
>
|
||||
<X className="w-5 h-5" />
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
{!isEditing && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={onClose}
|
||||
className="text-muted-foreground hover:text-foreground hover:bg-muted transition-all duration-200"
|
||||
>
|
||||
<X className="w-5 h-5" />
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</FullscreenSheetHeader>
|
||||
|
||||
<FullscreenSheetContent>
|
||||
<FileBrowser
|
||||
<FileBrowser
|
||||
basePath={normalizedBasePath}
|
||||
embedded={true}
|
||||
initialSelectedFile={initialSelectedFile}
|
||||
@@ -129,6 +183,17 @@ export const FileBrowserSheet = memo(function FileBrowserSheet({ isOpen, onClose
|
||||
/>
|
||||
</FullscreenSheetContent>
|
||||
</FullscreenSheet>
|
||||
|
||||
<DownloadDialog
|
||||
open={downloadDialog !== null}
|
||||
onOpenChange={(open) => !open && setDownloadDialog(null)}
|
||||
onDownload={downloadDialog?.type === 'directory' ? handleDownloadDirectory : handleDownloadRepo}
|
||||
title={downloadDialog?.type === 'directory' ? 'Download Current Directory' : 'Download Repository'}
|
||||
description={downloadDialog?.type === 'directory'
|
||||
? 'This will create a ZIP archive of the current directory and all its contents.'
|
||||
: 'This will create a ZIP archive of the entire repository.'}
|
||||
itemName={downloadDialog?.type === 'directory' ? currentPath.split('/').pop() || 'Directory' : repoName || 'Repository'}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
@@ -22,7 +22,7 @@ interface FilePreviewProps {
|
||||
}
|
||||
|
||||
export const FilePreview = memo(function FilePreview({ file, hideHeader = false, isMobileModal = false, onCloseModal, onFileSaved, initialLineNumber }: FilePreviewProps) {
|
||||
const isMarkdownFile = file.name.endsWith('.md') || file.name.endsWith('.mdx') || file.mimeType === 'text/markdown'
|
||||
const isMarkdownFile = file.name.toLowerCase().endsWith('.md') || file.name.toLowerCase().endsWith('.mdx') || file.mimeType === 'text/markdown'
|
||||
|
||||
const [viewMode, setViewMode] = useState<'preview' | 'edit'>('preview')
|
||||
const [editContent, setEditContent] = useState('')
|
||||
@@ -33,6 +33,7 @@ export const FilePreview = memo(function FilePreview({ file, hideHeader = false,
|
||||
const [markdownPreview, setMarkdownPreview] = useState(isMarkdownFile)
|
||||
const [isLoadingAllContent, setIsLoadingAllContent] = useState(false)
|
||||
const [fullContentLoaded, setFullContentLoaded] = useState(false)
|
||||
const [fullContent, setFullContent] = useState<string | null>(null)
|
||||
const virtualizedRef = useRef<VirtualizedTextViewHandle>(null)
|
||||
const contentRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
@@ -41,18 +42,25 @@ export const FilePreview = memo(function FilePreview({ file, hideHeader = false,
|
||||
|
||||
useEffect(() => {
|
||||
setFullContentLoaded(false)
|
||||
}, [file.path])
|
||||
setMarkdownPreview(isMarkdownFile)
|
||||
setFullContent(null)
|
||||
}, [file.path, isMarkdownFile])
|
||||
|
||||
useEffect(() => {
|
||||
if (shouldVirtualize && isMarkdownFile && markdownPreview && !isMarkdownTooLarge && !fullContentLoaded) {
|
||||
const loadContent = async () => {
|
||||
if (!virtualizedRef.current) return
|
||||
setIsLoadingAllContent(true)
|
||||
await virtualizedRef.current.loadAll()
|
||||
setFullContentLoaded(true)
|
||||
setIsLoadingAllContent(false)
|
||||
try {
|
||||
await virtualizedRef.current.loadAll()
|
||||
setFullContentLoaded(true)
|
||||
} catch {
|
||||
setFullContentLoaded(false)
|
||||
} finally {
|
||||
setIsLoadingAllContent(false)
|
||||
}
|
||||
}
|
||||
const timer = setTimeout(loadContent, 50)
|
||||
const timer = setTimeout(loadContent, 0)
|
||||
return () => clearTimeout(timer)
|
||||
}
|
||||
}, [shouldVirtualize, isMarkdownFile, markdownPreview, isMarkdownTooLarge, fullContentLoaded])
|
||||
@@ -191,7 +199,6 @@ export const FilePreview = memo(function FilePreview({ file, hideHeader = false,
|
||||
|
||||
if (shouldVirtualize && isTextFile) {
|
||||
const showMarkdownPreview = isMarkdownFile && markdownPreview && viewMode !== 'edit'
|
||||
const fullContent = virtualizedRef.current?.getFullContent()
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -203,6 +210,7 @@ export const FilePreview = memo(function FilePreview({ file, hideHeader = false,
|
||||
editable={viewMode === 'edit'}
|
||||
onSaveStateChange={handleVirtualizedSaveStateChange}
|
||||
onSave={handleVirtualizedSave}
|
||||
onContentLoaded={setFullContent}
|
||||
className="h-full"
|
||||
initialLineNumber={initialLineNumber}
|
||||
lineWrap={lineWrap}
|
||||
|
||||
@@ -76,6 +76,7 @@ export function FilePreviewDialog({ isOpen, onClose, filePath, repoBasePath, onF
|
||||
</div>
|
||||
) : file ? (
|
||||
<FilePreview
|
||||
key={file.path}
|
||||
file={file}
|
||||
hideHeader={false}
|
||||
isMobileModal={true}
|
||||
|
||||
@@ -56,6 +56,7 @@ export const MobileFilePreviewModal = memo(function MobileFilePreviewModal({
|
||||
<FullscreenSheet style={{ ...GPU_ACCELERATED_STYLE, ...swipeStyles }}>
|
||||
<div className={`h-full overflow-hidden bg-background pt-safe ${showFilePreviewHeader ? "" : "pb-8"}`}>
|
||||
<FilePreview
|
||||
key={localFile.path}
|
||||
file={localFile}
|
||||
hideHeader={!showFilePreviewHeader}
|
||||
isMobileModal={showFilePreviewHeader}
|
||||
|
||||
@@ -92,9 +92,12 @@ export const PromptInput = forwardRef<PromptInputHandle, PromptInputProps>(funct
|
||||
const [selectedAgent, setSelectedAgent] = useState<string | null>(null)
|
||||
const [localMode, setLocalMode] = useState<string | null>(null)
|
||||
const [isFocused, setIsFocused] = useState(false)
|
||||
const [isTogglingRecording, setIsTogglingRecording] = useState(false)
|
||||
const lastAddedTranscriptRef = useRef('')
|
||||
|
||||
const {
|
||||
isRecording,
|
||||
isProcessing,
|
||||
startRecording,
|
||||
stopRecording,
|
||||
abortRecording,
|
||||
@@ -104,7 +107,7 @@ export const PromptInput = forwardRef<PromptInputHandle, PromptInputProps>(funct
|
||||
transcript,
|
||||
clear: clearSTT,
|
||||
} = useSTT()
|
||||
|
||||
|
||||
const textareaRef = useRef<HTMLTextAreaElement>(null)
|
||||
const fileInputRef = useRef<HTMLInputElement>(null)
|
||||
|
||||
@@ -356,9 +359,14 @@ export const PromptInput = forwardRef<PromptInputHandle, PromptInputProps>(funct
|
||||
if (isRecording) {
|
||||
stopRecording()
|
||||
} else {
|
||||
await startRecording()
|
||||
if (textareaRef.current) {
|
||||
textareaRef.current.blur()
|
||||
setIsTogglingRecording(true)
|
||||
try {
|
||||
await startRecording()
|
||||
if (textareaRef.current) {
|
||||
textareaRef.current.blur()
|
||||
}
|
||||
} catch {
|
||||
setIsTogglingRecording(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -367,13 +375,30 @@ export const PromptInput = forwardRef<PromptInputHandle, PromptInputProps>(funct
|
||||
const textToUse = transcript || interimTranscript
|
||||
if (!isRecording && textToUse && textToUse !== 'Processing...' && textToUse !== 'Recording...') {
|
||||
const trimmedTranscript = textToUse.trim()
|
||||
if (trimmedTranscript && (prompt === '' || prompt === 'Processing...' || prompt === 'Recording...')) {
|
||||
setPrompt(trimmedTranscript)
|
||||
if (trimmedTranscript && trimmedTranscript !== lastAddedTranscriptRef.current) {
|
||||
if (prompt === '' || prompt === 'Processing...' || prompt === 'Recording...') {
|
||||
setPrompt(trimmedTranscript)
|
||||
} else {
|
||||
setPrompt(prev => `${prev} ${trimmedTranscript}`)
|
||||
}
|
||||
lastAddedTranscriptRef.current = trimmedTranscript
|
||||
textareaRef.current?.focus()
|
||||
}
|
||||
}
|
||||
}, [isRecording, interimTranscript, transcript, prompt])
|
||||
|
||||
useEffect(() => {
|
||||
if (isRecording && isTogglingRecording) {
|
||||
setIsTogglingRecording(false)
|
||||
}
|
||||
}, [isRecording, isTogglingRecording])
|
||||
|
||||
useEffect(() => {
|
||||
if (isTogglingRecording) {
|
||||
lastAddedTranscriptRef.current = ''
|
||||
}
|
||||
}, [isTogglingRecording])
|
||||
|
||||
const addImageAttachment = (file: File) => {
|
||||
const generateId = () => {
|
||||
if (typeof crypto !== 'undefined' && crypto.randomUUID) {
|
||||
@@ -859,7 +884,7 @@ return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleVoiceToggle}
|
||||
disabled={disabled}
|
||||
disabled={disabled || isProcessing}
|
||||
className={`hidden md:flex p-2 rounded-lg transition-all duration-200 active:scale-95 hover:scale-105 shadow-md border items-center justify-center ${
|
||||
isRecording
|
||||
? 'bg-gradient-to-br from-red-600 to-red-700 hover:from-red-500 hover:to-red-600 text-destructive-foreground border-red-500/60 animate-pulse'
|
||||
@@ -867,21 +892,37 @@ return (
|
||||
}`}
|
||||
title={isRecording ? 'Stop recording' : 'Voice input'}
|
||||
>
|
||||
{isRecording ? <SquareFill className="w-5 h-5" /> : <Mic className="w-5 h-5" />}
|
||||
{isTogglingRecording && !isRecording ? (
|
||||
<div className="w-5 h-5 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent" />
|
||||
) : isProcessing && !isRecording ? (
|
||||
<div className="w-5 h-5 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent" />
|
||||
) : isRecording ? (
|
||||
<SquareFill className="w-5 h-5" />
|
||||
) : (
|
||||
<Mic className="w-5 h-5" />
|
||||
)}
|
||||
</button>
|
||||
)}
|
||||
{isMobile && !prompt.trim() && imageAttachments.length === 0 && sttEnabled && sttSupported && !hasPendingPermissionForSession ? (
|
||||
<button
|
||||
onClick={handleVoiceToggle}
|
||||
disabled={disabled}
|
||||
disabled={disabled || isProcessing}
|
||||
className={`px-4 py-2 rounded-lg transition-all duration-200 active:scale-95 flex items-center justify-center min-w-[52px] ${
|
||||
isRecording
|
||||
isRecording || isTogglingRecording || (isProcessing && !isRecording)
|
||||
? 'bg-gradient-to-br from-red-600 to-red-700 hover:from-red-500 hover:to-red-600 text-destructive-foreground border-2 border-red-500/60 shadow-lg shadow-red-500/30 animate-pulse'
|
||||
: 'bg-primary hover:bg-primary/90 text-primary-foreground border border-white/30'
|
||||
}`}
|
||||
title={isRecording ? 'Stop recording' : 'Voice input'}
|
||||
>
|
||||
{isRecording ? <SquareFill className="w-5 h-5" /> : <Mic className="w-5 h-5" />}
|
||||
{isTogglingRecording && !isRecording ? (
|
||||
<div className="w-5 h-5 animate-spin rounded-full border-2 border-white border-t-transparent" />
|
||||
) : isProcessing && !isRecording ? (
|
||||
<div className="w-5 h-5 animate-spin rounded-full border-2 border-white border-t-transparent" />
|
||||
) : isRecording ? (
|
||||
<SquareFill className="w-5 h-5" />
|
||||
) : (
|
||||
<Mic className="w-5 h-5" />
|
||||
)}
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
|
||||
@@ -8,6 +8,7 @@ import { downloadRepo } from "@/api/repos";
|
||||
import { showToast } from "@/lib/toast";
|
||||
import type { GitStatusResponse } from "@/types/git";
|
||||
import { SourceControlPanel } from "@/components/source-control/SourceControlPanel";
|
||||
import { DownloadDialog } from "@/components/ui/download-dialog";
|
||||
|
||||
interface RepoCardProps {
|
||||
repo: {
|
||||
@@ -36,7 +37,7 @@ export function RepoCard({
|
||||
gitStatus,
|
||||
}: RepoCardProps) {
|
||||
const navigate = useNavigate();
|
||||
const [isDownloading, setIsDownloading] = useState(false);
|
||||
const [showDownloadDialog, setShowDownloadDialog] = useState(false);
|
||||
const [showSourceControl, setShowSourceControl] = useState(false);
|
||||
|
||||
const repoName = repo.repoUrl
|
||||
@@ -63,6 +64,15 @@ export function RepoCard({
|
||||
action();
|
||||
};
|
||||
|
||||
const handleDownload = async () => {
|
||||
try {
|
||||
await downloadRepo(repo.id, repoName);
|
||||
showToast.success("Download complete");
|
||||
} catch (error: unknown) {
|
||||
showToast.error(error instanceof Error ? error.message : "Download failed");
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
onClick={handleCardClick}
|
||||
@@ -155,25 +165,11 @@ export function RepoCard({
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
onClick={(e) => handleActionClick(e, async () => {
|
||||
setIsDownloading(true);
|
||||
try {
|
||||
await downloadRepo(repo.id, repoName);
|
||||
showToast.success("Download complete");
|
||||
} catch (error: unknown) {
|
||||
showToast.error(error instanceof Error ? error.message : "Download failed");
|
||||
} finally {
|
||||
setIsDownloading(false);
|
||||
}
|
||||
})}
|
||||
disabled={!isReady || isDownloading}
|
||||
onClick={(e) => handleActionClick(e, () => setShowDownloadDialog(true))}
|
||||
disabled={!isReady}
|
||||
className="h-8 w-8 p-0"
|
||||
>
|
||||
{isDownloading ? (
|
||||
<Loader2 className="w-4 h-4 animate-spin" />
|
||||
) : (
|
||||
<Download className="w-4 h-4" />
|
||||
)}
|
||||
<Download className="w-4 h-4" />
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
@@ -203,6 +199,14 @@ export function RepoCard({
|
||||
isRepoWorktree={repo.isWorktree}
|
||||
repoName={repoName}
|
||||
/>
|
||||
<DownloadDialog
|
||||
open={showDownloadDialog}
|
||||
onOpenChange={setShowDownloadDialog}
|
||||
onDownload={handleDownload}
|
||||
title="Download Repository"
|
||||
description="This will create a ZIP archive of the entire repository."
|
||||
itemName={repoName}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -78,7 +78,7 @@ export function AccountSettings() {
|
||||
|
||||
const changePasswordMutation = useMutation({
|
||||
mutationFn: async ({ currentPassword, newPassword }: { currentPassword: string; newPassword: string }) => {
|
||||
const response = await changePassword({ currentPassword, newPassword })
|
||||
const response = await changePassword({ currentPassword, newPassword, revokeOtherSessions: true })
|
||||
if (response.error) {
|
||||
throw new Error(response.error.message || 'Failed to change password')
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
import { useState } from 'react'
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Download, Loader2, Archive } from 'lucide-react'
|
||||
|
||||
interface DownloadDialogProps {
|
||||
open: boolean
|
||||
onOpenChange: (open: boolean) => void
|
||||
onDownload: () => Promise<void>
|
||||
title: string
|
||||
description: string
|
||||
itemName: string
|
||||
}
|
||||
|
||||
export function DownloadDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
onDownload,
|
||||
title,
|
||||
description,
|
||||
itemName,
|
||||
}: DownloadDialogProps) {
|
||||
const [isDownloading, setIsDownloading] = useState(false)
|
||||
const [isConfirmed, setIsConfirmed] = useState(false)
|
||||
|
||||
const handleConfirm = async () => {
|
||||
setIsConfirmed(true)
|
||||
setIsDownloading(true)
|
||||
try {
|
||||
await onDownload()
|
||||
} catch (error) {
|
||||
console.error('Download failed:', error)
|
||||
} finally {
|
||||
setIsDownloading(false)
|
||||
onOpenChange(false)
|
||||
setIsConfirmed(false)
|
||||
}
|
||||
}
|
||||
|
||||
const handleCancel = () => {
|
||||
if (isDownloading) return
|
||||
onOpenChange(false)
|
||||
setIsConfirmed(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={handleCancel}>
|
||||
<DialogContent className="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="flex items-center gap-2">
|
||||
{isDownloading ? (
|
||||
<Loader2 className="w-5 h-5 animate-spin" />
|
||||
) : (
|
||||
<Archive className="w-5 h-5" />
|
||||
)}
|
||||
{title}
|
||||
</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="space-y-4 py-4">
|
||||
{!isDownloading && (
|
||||
<DialogDescription>
|
||||
{description}
|
||||
</DialogDescription>
|
||||
)}
|
||||
|
||||
<div className="flex items-center gap-3 p-3 bg-muted rounded-md">
|
||||
<Archive className="w-8 h-8 text-muted-foreground" />
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-sm font-medium">{isConfirmed ? 'Processing...' : itemName}</p>
|
||||
{isDownloading && (
|
||||
<p className="text-xs text-muted-foreground mt-1">
|
||||
Creating ZIP archive, please wait...
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{isDownloading && (
|
||||
<div className="space-y-2">
|
||||
<div className="h-2 bg-muted rounded-full overflow-hidden">
|
||||
<div className="h-full bg-primary animate-progress w-full" />
|
||||
</div>
|
||||
<p className="text-xs text-center text-muted-foreground">
|
||||
Download starting...
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<DialogFooter >
|
||||
{!isDownloading && !isConfirmed && (
|
||||
<div className='flex gap-2 w-full'>
|
||||
<Button variant="outline" onClick={handleCancel} className="flex-1">
|
||||
Cancel
|
||||
</Button>
|
||||
<Button onClick={handleConfirm} className="gap-2 flex-1">
|
||||
<Download className="w-4 h-4" />
|
||||
Download
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
@@ -13,6 +13,7 @@ interface VirtualizedTextViewProps {
|
||||
className?: string
|
||||
initialLineNumber?: number
|
||||
lineWrap?: boolean
|
||||
onContentLoaded?: (content: string) => void
|
||||
}
|
||||
|
||||
export interface VirtualizedTextViewHandle {
|
||||
@@ -141,6 +142,7 @@ export const VirtualizedTextView = forwardRef<VirtualizedTextViewHandle, Virtual
|
||||
className = '',
|
||||
initialLineNumber,
|
||||
lineWrap = false,
|
||||
onContentLoaded,
|
||||
}, ref) {
|
||||
const containerRef = useRef<HTMLDivElement>(null)
|
||||
const scrollTopRef = useRef(0)
|
||||
@@ -192,6 +194,12 @@ export const VirtualizedTextView = forwardRef<VirtualizedTextViewHandle, Virtual
|
||||
onSaveStateChange?.(hasUnsavedChanges)
|
||||
}, [hasUnsavedChanges, onSaveStateChange])
|
||||
|
||||
useEffect(() => {
|
||||
if (isFullyLoaded && fullContent && onContentLoaded) {
|
||||
onContentLoaded(fullContent)
|
||||
}
|
||||
}, [isFullyLoaded, fullContent, onContentLoaded])
|
||||
|
||||
useEffect(() => {
|
||||
loadedBufferRef.current = { start: 0, end: 0 }
|
||||
heightCacheRef.current.clear()
|
||||
|
||||
@@ -78,6 +78,7 @@ export function useSTT(userId = 'default') {
|
||||
|
||||
rec.onStart(() => {
|
||||
setIsRecording(true)
|
||||
setIsProcessing(false)
|
||||
setState('listening')
|
||||
setInterimTranscript('')
|
||||
})
|
||||
@@ -91,6 +92,7 @@ export function useSTT(userId = 'default') {
|
||||
recorder.setOnStateChange((recState) => {
|
||||
if (recState === 'recording') {
|
||||
setIsRecording(true)
|
||||
setIsProcessing(false)
|
||||
setState('listening')
|
||||
setInterimTranscript('Recording...')
|
||||
} else if (recState === 'stopped') {
|
||||
|
||||
@@ -357,3 +357,20 @@ body {
|
||||
.scrollbar-thin::-webkit-scrollbar-thumb:hover {
|
||||
background-color: var(--color-muted-foreground);
|
||||
}
|
||||
|
||||
/* Progress bar animation for download dialog */
|
||||
@keyframes progress {
|
||||
0% {
|
||||
width: 0%;
|
||||
}
|
||||
50% {
|
||||
width: 70%;
|
||||
}
|
||||
100% {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.animate-progress {
|
||||
animation: progress 2s ease-in-out infinite;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ const getBaseUrl = () => {
|
||||
if (typeof window !== 'undefined') {
|
||||
return `${window.location.origin}/api/auth`
|
||||
}
|
||||
return 'http://localhost:5001/api/auth'
|
||||
return 'http://localhost:5003/api/auth'
|
||||
}
|
||||
|
||||
export const authClient = createAuthClient({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState } from 'react'
|
||||
import { Link, useLoaderData } from 'react-router-dom'
|
||||
import { useLoaderData } from 'react-router-dom'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { z } from 'zod'
|
||||
@@ -87,7 +87,6 @@ export function Login() {
|
||||
alt="OpenCode"
|
||||
className="h-8 w-auto"
|
||||
/>
|
||||
<p className="text-sm text-muted-foreground">Sign in to continue</p>
|
||||
</div>
|
||||
|
||||
<div className="rounded-lg border border-border bg-card p-6 space-y-4">
|
||||
@@ -204,7 +203,7 @@ export function Login() {
|
||||
<Input
|
||||
id="email"
|
||||
type="email"
|
||||
placeholder="you@example.com"
|
||||
placeholder=""
|
||||
className="bg-input border-border focus:border-primary"
|
||||
{...register('email')}
|
||||
aria-invalid={!!errors.email}
|
||||
@@ -218,7 +217,7 @@ export function Login() {
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
placeholder="Enter your password"
|
||||
placeholder=""
|
||||
className="bg-input border-border focus:border-primary"
|
||||
{...register('password')}
|
||||
aria-invalid={!!errors.password}
|
||||
@@ -239,14 +238,7 @@ export function Login() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{config.registrationEnabled && (
|
||||
<p className="text-center text-sm text-muted-foreground">
|
||||
Don't have an account?{' '}
|
||||
<Link to="/register" className="text-primary hover:underline transition-colors">
|
||||
Sign up
|
||||
</Link>
|
||||
</p>
|
||||
)}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -237,6 +237,7 @@ export function RepoDetail() {
|
||||
onClose={() => setFileBrowserOpen(false)}
|
||||
basePath={repo.localPath}
|
||||
repoName={displayName}
|
||||
repoId={repoId}
|
||||
/>
|
||||
|
||||
<RepoMcpDialog
|
||||
|
||||
@@ -521,6 +521,7 @@ export function SessionDetail() {
|
||||
onClose={handleFileBrowserClose}
|
||||
basePath={repo.localPath}
|
||||
repoName={repo.repoUrl?.split("/").pop()?.replace(".git", "") || repo.localPath || "Repository"}
|
||||
repoId={repoId}
|
||||
initialSelectedFile={selectedFilePath}
|
||||
/>
|
||||
|
||||
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
site_name: OpenCode Manager
|
||||
site_url: https://chriswritescode-dev.github.io/opencode-manager
|
||||
repo_url: https://github.com/chriswritescode-dev/opencode-manager
|
||||
repo_name: opencode-manager
|
||||
|
||||
theme:
|
||||
name: material
|
||||
palette:
|
||||
- scheme: slate
|
||||
primary: blue grey
|
||||
accent: cyan
|
||||
toggle:
|
||||
icon: material/brightness-7
|
||||
name: Switch to light mode
|
||||
- scheme: default
|
||||
primary: blue grey
|
||||
accent: cyan
|
||||
toggle:
|
||||
icon: material/brightness-4
|
||||
name: Switch to dark mode
|
||||
features:
|
||||
- navigation.sections
|
||||
- navigation.expand
|
||||
- navigation.top
|
||||
- navigation.tracking
|
||||
- navigation.tabs
|
||||
- navigation.instant
|
||||
- search.highlight
|
||||
- search.suggest
|
||||
- content.code.copy
|
||||
- content.code.annotate
|
||||
- toc.follow
|
||||
|
||||
nav:
|
||||
- Home: index.md
|
||||
- Getting Started:
|
||||
- Installation: getting-started/installation.md
|
||||
- Quick Start: getting-started/quickstart.md
|
||||
- First Run Setup: getting-started/first-run.md
|
||||
- Features:
|
||||
- Overview: features/overview.md
|
||||
- Repository & Git: features/git.md
|
||||
- File Browser: features/files.md
|
||||
- Chat & Sessions: features/chat.md
|
||||
- AI Configuration: features/ai-config.md
|
||||
- MCP Servers: features/mcp.md
|
||||
- Text-to-Speech: features/tts.md
|
||||
- Mobile & PWA: features/mobile.md
|
||||
- Configuration:
|
||||
- Environment Variables: configuration/environment.md
|
||||
- Authentication: configuration/authentication.md
|
||||
- OAuth Providers: configuration/oauth.md
|
||||
- Docker: configuration/docker.md
|
||||
- Development:
|
||||
- Local Setup: development/setup.md
|
||||
- Contributing: development/contributing.md
|
||||
- Troubleshooting: troubleshooting.md
|
||||
|
||||
markdown_extensions:
|
||||
- pymdownx.highlight:
|
||||
anchor_linenums: true
|
||||
- pymdownx.superfences
|
||||
- admonition
|
||||
- pymdownx.details
|
||||
- pymdownx.tabbed:
|
||||
alternate_style: true
|
||||
- tables
|
||||
- attr_list
|
||||
|
||||
extra_css:
|
||||
- stylesheets/extra.css
|
||||
|
||||
extra:
|
||||
social:
|
||||
- icon: fontawesome/brands/github
|
||||
link: https://github.com/chriswritescode-dev/opencode-manager
|
||||
@@ -64,6 +64,7 @@ export const ALLOWED_MIME_TYPES = [
|
||||
'image/svg+xml',
|
||||
'application/pdf',
|
||||
'application/zip',
|
||||
'text/markdown',
|
||||
] as const
|
||||
|
||||
export const GIT_PROVIDERS = {
|
||||
|
||||
@@ -102,7 +102,7 @@ export const ENV = {
|
||||
DISCORD_CLIENT_SECRET: process.env.DISCORD_CLIENT_SECRET,
|
||||
PASSKEY_RP_ID: getEnvString('PASSKEY_RP_ID', 'localhost'),
|
||||
PASSKEY_RP_NAME: getEnvString('PASSKEY_RP_NAME', 'OpenCode Manager'),
|
||||
PASSKEY_ORIGIN: getEnvString('PASSKEY_ORIGIN', 'http://localhost:5001'),
|
||||
PASSKEY_ORIGIN: getEnvString('PASSKEY_ORIGIN', 'http://localhost:5003'),
|
||||
},
|
||||
} as const
|
||||
|
||||
|
||||
Reference in new issue
Block a user