mystack-rig 1.4.0__tar.gz → 1.6.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 (127) hide show
  1. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/CLI_STORAGE_SUMMARY.md +2 -2
  2. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/GLOSSARY.md +13 -1
  3. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/HETZNER_STORAGE_GUIDE.md +2 -2
  4. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/HETZNER_STORAGE_SECURITY_GUIDE.md +1 -1
  5. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/PKG-INFO +32 -1
  6. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/README.md +31 -0
  7. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/STORAGE_CLI_GUIDE.md +4 -4
  8. mystack_rig-1.6.0/docs/adr/0005-docker-in-configure-for-devcontainers.md +16 -0
  9. mystack_rig-1.6.0/sample.env +17 -0
  10. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/config.py +43 -24
  11. mystack_rig-1.6.0/src/cli/devcontainers.py +191 -0
  12. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/encrypt.py +15 -6
  13. mystack_rig-1.6.0/src/cli/last_target.py +52 -0
  14. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/main.py +58 -0
  15. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/remote_dev.py +148 -11
  16. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/snapshots.py +1 -0
  17. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/storage.py +46 -13
  18. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/mystack_rig.egg-info/PKG-INFO +32 -1
  19. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/mystack_rig.egg-info/SOURCES.txt +6 -0
  20. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/mystack_rig.egg-info/scm_file_list.json +6 -0
  21. mystack_rig-1.6.0/src/mystack_rig.egg-info/scm_version.json +8 -0
  22. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/conftest.py +6 -0
  23. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_dev_command.py +145 -0
  24. mystack_rig-1.6.0/tests/test_devcontainers.py +241 -0
  25. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_encrypt_coverage.py +16 -0
  26. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_init_command.py +182 -15
  27. mystack_rig-1.6.0/tests/test_last_target.py +52 -0
  28. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_outputs_storage.py +2 -2
  29. mystack_rig-1.6.0/tests/test_r2_storage.py +150 -0
  30. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_real_e2e_storage.py +11 -7
  31. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_remote_dev_coverage_extensions.py +1 -1
  32. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_rig_config.py +10 -10
  33. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_small_module_coverage.py +2 -2
  34. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_state_bucket.py +20 -1
  35. mystack_rig-1.4.0/sample.env +0 -12
  36. mystack_rig-1.4.0/src/mystack_rig.egg-info/scm_version.json +0 -8
  37. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/.coveragerc +0 -0
  38. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/.git-blame-ignore-revs +0 -0
  39. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/.github/workflows/release.yml +0 -0
  40. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/.github/workflows/tests.yml +0 -0
  41. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/.gitignore +0 -0
  42. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/.rig/playbooks/README.md +0 -0
  43. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/.rig/playbooks/vpn-gateway.yml +0 -0
  44. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/Dockerfile +0 -0
  45. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/GIT_CLONE_FEATURE.md +0 -0
  46. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/LICENSE +0 -0
  47. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/Makefile +0 -0
  48. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/README_REAL_E2E.md +0 -0
  49. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/docs/adr/0001-per-profile-generated-state-bucket.md +0 -0
  50. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/docs/adr/0002-outputs-as-separate-object-via-file-handoff.md +0 -0
  51. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/docs/adr/0003-mcp-servers-declared-once-rendered-at-authorize.md +0 -0
  52. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/docs/adr/0004-agents-run-as-live-agents-in-tmux.md +0 -0
  53. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/docs/architecture.md +0 -0
  54. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/docs/architecture.png +0 -0
  55. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/docs/architecture.svg +0 -0
  56. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/forged-idea.md +0 -0
  57. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/pyproject.toml +0 -0
  58. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/pytest.ini +0 -0
  59. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/requirements.txt +0 -0
  60. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/scripts/coverage_badge.py +0 -0
  61. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/scripts/pypi_version.py +0 -0
  62. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/setup.cfg +0 -0
  63. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/__init__.py +0 -0
  64. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/__init__.py +0 -0
  65. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/__main__.py +0 -0
  66. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/agents.py +0 -0
  67. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/ansible_filters/__init__.py +0 -0
  68. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/ansible_filters/rig_live.py +0 -0
  69. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/ansible_filters/rig_mcp.py +0 -0
  70. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/assets/rig-agent-queue +0 -0
  71. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/assets/rig-agent-state +0 -0
  72. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/assets/tmux.conf +0 -0
  73. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/git.py +0 -0
  74. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/git_author.py +0 -0
  75. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/last_env.py +0 -0
  76. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/last_session.py +0 -0
  77. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/live_agent.py +0 -0
  78. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/log.py +0 -0
  79. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/mcp.py +0 -0
  80. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/outputs.py +0 -0
  81. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/requirements.txt +0 -0
  82. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/state_bucket.py +0 -0
  83. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/vault_keys.py +0 -0
  84. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/cli/vpn.py +0 -0
  85. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/mystack_rig.egg-info/dependency_links.txt +0 -0
  86. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/mystack_rig.egg-info/entry_points.txt +0 -0
  87. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/mystack_rig.egg-info/requires.txt +0 -0
  88. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/src/mystack_rig.egg-info/top_level.txt +0 -0
  89. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/test_hetzner_integration.py +0 -0
  90. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_agents.py +0 -0
  91. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_ansible_galaxy.py +0 -0
  92. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_attach_command.py +0 -0
  93. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_credential_security.py +0 -0
  94. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_destroy_command.py +0 -0
  95. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_encrypt_command.py +0 -0
  96. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_firewall_client_ip.py +0 -0
  97. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_git_clone_unit.py +0 -0
  98. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_git_credentials_and_author.py +0 -0
  99. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_git_manager.py +0 -0
  100. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_gitignore_init.py +0 -0
  101. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_hetzner_storage.py +0 -0
  102. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_inspect_describe.py +0 -0
  103. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_last_env.py +0 -0
  104. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_last_session.py +0 -0
  105. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_live_agent.py +0 -0
  106. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_live_agent_cli.py +0 -0
  107. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_log.py +0 -0
  108. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_main_coverage.py +0 -0
  109. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_mcp_command.py +0 -0
  110. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_mcp_render.py +0 -0
  111. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_outputs.py +0 -0
  112. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_pypi_version.py +0 -0
  113. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_python_floor.py +0 -0
  114. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_real_e2e_integration.py +0 -0
  115. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_real_e2e_vpn.py +0 -0
  116. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_real_e2e_vpn_tunnel.py +0 -0
  117. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_remote_dev.py +0 -0
  118. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_rig_ansible_vars.py +0 -0
  119. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_secret_prompt_hidden.py +0 -0
  120. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_setup_provision.py +0 -0
  121. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_simulation_storage.py +0 -0
  122. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_snapshots.py +0 -0
  123. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_storage_basic.py +0 -0
  124. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_vault_keys.py +0 -0
  125. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_vpn_optional.py +0 -0
  126. {mystack_rig-1.4.0 → mystack_rig-1.6.0}/tests/test_vpn_unit.py +0 -0
  127. {mystack_rig-1.4.0 → mystack_rig-1.6.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
@@ -51,3 +55,11 @@ _Avoid_: Plugin, tool, integration
51
55
  **MCP variable**:
52
56
  A named value an MCP server needs at runtime, resolved from the vaulted variable whose name matches it ignoring case.
53
57
  _Avoid_: MCP secret, MCP env
58
+
59
+ **Dev Container**:
60
+ One `devcontainer.json` definition found in a Repo, describing the container its code is developed in.
61
+ _Avoid_: Project, devbox
62
+
63
+ **Dev target**:
64
+ The Repo and Dev Container pair that `rig dev` opens on an Environment.
65
+ _Avoid_: Project, selection
@@ -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.6.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.
@@ -155,6 +164,23 @@ The prompt reaches the VM on stdin and a private temporary file that is deleted
155
164
 
156
165
  Chosen at `rig init` (`editor.enabled` in `rig.yml`, same multi-select as git projects: numbers, names, or `all`). When more than one is selected, init asks which is the default for `rig dev` (`editor.default`). Pass `--editor` to open another enabled one. These are local clients: nothing extra is installed on the VM, and each IDE downloads its own remote server the first time it connects. Browser login: `rig vars decrypt vscode_browser_password`.
157
166
 
167
+ ### Dev Containers
168
+
169
+ Set `editor.devcontainers: true` and `rig dev` looks for Dev Containers in your Repos on the VM (each Repo's root and its immediate subfolders: `.devcontainer/devcontainer.json`, `.devcontainer.json`, `.devcontainer/<name>/devcontainer.json`). One match opens straight away, several give a numbered prompt, none opens the plain folder.
170
+
171
+ - `rig dev --target api` or `--target api:backend` skips the prompt; `--select` forces it. The last choice per Environment is remembered in `/tmp/.rig/targets/`.
172
+ - Not supported with `--browser`. Agents still run on the VM, not in the container.
173
+ - Docker is installed in the configure Stage and cached in the snapshot, so turning the flag on rebuilds the Workspace's snapshot once. New Workspaces get the task in `.rig/configure.yml`. **Existing Workspaces** must add it themselves, and existing Environments must be re-created:
174
+
175
+ ```yaml
176
+ - name: Install Docker for Dev Containers
177
+ include_role:
178
+ name: geerlingguy.docker
179
+ when: install_docker | default(false)
180
+ ```
181
+
182
+ See [ADR 0005](docs/adr/0005-docker-in-configure-for-devcontainers.md).
183
+
158
184
  ## Layout
159
185
 
160
186
  `rig init` writes commit-friendly files into the current directory (including a subdirectory of a git repo):
@@ -201,6 +227,7 @@ agent:
201
227
  editor:
202
228
  default: code # default for `rig dev`
203
229
  enabled: [code] # local IDEs `rig dev --editor` may open
230
+ devcontainers: false # true: `rig dev` opens a Dev Container (see below)
204
231
  playbooks:
205
232
  provision: .rig/provision.yml
206
233
  configure: .rig/configure.yml
@@ -388,6 +415,10 @@ See `docs/adr/0002-outputs-as-separate-object-via-file-handoff.md`.
388
415
  | `/tmp/.rig/.personal-data-key` / `.shared-data-key` | Materialized Ansible vault passwords after unlock (tmpfs). |
389
416
  | `/tmp/<env>-key` | Per-env SSH private key (attach / apply / delete finalizers). |
390
417
 
418
+ ### State backend: Hetzner Object Storage or Cloudflare R2
419
+
420
+ 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.
421
+
391
422
  `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
423
 
393
424
  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.
@@ -133,6 +142,23 @@ The prompt reaches the VM on stdin and a private temporary file that is deleted
133
142
 
134
143
  Chosen at `rig init` (`editor.enabled` in `rig.yml`, same multi-select as git projects: numbers, names, or `all`). When more than one is selected, init asks which is the default for `rig dev` (`editor.default`). Pass `--editor` to open another enabled one. These are local clients: nothing extra is installed on the VM, and each IDE downloads its own remote server the first time it connects. Browser login: `rig vars decrypt vscode_browser_password`.
135
144
 
145
+ ### Dev Containers
146
+
147
+ Set `editor.devcontainers: true` and `rig dev` looks for Dev Containers in your Repos on the VM (each Repo's root and its immediate subfolders: `.devcontainer/devcontainer.json`, `.devcontainer.json`, `.devcontainer/<name>/devcontainer.json`). One match opens straight away, several give a numbered prompt, none opens the plain folder.
148
+
149
+ - `rig dev --target api` or `--target api:backend` skips the prompt; `--select` forces it. The last choice per Environment is remembered in `/tmp/.rig/targets/`.
150
+ - Not supported with `--browser`. Agents still run on the VM, not in the container.
151
+ - Docker is installed in the configure Stage and cached in the snapshot, so turning the flag on rebuilds the Workspace's snapshot once. New Workspaces get the task in `.rig/configure.yml`. **Existing Workspaces** must add it themselves, and existing Environments must be re-created:
152
+
153
+ ```yaml
154
+ - name: Install Docker for Dev Containers
155
+ include_role:
156
+ name: geerlingguy.docker
157
+ when: install_docker | default(false)
158
+ ```
159
+
160
+ See [ADR 0005](docs/adr/0005-docker-in-configure-for-devcontainers.md).
161
+
136
162
  ## Layout
137
163
 
138
164
  `rig init` writes commit-friendly files into the current directory (including a subdirectory of a git repo):
@@ -179,6 +205,7 @@ agent:
179
205
  editor:
180
206
  default: code # default for `rig dev`
181
207
  enabled: [code] # local IDEs `rig dev --editor` may open
208
+ devcontainers: false # true: `rig dev` opens a Dev Container (see below)
182
209
  playbooks:
183
210
  provision: .rig/provision.yml
184
211
  configure: .rig/configure.yml
@@ -366,6 +393,10 @@ See `docs/adr/0002-outputs-as-separate-object-via-file-handoff.md`.
366
393
  | `/tmp/.rig/.personal-data-key` / `.shared-data-key` | Materialized Ansible vault passwords after unlock (tmpfs). |
367
394
  | `/tmp/<env>-key` | Per-env SSH private key (attach / apply / delete finalizers). |
368
395
 
396
+ ### State backend: Hetzner Object Storage or Cloudflare R2
397
+
398
+ 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.
399
+
369
400
  `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
401
 
371
402
  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,16 @@
1
+ # Docker for Dev Containers is installed in configure, behind an opt-in
2
+
3
+ When `editor.devcontainers` is true in `rig.yml`, the configure Stage installs Docker (the `geerlingguy.docker` role already in the default requirements), so it is baked into the snapshot and new Environments start with it ready. The flag is off by default and adds nothing to configure when false, so Workspaces that do not use Dev Containers keep their snapshots and pay nothing.
4
+
5
+ ## Considered Options
6
+
7
+ - **Install Docker at materialize**: rejected. Materialize is not snapshot-cached, so it would reach already-running Environments, but every create would pay the Docker install time again. Dev Containers are used on every Environment of a Workspace that enables them, which is what the snapshot cache is for.
8
+ - **Install Docker unconditionally in configure**: rejected. It would change the system hash and invalidate every Workspace's snapshot, including those that never use Dev Containers.
9
+
10
+ ## Consequences
11
+
12
+ - Enabling `editor.devcontainers` changes the system hash, so the Workspace's snapshot is rebuilt once.
13
+ - Environments created before the flag was enabled have no Docker. `rig dev` warns, names the cause, says to re-create the Environment, and falls back to a plain Remote-SSH open. An explicit `--target` fails instead.
14
+ - `.rig/configure.yml` is the Workspace's own file, so rig cannot add the Docker task to an existing one. New Workspaces get it from the default playbook, and existing ones add it by hand (see the README).
15
+ - Disabling the flag later does not remove Docker from existing Environments or snapshots.
16
+ - Dev Container support is editor-only. Agents still run on the host (ADR 0004), not in the container.
@@ -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()
@@ -0,0 +1,191 @@
1
+ """Dev Containers: discovery and selection of the Dev target `rig dev` opens."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import os
7
+ import posixpath
8
+ import re
9
+ import shlex
10
+ from collections.abc import Callable, Sequence
11
+ from dataclasses import dataclass
12
+
13
+
14
+ @dataclass(frozen=True)
15
+ class DevTarget:
16
+ """A Repo plus one Dev Container in it.
17
+
18
+ ``config`` is the ``devcontainer.json`` path relative to the Repo root.
19
+ """
20
+
21
+ repo: str
22
+ config: str
23
+
24
+ @property
25
+ def name(self) -> str:
26
+ """The container's name within its Repo ('' for the default one).
27
+
28
+ A subfolder prefixes the name: ``svc/x`` is ``svc/.devcontainer/x/``.
29
+ """
30
+ parts = self.config.split("/")
31
+ sub = parts[0] if len(parts) > 1 and not parts[0].startswith(".devcontainer") else ""
32
+ rest = parts[1:] if sub else parts
33
+ named = rest[1] if len(rest) == 3 else "" # .devcontainer/<name>/devcontainer.json
34
+ return "/".join(p for p in (sub, named) if p)
35
+
36
+ @property
37
+ def label(self) -> str:
38
+ return f"{self.repo}:{self.name}" if self.name else self.repo
39
+
40
+
41
+ class DevContainerError(Exception):
42
+ """A Dev target could not be chosen."""
43
+
44
+
45
+ # `<repo>/[<subfolder>/]` then one of the three locations the Dev Containers spec defines.
46
+ _CONFIG_RE = re.compile(
47
+ r"^(?:(?P<sub>[^/]+)/)?"
48
+ r"(?:\.devcontainer/(?:[^/]+/)?devcontainer\.json|\.devcontainer\.json)$"
49
+ )
50
+ _SKIPPED_DIRS = ("node_modules", ".git")
51
+
52
+
53
+ def _scan_command(dest: str) -> str:
54
+ skipped = " -o ".join(f"-name {d}" for d in _SKIPPED_DIRS)
55
+ return (
56
+ f"find {shlex.quote(dest)} -maxdepth 4 \\( {skipped} \\) -prune -o "
57
+ r"-type f \( -name devcontainer.json -o -name .devcontainer.json \) -print"
58
+ )
59
+
60
+
61
+ def find_devcontainers(
62
+ run_remote: Callable[[str], str],
63
+ repos: Sequence[tuple[str, str]],
64
+ ) -> list[DevTarget]:
65
+ """List the Dev Containers in each ``(repo name, remote path)``.
66
+
67
+ Looks in the Repo root and its immediate subfolders only.
68
+ """
69
+ found: list[DevTarget] = []
70
+ for name, dest in repos:
71
+ for line in run_remote(_scan_command(dest)).splitlines():
72
+ line = line.strip()
73
+ if not line.startswith(dest.rstrip("/") + "/"):
74
+ continue
75
+ config = os.path.relpath(line, dest)
76
+ match = _CONFIG_RE.match(config)
77
+ if not match or match.group("sub") in _SKIPPED_DIRS:
78
+ continue
79
+ found.append(DevTarget(name, config))
80
+ return sorted(found, key=lambda t: (t.repo, t.config))
81
+
82
+
83
+ def _listing(candidates: Sequence[DevTarget]) -> str:
84
+ return ", ".join(t.label for t in candidates)
85
+
86
+
87
+ def choose_target(
88
+ candidates: Sequence[DevTarget],
89
+ remembered: DevTarget | None,
90
+ requested: str | None,
91
+ select: bool,
92
+ interactive: bool,
93
+ input_fn: Callable[[str], str] = input,
94
+ ) -> DevTarget | None:
95
+ """Pick the Dev target to open, or None when there is no Dev Container.
96
+
97
+ ``requested`` is ``--target repo[:name]``. ``select`` forces the prompt.
98
+ """
99
+ if requested:
100
+ exact = [t for t in candidates if t.label == requested] if ":" in requested else []
101
+ in_repo = [t for t in candidates if t.repo == requested]
102
+ if exact:
103
+ return exact[0]
104
+ if len(in_repo) == 1:
105
+ return in_repo[0]
106
+ if not in_repo:
107
+ raise DevContainerError(f"No Dev Container matches '{requested}' (found: {_listing(candidates) or 'none'})")
108
+ candidates = in_repo
109
+ elif not candidates:
110
+ return None
111
+ elif len(candidates) == 1 and not select:
112
+ return candidates[0]
113
+
114
+ if not interactive:
115
+ raise DevContainerError(
116
+ f"Several Dev Containers found: {_listing(candidates)}. Pick one with --target <repo>[:<name>]"
117
+ )
118
+ default = candidates[0]
119
+ if remembered is not None and remembered in candidates:
120
+ default = remembered
121
+ for index, target in enumerate(candidates, 1):
122
+ print(f" {index}) {target.label}")
123
+ while True:
124
+ answer = input_fn(f"Open which Dev Container? [{default.label}] ").strip()
125
+ if not answer:
126
+ return default
127
+ if answer.isdigit() and 1 <= int(answer) <= len(candidates):
128
+ return candidates[int(answer) - 1]
129
+ named = [t for t in candidates if t.label == answer]
130
+ if named:
131
+ return named[0]
132
+ print(f"Not a choice: {answer}")
133
+
134
+
135
+ def devcontainer_folder_uri(alias: str, repo_dest: str, target: DevTarget) -> str:
136
+ """``--folder-uri`` that opens *target* in its container over Remote-SSH.
137
+
138
+ The folder holding the ``.devcontainer`` definition is the container's host
139
+ path, and the editor mounts it at ``/workspaces/<folder name>``.
140
+ """
141
+ config = posixpath.join(repo_dest, target.config)
142
+ # "" for the repo root, "sub/" for a subfolder
143
+ prefix = target.config.split(".devcontainer")[0]
144
+ host_path = posixpath.join(repo_dest, prefix).rstrip("/")
145
+ payload = {
146
+ "hostPath": host_path,
147
+ "configFile": {
148
+ "$mid": 1,
149
+ "path": config,
150
+ "scheme": "vscode-remote",
151
+ "authority": f"ssh-remote+{alias}",
152
+ },
153
+ }
154
+ encoded = json.dumps(payload, separators=(",", ":")).encode().hex()
155
+ return f"vscode-remote://dev-container+{encoded}@ssh-remote+{alias}/workspaces/{posixpath.basename(host_path)}"
156
+
157
+
158
+ class DevContainerScanError(DevContainerError):
159
+ """The Environment could not be searched for Dev Containers."""
160
+
161
+
162
+ def devcontainers_enabled(config: dict | None) -> bool:
163
+ """``editor.devcontainers`` in rig.yml (off by default)."""
164
+ editor = (config or {}).get("editor")
165
+ return isinstance(editor, dict) and editor.get("devcontainers") is True
166
+
167
+
168
+ def repo_destinations(config: dict | None, root: str) -> list[tuple[str, str]]:
169
+ """``(name, remote path)`` of every Repo in rig.yml."""
170
+ found = []
171
+ for item in (config or {}).get("repos") or []:
172
+ if isinstance(item, dict) and item.get("name"):
173
+ name = str(item["name"])
174
+ found.append((name, str(item.get("dest") or posixpath.join(root, name))))
175
+ return found
176
+
177
+
178
+ def scan_environment(env, repos: Sequence[tuple[str, str]]) -> list[DevTarget]:
179
+ """Find the Dev Containers in *repos* on *env*'s VM over SSH."""
180
+
181
+ def run_remote(command: str) -> str:
182
+ try:
183
+ result = env.run_remote(command)
184
+ except Exception as exc: # ssh missing, timeout, ...
185
+ raise DevContainerScanError(f"could not reach the Environment: {exc}") from exc
186
+ if result.returncode != 0:
187
+ detail = (result.stderr or "").strip() or f"exit {result.returncode}"
188
+ raise DevContainerScanError(f"scan failed: {detail}")
189
+ return result.stdout
190
+
191
+ return find_devcontainers(run_remote, repos)
@@ -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