diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 52232951..acc2ca7d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -35,11 +35,16 @@ "--profile", "black", "--filter-files" - ] + ], + "python.testing.pytestArgs": [ + "tests" + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true } } }, - "postCreateCommand": "scripts/dev_setup.sh", + "postCreateCommand": "scripts/dev_setup.sh --devcontainer", "features": { "ghcr.io/devcontainers-contrib/features/black:2": {}, "ghcr.io/devcontainers-contrib/features/mypy:2": {}, diff --git a/scripts/dev_setup.sh b/scripts/dev_setup.sh index 24be672d..3de55d1d 100755 --- a/scripts/dev_setup.sh +++ b/scripts/dev_setup.sh @@ -2,14 +2,18 @@ # --- PROJECT_ROOT=$(git rev-parse --show-toplevel) -# Default to minimal installation unless --full flag passed +# Default is a minimal, local installation unless config flags are set. INSTALL_FULL=false +DEVCONTAINER=false for arg in "$@" do if [ "$arg" == "--full" ] then INSTALL_FULL=true - break + fi + if [ "$arg" == "--devcontainer" ] + then + DEVCONTAINER=true fi done @@ -42,6 +46,74 @@ if [ "$INSTALL_FULL" = true ] ; then yarn install fi +# Create .vscode/launch.json if it doesn't exist +# --- +VSCODE_DIR="$PROJECT_ROOT/.vscode" +LAUNCH_JSON_PATH="$VSCODE_DIR/launch.json" + +# Overwrite project vscode launch.json in devcontainer +# --- +# Differs from default launch.json with sudo true. +# Required by pgserver in github codespaces, not in local dev. +mkdir -p "$VSCODE_DIR" +if [ "$DEVCONTAINER" = true ]; then + echo "Creating $LAUNCH_JSON_PATH..." + cat << EOF > "$LAUNCH_JSON_PATH" +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Launch Khoj", + "type": "debugpy", + "request": "launch", + "module": "src.khoj.main", + "justMyCode": false, + "console": "integratedTerminal", + "sudo": true, + "args": [ + "-v", + "--anonymous-mode", + "--non-interactive", + "--port=42110", + ], + // You can load environment variables via a .env file, the env field below or Github Codespace secrets. + "envFile": "\${workspaceFolder}/.env", + "env": { + "KHOJ_ADMIN_EMAIL": "admin", + "KHOJ_ADMIN_PASSWORD": "admin", + "USE_EMBEDDED_DB": "True", + "KHOJ_DEBUG": "True", + "KHOJ_TELEMETRY_DISABLE": "True", + // Set LLM Provider API keys + // --- + // "GEMINI_API_KEY": "", + // "ANTHROPIC_API_KEY": "", + // "OPENAI_API_KEY": "", + // "OPENAI_BASE_URL": "http://localhost:11434/v1/", + // "KHOJ_DEFAULT_CHAT_MODEL": "claude-sonnet-4-0", + // Set Search Provider API keys + // --- + // "SERPER_DEV_API_KEY": "", + // "OLOSTEP_API_KEY": "", + // "FIRECRAWL_API_KEY": "", + // "JINA_API_KEY": "", + // Enable Khoj Operator + // --- + // "KHOJ_OPERATOR_ENABLED": "True", + // Configure Code Sandbox + // --- + // "KHOJ_TERRARIUM_URL": "http://localhost:8080", + // "E2B_API_KEY": "", + // Enable Promptracer to debug prompt flows + // --- + // "PROMPTRACE_DIR": "\${workspaceFolder}/promptrace", + } + }, + ] +} +EOF +fi + # Install pre-commit hooks # ---- echo "Installing pre-commit hooks..."