Initial Release: OpenQode Public Alpha v1.3

This commit is contained in:
Gemini AI
2025-12-14 00:40:14 +04:00
Unverified
commit 8e8d80c110
119 changed files with 31174 additions and 0 deletions

View File

@@ -0,0 +1,109 @@
# OpenCode Binary Download Script
# Downloads the required opencode.exe binary for OpenQode
param(
[string]$BinaryUrl = "https://github.com/sst/opencode/releases/latest/download/opencode-windows-x64.exe",
[string]$BinaryPath = "",
[switch]$Force = $false,
[switch]$NonInteractive = $false
)
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$OpenQodeDir = Split-Path -Parent $ScriptDir
if (-not $BinaryPath) {
$BinaryPath = Join-Path $OpenQodeDir "bin\\opencode.exe"
}
# Back-compat variable names used below
$binaryUrl = $BinaryUrl
$binaryPath = $BinaryPath
Write-Host "OpenQode - Downloading OpenCode Binary" -ForegroundColor Cyan
Write-Host "======================================" -ForegroundColor Cyan
Write-Host ""
# Create bin directory if it doesn't exist
$BinDir = Split-Path -Parent $BinaryPath
if (-not (Test-Path $BinDir)) {
Write-Host "Creating bin directory..." -ForegroundColor Yellow
New-Item -ItemType Directory -Path $BinDir -Force | Out-Null
}
# Check if binary already exists
if (Test-Path $BinaryPath) {
if (-not $Force) {
Write-Host "opencode.exe already exists at: $BinaryPath" -ForegroundColor Yellow
Write-Host "Skipping download." -ForegroundColor Gray
return
}
if (-not $NonInteractive) {
$overwrite = Read-Host "opencode.exe already exists. Overwrite? (y/N)"
if ($overwrite -ne "y" -and $overwrite -ne "Y") {
Write-Host "Download cancelled." -ForegroundColor Yellow
return
}
} else {
Write-Host "Overwriting existing opencode.exe..." -ForegroundColor Yellow
}
}
Write-Host "Downloading OpenCode binary..." -ForegroundColor Green
Write-Host "URL: $binaryUrl" -ForegroundColor Gray
try {
# Download the file
Invoke-WebRequest -Uri $BinaryUrl -OutFile $BinaryPath -UseBasicParsing
if (-not (Test-Path $BinaryPath)) {
throw "Binary not found after download"
}
$fileSize = (Get-Item $BinaryPath).Length / 1MB
Write-Host "Download completed successfully!" -ForegroundColor Green
Write-Host "File size: $([math]::Round($fileSize, 2)) MB" -ForegroundColor White
Write-Host "Location: $BinaryPath" -ForegroundColor White
Write-Host ""
Write-Host "You can now run OpenQode using:" -ForegroundColor Cyan
Write-Host " .\\OpenQode.bat" -ForegroundColor White
Write-Host " .\\OpenQode.ps1" -ForegroundColor White
if (-not $NonInteractive) {
Write-Host ""
Write-Host "Press any key to exit..." -ForegroundColor Cyan
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
return
if (Test-Path $binaryPath) {
$fileSize = (Get-Item $binaryPath).Length / 1MB
Write-Host "✅ Download completed successfully!" -ForegroundColor Green
Write-Host "File size: $([math]::Round($fileSize, 2)) MB" -ForegroundColor White
Write-Host "Location: $binaryPath" -ForegroundColor White
Write-Host ""
Write-Host "You can now run OpenQode using:" -ForegroundColor Cyan
Write-Host " .\OpenQode.bat" -ForegroundColor White
Write-Host " .\OpenQode.ps1" -ForegroundColor White
} else {
Write-Host "❌ Download failed - file not found after download" -ForegroundColor Red
exit 1
}
} catch {
Write-Host "❌ Download failed:" -ForegroundColor Red
Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red
Write-Host ""
Write-Host "Alternative: Download manually from:" -ForegroundColor Yellow
Write-Host "https://github.com/sst/opencode/releases" -ForegroundColor White
if (-not $NonInteractive) {
Write-Host ""
Write-Host "Press any key to exit..." -ForegroundColor Cyan
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
exit 1
}
throw
}
Write-Host ""
Write-Host "Press any key to exit..." -ForegroundColor Cyan
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

View File

@@ -0,0 +1,64 @@
#!/bin/bash
# Detect OS
OS="$(uname -s)"
case "${OS}" in
Linux*) OS=linux;;
Darwin*) OS=darwin;;
*) OS="UNKNOWN:${OS}"
esac
# Detect Arch
ARCH="$(uname -m)"
case "${ARCH}" in
x86_64) ARCH=x64;;
arm64) ARCH=arm64;;
aarch64) ARCH=arm64;;
*) ARCH="UNKNOWN:${ARCH}"
esac
if [[ "$OS" == *"UNKNOWN"* ]] || [[ "$ARCH" == *"UNKNOWN"* ]]; then
echo "❌ Unsupported platform: $OS $ARCH"
echo "Please download manually."
exit 1
fi
BINARY_NAME="opencode-$OS-$ARCH"
# Windows uses .exe, but we are in bash script, mostly for nix.
# If running bash on windows (git bash), uname -s is MINGW...
if [[ "$OS" == *"MINGW"* ]] || [[ "$OS" == *"CYGWIN"* ]]; then
BINARY_NAME="opencode-windows-x64.exe"
TARGET_FILE="opencode.exe"
else
TARGET_FILE="opencode"
fi
DOWNLOAD_URL="https://github.com/sst/opencode/releases/latest/download/$BINARY_NAME"
# Resolve script directory to handle running from root or scripts dir
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
TARGET_DIR="$SCRIPT_DIR/../bin"
FULL_TARGET="$TARGET_DIR/$TARGET_FILE"
# Create bin dir
mkdir -p "$TARGET_DIR"
echo "Downloading OpenCode for $OS-$ARCH..."
echo "URL: $DOWNLOAD_URL"
# Download
if command -v curl &> /dev/null; then
curl -L -o "$FULL_TARGET" "$DOWNLOAD_URL"
elif command -v wget &> /dev/null; then
wget -O "$FULL_TARGET" "$DOWNLOAD_URL"
else
echo "❌ Neither curl nor wget found. Please install one."
exit 1
fi
if [ -f "$FULL_TARGET" ]; then
chmod +x "$FULL_TARGET"
echo "✅ Download successful: $FULL_TARGET"
else
echo "❌ Download failed."
exit 1
fi

