package github import ( "embed" ) // UIAssets embeds the built MCP App UI HTML files. // These files are generated by running `script/build-ui` which compiles // the React/Primer components in the ui/ directory. // //go:embed ui_dist/*.html var UIAssets embed.FS // GetUIAsset reads a UI asset from the embedded filesystem. // The name should be just the filename (e.g., "get-me.html"). func GetUIAsset(name string) (string, error) { data, err := UIAssets.ReadFile("ui_dist/" + name) if err != nil { return "", err } return string(data), nil } // MustGetUIAsset reads a UI asset and panics if it fails. // Use this when the asset is required for server operation. func MustGetUIAsset(name string) string { html, err := GetUIAsset(name) if err != nil { panic("failed to load UI asset " + name + ": " + err.Error()) } return html } // UIAssetsAvailable returns true if the MCP App UI assets have been built. // This checks for a known UI asset file to determine if `script/build-ui` has been run. // Use this to gracefully skip UI registration when assets aren't available, // allowing Insiders mode to work for non-UI features without requiring a UI build. func UIAssetsAvailable() bool { _, err := GetUIAsset("get-me.html") return err == nil }