Skip to main content

gitstack/
lib.rs

1//! # gitstack
2//!
3//! Git history viewer & analysis tool. Intuitively explore Git repositories via TUI.
4//!
5//! ## Key Features
6//!
7//! - **Commit history browsing**: Graph-annotated commit log, branch topology analysis
8//! - **Code analysis**: File heatmap, code ownership, Change Coupling
9//! - **Quality metrics**: Impact score, quality score, technical debt analysis
10//! - **AI integration**: Context pack generation, review pack, MCP integration
11//! - **i18n support**: Full Japanese/English internationalization (300+ translation keys)
12//!
13//! ## Usage
14//!
15//! ```bash
16//! # Launch TUI inside a Git repository
17//! gitstack
18//!
19//! # CLI analysis mode
20//! gitstack stats --json
21//! gitstack heatmap --csv
22//! gitstack health
23//! ```
24//!
25//! ## Crate Structure
26//!
27//! - [`app`] - Application state management (`App` struct)
28//! - [`git`] - Git operations wrapper (`git2`-based)
29//! - [`stats`] - Statistics & analysis engine
30//! - [`tui`] - Terminal UI rendering (`ratatui`-based)
31//! - [`i18n`] - Internationalization macros & translation definitions
32//! - [`navigation`] - List navigation (`ListNavigation` struct)
33
34pub mod app;
35pub mod cache;
36pub mod cli;
37pub mod compare;
38pub mod config;
39pub mod event;
40pub mod export;
41pub mod filter;
42pub mod git;
43pub mod graph;
44pub mod i18n;
45pub mod index;
46pub mod insights;
47pub mod intent;
48pub mod metrics;
49pub mod navigation;
50pub mod pr;
51pub mod related_files;
52pub mod relevance;
53pub mod review_queue;
54pub mod risk;
55pub mod session;
56pub mod split;
57pub mod staging;
58pub mod stats;
59pub mod suggestion;
60pub mod topology;
61pub mod tui;
62
63pub use app::{App, CommitType, InputMode, QuickAction, SidebarPanel};
64pub use cache::{clear_analysis_cache, load_or_compute, load_or_compute_with_repo};
65pub use cli::{
66    parse_cli_args, parse_tui_options, run_cli_mode, CliCommand, TuiFocusTarget, TuiOptions,
67};
68pub use compare::{BranchCompare, CompareCommit, CompareTab};
69pub use config::{FilterPreset, FilterPresets, LanguageConfig, PRESET_SLOT_COUNT};
70pub use event::{GitEvent, GitEventKind};
71pub use export::{
72    bus_factor_to_json, coupling_to_json, export_coupling_csv, export_coupling_json,
73    export_heatmap_csv, export_heatmap_json, export_impact_csv, export_impact_json,
74    export_ownership_csv, export_ownership_json, export_quality_csv, export_quality_json,
75    export_stats_csv, export_stats_json, export_timeline_csv, export_timeline_json, health_to_json,
76    health_to_markdown, heatmap_to_json, impact_to_json, log_to_json, ownership_to_json,
77    quality_to_json, stats_to_json, tech_debt_to_json, timeline_to_json,
78};
79pub use filter::FilterQuery;
80pub use git::{
81    checkout_branch, checkout_branch_in_repo, compare_branches, compare_branches_from_repo,
82    create_branch, create_branch_in_repo, create_commit, create_commit_in_repo, delete_branch,
83    delete_branch_in_repo, fetch_remote_at_path, get_blame, get_blame_from_repo, get_commit_diff,
84    get_commit_diff_from_repo, get_commit_files, get_commit_files_from_repo, get_file_history,
85    get_file_history_from_repo, get_file_patch, get_file_patch_from_repo, get_head_hash,
86    get_head_hash_cached, get_head_hash_from_repo, get_index_mtime, get_index_mtime_cached,
87    get_index_mtime_from_repo, get_repo_info_cached, get_stash_list, get_status, get_status_cached,
88    get_status_from_repo, get_working_file_diff, get_working_file_diff_from_repo, has_staged_files,
89    has_staged_files_in_repo, list_branches, list_branches_cached, list_branches_from_repo,
90    load_events, load_events_fast, load_events_from_repo, pull, pull_in_repo, push, push_in_repo,
91    stage_all, stage_all_in_repo, stage_file, stage_file_in_repo, stash_apply, stash_drop,
92    stash_pop, stash_save, unstage_all, unstage_all_in_repo, unstage_file, unstage_file_in_repo,
93    BlameLine, BranchInfo, CommitDiff, DiffLine, DiffStats, FileChange, FileChangeStatus,
94    FileHistoryEntry, FilePatch, FileStatus, FileStatusKind, RepoInfo, StashEntry,
95};
96pub use graph::{build_graph, get_graph_color, GraphCell, GraphLayout, GraphRow};
97pub use i18n::Language;
98pub use index::{
99    load_review_pack as load_cached_review_pack, save_review_pack as save_cached_review_pack,
100};
101pub use insights::{
102    actions_to_markdown, build_context_pack, build_context_summary, build_handoff_context,
103    build_next_actions, build_review_pack, compute_signals_for_event, explain_recommendation,
104    handoff_to_markdown, pack_to_markdown, review_pack_to_markdown, summary_to_markdown,
105    verify_patch_risk, ActionRecommendation, ContextPack, ContextSummary, EvidenceLink,
106    HandoffContext, ReviewOwnerCandidate, ReviewPack, ReviewRisk, SignalContext, SignalSet,
107    MIN_COMMITS_FOR_COUPLING, MIN_COUPLING_RATIO,
108};
109pub use intent::{classify_intent, ChangeIntent};
110pub use metrics::{
111    load_metrics, quick_action_usage_enabled, record_quick_action_usage, reset_metrics,
112    ActionUsageEntry, MetricsData,
113};
114pub use navigation::ListNavigation;
115pub use pr::{check_gh_available, create_pr, PrCreateState};
116pub use related_files::{analyze_related_files, RelatedFiles};
117pub use relevance::{calculate_relevance, RelevanceScore};
118pub use review_queue::{ReviewItem, ReviewQueue, ReviewStatus};
119pub use risk::{calculate_staged_risk, RiskLevel};
120pub use session::{detect_sessions, AiSession, SessionStats};
121pub use split::{suggest_splits, SplitGroup, SplitSuggestion};
122pub use staging::{suggest_groups, StagingGroup};
123pub use stats::{
124    calculate_activity_timeline, calculate_bus_factor, calculate_change_coupling,
125    calculate_file_heatmap, calculate_impact_scores, calculate_ownership, calculate_project_health,
126    calculate_quality_scores, calculate_stats, calculate_tech_debt, is_test_file, ActivityTimeline,
127    AggregationLevel, AlertSeverity, AuthorStats, BusFactorAnalysis, BusFactorEntry, BusFactorRisk,
128    ChangeCouplingAnalysis, CodeOwnership, CodeOwnershipEntry, CommitImpactAnalysis,
129    CommitImpactScore, CommitQualityAnalysis, CommitQualityScore, ConfidenceLevel, ContributorInfo,
130    FileCoupling, FileHeatmap, FileHeatmapEntry, HealthAlert, HealthAlertKind, HealthConfidence,
131    HealthScoreComponent, ProjectHealth, RepoStats, TechDebtAnalysis, TechDebtEntry, TechDebtLevel,
132};
133pub use suggestion::{generate_suggestions, CommitSuggestion};
134pub use topology::{
135    analyze_branch_recommendations, analyze_topology, analyze_topology_from_repo, BranchHealth,
136    BranchRecommendation, BranchRecommendations, BranchRelation, BranchStatus, BranchTopology,
137    HealthWarning, RecommendedAction, TopologyBranch, TopologyConfig,
138};