Files
biz-bud/docker/entrypoint.sh
Travis Vasceannie 18b93515cc Bb-core-restoration-backup (#54)
* fix: complete bb_tools migration with pre-commit compliance

- Migrate all bb_tools modules to src/biz_bud/tools structure
- Fix TypedDict definitions and type checking issues
- Create missing extraction modules (core/types.py, numeric/)
- Update pre-commit config with correct pyrefly paths
- Disable general pyrefly check (missing modules outside migration scope)
- Achieve pre-commit compliance for migration-specific modules

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: complete bb_tools migration with pre-commit compliance

* Pre-config-migration-backup (#51)

* fix: resolve linting errors for ErrorDetails import, spacing, and unused variables

* fix: correct docstring imperative mood in conftest.py

- Change 'Factory for creating...' to 'Create...'
- Change 'Simple timer...' to 'Provide simple timer...'
- Ensure all docstrings use imperative mood as required by D401

* feat: add new configuration and migration tools

- Introduced new configuration files and scripts for dependency analysis and migration planning.
- Added new Python modules for dependency analysis and migration processes.
- Updated .gitignore to include task files.
- Enhanced existing examples and scripts to support new functionality.

These changes improve the overall configuration management and migration capabilities of the project.

* refactor: reorganize tools package and enhance LangGraph integration

- Moved tool factory and related components to a new core structure for better organization.
- Updated pre-commit configuration to enable pyrefly type checking.
- Introduced new scraping strategies and unified scraper implementations for improved functionality.
- Enhanced error handling and logging across various tools and services.
- Added new TypedDicts for state management and tool execution tracking.

These changes improve the overall architecture and maintainability of the tools package while ensuring compliance with LangGraph standards.

* refactor: apply final Sourcery improvements

- Use named expression for cleanup_tasks in container.py
- Fix whitespace issue in cleanup_registry.py

All Sourcery suggestions now implemented

* refactor: reorganize tools package and enhance LangGraph integration

- Moved tool factory and related components to a new core structure for better organization.
- Updated pre-commit configuration to enable pyrefly type checking.
- Introduced new scraping strategies and unified scraper implementations for improved functionality.
- Enhanced error handling and logging across various tools and services.
- Added new TypedDicts for state management and tool execution tracking.

These changes improve the overall architecture and maintainability of the tools package while ensuring compliance with LangGraph standards.

* chore: update dependencies and improve error handling

- Bump version of @anthropic-ai/claude-code in package-lock.json to 1.0.64.
- Modify Dockerfile to allow 'npm' command in sudoers for the 'dev' user.
- Refactor buddy_execution.py and buddy_nodes_registry.py for improved readability.
- Enhance error handling in tool_exceptions.py with detailed docstrings.
- Update various decorators in langgraph to clarify their functionality in docstrings.
- Improve validation error handling in pydantic_models.py and security.py.
- Refactor catalog data loading to use asyncio for better performance.
- Enhance batch web search tool with a new result formatting function.

These changes enhance the overall functionality, maintainability, and clarity of the codebase.

* refactor: update .gitignore and improve configuration files

- Updated .gitignore to include task files with clearer formatting.
- Simplified the include paths in repomix.config.json for better clarity.
- Added a new documentation file for tool organization and refactoring plans.
- Enhanced docstrings across various files for improved clarity and consistency.

These changes enhance the organization and maintainability of the project while improving documentation clarity.

* refactor: streamline code with assignment expressions and improve readability

- Updated buddy_nodes_registry.py to simplify graph name assignment.
- Enhanced error handling in various files by using assignment expressions for clarity.
- Refactored multiple functions across the codebase to improve readability and maintainability.
- Adjusted return statements in validation and processing functions for better flow.

These changes enhance the overall clarity and efficiency of the codebase while maintaining functionality.

* refactor: enhance test structure and improve docstring clarity

- Added timeout decorator to improve async test handling in test_concurrency_races.py.
- Removed redundant imports and improved docstring clarity across multiple test files.
- Updated various test classes to ensure consistent and clear documentation.

These changes enhance the maintainability and readability of the test suite while ensuring proper async handling.

* refactor: enhance test documentation and structure

- Updated test fixture imports to include additional noqa codes for clarity.
- Added module docstrings for various test directories to improve documentation.
- Improved docstring formatting in test_embed_integration.py for consistency.

These changes enhance the clarity and maintainability of the test suite while ensuring proper documentation across test files.

* refactor: enhance test documentation and structure

- Added module docstrings to various test files for improved clarity.
- Improved individual test function docstrings to better describe their purpose.

These changes enhance the maintainability and readability of the test suite while ensuring proper documentation across test files.

* Refactoring of graphs nodes and tools (#52)

* Refactoring of graphs nodes and tools

* Refactoring of graphs nodes and tools

* Update src/biz_bud/graphs/planner.py

Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com>

* Refactoring of graphs nodes and tools

* Refactoring of graphs nodes and tools

* Refactoring of graphs nodes and tools

* Refactoring of graphs nodes and tools

---------

Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com>

* Tool-streamlining (#53)

* feat: add new tools and capabilities for extraction, scraping, and search

- Introduced new modules for extraction, scraping, and search capabilities, enhancing the overall functionality of the tools package.
- Added unit tests for browser tools and capabilities, improving test coverage and reliability.
- Refactored existing code for better organization and maintainability, including the removal of obsolete directories and files.

These changes significantly enhance the toolset available for data extraction and processing, while ensuring robust testing and code quality.

* refactor: remove obsolete extraction, scraping, and search modules

- Deleted outdated modules related to extraction, scraping, and search functionalities to streamline the codebase.
- This cleanup enhances maintainability and reduces complexity by removing unused code.

* big

* refactor: enhance tool call validation and logging

- Improved validation for tool calls to handle both dictionary and ToolCall object formats.
- Added detailed logging for invalid tool call structures and missing required fields.
- Streamlined the process of filtering valid tool calls for better maintainability and clarity.

* refactor: enhance capability normalization and metadata structure in LLM client and tests

- Added normalization for capability names in LangchainLLMClient to prevent duplicates.
- Updated test_memory_exhaustion.py to include detailed metadata structure for documents.
- Improved test_state_corruption.py to use a more descriptive data structure for large data entries.
- Enhanced test visualization state with additional fields for better context and configuration.

* refactor: update .gitignore and remove obsolete files

- Updated .gitignore to include task files and ensure proper tracking.
- Deleted analyze_test_violations.py, comprehensive_violations_baseline.txt, domain-nodes-migration-summary.md, domain-specific-nodes-migration-plan.md, EXTRACTION_REORGANIZATION.md, graph-specific-nodes-migration-plan.md, legacy-nodes-cleanup-analysis.md, MIGRATION_COMPLETE_SUMMARY.md, MIGRATION_COMPLETE.md, node-migration-final-analysis.md, nodes-migration-analysis.md, phase1-import-migration-status.md, REDUNDANT_FILE_CLEANUP.md, REGISTRY_REMOVAL_SUMMARY.md, shared-types-migration-summary.md, and various test violation reports to streamline the codebase and remove unused files.

* refactor: update .gitignore and enhance message handling in LLM call

- Added environment files to .gitignore for better configuration management.
- Refactored agent imports in __init__.py to reflect changes in architecture.
- Improved message handling in call_model_node to ensure valid message lists and provide clearer error responses.
- Updated unit tests to reflect changes in error messages and ensure consistency in validation checks.

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com>
2025-08-01 21:18:22 -04:00

244 lines
10 KiB
Bash

#!/bin/bash
# Docker container entrypoint script
# This script sets up Git configuration, credentials,
# 1Password SSH agent integration, and development tools
# Exit on error
set -e
echo "=== ???? Starting container initialization as user: $(whoami) ==="
## 1. Set up directories and environment variables
#echo "???? Setting up directories..."
# Create writable directories for Git configuration and tools
mkdir -p /tmp/git-config/git
mkdir -p /tmp/git-tools
# Set Git to use our writable config directory
export XDG_CONFIG_HOME="/tmp/git-config"
export GIT_CONFIG_GLOBAL="${XDG_CONFIG_HOME}/git/config"
# Initialize empty Git config
mkdir -p "$(dirname "$GIT_CONFIG_GLOBAL")"
touch "$GIT_CONFIG_GLOBAL"
chmod 600 "$GIT_CONFIG_GLOBAL"
# If /root/.gitconfig does not exist and /root/.gitconfig.host exists, copy it
if [ ! -f /root/.gitconfig ] && [ -f /root/.gitconfig.host ]; then
echo "???? Copying /root/.gitconfig.host to /root/.gitconfig for writable config..."
cp /root/.gitconfig.host /root/.gitconfig
chmod 600 /root/.gitconfig
fi
# 2. Git configuration setup
## Check for mounted Git configuration and copy contents if available
if [ -f /home/dev/.gitconfig ]; then
echo "🔧 Importing existing Git configuration..."
cat /home/dev/.gitconfig >> "$GIT_CONFIG_GLOBAL"
echo "✅ Git configuration imported successfully"
else
echo "⚠️ No Git configuration found at /home/dev/.gitconfig"
fi
## 3. Git credentials setup
## First check the tmp location
if [ -f /tmp/git-source/.git-credentials ]; then
echo "???? Setting up Git credentials from /tmp/git-source/.git-credentials..."
git config --global --replace-all credential.helper store
# Create a writable credentials file
mkdir -p "${HOME}"
# Only copy if different
if [ "/tmp/git-source/.git-credentials" != "${HOME}/.git-credentials" ]; then
cp /tmp/git-source/.git-credentials "${HOME}/.git-credentials"
fi
chmod 600 "${HOME}/.git-credentials"
echo "??? Git credentials configured successfully"
# Check alternative location
elif [ -f /home/dev/.git-credentials ]; then
echo "🔧 Setting up Git credentials from /home/dev/.git-credentials..."
git config --global --replace-all credential.helper store
# Create a writable credentials file
mkdir -p "${HOME}"
# Only copy if source and destination are different
if [ "/home/dev/.git-credentials" != "${HOME}/.git-credentials" ]; then
cp /home/dev/.git-credentials "${HOME}/.git-credentials"
chmod 600 "${HOME}/.git-credentials"
else
echo "Credentials file already in correct location"
chmod 600 "${HOME}/.git-credentials"
fi
echo "✅ Git credentials configured successfully"
else
echo "?????? No Git credentials found"
fi
## 4. 1Password SSH signing integration
## Check for 1Password SSH bridge in various possible locations
if [ -f /usr/local/bin/op-ssh-bridge.sh ]; then
OP_SSH_BRIDGE_PATH="/usr/local/bin/op-ssh-bridge.sh"
elif [ -f /tmp/op-ssh-scripts/op-ssh-sign-bridge ]; then
OP_SSH_BRIDGE_PATH="/tmp/op-ssh-scripts/op-ssh-sign-bridge"
else
OP_SSH_BRIDGE_PATH=""
fi
# Fix SSH configuration for container environment
if [ -d /home/dev/.ssh ]; then
echo "🔐 Setting up SSH configuration..."
# Copy SSH files to writable location to avoid permission issues with mounted volumes
echo "📋 Copying SSH configuration to writable location..."
mkdir -p /tmp/.ssh
# Copy files individually since glob expansion can fail with permission issues
sudo find /home/dev/.ssh -type f -exec cp {} /tmp/.ssh/ \; 2>/dev/null || echo "⚠️ Some SSH files may not be accessible"
sudo chown -R dev:dev /tmp/.ssh 2>/dev/null || true
# Fix permissions on copied files
chmod 700 /tmp/.ssh
find /tmp/.ssh -name "id_*" -type f -exec chmod 600 {} \; 2>/dev/null || true
find /tmp/.ssh -name "*.pub" -type f -exec chmod 644 {} \; 2>/dev/null || true
find /tmp/.ssh -name "config" -type f -exec chmod 600 {} \; 2>/dev/null || true
find /tmp/.ssh -name "known_hosts" -type f -exec chmod 644 {} \; 2>/dev/null || true
# Set SSH to use our writable directory
export SSH_AUTH_SOCK=""
export SSH_CONFIG_DIR="/tmp/.ssh"
# Start SSH agent
eval "$(ssh-agent -s)"
# Add SSH keys to agent
for key in /tmp/.ssh/id_* /tmp/.ssh/*_ed25519; do
if [ -f "$key" ] && [ ! -f "$key.pub" ]; then
ssh-add "$key" 2>/dev/null || echo "⚠️ Could not add key: $key"
fi
done
# Create SSH config to use our directory and the correct GitHub key
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/tmp/.ssh/known_hosts -o IdentitiesOnly=yes -i /tmp/.ssh/git_ed25519"
echo "✅ SSH configuration completed"
else
echo "⚠️ No SSH directory found"
fi
# Configure Git for container environment (disable signing for simplicity)
git config --global --unset-all commit.gpgsign || true
git config --global commit.gpgsign false
git config --global --unset gpg.program || true
git config --global --unset gpg.format || true
git config --global --unset core.sshcommand || true
echo "✅ Git commit signing disabled for container use"
if [ -n "$OP_SSH_BRIDGE_PATH" ]; then
echo "???? Setting up 1Password SSH bridge from $OP_SSH_BRIDGE_PATH..."
# Copy to writable location
cp "$OP_SSH_BRIDGE_PATH" /tmp/git-tools/op-ssh-bridge
chmod +x /tmp/git-tools/op-ssh-bridge
# Do not configure Git to use the SSH bridge for signing
# since we've disabled commit signing above
echo "??? 1Password SSH bridge available but not used for commit signing"
else
echo "?????? 1Password SSH bridge not found, signing is disabled"
fi
## 5. Fix container-specific file permissions (preserve host compatibility)
echo "🔧 Fixing container-specific permissions..."
# Get current user info
CURRENT_UID=$(id -u)
CURRENT_GID=$(id -g)
CURRENT_USER=$(id -un)
echo "Running as: $CURRENT_USER (UID: $CURRENT_UID, GID: $CURRENT_GID)"
# Only fix permissions for directories that are container-specific
# and won't affect host file access
# Fix Claude directory permissions (mounted from host but needs container access)
if [ -d /home/dev/.claude ]; then
echo "🤖 Setting up Claude Code directory permissions..."
# Only fix ownership of files that are safe to change
find /home/dev/.claude -type d -exec chmod 755 {} \; 2>/dev/null || true
find /home/dev/.claude -name "*.jsonl" -exec chown $CURRENT_UID:$CURRENT_GID {} \; 2>/dev/null || true
mkdir -p /home/dev/.claude/projects 2>/dev/null || true
echo "✅ Claude Code permissions configured"
# Ensure Claude symlink points to local installation (not global)
if [ -f /home/dev/.claude/local/claude ]; then
sudo ln -sf /home/dev/.claude/local/claude /usr/local/bin/claude 2>/dev/null || true
echo "✅ Claude Code symlink configured for local installation"
# Create local bashrc with Claude alias for proper local installation detection
if [ ! -f /home/dev/.bashrc.local ] || ! grep -q "claude.*\.claude/local/claude" /home/dev/.bashrc.local; then
echo "# Claude Code alias for local installation" >> /home/dev/.bashrc.local
echo "alias claude=\"~/.claude/local/claude\"" >> /home/dev/.bashrc.local
echo "✅ Claude Code alias configured in .bashrc.local"
fi
fi
fi
# Fix permissions on any root-owned files in the workspace that shouldn't be
echo "🔧 Fixing workspace file permissions..."
# Only change ownership of files that were created by root and shouldn't be
if [ -w /app ]; then
# Fix common files that get created as root
find /app -name "*.pyc" -user root -exec chown $CURRENT_UID:$CURRENT_GID {} \; 2>/dev/null || true
find /app -name "__pycache__" -user root -exec chown -R $CURRENT_UID:$CURRENT_GID {} \; 2>/dev/null || true
find /app -name ".pytest_cache" -user root -exec chown -R $CURRENT_UID:$CURRENT_GID {} \; 2>/dev/null || true
# Fix any dotfiles that got created as root (but preserve git objects)
find /app -maxdepth 1 -name ".*" -user root ! -path "*/.git/objects*" -exec chown $CURRENT_UID:$CURRENT_GID {} \; 2>/dev/null || true
echo "✅ Workspace permissions fixed"
fi
## 6. Fix profile environment issues
echo "🔧 Setting up shell environment..."
# Create missing environment files to prevent profile errors
mkdir -p /home/dev/.local/bin /home/dev/.cargo
# Create empty env files if they don't exist to prevent profile errors
if [ ! -f /home/dev/.local/bin/env ]; then
touch /home/dev/.local/bin/env
echo "✅ Created empty /home/dev/.local/bin/env"
fi
if [ ! -f /home/dev/.cargo/env ]; then
touch /home/dev/.cargo/env
echo "✅ Created empty /home/dev/.cargo/env"
fi
## 7. Python environment configuration
#echo "???? Setting up Python environment..."
# Set PYTHONPATH to include /app and /app/src if not already set
# This helps avoid circular path references in case PYTHONPATH is already set
if [ -z "$PYTHONPATH" ]; then
export PYTHONPATH="/app:/app/src"
else
# Only add paths if they're not already in PYTHONPATH
if [[ ":$PYTHONPATH:" != *":/app:"* ]]; then
export PYTHONPATH="/app:$PYTHONPATH"
fi
if [[ ":$PYTHONPATH:" != *":/app/src:"* ]]; then
export PYTHONPATH="$PYTHONPATH:/app/src"
fi
fi
echo "???? PYTHONPATH set to: $PYTHONPATH"
## 8. Print configurations and versions for debugging
#echo "???? Current Git configuration:"
git config --list
echo "???? Installed tool versions:"
echo "Node.js: $(node --version 2>/dev/null || echo 'not found')"
echo "npm: $(npm --version 2>/dev/null || echo 'not found')"
echo "uv: $(uv --version 2>/dev/null || echo 'not found')"
echo "Python: $(python3 --version 2>/dev/null || python --version 2>/dev/null || echo 'not found')"
echo "pip: $(pip --version 2>/dev/null || echo 'not found')"
echo "repomix: $(repomix --version 2>/dev/null || echo 'not found')"
echo "langgraph: $(langgraph --version 2>/dev/null || echo 'not found')"
echo "tree: $(tree --version 2>/dev/null || echo 'not found')"
echo "=== ??? Container initialization completed ==="
## 9. Execute the command passed to the container
#if [ $# -eq 0 ]; then
# If no arguments are provided, sleep infinity (default behavior)
echo "?????? No command specified, running sleep infinity..."
exec sleep infinity
#else
# Otherwise, execute the provided command
echo "?????? Executing command: $@"
exec "$@"
#fi