Skip to content

Latest commit

 

History

History
164 lines (125 loc) · 5.64 KB

File metadata and controls

164 lines (125 loc) · 5.64 KB

Configuration Files for Code Intelligence Toolkit v1.5.0

This directory contains multiple .pytoolsrc configuration files for different use cases.

Available Configurations

1. .pytoolsrc (Default - Development)

  • Purpose: Interactive development with safety
  • Mode: Interactive with confirmations
  • Best for: Day-to-day development work
  • Usage: Default configuration (no setup needed)

2. .pytoolsrc.ci (CI/CD Environments)

  • Purpose: Continuous integration and automated testing
  • Mode: Fully non-interactive, auto-confirm safe operations
  • Best for: GitHub Actions, GitLab CI, Jenkins, automated testing
  • Usage: export PYTOOLSRC=.pytoolsrc.ci

3. .pytoolsrc.automation (General Automation)

  • Purpose: Local automation and batch processing
  • Mode: Non-interactive but keeps output for debugging
  • Best for: Scripts, batch operations, local automation
  • Usage: export PYTOOLSRC=.pytoolsrc.automation

4. .pytoolsrc.safe (Maximum Safety)

  • Purpose: Maximum safety with extensive validation
  • Mode: Interactive with dry-run by default
  • Best for: Production changes, critical code, learning
  • Usage: export PYTOOLSRC=.pytoolsrc.safe

Quick Setup Examples

CI/CD (GitHub Actions)

env:
  PYTOOLSRC: .pytoolsrc.ci
steps:
  - run: ./run_any_python_tool.sh safe_file_manager.py organize src/

Local Automation Script

#\!/bin/bash
export PYTOOLSRC=.pytoolsrc.automation

# Your automated operations
./run_any_python_tool.sh replace_text_v9.py "TODO" "DONE" --scope src/
./run_any_python_tool.sh safe_file_manager.py organize ~/Downloads

Safe Mode for Critical Changes

export PYTOOLSRC=.pytoolsrc.safe
./run_any_python_tool.sh replace_text_v9.py "oldAPI" "newAPI" --scope src/
# Will preview changes and ask for confirmation

Environment Variable Overrides

You can override specific settings with environment variables (highest priority):

# Force non-interactive mode for any tool
export PYTOOLSRC_NON_INTERACTIVE=1

# Tool-specific overrides
export SFM_ASSUME_YES=1                    # safe_file_manager
export SAFEGIT_NONINTERACTIVE=1            # safegit
export TEXT_UNDO_ASSUME_YES=1              # text_undo
export REPLACE_TEXT_ASSUME_YES=1           # replace_text_v9
export REPLACE_TEXT_AST_ASSUME_YES=1       # replace_text_ast_v3
export UNIFIED_REFACTOR_ASSUME_YES=1       # unified_refactor_v2

Configuration Priority

Tools check settings in this order (first found wins):

  1. Command-line flags (e.g., --yes, --non-interactive)
  2. Environment variables (e.g., TOOL_NAME_ASSUME_YES=1)
  3. Configuration file (specified by PYTOOLSRC)
  4. Default config (.pytoolsrc)
  5. Tool defaults (interactive mode)

v1.5.0 Features

All configurations support the new interactive_utils features:

  • EOF Error Elimination: No more "EOF when reading a line" crashes
  • Auto CI Detection: Automatically detects CI environments
  • Unified Behavior: Same patterns work across all migrated tools
  • Clear Error Messages: Actionable hints when interaction is required
  • Multiple Prompt Types: Yes/no, typed phrases, numbered selections
  • Language-Aware Backends: Auto-detects Java vs Python for optimal AST processing

Tool Migration Status (v1.5.0)

Fully Migrated (support all configurations):

  • text_undo.py - Numbered selection menus
  • safe_file_manager.py - Risk-based confirmations
  • safegit.py - Multi-choice prompts
  • replace_text_v9.py - Large change confirmations
  • replace_text_ast_v3.py - Batch operation confirmations

Legacy Tools (basic environment variable support):

  • Tools using older patterns - use environment variables for non-interactive mode

Troubleshooting

Tool Still Prompts Despite Configuration

  1. Check PYTOOLSRC is set: echo $PYTOOLSRC
  2. Verify tool supports interactive_utils: grep "interactive_utils" tool_name.py
  3. Add tool-specific environment variable: export TOOL_NAME_ASSUME_YES=1
  4. Use command-line flag: ./run_any_python_tool.sh tool.py --yes

Testing Non-Interactive Mode

# Test with no stdin (should not hang)
(exec < /dev/null && PYTOOLSRC=.pytoolsrc.ci ./run_any_python_tool.sh safe_file_manager.py list .)

Backend Auto-Detection (v1.5.0)

All configurations use intelligent backend selection for unified_refactor:

[unified_refactor_v2]
backend = auto                      # Auto-detect: java_scope for .java, python_ast for .py

How it works:

  • .java filesjava_scope backend (Java AST analysis)
  • .py filespython_ast backend (Python AST analysis)
  • Other filestext_based backend (fallback)

Benefits:

  • Mixed codebases work seamlessly without manual configuration
  • Optimal performance using language-specific AST parsers
  • No configuration overhead - just works for any file type
  • Consistent behavior across all configuration profiles

Creating Custom Configurations

Copy an existing configuration and modify as needed:

cp .pytoolsrc.automation .pytoolsrc.custom
# Edit .pytoolsrc.custom with your specific requirements
export PYTOOLSRC=.pytoolsrc.custom

Security Note

  • Never set force = true in configuration files
  • Use environment variables for temporary force operations
  • Test configurations in safe environments first
  • Keep backups enabled (backup = true) in all configurations

For complete documentation, see: