Skip to content

Commit 03e0f86

Browse files
chore: sync tools from main repository for v1.5.0
Complete interactive_utils migration with enhanced CI/automation support - eliminates EOF errors in CI/CD environments
1 parent 77c9349 commit 03e0f86

38 files changed

+13646
-364
lines changed

.pytoolsrc

Lines changed: 99 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# Author: Vaibhav-api-code
99
# Co-Author: Claude Code (https://claude.ai/code)
1010
# Created: 2025-07-24
11-
# Updated: 2025-07-24
11+
# Updated: 2025-07-28 # v1.5.0 - Enhanced CI/automation support
1212
# License: Mozilla Public License 2.0 (MPL-2.0)
1313

1414
[defaults]
@@ -26,6 +26,11 @@ assume_yes = false # Require explicit confirmation
2626
force = false # Never auto-confirm dangerous operations
2727
auto_confirm = false # Require user interaction by default
2828

29+
# v1.5.0 - Enhanced interactive behavior
30+
interactive_mode = true # Allow interactive prompts by default
31+
ci_detection = true # Auto-detect CI environments
32+
quiet_errors = false # Show full error messages with hints
33+
2934
# Development-friendly settings
3035
verbose = false # Set to true for debugging
3136
dry_run = false # Set to true to preview operations
@@ -87,22 +92,72 @@ show_dirs = true
8792
show_recent = true
8893
show_empty = false
8994

90-
[replace_text]
91-
# Text replacement defaults
95+
[replace_text_v9]
96+
# Text replacement defaults (v9 with undo support)
9297
backup = true # Always backup before replacing
9398
whole_word = false
9499
dry_run = false
95100
check_compile = true
101+
track_undo = true # Enable undo tracking by default
102+
interpret_escapes = false # Enable with --interpret-escapes flag
96103
# For automation, set these in environment or use --yes flag
97104
non_interactive = false
98105
assume_yes = false
99106

100-
[replace_text_ast]
101-
# AST-based refactoring defaults
107+
[replace_text]
108+
# Legacy alias - redirects to v9 settings
109+
backup = true
110+
track_undo = true
111+
non_interactive = false
112+
assume_yes = false
113+
114+
[replace_text_ast_v3]
115+
# AST-based refactoring defaults (v3 with undo support)
102116
dry_run = false
103117
backup = true
104118
language = auto # Auto-detect language
105119
check_compile = true
120+
track_undo = true # Enable undo tracking
121+
scope_aware = true # Enhanced scope analysis
122+
# v1.5.0 - Interactive support
123+
non_interactive = false
124+
assume_yes = false
125+
126+
[replace_text_ast]
127+
# Legacy alias - redirects to v3 settings
128+
dry_run = false
129+
backup = true
130+
track_undo = true
131+
non_interactive = false
132+
assume_yes = false
133+
134+
[text_undo]
135+
# Text undo system defaults (v1.5.0 - interactive_utils support)
136+
non_interactive = false
137+
assume_yes = false
138+
allow_interactive_selection = true # Allow numbered menu selections
139+
max_history_days = 30 # Keep undo history for 30 days
140+
auto_cleanup = true # Automatically clean old entries
141+
142+
[unified_refactor_v2]
143+
# Universal refactoring defaults (v2 with undo support)
144+
backend = auto # Auto-detect: java_scope for .java, python_ast for .py
145+
dry_run = false
146+
backup = true
147+
check_compile = true
148+
track_undo = true # Enable undo tracking
149+
# v1.5.0 - Interactive support
150+
non_interactive = false
151+
assume_yes = false
152+
153+
[unified_refactor]
154+
# Legacy alias - redirects to v2 settings
155+
backend = auto # Auto-detect backend based on file type
156+
dry_run = false
157+
backup = true
158+
track_undo = true
159+
non_interactive = false
160+
assume_yes = false
106161

107162
[navigate_ast]
108163
# AST navigation defaults
@@ -197,19 +252,56 @@ format = text
197252
#
198253
# Then use: export PYTOOLSRC=.pytoolsrc.ci
199254

200-
# ===== ENVIRONMENT VARIABLE OVERRIDES =====
255+
# ===== ENVIRONMENT VARIABLE OVERRIDES (v1.5.0) =====
201256
# These override config file settings:
202257
#
203258
# SFM_ASSUME_YES=1 - Auto-confirm safe_file_manager
204259
# SAFEGIT_NONINTERACTIVE=1 - Non-interactive git operations
205260
# PYTOOLSRC_NON_INTERACTIVE=1 - Global non-interactive mode
206261
# PYTOOLSRC=/path/to/config - Use different config file
262+
#
263+
# Tool-specific variables (v1.5.0):
264+
# TEXT_UNDO_ASSUME_YES=1 - Auto-confirm text_undo operations
265+
# REPLACE_TEXT_ASSUME_YES=1 - Auto-confirm replace operations
266+
# REPLACE_TEXT_AST_ASSUME_YES=1 - Auto-confirm AST refactoring
267+
# UNIFIED_REFACTOR_ASSUME_YES=1 - Auto-confirm refactoring
207268

