Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/advanced/ci-cd.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'

- name: Install Refactron
run: pip install refactron

- name: Analyze Code
run: refactron analyze . --log-format json
```
Expand Down Expand Up @@ -131,7 +131,7 @@ repos:
refactron analyze . --log-format json
```
</Accordion>

<Accordion title="Configure Failure Thresholds">
Fail builds based on severity:
```yaml
Expand All @@ -142,7 +142,7 @@ repos:
max_error_issues: 10
```
</Accordion>

<Accordion title="Cache Dependencies">
Speed up CI runs by caching pip packages:
```yaml
Expand All @@ -153,7 +153,7 @@ repos:
key: ${{ runner.os }}-pip-refactron
```
</Accordion>

<Accordion title="Generate Reports">
Create HTML reports and save as artifacts:
```bash
Expand Down
8 changes: 4 additions & 4 deletions docs/advanced/monitoring.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: 'Production monitoring and telemetry'
Refactron includes comprehensive logging and monitoring capabilities for production environments:

- **Structured Logging** - JSON-formatted logs for CI/CD
- **Metrics Collection** - Track analysis time and success rates
- **Metrics Collection** - Track analysis time and success rates
- **Prometheus Integration** - Expose metrics via HTTP endpoint
- **Opt-in Telemetry** - Anonymous usage analytics

Expand Down Expand Up @@ -187,15 +187,15 @@ prometheus_port: 9090
<Step title="Use JSON Logging in CI/CD">
JSON format integrates easily with log aggregation systems
</Step>

<Step title="Enable Metrics in Production">
Track performance and identify bottlenecks
</Step>

<Step title="Set Up Prometheus Dashboards">
Visualize Refactron metrics over time
</Step>

<Step title="Keep Telemetry Optional">
Respect user privacy with opt-in telemetry
</Step>
Expand Down
10 changes: 5 additions & 5 deletions docs/advanced/performance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ Cache parsed Abstract Syntax Trees to avoid re-parsing.
- Reduces CPU usage
- Especially effective for large files
</Accordion>

<Accordion title="Configuration">
```python
from refactron import Refactron
from refactron.core.config import RefactronConfig

config = RefactronConfig(
enable_ast_cache=True,
max_ast_cache_size_mb=100
)
refactron = Refactron(config)
```
</Accordion>

<Accordion title="Cache Statistics">
```python
stats = refactron.get_performance_stats()
Expand Down Expand Up @@ -156,13 +156,13 @@ refactron.clear_caches()
print(f"Hit rate: {stats['ast_cache']['hit_rate']}%")
```
</Accordion>

<Accordion title="High Memory Usage">
- Reduce cache size: `max_ast_cache_size_mb: 50`
- Lower parallel workers: `max_parallel_workers: 2`
- Clear caches periodically: `refactron.clear_caches()`
</Accordion>

<Accordion title="Parallel Processing Slower">
Disable for small codebases:
```yaml
Expand Down
4 changes: 2 additions & 2 deletions docs/api-reference/refactron-class.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def refactor(

<ParamField path="operation_types" type="List[str]" default="None">
Specific refactoring types to apply. None = all types.

Available types:
- `extract_constant`
- `add_docstring`
Expand Down Expand Up @@ -316,7 +316,7 @@ for op in result.operations:
print(f" File: {op.file_path}:{op.line_number}")
print(f" Risk: {op.risk_score}")
print(f" Description: {op.description}")

# Record feedback
refactron.record_feedback(
operation_id=op.operation_id,
Expand Down
2 changes: 1 addition & 1 deletion docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@
"vscode"
]
}
}
}
10 changes: 5 additions & 5 deletions docs/essentials/authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ Features that require authentication:
refactron repo connect my-repo
```
</Accordion>

<Accordion icon="sparkles" title="Cloud AI Features">
Enhanced AI-powered refactoring with cloud LLM models
</Accordion>

<Accordion icon="chart-simple" title="Usage Analytics">
```bash
refactron metrics
```
</Accordion>

<Accordion icon="share-nodes" title="Team Pattern Sharing">
Share learned patterns across your team
</Accordion>
Expand All @@ -120,15 +120,15 @@ Cloud features gracefully degrade when offline.
2. Paste it into your browser manually
3. Complete the authentication
</Accordion>

<Accordion title="Token expired">
If you see "Token expired" errors:
```bash
refactron auth logout
refactron login
```
</Accordion>

<Accordion title="API key not working">
Verify the API key is set correctly:
```bash
Expand Down
16 changes: 8 additions & 8 deletions docs/essentials/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,23 @@ pattern_storage_dir: null # null = auto-detect
<Accordion icon="shield" title="security">
Detects security vulnerabilities like SQL injection, code injection, hardcoded secrets, and SSRF
</Accordion>

