episteme 0.3.3

Knowledge graph for software engineering — design patterns, refactorings, and laws for AI agents
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
# Episteme UV Installation & Usage Guide

**Date:** 2026-04-29  
**Version:** 0.0.5

---

## What is uv?

[uv](https://github.com/astral-sh/uv) is an extremely fast Python package installer and resolver written in Rust by Astral (the creators of Ruff). It's designed as a drop-in replacement for pip with 10-100× faster performance.

### Key Features

- **10-100× faster** than pip
- 🔒 **Deterministic installs** with lockfile (`uv.lock`)
- 🎯 **Drop-in replacement** for pip (familiar commands)
- 🚀 **Built-in venv management** (no separate `python -m venv` needed)
- 📦 **Compatible with pyproject.toml** (PEP 621)

---

## Installation

### macOS / Linux

```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
```

### Windows

```powershell
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
```

### Using pipx (cross-platform)

```bash
pipx install uv
```

### Verify Installation

```bash
uv --version
# Output: uv 0.1.x
```

---

## Quick Start with Episteme

### 1. Clone Repository

```bash
git clone https://github.com/epicsagas/Episteme.git
cd Episteme
```

### 2. Install Dependencies

```bash
# Single command: creates venv + installs all dependencies
uv sync

# Output:
# Using Python 3.11.7
# Creating virtualenv at: .venv
# Resolved 25 packages in 127ms
# Downloaded 15 packages in 1.2s
# Installed 25 packages in 423ms
```

**What `uv sync` does:**
1. Reads `pyproject.toml`
2. Checks `.python-version` for Python version
3. Creates `.venv/` if it doesn't exist
4. Resolves dependencies and generates `uv.lock`
5. Installs all packages from lockfile

### 3. Activate Virtual Environment

```bash
# macOS/Linux
source .venv/bin/activate

# Windows
.venv\Scripts\activate
```

### 4. Verify Installation

```bash
python -c "from scripts.language_parsers import get_parser; print('✅ Success')"
```

---

## Common Commands

### Install Packages

```bash
# Install from pyproject.toml
uv sync

# Install with dev dependencies
uv sync --all-extras

# Install specific package
uv add requests

# Install specific version
uv add "fastapi>=0.104.0"

# Install as dev dependency
uv add --dev pytest
```

### Remove Packages

```bash
uv remove requests
```

### Update Dependencies

```bash
# Update all packages
uv sync --upgrade

# Update specific package
uv add --upgrade fastapi
```

### Run Commands

```bash
# Run Python script in venv (no activation needed)
uv run python scripts/detect_smells.py mycode.py

# Run pytest
uv run pytest

# Run custom script
uv run episteme-analyze mycode.py
```

### Lock File Management

```bash
# Generate/update lockfile
uv lock

# Sync from lockfile (reproducible install)
uv sync --frozen
```

---

## Comparison: uv vs pip

### Speed Comparison

**Test**: Install Episteme dependencies (25 packages)

| Tool | Time | Speedup |
|------|------|---------|
| **uv** | 1.6s | **baseline** |
| pip | 45.3s | **28× slower** |
| poetry | 38.7s | **24× slower** |

### Feature Comparison

| Feature | uv | pip | poetry |
|---------|----|----|--------|
| **Speed** | ⚡⚡⚡ |||
| **Lockfile** | ✅ uv.lock || ✅ poetry.lock |
| **Venv management** | ✅ Built-in | ❌ Manual | ✅ Built-in |
| **PEP 621 (pyproject.toml)** ||| ⚠️ Custom format |
| **Dependency resolution** | ✅ Fast | ⚠️ Slow | ⚠️ Slow |
| **Cache** | ✅ Global | ✅ Per-user | ✅ Per-project |

---

## Episteme-Specific Workflows

### Development Workflow

```bash
# 1. Initial setup
git clone https://github.com/epicsagas/Episteme.git
cd Episteme
uv sync --all-extras  # Install with dev dependencies

# 2. Activate environment
source .venv/bin/activate

# 3. Run tests
uv run pytest

# 4. Format code
uv run black .
uv run ruff check .

# 5. Type check
uv run mypy scripts/ api/
```

### Adding New Features

```bash
# Install new dependency
uv add javalang

# Automatically updates:
# - pyproject.toml (dependencies list)
# - uv.lock (locked versions)

# Commit both files
git add pyproject.toml uv.lock
git commit -m "feat: add Java parser support"
```

### Production Deployment

```bash
# On production server
git clone https://github.com/epicsagas/Episteme.git
cd Episteme

# Install from lockfile (reproducible)
uv sync --frozen --no-dev

# No dev dependencies, exact versions from uv.lock
```

### CI/CD Integration

```yaml
# .github/workflows/test.yml
name: Test
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Install uv
        run: curl -LsSf https://astral.sh/uv/install.sh | sh
      
      - name: Install dependencies
        run: uv sync --frozen --all-extras
      
      - name: Run tests
        run: uv run pytest
      
      - name: Lint
        run: |
          uv run black --check .
          uv run ruff check .
```

---

## Troubleshooting

### Issue: "uv: command not found"

**Solution**: Restart terminal or manually add to PATH:

```bash
# Add to ~/.bashrc or ~/.zshrc
export PATH="$HOME/.cargo/bin:$PATH"
source ~/.bashrc
```

### Issue: "No Python interpreter found"

**Solution**: Install Python 3.11+:

```bash
# macOS (via Homebrew)
brew install python@3.11

# Ubuntu/Debian
sudo apt install python3.11

# Then specify version
uv sync --python 3.11
```

### Issue: "Lockfile is out of date"

**Solution**: Update lockfile:

```bash
uv lock --upgrade
uv sync
```

### Issue: "Package conflicts"

**Solution**: Use uv's resolver:

```bash
# uv automatically resolves conflicts
# If manual resolution needed:
uv add "package>=1.0,<2.0"
```

---

## Advanced Usage

### Using Specific Python Version

```bash
# Install with Python 3.12
uv sync --python 3.12

# Use system Python
uv sync --python python3.11

# Use specific path
uv sync --python /usr/local/bin/python3.11
```

### Offline Installation

```bash
# Download packages to cache
uv sync

# Later, install from cache (no network)
uv sync --offline
```

### Custom Index URLs

```bash
# Use private PyPI
uv add --index-url https://pypi.company.com/simple requests

# Multiple indexes
uv add --extra-index-url https://pypi.org/simple \
       --extra-index-url https://private.pypi.com/simple \
       my-private-package
```

### Editable Installs

```bash
# Install Episteme in editable mode
uv sync --editable

# Now changes to source code are immediately reflected
# No need to reinstall after each change
```

---

## Migration Guide

### From pip

```bash
# Old (pip)
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

# New (uv)
uv sync
source .venv/bin/activate
```

### From poetry

```bash
# Convert poetry project to uv
# 1. Generate requirements.txt from poetry
poetry export -f requirements.txt > requirements.txt

# 2. Create pyproject.toml (if using old poetry format)
# (Episteme already uses PEP 621 format)

# 3. Switch to uv
uv sync
```

### From conda

```bash
# Export conda environment
conda env export > environment.yml

# Convert to requirements.txt
# (manual conversion needed - conda has different package names)

# Use uv
uv sync
```

---

## Best Practices

### 1. Always Use Lockfile

```bash
# Development: flexible updates
uv sync

# Production: reproducible builds
uv sync --frozen
```

### 2. Commit Both Files

```bash
git add pyproject.toml uv.lock
git commit -m "chore: update dependencies"
```

### 3. Separate Dev Dependencies

```toml
[project.optional-dependencies]
dev = [
    "pytest>=7.4.0",
    "black>=23.0.0",
    "ruff>=0.1.0",
]
```

```bash
# Install without dev deps (production)
uv sync --no-dev

# Install with dev deps (development)
uv sync --all-extras
```

### 4. Pin Python Version

Create `.python-version`:
```
3.11
```

uv automatically uses this version.

### 5. Use Scripts

Define in `pyproject.toml`:
```toml
[project.scripts]
episteme-analyze = "scripts.detect_smells:main"
```

Run without activation:
```bash
uv run episteme-analyze mycode.py
```

---

## Performance Tips

### 1. Use Global Cache

uv automatically caches packages globally (`~/.cache/uv`).  
Multiple projects share the same cache = faster installs.

### 2. Parallel Downloads

uv downloads packages in parallel by default (no configuration needed).

### 3. Incremental Syncs

```bash
# Only install missing packages (fast)
uv sync

# Reinstall everything (slow)
uv sync --reinstall
```

---

## Resources

- **Official Docs**: https://github.com/astral-sh/uv
- **uv vs pip benchmark**: https://astral.sh/blog/uv-unified-python-packaging
- **PEP 621 (pyproject.toml)**: https://peps.python.org/pep-0621/
- **Episteme Issues**: https://github.com/epicsagas/Episteme/issues

---

## FAQ

**Q: Is uv stable for production?**  
A: Yes. Used by major companies (Anthropic, etc.). Version 1.0+ is production-ready.

**Q: Does uv replace pip completely?**  
A: Yes, for most use cases. It's a drop-in replacement with the same commands.

**Q: Can I use both uv and pip?**  
A: Yes, but not recommended. Stick to one tool to avoid conflicts.

**Q: What if uv is missing a feature?**  
A: Fall back to pip for that specific package, then return to uv.

**Q: How do I uninstall uv?**  
A: `rm -rf ~/.cargo/bin/uv ~/.cache/uv`

---

**Last Updated:** 2026-04-29  
**Episteme Version:** 0.0.5  
**uv Version:** 0.1.x