1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
//! # bashrs REPL - Interactive Shell Analysis Environment
//!
//! The REPL (Read-Eval-Print Loop) module provides an interactive environment for
//! analyzing, transforming, and debugging bash scripts in real-time.
//!
//! ## Overview
//!
//! The bashrs REPL is a production-ready interactive shell that combines:
//!
//! - **5 Interactive Modes**: Normal, purify, lint, debug, and explain modes
//! - **Real-time Analysis**: Parse, lint, and purify bash code interactively
//! - **Script Management**: Load scripts, extract functions, reload after changes
//! - **Session State**: Persistent variables, history, and context
//! - **Tab Completion**: Intelligent completion for commands, modes, and files
//! - **Multi-line Input**: Natural support for functions, loops, and conditionals
//!
//! ## Architecture
//!
//! The REPL follows the **Debugger-as-REPL** pattern (matklad pattern):
//! - Debugger capabilities are exposed through REPL commands
//! - Symbiotic embedding enables deep integration with bash analysis tools
//!
//! ## Quick Start
//!
//! ```bash
//! $ bashrs repl
//! bashrs [normal]> echo "Hello, REPL!"
//! Hello, REPL!
//!
//! bashrs [normal]> :parse echo test
//! ✓ Parse successful!
//!
//! bashrs [normal]> :mode lint
//! Switched to lint mode
//!
//! bashrs [lint]> cat $FILE | grep pattern
//! Found 1 issue(s): SC2086 - Unquoted variable
//! ```
//!
//! ## Modules
//!
//! - [`ast_display`]: Format and display AST structures
//! - [`breakpoint`]: Debugger breakpoint management
//! - [`completion`]: Tab completion for commands and files
//! - [`config`]: REPL configuration and settings
//! - [`debugger`]: Interactive debugging capabilities
//! - [`determinism`]: Detect non-deterministic patterns
//! - [`errors`]: Error formatting and reporting
//! - [`executor`]: Execute bash commands safely
//! - [`explain`]: Explain bash constructs interactively
//! - [`highlighting`]: Syntax highlighting for bash code
//! - [`linter`]: Real-time linting and diagnostics
//! - [`loader`]: Script loading and function extraction
//! - [`modes`]: REPL mode management (normal, purify, lint, etc.)
//! - [`multiline`]: Multi-line input handling
//! - [`parser`]: Bash parsing integration
//! - [`purifier`]: Idempotency and determinism transformations
//! - [`state`]: Session state management
//! - [`variables`]: Variable storage and expansion
//!
//! ## Features
//!
//! ### Interactive Modes
//!
//! The REPL supports 5 specialized modes:
//!
//! | Mode | Purpose | Use Case |
//! |------|---------|----------|
//! | **normal** | Direct execution | Testing commands, learning bash |
//! | **purify** | Automatic purification | Fixing idempotency issues |
//! | **lint** | Automatic linting | Finding security problems |
//! | **debug** | Step-by-step execution | Understanding complex scripts |
//! | **explain** | Interactive explanations | Learning bash constructs |
//!
//! ### Commands
//!
//! Core commands for bash analysis:
//!
//! - `:parse <code>` - Parse bash code and show AST
//! - `:lint <code>` - Lint for security and quality issues
//! - `:purify <code>` - Transform to idempotent/deterministic code
//! - `:mode <name>` - Switch to a different mode
//! - `:load <file>` - Load and analyze a bash script
//! - `:reload` - Reload the most recently loaded script
//! - `:vars` - Show session variables
//! - `:history` - Show command history
//!
//! ### Script Loading
//!
//! Load complete scripts for analysis:
//!
//! ```bash
//! bashrs [normal]> :load deploy.sh
//! ✓ Loaded: deploy.sh (5 functions, 120 lines)
//!
//! bashrs [normal]> :functions
//! Available functions (5 total):
//! 1 validate_env
//! 2 build_app
//! 3 run_tests
//! 4 deploy_staging
//! 5 deploy_production
//! ```
//!
//! ### Variable Management
//!
//! Persistent variables across your session:
//!
//! ```bash
//! bashrs [normal]> app_name="myapp"
//! ✓ Variable set: app_name = myapp
//!
//! bashrs [normal]> version=1.0.0
//! ✓ Variable set: version = 1.0.0
//!
//! bashrs [normal]> echo $app_name v$version
//! myapp v1.0.0
//! ```
//!
//! ## Examples
//!
//! See the [`examples/repl/`](../../../examples/repl/) directory for 11 comprehensive
//! real-world examples covering:
//!
//! - Basic REPL workflow
//! - Security auditing
//! - Purification workflows
//! - CI/CD pipeline development
//! - Configuration management
//! - Multi-line editing
//! - Tab completion
//! - Variable management
//! - Troubleshooting
//!
//! ## API Usage
//!
//! ```rust,ignore
//! use bashrs::repl::{run_repl, ReplConfig};
//!
//! // Run the REPL with default configuration
//! let config = ReplConfig::default();
//! run_repl(config)?;
//! ```
//!
//! ## Implementation Status
//!
//! - ✅ **Phase 0** (REPL-001-002): Complete - Core infrastructure
//! - ✅ **Phase 1** (REPL-003-008): Complete - Basic REPL loop and modes
//! - ✅ **Phase 2** (REPL-009-016): Complete - Advanced features (variables, loading, completion)
//! - 🚧 **Phase 3** (REPL-017): In Progress - Documentation
//! - ⏳ **Phase 4** (REPL-018+): Planned - Testing and validation
//!
//! ## See Also
//!
//! - User Guide: [`book/src/repl/user-guide.md`](../../../book/src/repl/user-guide.md)
//! - Tutorial: [`book/src/repl/tutorial.md`](../../../book/src/repl/tutorial.md)
//! - Examples: [`examples/repl/`](../../../examples/repl/)
//!
//! Architecture: Debugger-as-REPL (matklad pattern)
//! Integration: Symbiotic embedding (RuchyRuchy pattern)
//! Sprint: REPL-003 (Basic REPL Loop)
//! Status: Phase 1 - RED-GREEN-REFACTOR-PROPERTY-MUTATION
pub use format_ast;
pub use ;
pub use ReplConfig;
pub use ;
pub use ;
pub use ;
pub use ;
pub use display_diff;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ReplMode;
pub use ;
pub use ;
pub use ;
pub use r#looprun_repl;
pub use ReplState;