mystack-rig 1.4.0__tar.gz → 1.5.0__tar.gz

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 (122) hide show
  1. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/CLI_STORAGE_SUMMARY.md +2 -2
  2. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/GLOSSARY.md +5 -1
  3. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/HETZNER_STORAGE_GUIDE.md +2 -2
  4. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/HETZNER_STORAGE_SECURITY_GUIDE.md +1 -1
  5. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/PKG-INFO +14 -1
  6. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/README.md +13 -0
  7. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/STORAGE_CLI_GUIDE.md +4 -4
  8. mystack_rig-1.5.0/sample.env +17 -0
  9. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/config.py +43 -24
  10. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/encrypt.py +15 -6
  11. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/remote_dev.py +128 -11
  12. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/storage.py +46 -13
  13. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/mystack_rig.egg-info/PKG-INFO +14 -1
  14. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/mystack_rig.egg-info/SOURCES.txt +1 -0
  15. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/mystack_rig.egg-info/scm_file_list.json +1 -0
  16. mystack_rig-1.5.0/src/mystack_rig.egg-info/scm_version.json +8 -0
  17. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/conftest.py +6 -0
  18. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_encrypt_coverage.py +16 -0
  19. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_init_command.py +182 -15
  20. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_outputs_storage.py +2 -2
  21. mystack_rig-1.5.0/tests/test_r2_storage.py +150 -0
  22. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_real_e2e_storage.py +11 -7
  23. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_remote_dev_coverage_extensions.py +1 -1
  24. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_rig_config.py +10 -10
  25. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_small_module_coverage.py +2 -2
  26. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_state_bucket.py +20 -1
  27. mystack_rig-1.4.0/sample.env +0 -12
  28. mystack_rig-1.4.0/src/mystack_rig.egg-info/scm_version.json +0 -8
  29. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/.coveragerc +0 -0
  30. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/.git-blame-ignore-revs +0 -0
  31. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/.github/workflows/release.yml +0 -0
  32. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/.github/workflows/tests.yml +0 -0
  33. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/.gitignore +0 -0
  34. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/.rig/playbooks/README.md +0 -0
  35. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/.rig/playbooks/vpn-gateway.yml +0 -0
  36. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/Dockerfile +0 -0
  37. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/GIT_CLONE_FEATURE.md +0 -0
  38. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/LICENSE +0 -0
  39. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/Makefile +0 -0
  40. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/README_REAL_E2E.md +0 -0
  41. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/docs/adr/0001-per-profile-generated-state-bucket.md +0 -0
  42. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/docs/adr/0002-outputs-as-separate-object-via-file-handoff.md +0 -0
  43. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/docs/adr/0003-mcp-servers-declared-once-rendered-at-authorize.md +0 -0
  44. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/docs/adr/0004-agents-run-as-live-agents-in-tmux.md +0 -0
  45. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/docs/architecture.md +0 -0
  46. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/docs/architecture.png +0 -0
  47. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/docs/architecture.svg +0 -0
  48. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/forged-idea.md +0 -0
  49. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/pyproject.toml +0 -0
  50. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/pytest.ini +0 -0
  51. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/requirements.txt +0 -0
  52. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/scripts/coverage_badge.py +0 -0
  53. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/scripts/pypi_version.py +0 -0
  54. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/setup.cfg +0 -0
  55. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/__init__.py +0 -0
  56. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/__init__.py +0 -0
  57. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/__main__.py +0 -0
  58. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/agents.py +0 -0
  59. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/ansible_filters/__init__.py +0 -0
  60. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/ansible_filters/rig_live.py +0 -0
  61. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/ansible_filters/rig_mcp.py +0 -0
  62. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/assets/rig-agent-queue +0 -0
  63. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/assets/rig-agent-state +0 -0
  64. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/assets/tmux.conf +0 -0
  65. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/git.py +0 -0
  66. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/git_author.py +0 -0
  67. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/last_env.py +0 -0
  68. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/last_session.py +0 -0
  69. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/live_agent.py +0 -0
  70. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/log.py +0 -0
  71. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/main.py +0 -0
  72. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/mcp.py +0 -0
  73. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/outputs.py +0 -0
  74. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/requirements.txt +0 -0
  75. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/snapshots.py +0 -0
  76. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/state_bucket.py +0 -0
  77. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/vault_keys.py +0 -0
  78. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/cli/vpn.py +0 -0
  79. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/mystack_rig.egg-info/dependency_links.txt +0 -0
  80. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/mystack_rig.egg-info/entry_points.txt +0 -0
  81. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/mystack_rig.egg-info/requires.txt +0 -0
  82. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/src/mystack_rig.egg-info/top_level.txt +0 -0
  83. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/test_hetzner_integration.py +0 -0
  84. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_agents.py +0 -0
  85. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_ansible_galaxy.py +0 -0
  86. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_attach_command.py +0 -0
  87. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_credential_security.py +0 -0
  88. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_destroy_command.py +0 -0
  89. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_dev_command.py +0 -0
  90. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_encrypt_command.py +0 -0
  91. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_firewall_client_ip.py +0 -0
  92. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_git_clone_unit.py +0 -0
  93. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_git_credentials_and_author.py +0 -0
  94. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_git_manager.py +0 -0
  95. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_gitignore_init.py +0 -0
  96. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_hetzner_storage.py +0 -0
  97. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_inspect_describe.py +0 -0
  98. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_last_env.py +0 -0
  99. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_last_session.py +0 -0
  100. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_live_agent.py +0 -0
  101. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_live_agent_cli.py +0 -0
  102. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_log.py +0 -0
  103. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_main_coverage.py +0 -0
  104. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_mcp_command.py +0 -0
  105. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_mcp_render.py +0 -0
  106. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_outputs.py +0 -0
  107. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_pypi_version.py +0 -0
  108. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_python_floor.py +0 -0
  109. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_real_e2e_integration.py +0 -0
  110. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_real_e2e_vpn.py +0 -0
  111. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_real_e2e_vpn_tunnel.py +0 -0
  112. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_remote_dev.py +0 -0
  113. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_rig_ansible_vars.py +0 -0
  114. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_secret_prompt_hidden.py +0 -0
  115. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_setup_provision.py +0 -0
  116. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_simulation_storage.py +0 -0
  117. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_snapshots.py +0 -0
  118. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_storage_basic.py +0 -0
  119. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_vault_keys.py +0 -0
  120. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_vpn_optional.py +0 -0
  121. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_vpn_unit.py +0 -0
  122. {mystack_rig-1.4.0 → mystack_rig-1.5.0}/tests/test_workspace_git_clone.py +0 -0
