loop-benchmarking

Controlled experiments across agentic coding configurations. Same task, one variable, what actually works.
git clone https://git.shiptheloop.com/loop-benchmarking.git
Log | Files | Refs | README

workspace.sh (1795B)


      1 #!/usr/bin/env bash
      2 # Workspace creation and teardown for isolated benchmark runs.
      3 # Each run gets a fresh temp directory with no project context.
      4 
      5 create_workspace() {
      6   local project_dir="$1"
      7   local task="$2"
      8   local cell_json="$3"
      9 
     10   local language
     11   language=$(echo "$cell_json" | jq -r '.language')
     12   local linter
     13   linter=$(echo "$cell_json" | jq -r '.linter')
     14   local playwright_val
     15   playwright_val=$(echo "$cell_json" | jq -r '.playwright')
     16 
     17   local workspace
     18   workspace=$(mktemp -d "/tmp/loop-bench-XXXXXX")
     19 
     20   # Initialize npm project
     21   cd "$workspace" || exit 1
     22   npm init -y > /dev/null 2>&1
     23 
     24   # Install TypeScript if needed
     25   if [[ "$language" == "typescript" ]]; then
     26     npm install --save-dev typescript @types/node > /dev/null 2>&1
     27   fi
     28 
     29   # Install linter if enabled
     30   if [[ "$linter" == "on" ]]; then
     31     npm install --save-dev eslint @eslint/js > /dev/null 2>&1
     32   fi
     33 
     34   # Install Playwright if enabled
     35   if [[ "$playwright_val" == "on" ]]; then
     36     npm install --save-dev @playwright/test > /dev/null 2>&1
     37     npx playwright install chromium --with-deps > /dev/null 2>&1
     38   fi
     39 
     40   # Copy task fixtures into workspace
     41   local fixtures_dir="$project_dir/tasks/$task/fixtures"
     42   if [[ -d "$fixtures_dir" ]] && [[ "$(ls -A "$fixtures_dir" 2>/dev/null)" ]]; then
     43     cp -r "$fixtures_dir"/* "$workspace/"
     44   fi
     45 
     46   echo "$workspace"
     47 }
     48 
     49 archive_workspace() {
     50   local workspace="$1"
     51   local run_dir="$2"
     52 
     53   if [[ -d "$workspace" ]]; then
     54     tar -czf "$run_dir/workspace.tar.gz" -C "$(dirname "$workspace")" "$(basename "$workspace")" 2>/dev/null || true
     55   fi
     56 }
     57 
     58 cleanup_workspace() {
     59   local workspace="$1"
     60   local run_dir="$2"
     61 
     62   archive_workspace "$workspace" "$run_dir"
     63 
     64   if [[ -d "$workspace" ]] && [[ "$workspace" == /tmp/loop-bench-* ]]; then
     65     rm -rf "$workspace"
     66   fi
     67 }

Impressum · Datenschutz