@sudocode-ai/cli 0.1.18 → 0.1.19

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 (59) hide show
  1. package/README.md +1299 -0
  2. package/dist/auth/claude.d.ts +19 -0
  3. package/dist/auth/claude.d.ts.map +1 -0
  4. package/dist/auth/claude.js +179 -0
  5. package/dist/auth/claude.js.map +1 -0
  6. package/dist/auth/clear.d.ts +17 -0
  7. package/dist/auth/clear.d.ts.map +1 -0
  8. package/dist/auth/clear.js +68 -0
  9. package/dist/auth/clear.js.map +1 -0
  10. package/dist/auth/credentials.d.ts +93 -0
  11. package/dist/auth/credentials.d.ts.map +1 -0
  12. package/dist/auth/credentials.js +255 -0
  13. package/dist/auth/credentials.js.map +1 -0
  14. package/dist/auth/index.d.ts +13 -0
  15. package/dist/auth/index.d.ts.map +1 -0
  16. package/dist/auth/index.js +19 -0
  17. package/dist/auth/index.js.map +1 -0
  18. package/dist/auth/status.d.ts +17 -0
  19. package/dist/auth/status.d.ts.map +1 -0
  20. package/dist/auth/status.js +132 -0
  21. package/dist/auth/status.js.map +1 -0
  22. package/dist/cli/auth-commands.d.ts +34 -0
  23. package/dist/cli/auth-commands.d.ts.map +1 -0
  24. package/dist/cli/auth-commands.js +28 -0
  25. package/dist/cli/auth-commands.js.map +1 -0
  26. package/dist/cli/remote-commands.d.ts +59 -0
  27. package/dist/cli/remote-commands.d.ts.map +1 -0
  28. package/dist/cli/remote-commands.js +391 -0
  29. package/dist/cli/remote-commands.js.map +1 -0
  30. package/dist/cli/update-commands.d.ts.map +1 -1
  31. package/dist/cli/update-commands.js +56 -0
  32. package/dist/cli/update-commands.js.map +1 -1
  33. package/dist/cli.js +131 -1
  34. package/dist/cli.js.map +1 -1
  35. package/dist/remote/claude-auth.d.ts +65 -0
  36. package/dist/remote/claude-auth.d.ts.map +1 -0
  37. package/dist/remote/claude-auth.js +100 -0
  38. package/dist/remote/claude-auth.js.map +1 -0
  39. package/dist/remote/config.d.ts +83 -0
  40. package/dist/remote/config.d.ts.map +1 -0
  41. package/dist/remote/config.js +266 -0
  42. package/dist/remote/config.js.map +1 -0
  43. package/dist/remote/errors.d.ts +18 -0
  44. package/dist/remote/errors.d.ts.map +1 -0
  45. package/dist/remote/errors.js +27 -0
  46. package/dist/remote/errors.js.map +1 -0
  47. package/dist/remote/git-context.d.ts +51 -0
  48. package/dist/remote/git-context.d.ts.map +1 -0
  49. package/dist/remote/git-context.js +107 -0
  50. package/dist/remote/git-context.js.map +1 -0
  51. package/dist/remote/spawn-service.d.ts +86 -0
  52. package/dist/remote/spawn-service.d.ts.map +1 -0
  53. package/dist/remote/spawn-service.js +248 -0
  54. package/dist/remote/spawn-service.js.map +1 -0
  55. package/dist/remote/types.d.ts +82 -0
  56. package/dist/remote/types.d.ts.map +1 -0
  57. package/dist/remote/types.js +5 -0
  58. package/dist/remote/types.js.map +1 -0
  59. package/package.json +3 -2
package/README.md CHANGED
@@ -30,6 +30,137 @@ Or install the meta-package that includes the CLI:
30
30
  npm install -g sudocode
31
31
  ```
32
32
 
33
+ ## Authentication
34
+
35
+ ### Overview
36
+
37
+ Sudocode supports multiple AI service credentials for remote deployment. Configure at least one service to enable Codespace deployment.
38
+
39
+ ### Supported Services
40
+
41
+ 1. **Claude Code** (Available now)
42
+ 2. **LLM Key** (OpenAI/LiteLLM) - Coming soon
43
+ 3. **LiteLLM** (Custom LLM configs) - Coming soon
44
+
45
+ ### Setup Claude Code
46
+
47
+ #### Interactive Setup (Recommended)
48
+
49
+ Run the interactive authentication flow:
50
+
51
+ ```bash
52
+ sudocode auth claude
53
+ ```
54
+
55
+ This will:
56
+ 1. Check for Claude CLI installation
57
+ 2. Launch OAuth flow in your browser
58
+ 3. Store the token securely
59
+ 4. Verify configuration
60
+
61
+ #### Non-Interactive Setup
62
+
63
+ If you already have a token:
64
+
65
+ ```bash
66
+ sudocode auth claude --token sk-ant-api03-xxxxx
67
+ ```
68
+
69
+ ### Check Authentication Status
70
+
71
+ View all configured credentials:
72
+
73
+ ```bash
74
+ sudocode auth status
75
+ ```
76
+
77
+ Output:
78
+ ```
79
+ Authentication Status:
80
+
81
+ Claude Code: ✓ Configured
82
+ Token: sk-ant-api03-***************************xxx
83
+
84
+ LLM Key: ✗ Not configured
85
+ Run: sudocode auth llm --key <key> (coming soon)
86
+
87
+ LiteLLM: ✗ Not configured
88
+ Run: sudocode auth litellm (coming soon)
89
+
90
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
91
+ Configured: 1/3 services
92
+ Storage: ~/.config/sudocode/user_credentials.json
93
+
94
+ ✓ Ready for remote deployment
95
+ ```
96
+
97
+ ### Clear Credentials
98
+
99
+ Remove all stored credentials:
100
+
101
+ ```bash
102
+ sudocode auth clear
103
+ ```
104
+
105
+ Or skip confirmation:
106
+
107
+ ```bash
108
+ sudocode auth clear --force
109
+ ```
110
+
111
+ ### How It Works
112
+
113
+ 1. Configure one or more services locally
114
+ 2. Credentials stored in `~/.config/sudocode/user_credentials.json` (600 permissions)
115
+ 3. When deploying to Codespace, all credentials are passed to the deployment system
116
+ 4. AI services are configured in the remote environment
117
+ 5. Sudocode server can use any configured service for executions
118
+
119
+ ### Security
120
+
121
+ - Credentials stored in `~/.config/sudocode/` with restrictive permissions (600)
122
+ - File is never committed to git (user-level config)
123
+ - Tokens are masked in command output
124
+ - Atomic file writes prevent corruption
125
+
126
+ ### Troubleshooting
127
+
128
+ #### Claude CLI Not Found
129
+
130
+ If you see "claude CLI not found":
131
+
132
+ ```bash
133
+ npm install -g @anthropic-ai/claude-cli
134
+ ```
135
+
136
+ #### Invalid Token Format
137
+
138
+ Tokens must:
139
+ - Start with `sk-ant-`
140
+ - Be at least 20 characters long
141
+ - Contain only alphanumeric characters, dashes, and underscores
142
+
143
+ #### Permission Errors
144
+
145
+ If you get permission errors:
146
+
147
+ ```bash
148
+ # Check permissions
149
+ ls -la ~/.config/sudocode/user_credentials.json
150
+
151
+ # Fix permissions
152
+ chmod 600 ~/.config/sudocode/user_credentials.json
153
+ ```
154
+
155
+ #### File Corrupted
156
+
157
+ If credentials file is corrupted, clear and reconfigure:
158
+
159
+ ```bash
160
+ sudocode auth clear --force
161
+ sudocode auth claude
162
+ ```
163
+
33
164
  ## Quick Start
34
165
 
35
166
  ```bash
