Skip to content

Fix process.cwd() issue for GUI-launched apps (Claude Desktop, VS Code) #19

@mrsimpson

Description

@mrsimpson

Problem

The server uses process.cwd() to find the .quiet-shell/ configuration directory, which fails when launched from GUI applications:

  • Claude Desktop on macOS: CWD = /Applications
  • VS Code on macOS: CWD = /Applications/Visual Studio Code.app/Contents/Resources/app

This makes it impossible for users to use project-specific .quiet-shell/ configuration.

Solution

A reusable directory-discovery utility has been implemented in prompts-mcp (commit 21c3830) that solves this problem.

Implementation Guide

See complete instructions: https://github.com/mrsimpson/prompts-mcp/blob/preconfigured-prompts/DIRECTORY_DISCOVERY_ISSUE.md

Quick Steps:

  1. Copy packages/mcp-server/src/utils/directory-discovery.ts from prompts-mcp
  2. Copy packages/mcp-server/test/unit/directory-discovery.test.ts
  3. Update code using process.cwd() to use the discovery utility:
import { discoverDirectory } from "./utils/directory-discovery.js";

const configDiscovery = discoverDirectory({
  subdirEnvPrefix: "QUIET_SHELL",  // Creates QUIET_SHELL_SUBDIR env var
  subdir: ".quiet-shell",
  useHomeFallback: true
});

// Use configDiscovery.path for the directory
// Check configDiscovery.exists to see if it exists
// Check configDiscovery.source to see how it was found

New Environment Variables

  • PROJECT_DIR - Override starting directory for upward search
  • QUIET_SHELL_SUBDIR - Directly specify .quiet-shell directory location

Search Strategy

  1. Check QUIET_SHELL_SUBDIR env var (direct override)
  2. Search upward from PROJECT_DIR or process.cwd()
  3. Fallback to ~/.quiet-shell/ (home directory)

Benefits

✅ Works with Claude Desktop and GUI apps
✅ Searches upward from nested directories
✅ Home directory fallback
✅ Flexible environment variable control
✅ Zero breaking changes
✅ Well-tested (18 new tests in prompts-mcp)

Reference Implementation

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions