Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Generated with cmux

Changes

Adds PROJECT_PATH environment variable to init hooks, providing access to the project root directory.

Implementation

  • LocalRuntime: Pass PROJECT_PATH when spawning init hook process
  • SSHRuntime: Pass PROJECT_PATH in env when executing init hook remotely
  • Centralized: Extract getInitHookEnv() helper to avoid duplication

Documentation

Updated docs/init-hooks.md with:

  • New "Environment Variables" section documenting PROJECT_PATH
  • Example showing how to reference files in project root from workspace

This allows init hooks to reliably access project-level files (like .env templates) without inferring paths from the workspace directory structure.

- LocalRuntime: Pass PROJECT_PATH when spawning init hook
- SSHRuntime: Pass PROJECT_PATH in env when executing init hook remotely

This allows init hooks to reference the project path without relying
on inferring it from the workspace path.
Added new 'Environment Variables' section documenting that init hooks
receive PROJECT_PATH pointing to the project root directory.

Includes example showing how to reference files in the project root
from within a workspace-scoped init hook.
Extract getInitHookEnv() helper in initHook.ts to avoid duplicating
environment variable logic between LocalRuntime and SSHRuntime.

This makes it easier to add new init hook env vars in the future - just
update the helper function instead of maintaining duplicate env objects.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

SSH init hooks now receive PROJECT_PATH pointing to the remote project
root (srcBaseDir/projectName) instead of the local project path.

This ensures init scripts can access project-level files on the remote
filesystem as documented in docs/init-hooks.md.
Changed init hook environment variables:
- PROJECT_PATH → MUX_PROJECT_PATH
- Added MUX_RUNTIME ("local" | "ssh")

MUX_RUNTIME is important because:
- On local workspaces, MUX_PROJECT_PATH points to local filesystem
- On SSH workspaces, MUX_PROJECT_PATH points to remote filesystem
- Scripts can check MUX_RUNTIME to handle platform differences

Updated docs with examples showing runtime-specific behavior.
MUX_PROJECT_PATH now always refers to the local project path, even on
SSH workspaces. This is more useful for logging and debugging.

Updated docs to clarify:
- MUX_PROJECT_PATH = local project path (both local and SSH)
- Use relative paths (e.g., '../.env') in init hooks to reference
  project files, which works for both local and SSH workspaces
@ammario ammario merged commit a810a93 into main Nov 13, 2025
16 checks passed
@ammario ammario deleted the init-project-path branch November 13, 2025 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants