PromucFlow_constructor/.cursor/hooks/scripts/update-docs.sh

123 lines
3.7 KiB
Bash
Raw Normal View History

refactor: restructure .cursor directory for improved organization and clarity (#40196) # refactor: restructure .cursor directory for improved organization and clarity ## Description This PR refactors the `.cursor` directory to enhance organization, clarity, and maintainability. ### Problem The existing `.cursor` directory lacked clear organization, making it difficult to find specific files, understand their purpose, and add new components consistently. ### Solution A comprehensive restructuring: #### New Directory Structure ``` .cursor/ ├── settings.json # Main configuration file ├── docs/ # Documentation │ ├── guides/ # In-depth guides │ ├── references/ # Quick references │ └── practices/ # Best practices ├── rules/ # Rule definitions │ ├── commit/ # Commit-related rules │ ├── quality/ # Code quality rules │ ├── testing/ # Testing rules │ └── verification/ # Verification rules └── hooks/ # Git hooks and scripts ``` #### Key Changes 1. **Logical Categorization**: Organized files into clear categories based on purpose 2. **Improved Documentation**: Added comprehensive README files for each directory 3. **Standardized Naming**: Implemented consistent kebab-case naming convention 4. **Reference Updates**: Updated all internal references to point to new file locations ### Benefits - **Easier Navigation**: Clear categorization makes finding files intuitive - **Improved Understanding**: Comprehensive documentation explains purpose and usage - **Simplified Maintenance**: Logical structure makes updates and additions easier - **Better Onboarding**: New team members can quickly understand the system This refactoring sets a solid foundation for all Cursor AI-related configurations and rules, making it easier for the team to leverage Cursor's capabilities.
2025-04-11 06:34:33 +00:00
#!/bin/bash
# update-cursor-docs.sh
# Pre-commit hook script to update Cursor documentation based on code changes
set -e
CURSOR_DIR=".cursor"
CODEBASE_MAP="${CURSOR_DIR}/appsmith-codebase-map.md"
TECHNICAL_DETAILS="${CURSOR_DIR}/appsmith-technical-details.md"
RULES_DIR="${CURSOR_DIR}/rules"
echo "🔍 Checking for updates to Cursor documentation..."
# Function to check if file needs to be included in the commit
add_to_commit_if_changed() {
local file=$1
if git diff --name-only --cached | grep -q "$file"; then
echo "$file is already staged for commit"
elif git diff --name-only | grep -q "$file"; then
echo "📝 Adding modified $file to commit"
git add "$file"
fi
}
# Get list of changed files in this commit
CHANGED_FILES=$(git diff --cached --name-only)
# Check if we need to update the codebase map
update_codebase_map() {
local need_update=false
# Check for directory structure changes
if echo "$CHANGED_FILES" | grep -q "^app/.*/$"; then
need_update=true
fi
# Check for major file additions
if echo "$CHANGED_FILES" | grep -q -E '\.(java|tsx?|jsx?)$' | wc -l | grep -q -v "^0$"; then
need_update=true
fi
if [ "$need_update" = true ]; then
echo "🔄 Updating Codebase Map documentation..."
# Append a timestamp to the file to mark it as updated
echo -e "\n\n> Last updated: $(date)" >> "$CODEBASE_MAP"
# In a real implementation, you would call an external script or Cursor API
# to analyze the codebase and update the map file
echo " Codebase Map should be manually reviewed to ensure accuracy"
add_to_commit_if_changed "$CODEBASE_MAP"
else
echo "✅ Codebase Map does not need updates"
fi
}
# Check if we need to update the technical details
update_technical_details() {
local need_update=false
# Check for framework changes
if echo "$CHANGED_FILES" | grep -q -E 'package\.json|pom\.xml|build\.gradle'; then
need_update=true
fi
# Check for core component changes
if echo "$CHANGED_FILES" | grep -q -E 'src/(components|widgets|services)/.*\.(tsx?|java)$'; then
need_update=true
fi
if [ "$need_update" = true ]; then
echo "🔄 Updating Technical Details documentation..."
# Append a timestamp to the file to mark it as updated
echo -e "\n\n> Last updated: $(date)" >> "$TECHNICAL_DETAILS"
# In a real implementation, you would call an external script or Cursor API
# to analyze the codebase and update the technical details file
echo " Technical Details should be manually reviewed to ensure accuracy"
add_to_commit_if_changed "$TECHNICAL_DETAILS"
else
echo "✅ Technical Details do not need updates"
fi
}
# Check if we need to update Cursor rules
update_cursor_rules() {
local need_update=false
# Update rules if specific patterns are found in changed files
if echo "$CHANGED_FILES" | grep -q -E 'app/client/src/(widgets|components)|app/server/.*/(controllers|services)/'; then
need_update=true
fi
if [ "$need_update" = true ]; then
echo "🔄 Checking Cursor rules for updates..."
# In a real implementation, you would call an external script or Cursor API
# to analyze rule relevance and update rules
# Add timestamp to index.mdc to mark rules as checked
if [ -f "$RULES_DIR/index.mdc" ]; then
echo -e "\n\n> Rules checked: $(date)" >> "$RULES_DIR/index.mdc"
add_to_commit_if_changed "$RULES_DIR/index.mdc"
fi
echo " Cursor rules should be manually reviewed to ensure they're up to date"
else
echo "✅ Cursor rules do not need updates"
fi
}
# Main execution
update_codebase_map
update_technical_details
update_cursor_rules
echo "✅ Cursor documentation check complete"
exit 0