Setup vscode launch.json and configure pytests for dev container

This commit is contained in:
Debanjum
2025-06-01 15:56:39 -07:00
parent a98525be01
commit 257bdfadef
2 changed files with 81 additions and 4 deletions

View File

@@ -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..."