Skip to content

Commit b046416

Browse files
committed
fix(ui-desktop): align config/runtime paths with GOOSE_PATH_ROOT
Signed-off-by: Vadim Polulyakh <bavadim@gmail.com> (cherry picked from commit ce19b4c)
1 parent 78fe007 commit b046416

5 files changed

Lines changed: 101 additions & 46 deletions

File tree

ui/desktop/src/bin/jbang

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,40 @@ trap 'log "An error occurred. Exiting with status $?."' ERR
2020

2121
log "Starting jbang setup script."
2222

23-
# Ensure ~/.config/goose/mcp-hermit/bin exists
24-
log "Creating directory ~/.config/goose/mcp-hermit/bin if it does not exist."
25-
mkdir -p ~/.config/goose/mcp-hermit/bin
23+
if [ -n "${GOOSE_CONFIG_DIR:-}" ]; then
24+
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_CONFIG_DIR}"
25+
elif [ -n "${GOOSE_PATH_ROOT:-}" ]; then
26+
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_PATH_ROOT}/config"
27+
else
28+
RESOLVED_GOOSE_CONFIG_DIR="${HOME}/.config/goose"
29+
fi
30+
MCP_HERMIT_DIR="${RESOLVED_GOOSE_CONFIG_DIR}/mcp-hermit"
31+
32+
# Ensure mcp-hermit/bin exists
33+
log "Creating directory ${MCP_HERMIT_DIR}/bin if it does not exist."
34+
mkdir -p "${MCP_HERMIT_DIR}/bin"
2635

27-
# Change to the ~/.config/goose/mcp-hermit directory
28-
log "Changing to directory ~/.config/goose/mcp-hermit."
29-
cd ~/.config/goose/mcp-hermit
36+
# Change to the mcp-hermit directory
37+
log "Changing to directory ${MCP_HERMIT_DIR}."
38+
cd "${MCP_HERMIT_DIR}"
3039

3140
# Check if hermit binary exists and download if not
32-
if [ ! -f ~/.config/goose/mcp-hermit/bin/hermit ]; then
41+
if [ ! -f "${MCP_HERMIT_DIR}/bin/hermit" ]; then
3342
log "Hermit binary not found. Downloading hermit binary."
3443
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" \
35-
| gzip -dc > ~/.config/goose/mcp-hermit/bin/hermit && chmod +x ~/.config/goose/mcp-hermit/bin/hermit
44+
| gzip -dc > "${MCP_HERMIT_DIR}/bin/hermit" && chmod +x "${MCP_HERMIT_DIR}/bin/hermit"
3645
log "Hermit binary downloaded and made executable."
3746
else
3847
log "Hermit binary already exists. Skipping download."
3948
fi
4049

4150
log "setting hermit cache to be local for MCP servers"
42-
mkdir -p ~/.config/goose/mcp-hermit/cache
43-
export HERMIT_STATE_DIR=~/.config/goose/mcp-hermit/cache
51+
mkdir -p "${MCP_HERMIT_DIR}/cache"
52+
export HERMIT_STATE_DIR="${MCP_HERMIT_DIR}/cache"
4453

4554
# Update PATH
46-
export PATH=~/.config/goose/mcp-hermit/bin:$PATH
47-
log "Updated PATH to include ~/.config/goose/mcp-hermit/bin."
55+
export PATH="${MCP_HERMIT_DIR}/bin:${PATH}"
56+
log "Updated PATH to include ${MCP_HERMIT_DIR}/bin."
4857

4958
# Initialize hermit
5059
log "Initializing hermit."
@@ -55,10 +64,10 @@ log "Installing OpenJDK with hermit."
5564
hermit install openjdk@17 >> "$LOG_FILE"
5665

5766
# Download and install jbang if not present
58-
if [ ! -f ~/.config/goose/mcp-hermit/bin/jbang ]; then
67+
if [ ! -f "${MCP_HERMIT_DIR}/bin/jbang" ]; then
5968
log "Downloading and installing jbang."
6069
curl -Ls https://sh.jbang.dev | bash -s - app setup
61-
cp ~/.jbang/bin/jbang ~/.config/goose/mcp-hermit/bin/
70+
cp ~/.jbang/bin/jbang "${MCP_HERMIT_DIR}/bin/"
6271
fi
6372

