Complete implementation of muyue v0.1.0, a single-binary Go tool that transforms the development environment with AI-powered orchestration. Core features: - TUI with 5 tabs (Dashboard/Chat/Workflow/Agents/Config) using Charm stack - AI chat via MiniMax M2.7 with async message handling - Structured Plan→Execute workflow engine (gather→plan→review→execute) - System scanner detecting 14 tools + 8 runtimes across Linux/macOS/Windows - Auto-installer for Crush, Claude Code, BMAD, Starship, runtimes - Background update daemon with hourly checks - LSP auto-config for 16 language servers - MCP auto-config for 12 servers (deployed to Crush + Claude Code) - Skills system with 5 built-ins + AI-powered generation - Crush/Claude Code proxy for unified control - HTML preview server for visual outputs - First-time setup wizard with interactive profiling - Cross-platform: Linux (primary), macOS, Windows, WSL CI/CD: - GitHub Actions CI: build + test + lint on Linux/macOS/Windows - Release workflow: cross-compile 6 binaries with checksums on tag push 💘 Generated with Crush Assisted-by: GLM-5.1 via Crush <crush@charm.land>
77 lines
1.4 KiB
Go
77 lines
1.4 KiB
Go
package preview
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"runtime"
|
|
)
|
|
|
|
type PreviewServer struct {
|
|
dir string
|
|
server *http.Server
|
|
}
|
|
|
|
func NewPreviewServer(dir string) *PreviewServer {
|
|
return &PreviewServer{dir: dir}
|
|
}
|
|
|
|
func (p *PreviewServer) Start(port int) error {
|
|
fs := http.FileServer(http.Dir(p.dir))
|
|
mux := http.NewServeMux()
|
|
mux.Handle("/", fs)
|
|
|
|
p.server = &http.Server{
|
|
Addr: fmt.Sprintf("127.0.0.1:%d", port),
|
|
Handler: mux,
|
|
}
|
|
|
|
go func() {
|
|
if err := p.server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
|
fmt.Printf("Preview server error: %s\n", err)
|
|
}
|
|
}()
|
|
|
|
url := fmt.Sprintf("http://127.0.0.1:%d", port)
|
|
fmt.Printf("Preview server running at %s\n", url)
|
|
|
|
return openBrowser(url)
|
|
}
|
|
|
|
func (p *PreviewServer) Stop() error {
|
|
if p.server != nil {
|
|
return p.server.Close()
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func CreatePreviewFile(dir, filename, content string) error {
|
|
if err := os.MkdirAll(dir, 0755); err != nil {
|
|
return err
|
|
}
|
|
return os.WriteFile(filepath.Join(dir, filename), []byte(content), 0644)
|
|
}
|
|
|
|
func openBrowser(url string) error {
|
|
var cmd string
|
|
var args []string
|
|
|
|
switch runtime.GOOS {
|
|
case "linux":
|
|
cmd = "xdg-open"
|
|
args = []string{url}
|
|
case "darwin":
|
|
cmd = "open"
|
|
args = []string{url}
|
|
case "windows":
|
|
cmd = "cmd"
|
|
args = []string{"/c", "start", url}
|
|
default:
|
|
return fmt.Errorf("unsupported platform")
|
|
}
|
|
|
|
return exec.Command(cmd, args...).Start()
|
|
}
|