<Accordion icon="code" title="code_smell">
Identifies magic numbers, long functions, excessive parameters, and deep nesting
</Accordion>

<Accordion icon="chart-line" title="complexity">
Measures cyclomatic complexity, maintainability index, and nested loops
</Accordion>

<Accordion icon="file-code" title="type_hint">
Checks for missing or incomplete type annotations
</Accordion>

<Accordion icon="trash" title="dead_code">
Finds unused functions and unreachable code
</Accordion>

<Accordion icon="link" title="dependency">
Analyzes circular imports and wildcard imports
</Accordion>
Expand All @@ -95,15 +95,15 @@ pattern_storage_dir: null # null = auto-detect
<Accordion title="extract_constant">
Extract magic numbers into named constants
</Accordion>

<Accordion title="add_docstring">
Add missing docstrings to functions and classes
</Accordion>

<Accordion title="simplify_conditionals">
Simplify complex conditional statements
</Accordion>

<Accordion title="reduce_parameters">
Reduce function parameter count using dataclasses or dictionaries
</Accordion>
Expand Down
8 changes: 4 additions & 4 deletions docs/essentials/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: 'How to install and set up Refactron'
## Requirements

<Info>
**Python Version**: 3.8 or higher
**Python Version**: 3.8 or higher
**Supported Platforms**: macOS, Linux, Windows
</Info>

Expand Down Expand Up @@ -71,7 +71,7 @@ Refactron automatically installs these dependencies:
- **radon** - Complexity metrics
- **astroid** - AST analysis
</Accordion>

<Accordion title="AI & RAG Dependencies">
- **chromadb** - Vector database for RAG
- **tree-sitter** - Code parsing
Expand All @@ -90,7 +90,7 @@ Refactron automatically installs these dependencies:
pip install --user refactron
```
</Accordion>

<Accordion title="Python Version Issues">
Ensure you're using Python 3.8+:
```bash
Expand All @@ -101,7 +101,7 @@ Refactron automatically installs these dependencies:
python3.10 -m pip install refactron
```
</Accordion>

<Accordion title="SSL Certificate Errors">
On macOS, you may need to install certificates:
```bash
Expand Down
32 changes: 16 additions & 16 deletions docs/guides/ai-features.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,19 @@ refactron refactor myfile.py --ai --apply
<Step title="Analysis">
Refactron analyzes your code for issues
</Step>

<Step title="Context Retrieval">
RAG system retrieves relevant code chunks from your project
</Step>

<Step title="LLM Generation">
LLM generates refactoring suggestions with project context
</Step>

<Step title="Safety Validation">
Safety gate validates syntax and checks for issues
</Step>

<Step title="Presentation">
Suggestions presented with explanations and risk scores
</Step>
Expand All @@ -158,10 +158,10 @@ AI-powered refactoring suggests:
# AI-suggested refactoring
def process_users(users):
"""Process and filter users based on eligibility criteria.

Args:
users: List of user objects to process

Returns:
List of eligible users (adult, active, verified)
"""
Expand Down Expand Up @@ -202,21 +202,21 @@ refactron suggest myfile.py --line 42 --apply
<AccordionGroup>
<Accordion title="Groq (Recommended)" icon="bolt">
Fast, cloud-based LLM provider with free tier

**Models:**
- `llama3-70b-8192` - Best quality
- `llama3-8b-8192` - Faster, good quality
- `mixtral-8x7b-32768` - Long context window

**Setup:**
```bash
export GROQ_API_KEY='your-key'
```
</Accordion>

<Accordion title="Custom Providers" icon="gear">
Bring your own LLM provider

Configure in `.refactron.yaml`:
```yaml
llm:
Expand Down Expand Up @@ -301,19 +301,19 @@ refactron feedback <operation-id> --action rejected --reason "Breaks API contrac
<Accordion title="Keep Index Updated">
Re-run `refactron rag index` after significant code changes for accurate context
</Accordion>

<Accordion title="Use Higher-Parameter Models">
Models like Llama 3 70B provide better refactoring logic than smaller models
</Accordion>

<Accordion title="Always Preview AI Suggestions">
Use `--preview` to review AI-generated code before applying
</Accordion>

<Accordion title="Provide Feedback">
Record feedback to improve AI suggestions over time
</Accordion>

<Accordion title="Test After Applying">
Run your test suite after applying AI refactorings
</Accordion>
Expand All @@ -329,14 +329,14 @@ refactron feedback <operation-id> --action rejected --reason "Breaks API contrac
```
Export it in your shell profile for persistence
</Accordion>

<Accordion title="RAG Index Not Found">
Create index first:
```bash
refactron rag index
```
</Accordion>

<Accordion title="Slow AI Responses">
- Use smaller models (llama3-8b-8192)
- Reduce `max_tokens`
Expand Down
Loading
Loading