From ac8f72cfe58c061dd6b9ae9ef301a3ea8de76976 Mon Sep 17 00:00:00 2001 From: Plean Date: Tue, 11 Aug 2026 00:47:20 +0000 Subject: [PATCH] Fixed model selection and the install script now properly works when not sudo --- README.md | 4 ++++ businessman | 51 ++++++++++++++++++++++++++++++------------ install-businessman.sh | 6 ++--- 3 files changed, 44 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 5ea5ae4..4a6a135 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,10 @@ If the selected model has a context length: If no context length is available: - `CLAUDE_CODE_DISABLE_1M_CONTEXT=1` +### Environment Variable Propagation + +**Important:** The environment variables are written to a temporary file and sourced by each tmux pane at startup. This ensures Claude Code in Pane 0 receives the correct model settings. Do not delete the temporary environment file while the tmux session is running. + ## Using the Businessman Skill The skill is automatically initialized when you run `businessman`. To use it manually after the session is running: diff --git a/businessman b/businessman index 5457955..2168b68 100755 --- a/businessman +++ b/businessman @@ -57,34 +57,54 @@ cd "$PROJECT_DIR" || { echo "Directory not found: $PROJECT_DIR"; exit 1; } SESSION_NAME="businessman-$(date +%Y%m%d-%H%M%S)" -# Set env vars (inheritable by tmux panes) -export ANTHROPIC_BASE_URL="$LLAMA_SWAP_API" -export ANTHROPIC_AUTH_TOKEN="dummy" -export ANTHROPIC_DEFAULT_SONNET_MODEL="$MODEL_ID" -export ANTHROPIC_DEFAULT_HAIKU_MODEL="$MODEL_ID" -export ANTHROPIC_DEFAULT_OPUS_MODEL="$MODEL_ID" +# Set env vars for tmux session (set before creating session) +LLAMA_BASE_URL="$LLAMA_SWAP_API" +LLAMA_AUTH_TOKEN="dummy" +LLAMA_MODEL_ID="$MODEL_ID" +LLAMA_CTX="$CTX" # Context-aware settings if [ -n "$CTX" ] && [ "$CTX" != "unknown" ] && [ "$CTX" -gt 0 ]; then if [ "$CTX" -gt 200000 ]; then - export CLAUDE_CODE_DISABLE_1M_CONTEXT="0" - export CLAUDE_CODE_AUTO_COMPACT_WINDOW="200000" + CLAUDE_DISABLE_1M_CONTEXT="0" + CLAUDE_AUTO_COMPACT_WINDOW="200000" else - export CLAUDE_CODE_DISABLE_1M_CONTEXT="1" - export CLAUDE_CODE_AUTO_COMPACT_WINDOW="$CTX" + CLAUDE_DISABLE_1M_CONTEXT="1" + CLAUDE_AUTO_COMPACT_WINDOW="$CTX" fi - export CLAUDE_AUTOCOMPACT_PCT_OVERRIDE="80" + CLAUDE_AUTOCOMPACT_PCT_OVERRIDE="80" else - export CLAUDE_CODE_DISABLE_1M_CONTEXT="1" + CLAUDE_DISABLE_1M_CONTEXT="1" + CLAUDE_AUTO_COMPACT_WINDOW="" fi +# Create environment setup file for the session +ENV_SETUP="/tmp/businessman-env-$$-$SESSION_NAME" +cat > "$ENV_SETUP" << EOF +export ANTHROPIC_BASE_URL="$LLAMA_BASE_URL" +export ANTHROPIC_AUTH_TOKEN="$LLAMA_AUTH_TOKEN" +export ANTHROPIC_DEFAULT_SONNET_MODEL="$LLAMA_MODEL_ID" +export ANTHROPIC_DEFAULT_HAIKU_MODEL="$LLAMA_MODEL_ID" +export ANTHROPIC_DEFAULT_OPUS_MODEL="$LLAMA_MODEL_ID" +export CLAUDE_CODE_DISABLE_1M_CONTEXT="$CLAUDE_DISABLE_1M_CONTEXT" +export CLAUDE_CODE_AUTO_COMPACT_WINDOW="$CLAUDE_AUTO_COMPACT_WINDOW" +export CLAUDE_AUTOCOMPACT_PCT_OVERRIDE="$CLAUDE_AUTOCOMPACT_PCT_OVERRIDE" +EOF + # Start tmux session with bash in pane 0 (keeps shell alive after claude exits) tmux new-session -d -s "$SESSION_NAME" "bash" -# Send 'claude' command to pane 0 and hit Enter + +# Send commands to pane 0 that source the env file and then run claude +tmux send-keys -t "$SESSION_NAME:0.0" "source \"$ENV_SETUP\"" Enter +sleep 0.2 tmux send-keys -t "$SESSION_NAME:0.0" "claude \"Use the businessman skill to initialize our session\"" Enter # Pane 1 is still a plain bash tmux split-window -t "$SESSION_NAME:0.0" -h "bash" + +# Set pane 1 to also source the env file +tmux send-keys -t "$SESSION_NAME:0.1" "source \"$ENV_SETUP\"" Enter + tmux resize-pane -t "$SESSION_NAME:0.0" -x 50 # Focus pane 0 (Claude) @@ -101,4 +121,7 @@ echo "When done with claude, type 'exit' in pane 0 to get your bash shell back" echo "To reattach: tmux attach -t $SESSION_NAME" # Auto-attach -tmux attach -t "$SESSION_NAME" \ No newline at end of file +tmux attach -t "$SESSION_NAME" + +# Clean up temp file after session ends +rm -f "$ENV_SETUP" \ No newline at end of file diff --git a/install-businessman.sh b/install-businessman.sh index cdbf917..0e338e4 100755 --- a/install-businessman.sh +++ b/install-businessman.sh @@ -68,9 +68,9 @@ echo "Copying SKILL.md to $SKILLS_DIR..." cp "$SKILL_MD" "$SKILLS_DIR/SKILL.md" # Copy businessman binary to /usr/local/bin -echo "Copying businessman to $BIN_DIR..." -cp "$BUSINESSMAN_TEMP" "$BIN_DIR/businessman" -chmod +x "$BIN_DIR/businessman" +# /usr/local/bin is root-owned, so the copy must run as sudo +echo "Copying businessman to $BIN_DIR (sudo)..." +sudo install -m 755 "$BUSINESSMAN_TEMP" "$BIN_DIR/businessman" # Cleanup rm -f "$BUSINESSMAN_TEMP"