refactor: Simplify pycli installation to use PATH environment variable

- Modify install_pycli.sh to add ~/.claude/scripts/ to PATH instead of creating alias
- Remove redundant alias configuration, use direct PATH registration
- Update documentation to reflect simplified installation process
- Delete README.md as requested by user
- Now users can call 'pycli' directly after installation without alias setup

Installation process:
1. Run install_pycli.sh
2. Reload shell configuration (source ~/.bashrc)
3. Use 'pycli' command directly

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
catlog22
2025-09-23 22:15:52 +08:00
parent c337204242
commit 9a1e90e558
3 changed files with 15 additions and 235 deletions

View File

@@ -1,152 +0,0 @@
# pycli - Python CLI Wrapper with Hierarchical Vector Database
This directory contains the bash wrapper and configuration for the enhanced Python-based analysis CLI with hierarchical vector database support.
## 📁 Files
- **`pycli`** - Main bash wrapper script
- **`pycli.conf`** - Configuration file
- **`install_pycli.sh`** - Installation script
- **`README.md`** - This documentation
## 🚀 Quick Installation
```bash
# Run the installation script
bash install_pycli.sh
# Follow the prompts to configure your shell
# The script will automatically detect your Python installation
# Verify installation
pycli --help
```
## 🎯 Key Features
### Hierarchical Vector Database
- **Smart Parent Discovery**: Subdirectories automatically use parent's vector database
- **No Redundant Processing**: Avoids duplicate vectorization in project subdirectories
- **Central Storage**: All vector databases stored in `~/.claude/vector_db/`
- **Path-based Organization**: Organized by project directory structure
### Unified Interface
- **Single Command**: `pycli` replaces complex Python script calls
- **Intelligent Context**: Automatic file discovery with semantic search
- **Tool Integration**: Seamless integration with Gemini and Codex
- **Configuration Management**: Environment-specific Python interpreter paths
## 📋 Common Commands
```bash
# Initialize new project
cd /path/to/your/project
pycli --init
# Smart analysis
pycli --analyze --query "authentication patterns" --tool gemini
# Direct analysis
pycli --analyze --tool codex -p "implement user login"
# Maintenance
pycli --update-embeddings
pycli --status
```
## 🔧 Configuration
Edit `~/.claude/scripts/pycli.conf` after installation:
```bash
# Python interpreter path
PYTHON_PATH="/usr/bin/python3"
# Vector database root directory
VECTOR_DB_ROOT="$HOME/.claude/vector_db"
# Python scripts directory
PYTHON_SCRIPT_DIR="$HOME/.claude/python_script"
```
## 🏗️ How Hierarchical DB Works
```
Project Structure: Vector Database:
/home/user/myproject/ ~/.claude/vector_db/
├── src/ └── home_user_myproject/
│ ├── auth/ ├── embeddings.pkl
│ └── api/ └── index.json
└── tests/
# All subdirectories use the single parent DB
```
## 📖 Documentation
For complete usage information, see:
- **Strategy Guide**: `~/.claude/workflows/python-tools-strategy.md`
- **Installation Guide**: Run `bash install_pycli.sh` for guided setup
## 🎪 Migration from Legacy Tools
```bash
# Replace gemini-wrapper
# OLD: ~/.claude/scripts/gemini-wrapper -p "prompt"
# NEW: pycli --analyze --tool gemini -p "prompt"
# Replace codex commands
# OLD: codex --full-auto exec "task"
# NEW: pycli --analyze --tool codex -p "task"
# Enhanced with context discovery
pycli --analyze --query "relevant context" --tool both
```
## 🐛 Troubleshooting
```bash
# Check system status
pycli --status
# Rebuild everything
pycli --init
# Test search functionality
pycli --test-search
# View configuration
cat ~/.claude/scripts/pycli.conf
```
## 💡 Advanced Usage
### Project Integration
```bash
# Add to package.json
{
"scripts": {
"analyze": "pycli --analyze --query",
"ai-init": "pycli --init",
"ai-update": "pycli --update-embeddings"
}
}
# Use in Makefiles
analyze:
pycli --analyze --query "$(QUERY)" --tool gemini
```
### CI/CD Integration
```yaml
# GitHub Actions example
- name: Update AI Context
run: pycli --update-embeddings
- name: Analyze Changes
run: pycli --analyze --query "code review" --tool gemini
```
---
For questions or issues, check the documentation or run `pycli --help`.

View File