View File

@@ -0,0 +1,134 @@
# Interactive OpenCode launcher with model selection and auto-auth
param(
[string]$Model = "",
[switch]$SkipAuth = $false
)
function Show-ModelMenu {
Clear-Host
Write-Host "🤖 OpenCode - Choose Your AI Model" -ForegroundColor Cyan
Write-Host "======================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "1. Qwen Coder Model (Free - 2,000 requests/day, 60 RPM)" -ForegroundColor Green
Write-Host " • Excellent for coding tasks" -ForegroundColor Gray
Write-Host " • Requires qwen.ai authentication" -ForegroundColor Gray
Write-Host ""
Write-Host "2. Qwen Vision Model (Free - 2,000 requests/day, 60 RPM)" -ForegroundColor Green
Write-Host " • For vision and coding tasks" -ForegroundColor Gray
Write-Host " • Requires qwen.ai authentication" -ForegroundColor Gray
Write-Host ""
Write-Host "3. OpenCode Big Pickle (Default)" -ForegroundColor Yellow
Write-Host " • OpenCode's default model" -ForegroundColor Gray
Write-Host " • No authentication required" -ForegroundColor Gray
Write-Host ""
Write-Host "4. OpenCode GPT-5 Nano" -ForegroundColor Yellow
Write-Host " • OpenCode's experimental model" -ForegroundColor Gray
Write-Host " • No authentication required" -ForegroundColor Gray
Write-Host ""
Write-Host "5. Grok Code" -ForegroundColor Yellow
Write-Host " • Grok's coding model" -ForegroundColor Gray
Write-Host " • No authentication required" -ForegroundColor Gray
Write-Host ""
do {
$choice = Read-Host "Enter your choice (1-5)"
switch ($choice) {
"1" { return "qwen/coder-model" }
"2" { return "qwen/vision-model" }
"3" { return "opencode/big-pickle" }
"4" { return "opencode/gpt-5-nano" }
"5" { return "opencode/grok-code" }
default {
Write-Host "Invalid choice. Please enter 1-5." -ForegroundColor Red
Start-Sleep -Seconds 1
}
}
} while ($choice -notin @("1","2","3","4","5"))
}
function Test-QwenAuth {
try {
$result = & "E:\TRAE Playground\Test Ideas\opencode-install\opencode.exe" auth list 2>$null
return $result -match "qwen"
} catch {
return $false
}
}
function Start-QwenAuth {
Write-Host ""
Write-Host "🔐 Qwen Authentication Required" -ForegroundColor Yellow
Write-Host "================================" -ForegroundColor Yellow
Write-Host "Opening browser for qwen.ai authentication..." -ForegroundColor Cyan
Write-Host ""
try {
& "E:\TRAE Playground\Test Ideas\opencode-install\opencode.exe" auth qwen
Write-Host ""
Write-Host "✅ Authentication initiated! Please complete in browser." -ForegroundColor Green
Write-Host "⏳ Waiting for authentication to complete..." -ForegroundColor Cyan
# Wait for auth to complete
$maxWait = 60 # seconds
$waited = 0
do {
Start-Sleep -Seconds 2
$waited += 2
if (Test-QwenAuth) {
Write-Host "✅ Authentication successful!" -ForegroundColor Green
return $true
}
if ($waited -ge $maxWait) {
Write-Host "⚠️ Authentication timeout. You can try again later." -ForegroundColor Yellow
return $false
}
} while ($waited -lt $maxWait)
} catch {
Write-Host "❌ Failed to start authentication" -ForegroundColor Red
Write-Host "You can manually run: opencode auth qwen" -ForegroundColor Gray
return $false
}
return $false
}
function Start-OpenCode {
param([string]$SelectedModel)
Write-Host ""
Write-Host "🚀 Starting OpenCode TUI..." -ForegroundColor Green
Write-Host "Model: $SelectedModel" -ForegroundColor Cyan
Write-Host "Features: Lakeview + Sequential Thinking" -ForegroundColor Gray
Write-Host ""
Start-Sleep -Seconds 2
# Launch OpenCode with selected model and features
& "E:\TRAE Playground\Test Ideas\opencode-install\opencode.exe" -m $SelectedModel --lakeview --think
}
# Main execution
if (-not $Model) {
$selectedModel = Show-ModelMenu
} else {
$selectedModel = $Model
}
# Check if Qwen model needs authentication
if ($selectedModel -like "qwen/*" -and -not $SkipAuth) {
if (-not (Test-QwenAuth)) {
if (Start-QwenAuth) {
Start-OpenCode -SelectedModel $selectedModel
} else {
Write-Host ""
Write-Host "❌ Could not authenticate with Qwen. Please try again later." -ForegroundColor Red
Write-Host "You can manually run: opencode auth qwen" -ForegroundColor Gray
exit 1
}
} else {
Write-Host "✅ Already authenticated with Qwen!" -ForegroundColor Green
Start-OpenCode -SelectedModel $selectedModel
}
} else {
Start-OpenCode -SelectedModel $selectedModel
}