@@ -278,6 +409,1174 @@ sudocode import [options]
278
409
  --json Output in JSON format
279
410
  ```
280
411
 
412
+ ## Remote Deployment
413
+
414
+ ### Overview
415
+
416
+ Sudocode supports deploying your project to remote development environments for AI-assisted development. Currently supports GitHub Codespaces, with additional providers planned for future releases.
417
+
418
+ **What is Remote Deployment?**
419
+
420
+ Remote deployment creates an isolated cloud environment where:
421
+ - Your project code is cloned from git
422
+ - Sudocode server runs automatically
423
+ - AI agents can execute tasks remotely
424
+ - Changes are committed back to git branches
425
+ - Multiple deployments can run in parallel
426
+
427
+ **Use Cases:**
428
+ - Run long-running AI tasks without keeping your laptop running
429
+ - Enable team members to review AI execution progress
430
+ - Execute tasks in a clean, reproducible environment
431
+ - Scale AI assistance across multiple issues simultaneously
432
+
433
+ **Supported Providers:**
434
+ - **GitHub Codespaces** - Fully supported (requires GitHub CLI)
435
+ - **Coder** - Coming soon
436
+
437
+ ### Prerequisites
438
+
439
+ Before deploying to remote environments, ensure you have:
440
+
441
+ 1. **GitHub CLI** - Required for Codespaces deployment
442
+ ```bash
443
+ # macOS
444
+ brew install gh
445
+
446
+ # Windows
447
+ winget install GitHub.cli
448
+
449
+ # Linux
450
+ sudo apt install gh # Debian/Ubuntu
451
+ ```
452
+
453
+ 2. **Git Repository** - Your project must be:
454
+ - Committed to a git repository
455
+ - Pushed to GitHub
456
+ - You have write access to the repository
457
+
458
+ 3. **Claude Authentication** - Configure at least one AI service
459
+ ```bash
460
+ sudocode auth claude
461
+ ```
462
+ See the [Authentication](#authentication) section for details.
463
+
464
+ 4. **GitHub Authentication** - Login to GitHub CLI
465
+ ```bash
466
+ gh auth login
467
+ ```
468
+
469
+ ### Quick Start
470
+
471
+ Deploy your current project to a Codespace:
472
+
473
+ ```bash
474
+ # From your project directory
475
+ cd /path/to/your/project
476
+ sudocode init # If not already initialized
477
+
478
+ # Authenticate with Claude
479
+ sudocode auth claude
480
+
481
+ # Deploy to Codespaces
482
+ sudocode remote codespaces spawn
483
+ ```
484
+
485
+ The deployment process will:
486
+ 1. Detect your git repository and branch
487
+ 2. Create a new GitHub Codespace
488
+ 3. Clone your code and install dependencies
489
+ 4. Start the sudocode server
490
+ 5. Configure AI credentials
491
+ 6. Print access URLs
492
+
493
+ **Output:**
494
+ ```
495
+ ✓ Created Codespace: sudocode-myproject-ab12cd
496
+ ✓ Installing dependencies...
497
+ ✓ Starting sudocode server...
498
+ ✓ Deployment complete
499
+
500
+ URLs:
501
+ Workspace: https://myorg-myproject-ab12cd.github.dev
502
+ Sudocode: https://myorg-myproject-ab12cd-3000.app.github.dev
503
+ SSH: gh cs ssh -c sudocode-myproject-ab12cd
504
+ ```
505
+
506
+ ### Command Reference
507
+
508
+ All remote deployment commands follow the pattern:
509
+
510
+ ```bash
511
+ sudocode remote <provider> <command> [options]
512
+ ```
513
+
514
+ Where `<provider>` is currently `codespaces` (with `coder` coming soon).
515
+
516
+ #### Spawn Deployment
517
+
518
+ Create a new remote deployment from your current project.
519
+
520
+ ```bash
521
+ sudocode remote codespaces spawn [options]
522
+ ```
523
+
524
+ **Options:**
525
+ - `--repo <owner/repo>` - Override repository (default: auto-detected from git remote)
526
+ - `--branch <name>` - Override branch (default: current branch or from config)
527
+ - `--port <number>` - Server port (default: 3000 or from config)
528
+ - `--machine <type>` - Machine type (default: "basicLinux32gb" or from config)
529
+ - `--idle-timeout <minutes>` - Idle timeout in minutes (default: 4320 or from config)
530
+ - `--keep-alive <hours>` - Keep-alive duration in hours (default: 72 or from config)
531
+ - `--retention <days>` - Retention period in days (default: 14 or from config)
532
+
533
+ **Examples:**
534
+
535
+ ```bash
536
+ # Deploy with defaults
537
+ sudocode remote codespaces spawn
538
+
539
+ # Deploy specific branch
540
+ sudocode remote codespaces spawn --branch feature/new-auth
541
+
542
+ # Deploy with custom port
543
+ sudocode remote codespaces spawn --port 8080
544
+
545
+ # Deploy with larger machine
546
+ sudocode remote codespaces spawn --machine "premiumLinux"
547
+
548
+ # Deploy with shorter timeout for quick tasks
549
+ sudocode remote codespaces spawn --idle-timeout 30 --keep-alive 2
550
+
551
+ # Deploy different repository
552
+ sudocode remote codespaces spawn --repo myorg/other-project --branch main
553
+
554
+ # Deploy with all custom options
555
+ sudocode remote codespaces spawn \
556
+ --branch develop \
557
+ --port 5000 \
558
+ --machine "standardLinux32gb" \
559
+ --idle-timeout 1440 \
560
+ --keep-alive 48 \
561
+ --retention 7
562
+ ```
563
+
564
+ **Auto-Detection:**
565
+ - Repository is detected from git remote `origin`
566
+ - Branch is detected from current git HEAD
567
+ - Configuration defaults from `.sudocode/spawn-config.json` are applied
568
+ - If repository has uncommitted changes, you'll be prompted to commit or stash them
569
+
570
+ #### List Deployments
571
+
572
+ List all active deployments for the specified provider.
573
+
574
+ ```bash
575
+ sudocode remote <provider> list
576
+ ```
577
+
578
+ **Examples:**
579
+
580
+ ```bash
581
+ # List Codespaces deployments
582
+ sudocode remote codespaces list
583
+
584
+ # JSON output
585
+ sudocode remote codespaces list --json
586
+ ```
587
+
588
+ **Output:**
589
+ ```
590
+ Active Deployments (codespaces):
591
+
592
+ ┌─────────────────────────┬──────────────────┬─────────────┬──────────┐
593
+ │ ID │ Repository │ Branch │ Status │
594
+ ├─────────────────────────┼──────────────────┼─────────────┼──────────┤
595
+ │ codespace-ab12cd │ myorg/myproject │ main │ running │
596
+ │ codespace-xy98zf │ myorg/myproject │ feature/new │ running │
597
+ │ codespace-mn34kl │ myorg/other │ develop │ starting │
598
+ └─────────────────────────┴──────────────────┴─────────────┴──────────┘
599
+
600
+ To view details: sudocode remote codespaces status <id>
601
+ To stop a deployment: sudocode remote codespaces stop <id>
602
+ ```
603
+
604
+ **Empty State:**
605
+ ```
606
+ No active deployments found for codespaces.
607
+
608
+ Spawn with: sudocode remote codespaces spawn
609
+ ```
610
+
611
+ **JSON Output:**
612
+ ```bash
613
+ sudocode remote codespaces list --json
614
+ ```
615
+
616
+ ```json
617
+ [
618
+ {
619
+ "id": "codespace-ab12cd",
620
+ "name": "deployment-ab12cd",
621
+ "provider": "codespaces",
622
+ "status": "running",
623
+ "git": {
624
+ "owner": "myorg",
625
+ "repo": "myproject",
626
+ "branch": "main"
627
+ },
628
+ "urls": {
629
+ "workspace": "https://myorg-myproject-ab12cd.github.dev",
630
+ "sudocode": "https://myorg-myproject-ab12cd-3000.app.github.dev",
631
+ "ssh": "gh cs ssh -c codespace-ab12cd"
632
+ },
633
+ "createdAt": "2026-01-14T10:30:00Z",
634
+ "keepAliveHours": 72,
635
+ "idleTimeout": 4320
636
+ }
637
+ ]
638
+ ```
639
+
640
+ #### Deployment Status
641
+
642
+ Get detailed information about a specific deployment.
643
+
644
+ ```bash
645
+ sudocode remote <provider> status <id>
646
+ ```
647
+
648
+ **Arguments:**
649
+ - `<id>` - Deployment ID (from list output)
650
+
651
+ **Examples:**
652
+
653
+ ```bash
654
+ # Get status
655
+ sudocode remote codespaces status codespace-ab12cd
656
+
657
+ # JSON output
658
+ sudocode remote codespaces status codespace-ab12cd --json
659
+ ```
660
+
661
+ **Output:**
662
+ ```
663
+ Deployment: codespace-ab12cd
664
+ Provider: codespaces
665
+
666
+ Status: running
667
+ Repository: myorg/myproject
668
+ Branch: main
669
+ Created: 2026-01-14T10:30:00Z
670
+
671
+ URLs:
672
+ Workspace: https://myorg-myproject-ab12cd.github.dev
673
+ Sudocode: https://myorg-myproject-ab12cd-3000.app.github.dev
674
+ SSH: gh cs ssh -c codespace-ab12cd
675
+
676
+ Configuration:
677
+ Port: 3000
678
+ Machine: basicLinux32gb
679
+ Keep-alive: 72 hours
680
+ Idle timeout: 4320 minutes
681
+ Retention: 14 days
682
+ ```
683
+
684
+ **Status Values:**
685
+ - `running` - Deployment is active and ready
686
+ - `starting` - Deployment is being provisioned
687
+ - `stopped` - Deployment has been stopped
688
+ - `stopping` - Deployment is shutting down
689
+ - `failed` - Deployment failed to start
690
+
691
+ **Error Handling:**
692
+
693
+ If deployment is not found:
694
+ ```
695
+ ✗ Deployment not found: codespace-invalid
696
+
697
+ List deployments with: sudocode remote codespaces list
698
+ ```
699
+
700
+ **JSON Output:**
701
+ ```bash
702
+ sudocode remote codespaces status codespace-ab12cd --json
703
+ ```
704
+
705
+ ```json
706
+ {
707
+ "id": "codespace-ab12cd",
708
+ "name": "deployment-ab12cd",
709
+ "provider": "codespaces",
710
+ "status": "running",
711
+ "git": {
712
+ "owner": "myorg",
713
+ "repo": "myproject",
714
+ "branch": "main"
715
+ },
716
+ "urls": {
717
+ "workspace": "https://myorg-myproject-ab12cd.github.dev",
718
+ "sudocode": "https://myorg-myproject-ab12cd-3000.app.github.dev",
719
+ "ssh": "gh cs ssh -c codespace-ab12cd"
720
+ },
721
+ "createdAt": "2026-01-14T10:30:00Z",
722
+ "keepAliveHours": 72,
723
+ "idleTimeout": 4320
724
+ }
725
+ ```
726
+
727
+ #### Stop Deployment
728
+
729
+ Stop and delete a running deployment.
730
+
731
+ ```bash
732
+ sudocode remote <provider> stop <id> [options]
733
+ ```
734
+
735
+ **Arguments:**
736
+ - `<id>` - Deployment ID (from list output)
737
+
738
+ **Options:**
739
+ - `-f, --force` - Skip confirmation prompt
740
+
741
+ **Examples:**
742
+
743
+ ```bash
744
+ # With confirmation prompt
745
+ sudocode remote codespaces stop codespace-ab12cd
746
+
747
+ # Skip confirmation
748
+ sudocode remote codespaces stop codespace-ab12cd --force
749
+
750
+ # JSON output
751
+ sudocode remote codespaces stop codespace-ab12cd --force --json
752
+ ```
753
+
754
+ **Confirmation Prompt:**
755
+ ```
756
+ ⚠ Stop deployment codespace-ab12cd?
757
+ This will delete the codespace and all uncommitted changes.
758
+
759
+ Continue? (y/N):
760
+ ```
761
+
762
+ **Output:**
763
+ ```
764
+ Stopping deployment...
765
+
766
+ ✓ Deployment stopped: codespace-ab12cd
767
+ ```
768
+
769
+ **JSON Output:**
770
+ ```json
771
+ {
772
+ "success": true,
773
+ "id": "codespace-ab12cd"
774
+ }
775
+ ```
776
+
777
+ **Warning:** Stopping a deployment:
778
+ - Deletes the Codespace immediately
779
+ - Loses all uncommitted changes in the Codespace
780
+ - Cannot be undone
781
+ - Committed changes on git branches are preserved
782
+
783
+ **Error Handling:**
784
+
785
+ If deployment is not found:
786
+ ```
787
+ ✗ Deployment not found: codespace-invalid
788
+
789
+ List deployments with: sudocode remote codespaces list
790
+ ```
791
+
792
+ #### Configuration Management
793
+
794
+ Manage deployment configuration for a provider.
795
+
796
+ ```bash
797
+ sudocode remote <provider> config [options]
798
+ ```
799
+
800
+ **Options:**
801
+ - `--port <number>` - Set server port (1024-65535)
802
+ - `--idle-timeout <minutes>` - Set idle timeout in minutes (min: 1)
803
+ - `--keep-alive <hours>` - Set keep-alive duration in hours (min: 1)
804
+ - `--retention <days>` - Set retention period in days (min: 1)
805
+ - `--machine <type>` - Set machine type/size
806
+ - `--reset` - Reset to default configuration (cannot be combined with other options)
807
+
808
+ **Examples:**
809
+
810
+ ```bash
811
+ # View current configuration
812
+ sudocode remote codespaces config
813
+
814
+ # Update individual values
815
+ sudocode remote codespaces config --port 8080
816
+ sudocode remote codespaces config --idle-timeout 60
817
+ sudocode remote codespaces config --keep-alive 24
818
+
819
+ # Update multiple values at once
820
+ sudocode remote codespaces config \
821
+ --port 8080 \
822
+ --idle-timeout 60 \
823
+ --keep-alive 24 \
824
+ --machine "premiumLinux"
825
+
826
+ # Reset to defaults
827
+ sudocode remote codespaces config --reset
828
+
829
+ # JSON output
830
+ sudocode remote codespaces config --json
831
+ ```
832
+
833
+ **View Configuration Output:**
834
+ ```json
835
+ {
836
+ "provider": "codespaces",
837
+ "port": 3000,
838
+ "idleTimeout": 4320,
839
+ "keepAliveHours": 72,
840
+ "machine": "basicLinux32gb",
841
+ "retentionPeriod": 14
842
+ }
843
+ ```
844
+
845
+ **Update Output:**
846
+ ```
847
+ ✓ Spawn configuration updated for codespaces
848
+ Port: 8080
849
+ Idle timeout: 60 minutes
850
+ Keep-alive: 24 hours
851
+ Machine: premiumLinux
852
+
853
+ Updated: .sudocode/spawn-config.json
854
+ ```
855
+
856
+ **Reset Output:**
857
+ ```
858
+ ✓ Spawn configuration reset to defaults for codespaces
859
+ {
860
+ "provider": "codespaces",
861
+ "port": 3000,
862
+ "idleTimeout": 4320,
863
+ "keepAliveHours": 72,
864
+ "machine": "basicLinux32gb",
865
+ "retentionPeriod": 14
866
+ }
867
+
868
+ Updated: .sudocode/spawn-config.json
869
+ ```
870
+
871
+ **Configuration File Location:**
872
+ - File: `.sudocode/spawn-config.json`
873
+ - Git tracked (shared across team)
874
+ - Created automatically with defaults on first use
875
+
876
+ **Validation Rules:**
877
+ - Port: 1024-65535 (non-privileged ports only)
878
+ - Idle Timeout: Minimum 1 minute
879
+ - Keep-Alive: Minimum 1 hour
880
+ - Retention Period: Minimum 1 day
881
+ - Machine: Non-empty string
882
+
883
+ **Error Examples:**
884
+
885
+ Invalid port:
886
+ ```
887
+ ✗ Port must be between 1024 and 65535
888
+ ```
889
+
890
+ Cannot combine --reset:
891
+ ```
892
+ Error: Cannot combine --reset with other options
893
+ ```
894
+
895
+ Unknown provider:
896
+ ```
897
+ ✗ Unknown provider 'azure'
898
+ Supported providers: codespaces, coder
899
+ ```
900
+
901
+ ### Common Workflows
902
+
903
+ #### Quick Task Deployment
904
+
905
+ For short-lived AI tasks (e.g., bug fixes, small features):
906
+
907
+ ```bash
908
+ # Configure aggressive cleanup
909
+ sudocode remote codespaces config \
910
+ --idle-timeout 30 \
911
+ --keep-alive 2 \
912
+ --retention 1
913
+
914
+ # Deploy and run task
915
+ sudocode remote codespaces spawn --branch feature/quick-fix
916
+
917
+ # List deployments
918
+ sudocode remote codespaces list
919
+
920
+ # Stop when done
921
+ sudocode remote codespaces stop <id> --force
922
+ ```
923
+
924
+ #### Long-Running Project Deployment
925
+
926
+ For extended AI assistance sessions or demos:
927
+
928
+ ```bash
929
+ # Configure longer retention
930
+ sudocode remote codespaces config \
931
+ --idle-timeout 1440 \
932
+ --keep-alive 168 \
933
+ --retention 30 \
934
+ --machine "premiumLinux"
935
+
936
+ # Deploy
937
+ sudocode remote codespaces spawn --branch main
938
+
939
+ # Check status
940
+ sudocode remote codespaces status <id>
941
+ ```
942
+
943
+ #### Multi-Issue Parallel Execution
944
+
945
+ Deploy multiple branches simultaneously:
946
+
947
+ ```bash
948
+ # Deploy multiple branches for different issues
949
+ sudocode remote codespaces spawn --branch feature/auth-system
950
+ sudocode remote codespaces spawn --branch feature/payment-flow
951
+ sudocode remote codespaces spawn --branch bugfix/memory-leak
952
+
953
+ # Monitor all deployments
954
+ sudocode remote codespaces list
955
+
956
+ # Check individual progress
957
+ sudocode remote codespaces status <id-1>
958
+ sudocode remote codespaces status <id-2>
959
+ sudocode remote codespaces status <id-3>
960
+
961
+ # Stop completed ones
962
+ sudocode remote codespaces stop <id-1> --force
963
+ ```
964
+
965
+ #### Team Collaboration
966
+
967
+ Share deployment URLs with team members:
968
+
969
+ ```bash
970
+ # Deploy with team-friendly configuration
971
+ sudocode remote codespaces config --machine "basicLinux32gb"
972
+
973
+ # Deploy
974
+ sudocode remote codespaces spawn
975
+
976
+ # Share URLs from output
977
+ # Team members can access:
978
+ # - Workspace URL for viewing code in browser
979
+ # - Sudocode URL for monitoring AI execution in UI
980
+ # - SSH command for terminal access
981
+ ```
982
+
983
+ #### Configuration for Different Use Cases
984
+
985
+ Development environment (quick iterations):
986
+ ```bash
987
+ sudocode remote codespaces config \
988
+ --idle-timeout 30 \
989
+ --keep-alive 4 \
990
+ --retention 1
991
+ ```
992
+
993
+ Production/long-running environment:
994
+ ```bash
995
+ sudocode remote codespaces config \
996
+ --idle-timeout 1440 \
997
+ --keep-alive 168 \
998
+ --retention 30 \
999
+ --machine "premiumLinux"
1000
+ ```
1001
+
1002
+ Cost optimization (minimal resources):
1003
+ ```bash
1004
+ sudocode remote codespaces config \
1005
+ --idle-timeout 15 \
1006
+ --keep-alive 1 \
1007
+ --retention 1 \
1008
+ --machine "basicLinux32gb"
1009
+ ```
1010
+
1011
+ ### How It Works
1012
+
1013
+ #### Deployment Lifecycle
1014
+
1015
+ 1. **Preparation**
1016
+ - Detect git repository and current branch
1017
+ - Load configuration from `.sudocode/deploy-config.json`
1018
+ - Validate prerequisites (gh CLI, git remote, auth)
1019
+ - Apply command-line option overrides
1020
+
1021
+ 2. **Provisioning**
1022
+ - Create GitHub Codespace via `gh codespace create`
1023
+ - Apply machine type, timeout, and retention settings
1024
+ - Wait for Codespace to become available
1025
+
1026
+ 3. **Initialization**
1027
+ - Clone repository and checkout specified branch
1028
+ - Install dependencies (`npm install`)
1029
+ - Build sudocode packages
1030
+ - Transfer user credentials securely
1031
+
1032
+ 4. **Server Startup**
1033
+ - Start sudocode server on configured port
1034
+ - Configure AI services from transferred credentials
1035
+ - Expose ports for web access
1036
+ - Register URLs
1037
+
1038
+ 5. **Ready**
1039
+ - Print access URLs
1040
+ - Codespace is ready for AI execution
1041
+ - Server accepts API requests
1042
+ - Frontend UI is accessible
1043
+
1044
+ #### Credential Transfer
1045
+
1046
+ User credentials (configured via `sudocode auth`) are securely transferred:
1047
+
1048
+ 1. Credentials read from `~/.config/sudocode/user_credentials.json` on local machine
1049
+ 2. Transferred to Codespace using secure GitHub APIs
1050
+ 3. Written to `~/.config/sudocode/user_credentials.json` in Codespace
1051
+ 4. File permissions set to 600 (owner read/write only)
1052
+ 5. Used by sudocode server for AI service authentication
1053
+
1054
+ **Security Notes:**
1055
+ - Credentials are never committed to git
1056
+ - Transfer uses GitHub's secure Codespace APIs
1057
+ - File permissions prevent unauthorized access
1058
+ - Credentials are isolated per Codespace
1059
+
1060
+ #### Auto-Cleanup
1061
+
1062
+ Codespaces are automatically cleaned up based on configuration:
1063
+
1064
+ - **Idle Timeout**: Codespace stops after configured idle period (default: 72 hours)
1065
+ - **Retention Period**: Stopped Codespace is deleted after retention period (default: 14 days)
1066
+ - **Keep-Alive**: Active connections reset idle timer
1067
+
1068
+ Manual cleanup:
1069
+ ```bash
1070
+ sudocode remote codespaces stop <id>
1071
+ ```
1072
+
1073
+ ### Usage Examples
1074
+
1075
+ #### Example 1: Deploy Current Branch
1076
+
1077
+ ```bash
1078
+ # Working on feature branch
1079
+ git checkout feature/user-auth
1080
+ git add .
1081
+ git commit -m "WIP: implementing OAuth"
1082
+ git push origin feature/user-auth
1083
+
1084
+ # Deploy this branch
1085
+ sudocode remote codespaces spawn
1086
+ ```
1087
+
1088
+ **Output:**
1089
+ ```
1090
+ ✓ Detected repository: myorg/myproject
1091
+ ✓ Detected branch: feature/user-auth
1092
+ ✓ Creating Codespace...
1093
+ ✓ Codespace created: codespace-xyz123
1094
+ ✓ Installing dependencies...
1095
+ ✓ Starting server...
1096
+ ✓ Deployment complete
1097
+
1098
+ URLs:
1099
+ Workspace: https://myorg-myproject-xyz123.github.dev
1100
+ Sudocode: https://myorg-myproject-xyz123-3000.app.github.dev
1101
+ SSH: gh cs ssh -c codespace-xyz123
1102
+ ```
1103
+
1104
+ #### Example 2: Deploy Different Branch
1105
+
1106
+ ```bash
1107
+ # From any branch, deploy main
1108
+ sudocode remote codespaces spawn --branch main
1109
+ ```
1110
+
1111
+ #### Example 3: Custom Configuration
1112
+
1113
+ ```bash
1114
+ # Deploy with custom settings for intensive task
1115
+ sudocode remote codespaces spawn \
1116
+ --branch feature/refactor-db \
1117
+ --machine "premiumLinux" \
1118
+ --keep-alive 48 \
1119
+ --idle-timeout 480
1120
+ ```
1121
+
1122
+ #### Example 4: Monitor Multiple Deployments
1123
+
1124
+ ```bash
1125
+ # Deploy multiple branches
1126
+ sudocode remote codespaces spawn --branch feature/api-v2
1127
+ sudocode remote codespaces spawn --branch bugfix/cors-issue
1128
+ sudocode remote codespaces spawn --branch feature/new-ui
1129
+
1130
+ # List all
1131
+ sudocode remote codespaces list
1132
+
1133
+ # Check each status
1134
+ sudocode remote codespaces status <id-1>
1135
+ sudocode remote codespaces status <id-2>
1136
+ sudocode remote codespaces status <id-3>
1137
+
1138
+ # Stop completed ones
1139
+ sudocode remote codespaces stop <id-1> --force
1140
+ ```
1141
+
1142
+ #### Example 5: JSON Automation
1143
+
1144
+ ```bash
1145
+ # Deploy and capture ID
1146
+ DEPLOY_ID=$(sudocode remote codespaces spawn --json | jq -r '.id')
1147
+
1148
+ # Monitor status
1149
+ while true; do
1150
+ STATUS=$(sudocode remote codespaces status $DEPLOY_ID --json | jq -r '.status')
1151
+ echo "Status: $STATUS"
1152
+ if [ "$STATUS" = "running" ]; then
1153
+ break
1154
+ fi
1155
+ sleep 5
1156
+ done
1157
+
1158
+ # Get Sudocode URL
1159
+ SUDOCODE_URL=$(sudocode remote codespaces status $DEPLOY_ID --json | jq -r '.urls.sudocode')
1160
+ echo "Sudocode UI: $SUDOCODE_URL"
1161
+ ```
1162
+
1163
+ #### Example 6: Full Lifecycle
1164
+
1165
+ ```bash
1166
+ # 1. Configure for your needs
1167
+ sudocode remote codespaces config \
1168
+ --port 8080 \
1169
+ --machine "standardLinux32gb" \
1170
+ --idle-timeout 120 \
1171
+ --keep-alive 24
1172
+
1173
+ # 2. Deploy
1174
+ sudocode remote codespaces spawn --branch feature/new-feature
1175
+
1176
+ # 3. Monitor
1177
+ sudocode remote codespaces list
1178
+ sudocode remote codespaces status <id>
1179
+
1180
+ # 4. Access via SSH to check logs
1181
+ gh cs ssh -c <codespace-name>
1182
+ tail -f ~/.sudocode/server.log
1183
+
1184
+ # 5. Clean up when done
1185
+ sudocode remote codespaces stop <id> --force
1186
+ ```
1187
+
1188
+ ### Troubleshooting
1189
+
1190
+ #### GitHub CLI Not Found
1191
+
1192
+ **Error:**
1193
+ ```
1194
+ Error: gh CLI not found. Please install GitHub CLI first.
1195
+ ```
1196
+
1197
+ **Solution:**
1198
+ ```bash
1199
+ # macOS
1200
+ brew install gh
1201
+
1202
+ # Windows
1203
+ winget install GitHub.cli
1204
+
1205
+ # Linux
1206
+ sudo apt install gh
1207
+
1208
+ # Verify installation
1209
+ gh --version
1210
+ ```
1211
+
1212
+ #### Not Authenticated with GitHub
1213
+
1214
+ **Error:**
1215
+ ```
1216
+ Error: Not authenticated with GitHub
1217
+ ```
1218
+
1219
+ **Solution:**
1220
+ ```bash
1221
+ # Login to GitHub
1222
+ gh auth login
1223
+
1224
+ # Select GitHub.com
1225
+ # Choose HTTPS or SSH
1226
+ # Authenticate in browser
1227
+ ```
1228
+
1229
+ #### No Git Repository
1230
+
1231
+ **Error:**
1232
+ ```
1233
+ Error: Not a git repository
1234
+ ```
1235
+
1236
+ **Solution:**
1237
+ ```bash
1238
+ # Initialize git repository
1239
+ git init
1240
+
1241
+ # Add remote
1242
+ git remote add origin https://github.com/myorg/myproject.git
1243
+
1244
+ # Commit and push
1245
+ git add .
1246
+ git commit -m "Initial commit"
1247
+ git push -u origin main
1248
+ ```
1249
+
1250
+ #### Uncommitted Changes
1251
+
1252
+ **Error:**
1253
+ ```
1254
+ Error: Repository has uncommitted changes
1255
+ ```
1256
+
1257
+ **Solution:**
1258
+ ```bash
1259
+ # Option 1: Commit changes
1260
+ git add .
1261
+ git commit -m "Work in progress"
1262
+ git push
1263
+
1264
+ # Option 2: Stash changes
1265
+ git stash
1266
+ sudocode remote codespaces spawn
1267
+ git stash pop
1268
+
1269
+ # Option 3: Deploy different branch
1270
+ sudocode remote codespaces spawn --branch main
1271
+ ```
1272
+
1273
+ #### No Authentication Configured
1274
+
1275
+ **Error:**
1276
+ ```
1277
+ Error: No AI credentials configured
1278
+ ```
1279
+
1280
+ **Solution:**
1281
+ ```bash
1282
+ # Configure Claude
1283
+ sudocode auth claude
1284
+
1285
+ # Verify
1286
+ sudocode auth status
1287
+
1288
+ # Should show "Claude Code: ✓ Configured"
1289
+ ```
1290
+
1291
+ #### Port Already in Use
1292
+
1293
+ **Error:**
1294
+ ```
1295
+ Error: Port 3000 is already in use
1296
+ ```
1297
+
1298
+ **Solution:**
1299
+ ```bash
1300
+ # Use different port
1301
+ sudocode remote codespaces spawn --port 8080
1302
+
1303
+ # Or update config
1304
+ sudocode remote codespaces config --port 8080
1305
+ sudocode remote codespaces spawn
1306
+ ```
1307
+
1308
+ #### Deployment Not Found
1309
+
1310
+ **Error:**
1311
+ ```
1312
+ ✗ Deployment not found: codespace-abc123
1313
+ ```
1314
+
1315
+ **Solution:**
1316
+ ```bash
1317
+ # List all deployments
1318
+ sudocode remote codespaces list
1319
+
1320
+ # Use correct ID from list
1321
+ sudocode remote codespaces status <correct-id>
1322
+ ```
1323
+
1324
+ #### Codespace Creation Failed
1325
+
1326
+ **Error:**
1327
+ ```
1328
+ Error: Failed to create Codespace
1329
+ ```
1330
+
1331
+ **Common Causes:**
1332
+ - GitHub API rate limit exceeded
1333
+ - Repository not accessible
1334
+ - Insufficient permissions
1335
+ - GitHub Codespaces not enabled for repository
1336
+
1337
+ **Solution:**
1338
+ ```bash
1339
+ # Check GitHub authentication
1340
+ gh auth status
1341
+
1342
+ # Verify repository access
1343
+ gh repo view myorg/myproject
1344
+
1345
+ # Check Codespaces status
1346
+ gh codespace list
1347
+
1348
+ # Try again with specific repo
1349
+ sudocode remote codespaces spawn --repo myorg/myproject
1350
+ ```
1351
+
1352
+ #### Deployment Stuck in Starting
1353
+
1354
+ **Issue:**
1355
+ Deployment shows "starting" status for extended period.
1356
+
1357
+ **Solution:**
1358
+ ```bash
1359
+ # Check detailed status
1360
+ sudocode remote codespaces status <id>
1361
+
1362
+ # If stuck > 5 minutes, stop and retry
1363
+ sudocode remote codespaces stop <id> --force
1364
+ sudocode remote codespaces spawn
1365
+ ```
1366
+
1367
+ #### Cannot Access Sudocode URL
1368
+
1369
+ **Issue:**
1370
+ Sudocode URL returns connection error.
1371
+
1372
+ **Solutions:**
1373
+ ```bash
1374
+ # 1. Check deployment status
1375
+ sudocode remote codespaces status <id>
1376
+ # Status should be "running"
1377
+
1378
+ # 2. Wait for port forwarding
1379
+ # Codespace port forwarding can take 30-60 seconds
1380
+
1381
+ # 3. Try SSH access
1382
+ gh cs ssh -c <codespace-name>
1383
+ curl http://localhost:3000/health
1384
+
1385
+ # 4. Check logs in Codespace
1386
+ gh cs ssh -c <codespace-name>
1387
+ cd /workspaces/myproject
1388
+ cat ~/.sudocode/server.log
1389
+ ```
1390
+
1391
+ #### Deployment Stops Unexpectedly
1392
+
1393
+ **Issue:**
1394
+ Deployment status changes to "stopped" without manual intervention.
1395
+
1396
+ **Causes:**
1397
+ - Idle timeout reached (no activity for configured period)
1398
+ - GitHub Codespaces automatic cleanup
1399
+ - Insufficient credits/quota
1400
+
1401
+ **Solution:**
1402
+ ```bash
1403
+ # Check configuration
1404
+ sudocode remote codespaces config
1405
+
1406
+ # Increase timeouts for longer tasks
1407
+ sudocode remote codespaces config \
1408
+ --idle-timeout 1440 \
1409
+ --keep-alive 168
1410
+
1411
+ # Redeploy
1412
+ sudocode remote codespaces spawn --branch <branch>
1413
+ ```
1414
+
1415
+ ### Machine Types
1416
+
1417
+ GitHub Codespaces offers different machine types with varying resources:
1418
+
1419
+ | Machine Type | vCPUs | RAM | Storage | Use Case |
1420
+ |-------------|-------|-----|---------|----------|
1421
+ | `basicLinux32gb` | 2 | 8 GB | 32 GB | Small projects, quick tasks |
1422
+ | `standardLinux32gb` | 4 | 16 GB | 32 GB | Medium projects |
1423
+ | `premiumLinux` | 8 | 32 GB | 64 GB | Large projects, intensive tasks |
1424
+
1425
+ **Cost Considerations:**
1426
+ - Larger machines consume GitHub Codespaces quota faster
1427
+ - Free tier provides limited monthly minutes
1428
+ - Paid plans offer more quota
1429
+
1430
+ **Selecting Machine:**
1431
+ ```bash
1432
+ # Configure default machine
1433
+ sudocode remote codespaces config --machine "standardLinux32gb"
1434
+
1435
+ # Override for specific deployment
1436
+ sudocode remote codespaces spawn --machine "premiumLinux"
1437
+ ```
1438
+
1439
+ ### Best Practices
1440
+
1441
+ 1. **Commit Before Deploy**
1442
+ - Always commit and push changes before deploying
1443
+ - Deployments clone from git, not local working directory
1444
+
1445
+ 2. **Use Configuration Defaults**
1446
+ - Set project defaults in `.sudocode/spawn-config.json`
1447
+ - Commit configuration to share with team
1448
+ - Override per-deployment as needed
1449
+
1450
+ 3. **Monitor Active Deployments**
1451
+ - Regularly check `sudocode remote codespaces list`
1452
+ - Stop unused deployments to save quota
1453
+ - Use `--force` flag for batch cleanup
1454
+
1455
+ 4. **Right-Size Resources**
1456
+ - Start with `basicLinux32gb` for most tasks
1457
+ - Upgrade to larger machines only when needed
1458
+ - Use shorter timeouts for quick tasks
1459
+
1460
+ 5. **Secure Credentials**
1461
+ - Never commit credentials to git
1462
+ - Credentials are automatically secured in Codespaces
1463
+ - Use `sudocode auth clear` if credentials are compromised
1464
+
1465
+ 6. **Branch Strategy**
1466
+ - Deploy feature branches for isolated work
1467
+ - Keep deployments aligned with git workflow
1468
+ - Use configuration to set consistent defaults
1469
+
1470
+ 7. **Team Sharing**
1471
+ - Share Sudocode URLs with team members for review
1472
+ - Use descriptive branch names for clarity
1473
+ - Document deployment purpose in commit messages
1474
+
1475
+ 8. **Cleanup Routine**
1476
+ - Stop deployments when work is complete
1477
+ - Don't rely solely on auto-cleanup
1478
+ - Check monthly to avoid quota surprises
1479
+
1480
+ 9. **Provider-Specific Commands**
1481
+ - Always specify provider in commands: `sudocode remote <provider> <command>`
1482
+ - Currently only `codespaces` is fully supported
1483
+ - `coder` support coming soon
1484
+
1485
+ ### Error Messages
1486
+
1487
+ All deploy commands provide consistent, actionable error messages with clear guidance on how to resolve issues.
1488
+
1489
+ #### Error Message Format
1490
+
1491
+ All errors follow this consistent format:
1492
+
1493
+ ```
1494
+ ✗ Error Title
1495
+
1496
+ Detailed explanation of what went wrong
1497
+
1498
+ Suggested action:
1499
+ command to run or steps to take
1500
+ ```
1501
+
1502
+ #### Example Error Messages
1503
+
1504
+ **Authentication Error:**
1505
+ ```
1506
+ ✗ GitHub CLI is not authenticated
1507
+
1508
+ Sudocode needs GitHub CLI to deploy to Codespaces.
1509
+
1510
+ To authenticate:
1511
+ gh auth login
1512
+ ```
1513
+
1514
+ **Git Repository Not Found:**
1515
+ ```
1516
+ ✗ Git repository not found
1517
+
1518
+ This command must be run from within a git repository.
1519
+
1520
+ To initialize a repository:
1521
+ git init
1522
+ ```
1523
+
1524
+ **Port Conflict:**
1525
+ ```
1526
+ ✗ Port 3000 is already in use
1527
+
1528
+ The requested port is not available on your system.
1529
+
1530
+ To use a different port:
1531
+ sudocode remote codespaces spawn --port 3001
1532
+ ```
1533
+
1534
+ **Deployment Not Found:**
1535
+ ```
1536
+ ✗ Deployment 'codespace-xyz' not found
1537
+
1538
+ The specified deployment does not exist or has been deleted.
1539
+
1540
+ To list all deployments:
1541
+ sudocode remote codespaces list
1542
+ ```
1543
+
1544
+ **Network Connection Failed:**
1545
+ ```
1546
+ ✗ Network connection failed
1547
+
1548
+ Unable to list deployments due to network issues.
1549
+
1550
+ Suggested actions:
1551
+ • Check your internet connection
1552
+ • Verify VPN or proxy settings
1553
+ • Try again in a few moments
1554
+ ```
1555
+
1556
+ **Invalid Configuration:**
1557
+ ```
1558
+ ✗ Invalid configuration: port
1559
+
1560
+ Port must be between 1024 and 65535
1561
+
1562
+ To view current configuration:
1563
+ sudocode remote codespaces config
1564
+ ```
1565
+
1566
+ #### Error Types
1567
+
1568
+ The deploy system uses typed errors for consistent handling:
1569
+
1570
+ - **AuthenticationError** - Missing or invalid credentials (GitHub, Claude)
1571
+ - **GitContextError** - Git repository issues (not a repo, no remote, invalid branch)
1572
+ - **ConfigurationError** - Invalid configuration values
1573
+ - **ProviderError** - Deployment provider failures (Codespaces API errors)
1574
+ - **NetworkError** - Network connectivity issues
1575
+ - **PortConflictError** - Port already in use
1576
+ - **DeploymentNotFoundError** - Deployment ID not found
1577
+
1578
+ Each error type provides context-specific guidance for resolution.
1579
+
281
1580
  ## Example Workflows
282
1581
 
283
1582
  ### Creating and Working on a Feature