### Install Moltbot with Default Settings Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt Installs Moltbot using the default configuration. This is the simplest way to get started. ```bash curl -fsSL --proto '=https' --tlsv1.2 https://molt.bot/install.sh | bash ``` -------------------------------- ### Install Dependencies Source: https://github.com/nilesh7757/leetclone/blob/main/CONTRIBUTING.md Install all necessary project dependencies using npm. ```bash npm install ``` -------------------------------- ### Install Moltbot Script Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt This script handles the installation of Moltbot. It checks for existing installations, clones the repository if necessary, installs dependencies using pnpm, builds the project, and creates a command-line wrapper. ```bash local repo_dir="$1" local repo_url="https://github.com/moltbot/moltbot.git" if [[ -d "$repo_dir/.git" ]]; then echo -e "${WARN}→${NC} Installing Moltbot from git checkout: ${INFO}${repo_dir}${NC}" else echo -e "${WARN}→${NC} Installing Moltbot from GitHub (${repo_url})..." fi if ! check_git; then install_git fi ensure_pnpm if [[ ! -d "$repo_dir" ]]; then git clone "$repo_url" "$repo_dir" fi if [[ "$GIT_UPDATE" == "1" ]]; then if [[ -z "$(git -C "$repo_dir" status --porcelain 2>/dev/null || true)" ]]; then git -C "$repo_dir" pull --rebase || true else echo -e "${WARN}→${NC} Repo is dirty; skipping git pull" fi fi cleanup_legacy_submodules "$repo_dir" SHARP_IGNORE_GLOBAL_LIBVIPS="$SHARP_IGNORE_GLOBAL_LIBVIPS" pnpm -C "$repo_dir" install if ! pnpm -C "$repo_dir" ui:build; then echo -e "${WARN}→${NC} UI build failed; continuing (CLI may still work)" fi pnpm -C "$repo_dir" build ensure_user_local_bin_on_path cat > "$HOME/.local/bin/clawdbot" < /dev/null; then maybe_sudo apt-get update -y maybe_sudo apt-get install -y git elif command -v dnf &> /dev/null; then maybe_sudo dnf install -y git elif command -v yum &> /dev/null; then maybe_sudo yum install -y git else echo -e "${ERROR}Error: Could not detect package manager for Git${NC}" exit 1 fi fi echo -e "${SUCCESS}✓${NC} Git installed" } ``` -------------------------------- ### Start Development Server Source: https://github.com/nilesh7757/leetclone/blob/main/CONTRIBUTING.md Launch the local development server to test your changes. ```bash npm run dev ``` -------------------------------- ### Set Up Environment Variables Source: https://github.com/nilesh7757/leetclone/blob/main/README.md Copy the example environment file to `.env` and populate it with your specific credentials. ```bash cp .env.example .env ``` -------------------------------- ### Main Installation Flow Logic Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt This script handles the main logic for installing Moltbot. It checks for help flags, detects existing checkouts, prompts the user to choose an installation method (git or npm) if a checkout is found, and validates the chosen method. It also includes a dry-run mode to preview actions without making changes. ```bash main() { if [[ "$HELP" == "1" ]]; then print_usage return 0 fi local detected_checkout="" detected_checkout="$(detect_clawdbot_checkout "$PWD" || true)" if [[ -z "$INSTALL_METHOD" && -n "$detected_checkout" ]]; then if ! is_promptable; then echo -e "${WARN}→${NC} Found a Moltbot checkout, but no TTY; defaulting to npm install." INSTALL_METHOD="npm" else local choice="" choice="$(prompt_choice "$(cat </dev/null; then echo -e "${WARN}→${NC} Removing npm global install (switching to git)..." npm uninstall -g clawdbot 2>/dev/null || true echo -e "${SUCCESS}✓${NC} npm global install removed" fi local repo_dir="$GIT_DIR" if [[ -n "$detected_checkout" ]]; then repo_dir="$detected_checkout" fi final_git_dir="$repo_dir" install_clawdbot_from_git "$repo_dir" else # Clean up git wrapper if switching to npm if [[ -x "$HOME/.local/bin/clawdbot" ]]; then echo -e "${WARN}→${NC} Removing git wrapper (switching to npm)..." rm -f "$HOME/.local/bin/clawdbot" echo -e "${SUCCESS}✓${NC} git wrapper removed" fi # Step 3: Git (required for npm installs that may fetch from git or apply patches) if ! check_git; then install_git fi # Step 4: npm permissions (Linux) fix_npm_permissions # Step 5: Moltbot install_clawdbot fi CLAWDBOT_BIN="$(resolve_clawdbot_bin || true)" # PATH warning: installs can succeed while the user's login shell still lacks npm's global bin dir. local npm_bin="" npm_bin="$(npm_global_bin_dir || true)" if [[ "$INSTALL_METHOD" == "npm" ]]; then warn_shell_path_missing_dir "$npm_bin" "npm global bin dir" fi if [[ "$INSTALL_METHOD" == "git" ]]; then if [[ -x "$HOME/.local/bin/clawdbot" ]]; then warn_shell_path_missing_dir "$HOME/.local/bin" "user-local bin dir (~/.local/bin)" fi fi # Step 6: Run doctor for migrations on upgrades and git installs local run_doctor_after=false if [[ "$is_upgrade" == "true" || "$INSTALL_METHOD" == "git" ]]; then run_doctor_after=true fi if [[ "$run_doctor_after" == "true" ]]; then run_doctor fi # Step 7: If BOOTSTRAP.md is still present in the workspace, resume onboarding run_bootstrap_onboarding_if_needed local installed_version installed_version=$(resolve_clawdbot_version) echo "" if [[ -n "$installed_version" ]]; then echo -e "${SUCCESS}${BOLD}🦞 Moltbot installed successfully (${installed_version})!${NC}" else echo -e "${SUCCESS}${BOLD}🦞 Moltbot installed successfully!${NC}" fi if [[ "$is_upgrade" == "true" ]]; then local update_messages=( "Leveled up! New skills unlocked. You're welcome." "Fresh code, same lobster. Miss me?" ``` -------------------------------- ### Install Moltbot Package Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt Installs the Moltbot package using npm. It checks for a beta version if USE_BETA is set, resolves the specific version, and handles installation retries with cleanup. ```bash install_clawdbot() { local package_name="clawdbot" if [[ "$USE_BETA" == "1" ]]; then local beta_version="" beta_version="$(resolve_beta_version || true)" if [[ -n "$beta_version" ]]; then CLAWDBOT_VERSION="$beta_version" echo -e "${INFO}i${NC} Beta tag detected (${beta_version}); installing beta." package_name="moltbot" else CLAWDBOT_VERSION="latest" echo -e "${INFO}i${NC} No beta tag found; installing latest." fi fi if [[ -z "${CLAWDBOT_VERSION}" ]]; then CLAWDBOT_VERSION="latest" fi local resolved_version="" resolved_version="$(npm view "${package_name}@${CLAWDBOT_VERSION}" version 2>/dev/null || true)" if [[ -n "$resolved_version" ]]; then echo -e "${WARN}→${NC} Installing Moltbot ${INFO}${resolved_version}${NC}..." else echo -e "${WARN}→${NC} Installing Moltbot (${INFO}${CLAWDBOT_VERSION}${NC})..." fi local install_spec="" if [[ "${CLAWDBOT_VERSION}" == "latest" ]]; then install_spec="${package_name}@latest" else install_spec="${package_name}@${CLAWDBOT_VERSION}" fi if ! install_clawdbot_npm "${install_spec}"; then echo -e "${WARN}→${NC} npm install failed; cleaning up and retrying..." cleanup_npm_clawdbot_paths install_clawdbot_npm "${install_spec}" fi if [[ "${CLAWDBOT_VERSION}" == "latest" && "${package_name}" == "clawdbot" ]]; then if ! resolve_clawdbot_bin &> /dev/null; then echo -e "${WARN}→${NC} npm install clawdbot@latest failed; retrying clawdbot@next" cleanup_npm_clawdbot_paths install_clawdbot_npm "clawdbot@next" fi fi ensure_clawdbot_bin_link || true echo -e "${SUCCESS}✓${NC} Moltbot installed" } ``` -------------------------------- ### Install Moltbot without Onboarding Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt Installs Moltbot and skips the initial onboarding process. Useful for automated deployments. ```bash curl -fsSL --proto '=https' --tlsv1.2 https://molt.bot/install.sh | bash -s -- --no-onboard ``` -------------------------------- ### Database Setup and Seeding Source: https://github.com/nilesh7757/leetclone/blob/main/README.md Execute these Prisma commands to generate the database schema, apply migrations, and seed the database. ```bash npx prisma generate npx prisma migrate dev npx prisma db seed ``` -------------------------------- ### Install Moltbot on macOS and Linux Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt Use this command to download and execute the Moltbot installation script. Ensure you are using a secure connection with TLS 1.2. ```bash #!/bin/bash set -euo pipefail # Moltbot Installer for macOS and Linux # Usage: curl -fsSL --proto '=https' --tlsv1.2 https://molt.bot/install.sh | bash BOLD='\033[1m' ACCENT='\033[38;2;255;90;45m' ``` -------------------------------- ### Clawdbot Installation Completion Messages Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt These messages are displayed upon successful completion of the Clawdbot installation. They confirm the installation and provide next steps or status information. ```bash local completion_messages=( "Ahh nice, I like it here. Got any snacks? " "Home sweet home. Don't worry, I won't rearrange the furniture." "I'm in. Let's cause some responsible chaos." "Installation complete. Your productivity is about to get weird." "Settled in. Time to automate your life whether you're ready or not." "Cozy. I've already read your calendar. We need to talk." "Finally unpacked. Now point me at your problems." "cracks claws Alright, what are we building?" "The lobster has landed. Your terminal will never be the same." "All done! I promise to only judge your code a little bit." ) local completion_message completion_message="${completion_messages[RANDOM % ${#completion_messages[@]}]}" echo -e "${MUTED}${completion_message}${NC}" ``` ```bash if [[ "$INSTALL_METHOD" == "git" && -n "$final_git_dir" ]]; then echo -e "Source checkout: ${INFO}${final_git_dir}${NC}" echo -e "Wrapper: ${INFO}\\$HOME/.local/bin/clawdbot${NC}" echo -e "Installed from source. To update later, run: ${INFO}clawdbot update --restart${NC}" echo -e "Switch to global install later: ${INFO}curl -fsSL --proto '=https' --tlsv1.2 https://molt.bot/install.sh | bash -s -- --install-method npm${NC}" elif [[ "$is_upgrade" == "true" ]]; then echo -e "Upgrade complete." if [[ -r /dev/tty && -w /dev/tty ]]; then local claw="${CLAWDBOT_BIN:-}" if [[ -z "$claw" ]]; then claw="$(resolve_clawdbot_bin || true)" fi if [[ -z "$claw" ]]; then echo -e "${WARN}→${NC} Skipping doctor: ${INFO}clawdbot${NC} not on PATH yet." warn_clawdbot_not_found return 0 fi local -a doctor_args=() if [[ "$NO_ONBOARD" == "1" ]]; then if "$claw" doctor --help 2>/dev/null | grep -q -- "--non-interactive"; then doctor_args+=("--non-interactive") fi fi echo -e "Running ${INFO}clawdbot doctor${NC}..." local doctor_ok=0 if (( ${#doctor_args[@]} )); then CLAWDBOT_UPDATE_IN_PROGRESS=1 "$claw" doctor "${doctor_args[@]}" /dev/null; then echo -e "${WARN}→${NC} Installing Homebrew..." run_remote_bash "https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh" # Add Homebrew to PATH for this session if [[ -f "/opt/homebrew/bin/brew" ]]; then eval "$(/opt/homebrew/bin/brew shellenv)" elif [[ -f "/usr/local/bin/brew" ]]; then eval "$(/usr/local/bin/brew shellenv)" fi echo -e "${SUCCESS}✓${NC} Homebrew installed" else echo -e "${SUCCESS}✓${NC} Homebrew already installed" fi fi } ``` -------------------------------- ### Run Development Servers Source: https://github.com/nilesh7757/leetclone/blob/main/README.md Start the Next.js application and the Socket.IO server in separate terminals. ```bash # Terminal 1: Next.js App npm run dev # Terminal 2: Socket.IO Server npm run socket ``` -------------------------------- ### Install Node.js Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt Installs Node.js version 22+ using Homebrew on macOS or NodeSource repositories on Linux via apt, dnf, or yum. Exits with an error if the package manager is not detected on Linux. ```bash install_node() { if [[ "$OS" == "macos" ]]; then echo -e "${WARN}→${NC} Installing Node.js via Homebrew..." brew install node@22 brew link node@22 --overwrite --force 2>/dev/null || true echo -e "${SUCCESS}✓${NC} Node.js installed" elif [[ "$OS" == "linux" ]]; then echo -e "${WARN}→${NC} Installing Node.js via NodeSource..." require_sudo if command -v apt-get &> /dev/null; then local tmp tmp="$(mktempfile)" download_file "https://deb.nodesource.com/setup_22.x" "$tmp" maybe_sudo -E bash "$tmp" maybe_sudo apt-get install -y nodejs elif command -v dnf &> /dev/null; then local tmp tmp="$(mktempfile)" download_file "https://rpm.nodesource.com/setup_22.x" "$tmp" maybe_sudo bash "$tmp" maybe_sudo dnf install -y nodejs elif command -v yum &> /dev/null; then local tmp tmp="$(mktempfile)" download_file "https://rpm.nodesource.com/setup_22.x" "$tmp" maybe_sudo bash "$tmp" maybe_sudo yum install -y nodejs else echo -e "${ERROR}Error: Could not detect package manager${NC}" echo "Please install Node.js 22+ manually: https://nodejs.org" exit 1 fi echo -e "${SUCCESS}✓${NC} Node.js installed" fi } ``` -------------------------------- ### Parse Command-Line Arguments for Moltbot Installer Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt Parses various command-line arguments for the Moltbot installation script, setting environment variables based on user input. ```bash parse_args() { while [[ $# -gt 0 ]]; do case "$1" in --no-onboard) NO_ONBOARD=1 shift ;; --onboard) NO_ONBOARD=0 shift ;; --dry-run) DRY_RUN=1 shift ;; --verbose) VERBOSE=1 shift ;; --no-prompt) NO_PROMPT=1 shift ;; --help|-h) HELP=1 shift ;; --install-method|--method) INSTALL_METHOD="$2" shift 2 ;; --version) CLAWDBOT_VERSION="$2" shift 2 ;; --beta) USE_BETA=1 shift ;; --npm) INSTALL_METHOD="npm" shift ;; --git|--github) INSTALL_METHOD="git" shift ;; --git-dir|--dir) GIT_DIR="$2" shift 2 ;; --no-git-update) GIT_UPDATE=0 shift ;; *) shift ;; esac done } ``` -------------------------------- ### Install Clawdbot via npm Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt Installs a specified package version of clawdbot globally using npm. It includes logic to handle and retry installations if npm encounters directory not empty or file exists errors. ```shell install_clawdbot_npm() { local spec="$1" local log log="$(mktempfile)" if ! SHARP_IGNORE_GLOBAL_LIBVIPS="$SHARP_IGNORE_GLOBAL_LIBVIPS" npm --loglevel "$NPM_LOGLEVEL" ${NPM_SILENT_FLAG:+$NPM_SILENT_FLAG} --no-fund --no-audit install -g "$spec" 2>&1 | tee "$log"; then if grep -q "ENOTEMPTY: directory not empty, rename .*clawdbot" "$log"; then echo -e "${WARN}→${NC} npm left a stale clawdbot directory; cleaning and retrying..." cleanup_npm_clawdbot_paths SHARP_IGNORE_GLOBAL_LIBVIPS="$SHARP_IGNORE_GLOBAL_LIBVIPS" npm --loglevel "$NPM_LOGLEVEL" ${NPM_SILENT_FLAG:+$NPM_SILENT_FLAG} --no-fund --no-audit install -g "$spec" return $? fi if grep -q "EEXIST" "$log"; then local conflict="" conflict="$(extract_clawdbot_conflict_path "$log" || true)" if [[ -n "$conflict" ]] && cleanup_clawdbot_bin_conflict "$conflict"; then SHARP_IGNORE_GLOBAL_LIBVIPS="$SHARP_IGNORE_GLOBAL_LIBVIPS" npm --loglevel "$NPM_LOGLEVEL" ${NPM_SILENT_FLAG:+$NPM_SILENT_FLAG} --no-fund --no-audit install -g "$spec" return $? fi echo -e "${ERROR}npm failed because a clawdbot binary already exists.${NC}" if [[ -n "$conflict" ]]; then echo -e "${INFO}i${NC} Remove or move ${INFO}${conflict}${NC}, then retry." fi echo -e "${INFO}i${NC} Or rerun with ${INFO}npm install -g --force ${spec}${NC} (overwrites)." fi fi } ``` -------------------------------- ### Ensure PNPM Installation Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt Ensures that pnpm is installed. It first checks if pnpm is available, then attempts to install it using Corepack, and falls back to npm if Corepack is not available. ```bash ensure_pnpm() { if command -v pnpm &> /dev/null; then return 0 fi if command -v corepack &> /dev/null; then echo -e "${WARN}→${NC} Installing pnpm via Corepack..." corepack enable >/dev/null 2>&1 || true corepack prepare pnpm@10 --activate echo -e "${SUCCESS}✓${NC} pnpm installed" return 0 fi echo -e "${WARN}→${NC} Installing pnpm via npm..." fix_npm_permissions npm install -g pnpm@10 echo -e "${SUCCESS}✓${NC} pnpm installed" return 0 } ``` -------------------------------- ### Check for Existing Moltbot Installation Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt Checks if 'clawdbot' is already installed and available in the system's PATH. Returns 0 if found, 1 otherwise. ```bash check_existing_clawdbot() { if [[ -n "$(type -P clawdbot 2>/dev/null || true)" ]]; then echo -e "${WARN}→${NC} Existing Moltbot installation detected" return 0 fi return 1 } ``` -------------------------------- ### Run Code Against Example Test Cases Source: https://context7.com/nilesh7757/leetclone/llms.txt Executes provided code against example test cases for a problem, offering immediate feedback without creating a formal submission. Custom test cases can be provided. ```APIDOC ## `POST /api/run` — Run Code Against Example Test Cases (No Auth Required) Executes code against example test cases for immediate feedback without creating a submission record. Accepts custom `testCases` or falls back to stored example test cases for a known `problemId`. ### Method POST ### Endpoint `/api/run` ### Request Body - **language** (string) - Required - The programming language of the code (e.g., python, javascript) - **code** (string) - Required - The code to be executed - **type** (string) - Required - The type of problem (e.g., CODING) - **testCases** (array) - Optional - An array of custom test cases. If not provided, stored example test cases are used. - **input** (string) - The input for the test case - **expectedOutput** (string) - The expected output for the test case ### Request Example ```bash curl -X POST http://localhost:3000/api/run \ -H "Content-Type: application/json" \ -d '{ "language": "python", "code": "n = int(input())\nprint(n * 2)", "type": "CODING", "testCases": [ { "input": "5", "expectedOutput": "10" }, { "input": "0", "expectedOutput": "0" } ] }' ``` ### Response #### Success Response (200 OK) - **results** (array) - An array of execution results for each test case. - **input** (string) - The input provided for the test case - **expected** (string) - The expected output for the test case - **actual** (string) - The actual output produced by the code - **status** (string) - The status of the test case (e.g., Accepted, Wrong Answer) - **runtime** (integer) - The execution time in milliseconds ### Response Example ```json { "results": [ { "input": "5", "expected": "10", "actual": "10", "status": "Accepted", "runtime": 52 }, { "input": "0", "expected": "0", "actual": "0", "status": "Accepted", "runtime": 48 } ] } ``` ``` -------------------------------- ### Get NPM Global Bin Directory Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt Determines and returns the global npm binary directory. It checks both 'npm prefix -g' and 'npm config get prefix' for the directory. ```bash npm_global_bin_dir() { local prefix="" prefix="$(npm prefix -g 2>/dev/null || true)" if [[ -n "$prefix" ]]; then if [[ "$prefix" == /* ]]; then echo "${prefix%/}/bin" return 0 fi fi prefix="$(npm config get prefix 2>/dev/null || true)" if [[ -n "$prefix" && "$prefix" != "undefined" && "$prefix" != "null" ]]; then if [[ "$prefix" == /* ]]; then echo "${prefix%/}/bin" return 0 fi fi echo "" return 1 } ``` -------------------------------- ### Require sudo for Linux Installs Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt Ensures that 'sudo' is available and the user has privileges to use it for system-level installations on Linux. Exits with an error if sudo is not available or not permitted. ```bash require_sudo() { if [[ "$OS" != "linux" ]]; then return 0 fi if is_root; then return 0 fi if command -v sudo &> /dev/null; then return 0 fi echo -e "${ERROR}Error: sudo is required for system installs on Linux${NC}" echo "Install sudo or re-run as root." exit 1 } ``` -------------------------------- ### Print Usage Function Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt Displays the usage instructions and available options for the Moltbot installer script. It uses a heredoc to format the output. ```shell print_usage() { cat < npm install: version (default: latest) --beta Use beta if available, else latest --git-dir, --dir Checkout directory (default: ~/moltbot) --no-git-update Skip git pull for existing checkout --no-onboard Skip onboarding (non-interactive) --no-prompt Disable prompts (required in CI/automation) --dry-run Print what would happen (no changes) --verbose Print debug output (set -x, npm verbose) --help, -h Show this help Environment variables: CLAWDBOT_INSTALL_METHOD=git|npm CLAWDBOT_VERSION=latest|next| CLAWDBOT_BETA=0|1 CLAWDBOT_GIT_DIR=... CLAWDBOT_GIT_UPDATE=0|1 CLAWDBOT_NO_PROMPT=1 CLAWDBOT_DRY_RUN=1 CLAWDBOT_NO_ONBOARD=1 CLAWDBOT_VERBOSE=1 EOF } ``` -------------------------------- ### Check Git Installation Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt Checks if the Git command is available in the system's PATH. Returns 0 if Git is found, 1 otherwise. ```bash check_git() { if command -v git &> /dev/null; then echo -e "${SUCCESS}✓${NC} Git already installed" return 0 fi echo -e "${WARN}→${NC} Git not found" return 1 } ``` -------------------------------- ### Run Code Against Test Cases API Endpoint Source: https://context7.com/nilesh7757/leetclone/llms.txt Executes provided code against example test cases for immediate feedback without creating a submission. Accepts custom test cases or uses stored examples for a given problem ID. ```bash curl -X POST http://localhost:3000/api/run \ -H "Content-Type: application/json" \ -d '{ \ "language": "python", \ "code": "n = int(input())\ print(n * 2)", \ "type": "CODING", \ "testCases": [ \ { "input": "5", "expectedOutput": "10" }, \ { "input": "0", "expectedOutput": "0" } \ ] \ }' # { # "results": [ # { "input": "5", "expected": "10", "actual": "10", "status": "Accepted", "runtime": 52 }, # { "input": "0", "expected": "0", "actual": "0", "status": "Accepted", "runtime": 48 } # ] # } ``` -------------------------------- ### Check Node.js Version Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt Verifies if Node.js is installed and if its version is 22 or higher. Returns 0 if the condition is met, 1 otherwise. ```bash check_node() { if command -v node &> /dev/null; then NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1) if [[ "$NODE_VERSION" -ge 22 ]]; then echo -e "${SUCCESS}✓${NC} Node.js v$(node -v | cut -d'v' -f2) found" return 0 else echo -e "${WARN}→${NC} Node.js $(node -v) found, but v22+ required" return 1 fi else echo -e "${WARN}→${NC} Node.js not found" return 1 fi } ``` -------------------------------- ### Check for Gateway Daemon Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt Checks if clawdbot is installed and if the gateway daemon is loaded. If detected, it suggests restarting the daemon. ```shell if command -v clawdbot &> /dev/null; then local claw="${CLAWDBOT_BIN:-}" if [[ -z "$claw" ]]; then claw="$(resolve_clawdbot_bin || true)" fi if [[ -n "$claw" ]] && is_gateway_daemon_loaded "$claw"; then echo -e "${INFO}i${NC} Gateway daemon detected; restart with: ${INFO}clawdbot daemon restart${NC}" fi fi ``` -------------------------------- ### TrieVisualizer Usage Example Source: https://github.com/nilesh7757/leetclone/blob/main/src/features/visualizer/components/DSA/Trie_README.md Demonstrates how to integrate the TrieVisualizer component into a React application. The 'speed' prop can be adjusted to control animation timing. ```tsx import TrieVisualizer from './TrieVisualizer'; export default function Page() { return (
); } ``` -------------------------------- ### Render FloydWarshallVisualizer Component Source: https://github.com/nilesh7757/leetclone/blob/main/src/features/visualizer/components/DSA/FloydWarshall_README.md This is the main usage example for the FloydWarshallVisualizer component. It shows how to import and render the component within a React application, with an optional speed prop for animation control. ```tsx import FloydWarshallVisualizer from './FloydWarshallVisualizer'; export default function Page() { return (
); } ``` -------------------------------- ### Warn if Clawdbot Not Found Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt Provides helpful messages and troubleshooting steps when 'clawdbot' is installed but not discoverable in the current shell's PATH. It suggests commands like 'hash -r' or 'rehash' and provides information about npm prefix and binary paths. ```bash warn_clawdbot_not_found() { echo -e "${WARN}→${NC} Installed, but ${INFO}clawdbot${NC} is not discoverable on PATH in this shell." echo -e "Try: ${INFO}hash -r${NC} (bash) or ${INFO}rehash${NC} (zsh), then retry." echo -e "Docs: ${INFO}https://docs.molt.bot/install#nodejs--npm-path-sanity${NC}" local t="" t="$(type -t clawdbot 2>/dev/null || true)" if [[ "$t" == "alias" || "$t" == "function" ]]; then echo -e "${WARN}→${NC} Found a shell ${INFO}${t}${NC} named ${INFO}clawdbot${NC}; it may shadow the real binary." fi if command -v nodenv &> /dev/null; then echo -e "Using nodenv? Run: ${INFO}nodenv rehash${NC}" fi local npm_prefix="" npm_prefix="$(npm prefix -g 2>/dev/null || true)" local npm_bin="" npm_bin="$(npm_global_bin_dir 2>/dev/null || true)" if [[ -n "$npm_prefix" ]]; then echo -e "npm prefix -g: ${INFO}${npm_prefix}${NC}" fi if [[ -n "$npm_bin" ]]; then echo -e "npm bin -g: ${INFO}${npm_bin}${NC}" echo -e "If needed: ${INFO}export PATH=\"${npm_bin}:\\$PATH\"${NC}" fi } ``` -------------------------------- ### Run Bootstrap Onboarding if Needed Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt Checks for a 'BOOTSTRAP.md' file in the workspace and initiates the 'clawdbot onboard' process if found and the TTY is available. Skips if NO_ONBOARD is set to '1'. ```shell run_bootstrap_onboarding_if_needed() { if [[ "${NO_ONBOARD}" == "1" ]]; then return fi local workspace workspace="$(resolve_workspace_dir)" local bootstrap="${workspace}/BOOTSTRAP.md" if [[ ! -f "${bootstrap}" ]]; then return fi if [[ ! -r /dev/tty || ! -w /dev/tty ]]; then echo -e "${WARN}→${NC} BOOTSTRAP.md found at ${INFO}${bootstrap}${NC}; no TTY, skipping onboarding." echo -e "Run ${INFO}clawdbot onboard${NC} later to finish setup." return fi echo -e "${WARN}→${NC} BOOTSTRAP.md found at ${INFO}${bootstrap}${NC}; starting onboarding..." local claw="${CLAWDBOT_BIN:-}" if [[ -z "$claw" ]]; then claw="$(resolve_clawdbot_bin || true)" fi if [[ -z "$claw" ]]; then echo -e "${WARN}→${NC} BOOTSTRAP.md found, but ${INFO}clawdbot${NC} not on PATH yet; skipping onboarding." warn_clawdbot_not_found return fi "$claw" onboard || { echo -e "${ERROR}Onboarding failed; BOOTSTRAP.md still present. Re-run ${INFO}clawdbot onboard${ERROR}.${NC}" return } } ``` -------------------------------- ### Clone Repository and Navigate Source: https://github.com/nilesh7757/leetclone/blob/main/README.md Use these bash commands to clone the LEETCLONE repository and navigate into the project directory. ```bash git clone https://github.com/nilesh7757/LEETCLONE.git cd LEETCLONE ``` -------------------------------- ### Onboarding with TTY Available Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt Executes the clawdbot onboard command when a TTY is available. ```shell exec /dev/null; then nodenv rehash >/dev/null 2>&1 || true fi } ``` -------------------------------- ### Handle No TTY Available Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt Informs the user that onboarding is skipped due to no TTY and suggests running the command later. ```shell echo -e "${WARN}→${NC} No TTY available; skipping onboarding." echo -e "Run ${INFO}clawdbot onboard${NC} later." return 0 ``` -------------------------------- ### Display FAQ Link Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt Prints a link to the clawdbot FAQ page. ```shell echo "" echo -e "FAQ: ${INFO}https://docs.molt.bot/start/faq${NC}" ``` -------------------------------- ### User Registration API Endpoint Source: https://context7.com/nilesh7757/leetclone/llms.txt Handles user registration by creating an account, hashing passwords, and sending an OTP via email. For unverified accounts, it refreshes the OTP. ```bash curl -X POST http://localhost:3000/api/register \ -H "Content-Type: application/json" \ -d '{"name": "Alice", "email": "alice@example.com", "password": "securePass123"}' # 201 Created (new user): # { "message": "OTP sent to email", "requireVerification": true, "email": "alice@example.com" } # 200 OK (unverified existing user — OTP resent): # { "message": "OTP sent to email", "requireVerification": true, "email": "alice@example.com" } # 409 Conflict (already verified): # { "error": "User with this email already exists" } # Complete verification after receiving OTP: curl -X POST http://localhost:3000/api/verify \ -H "Content-Type: application/json" \ -d '{"email": "alice@example.com", "otp": "483921"}' # { "message": "Account verified successfully" } ``` -------------------------------- ### Fix npm Permissions for Global Installs (Linux) Source: https://github.com/nilesh7757/leetclone/blob/main/install_sh.txt Configures npm for user-local installs on Linux if global write permissions are insufficient. It modifies npm's prefix and updates the PATH in shell configuration files. ```shell fix_npm_permissions() { if [[ "$OS" != "linux" ]]; then return 0 fi local npm_prefix npm_prefix="$(npm config get prefix 2>/dev/null || true)" if [[ -z "$npm_prefix" ]]; then return 0 fi if [[ -w "$npm_prefix" || -w "$npm_prefix/lib" ]]; then return 0 fi echo -e "${WARN}→${NC} Configuring npm for user-local installs..." mkdir -p "$HOME/.npm-global" npm config set prefix "$HOME/.npm-global" # shellcheck disable=SC2016 local path_line='export PATH="$HOME/.npm-global/bin:$PATH"' for rc in "$HOME/.bashrc" "$HOME/.zshrc"; do if [[ -f "$rc" ]] && ! grep -q ".npm-global" "$rc"; then echo "$path_line" >> "$rc" fi done export PATH="$HOME/.npm-global/bin:$PATH" echo -e "${SUCCESS}✓${NC} npm configured for user installs" } ``` -------------------------------- ### POST /api/study-plans - Create a Study Plan Source: https://context7.com/nilesh7757/leetclone/llms.txt Creates a new study plan. Regular users can create private DRAFT plans, while admins have additional options for public or official plans. The request body must include a title, description, and an ordered list of problems. ```bash curl -X POST http://localhost:3000/api/study-plans \ -H "Content-Type: application/json" \ -H "Cookie: authjs.session-token=..." \ -d '{ "title": "Arrays & Hashing in 7 Days", "description": "A structured plan to master core array techniques.", "isPublic": false, "durationDays": 7, "problems": [ { "problemId": "uuid-1", "order": 1 }, { "problemId": "uuid-2", "order": 2 } ] }' ```