View File

@@ -0,0 +1,291 @@
# OpenCode Interactive Launcher with Model Selection and Agent Manager
# Clear screen for better UX
Clear-Host
# Resolve OpenQode paths
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$OpenQodeDir = Split-Path -Parent $ScriptDir
$BinaryPath = Join-Path $OpenQodeDir "bin\\opencode.exe"
$AgentDir = Join-Path $OpenQodeDir ".opencode\\agent"
$DownloadScript = Join-Path $OpenQodeDir "scripts\\download-opencode.ps1"
# Ensure OpenCode binary exists (auto-download if missing)
if (-not (Test-Path $BinaryPath)) {
Write-Host "OpenCode binary not found at: $BinaryPath" -ForegroundColor Yellow
Write-Host "Attempting to download OpenCode automatically..." -ForegroundColor Cyan
if (Test-Path $DownloadScript) {
try {
& $DownloadScript -NonInteractive
} catch {
Write-Host "Failed to download OpenCode binary automatically." -ForegroundColor Red
Write-Host "Run .\\scripts\\download-opencode.ps1 manually or download from:" -ForegroundColor Yellow
Write-Host "https://github.com/sst/opencode/releases" -ForegroundColor White
exit 1
}
} else {
Write-Host "Download script missing. Please download opencode.exe manually from:" -ForegroundColor Red
Write-Host "https://github.com/sst/opencode/releases" -ForegroundColor White
exit 1
}
}
# Ensure agent directory exists
if (-not (Test-Path $AgentDir)) {
New-Item -ItemType Directory -Path $AgentDir -Force | Out-Null
}
function Show-MainMenu {
Clear-Host
Write-Host "🤖 OpenQode v1.01 - Main Menu" -ForegroundColor Cyan
Write-Host "==============================" -ForegroundColor Cyan
Write-Host ""
Write-Host "1. 🚀 Launch TUI (Select Model)" -ForegroundColor Green
Write-Host "2. 🤖 Agent Manager" -ForegroundColor Yellow
Write-Host "3. 🌐 Web Assist Dashboard" -ForegroundColor Magenta
Write-Host "4. ❌ Exit" -ForegroundColor Red
Write-Host ""
$choice = Read-Host "Enter your choice (1-4)"
return $choice
}
function Show-ModelMenu {
Clear-Host
Write-Host "🎯 Select AI Model" -ForegroundColor Cyan
Write-Host "==================" -ForegroundColor Cyan
Write-Host ""
Write-Host "1. Qwen Coder Model (Free - 2,000 req/day)" -ForegroundColor Green
Write-Host "2. Qwen Vision Model (Free - 2,000 req/day)" -ForegroundColor Green
Write-Host "3. OpenCode Big Pickle (Default)" -ForegroundColor Yellow
Write-Host "4. OpenCode GPT-5 Nano" -ForegroundColor Yellow
Write-Host "5. Grok Code" -ForegroundColor Yellow
Write-Host "6. ← Back to Main Menu" -ForegroundColor Gray
Write-Host ""
$choice = Read-Host "Enter your choice (1-6)"
return $choice
}
function Show-AgentManager {
Clear-Host
Write-Host "🤖 Agent Manager" -ForegroundColor Cyan
Write-Host "=================" -ForegroundColor Cyan
Write-Host ""
# List existing agents
$agents = Get-ChildItem -Path $AgentDir -Filter "*.md" -ErrorAction SilentlyContinue
if ($agents.Count -gt 0) {
Write-Host "📋 Current Agents:" -ForegroundColor Yellow
$i = 1
foreach ($agent in $agents) {
$name = [System.IO.Path]::GetFileNameWithoutExtension($agent.Name)
Write-Host " $i. $name" -ForegroundColor White
$i++
}
Write-Host ""
} else {
Write-Host "📋 No custom agents found." -ForegroundColor Gray
Write-Host ""
}
Write-Host "Options:" -ForegroundColor Cyan
Write-Host "1. Create New Agent" -ForegroundColor Green
Write-Host "2. 📝 Edit Agent" -ForegroundColor Yellow
Write-Host "3. 🗑️ Delete Agent" -ForegroundColor Red
Write-Host "4. ← Back to Main Menu" -ForegroundColor Gray
Write-Host ""
$choice = Read-Host "Enter your choice (1-4)"
return $choice
}
function Create-Agent {
Clear-Host
Write-Host " Create New Agent" -ForegroundColor Cyan
Write-Host "===================" -ForegroundColor Cyan
Write-Host ""
$name = Read-Host "Agent name (e.g., 'security', 'optimize')"
if (-not $name) {
Write-Host "❌ Name cannot be empty" -ForegroundColor Red
Start-Sleep -Seconds 2
return
}
# Sanitize name
$name = $name.ToLower() -replace '[^a-z0-9_-]', ''
$agentPath = Join-Path $AgentDir "$name.md"
if (Test-Path $agentPath) {
Write-Host "❌ Agent '$name' already exists" -ForegroundColor Red
Start-Sleep -Seconds 2
return
}
Write-Host ""
Write-Host "Describe what this agent should do:" -ForegroundColor Yellow
Write-Host "(Enter your prompt, then type 'END' on a new line to finish)"
Write-Host ""
$promptLines = @()
while ($true) {
$line = Read-Host
if ($line -eq "END") { break }
$promptLines += $line
}
$prompt = $promptLines -join "`n"
# Create agent file
$content = @"
# $($name.Substring(0,1).ToUpper() + $name.Substring(1)) Agent
$prompt
"@
Set-Content -Path $agentPath -Value $content -Encoding UTF8
Write-Host ""
Write-Host "✅ Agent '$name' created successfully!" -ForegroundColor Green
Write-Host "File: $agentPath" -ForegroundColor Gray
Start-Sleep -Seconds 2
}
function Edit-Agent {
$agents = Get-ChildItem -Path $AgentDir -Filter "*.md" -ErrorAction SilentlyContinue
if ($agents.Count -eq 0) {
Write-Host "❌ No agents to edit" -ForegroundColor Red
Start-Sleep -Seconds 2
return
}
Write-Host ""
Write-Host "Select agent to edit:" -ForegroundColor Yellow
$i = 1
foreach ($agent in $agents) {
$name = [System.IO.Path]::GetFileNameWithoutExtension($agent.Name)
Write-Host "$i. $name" -ForegroundColor White
$i++
}
$choice = Read-Host "Enter number"
$index = [int]$choice - 1
if ($index -ge 0 -and $index -lt $agents.Count) {
$agentPath = $agents[$index].FullName
notepad $agentPath
Write-Host "✅ Opening in Notepad..." -ForegroundColor Green
}
}
function Delete-Agent {
$agents = Get-ChildItem -Path $AgentDir -Filter "*.md" -ErrorAction SilentlyContinue
if ($agents.Count -eq 0) {
Write-Host "❌ No agents to delete" -ForegroundColor Red
Start-Sleep -Seconds 2
return
}
Write-Host ""
Write-Host "Select agent to delete:" -ForegroundColor Yellow
$i = 1
foreach ($agent in $agents) {
$name = [System.IO.Path]::GetFileNameWithoutExtension($agent.Name)
Write-Host "$i. $name" -ForegroundColor White
$i++
}
$choice = Read-Host "Enter number"
$index = [int]$choice - 1
if ($index -ge 0 -and $index -lt $agents.Count) {
$agentPath = $agents[$index].FullName
$agentName = [System.IO.Path]::GetFileNameWithoutExtension($agents[$index].Name)
$confirm = Read-Host "Delete '$agentName'? (y/n)"
if ($confirm -eq 'y') {
Remove-Item $agentPath -Force
Write-Host "✅ Agent deleted" -ForegroundColor Green
}
}
Start-Sleep -Seconds 1
}
function Launch-Model($modelChoice) {
switch ($modelChoice) {
"1" {
$model = "qwen/coder-model"
Write-Host "`n🔐 Checking Qwen authentication..." -ForegroundColor Cyan
try {
$authCheck = & $BinaryPath auth list 2>$null
if ($authCheck -match "qwen") {
Write-Host "✅ Already authenticated!" -ForegroundColor Green
} else {
Write-Host "🌐 Opening browser for Qwen authentication..." -ForegroundColor Yellow
& $BinaryPath auth qwen
Read-Host "Press Enter after completing browser auth..."
}
} catch {}
}
"2" {
$model = "qwen/vision-model"
Write-Host "`n🔐 Checking Qwen authentication..." -ForegroundColor Cyan
try {
$authCheck = & $BinaryPath auth list 2>$null
if ($authCheck -match "qwen") {
Write-Host "✅ Already authenticated!" -ForegroundColor Green
} else {
Write-Host "🌐 Opening browser for auth..." -ForegroundColor Yellow
& $BinaryPath auth qwen
Read-Host "Press Enter after completing browser auth..."
}
} catch {}
}
"3" { $model = "opencode/big-pickle" }
"4" { $model = "opencode/gpt-5-nano" }
"5" { $model = "opencode/grok-code" }
default { return }
}
Write-Host "`n🚀 Launching with: $model" -ForegroundColor Green
Start-Sleep -Seconds 1
& $BinaryPath -m $model
}
# Main loop
while ($true) {
$mainChoice = Show-MainMenu
switch ($mainChoice) {
"1" {
$modelChoice = Show-ModelMenu
if ($modelChoice -ne "6") {
Launch-Model $modelChoice
}
}
"2" {
while ($true) {
$agentChoice = Show-AgentManager
switch ($agentChoice) {
"1" { Create-Agent }
"2" { Edit-Agent }
"3" { Delete-Agent }
"4" { break }
}
if ($agentChoice -eq "4") { break }
}
}
"3" {
Write-Host "`n🌐 Opening Web Assist Dashboard..." -ForegroundColor Cyan
Start-Process "http://127.0.0.1:15044/assist/"
Start-Sleep -Seconds 2
}
"4" {
Write-Host "`n👋 Goodbye!" -ForegroundColor Cyan
exit 0
}
}
}