6473
# Verify installations
@@ -86,4 +95,4 @@ jbang --quiet trust add *
8695
log "Executing 'jbang' command with arguments: $*"
8796
jbang --fresh --quiet "$@" || log "Failed to execute 'jbang' with arguments: $*"
8897

89-
log "jbang setup script completed successfully."
98+
log "jbang setup script completed successfully."

ui/desktop/src/bin/node-setup-common.sh

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,46 +23,56 @@ trap 'log "An error occurred. Exiting with status $?."' ERR
2323

2424
log "Starting node setup (common)."
2525

26+
if [ -n "${GOOSE_CONFIG_DIR:-}" ]; then
27+
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_CONFIG_DIR}"
28+
elif [ -n "${GOOSE_PATH_ROOT:-}" ]; then
29+
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_PATH_ROOT}/config"
30+
else
31+
RESOLVED_GOOSE_CONFIG_DIR="${HOME}/.config/goose"
32+
fi
33+
MCP_HERMIT_DIR="${RESOLVED_GOOSE_CONFIG_DIR}/mcp-hermit"
34+
2635
# One-time cleanup for existing Linux users to fix locking issues
27-
CLEANUP_MARKER="${HOME}/.config/goose/.mcp-hermit-cleanup-v1"
36+
CLEANUP_MARKER="${RESOLVED_GOOSE_CONFIG_DIR}/.mcp-hermit-cleanup-v1"
2837
if [[ "$(uname -s)" == "Linux" ]] && [ ! -f "${CLEANUP_MARKER}" ]; then
2938
log "Performing one-time cleanup of old mcp-hermit directory to fix locking issues."
30-
if [ -d "${HOME}/.config/goose/mcp-hermit" ]; then
31-
rm -rf "${HOME}/.config/goose/mcp-hermit"
39+
if [ -d "${MCP_HERMIT_DIR}" ]; then
40+
rm -rf "${MCP_HERMIT_DIR}"
3241
log "Removed old mcp-hermit directory."
3342
fi
43+
mkdir -p "${RESOLVED_GOOSE_CONFIG_DIR}"
3444
touch "${CLEANUP_MARKER}"
3545
log "Cleanup completed. Marker file created."
3646
fi
3747

38-
# Ensure ${HOME}/.config/goose/mcp-hermit/bin exists
39-
log "Creating directory ${HOME}/.config/goose/mcp-hermit/bin if it does not exist."
40-
mkdir -p "${HOME}/.config/goose/mcp-hermit/bin"
48+
# Ensure mcp-hermit/bin exists
49+
log "Creating directory ${MCP_HERMIT_DIR}/bin if it does not exist."
50+
mkdir -p "${MCP_HERMIT_DIR}/bin"
4151

42-
# Change to the ${HOME}/.config/goose/mcp-hermit directory
43-
log "Changing to directory ${HOME}/.config/goose/mcp-hermit."
44-
cd "${HOME}/.config/goose/mcp-hermit"
52+
# Change to the mcp-hermit directory
53+
log "Changing to directory ${MCP_HERMIT_DIR}."
54+
cd "${MCP_HERMIT_DIR}"
4555

4656

4757
# Check if hermit binary exists and download if not
48-
if [ ! -f "${HOME}/.config/goose/mcp-hermit/bin/hermit" ]; then
58+
if [ ! -f "${MCP_HERMIT_DIR}/bin/hermit" ]; then
4959
log "Hermit binary not found. Downloading hermit binary."
5060
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" \
51-
| gzip -dc > "${HOME}/.config/goose/mcp-hermit/bin/hermit" && chmod +x "${HOME}/.config/goose/mcp-hermit/bin/hermit"
61+
| gzip -dc > "${MCP_HERMIT_DIR}/bin/hermit" && chmod +x "${MCP_HERMIT_DIR}/bin/hermit"
5262
log "Hermit binary downloaded and made executable."
5363
else
5464
log "Hermit binary already exists. Skipping download."
5565
fi
5666

5767

5868
log "setting hermit cache to be local for MCP servers"
59-
mkdir -p "${HOME}/.config/goose/mcp-hermit/cache"
60-
export HERMIT_STATE_DIR="${HOME}/.config/goose/mcp-hermit/cache"
69+
mkdir -p "${MCP_HERMIT_DIR}/cache"
70+
export HERMIT_STATE_DIR="${MCP_HERMIT_DIR}/cache"
6171

6272

