mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-12 02:37:45 +08:00
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:
@@ -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`.
|
|
||||||
@@ -199,19 +199,14 @@ add_to_shell_config() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Try to add alias automatically
|
# Add pycli to PATH
|
||||||
ALIAS_ADDED=false
|
|
||||||
PATH_ADDED=false
|
PATH_ADDED=false
|
||||||
|
|
||||||
if [[ -n "$SHELL_RC" ]]; then
|
if [[ -n "$SHELL_RC" ]]; then
|
||||||
# Try to add alias
|
# Add pycli directory to PATH
|
||||||
if add_to_shell_config "$SHELL_RC" "alias pycli='$INSTALL_DIR/pycli'"; then
|
|
||||||
ALIAS_ADDED=true
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Also add to PATH
|
|
||||||
if add_to_shell_config "$SHELL_RC" "export PATH=\"\$PATH:$INSTALL_DIR\""; then
|
if add_to_shell_config "$SHELL_RC" "export PATH=\"\$PATH:$INSTALL_DIR\""; then
|
||||||
PATH_ADDED=true
|
PATH_ADDED=true
|
||||||
|
print_success "Added $INSTALL_DIR to PATH in $SHELL_RC"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -254,7 +249,7 @@ echo
|
|||||||
echo "🚀 Quick Start:"
|
echo "🚀 Quick Start:"
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
|
|
||||||
if [[ "$ALIAS_ADDED" == true ]]; then
|
if [[ "$PATH_ADDED" == true ]]; then
|
||||||
echo " 1. Reload your shell configuration:"
|
echo " 1. Reload your shell configuration:"
|
||||||
echo " source $SHELL_RC"
|
echo " source $SHELL_RC"
|
||||||
echo
|
echo
|
||||||
@@ -265,16 +260,12 @@ if [[ "$ALIAS_ADDED" == true ]]; then
|
|||||||
echo " 3. Start analyzing code:"
|
echo " 3. Start analyzing code:"
|
||||||
echo " pycli --analyze --query \"authentication patterns\" --tool gemini"
|
echo " pycli --analyze --query \"authentication patterns\" --tool gemini"
|
||||||
else
|
else
|
||||||
echo " 1. Add pycli to your shell configuration:"
|
echo " 1. Add pycli to your PATH manually:"
|
||||||
if [[ -n "$SHELL_RC" ]]; then
|
echo " echo 'export PATH=\"\$PATH:$INSTALL_DIR\"' >> $SHELL_RC"
|
||||||
echo " echo \"alias pycli='$INSTALL_DIR/pycli'\" >> $SHELL_RC"
|
echo " source $SHELL_RC"
|
||||||
echo " source $SHELL_RC"
|
|
||||||
else
|
|
||||||
echo " alias pycli='$INSTALL_DIR/pycli'"
|
|
||||||
fi
|
|
||||||
echo
|
echo
|
||||||
echo " 2. Or add to PATH:"
|
echo " 2. Or create a symlink (alternative):"
|
||||||
echo " export PATH=\"\$PATH:$INSTALL_DIR\""
|
echo " sudo ln -sf $INSTALL_DIR/pycli /usr/local/bin/pycli"
|
||||||
echo
|
echo
|
||||||
echo " 3. Initialize vector DB for a project:"
|
echo " 3. Initialize vector DB for a project:"
|
||||||
echo " cd /path/to/your/project"
|
echo " cd /path/to/your/project"
|
||||||
@@ -293,10 +284,11 @@ echo
|
|||||||
echo "⚙️ Configuration:"
|
echo "⚙️ Configuration:"
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
echo " • Edit config: $INSTALL_DIR/pycli.conf"
|
echo " • Edit config: $INSTALL_DIR/pycli.conf"
|
||||||
|
echo " • pycli location: $INSTALL_DIR/pycli"
|
||||||
|
|
||||||
if [[ -z "$DETECTED_PYTHON" ]]; then
|
if [[ -z "$DETECTED_PYTHON" ]]; then
|
||||||
echo " • ⚠️ Please update PYTHON_PATH in pycli.conf"
|
echo " • ⚠️ Please update PYTHON_PATH in pycli.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
print_success "Installation complete! 🎉"
|
print_success "Installation complete! Now you can use 'pycli' command directly! 🎉"
|
||||||
@@ -140,10 +140,11 @@ Output Options:
|
|||||||
# Install pycli system
|
# Install pycli system
|
||||||
bash D:/Claude_dms3/.claude/scripts/install_pycli.sh
|
bash D:/Claude_dms3/.claude/scripts/install_pycli.sh
|
||||||
|
|
||||||
# Add to shell (automatic during install)
|
# The script will automatically add ~/.claude/scripts/ to your PATH
|
||||||
alias pycli='~/.claude/scripts/pycli'
|
# Reload your shell configuration
|
||||||
|
source ~/.bashrc # or ~/.zshrc
|
||||||
|
|
||||||
# Verify installation
|
# Verify installation - now you can use pycli directly
|
||||||
pycli --help
|
pycli --help
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -412,38 +413,6 @@ python .claude/python_script/indexer.py --rebuild-index --update-embeddings
|
|||||||
- ✅ System performance degraded
|
- ✅ System performance degraded
|
||||||
- ✅ Configuration changed
|
- ✅ 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
|
### 🚀 Migration from Legacy Tools
|
||||||
|
|
||||||
@@ -479,33 +448,4 @@ pycli --analyze --query "login implementation patterns" --tool codex
|
|||||||
- **Environment Management**: Configurable Python interpreter path
|
- **Environment Management**: Configurable Python interpreter path
|
||||||
- **Hierarchical Support**: Intelligent parent directory discovery
|
- **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
|
|
||||||
```
|
|
||||||
Reference in New Issue
Block a user