@voria/cli 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +439 -0
  2. package/bin/voria +730 -0
  3. package/docs/ARCHITECTURE.md +419 -0
  4. package/docs/CHANGELOG.md +189 -0
  5. package/docs/CONTRIBUTING.md +447 -0
  6. package/docs/DESIGN_DECISIONS.md +380 -0
  7. package/docs/DEVELOPMENT.md +535 -0
  8. package/docs/EXAMPLES.md +434 -0
  9. package/docs/INSTALL.md +335 -0
  10. package/docs/IPC_PROTOCOL.md +310 -0
  11. package/docs/LLM_INTEGRATION.md +416 -0
  12. package/docs/MODULES.md +470 -0
  13. package/docs/PERFORMANCE.md +346 -0
  14. package/docs/PLUGINS.md +432 -0
  15. package/docs/QUICKSTART.md +184 -0
  16. package/docs/README.md +133 -0
  17. package/docs/ROADMAP.md +346 -0
  18. package/docs/SECURITY.md +334 -0
  19. package/docs/TROUBLESHOOTING.md +565 -0
  20. package/docs/USER_GUIDE.md +700 -0
  21. package/package.json +63 -0
  22. package/python/voria/__init__.py +8 -0
  23. package/python/voria/__pycache__/__init__.cpython-312.pyc +0 -0
  24. package/python/voria/__pycache__/engine.cpython-312.pyc +0 -0
  25. package/python/voria/core/__init__.py +1 -0
  26. package/python/voria/core/__pycache__/__init__.cpython-312.pyc +0 -0
  27. package/python/voria/core/__pycache__/setup.cpython-312.pyc +0 -0
  28. package/python/voria/core/agent/__init__.py +9 -0
  29. package/python/voria/core/agent/__pycache__/__init__.cpython-312.pyc +0 -0
  30. package/python/voria/core/agent/__pycache__/loop.cpython-312.pyc +0 -0
  31. package/python/voria/core/agent/loop.py +343 -0
  32. package/python/voria/core/executor/__init__.py +19 -0
  33. package/python/voria/core/executor/__pycache__/__init__.cpython-312.pyc +0 -0
  34. package/python/voria/core/executor/__pycache__/executor.cpython-312.pyc +0 -0
  35. package/python/voria/core/executor/executor.py +431 -0
  36. package/python/voria/core/github/__init__.py +33 -0
  37. package/python/voria/core/github/__pycache__/__init__.cpython-312.pyc +0 -0
  38. package/python/voria/core/github/__pycache__/client.cpython-312.pyc +0 -0
  39. package/python/voria/core/github/client.py +438 -0
  40. package/python/voria/core/llm/__init__.py +55 -0
  41. package/python/voria/core/llm/__pycache__/__init__.cpython-312.pyc +0 -0
  42. package/python/voria/core/llm/__pycache__/base.cpython-312.pyc +0 -0
  43. package/python/voria/core/llm/__pycache__/claude_provider.cpython-312.pyc +0 -0
  44. package/python/voria/core/llm/__pycache__/gemini_provider.cpython-312.pyc +0 -0
  45. package/python/voria/core/llm/__pycache__/modal_provider.cpython-312.pyc +0 -0
  46. package/python/voria/core/llm/__pycache__/model_discovery.cpython-312.pyc +0 -0
  47. package/python/voria/core/llm/__pycache__/openai_provider.cpython-312.pyc +0 -0
  48. package/python/voria/core/llm/base.py +152 -0
  49. package/python/voria/core/llm/claude_provider.py +188 -0
  50. package/python/voria/core/llm/gemini_provider.py +148 -0
  51. package/python/voria/core/llm/modal_provider.py +228 -0
  52. package/python/voria/core/llm/model_discovery.py +289 -0
  53. package/python/voria/core/llm/openai_provider.py +146 -0
  54. package/python/voria/core/patcher/__init__.py +9 -0
  55. package/python/voria/core/patcher/__pycache__/__init__.cpython-312.pyc +0 -0
  56. package/python/voria/core/patcher/__pycache__/patcher.cpython-312.pyc +0 -0
  57. package/python/voria/core/patcher/patcher.py +375 -0
  58. package/python/voria/core/planner/__init__.py +1 -0
  59. package/python/voria/core/setup.py +201 -0
  60. package/python/voria/core/token_manager/__init__.py +29 -0
  61. package/python/voria/core/token_manager/__pycache__/__init__.cpython-312.pyc +0 -0
  62. package/python/voria/core/token_manager/__pycache__/manager.cpython-312.pyc +0 -0
  63. package/python/voria/core/token_manager/manager.py +241 -0
  64. package/python/voria/engine.py +1185 -0
  65. package/python/voria/plugins/__init__.py +1 -0
  66. package/python/voria/plugins/python/__init__.py +1 -0
  67. package/python/voria/plugins/typescript/__init__.py +1 -0
