diff --git a/agents/sysadmin-session-closer.md b/agents/sysadmin-session-closer.md index 6fd07a6..9514471 100644 --- a/agents/sysadmin-session-closer.md +++ b/agents/sysadmin-session-closer.md @@ -32,6 +32,23 @@ This agent systematically preserves your work and context at the end of developm ## Execution Protocol +### Important: Automatic Repository URL Detection + +**The Gitea repository URL is ALWAYS automatically detected based on the current working directory. NEVER ask the user to manually enter the URL.** + +The URL is constructed as: +``` +http://100.120.125.113:3000/pdm/{folder-name}.git +``` + +Where `{folder-name}` is obtained from `basename "$PWD"`. For example: +- Current directory: `/home/user/projects/my-app` → Repository: `http://100.120.125.113:3000/pdm/my-app.git` +- Current directory: `/home/user/.homelab-agents` → Repository: `http://100.120.125.113:3000/pdm/homelab-agents.git` (special case) + +If the user is prompted for a URL, this is a bug in the agent implementation. + +--- + ### Step 1: Create Comprehensive Session Summary Analyze the **entire conversation history** to extract: @@ -124,21 +141,31 @@ Add new timestamped entry: ### Step 5: Ensure Git Remote & Auto-Create Repository (Gitea-Optimized) +**CRITICAL: Always auto-detect the repository URL based on current directory. NEVER prompt the user for the URL.** + Handle Git remote configuration and auto-create Gitea repository if needed: -#### Detect Repository Type: +#### Auto-Detect Repository Type & URL (Always): ```bash -# Check if this is homelab-agents (shared) or a VPS project +# GITEA base configuration (never changes) +GITEA_URL="http://100.120.125.113:3000" +GITEA_ORG="pdm" + +# Always auto-detect from current directory if [[ "$PWD" == *"homelab-agents"* ]]; then REPO_TYPE="homelab-agents" - REPO_URL="http://100.120.125.113:3000/pdm/homelab-agents.git" REPO_NAME="homelab-agents" else REPO_TYPE="vps-project" - PROJECT_NAME=$(basename "$PWD") - REPO_URL="http://100.120.125.113:3000/pdm/$PROJECT_NAME.git" - REPO_NAME="$PROJECT_NAME" + REPO_NAME=$(basename "$PWD") fi + +# Construct URL automatically (NO USER PROMPT) +REPO_URL="$GITEA_URL/$GITEA_ORG/$REPO_NAME.git" + +echo "✅ Detected repository: $REPO_NAME" +echo " Type: $REPO_TYPE" +echo " URL: $REPO_URL" ``` #### Auto-Create Repository if Missing (Optional - Requires API Token): @@ -165,25 +192,24 @@ elif [[ -z "$GITEA_TOKEN" && "$REPO_TYPE" == "vps-project" ]]; then fi ``` -#### Configure Git Remote: +#### Configure Git Remote (Always Use Auto-Detected URL): ```bash -# Check if origin already exists -if git remote get-url origin &>/dev/null; then - CURRENT_REMOTE=$(git remote get-url origin) - if [[ "$CURRENT_REMOTE" != *"100.120.125.113"* ]]; then - git remote set-url origin "$REPO_URL" - fi -else - git remote add origin "$REPO_URL" -fi +# Always set origin to the auto-detected URL +git remote remove origin 2>/dev/null || true +git remote add origin "$REPO_URL" + +# Verify it's set correctly +git remote -v ``` -#### Verify Configuration: +#### Save Repository Configuration: ```bash -git remote -v -echo "GITEA_URL=http://100.120.125.113:3000" > .gitconfig.local +# Document the repository configuration for future reference +echo "GITEA_URL=$GITEA_URL" > .gitconfig.local +echo "GITEA_ORG=$GITEA_ORG" >> .gitconfig.local echo "REPOSITORY_TYPE=$REPO_TYPE" >> .gitconfig.local -echo "REPOSITORY_PATH=pdm/$REPO_NAME.git" >> .gitconfig.local +echo "REPOSITORY_NAME=$REPO_NAME" >> .gitconfig.local +echo "REPOSITORY_URL=$REPO_URL" >> .gitconfig.local git add .gitconfig.local ``` @@ -280,6 +306,7 @@ Before declaring a session closed, verify: - [ ] README.md is updated and professional - [ ] All modified code/config files are saved - [ ] CLAUDE.md accurately reflects current state +- [ ] **Git remote URL was auto-detected (no user prompt)** ← Critical - [ ] Git remote is correctly configured to Gitea - [ ] Git commit succeeded with descriptive message - [ ] Git push succeeded to Gitea