6373
# Update PATH
64-
export PATH="${HOME}/.config/goose/mcp-hermit/bin:${PATH}"
65-
log "Updated PATH to include ${HOME}/.config/goose/mcp-hermit/bin."
74+
export PATH="${MCP_HERMIT_DIR}/bin:${PATH}"
75+
log "Updated PATH to include ${MCP_HERMIT_DIR}/bin."
6676

6777

6878
# Verify hermit installation
@@ -78,7 +88,7 @@ if [ ! -f "bin/activate-hermit" ]; then
7888
log "Creating temp dir with bin subdirectory for hermit copy to avoid self-update locks."
7989
HERMIT_TMP_DIR="/tmp/hermit_tmp_$$/bin"
8090
mkdir -p "${HERMIT_TMP_DIR}"
81-
cp "${HOME}/.config/goose/mcp-hermit/bin/hermit" "${HERMIT_TMP_DIR}/hermit"
91+
cp "${MCP_HERMIT_DIR}/bin/hermit" "${HERMIT_TMP_DIR}/hermit"
8292
chmod +x "${HERMIT_TMP_DIR}/hermit"
8393
export PATH="${HERMIT_TMP_DIR}:${PATH}"
8494
HERMIT_CLEANUP_DIR="/tmp/hermit_tmp_$$"
@@ -124,10 +134,10 @@ if [ -n "${GOOSE_NPM_REGISTRY:-}" ] && curl -s --head --fail "${GOOSE_NPM_REGIST
124134
# Check if GOOSE_NPM_CERT is set and accessible
125135
if [ -n "${GOOSE_NPM_CERT:-}" ] && curl -s --head --fail "${GOOSE_NPM_CERT}" > /dev/null; then
126136
log "Downloading certificate from: ${GOOSE_NPM_CERT}"
127-
curl -sSL -o "${HOME}/.config/goose/mcp-hermit/cert.pem" "${GOOSE_NPM_CERT}"
137+
curl -sSL -o "${MCP_HERMIT_DIR}/cert.pem" "${GOOSE_NPM_CERT}"
128138
if [ $? -eq 0 ]; then
129139
log "Certificate downloaded successfully."
130-
export NODE_EXTRA_CA_CERTS="${HOME}/.config/goose/mcp-hermit/cert.pem"
140+
export NODE_EXTRA_CA_CERTS="${MCP_HERMIT_DIR}/cert.pem"
131141
else
132142
log "Unable to download the certificate. Skipping certificate setup."
133143
fi

ui/desktop/src/bin/uvx

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,41 @@ trap 'log "An error occurred. Exiting with status $?."' ERR
2020

2121
log "Starting uvx setup script."
2222

23-
# Ensure ~/.config/goose/mcp-hermit/bin exists
24-
log "Creating directory ~/.config/goose/mcp-hermit/bin if it does not exist."
25-
mkdir -p ~/.config/goose/mcp-hermit/bin
23+
if [ -n "${GOOSE_CONFIG_DIR:-}" ]; then
24+
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_CONFIG_DIR}"
25+
elif [ -n "${GOOSE_PATH_ROOT:-}" ]; then
26+
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_PATH_ROOT}/config"
27+
else
28+
RESOLVED_GOOSE_CONFIG_DIR="${HOME}/.config/goose"
29+
fi
30+
MCP_HERMIT_DIR="${RESOLVED_GOOSE_CONFIG_DIR}/mcp-hermit"
31+
32+
# Ensure mcp-hermit/bin exists
33+
log "Creating directory ${MCP_HERMIT_DIR}/bin if it does not exist."
34+
mkdir -p "${MCP_HERMIT_DIR}/bin"
2635

27-
# Change to the ~/.config/goose/mcp-hermit directory
28-
log "Changing to directory ~/.config/goose/mcp-hermit."
29-
cd ~/.config/goose/mcp-hermit
36+
# Change to the mcp-hermit directory
37+
log "Changing to directory ${MCP_HERMIT_DIR}."
38+
cd "${MCP_HERMIT_DIR}"
3039

