mystack-rig 1.7.1__tar.gz → 1.7.3__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.
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/PKG-INFO +4 -2
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/README.md +3 -1
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/devcontainers.py +75 -6
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/remote_dev.py +57 -3
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/mystack_rig.egg-info/PKG-INFO +4 -2
- mystack_rig-1.7.3/src/mystack_rig.egg-info/scm_version.json +8 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_devcontainers.py +55 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_git_credentials_and_author.py +67 -3
- mystack_rig-1.7.1/src/mystack_rig.egg-info/scm_version.json +0 -8
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/.coveragerc +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/.git-blame-ignore-revs +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/.github/workflows/release.yml +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/.github/workflows/tests.yml +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/.gitignore +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/.rig/playbooks/README.md +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/.rig/playbooks/vpn-gateway.yml +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/CLAUDE.md +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/CLI_STORAGE_SUMMARY.md +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/Dockerfile +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/GIT_CLONE_FEATURE.md +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/GLOSSARY.md +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/HETZNER_STORAGE_GUIDE.md +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/HETZNER_STORAGE_SECURITY_GUIDE.md +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/LICENSE +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/Makefile +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/README_REAL_E2E.md +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/STORAGE_CLI_GUIDE.md +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/docs/adr/0001-per-profile-generated-state-bucket.md +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/docs/adr/0002-outputs-as-separate-object-via-file-handoff.md +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/docs/adr/0003-mcp-servers-declared-once-rendered-at-authorize.md +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/docs/adr/0004-agents-run-as-live-agents-in-tmux.md +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/docs/adr/0005-docker-in-configure-for-devcontainers.md +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/docs/adr/0006-workspace-user-instead-of-root.md +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/docs/architecture.md +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/docs/architecture.png +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/docs/architecture.svg +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/forged-idea.md +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/pyproject.toml +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/pytest.ini +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/requirements.txt +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/sample.env +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/scripts/coverage_badge.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/scripts/pypi_version.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/setup.cfg +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/__init__.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/__init__.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/__main__.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/agents.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/ansible_filters/__init__.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/ansible_filters/rig_live.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/ansible_filters/rig_mcp.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/assets/rig-agent-queue +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/assets/rig-agent-state +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/assets/tmux.conf +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/config.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/encrypt.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/git.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/git_author.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/last_env.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/last_session.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/last_target.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/live_agent.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/log.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/main.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/mcp.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/outputs.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/requirements.txt +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/snapshots.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/state_bucket.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/storage.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/vault_keys.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/vpn.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/cli/workspace_user.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/mystack_rig.egg-info/SOURCES.txt +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/mystack_rig.egg-info/dependency_links.txt +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/mystack_rig.egg-info/entry_points.txt +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/mystack_rig.egg-info/requires.txt +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/mystack_rig.egg-info/scm_file_list.json +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/src/mystack_rig.egg-info/top_level.txt +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/test_hetzner_integration.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/conftest.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_agents.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_ansible_galaxy.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_attach_command.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_credential_security.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_destroy_command.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_dev_command.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_encrypt_command.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_encrypt_coverage.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_firewall_client_ip.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_git_clone_unit.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_git_manager.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_gitignore_init.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_hetzner_storage.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_init_command.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_inspect_describe.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_last_env.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_last_session.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_last_target.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_live_agent.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_live_agent_cli.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_log.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_main_coverage.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_mcp_command.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_mcp_render.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_outputs.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_outputs_storage.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_pypi_version.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_python_floor.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_r2_storage.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_real_e2e_integration.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_real_e2e_storage.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_real_e2e_vpn.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_real_e2e_vpn_tunnel.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_remote_dev.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_remote_dev_coverage_extensions.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_rig_ansible_vars.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_rig_config.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_secret_prompt_hidden.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_setup_provision.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_simulation_storage.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_small_module_coverage.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_snapshots.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_state_bucket.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_storage_basic.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_vault_keys.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_vpn_optional.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_vpn_unit.py +0 -0
- {mystack_rig-1.7.1 → mystack_rig-1.7.3}/tests/test_workspace_git_clone.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mystack-rig
|
|
3
|
-
Version: 1.7.
|
|
3
|
+
Version: 1.7.3
|
|
4
4
|
Summary: Ephemeral remotes with full local parity for coding agents
|
|
5
5
|
Author: mystack-cloud
|
|
6
6
|
License-Expression: MIT
|
|
@@ -481,7 +481,9 @@ MIT
|
|
|
481
481
|
shell, which never reads `/etc/profile.d`), so `gh` and `glab` work out of the
|
|
482
482
|
box in both;
|
|
483
483
|
- a system-wide git credential helper (`/usr/local/bin/rig-git-credential`)
|
|
484
|
-
answers `github.com` / `gitlab.com` HTTPS requests from that same file,
|
|
484
|
+
answers `github.com` / `gitlab.com` HTTPS requests from that same file (and, for a
|
|
485
|
+
Repo with its own `password_var` such as `<project>_git_pat`, requests to that
|
|
486
|
+
Repo's host from `~/.config/rig/git-hosts`), so
|
|
485
487
|
`git clone`, `git push` and the `materialize.yml` clone task all use plain
|
|
486
488
|
URLs (`https://github.com/org/repo.git`) and nothing sits in `.git/config`
|
|
487
489
|
or `git remote -v`. Other users on the VM (besides root) can't read the file and get no
|
|
@@ -459,7 +459,9 @@ MIT
|
|
|
459
459
|
shell, which never reads `/etc/profile.d`), so `gh` and `glab` work out of the
|
|
460
460
|
box in both;
|
|
461
461
|
- a system-wide git credential helper (`/usr/local/bin/rig-git-credential`)
|
|
462
|
-
answers `github.com` / `gitlab.com` HTTPS requests from that same file,
|
|
462
|
+
answers `github.com` / `gitlab.com` HTTPS requests from that same file (and, for a
|
|
463
|
+
Repo with its own `password_var` such as `<project>_git_pat`, requests to that
|
|
464
|
+
Repo's host from `~/.config/rig/git-hosts`), so
|
|
463
465
|
`git clone`, `git push` and the `materialize.yml` clone task all use plain
|
|
464
466
|
URLs (`https://github.com/org/repo.git`) and nothing sits in `.git/config`
|
|
465
467
|
or `git remote -v`. Other users on the VM (besides root) can't read the file and get no
|
|
@@ -137,16 +137,84 @@ def choose_target(
|
|
|
137
137
|
print(f"Not a choice: {answer}")
|
|
138
138
|
|
|
139
139
|
|
|
140
|
-
def
|
|
141
|
-
"""
|
|
140
|
+
def _strip_jsonc(text: str) -> str:
|
|
141
|
+
"""Drop ``//`` and ``/* */`` comments and trailing commas (devcontainer.json is JSONC)."""
|
|
142
|
+
out: list[str] = []
|
|
143
|
+
i, n, in_str = 0, len(text), False
|
|
144
|
+
while i < n:
|
|
145
|
+
c = text[i]
|
|
146
|
+
if in_str:
|
|
147
|
+
out.append(c)
|
|
148
|
+
if c == "\\" and i + 1 < n:
|
|
149
|
+
out.append(text[i + 1])
|
|
150
|
+
i += 1
|
|
151
|
+
elif c == '"':
|
|
152
|
+
in_str = False
|
|
153
|
+
elif c == '"':
|
|
154
|
+
in_str = True
|
|
155
|
+
out.append(c)
|
|
156
|
+
elif text.startswith("//", i):
|
|
157
|
+
while i < n and text[i] != "\n":
|
|
158
|
+
i += 1
|
|
159
|
+
continue
|
|
160
|
+
elif text.startswith("/*", i):
|
|
161
|
+
end = text.find("*/", i + 2)
|
|
162
|
+
i = n if end < 0 else end + 2
|
|
163
|
+
continue
|
|
164
|
+
else:
|
|
165
|
+
out.append(c)
|
|
166
|
+
i += 1
|
|
167
|
+
return re.sub(r",(\s*[}\]])", r"\1", "".join(out))
|
|
142
168
|
|
|
143
|
-
|
|
144
|
-
|
|
169
|
+
|
|
170
|
+
def parse_workspace_folder(config_text: str, host_path: str) -> str | None:
|
|
171
|
+
"""``workspaceFolder`` from a devcontainer.json's text, or None when unset or unusable.
|
|
172
|
+
|
|
173
|
+
Resolves ``${localWorkspaceFolder}`` and ``${localWorkspaceFolderBasename}``;
|
|
174
|
+
anything else that is not an absolute path is ignored.
|
|
175
|
+
"""
|
|
176
|
+
try:
|
|
177
|
+
data = json.loads(_strip_jsonc(config_text))
|
|
178
|
+
except ValueError:
|
|
179
|
+
return None
|
|
180
|
+
value = data.get("workspaceFolder") if isinstance(data, dict) else None
|
|
181
|
+
if not isinstance(value, str):
|
|
182
|
+
return None
|
|
183
|
+
value = value.replace("${localWorkspaceFolderBasename}", posixpath.basename(host_path))
|
|
184
|
+
value = value.replace("${localWorkspaceFolder}", host_path)
|
|
185
|
+
return value if value.startswith("/") and "${" not in value else None
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def read_workspace_folder(env, repo_dest: str, target: DevTarget) -> str | None:
|
|
189
|
+
"""The ``workspaceFolder`` *target*'s devcontainer.json sets, read from *env*'s VM over SSH.
|
|
190
|
+
|
|
191
|
+
None when it is unset or the file can't be read, so the caller falls back to the default.
|
|
145
192
|
"""
|
|
146
193
|
config = posixpath.join(repo_dest, target.config)
|
|
194
|
+
try:
|
|
195
|
+
result = env.run_remote(f"cat {shlex.quote(config)}")
|
|
196
|
+
except Exception: # ssh missing, timeout, ...
|
|
197
|
+
return None
|
|
198
|
+
if result.returncode != 0:
|
|
199
|
+
return None
|
|
200
|
+
return parse_workspace_folder(result.stdout, _host_path(repo_dest, target))
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def _host_path(repo_dest: str, target: DevTarget) -> str:
|
|
147
204
|
# "" for the repo root, "sub/" for a subfolder
|
|
148
205
|
prefix = target.config.split(".devcontainer")[0]
|
|
149
|
-
|
|
206
|
+
return posixpath.join(repo_dest, prefix).rstrip("/")
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def devcontainer_folder_uri(alias: str, repo_dest: str, target: DevTarget, workspace_folder: str | None = None) -> str:
|
|
210
|
+
"""``--folder-uri`` that opens *target* in its container over Remote-SSH.
|
|
211
|
+
|
|
212
|
+
The folder holding the ``.devcontainer`` definition is the container's host
|
|
213
|
+
path. The editor opens the config's ``workspaceFolder`` when it sets one,
|
|
214
|
+
else the Dev Containers default ``/workspaces/<folder name>``.
|
|
215
|
+
"""
|
|
216
|
+
config = posixpath.join(repo_dest, target.config)
|
|
217
|
+
host_path = _host_path(repo_dest, target)
|
|
150
218
|
payload = {
|
|
151
219
|
"hostPath": host_path,
|
|
152
220
|
"configFile": {
|
|
@@ -157,7 +225,8 @@ def devcontainer_folder_uri(alias: str, repo_dest: str, target: DevTarget) -> st
|
|
|
157
225
|
},
|
|
158
226
|
}
|
|
159
227
|
encoded = json.dumps(payload, separators=(",", ":")).encode().hex()
|
|
160
|
-
|
|
228
|
+
folder = workspace_folder or f"/workspaces/{posixpath.basename(host_path)}"
|
|
229
|
+
return f"vscode-remote://dev-container+{encoded}@ssh-remote+{alias}{folder}"
|
|
161
230
|
|
|
162
231
|
|
|
163
232
|
class DevContainerScanError(DevContainerError):
|
|
@@ -698,6 +698,7 @@ def build_rig_ansible_vars(
|
|
|
698
698
|
except Exception:
|
|
699
699
|
identity = ""
|
|
700
700
|
author = {"name": "", "email": ""}
|
|
701
|
+
vars_out["rig_git_repo_tokens"] = git_repo_token_vars(project)
|
|
701
702
|
vars_out["rig_identity"] = identity
|
|
702
703
|
vars_out["rig_git_author_name"] = author["name"]
|
|
703
704
|
vars_out["rig_git_author_email"] = author["email"]
|
|
@@ -706,6 +707,32 @@ def build_rig_ansible_vars(
|
|
|
706
707
|
return vars_out
|
|
707
708
|
|
|
708
709
|
|
|
710
|
+
def git_repo_token_vars(project: Any) -> list[dict[str, str]]:
|
|
711
|
+
"""``{host, user, var}`` for each HTTPS clone Repo that has its own ``password_var``.
|
|
712
|
+
|
|
713
|
+
Only the variable *name* is passed on; authorize resolves the secret, so a
|
|
714
|
+
PAT stored per Repo (``<project>_git_pat``) reaches the VM's git credential
|
|
715
|
+
helper like ``github_pat`` / ``gitlab_pat`` do.
|
|
716
|
+
"""
|
|
717
|
+
if project is None:
|
|
718
|
+
return []
|
|
719
|
+
from cli.encrypt import _git_host, detect_git_provider
|
|
720
|
+
|
|
721
|
+
found: list[dict[str, str]] = []
|
|
722
|
+
for item in (project.get_vars("git") or {}).get("clone_repos") or []:
|
|
723
|
+
if not isinstance(item, dict):
|
|
724
|
+
continue
|
|
725
|
+
repo, var = str(item.get("repo") or ""), str(item.get("password_var") or "")
|
|
726
|
+
host = _git_host(repo)
|
|
727
|
+
if not (repo.startswith("https://") and var and host):
|
|
728
|
+
continue
|
|
729
|
+
user = "x-access-token" if detect_git_provider(repo) == "github" else "oauth2"
|
|
730
|
+
entry = {"host": host, "user": user, "var": var}
|
|
731
|
+
if entry not in found:
|
|
732
|
+
found.append(entry)
|
|
733
|
+
return found
|
|
734
|
+
|
|
735
|
+
|
|
709
736
|
def remote_workspace_path(*parts: str) -> str:
|
|
710
737
|
"""Build an absolute path under the remote workspace root."""
|
|
711
738
|
cleaned = [part.strip("/") for part in parts if part and str(part).strip("/")]
|
|
@@ -3640,9 +3667,11 @@ echo "Agent installation complete!"
|
|
|
3640
3667
|
alias = self.ensure_ssh_config_host(ssh_config_path=ssh_config_path)
|
|
3641
3668
|
folder_uri = f"vscode-remote://ssh-remote+{alias}{remote_path}"
|
|
3642
3669
|
if dev_target is not None and repo_dest:
|
|
3643
|
-
from cli.devcontainers import devcontainer_folder_uri
|
|
3670
|
+
from cli.devcontainers import devcontainer_folder_uri, read_workspace_folder
|
|
3644
3671
|
|
|
3645
|
-
folder_uri = devcontainer_folder_uri(
|
|
3672
|
+
folder_uri = devcontainer_folder_uri(
|
|
3673
|
+
alias, repo_dest, dev_target, read_workspace_folder(self, repo_dest, dev_target)
|
|
3674
|
+
)
|
|
3646
3675
|
remote_path = f"{dev_target.label} Dev Container"
|
|
3647
3676
|
cmd = [editor_bin, "--folder-uri", folder_uri]
|
|
3648
3677
|
log.info("Opening %s on %s (%s)", editor_bin, self.vm_ip, remote_path)
|
|
@@ -4512,7 +4541,7 @@ AUTHORIZE_PLAYBOOK = r"""---
|
|
|
4512
4541
|
vars:
|
|
4513
4542
|
_rig_gh_token: "{{ github_pat | default('') }}"
|
|
4514
4543
|
_rig_gl_token: "{{ gitlab_pat | default('') }}"
|
|
4515
|
-
when: (_rig_gh_token | length > 0) or (_rig_gl_token | length > 0)
|
|
4544
|
+
when: (_rig_gh_token | length > 0) or (_rig_gl_token | length > 0) or (rig_git_repo_tokens | default([]) | length > 0)
|
|
4516
4545
|
block:
|
|
4517
4546
|
- name: Ensure the rig config directory exists
|
|
4518
4547
|
file:
|
|
@@ -4533,6 +4562,21 @@ AUTHORIZE_PLAYBOOK = r"""---
|
|
|
4533
4562
|
{% endif %}
|
|
4534
4563
|
no_log: true
|
|
4535
4564
|
|
|
4565
|
+
# PATs stored per Repo (password_var, e.g. <project>_git_pat): one
|
|
4566
|
+
# "host user token" line each, for the credential helper below.
|
|
4567
|
+
- name: Write the per-repo token file (workspace user only)
|
|
4568
|
+
copy:
|
|
4569
|
+
dest: /home/{{ rig_user }}/.config/rig/git-hosts
|
|
4570
|
+
mode: "0600"
|
|
4571
|
+
content: |
|
|
4572
|
+
{% for t in rig_git_repo_tokens | default([]) %}
|
|
4573
|
+
{% set _tok = lookup('vars', t.var, default='') %}
|
|
4574
|
+
{% if _tok | length > 0 %}
|
|
4575
|
+
{{ t.host }} {{ t.user }} {{ _tok }}
|
|
4576
|
+
{% endif %}
|
|
4577
|
+
{% endfor %}
|
|
4578
|
+
no_log: true
|
|
4579
|
+
|
|
4536
4580
|
- name: Export the tokens in login shells (gh and glab work out of the box)
|
|
4537
4581
|
copy:
|
|
4538
4582
|
dest: /etc/profile.d/rig-git-provider.sh
|
|
@@ -4559,6 +4603,16 @@ AUTHORIZE_PLAYBOOK = r"""---
|
|
|
4559
4603
|
[ -z "$key" ] && break
|
|
4560
4604
|
[ "$key" = host ] && host="$value"
|
|
4561
4605
|
done
|
|
4606
|
+
# A token stored for this exact host (per-Repo password_var) wins.
|
|
4607
|
+
hosts=/home/{{ rig_user }}/.config/rig/git-hosts
|
|
4608
|
+
if [ -r "$hosts" ]; then
|
|
4609
|
+
while read -r h u p; do
|
|
4610
|
+
if [ "$h" = "$host" ] && [ -n "$p" ]; then
|
|
4611
|
+
printf 'username=%s\npassword=%s\n' "$u" "$p"
|
|
4612
|
+
exit 0
|
|
4613
|
+
fi
|
|
4614
|
+
done < "$hosts"
|
|
4615
|
+
fi
|
|
4562
4616
|
[ -r /home/{{ rig_user }}/.config/rig/git-provider.env ] || exit 0
|
|
4563
4617
|
. /home/{{ rig_user }}/.config/rig/git-provider.env
|
|
4564
4618
|
case "$host" in
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mystack-rig
|
|
3
|
-
Version: 1.7.
|
|
3
|
+
Version: 1.7.3
|
|
4
4
|
Summary: Ephemeral remotes with full local parity for coding agents
|
|
5
5
|
Author: mystack-cloud
|
|
6
6
|
License-Expression: MIT
|
|
@@ -481,7 +481,9 @@ MIT
|
|
|
481
481
|
shell, which never reads `/etc/profile.d`), so `gh` and `glab` work out of the
|
|
482
482
|
box in both;
|
|
483
483
|
- a system-wide git credential helper (`/usr/local/bin/rig-git-credential`)
|
|
484
|
-
answers `github.com` / `gitlab.com` HTTPS requests from that same file,
|
|
484
|
+
answers `github.com` / `gitlab.com` HTTPS requests from that same file (and, for a
|
|
485
|
+
Repo with its own `password_var` such as `<project>_git_pat`, requests to that
|
|
486
|
+
Repo's host from `~/.config/rig/git-hosts`), so
|
|
485
487
|
`git clone`, `git push` and the `materialize.yml` clone task all use plain
|
|
486
488
|
URLs (`https://github.com/org/repo.git`) and nothing sits in `.git/config`
|
|
487
489
|
or `git remote -v`. Other users on the VM (besides root) can't read the file and get no
|
|
@@ -198,6 +198,61 @@ def test_uri_for_subfolder_container_uses_that_folder_as_host_path():
|
|
|
198
198
|
assert folder == "/workspaces/svc"
|
|
199
199
|
|
|
200
200
|
|
|
201
|
+
def test_uri_opens_the_workspace_folder_the_config_sets():
|
|
202
|
+
from cli.devcontainers import devcontainer_folder_uri
|
|
203
|
+
|
|
204
|
+
uri = devcontainer_folder_uri("rig-env1", "/workspace/ops-box", API_DEFAULT, "/workspace")
|
|
205
|
+
_payload, _host, folder = _decode_uri(uri)
|
|
206
|
+
assert folder == "/workspace"
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
JSONC = """{
|
|
210
|
+
// the compose file mounts the parent directory
|
|
211
|
+
"name": "ops", /* c */
|
|
212
|
+
"url": "http://x//y",
|
|
213
|
+
"workspaceFolder": "/workspace/${localWorkspaceFolderBasename}",
|
|
214
|
+
}"""
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def test_parse_workspace_folder_handles_jsonc_and_variables():
|
|
218
|
+
from cli.devcontainers import parse_workspace_folder
|
|
219
|
+
|
|
220
|
+
assert parse_workspace_folder(JSONC, "/workspace/ops-box") == "/workspace/ops-box"
|
|
221
|
+
assert parse_workspace_folder('{"workspaceFolder": "${localWorkspaceFolder}/app"}', "/w/r") == "/w/r/app"
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def test_parse_workspace_folder_ignores_unset_relative_unknown_and_broken():
|
|
225
|
+
from cli.devcontainers import parse_workspace_folder
|
|
226
|
+
|
|
227
|
+
for text in ("{}", '{"workspaceFolder": "rel"}', '{"workspaceFolder": "${containerEnv:X}"}', "nope", "[]"):
|
|
228
|
+
assert parse_workspace_folder(text, "/w/r") is None
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def test_read_workspace_folder_reads_over_ssh_and_falls_back_on_failure():
|
|
232
|
+
import subprocess
|
|
233
|
+
from types import SimpleNamespace
|
|
234
|
+
|
|
235
|
+
from cli.devcontainers import read_workspace_folder
|
|
236
|
+
|
|
237
|
+
seen = []
|
|
238
|
+
|
|
239
|
+
def ok(cmd):
|
|
240
|
+
seen.append(cmd)
|
|
241
|
+
return subprocess.CompletedProcess(cmd, 0, stdout='{"workspaceFolder": "/workspace"}', stderr="")
|
|
242
|
+
|
|
243
|
+
assert read_workspace_folder(SimpleNamespace(run_remote=ok), "/workspace/api", API_DEFAULT) == "/workspace"
|
|
244
|
+
assert "/workspace/api/.devcontainer/devcontainer.json" in seen[0]
|
|
245
|
+
|
|
246
|
+
def bad(cmd):
|
|
247
|
+
return subprocess.CompletedProcess(cmd, 1, stdout="", stderr="no such file")
|
|
248
|
+
|
|
249
|
+
def boom(cmd):
|
|
250
|
+
raise OSError("ssh missing")
|
|
251
|
+
|
|
252
|
+
assert read_workspace_folder(SimpleNamespace(run_remote=bad), "/workspace/api", API_DEFAULT) is None
|
|
253
|
+
assert read_workspace_folder(SimpleNamespace(run_remote=boom), "/workspace/api", API_DEFAULT) is None
|
|
254
|
+
|
|
255
|
+
|
|
201
256
|
# --- Docker in configure (ADR 0005) -----------------------------------------
|
|
202
257
|
|
|
203
258
|
|
|
@@ -209,9 +209,8 @@ def _helper_script(tmp_path):
|
|
|
209
209
|
assert helper["copy"]["mode"] == "0755"
|
|
210
210
|
token_file = tmp_path / "git-provider.env"
|
|
211
211
|
script = tmp_path / "rig-git-credential"
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
)
|
|
212
|
+
content = helper["copy"]["content"].replace("/home/{{ rig_user }}/.config/rig/git-provider.env", str(token_file))
|
|
213
|
+
script.write_text(content.replace("/home/{{ rig_user }}/.config/rig/git-hosts", str(tmp_path / "git-hosts")))
|
|
215
214
|
script.chmod(script.stat().st_mode | stat.S_IXUSR)
|
|
216
215
|
return script, token_file
|
|
217
216
|
|
|
@@ -245,6 +244,71 @@ def test_helper_stays_silent_when_it_has_nothing_to_say(tmp_path):
|
|
|
245
244
|
assert _ask(script, "erase", "github.com") == ""
|
|
246
245
|
|
|
247
246
|
|
|
247
|
+
def test_helper_serves_a_per_repo_token_for_its_host(tmp_path):
|
|
248
|
+
"""A PAT stored per Repo (password_var) answers git pull, even on a host rig can't classify."""
|
|
249
|
+
script, token_file = _helper_script(tmp_path)
|
|
250
|
+
(tmp_path / "git-hosts").write_text("git.corp.example oauth2 glpat-repo\ngitlab.com oauth2 glpat-own\n")
|
|
251
|
+
token_file.write_text("GITLAB_TOKEN=glpat-default\n")
|
|
252
|
+
|
|
253
|
+
assert _ask(script, "get", "git.corp.example") == "username=oauth2\npassword=glpat-repo\n"
|
|
254
|
+
assert _ask(script, "get", "gitlab.com") == "username=oauth2\npassword=glpat-own\n" # per-repo wins
|
|
255
|
+
assert _ask(script, "get", "other.example") == ""
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def test_helper_without_provider_file_still_serves_per_repo_token(tmp_path):
|
|
259
|
+
script, _token_file = _helper_script(tmp_path)
|
|
260
|
+
(tmp_path / "git-hosts").write_text("gitlab.com oauth2 glpat-own\n")
|
|
261
|
+
|
|
262
|
+
assert _ask(script, "get", "gitlab.com") == "username=oauth2\npassword=glpat-own\n"
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
def test_authorize_writes_per_repo_tokens_from_their_vars():
|
|
266
|
+
import jinja2
|
|
267
|
+
|
|
268
|
+
block = _provider_block()
|
|
269
|
+
task = next(t for t in block if t["name"].startswith("Write the per-repo token file"))
|
|
270
|
+
assert task["copy"]["mode"] == "0600" and task["no_log"] is True
|
|
271
|
+
secrets = {"p_git_pat": "glpat-1", "unset": ""}
|
|
272
|
+
template = jinja2.Environment().from_string(task["copy"]["content"])
|
|
273
|
+
rendered = template.render(
|
|
274
|
+
lookup=lambda _kind, name, default="": secrets.get(name, default),
|
|
275
|
+
rig_git_repo_tokens=[
|
|
276
|
+
{"host": "gitlab.com", "user": "oauth2", "var": "p_git_pat"},
|
|
277
|
+
{"host": "x.example", "user": "oauth2", "var": "unset"},
|
|
278
|
+
],
|
|
279
|
+
)
|
|
280
|
+
assert rendered.strip() == "gitlab.com oauth2 glpat-1"
|
|
281
|
+
assert next(t for t in _authorize_tasks() if t["name"] == "Provider tokens for git, gh and glab")["when"].count(
|
|
282
|
+
"rig_git_repo_tokens"
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def test_git_repo_token_vars_lists_https_repos_with_their_own_password_var():
|
|
287
|
+
from cli.remote_dev import git_repo_token_vars
|
|
288
|
+
|
|
289
|
+
class Project:
|
|
290
|
+
def get_vars(self, key):
|
|
291
|
+
assert key == "git"
|
|
292
|
+
return {
|
|
293
|
+
"clone_repos": [
|
|
294
|
+
{"repo": "https://gitlab.com/o/a.git", "password_var": "a_git_pat"},
|
|
295
|
+
{"repo": "https://gitlab.com/o/a2.git", "password_var": "a_git_pat"},
|
|
296
|
+
{"repo": "https://github.com/o/b.git", "password_var": "b_git_pat"},
|
|
297
|
+
{"repo": "https://git.corp.example/o/c.git", "password_var": "c_git_pat"},
|
|
298
|
+
{"repo": "git@gitlab.com:o/d.git", "password_var": "d_git_pat"},
|
|
299
|
+
{"repo": "https://gitlab.com/o/e.git"},
|
|
300
|
+
"junk",
|
|
301
|
+
]
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
assert git_repo_token_vars(Project()) == [
|
|
305
|
+
{"host": "gitlab.com", "user": "oauth2", "var": "a_git_pat"},
|
|
306
|
+
{"host": "github.com", "user": "x-access-token", "var": "b_git_pat"},
|
|
307
|
+
{"host": "git.corp.example", "user": "oauth2", "var": "c_git_pat"},
|
|
308
|
+
]
|
|
309
|
+
assert git_repo_token_vars(None) == []
|
|
310
|
+
|
|
311
|
+
|
|
248
312
|
def test_helper_works_through_real_git(tmp_path):
|
|
249
313
|
script, token_file = _helper_script(tmp_path)
|
|
250
314
|
token_file.write_text("GH_TOKEN=ghp_abc\n")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mystack_rig-1.7.1 → mystack_rig-1.7.3}/docs/adr/0002-outputs-as-separate-object-via-file-handoff.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mystack_rig-1.7.1 → mystack_rig-1.7.3}/docs/adr/0005-docker-in-configure-for-devcontainers.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|