mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
* feat(opencode): migrate OpenCode Manager to OpenCode 2 Port the backend lifecycle, generated plugins, event aggregation, schedules, worktrees, provider credentials, MCP, config handling, the frontend chat model, and the ocm CLI to OpenCode 2. Adopt @opencode/client 2.0.15 as the single typed V2 API contract, require OpenCode 2.0.0 or newer (pinned 2.0.15), and delete every V1-only code path. * refactor(opencode): reload config in place and drop v1 compatibility shims Route config/skill/AGENTS.md changes through the OpenCode location reload API instead of a full server restart, stop auto-resuming interrupted sessions, remove the restart coordinator and v1 MCP/version shims, and pin support to OpenCode >=2.0.15 <3.0.0. Adds integration-ready retries, service-mode launch, ocm-cli repo proxy, and new frontend form/MCP helpers. * refactor(opencode): consolidate v2 migration helpers and harden install, proxy, and session flows - extract shared semver and model-ref utilities, reuse across version checks - share the OpenCode release download script across Docker, entrypoint, dev setup - unify install/upgrade failure recovery and guard externally managed OPENCODE_BIN - scope the repo proxy location rewrite and surface ocm proxy errors - rework frontend session projection, permission lookup, and cache invalidation * fix(schedules): reject unavailable agents before creating a session * feat(opencode): add ocm install, schedule agent fallback, and session move guards
5.2 KiB
5.2 KiB
Local Development Setup
Guide for setting up a local development environment.
Prerequisites
- pnpm - Package manager (required for workspaces)
- Bun - Backend runtime
- OpenCode TUI 2.x, 2.0.15 or newer -
curl -fsSL https://opencode.ai/v2/install | bash
Installation
# Clone the repository
git clone https://github.com/chriswritescode-dev/opencode-manager.git
cd opencode-manager
# Install dependencies
pnpm install
The pnpm dev command automatically runs scripts/setup-dev.sh first, which:
- Checks prerequisites (pnpm, bun, git, OpenCode TUI)
- Creates required workspace directories
- Copies
.env.exampleto.envif missing
Then 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 migrations and queries
│ │ │ └── migrations/ # Numbered migration files
│ │ ├── types/ # TypeScript types
│ │ ├── utils/ # Utility functions
│ │ └── index.ts # Entry point
│ └── test/ # Backend tests
├── frontend/ # React + Vite SPA
│ ├── src/
│ │ ├── components/ # UI components
│ │ ├── pages/ # Page components
│ │ ├── hooks/ # Custom React hooks
│ │ ├── api/ # API client
│ │ ├── lib/ # Utilities
│ │ ├── stores/ # Zustand stores
│ │ └── contexts/ # React contexts
│ └── public/ # Static assets
├── shared/ # @opencode-manager/shared types and utilities
├── workspace/ # Runtime workspace for OpenCode
├── docs/ # Documentation
├── scripts/ # Build and utility scripts
├── Dockerfile # Docker image definition
└── docker-compose.yml # Docker Compose configuration
Available Scripts
Root Level
pnpm dev # Start both backend and frontend (runs setup-dev.sh first)
pnpm dev:backend # Start backend only
pnpm dev:frontend # Start frontend only
pnpm build # Build both packages
pnpm lint # Lint both packages
pnpm test # Run all tests
Backend
cd backend
bun --watch src/index.ts # Start with hot reload
pnpm test # Run tests (uses Vitest)
vitest <file> # Run single test file
vitest --ui # Test UI
vitest --coverage # Coverage report
eslint . --ext .ts # Lint
tsc --noEmit # TypeScript check
Frontend
cd frontend
pnpm dev # Start Vite dev server
pnpm build # Production build
pnpm lint # ESLint
pnpm typecheck # TypeScript check
Database
Using Bun's built-in SQLite (bun:sqlite) with numbered migrations.
Location
- Development:
./data/opencode.db - Docker:
/app/data/opencode.db
Schema Changes
- Add new migration file in
backend/src/db/migrations/(e.g.,007-new-feature.ts) - Export the migration in
backend/src/db/migrations/index.ts - Migrations run automatically on startup
Inspection
sqlite3 ./data/opencode.db
# Useful commands
.tables # List tables
.schema user # Show table schema
SELECT * FROM user; # View data
Testing
Running Tests
# All tests
cd backend && pnpm test
# Single file
cd backend && pnpm test src/services/repo.test.ts
# With UI
cd backend && pnpm test:ui
# With coverage
cd backend && pnpm test -- --coverage
Writing Tests
import { describe, it, expect } from 'vitest'
import { repoService } from '../src/services/repo'
describe('repoService', () => {
it('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 verbose debug logging:
# Add to .env
DEBUG=true
LOG_LEVEL=debug
Frontend
- Open browser DevTools (F12)
- Check Console for errors
- Check Network tab for API calls
- Use React DevTools extension
Building
Development Build
pnpm build
Production Build
NODE_ENV=production pnpm build
Docker Build
docker build -t opencode-manager .
Common Issues
Port Already in Use
# Find process using port
lsof -i :5003
# Kill process
kill -9 <PID>
Module Not Found
# Clear node_modules and reinstall
rm -rf node_modules
rm -rf */node_modules
pnpm install
TypeScript Errors
# Check types
pnpm typecheck
# Clear TypeScript cache
rm -rf */tsconfig.tsbuildinfo
Database Issues
# Reset database
rm -f data/opencode.db
pnpm dev # Database is recreated