Commit 9b6ec1f05dbe
Changed files (1)
tools
shpool-ssh-wrapper
tools/shpool-ssh-wrapper/default.nix
@@ -2,17 +2,27 @@
let
# Helper script to start Claude Code with Vertex AI environment
- # Takes optional directory argument: claude-vertex [directory]
+ # Takes required directory argument: claude-vertex <directory>
claude-vertex = pkgs.writeShellScript "claude-vertex" ''
export CLAUDE_CODE_USE_VERTEX=1
export CLOUD_ML_REGION=us-east5
export ANTHROPIC_VERTEX_PROJECT_ID=itpc-gcp-pnd-pe-eng-claude
- # Change to specified directory if provided
- if [ -n "''${1:-}" ]; then
- cd "$1"
+ # Directory is required
+ if [ -z "''${1:-}" ]; then
+ echo "Error: directory argument is required" >&2
+ exit 1
fi
+ # Check if directory exists
+ if [ ! -d "$1" ]; then
+ echo "Error: directory does not exist: $1" >&2
+ exit 1
+ fi
+
+ # Change to specified directory
+ cd "$1"
+
# Use full path since PATH isn't set in non-login shells
exec /etc/profiles/per-user/vincent/bin/claude
'';
@@ -47,12 +57,14 @@ pkgs.writeScriptBin "shpool-ssh-wrapper" ''
case "$SESSION_NAME" in
claude/*)
# Claude Code session - run with Vertex AI environment
- # Use helper script since shpool -c expects a binary, not a shell command
- if [ -n "$WORK_DIR" ]; then
- run_with_command "$SESSION_NAME" "${claude-vertex}" "$WORK_DIR"
- else
- run_with_command "$SESSION_NAME" "${claude-vertex}"
+ # If no directory specified, default to src/{session-name}
+ if [ -z "$WORK_DIR" ]; then
+ # Extract session name part after "claude/"
+ SESSION_SUFFIX="''${SESSION_NAME#claude/}"
+ WORK_DIR="src/$SESSION_SUFFIX"
fi
+ # Use helper script since shpool -c expects a binary, not a shell command
+ run_with_command "$SESSION_NAME" "${claude-vertex}" "$WORK_DIR"
;;
*)
# Default: just attach to session with default shell