@@ -76,13 +76,13 @@ The solution provides comprehensive storage management for Hetzner S3-compatible
76
76
  #### Environment Variables
77
77
  ```bash
78
78
  export HZ_TOKEN="your-hetzner-cloud-token"
79
- export S3_ENDPOINT_URL="https://fsn1.yourdomain.com" # Optional override
79
+ export RIG_STATE_ENDPOINT_URL="https://fsn1.yourdomain.com" # Optional override
80
80
  ```
81
81
 
82
82
  #### Configuration File (`config.yaml`)
83
83
  ```yaml
84
84
  hz_token: "your-hetzner-cloud-token"
85
- s3_endpoint_url: "https://fsn1.yourdomain.com"
85
+ state_endpoint_url: "https://fsn1.yourdomain.com"
86
86
  ```
87
87
 
88
88
  ### 5. Usage Examples
@@ -13,9 +13,13 @@ The storage bucket holding environment state for one Profile within one workspac
13
13
  _Avoid_: Production bucket, installation bucket
14
14
 
15
15
  **Workspace**:
16
- A project repository containing a `.rig/` directory, which owns its own State buckets.
16
+ A folder containing `rig.yml` and a `.rig/` directory, which groups zero or more Repos and owns its own State buckets. It need not itself be a git repository.
17
17
  _Avoid_: Project (ambiguous with a Hetzner Cloud project)
18
18
 
19
+ **Repo**:
20
+ A git repository included in a Workspace and cloned onto its Environments.
21
+ _Avoid_: Project
22
+
19
23
  **Environment**:
20
24
  A remote development machine provisioned by rig, owned by one identity and tracked in a State bucket.
21
25
  _Avoid_: Instance, VM, server
@@ -83,12 +83,12 @@ The CLI follows a modular architecture:
83
83
 
84
84
  ### Environment Variables
85
85
  - `HZ_TOKEN`: Hetzner Cloud API token (required)
86
- - `S3_ENDPOINT_URL`: S3 endpoint URL (defaults to `https://fsn1.yourdomain.com`)
86
+ - `RIG_STATE_ENDPOINT_URL`: S3 endpoint URL (defaults to `https://fsn1.yourdomain.com`)
87
87
 
88
88
  ### Configuration File (`config.yaml`)
89
89
  ```yaml
90
90
  hz_token: "your-hetzner-cloud-token"
91
- s3_endpoint_url: "https://fsn1.yourdomain.com"
91
+ state_endpoint_url: "https://fsn1.yourdomain.com"
92
92
  ```
93
93
 
94
94
  ## How It Works
@@ -125,7 +125,7 @@ export HZ_TOKEN="your-hetzner-cloud-token"
125
125
  ```yaml
126
126
  # config.yaml
127
127
  hz_token: "your-hetzner-cloud-token" # Only stored in environment variables
128
- s3_endpoint_url: "https://fsn1.yourdomain.com" # Default Hetzner endpoint
128
+ state_endpoint_url: "https://fsn1.yourdomain.com" # Default Hetzner endpoint
129
129
  ```
130
130
 
131
131
  ## Security Features
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mystack-rig
3
- Version: 1.4.0
3
+ Version: 1.5.0
4
4
  Summary: Ephemeral remotes with full local parity for coding agents
5
5
  Author: mystack-cloud
6
6
  License-Expression: MIT
@@ -52,6 +52,15 @@ Run `rig` from your machine, CI/CD, or a control plane: it provisions cloud VMs
52
52
 
53
53
  `rig create` reads `host.provider`. Omit it and the provider is Hetzner. `--provider` overrides the file. `aws` and `gcp` are accepted as names and refused until those clouds can provision.
54
54
 
