From e8d145a1301680831a99124026d278b779a2571e Mon Sep 17 00:00:00 2001 From: saravanakumardb1 Date: Tue, 24 Mar 2026 16:05:12 -0700 Subject: [PATCH] fix(workflows): normalize repo management coverage --- .windsurf/workflows/repo_backup-and-push.md | 4 +- .../workflows/repo_backup-main-branch.md | 2 +- .windsurf/workflows/repo_commit-workspace.md | 7 +- .windsurf/workflows/repo_push-repos.md | 4 +- .windsurf/workflows/repo_sync-repos.md | 4 +- .windsurf/workflows/repo_update-agent-docs.md | 29 ++-- scripts/commit-workspace.sh | 142 ++++++++++++++++++ scripts/sync-workflows.sh | 24 +-- 8 files changed, 184 insertions(+), 32 deletions(-) create mode 100644 scripts/commit-workspace.sh diff --git a/.windsurf/workflows/repo_backup-and-push.md b/.windsurf/workflows/repo_backup-and-push.md index 1b194198..e53d0839 100644 --- a/.windsurf/workflows/repo_backup-and-push.md +++ b/.windsurf/workflows/repo_backup-and-push.md @@ -11,7 +11,7 @@ Combines `/repo_backup-main-branch` and `/repo_push-repos` into a single sequent Creates timestamped backup branches with smart duplicate detection. // turbo -Run `bash scripts/backup-main.sh` from any repository root +Run `bash /Users/sd9235/code/mygh/learning_ai_common_plat/scripts/backup-main.sh` ## Step 2: Push all repos to origin @@ -30,7 +30,7 @@ echo "✨ All repos pushed!" ## What it does: 1. **Backup** — creates timestamped backup branches, cleans up old ones (7 days), skips duplicates -2. **Push** — pushes `main` to `origin/main` for all 13 repos +2. **Push** — pushes `main` to `origin/main` for all repositories listed in the canonical `repos.txt` ## Repositories: diff --git a/.windsurf/workflows/repo_backup-main-branch.md b/.windsurf/workflows/repo_backup-main-branch.md index 451cbd03..5339ce07 100644 --- a/.windsurf/workflows/repo_backup-main-branch.md +++ b/.windsurf/workflows/repo_backup-main-branch.md @@ -7,7 +7,7 @@ description: Smart backup of main branches with duplicate detection Creates smart backups of main branches across all repositories. // turbo -Run `bash scripts/backup-main.sh` from any repository root +Run `bash /Users/sd9235/code/mygh/learning_ai_common_plat/scripts/backup-main.sh` The script reads `repos.txt` to determine which repositories to back up. diff --git a/.windsurf/workflows/repo_commit-workspace.md b/.windsurf/workflows/repo_commit-workspace.md index 99b05312..297dbc57 100644 --- a/.windsurf/workflows/repo_commit-workspace.md +++ b/.windsurf/workflows/repo_commit-workspace.md @@ -8,7 +8,7 @@ date: 2025-02-12 Scans all repositories for pending changes and commits them in logical order with intelligent commit messages. // turbo -~/commit-workspace.sh +bash /Users/sd9235/code/mygh/learning_ai_common_plat/scripts/commit-workspace.sh ## What it does: @@ -47,7 +47,7 @@ The script analyzes file types to generate appropriate messages: ```bash # Run from anywhere -~/commit-workspace.sh +bash /Users/sd9235/code/mygh/learning_ai_common_plat/scripts/commit-workspace.sh # Or via Windsurf /commit-workspace @@ -106,7 +106,8 @@ Found changes in 2 repo(s) ## Notes: -- Script location: `~/commit-workspace.sh` +- Script location: `learning_ai_common_plat/scripts/commit-workspace.sh` +- Reads repo names from `learning_ai_common_plat/.windsurf/workflows/repos.txt` - Requires git access to all repos - Works with any branch (but assumes main is primary) - Will skip repos with no changes diff --git a/.windsurf/workflows/repo_push-repos.md b/.windsurf/workflows/repo_push-repos.md index 2ebc559b..39e7463f 100644 --- a/.windsurf/workflows/repo_push-repos.md +++ b/.windsurf/workflows/repo_push-repos.md @@ -1,5 +1,5 @@ --- -description: Push local main branch to origin for all 13 workspace repos +description: Push local main branch to origin for all managed workspace repos --- # Push Repos @@ -18,7 +18,7 @@ done < ~/code/mygh/learning_ai_common_plat/.windsurf/workflows/repos.txt ## What it does: -1. Iterates over all 13 workspace repos +1. Iterates over all repositories listed in the canonical `repos.txt` 2. Runs `git push origin main` in each 3. Fails fast if a repo has diverged from remote (resolve with rebase manually) diff --git a/.windsurf/workflows/repo_sync-repos.md b/.windsurf/workflows/repo_sync-repos.md index 13a40c67..03091d5f 100644 --- a/.windsurf/workflows/repo_sync-repos.md +++ b/.windsurf/workflows/repo_sync-repos.md @@ -1,5 +1,5 @@ --- -description: Pull latest from origin main across all 13 workspace repos +description: Pull latest from origin main across all managed workspace repos --- # Sync Repos @@ -18,7 +18,7 @@ done < ~/code/mygh/learning_ai_common_plat/.windsurf/workflows/repos.txt ## What it does: -1. Iterates over all 13 workspace repos +1. Iterates over all repositories listed in the canonical `repos.txt` 2. Runs `git pull --ff-only origin main` in each 3. Fails fast if there are local divergent commits (use `git pull --rebase` manually in that case) diff --git a/.windsurf/workflows/repo_update-agent-docs.md b/.windsurf/workflows/repo_update-agent-docs.md index 51bbe0f5..4d9dde76 100644 --- a/.windsurf/workflows/repo_update-agent-docs.md +++ b/.windsurf/workflows/repo_update-agent-docs.md @@ -8,16 +8,16 @@ Regenerates all 8 AI agent configuration files across all repos in the workspace ## Files Generated Per Repo -| File | Tool | -|------|------| -| `AGENTS.md` | Universal (OpenAI Codex, Claude, Copilot, etc.) | -| `CLAUDE.md` | Claude Code | -| `.cursorrules` | Cursor AI | -| `.github/copilot-instructions.md` | GitHub Copilot | -| `.windsurfrules` | Windsurf / Cascade | -| `.clinerules` | Cline / Roo Code | -| `.aider.conf.yml` | Aider | -| `.editorconfig` | All editors | +| File | Tool | +| --------------------------------- | ----------------------------------------------- | +| `AGENTS.md` | Universal (OpenAI Codex, Claude, Copilot, etc.) | +| `CLAUDE.md` | Claude Code | +| `.cursorrules` | Cursor AI | +| `.github/copilot-instructions.md` | GitHub Copilot | +| `.windsurfrules` | Windsurf / Cascade | +| `.clinerules` | Cline / Roo Code | +| `.aider.conf.yml` | Aider | +| `.editorconfig` | All editors | ## Steps @@ -28,12 +28,15 @@ cd /Users/sd9235/code/mygh/learning_ai_common_plat ./scripts/update-agent-docs.sh ``` +The script reads `learning_ai_common_plat/.windsurf/workflows/repos.txt` as the canonical list of managed workspace repositories. + 2. Review changes per repo: ```bash -cd /Users/sd9235/code/mygh/learning_voice_ai_agent && git diff --stat -cd /Users/sd9235/code/mygh/learning_multimodal_memory_agents && git diff --stat -# ... etc for all repos +while IFS= read -r repo; do + [[ -z "$repo" || "$repo" =~ ^# ]] && continue + cd /Users/sd9235/code/mygh/$repo && git diff --stat +done < /Users/sd9235/code/mygh/learning_ai_common_plat/.windsurf/workflows/repos.txt ``` 3. Commit changes (if any): diff --git a/scripts/commit-workspace.sh b/scripts/commit-workspace.sh new file mode 100644 index 00000000..558936fb --- /dev/null +++ b/scripts/commit-workspace.sh @@ -0,0 +1,142 @@ +#!/bin/bash + +set -euo pipefail + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +COMMON_PLAT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)" +WORKSPACE_DIR="${WORKSPACE_DIR:-$(cd "${COMMON_PLAT_DIR}/.." && pwd)}" +REPOS_TXT="${COMMON_PLAT_DIR}/.windsurf/workflows/repos.txt" + +if [[ ! -f "$REPOS_TXT" ]]; then + echo -e "${RED}❌ repos.txt not found at ${REPOS_TXT}${NC}" + exit 1 +fi + +read_repos() { + local repos=() + while IFS= read -r line; do + [[ "$line" =~ ^[[:space:]]*# ]] && continue + [[ -z "${line// }" ]] && continue + repos+=("$line") + done < "$REPOS_TXT" + printf '%s\n' "${repos[@]}" +} + +get_commit_message() { + local repo="$1" + local repo_path="${WORKSPACE_DIR}/${repo}" + local files + + files="$(git -C "$repo_path" diff --name-only 2>/dev/null || true)" + files+=$'\n'"$(git -C "$repo_path" diff --cached --name-only 2>/dev/null || true)" + files+=$'\n'"$(git -C "$repo_path" ls-files --others --exclude-standard 2>/dev/null || true)" + + local has_auth has_ci has_docs has_docker has_package has_python has_tests has_config + has_auth="$(echo "$files" | grep -E '(auth|middleware|jwt)' || true)" + has_ci="$(echo "$files" | grep -E '\.github|workflow|ci' || true)" + has_docs="$(echo "$files" | grep -E '\.md$' || true)" + has_docker="$(echo "$files" | grep -E 'Dockerfile|docker' || true)" + has_package="$(echo "$files" | grep -E 'package\.json|pnpm-lock|yarn\.lock' || true)" + has_python="$(echo "$files" | grep -E '\.py$|requirements' || true)" + has_tests="$(echo "$files" | grep -E 'test|spec' || true)" + has_config="$(echo "$files" | grep -E '\.env|config|\.toml' || true)" + + if [[ -n "$has_auth" ]]; then + echo "feat(auth): update authentication and middleware" + elif [[ -n "$has_ci" ]]; then + echo "ci: update CI/CD configuration" + elif [[ -n "$has_docker" ]]; then + if [[ -n "$has_package" ]]; then + echo "feat(devops): update docker and package configuration" + else + echo "feat(devops): update Docker configuration" + fi + elif [[ -n "$has_package" ]]; then + echo "chore: update dependencies" + elif [[ -n "$has_docs" ]]; then + echo "docs: update documentation" + elif [[ -n "$has_python" ]]; then + if [[ -n "$has_tests" ]]; then + echo "test(python): update test suite" + else + echo "feat(python): update Python modules" + fi + elif [[ -n "$has_tests" ]]; then + echo "test: add/update tests" + elif [[ -n "$has_config" ]]; then + echo "chore: update configuration" + else + echo "chore: update project files" + fi +} + +commit_repo() { + local repo="$1" + local repo_path="${WORKSPACE_DIR}/${repo}" + + echo -e "${BLUE}📝 Committing ${repo}...${NC}" + git -C "$repo_path" add -A + local commit_msg + commit_msg="$(get_commit_message "$repo")" + echo -e " Message: ${YELLOW}${commit_msg}${NC}" + git -C "$repo_path" commit -m "$commit_msg" + echo -e " ${GREEN}✅ Committed${NC}" + echo +} + +echo -e "${BLUE}📋 Scanning workspace for changes...${NC}" +echo + +mapfile -t REPOS < <(read_repos) +REPOS_WITH_CHANGES=() + +for repo in "${REPOS[@]}"; do + repo_path="${WORKSPACE_DIR}/${repo}" + if [[ ! -d "$repo_path/.git" ]]; then + continue + fi + + if ! git -C "$repo_path" diff --quiet || ! git -C "$repo_path" diff --cached --quiet || [[ -n "$(git -C "$repo_path" ls-files --others --exclude-standard)" ]]; then + REPOS_WITH_CHANGES+=("$repo") + + staged=$(git -C "$repo_path" diff --cached --name-only | wc -l | tr -d ' ') + modified=$(git -C "$repo_path" diff --name-only | wc -l | tr -d ' ') + untracked=$(git -C "$repo_path" ls-files --others --exclude-standard | wc -l | tr -d ' ') + + echo -e "${YELLOW}📁 ${repo}${NC}:" + [[ "$staged" -gt 0 ]] && echo " - ${staged} staged" + [[ "$modified" -gt 0 ]] && echo " - ${modified} modified" + [[ "$untracked" -gt 0 ]] && echo " - ${untracked} untracked" + echo + fi +done + +if [[ ${#REPOS_WITH_CHANGES[@]} -eq 0 ]]; then + echo -e "${GREEN}✅ No changes to commit${NC}" + exit 0 +fi + +echo -e "${BLUE}Found changes in ${#REPOS_WITH_CHANGES[@]} repo(s)${NC}" +echo + +echo -e "${BLUE}🚀 Committing in dependency order...${NC}" +echo + +if [[ " ${REPOS_WITH_CHANGES[*]} " =~ " learning_ai_common_plat " ]]; then + commit_repo "learning_ai_common_plat" +fi + +for repo in "${REPOS_WITH_CHANGES[@]}"; do + if [[ "$repo" != "learning_ai_common_plat" ]]; then + commit_repo "$repo" + fi +done + +echo -e "${GREEN}✨ All changes committed locally!${NC}" +echo -e "${BLUE}💡 Use /repo_sync-repos or git push to push to remote${NC}" diff --git a/scripts/sync-workflows.sh b/scripts/sync-workflows.sh index dbe6d7b2..e7d828a3 100755 --- a/scripts/sync-workflows.sh +++ b/scripts/sync-workflows.sh @@ -7,27 +7,33 @@ set -eo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" REPOS_ROOT="/Users/sd9235/code/mygh" COMMON_PLAT="$REPOS_ROOT/learning_ai_common_plat" +REPOS_TXT="$COMMON_PLAT/.windsurf/workflows/repos.txt" -REPOS=( - "learning_voice_ai_agent" - "learning_multimodal_memory_agents" - "learning_ai_clock" - "learning_ai_peakpulse" - "learning_ai_fastgap" - "learning_ai_jarvis_jr" -) +if [ ! -f "$REPOS_TXT" ]; then + echo "❌ Canonical repos.txt not found: $REPOS_TXT" + exit 1 +fi + +REPOS=() +while IFS= read -r line; do + [[ "$line" =~ ^[[:space:]]*# ]] && continue + [[ -z "${line// }" ]] && continue + [[ "$line" == "learning_ai_common_plat" ]] && continue + REPOS+=("$line") +done < "$REPOS_TXT" WORKFLOWS_TO_SYNC=( "repo_backup-main-branch.md" "repo_backup-and-push.md" "repo_sync-repos.md" "repo_commit-workspace.md" + "repo_push-repos.md" "repo_update-agent-docs.md" "refresh-chat-history.md" ) DRY_RUN=false -if [ "$1" = "--dry-run" ]; then +if [ "${1:-}" = "--dry-run" ]; then DRY_RUN=true fi