@@ -0,0 +1,535 @@
1
+ # Development Guide
2
+
3
+ Complete guide for setting up a development environment and contributing to voria.
4
+
5
+ ## Quick Dev Setup
6
+
7
+ ```bash
8
+ # 1. Clone repo
9
+ git clone https://github.com/Srizdebnath/voria.git
10
+ cd voria
11
+
12
+ # 2. Set up Rust
13
+ rustup update
14
+
15
+ # 3. Build Rust
16
+ cd rust
17
+ cargo build
18
+ cargo test
19
+ cd ..
20
+
21
+ # 4. Set up Python
22
+ python3 -m venv venv
23
+ source venv/bin/activate
24
+
25
+ # 5. Install Python dev dependencies
26
+ cd python
27
+ pip install -e ".[dev]"
28
+ cd ..
29
+
30
+ # 6. Verify everything
31
+ ./target/debug/voria --version
32
+ python3 -m voria.engine < /dev/null
33
+ ```
34
+
35
+ ## Project Structure
36
+
37
+ ```
38
+ voria/
39
+ ├── rust/ # Rust CLI
40
+ │ ├── Cargo.toml # Rust dependencies
41
+ │ ├── src/
42
+ │ │ ├── main.rs # Entry point
43
+ │ │ ├── cli/mod.rs # Subcommands
44
+ │ │ ├── ipc/mod.rs # NDJSON protocol
45
+ │ │ ├── orchestrator/mod.rs # Workflow
46
+ │ │ ├── ui/mod.rs # Terminal UI
47
+ │ │ └── config/mod.rs # Config loading
48
+ │ └── target/ # Build output
49
+
50
+ ├── python/ # Python engine
51
+ │ ├── setup.py # Python package config
52
+ │ ├── voria/
53
+ │ │ ├── __init__.py
54
+ │ │ ├── engine.py # Main loop
55
+ │ │ ├── core/
56
+ │ │ │ ├── llm/ # LLM providers
57
+ │ │ │ ├── patcher/ # Patching logic
58
+ │ │ │ ├── executor/ # Test execution
59
+ │ │ │ ├── agent/ # Agent loop
60
+ │ │ │ ├── github/ # GitHub API
61
+ │ │ │ ├── token_manager/ # Cost tracking
62
+ │ │ │ └── setup.py # Configuration
63
+ │ │ └── plugins/ # Language plugins
64
+ │ └── tests/ # Python tests
65
+
66
+ ├── docs/ # Documentation ( New!)
67
+ │ ├── README.md
68
+ │ ├── QUICKSTART.md
69
+ │ ├── USER_GUIDE.md
70
+ │ ├── EXAMPLES.md
71
+ │ ├── ARCHITECTURE.md
72
+ │ ├── IPC_PROTOCOL.md
73
+ │ ├── DESIGN_DECISIONS.md
74
+ │ ├── MODULES.md
75
+ │ ├── DEVELOPMENT.md # This file
76
+ │ ├── CONTRIBUTING.md
77
+ │ ├── PLUGINS.md
78
+ │ ├── LLM_INTEGRATION.md
79
+ │ ├── PERFORMANCE.md
80
+ │ ├── SECURITY.md
81
+ │ ├── TROUBLESHOOTING.md
82
+ │ └── ROADMAP.md
83
+
84
+ └── test_*.py # Integration tests
85
+ ```
86
+
87
+ ## Development Workflow
88
+
89
+ ### Rust Development
90
+
91
+ **Build & Test:**
92
+ ```bash
93
+ cd rust
94
+ cargo build # Debug binary
95
+ cargo build --release # Optimized binary
96
+ cargo test # Run tests
97
+ cargo check # Quick type check
98
+ ```
99
+
100
+ **Code Quality:**
101
+ ```bash
102
+ cargo fmt # Format code
103
+ cargo clippy # Linting
104
+ cargo doc --open # Documentation
105
+ ```
106
+
107
+ **Debug Logging:**
108
+ ```bash
109
+ RUST_LOG=debug cargo run -- plan 1
110
+ RUST_LOG=voria=trace cargo run -- plan 1 # Module-specific
111
+ ```
112
+
113
+ ### Python Development
114
+
115
+ **Activate Environment:**
116
+ ```bash
117
+ source venv/bin/activate
118
+ cd python
119
+ ```
120
+
121
+ **Install & Test:**
122
+ ```bash
123
+ pip install -e . # Editable install (dev mode)
124
+ pip install -e ".[dev]" # With dev dependencies
125
+ pytest -v # Run tests with verbose
126
+ pytest --cov # Generate coverage report
127
+ ```
128
+
129
+ **Code Quality:**
130
+ ```bash
131
+ black . # Format code
132
+ black --check . # Check without formatting
133
+ mypy . # Type checking
134
+ pylint voria/ # Linting
135
+ ```
136
+
137
+ **Manual Testing:**
138
+ ```bash
139
+ # Test engine directly
140
+ python3 -m voria.engine
141
+
142
+ # Test specific module
143
+ python3 -c "from voria.core.llm import ModelDiscovery; print('Import OK')"
144
+
145
+ # Run single test
146
+ pytest tests/test_llm.py::test_discover_models -v
147
+ ```
148
+
149
+ ## 🔨 Making Changes
150
+
151
+ ### Adding a New Command
152
+
153
+ **Step 1**: Add Rust side (`rust/src/cli/mod.rs`)
154
+ ```rust
155
+ pub async fn handle_new_command(args: <Args>) -> Result<()> {
156
+ let request = json!({
157
+ "command": "new_command",
158
+ "args": args
159
+ });
160
+ // Send request to Python...
161
+ }
162
+ ```
163
+
164
+ **Step 2**: Add Python side (`python/voria/engine.py`)
165
+ ```python
166
+ async def on_new_command(data):
167
+ # Handle the command
168
+ result = await process_command(data)
169
+ return {"status": "success", "result": result}
170
+ ```
171
+
172
+ **Step 3**: Test
173
+ ```bash
174
+ ./target/debug/voria new-command --args
175
+ ```
176
+
177
+ ### Adding a New LLM Provider
178
+
179
+ **Step 1**: Create provider file (`python/voria/core/llm/kimi.py`)
180
+ ```python
181
+ from .base import BaseLLMProvider
182
+
183
+ class KimiProvider(BaseLLMProvider):
184
+ async def plan(self, issue_desc: str) -> str:
185
+ # Implementation
186
+ pass
187
+ ```
188
+
189
+ **Step 2**: Register in factory (`python/voria/core/llm/__init__.py`)
190
+ ```python
191
+ from .kimi import KimiProvider
192
+ LLMProviderFactory.register("kimi", KimiProvider)
193
+ ```
194
+
195
+ **Step 3**: Test
196
+ ```python
197
+ provider = LLMProviderFactory.create("kimi", api_key, "model")
198
+ result = await provider.plan("Test issue")
199
+ ```
200
+
201
+ ### Adding Plugin Support
202
+
203
+ **Step 1**: Create plugin (`python/voria/plugins/go/executor.py`)
204
+ ```python
205
+ class GoTestExecutor:
206
+ async def run(self, path: str) -> TestSuiteResult:
207
+ # Run go test ./...
208
+ pass
209
+ ```
210
+
211
+ **Step 2**: Register in detector (`python/voria/core/executor/executor.py`)
212
+ ```python
213
+ async def detect_framework(self):
214
+ if Path("go.mod").exists():
215
+ return "go"
216
+ ```
217
+
218
+ **Step 3**: Test
219
+ ```python
220
+ executor = TestExecutor("/go-repo")
221
+ framework = await executor.detect_framework() # Should be "go"
222
+ ```
223
+
224
+ ## Testing
225
+
226
+ ### Running Tests
227
+
228
+ ```bash
229
+ # All tests
230
+ pytest tests/ -v
231
+
232
+ # Specific test file
233
+ pytest tests/test_llm.py -v
234
+
235
+ # Specific test
236
+ pytest tests/test_llm.py::test_discover_models -v
237
+
238
+ # With coverage
239
+ pytest tests/ --cov=voria --cov-report=html
240
+
241
+ # Watch mode (needs pytest-watch)
242
+ ptw tests/
243
+ ```
244
+
245
+ ### Integration Tests
246
+
247
+ ```bash
248
+ # Full CLI test
249
+ python3 test_voria_cli.py
250
+
251
+ # Phase 2 integration test
252
+ python3 test_phase2_integration.py
253
+
254
+ # End-to-end
255
+ ./target/debug/voria plan 1
256
+ ```
257
+
258
+ ### Writing Tests
259
+
260
+ **Python test example:**
261
+ ```python
262
+ import pytest
263
+ from voria.core.llm import ModelDiscovery
264
+
265
+ @pytest.mark.asyncio
266
+ async def test_discover_openai_models():
267
+ """Test fetching OpenAI models"""
268
+ models = await ModelDiscovery._get_openai_fallback()
269
+ assert len(models) > 0
270
+ assert any("gpt-" in m.name for m in models)
271
+ ```
272
+
273
+ ## 🔧 Debugging Tips
274
+
275
+ ### Enable Detailed Logging
276
+
277
+ **Rust:**
278
+ ```bash
279
+ RUST_LOG=debug ./target/debug/voria -v plan 1
280
+ ```
281
+
282
+ **Python:**
283
+ ```bash
284
+ python3 -m voria.engine # Logs go to stderr automatically
285
+ ```
286
+
287
+ ### Inspect NDJSON Protocol
288
+
289
+ **See what Rust sends:**
290
+ ```bash
291
+ strace -e write ./target/debug/voria plan 1 2>&1 | grep '"command"'
292
+ ```
293
+
294
+ **See what Python receives/sends:**
295
+ ```bash
296
+ python3 -c '
297
+ import sys, json
298
+ for line in sys.stdin:
299
+ msg = json.loads(line)
300
+ print("Received:", json.dumps(msg, indent=2))
301
+ ' <<< '{"command":"plan","issue_id":1}'
302
+ ```
303
+
304
+ ### Test Python Engine Directly
305
+
306
+ ```bash
307
+ (
308
+ echo '{"command":"plan","issue_id":1}'
309
+ sleep 0.5
310
+ echo '{"command":"plan","issue_id":2}'
311
+ ) | python3 -m voria.engine
312
+ ```
313
+
314
+ ### Breakpoint Debugging
315
+
316
+ **Python:**
317
+ ```python
318
+ import pdb; pdb.set_trace() # Stop here
319
+ ```
320
+
321
+ **Rust:**
322
+ ```rust
323
+ dbg!(variable); // Print variable
324
+ ```
325
+
326
+ ## Running Specific Scenarios
327
+
328
+ ### Test LLM Discovery
329
+
330
+ ```bash
331
+ python3 << 'EOF'
332
+ import asyncio
333
+ from voria.core.llm import ModelDiscovery
334
+
335
+ async def test():
336
+ models = await ModelDiscovery.discover_all("openai", "sk-test")
337
+ for m in models:
338
+ print(f"{m.name}: {m.display_name}")
339
+
340
+ asyncio.run(test())
341
+ EOF
342
+ ```
343
+
344
+ ### Test Patching
345
+
346
+ ```bash
347
+ python3 << 'EOF'
348
+ import asyncio
349
+ import tempfile
350
+ from pathlib import Path
351
+ from voria.core.patcher import CodePatcher
352
+
353
+ async def test():
354
+ with tempfile.TemporaryDirectory() as tmpdir:
355
+ # Create test file
356
+ test_file = Path(tmpdir) / "test.py"
357
+ test_file.write_text("print('hello')")
358
+
359
+ # Apply patch
360
+ patcher = CodePatcher(tmpdir)
361
+ patch = """--- a/test.py
362
+ +++ b/test.py
363
+ @@ -1 +1 @@
364
+ -print('hello')
365
+ +print('world')
366
+ """
367
+ result = await patcher.apply_patch(patch)
368
+ print("Result:", result)
369
+ print("Content:", test_file.read_text())
370
+
371
+ asyncio.run(test())
372
+ EOF
373
+ ```
374
+
375
+ ### Test Agent Loop
376
+
377
+ ```bash
378
+ python3 << 'EOF'
379
+ import asyncio
380
+ from voria.core.agent import AgentLoop
381
+
382
+ async def test():
383
+ loop = AgentLoop("modal", "test-key", "/repo")
384
+ await loop.initialize("zai-org/GLM-5.1-FP8")
385
+ result = await loop.run(42, "Fix the bug")
386
+ print(result)
387
+
388
+ asyncio.run(test())
389
+ EOF
390
+ ```
391
+
392
+ ## Code Style Guidelines
393
+
394
+ ### Python
395
+
396
+ ```python
397
+ # Type hints on all functions
398
+ def process_data(value: str) -> Dict[str, Any]:
399
+ """Detailed docstring.
400
+
401
+ Args:
402
+ value: Description
403
+
404
+ Returns:
405
+ Description
406
+
407
+ Raises:
408
+ ValueError: When...
409
+ """
410
+ pass
411
+
412
+ # Use f-strings
413
+ message = f"Processing {value}"
414
+
415
+ # Use type hints in class
416
+ from typing import Optional
417
+
418
+ class MyClass:
419
+ value: Optional[str] = None
420
+ ```
421
+
422
+ ### Rust
423
+
424
+ ```rust
425
+ /// Document public APIs
426
+ ///
427
+ /// # Errors
428
+ /// Returns error if...
429
+ pub async fn process() -> Result<()> {
430
+ Ok(())
431
+ }
432
+
433
+ // Use meaningful variable names
434
+ let is_valid = check_validity();
435
+
436
+ // Comments for non-obvious logic
437
+ // This happens because of X (see issue #123)
438
+ ```
439
+
440
+ ## Committing Code
441
+
442
+ ### Conventional Commits
443
+
444
+ Format:
445
+ ```
446
+ <type>(<scope>): <subject>
447
+
448
+ <body>
449
+
450
+ Fixes #<issue>
451
+ ```
452
+
453
+ Types:
454
+ - `feat` - New feature
455
+ - `fix` - Bug fix
456
+ - `docs` - Documentation
457
+ - `refactor` - Code restructuring
458
+ - `perf` - Performance improvement
459
+ - `test` - Test additions
460
+ - `chore` - Build, dependencies
461
+
462
+ Examples:
463
+ ```
464
+ feat(llm): add Kimi provider support
465
+ fix(patcher): handle multi-file diffs correctly
466
+ docs: update LLM integration guide
467
+ refactor(agent): simplify iteration logic
468
+ perf: optimize token counting
469
+ test: add test cases for edge cases
470
+ ```
471
+
472
+ ### Pre-commit Checklist
473
+
474
+ - [ ] Code passes `cargo fmt` and `black`
475
+ - [ ] Tests pass locally
476
+ - [ ] No new warnings from `cargo clippy`
477
+ - [ ] Python types check with `mypy`
478
+ - [ ] Updated docs if needed
479
+ - [ ] Commit message follows conventions
480
+
481
+ ## Release Process
482
+
483
+ ### Version Bumping
484
+
485
+ ```bash
486
+ # Update version in Cargo.toml and setup.py
487
+ # Tag release
488
+ git tag v0.2.0
489
+ git push origin v0.2.0
490
+ ```
491
+
492
+ ###Build Release Binary
493
+
494
+ ```bash
495
+ cd rust
496
+ cargo build --release
497
+ # Binary at: target/release/voria
498
+ ```
499
+
500
+ ## Common Issues
501
+
502
+ ### "Cargo not found"
503
+ ```bash
504
+ curl --proto '=https' --tlsvv0.0.1 -sSf https://sh.rustup.rs | sh
505
+ source $HOME/.cargo/env
506
+ ```
507
+
508
+ ### "Python import error"
509
+ ```bash
510
+ # Reinstall
511
+ cd python
512
+ pip uninstall voria
513
+ pip install -e .
514
+ ```
515
+
516
+ ### "Test failures"
517
+ ```bash
518
+ # Run with verbose traceback
519
+ pytest tests/ -v -s --tb=long
520
+ ```
521
+
522
+ ## Contributing Workflow
523
+
524
+ 1. Fork repository
525
+ 2. Create feature branch: `git checkout -b feature/my-feature`
526
+ 3. Make changes and commit with conventional commits
527
+ 4. Run tests: `pytest && cargo test`
528
+ 5. Push: `git push origin feature/my-feature`
529
+ 6. Create Pull Request
530
+ 7. Address review feedback
531
+ 8. Merge when approved
532
+
533
+ ---
534
+
535
+ **Need Help?** Check [TROUBLESHOOTING.md](TROUBLESHOOTING.md) or ask in discussions.