55
+ State storage (environment records, outputs) is separate from the VM provider and can be any of:
56
+
57
+ | Storage | Selected by | Status |
58
+ | --- | --- | --- |
59
+ | [Hetzner Object Storage](https://www.hetzner.com/storage/object-storage) | default endpoint (`https://fsn1.your-objectstorage.com`) | Supported |
60
+ | [Cloudflare R2](https://www.cloudflare.com/developer-platform/products/r2/) | `state_endpoint_url` = `https://<account-id>.r2.cloudflarestorage.com` | Supported |
61
+
62
+ See [State backend](#state-backend-hetzner-object-storage-or-cloudflare-r2) for the settings.
63
+
55
64
  ## Coding agents
56
65
 
57
66
  Chosen at `rig init` (`agent.enabled` in `rig.yml`, same multi-select as git projects: numbers, names, or `all`). Every selected agent is installed and configured on the VM. When more than one is selected, init asks which is the default for `rig attach` (`agent.default`). Pass `--agent` to open another one.
@@ -388,6 +397,10 @@ See `docs/adr/0002-outputs-as-separate-object-via-file-handoff.md`.
388
397
  | `/tmp/.rig/.personal-data-key` / `.shared-data-key` | Materialized Ansible vault passwords after unlock (tmpfs). |
389
398
  | `/tmp/<env>-key` | Per-env SSH private key (attach / apply / delete finalizers). |
390
399
 
400
+ ### State backend: Hetzner Object Storage or Cloudflare R2
401
+
402
+ State (environment records, outputs) lives in an S3-compatible bucket. The endpoint decides the provider: set `state_endpoint_url` in `~/.rig/config` (or `RIG_STATE_ENDPOINT_URL`) to your R2 endpoint, `https://<account-id>.r2.cloudflarestorage.com` (or the `.eu.` / `.fedramp.` variant), and use an R2 API token as `state_access_key` / `state_secret_key` (`RIG_STATE_ACCESS_KEY` / `RIG_STATE_SECRET_KEY`). The older `HETZNER_S3_*`, `S3_ENDPOINT_URL` and `hetzner_s3_*` / `s3_endpoint_url` names are still read as fallbacks. rig signs R2 requests with region `auto`. The Hetzner Cloud token is still required for the servers.
403
+
391
404
  `RIG_IDENTITY` overrides the configured identity. Teammates joining an existing workspace paste the shared data key once (`rig vars export-shared-key` from an unlocked machine).
392
405
 
393
406
  OpenCode without an API key uses free Zen models. With a key, config switches to the paid provider path. When several agents are selected, keys are `opencode_api_key`, `claude_api_key`, and `cursor_api_key` (`RIG_OPENCODE_API_KEY`, `RIG_ANTHROPIC_API_KEY`, `RIG_CURSOR_API_KEY`). A single agent still uses `coding_agent_api_key` (`RIG_CODING_AGENT_API_KEY`).
@@ -30,6 +30,15 @@ Run `rig` from your machine, CI/CD, or a control plane: it provisions cloud VMs
30
30
 
31
31
  `rig create` reads `host.provider`. Omit it and the provider is Hetzner. `--provider` overrides the file. `aws` and `gcp` are accepted as names and refused until those clouds can provision.
32
32
 
33
+ State storage (environment records, outputs) is separate from the VM provider and can be any of:
34
+
35
+ | Storage | Selected by | Status |
36
+ | --- | --- | --- |
37
+ | [Hetzner Object Storage](https://www.hetzner.com/storage/object-storage) | default endpoint (`https://fsn1.your-objectstorage.com`) | Supported |
38
+ | [Cloudflare R2](https://www.cloudflare.com/developer-platform/products/r2/) | `state_endpoint_url` = `https://<account-id>.r2.cloudflarestorage.com` | Supported |
39
+
40
+ See [State backend](#state-backend-hetzner-object-storage-or-cloudflare-r2) for the settings.
41
+
33
42
  ## Coding agents
34
43
 
35
44
  Chosen at `rig init` (`agent.enabled` in `rig.yml`, same multi-select as git projects: numbers, names, or `all`). Every selected agent is installed and configured on the VM. When more than one is selected, init asks which is the default for `rig attach` (`agent.default`). Pass `--agent` to open another one.
@@ -366,6 +375,10 @@ See `docs/adr/0002-outputs-as-separate-object-via-file-handoff.md`.
366
375
  | `/tmp/.rig/.personal-data-key` / `.shared-data-key` | Materialized Ansible vault passwords after unlock (tmpfs). |
367
376
  | `/tmp/<env>-key` | Per-env SSH private key (attach / apply / delete finalizers). |
368
377
 
378
+ ### State backend: Hetzner Object Storage or Cloudflare R2
379
+
380
+ State (environment records, outputs) lives in an S3-compatible bucket. The endpoint decides the provider: set `state_endpoint_url` in `~/.rig/config` (or `RIG_STATE_ENDPOINT_URL`) to your R2 endpoint, `https://<account-id>.r2.cloudflarestorage.com` (or the `.eu.` / `.fedramp.` variant), and use an R2 API token as `state_access_key` / `state_secret_key` (`RIG_STATE_ACCESS_KEY` / `RIG_STATE_SECRET_KEY`). The older `HETZNER_S3_*`, `S3_ENDPOINT_URL` and `hetzner_s3_*` / `s3_endpoint_url` names are still read as fallbacks. rig signs R2 requests with region `auto`. The Hetzner Cloud token is still required for the servers.
381
+
369
382
  `RIG_IDENTITY` overrides the configured identity. Teammates joining an existing workspace paste the shared data key once (`rig vars export-shared-key` from an unlocked machine).
370
383
 
371
384
  OpenCode without an API key uses free Zen models. With a key, config switches to the paid provider path. When several agents are selected, keys are `opencode_api_key`, `claude_api_key`, and `cursor_api_key` (`RIG_OPENCODE_API_KEY`, `RIG_ANTHROPIC_API_KEY`, `RIG_CURSOR_API_KEY`). A single agent still uses `coding_agent_api_key` (`RIG_CODING_AGENT_API_KEY`).
@@ -21,14 +21,14 @@ This CLI tool is specifically designed to manage storage operations with Hetzner
21
21
 
22
22
  2. **Configure environment variables** (recommended):
23
23
  ```bash
24
- export S3_ENDPOINT_URL="https://fsn1.yourdomain.com"
24
+ export RIG_STATE_ENDPOINT_URL="https://fsn1.yourdomain.com"
25
25
  export S3_ACCESS_KEY="your-access-key"
26
26
  export S3_SECRET_KEY="your-secret-key"
27
27
  ```
28
28
 
29
29
  3. **Or create a config.yaml file**:
30
30
  ```yaml
31
- s3_endpoint_url: "https://fsn1.yourdomain.com"
31
+ state_endpoint_url: "https://fsn1.yourdomain.com"
32
32
  s3_access_key: "your-access-key"
33
33
  s3_secret_key: "your-secret-key"
34
34
  ```
@@ -91,14 +91,14 @@ The CLI follows a modular architecture:
91
91
  ## Configuration Options
92
92
 
93
93
  ### Environment Variables
94
- - `S3_ENDPOINT_URL`: The S3 endpoint URL (e.g., `https://fsn1.yourdomain.com`)
94
+ - `RIG_STATE_ENDPOINT_URL`: The S3 endpoint URL (e.g., `https://fsn1.yourdomain.com`)
95
95
  - `S3_ACCESS_KEY`: Access key for authentication
96
96
  - `S3_SECRET_KEY`: Secret key for authentication
97
97
 
98
98
  ### Configuration File
99
99
  The CLI reads from `config.yaml` if it exists. The file should contain:
100
100
  ```yaml
101
- s3_endpoint_url: "https://fsn1.yourdomain.com"
101
+ state_endpoint_url: "https://fsn1.yourdomain.com"
102
102
  s3_access_key: "your-access-key"
103
103
  s3_secret_key: "your-secret-key"
104
104
  ```
@@ -0,0 +1,17 @@
1
+ # Sample environment file for RIG project
2
+ # This file should be renamed to .env and populated with actual credentials
3
+
4
+ # Hetzner Cloud API Token
5
+ HETZNER_CLOUD_API_TOKEN="your-hetzner-cloud-token-here"
6
+
7
+ # Optional: Hetzner S3-Compatible Storage Endpoint
8
+ # RIG_STATE_ENDPOINT_URL="https://fsn1.yourdomain.com"
9
+
10
+ # GitHub Personal Access Token for git clone operations
11
+ # Required for cloning private repositories or for higher rate limits
12
+ RIG_GITHUB_PAT="your-github-personal-access-token-here"
13
+ # Cloudflare R2 for state: point the endpoint at R2 and use an R2 API token
14
+ # as the S3 keys (the Hetzner Cloud token above is still needed for servers).
15
+ # RIG_STATE_ENDPOINT_URL="https://<account-id>.r2.cloudflarestorage.com"
16
+ # RIG_STATE_ACCESS_KEY="r2-access-key-id"
17
+ # RIG_STATE_SECRET_KEY="r2-secret-access-key"
@@ -5,9 +5,9 @@ Credentials live in ~/.rig/config using AWS-style profiles:
5
5
 
6
6
  [default]
7
7
  hetzner_cloud_api_token = ...
8
- hetzner_s3_access_key = ...
9
- hetzner_s3_secret_key = ...
10
- s3_endpoint_url = https://fsn1.your-objectstorage.com
8
+ state_access_key = ...
9
+ state_secret_key = ...
10
+ state_endpoint_url = https://fsn1.your-objectstorage.com
11
11
 
12
12
  [profile staging]
13
13
  hetzner_cloud_api_token = ...
@@ -27,11 +27,18 @@ DEFAULT_S3_ENDPOINT = "https://fsn1.your-objectstorage.com"
27
27
 
28
28
  PROFILE_KEYS = (
29
29
  "hetzner_cloud_api_token",
30
- "hetzner_s3_access_key",
31
- "hetzner_s3_secret_key",
32
- "s3_endpoint_url",
30
+ "state_access_key",
31
+ "state_secret_key",
32
+ "state_endpoint_url",
33
33
  )
34
34
 
35
+ # Names used before the RIG_STATE_* rename; still read as fallbacks.
36
+ LEGACY_PROFILE_KEYS = {
37
+ "state_access_key": "hetzner_s3_access_key",
38
+ "state_secret_key": "hetzner_s3_secret_key",
39
+ "state_endpoint_url": "s3_endpoint_url",
40
+ }
41
+
35
42
  # Developer identity for ``.rig/vars.{identity}.yml`` (not a cloud profile).
36
43
  IDENTITY_KEY = "identity"
37
44
 
@@ -94,7 +101,12 @@ class RigConfig:
94
101
  section = name
95
102
  else:
96
103
  return {}
97
- return {key: value for key, value in self._parser.items(section) if key in PROFILE_KEYS and value}
104
+ raw = {key: value for key, value in self._parser.items(section) if value}
105
+ values = {key: value for key, value in raw.items() if key in PROFILE_KEYS}
106
+ for key, legacy in LEGACY_PROFILE_KEYS.items():
107
+ if key not in values and legacy in raw:
108
+ values[key] = raw[legacy]
109
+ return values
98
110
 
99
111
  def set_profile(self, values: dict[str, str], profile: str | None = None) -> None:
100
112
  name = profile or self.profile or DEFAULT_PROFILE
@@ -119,17 +131,24 @@ class RigConfig:
119
131
  or os.getenv("HZ_TOKEN")
120
132
  or stored.get("hetzner_cloud_api_token", "")
121
133
  ),
122
- "hetzner_s3_access_key": (
123
- os.getenv("HETZNER_S3_ACCESS_KEY")
134
+ "state_access_key": (
135
+ os.getenv("RIG_STATE_ACCESS_KEY")
136
+ or os.getenv("HETZNER_S3_ACCESS_KEY")
124
137
  or os.getenv("HETZNER_CLOUD_OBJECT_STORAGE_ACCESS_KEY")
125
- or stored.get("hetzner_s3_access_key", "")
138
+ or stored.get("state_access_key", "")
126
139
  ),
127
- "hetzner_s3_secret_key": (
128
- os.getenv("HETZNER_S3_SECRET_KEY")
140
+ "state_secret_key": (
141
+ os.getenv("RIG_STATE_SECRET_KEY")
142
+ or os.getenv("HETZNER_S3_SECRET_KEY")
129
143
  or os.getenv("HETZNER_CLOUD_OBJECT_STORAGE_SECRET_KEY")
130
- or stored.get("hetzner_s3_secret_key", "")
144
+ or stored.get("state_secret_key", "")
145
+ ),
146
+ "state_endpoint_url": (
147
+ os.getenv("RIG_STATE_ENDPOINT_URL")
148
+ or os.getenv("S3_ENDPOINT_URL")
149
+ or stored.get("state_endpoint_url")
150
+ or DEFAULT_S3_ENDPOINT
131
151
  ),
132
- "s3_endpoint_url": (os.getenv("S3_ENDPOINT_URL") or stored.get("s3_endpoint_url") or DEFAULT_S3_ENDPOINT),
133
152
  }
134
153
 
135
154
  def apply_to_environ(self, profile: str | None = None) -> dict[str, str]:
@@ -137,9 +156,9 @@ class RigConfig:
137
156
  resolved = self.resolve(profile)
138
157
  mapping = {
139
158
  "hetzner_cloud_api_token": "HETZNER_CLOUD_API_TOKEN",
140
- "hetzner_s3_access_key": "HETZNER_S3_ACCESS_KEY",
141
- "hetzner_s3_secret_key": "HETZNER_S3_SECRET_KEY",
142
- "s3_endpoint_url": "S3_ENDPOINT_URL",
159
+ "state_access_key": "RIG_STATE_ACCESS_KEY",
160
+ "state_secret_key": "RIG_STATE_SECRET_KEY",
161
+ "state_endpoint_url": "RIG_STATE_ENDPOINT_URL",
143
162
  }
144
163
  for key, env_name in mapping.items():
145
164
  value = resolved.get(key) or ""
@@ -200,7 +219,7 @@ def ensure_credentials(
200
219
  config = config or RigConfig()
201
220
  resolved = config.resolve()
202
221
  missing_token = not resolved.get("hetzner_cloud_api_token")
203
- missing_s3 = not (resolved.get("hetzner_s3_access_key") and resolved.get("hetzner_s3_secret_key"))
222
+ missing_s3 = not (resolved.get("state_access_key") and resolved.get("state_secret_key"))
204
223
 
205
224
  if not force_prompt and not missing_token and not missing_s3:
206
225
  config.apply_to_environ()
@@ -208,9 +227,9 @@ def ensure_credentials(
208
227
 
209
228
  print(f"Hetzner credentials ({config.profile} profile in {config.path})")
210
229
  token = resolved.get("hetzner_cloud_api_token", "")
211
- access_key = resolved.get("hetzner_s3_access_key", "")
212
- secret_key = resolved.get("hetzner_s3_secret_key", "")
213
- endpoint = resolved.get("s3_endpoint_url", DEFAULT_S3_ENDPOINT)
230
+ access_key = resolved.get("state_access_key", "")
231
+ secret_key = resolved.get("state_secret_key", "")
232
+ endpoint = resolved.get("state_endpoint_url", DEFAULT_S3_ENDPOINT)
214
233
 
215
234
  if force_prompt or missing_token:
216
235
  token = _prompt_secret(
@@ -244,9 +263,9 @@ def ensure_credentials(
244
263
 
245
264
  values = {
246
265
  "hetzner_cloud_api_token": token,
247
- "hetzner_s3_access_key": access_key,
248
- "hetzner_s3_secret_key": secret_key,
249
- "s3_endpoint_url": endpoint or DEFAULT_S3_ENDPOINT,
266
+ "state_access_key": access_key,
267
+ "state_secret_key": secret_key,
268
+ "state_endpoint_url": endpoint or DEFAULT_S3_ENDPOINT,
250
269
  }
251
270
  config.set_profile(values)
252
271
  config.apply_to_environ()
@@ -400,14 +400,23 @@ PROVIDER_ENV_VARS = {
400
400
  }
401
401
 
402
402
 
403
+ def _git_host(url: str) -> str:
404
+ """Lower-cased host of an https://, ssh:// or scp-style (git@host:path) remote."""
405
+ value = (url or "").strip().lower()
406
+ match = re.match(r"^(?:[a-z+]+://)?(?:[^@/]+@)?([^/:]+)", value)
407
+ return match.group(1) if match else ""
408
+
409
+
403
410
  def detect_git_provider(url: str) -> str | None:
404
- """Return 'github' or 'gitlab' when the remote URL is a known host."""
405
- if not url:
406
- return None
407
- lower = url.strip().lower()
408
- if "github.com" in lower or lower.startswith("git@github.com:"):
411
+ """Return 'github' or 'gitlab' for a remote URL.
412
+
413
+ GitLab includes self-hosted instances (any host with a ``gitlab`` label,
414
+ e.g. ``gitlab.example.com``); GitHub is github.com only.
415
+ """
416
+ host = _git_host(url)
417
+ if host == "github.com":
409
418
  return "github"
410
- if "gitlab.com" in lower or lower.startswith("git@gitlab.com:"):
419
+ if host == "gitlab.com" or "gitlab" in host.split("."):
411
420
  return "gitlab"
412
421
  return None
413
422
 
@@ -571,6 +571,50 @@ def configured_agents(project) -> tuple[list[str], str]:
571
571
  )
572
572
 
573
573
 
574
+ def derive_config_vars(config: dict[str, Any] | None) -> dict[str, Any]:
575
+ """Vars derivable from rig.yml, so ``vars.yml`` need not repeat them.
576
+
577
+ ``repos`` → ``git`` (clone lists) and ``git_providers``;
578
+ ``agent`` → ``coding_agent_type`` / ``coding_agent_types``.
579
+ A key is only returned when rig.yml actually declares its source.
580
+ """
581
+ from cli.agents import resolve_configured_agents
582
+ from cli.encrypt import git_providers_from_repos, to_https_git_url
583
+
584
+ cfg = config or {}
585
+ out: dict[str, Any] = {}
586
+
587
+ repos = [r for r in (cfg.get("repos") or []) if isinstance(r, dict) and r.get("name")]
588
+ if repos:
589
+ clone_repos: list[dict[str, Any]] = []
590
+ ssh_repos: list[dict[str, Any]] = []
591
+ for repo in repos:
592
+ url = str(repo.get("url") or "").strip()
593
+ if not url:
594
+ continue
595
+ entry: dict[str, Any] = {
596
+ "repo": url,
597
+ "dest": repo.get("dest") or remote_workspace_path(str(repo["name"])),
598
+ "accept_hostkey": True,
599
+ }
600
+ if repo.get("password_var"):
601
+ entry["password_var"] = repo["password_var"]
602
+ if url != to_https_git_url(url):
603
+ entry["ssh_key"] = "/root/.ssh/id_rsa"
604
+ ssh_repos.append(entry)
605
+ else:
606
+ clone_repos.append(entry)
607
+ out["git"] = {"clone_repos": clone_repos, "ssh_repos": ssh_repos}
608
+ out["git_providers"] = git_providers_from_repos(repos)
609
+
610
+ agent_cfg = cfg.get("agent")
611
+ if isinstance(agent_cfg, dict) and (agent_cfg.get("default") or agent_cfg.get("enabled") or agent_cfg.get("type")):
612
+ types, default = resolve_configured_agents(agent_cfg)
613
+ out["coding_agent_type"] = default
614
+ out["coding_agent_types"] = list(types)
615
+ return out
616
+
617
+
574
618
  def build_rig_ansible_vars(
575
619
  env: "RemoteDevEnvironment",
576
620
  project: Optional["ProjectConfig"] = None,
@@ -1533,15 +1577,18 @@ class RemoteDevManager:
1533
1577
  key = self._records_prefix(owner)
1534
1578
  return f"{self.state_bucket}/{key}"
1535
1579
 
1536
- def _read_yaml_object(self, key: str) -> dict | None:
1537
- """Download one object and parse it as YAML; None if unavailable."""
1580
+ def _read_yaml_object(self, key: str, *, may_be_absent: bool = False) -> dict | None:
1581
+ """Download one object and parse it as YAML; None if unavailable.
1582
+
1583
+ ``may_be_absent`` skips the 404 retry window for optional objects.
1584
+ """
1538
1585
  import tempfile
1539
1586
 
1540
1587
  assert self.storage_manager is not None
1541
1588
  fd, tmp = tempfile.mkstemp(suffix=".yml")
1542
1589
  os.close(fd)
1543
1590
  try:
1544
- if not self.storage_manager.download_file(self.state_bucket, key, tmp):
1591
+ if not self.storage_manager.download_file(self.state_bucket, key, tmp, retry_not_found=not may_be_absent):
1545
1592
  return None
1546
1593
  with open(tmp) as f:
1547
1594
  data = yaml.safe_load(f)
@@ -1764,7 +1811,7 @@ class RemoteDevManager:
1764
1811
  seen.add(record["name"])
1765
1812
 
1766
1813
  if owner is None:
1767
- legacy = self._read_yaml_object(f"{self.state_prefix}/state.yml") or {}
1814
+ legacy = self._read_yaml_object(f"{self.state_prefix}/state.yml", may_be_absent=True) or {}
1768
1815
  for entry in legacy.get("environments") or []:
1769
1816
  if entry.get("name") not in seen:
1770
1817
  environments.append(entry)
@@ -2344,6 +2391,8 @@ class RemoteDevEnvironment:
2344
2391
  clones = git_cfg.get("clone_repos") or []
2345
2392
  has_github_pat = bool(project.get_vars("github_pat"))
2346
2393
  has_gitlab_pat = bool(project.get_vars("gitlab_pat"))
2394
+ from cli.encrypt import detect_git_provider
2395
+
2347
2396
  missing = []
2348
2397
  for item in clones:
2349
2398
  if not isinstance(item, dict):
@@ -2354,9 +2403,10 @@ class RemoteDevEnvironment:
2354
2403
  pat_var = item.get("password_var") or ""
2355
2404
  if pat_var and project.get_vars(str(pat_var)):
2356
2405
  continue
2357
- if "gitlab.com" in repo and has_gitlab_pat:
2406
+ is_gitlab = detect_git_provider(repo) == "gitlab"
2407
+ if is_gitlab and has_gitlab_pat:
2358
2408
  continue
2359
- if "gitlab.com" not in repo and has_github_pat:
2409
+ if not is_gitlab and has_github_pat:
2360
2410
  continue
2361
2411
  missing.append(item.get("dest") or repo)
2362
2412
  if missing and "materialize" in wanted:
@@ -4389,7 +4439,7 @@ AUTHORIZE_PLAYBOOK = r"""---
4389
4439
  . /root/.config/rig/git-provider.env
4390
4440
  case "$host" in
4391
4441
  github.com) user=x-access-token; pass="${GH_TOKEN:-}" ;;
4392
- gitlab.com) user=oauth2; pass="${GITLAB_TOKEN:-}" ;;
4442
+ gitlab.com|*gitlab*) user=oauth2; pass="${GITLAB_TOKEN:-}" ;;
4393
4443
  *) exit 0 ;;
4394
4444
  esac
4395
4445
  [ -n "$pass" ] || exit 0
@@ -4432,13 +4482,13 @@ MATERIALIZE_PLAYBOOK = """---
4432
4482
  # Fall back to provider default vault vars when password_var was skipped at init.
4433
4483
  _provider_pat: >-
4434
4484
  {{ (gitlab_pat | default(''))
4435
- if ('gitlab.com' in (item.repo | default('')))
4485
+ if ((item.repo | default('')) is match('^(https?://)?([^/@]+@)?[^/]*gitlab'))
4436
4486
  else (github_pat | default('')) }}
4437
4487
  _pat: >-
4438
4488
  {{ (lookup('vars', _pat_var, default='') if _pat_var else '')
4439
4489
  or _provider_pat }}
4440
4490
  # GitHub expects x-access-token; GitLab expects oauth2.
4441
- _auth_user: "{{ 'oauth2' if ('gitlab.com' in item.repo) else 'x-access-token' }}"
4491
+ _auth_user: "{{ 'oauth2' if (item.repo is match('^(https?://)?([^/@]+@)?[^/]*gitlab')) else 'x-access-token' }}"
4442
4492
  environment:
4443
4493
  # Never hang on an interactive username/password prompt (missing PAT).
4444
4494
  GIT_TERMINAL_PROMPT: "0"
@@ -4523,6 +4573,7 @@ class ProjectConfig:
4523
4573
  self.rig_dir = os.path.join(self.project_dir, self.RIG_DIR)
4524
4574
  self.config: dict[str, Any] = {}
4525
4575
  self.vars_config: dict[str, Any] = {}
4576
+ self._personal_var_keys: set[str] = set()
4526
4577
  self.requirements: list[str] = []
4527
4578
  self.vault_password: str | None = None
4528
4579
 
@@ -4672,10 +4723,14 @@ class ProjectConfig:
4672
4723
  personal = self._load_vars_with_vault(id_path)
4673
4724
  for key in ("rig_identity_data_key", "rig_shared_data_key"):
4674
4725
  personal.pop(key, None)
4726
+ self._personal_var_keys = set(personal)
4675
4727
  self.vars_config = {**(self.vars_config or {}), **personal}
4676
4728
  except Exception:
4677
4729
  pass
4678
4730
 
4731
+ self._adopt_legacy_repo_fields()
4732
+ self.vars_config = {**(self.vars_config or {}), **self.derived_vars()}
4733
+
4679
4734
  requirements_path = os.path.join(self.rig_dir, self.REQUIREMENTS_YML)
4680
4735
  legacy_requirements = os.path.join(self.rig_dir, "requirements.txt")
4681
4736
  if os.path.exists(requirements_path):
@@ -4769,10 +4824,55 @@ class ProjectConfig:
4769
4824
  print(f"Warning: Could not load vars with vault: {e}")
4770
4825
  return {}
4771
4826
 
4827
+ def derived_vars(self) -> dict[str, Any]:
4828
+ """Vars computed from rig.yml (see ``derive_config_vars``)."""
4829
+ return derive_config_vars(self.config)
4830
+
4831
+ def _adopt_legacy_repo_fields(self) -> None:
4832
+ """Move per-repo fields that older versions kept only in vars.yml into rig.yml."""
4833
+ repos = self.config.get("repos") if isinstance(self.config, dict) else None
4834
+ legacy = ((self.vars_config or {}).get("git") or {}) if isinstance(self.vars_config, dict) else {}
4835
+ if not repos or not isinstance(legacy, dict):
4836
+ return
4837
+ from cli.encrypt import to_https_git_url
4838
+
4839
+ by_url: dict[str, dict[str, Any]] = {}
4840
+ for key in ("clone_repos", "ssh_repos"):
4841
+ for item in legacy.get(key) or []:
4842
+ if isinstance(item, dict) and item.get("repo"):
4843
+ by_url[str(item["repo"])] = item
4844
+ by_url[to_https_git_url(str(item["repo"]))] = item
4845
+ for repo in repos:
4846
+ if not isinstance(repo, dict) or repo.get("password_var"):
4847
+ continue
4848
+ item = by_url.get(str(repo.get("url") or ""))
4849
+ if item and item.get("password_var"):
4850
+ repo["password_var"] = item["password_var"]
4851
+
4772
4852
  def _dump_vars(self, vars_path: str) -> None:
4853
+ """Write shared vars.yml; personal and rig.yml-derived keys stay out."""
4854
+ data = self.vars_config
4855
+ if isinstance(data, dict):
4856
+ # Declared in rig.yml → derived at load/run time, not repeated here.
4857
+ derived = self.derived_vars()
4858
+ data = {k: v for k, v in data.items() if k not in derived}
4859
+ personal_keys = getattr(self, "_personal_var_keys", None)
4860
+ if personal_keys and isinstance(data, dict):
4861
+ shared_on_disk: dict[str, Any] = {}
4862
+ if os.path.exists(vars_path):
4863
+ try:
4864
+ with open(vars_path, encoding="utf-8") as existing:
4865
+ shared_on_disk = yaml.load(existing, Loader=_VarsLoader) or {}
4866
+ except Exception:
4867
+ shared_on_disk = {}
4868
+ data = {k: v for k, v in data.items() if k not in personal_keys}
4869
+ # A personal value may shadow a shared one: keep the shared one as it was.
4870
+ for key in personal_keys:
4871
+ if key in shared_on_disk:
4872
+ data[key] = shared_on_disk[key]
4773
4873
  with open(vars_path, "w", encoding="utf-8") as handle:
4774
4874
  yaml.dump(
4775
- self.vars_config,
4875
+ data,
4776
4876
  handle,
4777
4877
  Dumper=_VarsDumper,
4778
4878
  default_flow_style=False,
@@ -5307,9 +5407,21 @@ def resolve_init_context(start: str | None = None) -> dict[str, Any]:
5307
5407
  "in_git_repo": True,
5308
5408
  }
5309
5409
 
5410
+ projects = discover_git_projects(start)
5411
+ # Nothing at or below start: look at neighbouring folders, up to two levels up.
5412
+ ancestor = start
5413
+ for _ in range(2):
5414
+ if projects:
5415
+ break
5416
+ parent = os.path.dirname(ancestor)
5417
+ if not parent or parent == ancestor:
5418
+ break
5419
+ projects = [p for p in discover_git_projects(parent) if p["path"] not in (parent, start)]
5420
+ ancestor = parent
5421
+
5310
5422
  return {
5311
5423
  "root": start,
5312
- "projects": discover_git_projects(start),
5424
+ "projects": projects,
5313
5425
  "current": None,
5314
5426
  "in_git_repo": False,
5315
5427
  }
@@ -6386,6 +6498,11 @@ class AnsibleManager:
6386
6498
  cmd.extend(["-e", f"@{filtered_identity}"])
6387
6499
  vars_path = filtered_identity
6388
6500
 
6501
+ # Vars derived from rig.yml (git, git_providers, agent) are not in vars.yml.
6502
+ derived = self.project_config.derived_vars()
6503
+ if derived:
6504
+ cmd.extend(["-e", json.dumps(derived, default=str)])
6505
+
6389
6506
  if outputs_file:
6390
6507
  cmd.extend(["-e", f"rig_outputs_file={outputs_file}"])
6391
6508