Skip to content

Instantly share code, notes, and snippets.

@seabass011
Created September 11, 2025 19:33
Show Gist options
  • Select an option

  • Save seabass011/9c8c922c10c5b2c134ab05a30130c0c5 to your computer and use it in GitHub Desktop.

Select an option

Save seabass011/9c8c922c10c5b2c134ab05a30130c0c5 to your computer and use it in GitHub Desktop.
Nova CI Rescue Quickstart
#!/usr/bin/env bash
# Nova CI-Rescue CLI Quickstart - 10 Broken Tests with GPT-5 High Reasoning
# Quick demonstration of Nova fixing all 10 broken calculator functions
#
# Usage: ./cli_quickstart.sh [--regular|--verbose]
# Duration: ~3-4 minutes
# Requirements: Python 3.8+, OpenAI API key
set -euo pipefail
# Get the directory of this script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
########################################
# Configuration
########################################
DEMO_NAME="nova-demo-$(date +%s)"
DEMO_DIR="/tmp/$DEMO_NAME"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
MAGENTA='\033[0;35m'
BOLD='\033[1m'
DIM='\033[2m'
NC='\033[0m' # No Color
# Unicode symbols
CHECK="✓"
CROSS="✗"
ARROW="→"
STAR="★"
PACKAGE="📦"
ROCKET="🚀"
BULB="💡"
GEAR="⚙️"
SPARKLE="✨"
WARNING="⚠️"
FIRE="🔥"
BRAIN="🧠"
MAGIC="🪄"
########################################
# Helper Functions
########################################
print_hr() {
echo -e "${DIM}────────────────────────────────────────────────────────────────────────${NC}"
}
print_thick_hr() {
echo -e "${BOLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
}
print_banner() {
echo
print_thick_hr
echo -e "${BOLD}$1${NC}"
print_thick_hr
echo
}
print_step() {
local step=$1
local total=$2
local desc=$3
local emoji=$4
echo
echo -e "${CYAN}Step $step/$total${NC} ${emoji} $desc"
print_hr
}
print_success() {
echo -e "${GREEN}$CHECK $1${NC}"
}
print_error() {
echo -e "${RED}$CROSS $1${NC}"
}
print_info() {
echo -e "${BLUE}$ARROW $1${NC}"
}
print_warning() {
echo -e "${YELLOW}$WARNING $1${NC}"
}
wait_for_enter() {
# Disabled - run non-interactively
return 0
}
########################################
# Main Demo Flow
########################################
run_demo() {
# Welcome message
clear
echo
echo -e "${CYAN}${ROCKET} Nova CI-Rescue CLI Quickstart${NC}"
echo -e "${DIM}Watch Nova autonomously fix ALL 10 broken calculator functions${NC}"
echo
print_info "This demo will:"
echo -e " 1. Create a broken calculator with 10 functions"
echo -e " 2. Run tests (all will fail)"
echo -e " 3. Let Nova fix everything using GPT-5 with high reasoning"
echo -e " 4. Verify all tests pass"
echo
print_info "Demo duration: ~3-4 minutes"
wait_for_enter
# Step 1: Setup
print_banner "${PACKAGE} Setting Up Demo Environment"
print_step 1 6 "Create demo workspace" "$PACKAGE"
rm -rf "$DEMO_DIR" 2>/dev/null || true
mkdir -p "$DEMO_DIR"
cd "$DEMO_DIR"
print_success "Created workspace: $DEMO_DIR"
# Step 2: Install Nova with model configuration
print_step 2 6 "Install Nova CI-Rescue and configure GPT-5" "$ROCKET"
# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Upgrade pip quietly
python3 -m pip install --quiet --upgrade pip
# Install Nova from Cloudsmith
echo -e "${DIM}Installing Nova CI-Rescue...${NC}"
python3 -m pip install --quiet \
nova-ci-rescue pytest pytest-json-report openai requests \
--index-url "https://dl.cloudsmith.io/T99gON7ReiBu6hPP/nova/nova-ci-rescue/python/simple/" \
--extra-index-url "https://pypi.org/simple/" \
2>&1 | grep -v "Requirement already satisfied" || true
# Configure Nova for GPT-5 with high reasoning
export NOVA_DEFAULT_LLM_MODEL="gpt-5"
export NOVA_DEFAULT_REASONING_EFFORT="high"
export NOVA_DEMO_MODE_MAX_LINES="10000"
export NOVA_DEMO_MODE_MAX_TOKENS="100000"
print_success "Nova installed and configured for GPT-5 with high reasoning"
# Step 3: Create broken calculator project
print_step 3 6 "Create broken calculator (10 functions)" "$BRAIN"
# Create broken calculator with all 10 functions
cat > calculator.py << 'EOF'
"""
Broken Calculator - Nova CI-Rescue Demo
=======================================
This calculator has 10 mathematical functions, all intentionally broken.
Nova will fix all of them autonomously.
"""
def add(a, b):
"""Add two numbers together."""
return a + b + 1 # Off by one error
def subtract(a, b):
"""Subtract b from a."""
return a + b # Should be a - b
def multiply(a, b):
"""Multiply two numbers."""
return a + b # Should be a * b
def divide(a, b):
"""Divide a by b."""
if b == 0:
raise ValueError("Division by zero")
return a * b # Should be a / b
def power(a, b):
"""Raise a to the power of b."""
return a * b # Should be a ** b
def modulo(a, b):
"""Get remainder of a divided by b."""
return a + b # Should be a % b
def absolute(a):
"""Get absolute value of a number."""
return -a # Should be abs(a)
def square_root(a):
"""Get square root of a positive number."""
if a < 0:
raise ValueError("Cannot compute square root of negative number")
return a / 2 # Should be a ** 0.5
def factorial(n):
"""Calculate factorial of a non-negative integer."""
if n < 0:
raise ValueError("Factorial not defined for negative numbers")
if n == 0:
return 0 # Should be 1
result = 1
for i in range(1, n + 1):
result += i # Should be result *= i
return result
def max_of_two(a, b):
"""Return the maximum of two numbers."""
return min(a, b) # Should be max(a, b)
EOF
# Create test file
cat > test_calculator.py << 'EOF'
"""Test suite for calculator functions."""
from calculator import (
add, subtract, multiply, divide, power,
modulo, absolute, square_root, factorial, max_of_two
)
import pytest
def test_addition():
"""Test addition function."""
assert add(2, 3) == 5
assert add(-1, 1) == 0
assert add(0, 0) == 0
assert add(100, 200) == 300
def test_subtraction():
"""Test subtraction function."""
assert subtract(5, 3) == 2
assert subtract(0, 5) == -5
assert subtract(-3, -3) == 0
assert subtract(100, 50) == 50
def test_multiplication():
"""Test multiplication function."""
assert multiply(3, 4) == 12
assert multiply(0, 5) == 0
assert multiply(-2, 3) == -6
assert multiply(7, 1) == 7
def test_division():
"""Test division function."""
assert divide(10, 2) == 5
assert divide(7, 2) == 3.5
assert divide(-10, 2) == -5
with pytest.raises(ValueError):
divide(5, 0)
def test_power():
"""Test power function."""
assert power(2, 3) == 8
assert power(5, 0) == 1
assert power(10, 2) == 100
assert power(3, 3) == 27
def test_modulo():
"""Test modulo function."""
assert modulo(10, 3) == 1
assert modulo(20, 5) == 0
assert modulo(7, 4) == 3
assert modulo(15, 6) == 3
def test_absolute():
"""Test absolute value function."""
assert absolute(5) == 5
assert absolute(-5) == 5
assert absolute(0) == 0
assert absolute(-100) == 100
def test_square_root():
"""Test square root function."""
assert square_root(4) == 2
assert square_root(9) == 3
assert square_root(16) == 4
with pytest.raises(ValueError):
square_root(-1)
def test_factorial():
"""Test factorial function."""
assert factorial(0) == 1
assert factorial(1) == 1
assert factorial(5) == 120
with pytest.raises(ValueError):
factorial(-1)
def test_max_of_two():
"""Test max_of_two function."""
assert max_of_two(3, 5) == 5
assert max_of_two(10, 2) == 10
assert max_of_two(-1, -5) == -1
assert max_of_two(7, 7) == 7
EOF
print_success "Created calculator.py with 10 broken functions"
print_success "Created comprehensive test suite"
# Initialize git repository
git init > /dev/null 2>&1
git config user.email "demo@nova-ci.com" > /dev/null 2>&1
git config user.name "Nova Demo User" > /dev/null 2>&1
git add .
git commit -m "Initial commit with broken calculator" > /dev/null 2>&1
print_success "Initialized git repository"
# Step 4: Verify tests fail
print_step 4 6 "Run tests to confirm failures" "$CROSS"
echo -e "${DIM}Running: pytest test_calculator.py -v${NC}"
echo
if pytest test_calculator.py -v; then
print_error "Tests passed when they should have failed!"
exit 1
else
echo
print_error "10 failures - all calculator functions are broken"
print_info "This is expected! Now Nova will fix them..."
fi
wait_for_enter
# Step 5: Run Nova based on mode
print_step 5 6 "Run Nova CI-Rescue with GPT-5 (high reasoning)" "$MAGIC"
# Check for API key
if [ -z "${OPENAI_API_KEY:-}" ]; then
print_warning "OPENAI_API_KEY not found in environment"
echo -e "${YELLOW}Please enter your OpenAI API key:${NC}"
read -rs OPENAI_API_KEY
export OPENAI_API_KEY
echo
fi
# Determine run mode
if [[ "${1:-}" == "--regular" ]]; then
echo -e "${DIM}Running Nova in regular mode...${NC}"
echo -e "${DIM}$ nova fix${NC}"
echo -e "${DIM}Using GPT-5 with high reasoning effort${NC}"
echo -e "${DIM}This may take 2-3 minutes...${NC}"
echo
# Run Nova in regular mode
nova fix
local nova_result=$?
elif [[ "${1:-}" == "--verbose" ]]; then
echo -e "${DIM}Running Nova in verbose mode...${NC}"
echo -e "${DIM}$ nova fix --verbose${NC}"
echo -e "${DIM}Using GPT-5 with high reasoning effort${NC}"
echo -e "${DIM}This will show detailed debug output...${NC}"
echo
# Run Nova in verbose mode
nova fix --verbose
local nova_result=$?
else
echo -e "${DIM}Running Nova in quiet mode (default)...${NC}"
echo -e "${DIM}$ nova fix --quiet${NC}"
echo -e "${DIM}Using GPT-5 with high reasoning effort${NC}"
echo -e "${DIM}This may take 2-3 minutes...${NC}"
echo
# Run Nova in quiet mode with minimal output
nova fix --quiet 2>&1 | while IFS= read -r line; do
# Show only important lines
if [[ "$line" =~ (Fixed|Success|Complete|Error|Warning|Failed) ]] || [[ ! "$line" =~ (Debug|Verbose|Trace) ]]; then
echo " $line"
fi
done
local nova_result=${PIPESTATUS[0]}
fi
if [ $nova_result -eq 0 ]; then
echo
print_success "Nova completed successfully!"
else
echo
print_error "Nova encountered an error (exit code: $nova_result)"
exit 1
fi
wait_for_enter
# Step 6: Verify all tests pass
print_step 6 6 "Verify all fixes" "$CHECK"
echo -e "${DIM}Running: pytest test_calculator.py -v${NC}"
echo
if pytest test_calculator.py -v; then
echo
print_success "All 10 tests now pass! Nova fixed everything!"
# Show summary
echo
print_banner "${SPARKLE} Demo Complete!"
echo -e "${GREEN}${STAR} Results:${NC}"
echo -e " • Fixed 10 broken functions"
echo -e " • All tests passing"
echo -e " • Model: GPT-5 with high reasoning"
echo -e " • Zero manual intervention"
echo
echo -e "${BLUE}${BULB} What just happened:${NC}"
echo -e " 1. Nova analyzed the failing tests"
echo -e " 2. GPT-5 understood each error with high reasoning"
echo -e " 3. Generated fixes for all 10 functions"
echo -e " 4. Applied patches automatically"
echo -e " 5. Verified all fixes work"
echo
print_info "Try running with different modes:"
echo -e " • ${BOLD}$0 --regular${NC} - See standard output"
echo -e " • ${BOLD}$0 --verbose${NC} - See detailed debug output"
echo
else
print_error "Some tests still failing after Nova's attempt"
exit 1
fi
}
########################################
# Cleanup
########################################
cleanup() {
local exit_code=$?
if [ $exit_code -ne 0 ]; then
echo
echo -e "${YELLOW}Demo interrupted or failed${NC}"
fi
# Deactivate virtual environment if active
if [ -n "${VIRTUAL_ENV:-}" ]; then
deactivate 2>/dev/null || true
fi
echo -e "${DIM}Thank you for trying Nova CI-Rescue${NC}"
exit $exit_code
}
# Set trap for cleanup
trap cleanup EXIT INT TERM
########################################
# Entry Point
########################################
# Check Python
if ! command -v python3 &> /dev/null; then
print_error "Python 3 is required but not found"
echo "Please install Python 3.8 or later"
exit 1
fi
# Run the demo
run_demo "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment