Files
Claude-Code-Workflow/.claude/scripts/get_modules_by_depth.sh
catlog22 5983762810 feat: Add v1.1 update-memory system with dual-mode operations and enhanced documentation
## New Features
- **Dual-mode update-memory commands**: /update-memory-full and /update-memory-related
- **Git-aware change detection**: Intelligent context-aware documentation updates
- **Complexity-adaptive execution**: Auto-delegation to memory-gemini-bridge for complex projects
- **Depth-parallel processing**: Bottom-up execution ensuring proper context propagation
- **Enhanced issue tracking integration**: Complete /workflow:issue:* command set documentation

## New Scripts & Infrastructure
- detect_changed_modules.sh: Git-based change detection with fallback strategies
- get_modules_by_depth.sh: Hierarchical module discovery and organization
- update_module_claude.sh: Core CLAUDE.md update execution engine

## Documentation Updates
- **README.md**: Added comprehensive update-memory system documentation with usage examples
- **README_CN.md**: Complete Chinese localization of new features and technical details
- **Command reference tables**: Updated with new /update-memory-* commands and /workflow:issue:* set
- **Technical highlights**: Enhanced with dual-mode operations and complexity thresholds
- **Usage workflows**: Added detailed examples for different development scenarios

## Technical Improvements
- Streamlined memory-gemini-bridge.md (reduced by 200+ lines)
- Simplified gemini-unified.md workflow documentation
- Added comprehensive CLAUDE.md files for new modules
- Enhanced DMS (Distributed Memory System) with 4-layer hierarchy templates

## Architecture Enhancements
- **Complexity thresholds**: related mode (>15 modules), full mode (>20 modules)
- **Git integration**: Smart change detection with comprehensive status reporting
- **User confirmation workflows**: Clear execution plans with mandatory approval steps
- **Fallback strategies**: Graceful handling of non-git environments

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-10 18:15:30 +08:00

106 lines
4.3 KiB
Bash

#!/bin/bash
# Get modules organized by directory depth (deepest first)
# Usage: get_modules_by_depth.sh [format]
# format: list|grouped|json (default: list)
# Parse .gitignore patterns and build exclusion filters
build_exclusion_filters() {
local filters=""
# Always exclude these system/cache directories
local system_excludes=(
".git" ".history" ".vscode" "__pycache__" ".pytest_cache"
"node_modules" "dist" "build" ".egg-info" ".env"
)
for exclude in "${system_excludes[@]}"; do
filters+=" -not -path '*/$exclude' -not -path '*/$exclude/*'"
done
# Parse .gitignore if it exists
if [ -f ".gitignore" ]; then
while IFS= read -r line; do
# Skip empty lines and comments
[[ -z "$line" || "$line" =~ ^[[:space:]]*# ]] && continue
# Remove trailing slash and whitespace
line=$(echo "$line" | sed 's|/$||' | xargs)
# Add to filters
filters+=" -not -path '*/$line' -not -path '*/$line/*'"
done < .gitignore
fi
echo "$filters"
}
get_modules_by_depth() {
local format="${1:-list}"
local exclusion_filters=$(build_exclusion_filters)
local max_depth=$(eval "find . -type d $exclusion_filters 2>/dev/null" | awk -F/ '{print NF-1}' | sort -n | tail -1)
case "$format" in
"grouped")
echo "📊 Modules by depth (deepest first):"
for depth in $(seq $max_depth -1 0); do
local dirs=$(eval "find . -mindepth $depth -maxdepth $depth -type d $exclusion_filters 2>/dev/null" | \
while read dir; do
if [ $(find "$dir" -maxdepth 1 -type f 2>/dev/null | wc -l) -gt 0 ]; then
local claude_indicator=""
[ -f "$dir/CLAUDE.md" ] && claude_indicator=" [✓]"
echo "$dir$claude_indicator"
fi
done)
if [ -n "$dirs" ]; then
echo " 📁 Depth $depth:"
echo "$dirs" | sed 's/^/ - /'
fi
done
;;
"json")
echo "{"
echo " \"max_depth\": $max_depth,"
echo " \"modules\": {"
for depth in $(seq $max_depth -1 0); do
local dirs=$(eval "find . -mindepth $depth -maxdepth $depth -type d $exclusion_filters 2>/dev/null" | \
while read dir; do
if [ $(find "$dir" -maxdepth 1 -type f 2>/dev/null | wc -l) -gt 0 ]; then
local has_claude="false"
[ -f "$dir/CLAUDE.md" ] && has_claude="true"
echo "{\"path\":\"$dir\",\"has_claude\":$has_claude}"
fi
done | tr '\n' ',')
if [ -n "$dirs" ]; then
dirs=${dirs%,} # Remove trailing comma
echo " \"$depth\": [$dirs]"
[ $depth -gt 0 ] && echo ","
fi
done
echo " }"
echo "}"
;;
"list"|*)
# Simple list format (deepest first)
for depth in $(seq $max_depth -1 0); do
eval "find . -mindepth $depth -maxdepth $depth -type d $exclusion_filters 2>/dev/null" | \
while read dir; do
if [ $(find "$dir" -maxdepth 1 -type f 2>/dev/null | wc -l) -gt 0 ]; then
local file_count=$(find "$dir" -maxdepth 1 -type f 2>/dev/null | wc -l)
local types=$(find "$dir" -maxdepth 1 -type f -name "*.*" 2>/dev/null | \
grep -E '\.[^/]*$' | sed 's/.*\.//' | sort -u | tr '\n' ',' | sed 's/,$//')
local has_claude="no"
[ -f "$dir/CLAUDE.md" ] && has_claude="yes"
echo "depth:$depth|path:$dir|files:$file_count|types:[$types]|has_claude:$has_claude"
fi
done
done
;;
esac
}
# Execute function if script is run directly
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
get_modules_by_depth "$@"
fi