# Operation: Learn Project **Purpose:** Comprehensive project commit pattern learning - analyze all aspects of commit history to provide complete understanding of project conventions. ## Parameters From `$ARGUMENTS` (after operation name): - `count:N` - Number of commits to analyze (default: 100) - `branch:name` - Branch to analyze (default: current branch) - `format:json|text` - Output format (default: text) - `save:path` - Save results to file (optional) - `full:true|false` - Include detailed breakdown (default: false) ## Workflow ### 1. Validate Repository ```bash if ! git rev-parse --git-dir >/dev/null 2>&1; then echo "Error: Not in a git repository" exit 1 fi if ! git log -1 >/dev/null 2>&1; then echo "Error: No commit history found" exit 1 fi ``` ### 2. Execute Comprehensive Analysis This operation orchestrates all other history-analysis operations for complete project learning: **Phase 1: Style Analysis** ```bash echo "Phase 1/4: Analyzing commit style..." ./.scripts/style-analyzer.sh ``` **Phase 2: Pattern Detection** ```bash echo "Phase 2/4: Detecting conventions..." ./.scripts/pattern-detector.py --count --branch --detailed ``` **Phase 3: Scope Extraction** ```bash echo "Phase 3/4: Extracting scopes..." ./.scripts/scope-extractor.sh --count --branch --min-frequency 2 ``` **Phase 4: Convention Recommendations** ```bash echo "Phase 4/4: Generating recommendations..." ./.scripts/convention-recommender.py --count --branch --priority all ``` ### 3. Aggregate and Synthesize Results Combine all analysis data into comprehensive project profile: ```python project_profile = { 'metadata': { 'project_name': get_repo_name(), 'analysis_date': datetime.now(), 'commits_analyzed': count, 'branch': branch, 'first_commit_date': get_first_commit_date(), 'last_commit_date': get_last_commit_date() }, 'style': style_analysis_results, 'patterns': pattern_detection_results, 'scopes': scope_extraction_results, 'recommendations': convention_recommendations, 'confidence': calculate_confidence_score() } ``` ### 4. Generate Project Profile **Output Structure:** ``` ═══════════════════════════════════════════════════════════════ PROJECT COMMIT PROFILE ═══════════════════════════════════════════════════════════════ Repository: git-commit-assistant Branch: main Analysis Date: 2024-03-10 14:30:00 Commits Analyzed: 100 (from 2024-01-01 to 2024-03-10) Overall Consistency Score: 85/100 (GOOD) Confidence Level: HIGH (100 commits analyzed) ═══════════════════════════════════════════════════════════════ 📊 EXECUTIVE SUMMARY ═══════════════════════════════════════════════════════════════ ✓ Project uses conventional commits consistently (87%) ✓ Strong imperative mood usage (92%) ✓ Good issue reference practice (67%) ○ Moderate body usage (34%) ○ Occasional breaking change documentation (8%) Recommended Actions: 1. Maintain conventional commits format 2. Increase body usage for complex changes 3. Standardize breaking change documentation ═══════════════════════════════════════════════════════════════ 📝 COMMIT STYLE ANALYSIS ═══════════════════════════════════════════════════════════════ Format Distribution: Conventional Commits: 87% ████████████████████████░░░ Simple Subject: 10% ███░░░░░░░░░░░░░░░░░░░░░░░ Other: 3% █░░░░░░░░░░░░░░░░░░░░░░░░░ Subject Lines: Average Length: 47 characters (recommended: < 50) Standard Dev: 8 characters Exceeds 50 chars: 15% of commits Length Distribution: 30-40 chars: ████████ (35%) 41-50 chars: ██████████ (42%) 51-60 chars: ████ (15%) 61+ chars: ██ (8%) Body Usage: Has Body: 34% of commits Average Length: 120 characters Bullet Points: 89% of bodies Wrapping: 94% wrap at 72 chars Footer Usage: Issue References: 67% ████████████████████░░░░░ Breaking Changes: 8% ██░░░░░░░░░░░░░░░░░░░░░░ Co-Authors: 2% ░░░░░░░░░░░░░░░░░░░░░░░░ Signed-Off: 12% ███░░░░░░░░░░░░░░░░░░░░░ ═══════════════════════════════════════════════════════════════ 🎯 COMMIT TYPE ANALYSIS ═══════════════════════════════════════════════════════════════ Type Distribution (from 87 conventional commits): 1. feat 35% ████████████████████ (30 commits) └─ New features and capabilities 2. fix 30% ████████████████░ (26 commits) └─ Bug fixes and corrections 3. docs 16% █████████░ (14 commits) └─ Documentation updates 4. refactor 8% ████░ (7 commits) └─ Code restructuring 5. test 5% ███░ (4 commits) └─ Test additions/updates 6. chore 4% ██░ (3 commits) └─ Maintenance tasks 7. perf 2% █░ (2 commits) └─ Performance improvements Type Usage Timeline (last 20 commits): feat: ████████ (8 commits) fix: ██████ (6 commits) docs: ███ (3 commits) refactor: ██ (2 commits) chore: █ (1 commit) ═══════════════════════════════════════════════════════════════ 🎨 SCOPE ANALYSIS ═══════════════════════════════════════════════════════════════ Scopes Found: 15 unique Scoped Commits: 88% (76/87 conventional commits) Top Scopes by Frequency: 1. auth 23% ████████████████████ (20 commits) Category: Authentication Status: ACTIVE (used in last 10 commits) Examples: • feat(auth): implement OAuth2 authentication • fix(auth): handle session timeout correctly • refactor(auth): simplify middleware logic 2. api 19% ████████████████ (17 commits) Category: Backend Status: ACTIVE Hierarchy: api/endpoints (7), api/middleware (5), api/validation (3) 3. ui 15% █████████████ (13 commits) Category: Frontend Status: ACTIVE Hierarchy: ui/components (8), ui/styles (4) 4. db 12% ██████████ (10 commits) Category: Database Status: ACTIVE 5. docs 11% █████████ (9 commits) Category: Documentation Status: ACTIVE 6-15. (core, config, test, ci, deploy, utils, types, scripts, docker, nginx) Combined: 20% (17 commits) Scope Categories: Features: 45% (auth, payment, search, notifications) Backend: 32% (api, db, server, cache) Frontend: 19% (ui, components, styles) Infrastructure: 12% (ci, docker, deploy, nginx) Documentation: 11% (docs, readme, changelog) ═══════════════════════════════════════════════════════════════ 🔍 CONVENTION PATTERNS ═══════════════════════════════════════════════════════════════ Writing Style: Imperative Mood: 92% ██████████████████████░░ Capitalized Subject: 94% ██████████████████████░░ No Period at End: 88% ████████████████████░░░ Lowercase Scopes: 100% ████████████████████████ Message Structure: Blank Line Before Body: 100% (all 34 bodies) Body Wrapped at 72: 94% (32/34 bodies) Bullet Points in Body: 89% (30/34 bodies) Footer Separated: 100% (all 67 footers) Issue References: Format: "Closes #123" 45% ████████████ Format: "Fixes #456" 38% ██████████ Format: "Refs #789" 17% █████ Breaking Changes: Format: "BREAKING CHANGE:" 100% (all 7 instances) Always in footer: 100% Includes description: 100% ═══════════════════════════════════════════════════════════════ 💡 RECOMMENDATIONS (PRIORITIZED) ═══════════════════════════════════════════════════════════════ 🔴 HIGH PRIORITY (Critical for Consistency) 1. ✓ Continue Using Conventional Commits Current: 87% adoption Target: Maintain 85%+ Impact: HIGH - Enables automation 2. ✓ Maintain Imperative Mood Current: 92% compliance Target: Maintain 90%+ Impact: HIGH - Readability and clarity 🟡 MEDIUM PRIORITY (Improve Quality) 3. ○ Increase Body Usage for Complex Changes Current: 34% of commits Target: 50% for multi-file changes Impact: MEDIUM - Better documentation When to add body: • Changes affect >3 files • Complex logic modifications • Breaking changes • Security-related changes 4. ○ Document Breaking Changes Consistently Current: 8% when applicable Target: 100% of breaking changes documented Impact: MEDIUM - User experience 🟢 LOW PRIORITY (Polish) 5. ○ Consider Co-Author Attribution Current: 2% usage Target: Use for pair programming Impact: LOW - Team recognition 6. ○ Add Signed-off-by for Compliance Current: 12% usage Target: If required by project policy Impact: LOW - Legal compliance ═══════════════════════════════════════════════════════════════ 📚 PROJECT-SPECIFIC STYLE GUIDE ═══════════════════════════════════════════════════════════════ COMMIT MESSAGE FORMAT --------------------- (): ← 50 chars max, imperative mood ← Optional, explain "why" - Use bullet points ← Wrap at 72 characters - Multiple lines OK - Blank line before footer