|
| 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