208269
# ===== QUICK AUTOMATION SETUP =====
209270
# For temporary automation without changing this file:
210271
#
211272
# export SFM_ASSUME_YES=1
212273
# export SAFEGIT_NONINTERACTIVE=1
213274
# export SAFEGIT_ASSUME_YES=1
275+
# export TEXT_UNDO_ASSUME_YES=1
276+
# export REPLACE_TEXT_ASSUME_YES=1
277+
# export REPLACE_TEXT_AST_ASSUME_YES=1
278+
# export UNIFIED_REFACTOR_ASSUME_YES=1
214279
# # Run your automated tasks...
215-
# unset SFM_ASSUME_YES SAFEGIT_NONINTERACTIVE SAFEGIT_ASSUME_YES
280+
# unset SFM_ASSUME_YES SAFEGIT_NONINTERACTIVE SAFEGIT_ASSUME_YES TEXT_UNDO_ASSUME_YES REPLACE_TEXT_ASSUME_YES REPLACE_TEXT_AST_ASSUME_YES UNIFIED_REFACTOR_ASSUME_YES
281+
282+
# ===== CI/CD AUTOMATION PROFILE =====
283+
# Complete environment setup for CI/CD environments
284+
# Copy to .pytoolsrc.ci or export these variables:
285+
#
286+
# # Core automation
287+
# export PYTOOLSRC_NON_INTERACTIVE=1
288+
# export CI=true
289+
# export DISABLE_ERROR_LOGGING=1 # Optional: disable error logging in CI
290+
#
291+
# # File operations
292+
# export SFM_ASSUME_YES=1
293+
# export SFM_NON_INTERACTIVE=1
294+
#
295+
# # Git operations
296+
# export SAFEGIT_NONINTERACTIVE=1
297+
# export SAFEGIT_ASSUME_YES=1
298+
#
299+
# # Text operations with undo
300+
# export TEXT_UNDO_ASSUME_YES=1
301+
# export REPLACE_TEXT_ASSUME_YES=1
302+
# export REPLACE_TEXT_AST_ASSUME_YES=1
303+
# export UNIFIED_REFACTOR_ASSUME_YES=1
304+
#
305+
# # Analysis tools
306+
# export FIND_TEXT_NON_INTERACTIVE=1
307+
# export NAVIGATE_AST_NON_INTERACTIVE=1

