-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
88 lines (80 loc) · 2.17 KB
/
Copy pathmain.go
File metadata and controls
88 lines (80 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package main
import (
"embed"
"fmt"
"log"
"os"
"path/filepath"
"code-mind/internal/appdata"
"code-mind/internal/mcp"
"code-mind/internal/store"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"github.com/wailsapp/wails/v2/pkg/options/windows"
)
//go:embed all:frontend/dist
var assets embed.FS
// main dispatches between the three delivery modes of the single binary:
//
// codemind → desktop GUI (Wails)
// codemind serve → headless HTTP server (self-hosting / docker)
// codemind mcp → stdio MCP adapter for AI agents
//
// Dispatch must happen before any webview initialization.
func main() {
if len(os.Args) > 1 {
switch os.Args[1] {
case "serve":
attachParentConsole()
runServe()
return
case "mcp":
mcp.Run()
return
case "help", "-h", "--help":
attachParentConsole()
fmt.Println("Code Mind — usage:")
fmt.Println(" codemind start the desktop GUI")
fmt.Println(" codemind serve start the headless HTTP server (CODE_MIND_PORT, default 7979)")
fmt.Println(" codemind mcp start the stdio MCP adapter for AI agents")
return
}
// Unknown arguments fall through to the GUI so OS-level launches
// (file associations, shell handlers) keep working.
}
runGUI()
}
func runGUI() {
dataRoot, err := appdata.ResolveDataDir()
if err != nil {
log.Fatal("failed to resolve data directory:", err)
}
dataDir := filepath.Join(dataRoot, "maps")
webviewUserDataDir, err := appdata.ResolveWebviewUserDataDir()
if err != nil {
log.Fatal("failed to resolve webview data directory:", err)
}
fileStore := store.NewFileStore(dataDir)
app := NewApp(fileStore)
err = wails.Run(&options.App{
Title: "Code Mind",
Width: 1440,
Height: 920,
MinWidth: 1100,
MinHeight: 720,
AssetServer: &assetserver.Options{
Assets: assets,
},
BackgroundColour: &options.RGBA{R: 245, G: 244, B: 239, A: 1},
OnStartup: app.startup,
OnShutdown: app.shutdown,
Windows: &windows.Options{
WebviewIsTransparent: false,
WebviewUserDataPath: webviewUserDataDir,
},
})
if err != nil {
log.Fatal(err)
}
}