Advanced features, caching behavior, and best practices.
Analyzes git history to identify hotspots, temporal coupling, and contributor patterns.
/plugin marketplace add lis186/SourceAtlas/plugin install sourceatlas@lis186-SourceAtlashistory/Advanced features, caching behavior, and best practices.
# Default: Use cache if exists and fresh
/sourceatlas:history
# Check logic:
if [ -f ".sourceatlas/history.md" ]; then
age_days=$(calculate_age_in_days)
if [ $age_days -eq 0 ]; then
echo "š Loading from cache (today)"
elif [ $age_days -eq 1 ]; then
echo "š Loading from cache (1 day ago)"
else
echo "š Loading from cache ($age_days days ago)"
fi
# If >30 days, warn user
if [ $age_days -gt 30 ]; then
echo "ā ļø Cache is older than 30 days, recommend re-analysis"
fi
# Output cached content
exit 0
fi
# Force flag: Always skip cache
/sourceatlas:history --force
# ā Executes full analysis even if cache exists
# No cache: First time analysis
# ā .sourceatlas/history.md doesn't exist yet
Unlike other commands, history has fixed cache path:
# Always the same
.sourceatlas/history.md
Rationale: History analysis is repository-wide, doesn't vary by target.
.sourceatlas/
āāā history.md # Fixed filename
Auto-save occurs immediately after Step V4 verification:
# After verification passes
verification_summary:
confidence_level: "high"
# Then auto-save
š¾ Saved to .sourceatlas/history.md
Complete Markdown output including:
Format: Full Markdown as specified in output-template.md
If high-risk hotspots found (complexity >10,000):
Suggest:
| # | Command | Purpose |
|---|---------|---------|
| 1 | `/sourceatlas:impact "src/core/processor.ts"` | processor.ts changed 45 times, need to understand dependencies |
If cross-module coupling detected (degree >0.6):
Suggest:
| # | Command | Purpose |
|---|---------|---------|
| 1 | `/sourceatlas:flow "src/orders/checkout"` | Suspicious coupling with payments, trace execution flow |
If single-contributor modules identified:
Suggest:
| # | Command | Purpose |
|---|---------|---------|
| 1 | `/sourceatlas:pattern "legacy patterns"` | Bus factor risk in legacy/, need to understand patterns before knowledge transfer |
Output instead:
ā ļø **Insufficient Data Warning**
- Commits: 38 (recommend ā„50)
- Period: 67 days (recommend ā„90 days)
Recommend analyzing temporal patterns again in 3-6 months
$HOME/.sourceatlas/bin/code-maat-1.0.4-standalone.jar
export CODEMAAT_JAR="$HOME/.sourceatlas/bin/code-maat-1.0.4-standalone.jar"
./scripts/install-codemaat.sh
What it does:
~/.sourceatlas/bin/If automatic installation fails:
# 1. Download from GitHub
wget https://github.com/adamtornhill/code-maat/releases/download/v1.0.4/code-maat-1.0.4-standalone.jar
# 2. Create directory
mkdir -p ~/.sourceatlas/bin/
# 3. Move JAR
mv code-maat-1.0.4-standalone.jar ~/.sourceatlas/bin/
# 4. Set environment variable
export CODEMAAT_JAR="$HOME/.sourceatlas/bin/code-maat-1.0.4-standalone.jar"
Java 8+ required:
# Check Java version
java -version
# Install if missing (macOS)
brew install openjdk@11
# Install if missing (Ubuntu)
sudo apt-get install openjdk-11-jdk
Default: Last 12 months
git log --after="$(date -v-12m +%Y-%m-%d)" ...
Custom time range:
# Last 6 months
/sourceatlas:history "last 6 months"
# Last 18 months
/sourceatlas:history "last 18 months"
Parsing logic:
# Extract number from arguments
MONTHS=$(echo "$ARGUMENTS" | grep -o '[0-9]\+')
if [ -z "$MONTHS" ]; then
MONTHS=12 # Default
fi
Default: Entire repository
Custom scope:
# Specific directory
/sourceatlas:history "src/"
# Multiple directories (future enhancement)
/sourceatlas:history "src/ lib/"
Implementation:
if [ -n "$SCOPE" ]; then
git log --all --numstat ... -- "$SCOPE" > /tmp/git-history.log
else
git log --all --numstat ... > /tmp/git-history.log
fi
Not always bad:
Red flags:
Expected (normal):
Suspicious (review needed):
Healthy distribution:
Bus factor risks:
# Limit analysis to recent history
git log --all --numstat --date=short \
--pretty=format:'--%h--%ad--%aN' \
--after="$(date -v-6m +%Y-%m-%d)" \
--max-count=1000 \
> /tmp/git-history.log
# Analyze specific package only
git log --all --numstat --date=short \
--pretty=format:'--%h--%ad--%aN' \
-- "packages/app/" \
> /tmp/git-history.log
# Or analyze multiple related packages
git log --all --numstat --date=short \
--pretty=format:'--%h--%ad--%aN' \
-- "packages/app/" "packages/shared/" \
> /tmp/git-history.log
# Use faster analysis types
# revisions: Fast (seconds)
# coupling: Moderate (seconds to minutes)
# entity-ownership: Slow (minutes)
# Skip entity-ownership if too slow
# Focus on revisions + coupling
# Check if git repository
if ! git rev-parse --git-dir > /dev/null 2>&1; then
echo "ā Not a git repository"
echo "History analysis requires git version control"
exit 1
fi
output:
message: |
ā ļø Only 38 commits found in analysis period
Temporal analysis works best with >50 commits.
Consider:
- Extending time range (e.g., --after="2 years ago")
- Analyzing entire repository history (omit --after)
- Waiting for more development activity
If commits are very large (>100 files per commit):
warning: |
Large, infrequent commits detected.
This may affect coupling analysis accuracy:
- Many files change together in single commit
- Hard to distinguish real vs coincidental coupling
Recommend:
- Smaller, atomic commits going forward
- Focus on hotspot analysis (more reliable)
# If "Alice" appears as:
# - Alice Smith <alice@company.com>
# - Alice Johnson <alice@contractor.com>
# code-maat uses author name only, may merge stats
# Verify in git log:
git log --format='%aN <%aE>' | sort -u | grep -i alice
Action: If ambiguous, note in output:
Note: Multiple contributors with name "Alice" found.
Stats may be aggregated.
file:line for hotspotsAfter history analysis, consider:
/sourceatlas:impact "[hotspot]" - Understand dependencies of frequently changed files/sourceatlas:pattern "[pattern]" - Learn patterns used in hotspots before refactoring/sourceatlas:flow "[entry point]" - Trace execution through coupled modules/sourceatlas:overview - Get broader context if history reveals complexitySymptom: CODEMAAT_JAR not set or file not found
Debug:
# Check environment
echo $CODEMAAT_JAR
# Check default location
ls -la ~/.sourceatlas/bin/code-maat-*.jar
# Verify Java
java -version
Fix: Run installation script or set environment variable
Symptom: 0 commits found
Debug:
# Check git repository
git log --oneline | head -5
# Check date filter
date -v-12m +%Y-%m-%d # macOS
date -d '12 months ago' +%Y-%m-%d # Linux
Fix: Adjust date range or check if repository has history
Symptom: Exception in thread "main" or Java errors
Debug:
# Test code-maat directly
java -jar "$CODEMAAT_JAR" -h
# Check git log format
head -20 /tmp/git-history.log
Fix:
Symptom: All couplings <0.3, all hotspots <5 revisions
Possible causes:
Action:
ā
No significant temporal patterns detected.
This could mean:
- Clean architecture with good separation
- Young codebase with limited history
- Stable, mature codebase
Consider re-analyzing after more development activity.