@@ -199,19 +199,14 @@ add_to_shell_config() {
return 1
}
# Try to add alias automatically
ALIAS_ADDED=false
# Add pycli to PATH
PATH_ADDED=false
if [[ -n "$SHELL_RC" ]]; then
# Try to add alias
if add_to_shell_config "$SHELL_RC" "alias pycli='$INSTALL_DIR/pycli'"; then
ALIAS_ADDED=true
fi
# Also add to PATH
# Add pycli directory to PATH
if add_to_shell_config "$SHELL_RC" "export PATH=\"\$PATH:$INSTALL_DIR\""; then
PATH_ADDED=true
print_success "Added $INSTALL_DIR to PATH in $SHELL_RC"
fi
fi
@@ -254,7 +249,7 @@ echo
echo "🚀 Quick Start:"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
if [[ "$ALIAS_ADDED" == true ]]; then
if [[ "$PATH_ADDED" == true ]]; then
echo " 1. Reload your shell configuration:"
echo " source $SHELL_RC"
echo
@@ -265,16 +260,12 @@ if [[ "$ALIAS_ADDED" == true ]]; then
echo " 3. Start analyzing code:"
echo " pycli --analyze --query \"authentication patterns\" --tool gemini"
else
echo " 1. Add pycli to your shell configuration:"
if [[ -n "$SHELL_RC" ]]; then
echo " echo \"alias pycli='$INSTALL_DIR/pycli'\" >> $SHELL_RC"
echo " source $SHELL_RC"
else
echo " alias pycli='$INSTALL_DIR/pycli'"
fi
echo " 1. Add pycli to your PATH manually:"
echo " echo 'export PATH=\"\$PATH:$INSTALL_DIR\"' >> $SHELL_RC"
echo " source $SHELL_RC"
echo
echo " 2. Or add to PATH:"
echo " export PATH=\"\$PATH:$INSTALL_DIR\""
echo " 2. Or create a symlink (alternative):"
echo " sudo ln -sf $INSTALL_DIR/pycli /usr/local/bin/pycli"
echo
echo " 3. Initialize vector DB for a project:"
echo " cd /path/to/your/project"
@@ -293,10 +284,11 @@ echo
echo "⚙️ Configuration:"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " • Edit config: $INSTALL_DIR/pycli.conf"
echo " • pycli location: $INSTALL_DIR/pycli"
if [[ -z "$DETECTED_PYTHON" ]]; then
echo " • ⚠️ Please update PYTHON_PATH in pycli.conf"
fi
echo
print_success "Installation complete! 🎉"
print_success "Installation complete! Now you can use 'pycli' command directly! 🎉"

View File

@@ -140,10 +140,11 @@ Output Options:
# Install pycli system
bash D:/Claude_dms3/.claude/scripts/install_pycli.sh
# Add to shell (automatic during install)
alias pycli='~/.claude/scripts/pycli'
# The script will automatically add ~/.claude/scripts/ to your PATH
# Reload your shell configuration
source ~/.bashrc # or ~/.zshrc
# Verify installation
# Verify installation - now you can use pycli directly
pycli --help
```
@@ -412,38 +413,6 @@ python .claude/python_script/indexer.py --rebuild-index --update-embeddings
- ✅ System performance degraded
- ✅ Configuration changed
### 🔧 Configuration Guidelines
#### Minimal config.yaml
```yaml
embeddings:
enabled: true
similarity_threshold: 0.3
model: "all-MiniLM-L6-v2"
batch_size: 32
tools:
default_tool: "gemini"
timeout: 300
```
#### Performance tuning
```yaml
# Large codebase (>1000 files)
embeddings:
batch_size: 64
similarity_threshold: 0.4
# Memory constrained
embeddings:
batch_size: 16
similarity_threshold: 0.2
# High accuracy needed
embeddings:
model: "all-mpnet-base-v2"
similarity_threshold: 0.5
```
### 🚀 Migration from Legacy Tools
@@ -479,33 +448,4 @@ pycli --analyze --query "login implementation patterns" --tool codex
- **Environment Management**: Configurable Python interpreter path
- **Hierarchical Support**: Intelligent parent directory discovery
### Configuration Flexibility
```bash
# Edit pycli configuration
nano ~/.claude/scripts/pycli.conf
# Key settings:
# PYTHON_PATH - Python interpreter location
# VECTOR_DB_ROOT - Central vector database storage
# HIERARCHICAL_MODE - Enable parent DB discovery
```
### Integration Examples
```bash
# Add to your project's package.json scripts
{
"scripts": {
"analyze": "pycli --analyze --query",
"init-ai": "pycli --init",
"update-ai": "pycli --update-embeddings"
}
}
# Use in Makefiles
analyze:
pycli --analyze --query "$(QUERY)" --tool gemini
# Use in CI/CD pipelines
- name: Update AI Context
run: pycli --update-embeddings
```