package api import ( "net/http" "github.com/muyue/muyue/internal/lsp" "github.com/muyue/muyue/internal/mcp" "github.com/muyue/muyue/internal/scanner" "github.com/muyue/muyue/internal/skills" "github.com/muyue/muyue/internal/version" ) func (s *Server) handleInfo(w http.ResponseWriter, r *http.Request) { writeJSON(w, map[string]interface{}{ "name": version.Name, "version": version.Version, "author": version.Author, }) } func (s *Server) handleSystem(w http.ResponseWriter, r *http.Request) { if s.scanResult == nil { s.scanResult = scanner.ScanSystem() } writeJSON(w, map[string]interface{}{ "system": s.scanResult.System, }) } func (s *Server) handleTools(w http.ResponseWriter, r *http.Request) { if s.scanResult == nil { s.scanResult = scanner.ScanSystem() } type toolInfo struct { Name string `json:"name"` Installed bool `json:"installed"` Version string `json:"version"` Path string `json:"path"` } tools := make([]toolInfo, len(s.scanResult.Tools)) for i, t := range s.scanResult.Tools { tools[i] = toolInfo{ Name: t.Name, Installed: t.Installed, Version: t.Version, Path: t.Path, } } writeJSON(w, map[string]interface{}{ "tools": tools, "total": len(tools), }) } func (s *Server) handleConfig(w http.ResponseWriter, r *http.Request) { if s.config == nil { writeError(w, "no config", http.StatusNotFound) return } writeJSON(w, map[string]interface{}{ "profile": s.config.Profile, "terminal": s.config.Terminal, "bmad": s.config.BMAD, }) } func (s *Server) handleProviders(w http.ResponseWriter, r *http.Request) { if s.config == nil { writeError(w, "no config", http.StatusNotFound) return } writeJSON(w, map[string]interface{}{ "providers": s.config.AI.Providers, }) } func (s *Server) handleSkills(w http.ResponseWriter, r *http.Request) { list, err := skills.List() if err != nil { writeError(w, err.Error(), http.StatusInternalServerError) return } writeJSON(w, map[string]interface{}{ "skills": list, "count": len(list), }) } func (s *Server) handleLSP(w http.ResponseWriter, r *http.Request) { servers := lsp.ScanServers() writeJSON(w, map[string]interface{}{ "servers": servers, }) } func (s *Server) handleMCP(w http.ResponseWriter, r *http.Request) { servers := mcp.ScanServers() writeJSON(w, map[string]interface{}{ "servers": servers, "configured": true, }) } func (s *Server) handleMCPConfigure(w http.ResponseWriter, r *http.Request) { if r.Method != "POST" { writeError(w, "POST only", http.StatusMethodNotAllowed) return } if err := mcp.ConfigureAll(s.config); err != nil { writeError(w, err.Error(), http.StatusInternalServerError) return } writeJSON(w, map[string]string{"status": "ok"}) } func (s *Server) handleScan(w http.ResponseWriter, r *http.Request) { s.scanResult = scanner.ScanSystem() writeJSON(w, map[string]string{"status": "ok"}) }