Documentation
¶
Overview ¶
Claude Desktop (the desktop app, not the claude CLI / Claude Code) keeps its MCP config at a fixed per-OS path. The path has one owner — this file — because two surfaces need it: `gadak mcp install claude-desktop` writes the file and the desktop Integrations row reads it, and the two must never disagree about where Claude Desktop looks.
Package clitool installs the gadak binary onto PATH. Unix uses a symlink; Windows copies (symlink creation needs Developer Mode or elevation, so the default path fails). Shared by `gadak install-cli` and the desktop "Install Command Line Tool…" menu so both surfaces use the same resolve / install / PATH-advice logic.
LookPathThen / ResolveNPM / RaycastExtDir live here too: the CLI install verb and the desktop catalog must try the same candidates.
Index ¶
- Constants
- Variables
- func ClaudeDesktopConfigPath() (string, error)
- func ClaudeDesktopConfigPathFor(goos, home, appdata, xdg string) (string, error)
- func ClaudeDesktopConfigPathOn(goos string) (string, error)
- func DefaultDir(pathEnv string) (string, error)
- func ExpandHome(p string) (string, error)
- func Install(p Plan, force bool) error
- func LookPathThen(name string, fallbacks []string, look func(string) (string, error), ...) (string, bool)
- func NPMNotFoundDetail() string
- func PathContains(pathEnv, dir string) bool
- func PathExportAdvise(dir, shell string) (line, rc string)
- func PathExportAdviseFor(dir, shell, goos string) (line, rc string)
- func RaycastExtDir() (string, error)
- func RecordedDesktopExe() string
- func ResolveDir(dirFlag, pathEnv string) (string, error)
- func ResolveNPM(look func(string) (string, error), present func(string) bool) (string, bool)
- func TildeHome(path string) string
- type Plan
Constants ¶
const ( StatusMissing = "missing" // nothing at Dest StatusLinked = "linked" // Dest is already the desired install (symlink or copy) StatusConflict = "conflict" // Dest exists but is not the desired install )
Destination status after Resolve.
const RaycastExtDirName = "raycast-extension"
RaycastExtDirName is the directory under the gadak home that holds the unpacked Raycast extension. Profile is ignored: one copy per home.
Variables ¶
var DesktopExePathFile string
DesktopExePathFile is the pointer file written after a successful install-cli when gadak-desktop.exe sat next to the source binary. Empty means <UserConfigDir>/gadak/desktop-exe-path. Tests override to a temp path so they never touch the real UserConfigDir. Not GADAK_HOME: that directory is store-owned.
var NPMFallbackPaths = []string{
"/opt/homebrew/bin/npm",
"/usr/local/bin/npm",
}
NPMFallbackPaths is LookPath("npm") then these, first existing+executable wins. Same brew locations as contrib/raycast/src/gadak.ts GADAK_CANDIDATES, opposite direction (we are finding npm, not gadak).
Owned here so `gadak raycast install` and the desktop catalog cannot drift.
Functions ¶
func ClaudeDesktopConfigPath ¶ added in v0.22.0
ClaudeDesktopConfigPath is ClaudeDesktopConfigPathFor for this process: home from os.UserHomeDir, appdata from APPDATA, xdg from XDG_CONFIG_HOME. An unresolvable home matters only on the branches that need it — the For function decides which error, so a Windows process without a home still resolves through APPDATA.
func ClaudeDesktopConfigPathFor ¶ added in v0.22.0
ClaudeDesktopConfigPathFor returns the Claude Desktop config path for a GOOS value, with every lookup injected so the Windows and Linux branches are testable on any host (same shape as ResolveFor). These are the paths Anthropic documents for Claude Desktop; docs/MCP.md names the macOS one.
darwin: <home>/Library/Application Support/Claude/claude_desktop_config.json
windows: <appdata>/Claude/claude_desktop_config.json (empty appdata is an error)
linux, others: <xdg>/Claude/claude_desktop_config.json when xdg is set,
else <home>/.config/Claude/claude_desktop_config.json
func ClaudeDesktopConfigPathOn ¶ added in v0.22.0
ClaudeDesktopConfigPathOn is ClaudeDesktopConfigPath for an explicit GOOS: the environment lookups stay this process's, the branch is the caller's. A catalogue that describes one OS (integrations.listFor) needs exactly this — without it, the row calls ClaudeDesktopConfigPath and answers for the host no matter which GOOS was asked for.
func DefaultDir ¶
DefaultDir chooses an install directory when --dir is omitted.
func ExpandHome ¶
ExpandHome expands a leading ~ or ~/… using os.UserHomeDir. Other paths are returned cleaned as-is.
func Install ¶
Install creates Dir if needed and places Dest according to p.Method (symlink on Unix, copy on Windows). Empty Method is treated as symlink so a Plan built by older callers keeps the previous behaviour. When Status is linked, Install does not touch Dest (it may still record gadak-desktop.exe next to Source as a discovery fallback). When Status is conflict and force is false, Install returns an error without touching the filesystem. force replaces an existing Dest.
func LookPathThen ¶ added in v0.16.0
func LookPathThen(name string, fallbacks []string, look func(string) (string, error), present func(string) bool) (string, bool)
LookPathThen is LookPath(name), then the first fallback that present reports. look and present are injected so tests can assert order without touching the host; both are required.
func NPMNotFoundDetail ¶ added in v0.16.0
func NPMNotFoundDetail() string
NPMNotFoundDetail names every place ResolveNPM looks. Generated from NPMFallbackPaths so the wording cannot drift from the table.
func PathContains ¶
PathContains reports whether dir appears as a PATH entry (exact, after Clean). Empty entries are ignored. Leading ~ in pathEnv entries is expanded.
func PathExportAdvise ¶
PathExportAdvise returns a pasteable one-liner and a suggested shell rc path for persistence (rc may be empty). Unix shells only; Windows uses PathExportAdviseFor.
func PathExportAdviseFor ¶ added in v0.16.0
PathExportAdviseFor is PathExportAdvise with an explicit GOOS. Windows has no verified one-liner in this package (setx truncates PATH; this runner has not executed a Windows PATH edit), so the line only names the directory.
func RaycastExtDir ¶ added in v0.16.0
RaycastExtDir is $GADAK_HOME/raycast-extension (profile ignored). A DirFor error is returned: the install verb must not write to a guessed path. Catalog display that cannot fail should fall back at the call site.
func RecordedDesktopExe ¶ added in v0.17.0
func RecordedDesktopExe() string
RecordedDesktopExe returns the path stored in DesktopExePathFile when that path names an existing non-directory file. Missing or stale records are ignored (empty string).
func ResolveDir ¶
ResolveDir returns the absolute install directory. Empty flag → DefaultDir(pathEnv). Leading ~ is expanded.
func ResolveNPM ¶ added in v0.16.0
ResolveNPM is LookPath("npm"), then NPMFallbackPaths.
Types ¶
type Plan ¶
type Plan struct {
Source string
Dir string
Dest string
// Status is one of StatusMissing, StatusLinked, StatusConflict.
Status string
OnPath bool
// ExistingKind / ExistingTarget describe a conflict (or the current link).
// Kind is "symlink", "file", "directory", or "other".
ExistingKind string
ExistingTarget string // absolute path for symlinks; empty otherwise
// Method is methodSymlink or methodCopy. Set by ResolveFor from goos.
Method string
}
Plan is the result of Resolve: where to install, what is there, and whether the install directory is already on PATH.
func ResolveFor ¶ added in v0.16.0
ResolveFor picks the install directory and inspects Dest. goos is an explicit GOOS value so the Windows dest name and copy/symlink choice can be tested on any host (callers pass runtime.GOOS in production).
dirFlag empty → DefaultDir(pathEnv) heuristic. Non-empty → expand/absolutize that path and skip the heuristic. pathEnv is the PATH string (usually os.Getenv("PATH")); inject a fake value in tests.
func (Plan) AlreadyInstalledLine ¶ added in v0.16.0
AlreadyInstalledLine is printed when Status is already linked/copied.
func (Plan) InstalledLine ¶ added in v0.16.0
InstalledLine is printed after a successful Install.
func (Plan) PrintStatusLine ¶ added in v0.16.0
PrintStatusLine is the `gadak install-cli --print` status line. Ownership lives here so the CLI cannot drift into saying "symlink" for a copy.