diff --git a/ui/desktop/src/bin/jbang b/ui/desktop/src/bin/jbang index d06edbf61bb8..c49b80025e1e 100755 --- a/ui/desktop/src/bin/jbang +++ b/ui/desktop/src/bin/jbang @@ -20,31 +20,38 @@ trap 'log "An error occurred. Exiting with status $?."' ERR log "Starting jbang setup script." -# Ensure ~/.config/goose/mcp-hermit/bin exists -log "Creating directory ~/.config/goose/mcp-hermit/bin if it does not exist." -mkdir -p ~/.config/goose/mcp-hermit/bin +if [ -n "${GOOSE_PATH_ROOT:-}" ]; then + RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_PATH_ROOT}/config" +else + RESOLVED_GOOSE_CONFIG_DIR="${HOME}/.config/goose" +fi +MCP_HERMIT_DIR="${RESOLVED_GOOSE_CONFIG_DIR}/mcp-hermit" + +# Ensure mcp-hermit/bin exists +log "Creating directory ${MCP_HERMIT_DIR}/bin if it does not exist." +mkdir -p "${MCP_HERMIT_DIR}/bin" -# Change to the ~/.config/goose/mcp-hermit directory -log "Changing to directory ~/.config/goose/mcp-hermit." -cd ~/.config/goose/mcp-hermit +# Change to the mcp-hermit directory +log "Changing to directory ${MCP_HERMIT_DIR}." +cd "${MCP_HERMIT_DIR}" # Check if hermit binary exists and download if not -if [ ! -f ~/.config/goose/mcp-hermit/bin/hermit ]; then +if [ ! -f "${MCP_HERMIT_DIR}/bin/hermit" ]; then log "Hermit binary not found. Downloading hermit binary." curl -fsSL "https://github.com/cashapp/hermit/releases/download/stable/hermit-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/').gz" \ - | gzip -dc > ~/.config/goose/mcp-hermit/bin/hermit && chmod +x ~/.config/goose/mcp-hermit/bin/hermit + | gzip -dc > "${MCP_HERMIT_DIR}/bin/hermit" && chmod +x "${MCP_HERMIT_DIR}/bin/hermit" log "Hermit binary downloaded and made executable." else log "Hermit binary already exists. Skipping download." fi log "setting hermit cache to be local for MCP servers" -mkdir -p ~/.config/goose/mcp-hermit/cache -export HERMIT_STATE_DIR=~/.config/goose/mcp-hermit/cache +mkdir -p "${MCP_HERMIT_DIR}/cache" +export HERMIT_STATE_DIR="${MCP_HERMIT_DIR}/cache" # Update PATH -export PATH=~/.config/goose/mcp-hermit/bin:$PATH -log "Updated PATH to include ~/.config/goose/mcp-hermit/bin." +export PATH="${MCP_HERMIT_DIR}/bin:${PATH}" +log "Updated PATH to include ${MCP_HERMIT_DIR}/bin." # Initialize hermit log "Initializing hermit." @@ -55,10 +62,10 @@ log "Installing OpenJDK with hermit." hermit install openjdk@17 >> "$LOG_FILE" # Download and install jbang if not present -if [ ! -f ~/.config/goose/mcp-hermit/bin/jbang ]; then +if [ ! -f "${MCP_HERMIT_DIR}/bin/jbang" ]; then log "Downloading and installing jbang." curl -Ls https://sh.jbang.dev | bash -s - app setup - cp ~/.jbang/bin/jbang ~/.config/goose/mcp-hermit/bin/ + cp ~/.jbang/bin/jbang "${MCP_HERMIT_DIR}/bin/" fi # Verify installations @@ -86,4 +93,4 @@ jbang --quiet trust add * log "Executing 'jbang' command with arguments: $*" jbang --fresh --quiet "$@" || log "Failed to execute 'jbang' with arguments: $*" -log "jbang setup script completed successfully." \ No newline at end of file +log "jbang setup script completed successfully." diff --git a/ui/desktop/src/bin/node-setup-common.sh b/ui/desktop/src/bin/node-setup-common.sh index 34353034eab1..d9d55d5601da 100755 --- a/ui/desktop/src/bin/node-setup-common.sh +++ b/ui/desktop/src/bin/node-setup-common.sh @@ -23,32 +23,40 @@ trap 'log "An error occurred. Exiting with status $?."' ERR log "Starting node setup (common)." +if [ -n "${GOOSE_PATH_ROOT:-}" ]; then + RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_PATH_ROOT}/config" +else + RESOLVED_GOOSE_CONFIG_DIR="${HOME}/.config/goose" +fi +MCP_HERMIT_DIR="${RESOLVED_GOOSE_CONFIG_DIR}/mcp-hermit" + # One-time cleanup for existing Linux users to fix locking issues -CLEANUP_MARKER="${HOME}/.config/goose/.mcp-hermit-cleanup-v1" +CLEANUP_MARKER="${RESOLVED_GOOSE_CONFIG_DIR}/.mcp-hermit-cleanup-v1" if [[ "$(uname -s)" == "Linux" ]] && [ ! -f "${CLEANUP_MARKER}" ]; then log "Performing one-time cleanup of old mcp-hermit directory to fix locking issues." - if [ -d "${HOME}/.config/goose/mcp-hermit" ]; then - rm -rf "${HOME}/.config/goose/mcp-hermit" + if [ -d "${MCP_HERMIT_DIR}" ]; then + rm -rf "${MCP_HERMIT_DIR}" log "Removed old mcp-hermit directory." fi + mkdir -p "${RESOLVED_GOOSE_CONFIG_DIR}" touch "${CLEANUP_MARKER}" log "Cleanup completed. Marker file created." fi -# Ensure ${HOME}/.config/goose/mcp-hermit/bin exists -log "Creating directory ${HOME}/.config/goose/mcp-hermit/bin if it does not exist." -mkdir -p "${HOME}/.config/goose/mcp-hermit/bin" +# Ensure mcp-hermit/bin exists +log "Creating directory ${MCP_HERMIT_DIR}/bin if it does not exist." +mkdir -p "${MCP_HERMIT_DIR}/bin" -# Change to the ${HOME}/.config/goose/mcp-hermit directory -log "Changing to directory ${HOME}/.config/goose/mcp-hermit." -cd "${HOME}/.config/goose/mcp-hermit" +# Change to the mcp-hermit directory +log "Changing to directory ${MCP_HERMIT_DIR}." +cd "${MCP_HERMIT_DIR}" # Check if hermit binary exists and download if not -if [ ! -f "${HOME}/.config/goose/mcp-hermit/bin/hermit" ]; then +if [ ! -f "${MCP_HERMIT_DIR}/bin/hermit" ]; then log "Hermit binary not found. Downloading hermit binary." curl -fsSL "https://github.com/cashapp/hermit/releases/download/stable/hermit-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/').gz" \ - | gzip -dc > "${HOME}/.config/goose/mcp-hermit/bin/hermit" && chmod +x "${HOME}/.config/goose/mcp-hermit/bin/hermit" + | gzip -dc > "${MCP_HERMIT_DIR}/bin/hermit" && chmod +x "${MCP_HERMIT_DIR}/bin/hermit" log "Hermit binary downloaded and made executable." else log "Hermit binary already exists. Skipping download." @@ -56,13 +64,13 @@ fi log "setting hermit cache to be local for MCP servers" -mkdir -p "${HOME}/.config/goose/mcp-hermit/cache" -export HERMIT_STATE_DIR="${HOME}/.config/goose/mcp-hermit/cache" +mkdir -p "${MCP_HERMIT_DIR}/cache" +export HERMIT_STATE_DIR="${MCP_HERMIT_DIR}/cache" # Update PATH -export PATH="${HOME}/.config/goose/mcp-hermit/bin:${PATH}" -log "Updated PATH to include ${HOME}/.config/goose/mcp-hermit/bin." +export PATH="${MCP_HERMIT_DIR}/bin:${PATH}" +log "Updated PATH to include ${MCP_HERMIT_DIR}/bin." # Verify hermit installation @@ -78,7 +86,7 @@ if [ ! -f "bin/activate-hermit" ]; then log "Creating temp dir with bin subdirectory for hermit copy to avoid self-update locks." HERMIT_TMP_DIR="/tmp/hermit_tmp_$$/bin" mkdir -p "${HERMIT_TMP_DIR}" - cp "${HOME}/.config/goose/mcp-hermit/bin/hermit" "${HERMIT_TMP_DIR}/hermit" + cp "${MCP_HERMIT_DIR}/bin/hermit" "${HERMIT_TMP_DIR}/hermit" chmod +x "${HERMIT_TMP_DIR}/hermit" export PATH="${HERMIT_TMP_DIR}:${PATH}" HERMIT_CLEANUP_DIR="/tmp/hermit_tmp_$$" @@ -124,10 +132,10 @@ if [ -n "${GOOSE_NPM_REGISTRY:-}" ] && curl -s --head --fail "${GOOSE_NPM_REGIST # Check if GOOSE_NPM_CERT is set and accessible if [ -n "${GOOSE_NPM_CERT:-}" ] && curl -s --head --fail "${GOOSE_NPM_CERT}" > /dev/null; then log "Downloading certificate from: ${GOOSE_NPM_CERT}" - curl -sSL -o "${HOME}/.config/goose/mcp-hermit/cert.pem" "${GOOSE_NPM_CERT}" + curl -sSL -o "${MCP_HERMIT_DIR}/cert.pem" "${GOOSE_NPM_CERT}" if [ $? -eq 0 ]; then log "Certificate downloaded successfully." - export NODE_EXTRA_CA_CERTS="${HOME}/.config/goose/mcp-hermit/cert.pem" + export NODE_EXTRA_CA_CERTS="${MCP_HERMIT_DIR}/cert.pem" else log "Unable to download the certificate. Skipping certificate setup." fi diff --git a/ui/desktop/src/bin/uvx b/ui/desktop/src/bin/uvx index b0f1bdbed643..3a9d5f7718d0 100755 --- a/ui/desktop/src/bin/uvx +++ b/ui/desktop/src/bin/uvx @@ -20,19 +20,26 @@ trap 'log "An error occurred. Exiting with status $?."' ERR log "Starting uvx setup script." -# Ensure ~/.config/goose/mcp-hermit/bin exists -log "Creating directory ~/.config/goose/mcp-hermit/bin if it does not exist." -mkdir -p ~/.config/goose/mcp-hermit/bin +if [ -n "${GOOSE_PATH_ROOT:-}" ]; then + RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_PATH_ROOT}/config" +else + RESOLVED_GOOSE_CONFIG_DIR="${HOME}/.config/goose" +fi +MCP_HERMIT_DIR="${RESOLVED_GOOSE_CONFIG_DIR}/mcp-hermit" + +# Ensure mcp-hermit/bin exists +log "Creating directory ${MCP_HERMIT_DIR}/bin if it does not exist." +mkdir -p "${MCP_HERMIT_DIR}/bin" -# Change to the ~/.config/goose/mcp-hermit directory -log "Changing to directory ~/.config/goose/mcp-hermit." -cd ~/.config/goose/mcp-hermit +# Change to the mcp-hermit directory +log "Changing to directory ${MCP_HERMIT_DIR}." +cd "${MCP_HERMIT_DIR}" # Check if hermit binary exists and download if not -if [ ! -f ~/.config/goose/mcp-hermit/bin/hermit ]; then +if [ ! -f "${MCP_HERMIT_DIR}/bin/hermit" ]; then log "Hermit binary not found. Downloading hermit binary." curl -fsSL "https://github.com/cashapp/hermit/releases/download/stable/hermit-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/').gz" \ - | gzip -dc > ~/.config/goose/mcp-hermit/bin/hermit && chmod +x ~/.config/goose/mcp-hermit/bin/hermit + | gzip -dc > "${MCP_HERMIT_DIR}/bin/hermit" && chmod +x "${MCP_HERMIT_DIR}/bin/hermit" log "Hermit binary downloaded and made executable." else log "Hermit binary already exists. Skipping download." @@ -40,12 +47,12 @@ fi log "setting hermit cache to be local for MCP servers" -mkdir -p ~/.config/goose/mcp-hermit/cache -export HERMIT_STATE_DIR=~/.config/goose/mcp-hermit/cache +mkdir -p "${MCP_HERMIT_DIR}/cache" +export HERMIT_STATE_DIR="${MCP_HERMIT_DIR}/cache" # Update PATH -export PATH=~/.config/goose/mcp-hermit/bin:$PATH -log "Updated PATH to include ~/.config/goose/mcp-hermit/bin." +export PATH="${MCP_HERMIT_DIR}/bin:${PATH}" +log "Updated PATH to include ${MCP_HERMIT_DIR}/bin." # Verify hermit installation diff --git a/ui/desktop/src/main.ts b/ui/desktop/src/main.ts index bd1086fb2691..39c716c7d426 100644 --- a/ui/desktop/src/main.ts +++ b/ui/desktop/src/main.ts @@ -456,6 +456,7 @@ let appConfig = { GOOSE_DEFAULT_MODEL: defaultModel, GOOSE_PREDEFINED_MODELS: predefinedModels, GOOSE_API_HOST: 'http://127.0.0.1', + GOOSE_PATH_ROOT: process.env.GOOSE_PATH_ROOT, GOOSE_WORKING_DIR: '', // If GOOSE_ALLOWLIST_WARNING env var is not set, defaults to false (strict blocking mode) GOOSE_ALLOWLIST_WARNING: process.env.GOOSE_ALLOWLIST_WARNING === 'true', @@ -486,7 +487,9 @@ const createChat = async ( const goosedResult = await startGoosed({ serverSecret, dir: dir || os.homedir(), - env: { GOOSE_PATH_ROOT: process.env.GOOSE_PATH_ROOT }, + env: { + GOOSE_PATH_ROOT: process.env.GOOSE_PATH_ROOT, + }, externalGoosed: settings.externalGoosed, isPackaged: app.isPackaged, resourcesPath: app.isPackaged ? process.resourcesPath : undefined, diff --git a/ui/desktop/src/recipe/recipe_management.ts b/ui/desktop/src/recipe/recipe_management.ts index 8129a119a4df..a47437de3878 100644 --- a/ui/desktop/src/recipe/recipe_management.ts +++ b/ui/desktop/src/recipe/recipe_management.ts @@ -42,6 +42,10 @@ export const convertToLocaleDateString = (lastModified: string): string => { export const getStorageDirectory = (isGlobal: boolean): string => { if (isGlobal) { + const pathRoot = window.appConfig.get('GOOSE_PATH_ROOT') as string | undefined; + if (pathRoot) { + return `${pathRoot}/config/recipes`; + } return '~/.config/goose/recipes'; } else { // For directory recipes, build absolute path using working directory