.pytoolsrc.README.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# Configuration Files for Code Intelligence Toolkit v1.5.0
2+
3+
This directory contains multiple `.pytoolsrc` configuration files for different use cases.
4+
5+
## Available Configurations
6+
7+
### 1. `.pytoolsrc` (Default - Development)
8+
- **Purpose**: Interactive development with safety
9+
- **Mode**: Interactive with confirmations
10+
- **Best for**: Day-to-day development work
11+
- **Usage**: Default configuration (no setup needed)
12+
13+
### 2. `.pytoolsrc.ci` (CI/CD Environments)
14+
- **Purpose**: Continuous integration and automated testing
15+
- **Mode**: Fully non-interactive, auto-confirm safe operations
16+
- **Best for**: GitHub Actions, GitLab CI, Jenkins, automated testing
17+
- **Usage**: `export PYTOOLSRC=.pytoolsrc.ci`
18+
19+
### 3. `.pytoolsrc.automation` (General Automation)
20+
- **Purpose**: Local automation and batch processing
21+
- **Mode**: Non-interactive but keeps output for debugging
22+
- **Best for**: Scripts, batch operations, local automation
23+
- **Usage**: `export PYTOOLSRC=.pytoolsrc.automation`
24+
25+
### 4. `.pytoolsrc.safe` (Maximum Safety)
26+
- **Purpose**: Maximum safety with extensive validation
27+
- **Mode**: Interactive with dry-run by default
28+
- **Best for**: Production changes, critical code, learning
29+
- **Usage**: `export PYTOOLSRC=.pytoolsrc.safe`
30+
31+
## Quick Setup Examples
32+
33+
### CI/CD (GitHub Actions)
34+
```yaml
35+
env:
36+
PYTOOLSRC: .pytoolsrc.ci
37+
steps:
38+
- run: ./run_any_python_tool.sh safe_file_manager.py organize src/
39+
```
40+
41+
### Local Automation Script
42+
```bash
43+
#\!/bin/bash
44+
export PYTOOLSRC=.pytoolsrc.automation
45+
46+
# Your automated operations
47+
./run_any_python_tool.sh replace_text_v9.py "TODO" "DONE" --scope src/
48+
./run_any_python_tool.sh safe_file_manager.py organize ~/Downloads
49+
```
50+
51+
### Safe Mode for Critical Changes
52+
```bash
53+
export PYTOOLSRC=.pytoolsrc.safe
54+
./run_any_python_tool.sh replace_text_v9.py "oldAPI" "newAPI" --scope src/
55+
# Will preview changes and ask for confirmation
56+
```
57+
58+
## Environment Variable Overrides
59+
60+
You can override specific settings with environment variables (highest priority):
61+
62+
```bash
63+
# Force non-interactive mode for any tool
64+
export PYTOOLSRC_NON_INTERACTIVE=1
65+
66+
# Tool-specific overrides
67+
export SFM_ASSUME_YES=1 # safe_file_manager
68+
export SAFEGIT_NONINTERACTIVE=1 # safegit
69+
export TEXT_UNDO_ASSUME_YES=1 # text_undo
70+
export REPLACE_TEXT_ASSUME_YES=1 # replace_text_v9
71+
export REPLACE_TEXT_AST_ASSUME_YES=1 # replace_text_ast_v3
72+
export UNIFIED_REFACTOR_ASSUME_YES=1 # unified_refactor_v2
73+
```
74+
75+
## Configuration Priority
76+
77+
Tools check settings in this order (first found wins):
78+
79+
1. **Command-line flags** (e.g., `--yes`, `--non-interactive`)
80+
2. **Environment variables** (e.g., `TOOL_NAME_ASSUME_YES=1`)
81+
3. **Configuration file** (specified by `PYTOOLSRC`)
82+
4. **Default config** (`.pytoolsrc`)
83+
5. **Tool defaults** (interactive mode)
84+
85+
## v1.5.0 Features
86+
87+
All configurations support the new interactive_utils features:
88+
89+
-**EOF Error Elimination**: No more "EOF when reading a line" crashes
90+
-**Auto CI Detection**: Automatically detects CI environments
91+
-**Unified Behavior**: Same patterns work across all migrated tools
92+
-**Clear Error Messages**: Actionable hints when interaction is required
93+
-**Multiple Prompt Types**: Yes/no, typed phrases, numbered selections
94+
-**Language-Aware Backends**: Auto-detects Java vs Python for optimal AST processing
95+
96+
## Tool Migration Status (v1.5.0)
97+
98+
**Fully Migrated** (support all configurations):
99+
-`text_undo.py` - Numbered selection menus
100+
-`safe_file_manager.py` - Risk-based confirmations
101+
-`safegit.py` - Multi-choice prompts
102+
-`replace_text_v9.py` - Large change confirmations
103+
-`replace_text_ast_v3.py` - Batch operation confirmations
104+
105+
**Legacy Tools** (basic environment variable support):
106+
- Tools using older patterns - use environment variables for non-interactive mode
107+
108+
## Troubleshooting
109+
110+
### Tool Still Prompts Despite Configuration
111+
1. Check `PYTOOLSRC` is set: `echo $PYTOOLSRC`
112+
2. Verify tool supports interactive_utils: `grep "interactive_utils" tool_name.py`
113+
3. Add tool-specific environment variable: `export TOOL_NAME_ASSUME_YES=1`
114+
4. Use command-line flag: `./run_any_python_tool.sh tool.py --yes`
115+
116+
### Testing Non-Interactive Mode
117+
```bash
118+
# Test with no stdin (should not hang)
119+
(exec < /dev/null && PYTOOLSRC=.pytoolsrc.ci ./run_any_python_tool.sh safe_file_manager.py list .)
120+
```
121+
122+
## Backend Auto-Detection (v1.5.0)
123+
124+
All configurations use intelligent backend selection for `unified_refactor`:
125+
126+
```ini
127+
[unified_refactor_v2]
128+
backend = auto # Auto-detect: java_scope for .java, python_ast for .py
129+
```
130+
131+
**How it works:**
132+
- **`.java` files**`java_scope` backend (Java AST analysis)
133+
- **`.py` files**`python_ast` backend (Python AST analysis)
134+
- **Other files**`text_based` backend (fallback)
135+
136+
**Benefits:**
137+
-**Mixed codebases** work seamlessly without manual configuration
138+
-**Optimal performance** using language-specific AST parsers
139+
-**No configuration overhead** - just works for any file type
140+
-**Consistent behavior** across all configuration profiles
141+
142+
## Creating Custom Configurations
143+
144+
Copy an existing configuration and modify as needed:
145+
146+
```bash
147+
cp .pytoolsrc.automation .pytoolsrc.custom
148+
# Edit .pytoolsrc.custom with your specific requirements
149+
export PYTOOLSRC=.pytoolsrc.custom
150+
```
151+
152+
## Security Note
153+
154+
- **Never set `force = true`** in configuration files
155+
- **Use environment variables** for temporary force operations
156+
- **Test configurations** in safe environments first
157+
- **Keep backups enabled** (`backup = true`) in all configurations
158+
159+
---
160+
161+
For complete documentation, see:
162+
- [NON_INTERACTIVE_GUIDE.md](NON_INTERACTIVE_GUIDE.md)
163+
- [INTERACTIVE_UTILS_MIGRATION_STATUS.md](INTERACTIVE_UTILS_MIGRATION_STATUS.md)
164+
EOF < /dev/null

0 commit comments

Comments
 (0)