Repository navigation
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·96 lines (77 loc) · 3.01 KB
/
Copy pathentrypoint.sh
File metadata and controls
executable file
·96 lines (77 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
# Enable error handling
set -e
# Always enable command printing for debugging
set -x
# Add timestamp to logs
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"
}
debug() {
log "DEBUG: $*"
}
error() {
log "ERROR: $*"
exit 1
}
# Check if a project path was provided
if [ -z "$PROJECT_PATH" ]; then
error "PROJECT_PATH environment variable is required"
fi
# Strip any leading slashes from PROJECT_PATH to make it relative
RELATIVE_PATH="${PROJECT_PATH#/}"
# Set up communication directory
COMM_DIR="/workspace/$RELATIVE_PATH/.codebuff/comm"
debug "Setting up comm directory at: $COMM_DIR"
mkdir -p "$COMM_DIR" || error "Failed to create $COMM_DIR directory"
chmod 777 "$COMM_DIR" || error "Failed to set permissions on $COMM_DIR"
# Create communication files with proper permissions
touch "$COMM_DIR/messages.txt" "$COMM_DIR/responses.txt" || error "Failed to create communication files"
chmod 666 "$COMM_DIR/messages.txt" "$COMM_DIR/responses.txt" || error "Failed to set permissions on communication files"
# Create a working directory for this session
WORK_DIR="/tmp/codebuff_workspace/$RELATIVE_PATH"
mkdir -p "$WORK_DIR" || error "Failed to create working directory"
# Copy project files to working directory with error handling
debug "Copying project files to working directory..."
cd "/workspace/$RELATIVE_PATH" || error "Failed to change to source directory"
# Copy files individually
for file in .gitignore README.md eslint.config.js index.html knowledge.md package.json pnpm-lock.yaml tsconfig.app.json tsconfig.json tsconfig.node.json vite.config.ts; do
if [ -f "$file" ]; then
debug "Copying file: $file"
cp "$file" "$WORK_DIR/" || log "Failed to copy $file"
fi
done
# Copy directories individually
for dir in public src; do
if [ -d "$dir" ]; then
debug "Copying directory: $dir"
cp -r "$dir" "$WORK_DIR/" || log "Failed to copy $dir"
fi
done
# Change to the working directory
cd "$WORK_DIR" || error "Failed to change to working directory"
# Install dependencies if package.json exists
if [ -f "package.json" ]; then
debug "Setting up npm..."
source /root/.bashrc
log "Installing dependencies..."
npm install --silent || error "Failed to install dependencies"
fi
# Set up credentials directory in container's home directory
CREDS_DIR="$HOME/.config/manicode"
mkdir -p "$CREDS_DIR" || error "Failed to create credentials directory"
if [ -f "/workspace/.config/manicode/credentials.json" ]; then
if ! cp "/workspace/.config/manicode/credentials.json" "$CREDS_DIR/credentials.json"; then
debug "Warning: Failed to copy credentials file, continuing without credentials"
else
debug "Credentials copied from host to container's home directory"
fi
fi
# Verify codebuff is available and in PATH
PATH="/usr/local/bin:$PATH"
export PATH
which codebuff || error "codebuff command not found in PATH"
debug "Found codebuff at: $(which codebuff)"
# Start codebuff wrapper
log "Starting codebuff with communication layer..."
exec /codebuff-wrapper.sh