mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
Initial release v0.2.5
This commit is contained in:
commit
bbf66c259b
158 files changed
+37115
No files matched your search
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
export BUN_INSTALL="$HOME/.bun"
|
||||
export PATH="$BUN_INSTALL/bin:$HOME/.opencode/bin:$HOME/.local/bin:$PATH"
|
||||
|
||||
echo "🔍 Checking Bun installation..."
|
||||
|
||||
if ! command -v bun >/dev/null 2>&1; then
|
||||
echo "❌ Bun not found. Installing..."
|
||||
curl -fsSL https://bun.sh/install | bash
|
||||
|
||||
if ! command -v bun >/dev/null 2>&1; then
|
||||
echo "❌ Failed to install Bun. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Bun installed successfully"
|
||||
else
|
||||
BUN_VERSION=$(bun --version 2>&1 || echo "unknown")
|
||||
echo "✅ Bun is installed (version: $BUN_VERSION)"
|
||||
fi
|
||||
|
||||
echo "🔍 Checking OpenCode installation..."
|
||||
|
||||
if ! command -v opencode >/dev/null 2>&1; then
|
||||
echo "⚠️ OpenCode not found in PATH"
|
||||
else
|
||||
OPENCODE_VERSION=$(opencode --version 2>&1 || echo "unknown")
|
||||
echo "✅ OpenCode is installed (version: $OPENCODE_VERSION)"
|
||||
fi
|
||||
|
||||
echo "🚀 Starting OpenCode WebUI Backend..."
|
||||
|
||||
exec "$@"
|
||||
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env bun
|
||||
|
||||
import { writeFile } from 'fs/promises'
|
||||
import { join, dirname } from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url))
|
||||
const OPENCODE_SERVER_URL = process.env.OPENCODE_SERVER_URL || 'http://localhost:5561'
|
||||
|
||||
async function generateOpenAPISpec() {
|
||||
console.log(`📥 Fetching OpenAPI spec from ${OPENCODE_SERVER_URL}/doc...`)
|
||||
|
||||
try {
|
||||
const response = await fetch(`${OPENCODE_SERVER_URL}/doc`, {
|
||||
headers: {
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}: ${response.statusText}`)
|
||||
}
|
||||
|
||||
const spec = await response.json()
|
||||
const outputPath = join(__dirname, '../frontend/src/api/opencode-spec.json')
|
||||
|
||||
await writeFile(outputPath, JSON.stringify(spec, null, 2))
|
||||
console.log(`✅ OpenAPI spec saved to ${outputPath}`)
|
||||
|
||||
return outputPath
|
||||
} catch (error) {
|
||||
console.error('❌ Failed to fetch OpenAPI spec:', error)
|
||||
console.error('\n💡 Make sure an OpenCode server is running.')
|
||||
console.error(' You can start one by opening a repo in the WebUI.')
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
async function generateTypeScript(specPath: string) {
|
||||
console.log('\n📝 Generating TypeScript types...')
|
||||
|
||||
const outputPath = join(__dirname, '../frontend/src/api/opencode-types.ts')
|
||||
const { spawnSync } = await import('child_process')
|
||||
|
||||
try {
|
||||
const result = spawnSync('npx', ['openapi-typescript', specPath, '-o', outputPath], {
|
||||
cwd: join(__dirname, '..'),
|
||||
stdio: 'inherit'
|
||||
})
|
||||
|
||||
if (result.status !== 0) {
|
||||
throw new Error(`openapi-typescript exited with code ${result.status}`)
|
||||
}
|
||||
|
||||
console.log(`✅ TypeScript types generated at ${outputPath}`)
|
||||
} catch (error) {
|
||||
console.error('❌ Failed to generate TypeScript types:', error)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
console.log('🚀 Generating OpenCode API types...\n')
|
||||
|
||||
const specPath = await generateOpenAPISpec()
|
||||
await generateTypeScript(specPath)
|
||||
|
||||
console.log('\n✨ Done!')
|
||||
}
|
||||
|
||||
main()
|
||||
Executable
+73
@@ -0,0 +1,73 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "🔍 Checking prerequisites..."
|
||||
|
||||
# Check if Node.js/Bun is installed
|
||||
if command -v bun &> /dev/null; then
|
||||
echo "✅ Bun is installed"
|
||||
NODE_CMD="bun"
|
||||
elif command -v node &> /dev/null; then
|
||||
echo "✅ Node.js is installed"
|
||||
NODE_CMD="node"
|
||||
else
|
||||
echo "❌ Neither Bun nor Node.js is installed. Please install one of them."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if Git is installed
|
||||
if ! git --version &> /dev/null; then
|
||||
echo "❌ Git is not installed. Please install Git and try again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Git is installed"
|
||||
|
||||
# Check if OpenCode TUI is installed
|
||||
if ! opencode --version &> /dev/null; then
|
||||
echo "❌ OpenCode TUI is not installed. Please install it with:"
|
||||
echo " npm install -g @opencode/tui"
|
||||
echo " or"
|
||||
echo " bun add -g @opencode/tui"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ OpenCode TUI is installed"
|
||||
|
||||
# Create workspace directory if it doesn't exist
|
||||
WORKSPACE_PATH="${HOME}/.opencode-workspace"
|
||||
if [ ! -d "$WORKSPACE_PATH" ]; then
|
||||
echo "📁 Creating workspace directory at $WORKSPACE_PATH..."
|
||||
mkdir -p "$WORKSPACE_PATH/repos"
|
||||
mkdir -p "$WORKSPACE_PATH/config"
|
||||
echo "✅ Workspace directory created"
|
||||
else
|
||||
echo "✅ Workspace directory exists"
|
||||
fi
|
||||
|
||||
# Install dependencies
|
||||
echo "📦 Installing dependencies..."
|
||||
if [ "$NODE_CMD" = "bun" ]; then
|
||||
bun install
|
||||
else
|
||||
npm install
|
||||
fi
|
||||
|
||||
echo "✅ Dependencies installed"
|
||||
|
||||
# Copy environment file if it doesn't exist
|
||||
if [ ! -f ".env" ]; then
|
||||
echo "📝 Creating environment file..."
|
||||
cp .env.example .env
|
||||
echo "✅ Environment file created from .env.example"
|
||||
else
|
||||
echo "✅ Environment file exists"
|
||||
fi
|
||||
|
||||
echo "✅ Dev environment ready!"
|
||||
echo ""
|
||||
echo "🚀 To start development:"
|
||||
echo " npm run dev # Start both backend and frontend"
|
||||
echo " npm run dev:backend # Start backend only"
|
||||
echo " npm run dev:frontend # Start frontend only"
|
||||
Reference in new issue
Block a user