3140
# Check if hermit binary exists and download if not
32-
if [ ! -f ~/.config/goose/mcp-hermit/bin/hermit ]; then
41+
if [ ! -f "${MCP_HERMIT_DIR}/bin/hermit" ]; then
3342
log "Hermit binary not found. Downloading hermit binary."
3443
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" \
35-
| gzip -dc > ~/.config/goose/mcp-hermit/bin/hermit && chmod +x ~/.config/goose/mcp-hermit/bin/hermit
44+
| gzip -dc > "${MCP_HERMIT_DIR}/bin/hermit" && chmod +x "${MCP_HERMIT_DIR}/bin/hermit"
3645
log "Hermit binary downloaded and made executable."
3746
else
3847
log "Hermit binary already exists. Skipping download."
3948
fi
4049

4150

4251
log "setting hermit cache to be local for MCP servers"
43-
mkdir -p ~/.config/goose/mcp-hermit/cache
44-
export HERMIT_STATE_DIR=~/.config/goose/mcp-hermit/cache
52+
mkdir -p "${MCP_HERMIT_DIR}/cache"
53+
export HERMIT_STATE_DIR="${MCP_HERMIT_DIR}/cache"
4554

4655
# Update PATH
47-
export PATH=~/.config/goose/mcp-hermit/bin:$PATH
48-
log "Updated PATH to include ~/.config/goose/mcp-hermit/bin."
56+
export PATH="${MCP_HERMIT_DIR}/bin:${PATH}"
57+
log "Updated PATH to include ${MCP_HERMIT_DIR}/bin."
4958

5059

5160
# Verify hermit installation

ui/desktop/src/main.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,20 @@ const getBundledConfig = (): BundledConfig => {
439439
const { defaultProvider, defaultModel, predefinedModels, baseUrlShare, version } =
440440
getBundledConfig();
441441

442+
const resolveGooseConfigDir = (): string => {
443+
const explicitConfigDir = process.env.GOOSE_CONFIG_DIR?.trim();
444+
if (explicitConfigDir) {
445+
return expandTilde(explicitConfigDir);
446+
}
447+
448+
const pathRoot = process.env.GOOSE_PATH_ROOT?.trim();
449+
if (pathRoot) {
450+
return path.join(expandTilde(pathRoot), 'config');
451+
}
452+
453+
return '~/.config/goose';
454+
};
455+
442456
const GENERATED_SECRET = crypto.randomBytes(32).toString('hex');
443457

444458
const getServerSecret = (settings: Settings): string => {
@@ -456,6 +470,8 @@ let appConfig = {
456470
GOOSE_DEFAULT_MODEL: defaultModel,
457471
GOOSE_PREDEFINED_MODELS: predefinedModels,
458472
GOOSE_API_HOST: 'http://127.0.0.1',
473+
GOOSE_CONFIG_DIR: resolveGooseConfigDir(),
474+
GOOSE_PATH_ROOT: process.env.GOOSE_PATH_ROOT,
459475
GOOSE_WORKING_DIR: '',
460476
// If GOOSE_ALLOWLIST_WARNING env var is not set, defaults to false (strict blocking mode)
461477
GOOSE_ALLOWLIST_WARNING: process.env.GOOSE_ALLOWLIST_WARNING === 'true',
@@ -486,7 +502,10 @@ const createChat = async (
486502
const goosedResult = await startGoosed({
487503
serverSecret,
488504
dir: dir || os.homedir(),
489-
env: { GOOSE_PATH_ROOT: process.env.GOOSE_PATH_ROOT },
505+
env: {
506+
GOOSE_PATH_ROOT: process.env.GOOSE_PATH_ROOT,
507+
GOOSE_CONFIG_DIR: appConfig.GOOSE_CONFIG_DIR,
508+
},
490509
externalGoosed: settings.externalGoosed,
491510
isPackaged: app.isPackaged,
492511
resourcesPath: app.isPackaged ? process.resourcesPath : undefined,

ui/desktop/src/recipe/recipe_management.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ export const convertToLocaleDateString = (lastModified: string): string => {
4242

4343
export const getStorageDirectory = (isGlobal: boolean): string => {
4444
if (isGlobal) {
45+
const configDir = window.appConfig.get('GOOSE_CONFIG_DIR') as string | undefined;
46+
if (configDir) {
47+
return `${configDir}/recipes`;
48+
}
49+
const pathRoot = window.appConfig.get('GOOSE_PATH_ROOT') as string | undefined;
50+
if (pathRoot) {
51+
return `${pathRoot}/config/recipes`;
52+
}
4553
return '~/.config/goose/recipes';
4654
} else {
4755
// For directory recipes, build absolute path using working directory

0 commit comments

Comments
 (0)