30
scripts/qwen-auth.ps1 Normal file
View File

@@ -0,0 +1,30 @@
# Qwen Authentication Helper
param([switch]$Force = $false)
$OpenQodeDir = Split-Path -Parent $MyInvocation.MyCommand.Path | Split-Path
$BinaryPath = "$OpenQodeDir\bin\opencode.exe"
Write-Host "Qwen Authentication Helper" -ForegroundColor Cyan
Write-Host "=========================" -ForegroundColor Cyan
if ($Force) {
Write-Host "Logging out from Qwen first..." -ForegroundColor Yellow
& $BinaryPath auth logout
}
Write-Host "Opening Qwen authentication..." -ForegroundColor Green
Write-Host "If browser doesn't open, visit: https://qwen.ai" -ForegroundColor Cyan
# Try to open browser
try {
Start-Process "https://qwen.ai"
Write-Host "Browser opened successfully!" -ForegroundColor Green
} catch {
Write-Host "Could not open browser automatically" -ForegroundColor Yellow
Write-Host "Please manually visit: https://qwen.ai" -ForegroundColor Cyan
}
Write-Host "`nRunning authentication command..." -ForegroundColor Yellow
& $BinaryPath auth login qwen
Write-Host "`nAuthentication process completed!" -ForegroundColor Green