Commit 7e4b6c3
committed
feat: saar extract --index -- one-command OCI bootstrap (OPE-173)
The current setup path took 2+ hours of debugging (OPE-166). This makes
it one flag on a command the user already runs.
saar extract ./my-repo --index
Flow:
1. Check ~/.saar/config.yaml for OCI API key
2. If no key: show how to get one, exit gracefully
3. Detect git remote URL (SSH -> HTTPS conversion automatic)
4. POST /api/v1/repos -- add repo to OCI
5. POST /api/v1/repos/{id}/index -- trigger indexing with progress
6. Save repo_id to .saar/config.json for future MCP use
7. Extract always completes -- OCI failure is non-fatal
New module: saar/oci_client.py
- load/save ~/.saar/config.yaml (oci_api_key, oci_base_url)
- get_api_key() / get_base_url() with defaults
- detect_git_url(): SSH -> HTTPS conversion, graceful on failure
- detect_default_branch(): reads HEAD, falls back to 'main'
- add_repository() / poll_until_indexed(): clean HTTP wrappers
- save_repo_id() / load_repo_id(): .saar/config.json integration
- OCIAuthError / OCIAPIError: clean error hierarchy
saar/cli.py:
- --index flag on extract command
- _run_oci_indexing() helper: all OCI logic isolated, never breaks extract
Added tests/test_oci_client.py with 25 tests:
- Config read/write (round-trip, comments, corrupt file)
- Repo ID persistence (save/load, preserves existing fields)
- Git URL detection (SSH conversion, HTTPS passthrough, failure modes)
- Branch detection (success, failure fallback)
- CLI: no key shows guidance, OCI failure doesn't break extract,
no git remote shows guidance, happy path shows indexed count,
repo_id saved on success1 parent 72222f5 commit 7e4b6c3
6 files changed
Lines changed: 701 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
323 | 328 | | |
324 | 329 | | |
325 | 330 | | |
| |||
410 | 415 | | |
411 | 416 | | |
412 | 417 | | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
413 | 422 | | |
414 | 423 | | |
415 | 424 | | |
| |||
611 | 620 | | |
612 | 621 | | |
613 | 622 | | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
0 commit comments