mystack-rig 1.6.0__tar.gz → 1.6.2__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 (125) hide show
  1. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/PKG-INFO +2 -2
  2. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/README.md +1 -1
  3. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/devcontainers.py +51 -4
  4. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/remote_dev.py +45 -2
  5. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/mystack_rig.egg-info/PKG-INFO +2 -2
  6. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/mystack_rig.egg-info/scm_version.json +2 -2
  7. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_devcontainers.py +56 -0
  8. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_init_command.py +70 -0
  9. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_remote_dev_coverage_extensions.py +1 -0
  10. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_setup_provision.py +25 -0
  11. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_snapshots.py +56 -0
  12. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/.coveragerc +0 -0
  13. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/.git-blame-ignore-revs +0 -0
  14. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/.github/workflows/release.yml +0 -0
  15. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/.github/workflows/tests.yml +0 -0
  16. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/.gitignore +0 -0
  17. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/.rig/playbooks/README.md +0 -0
  18. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/.rig/playbooks/vpn-gateway.yml +0 -0
  19. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/CLI_STORAGE_SUMMARY.md +0 -0
  20. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/Dockerfile +0 -0
  21. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/GIT_CLONE_FEATURE.md +0 -0
  22. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/GLOSSARY.md +0 -0
  23. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/HETZNER_STORAGE_GUIDE.md +0 -0
  24. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/HETZNER_STORAGE_SECURITY_GUIDE.md +0 -0
  25. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/LICENSE +0 -0
  26. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/Makefile +0 -0
  27. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/README_REAL_E2E.md +0 -0
  28. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/STORAGE_CLI_GUIDE.md +0 -0
  29. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/docs/adr/0001-per-profile-generated-state-bucket.md +0 -0
  30. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/docs/adr/0002-outputs-as-separate-object-via-file-handoff.md +0 -0
  31. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/docs/adr/0003-mcp-servers-declared-once-rendered-at-authorize.md +0 -0
  32. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/docs/adr/0004-agents-run-as-live-agents-in-tmux.md +0 -0
  33. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/docs/adr/0005-docker-in-configure-for-devcontainers.md +0 -0
  34. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/docs/architecture.md +0 -0
  35. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/docs/architecture.png +0 -0
  36. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/docs/architecture.svg +0 -0
  37. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/forged-idea.md +0 -0
  38. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/pyproject.toml +0 -0
  39. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/pytest.ini +0 -0
  40. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/requirements.txt +0 -0
  41. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/sample.env +0 -0
  42. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/scripts/coverage_badge.py +0 -0
  43. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/scripts/pypi_version.py +0 -0
  44. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/setup.cfg +0 -0
  45. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/__init__.py +0 -0
  46. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/__init__.py +0 -0
  47. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/__main__.py +0 -0
  48. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/agents.py +0 -0
  49. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/ansible_filters/__init__.py +0 -0
  50. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/ansible_filters/rig_live.py +0 -0
  51. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/ansible_filters/rig_mcp.py +0 -0
  52. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/assets/rig-agent-queue +0 -0
  53. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/assets/rig-agent-state +0 -0
  54. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/assets/tmux.conf +0 -0
  55. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/config.py +0 -0
  56. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/encrypt.py +0 -0
  57. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/git.py +0 -0
  58. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/git_author.py +0 -0
  59. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/last_env.py +0 -0
  60. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/last_session.py +0 -0
  61. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/last_target.py +0 -0
  62. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/live_agent.py +0 -0
  63. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/log.py +0 -0
  64. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/main.py +0 -0
  65. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/mcp.py +0 -0
  66. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/outputs.py +0 -0
  67. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/requirements.txt +0 -0
  68. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/snapshots.py +0 -0
  69. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/state_bucket.py +0 -0
  70. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/storage.py +0 -0
  71. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/vault_keys.py +0 -0
  72. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/cli/vpn.py +0 -0
  73. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/mystack_rig.egg-info/SOURCES.txt +0 -0
  74. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/mystack_rig.egg-info/dependency_links.txt +0 -0
  75. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/mystack_rig.egg-info/entry_points.txt +0 -0
  76. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/mystack_rig.egg-info/requires.txt +0 -0
  77. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/mystack_rig.egg-info/scm_file_list.json +0 -0
  78. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/src/mystack_rig.egg-info/top_level.txt +0 -0
  79. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/test_hetzner_integration.py +0 -0
  80. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/conftest.py +0 -0
  81. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_agents.py +0 -0
  82. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_ansible_galaxy.py +0 -0
  83. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_attach_command.py +0 -0
  84. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_credential_security.py +0 -0
  85. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_destroy_command.py +0 -0
  86. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_dev_command.py +0 -0
  87. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_encrypt_command.py +0 -0
  88. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_encrypt_coverage.py +0 -0
  89. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_firewall_client_ip.py +0 -0
  90. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_git_clone_unit.py +0 -0
  91. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_git_credentials_and_author.py +0 -0
  92. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_git_manager.py +0 -0
  93. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_gitignore_init.py +0 -0
  94. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_hetzner_storage.py +0 -0
  95. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_inspect_describe.py +0 -0
  96. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_last_env.py +0 -0
  97. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_last_session.py +0 -0
  98. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_last_target.py +0 -0
  99. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_live_agent.py +0 -0
  100. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_live_agent_cli.py +0 -0
  101. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_log.py +0 -0
  102. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_main_coverage.py +0 -0
  103. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_mcp_command.py +0 -0
  104. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_mcp_render.py +0 -0
  105. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_outputs.py +0 -0
  106. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_outputs_storage.py +0 -0
  107. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_pypi_version.py +0 -0
  108. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_python_floor.py +0 -0
  109. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_r2_storage.py +0 -0
  110. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_real_e2e_integration.py +0 -0
  111. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_real_e2e_storage.py +0 -0
  112. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_real_e2e_vpn.py +0 -0
  113. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_real_e2e_vpn_tunnel.py +0 -0
  114. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_remote_dev.py +0 -0
  115. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_rig_ansible_vars.py +0 -0
  116. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_rig_config.py +0 -0
  117. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_secret_prompt_hidden.py +0 -0
  118. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_simulation_storage.py +0 -0
  119. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_small_module_coverage.py +0 -0
  120. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_state_bucket.py +0 -0
  121. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_storage_basic.py +0 -0
  122. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_vault_keys.py +0 -0
  123. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_vpn_optional.py +0 -0
  124. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/tests/test_vpn_unit.py +0 -0
  125. {mystack_rig-1.6.0 → mystack_rig-1.6.2}/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.6.0
3
+ Version: 1.6.2
4
4
  Summary: Ephemeral remotes with full local parity for coding agents
5
5
  Author: mystack-cloud
6
6
  License-Expression: MIT
@@ -166,7 +166,7 @@ Chosen at `rig init` (`editor.enabled` in `rig.yml`, same multi-select as git pr
166
166
 
167
167
  ### Dev Containers
168
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.
169
+ `rig init` looks for Dev Containers in the Repos you select and, when it finds any, asks whether to enable support (default yes). It records the answer in `rig.yml` and doesn't ask again. To enable it by hand, set `editor.devcontainers: true`; then `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
170
 
171
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
172
  - Not supported with `--browser`. Agents still run on the VM, not in the container.
@@ -144,7 +144,7 @@ Chosen at `rig init` (`editor.enabled` in `rig.yml`, same multi-select as git pr
144
144
 
145
145
  ### Dev Containers
146
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.
147
+ `rig init` looks for Dev Containers in the Repos you select and, when it finds any, asks whether to enable support (default yes). It records the answer in `rig.yml` and doesn't ask again. To enable it by hand, set `editor.devcontainers: true`; then `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
148
 
149
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
150
  - Not supported with `--browser`. Agents still run on the VM, not in the container.
@@ -9,6 +9,7 @@ import re
9
9
  import shlex
10
10
  from collections.abc import Callable, Sequence
11
11
  from dataclasses import dataclass
12
+ from pathlib import Path
12
13
 
13
14
 
14
15
  @dataclass(frozen=True)
@@ -50,6 +51,12 @@ _CONFIG_RE = re.compile(
50
51
  _SKIPPED_DIRS = ("node_modules", ".git")
51
52
 
52
53
 
54
+ def _is_dev_container_path(config: str) -> bool:
55
+ """Is *config* (relative to a Repo root) a Dev Container within the scan depth?"""
56
+ match = _CONFIG_RE.match(config)
57
+ return match is not None and match.group("sub") not in _SKIPPED_DIRS
58
+
59
+
53
60
  def _scan_command(dest: str) -> str:
54
61
  skipped = " -o ".join(f"-name {d}" for d in _SKIPPED_DIRS)
55
62
  return (
@@ -73,10 +80,8 @@ def find_devcontainers(
73
80
  if not line.startswith(dest.rstrip("/") + "/"):
74
81
  continue
75
82
  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))
83
+ if _is_dev_container_path(config):
84
+ found.append(DevTarget(name, config))
80
85
  return sorted(found, key=lambda t: (t.repo, t.config))
81
86
 
82
87
 
@@ -189,3 +194,45 @@ def scan_environment(env, repos: Sequence[tuple[str, str]]) -> list[DevTarget]:
189
194
  return result.stdout
190
195
 
191
196
  return find_devcontainers(run_remote, repos)
197
+
198
+
199
+ _LOCAL_PATTERNS = (".devcontainer.json", ".devcontainer/devcontainer.json", ".devcontainer/*/devcontainer.json")
200
+
201
+
202
+ def find_local_devcontainers(repos: Sequence[dict]) -> list[DevTarget]:
203
+ """Dev Containers in Repos checked out on this machine (each has ``name`` and ``path``)."""
204
+ found: list[DevTarget] = []
205
+ for repo in repos:
206
+ name, path = repo.get("name"), repo.get("path")
207
+ if not name or not path or not os.path.isdir(path):
208
+ continue
209
+ root = Path(path)
210
+ for prefix in ("", "*/"):
211
+ for pattern in _LOCAL_PATTERNS:
212
+ for match in root.glob(prefix + pattern):
213
+ config = match.relative_to(root).as_posix()
214
+ if match.is_file() and _is_dev_container_path(config):
215
+ found.append(DevTarget(str(name), config))
216
+ return sorted(set(found), key=lambda t: (t.repo, t.config))
217
+
218
+
219
+ def prompt_devcontainers(
220
+ found: Sequence[DevTarget],
221
+ current: bool | None,
222
+ input_fn: Callable[[str], str] = input,
223
+ ) -> bool | None:
224
+ """Whether to enable Dev Containers for the Workspace, asked by ``rig init``.
225
+
226
+ Asks only when some were found and ``editor.devcontainers`` was never set;
227
+ Enter means yes. An earlier answer is kept. None means leave the flag unset.
228
+ """
229
+ if current is not None:
230
+ return current
231
+ if not found:
232
+ return None
233
+ repos = ", ".join(sorted({t.repo for t in found}))
234
+ answer = input_fn(
235
+ f"Dev Containers found in {repos}. Enable Dev Container support "
236
+ "(installs Docker, rebuilds the snapshot once)? [Y/n]: "
237
+ )
238
+ return not answer.strip().lower().startswith("n")
@@ -2528,6 +2528,10 @@ class RemoteDevEnvironment:
2528
2528
  agent_type=inputs.get("agent_type"),
2529
2529
  )
2530
2530
 
2531
+ if not self.flush_disk():
2532
+ log.warning("Skipping snapshot %s: could not flush the disk first", description)
2533
+ return False
2534
+
2531
2535
  try:
2532
2536
  image = self.manager.create_snapshot(
2533
2537
  str(self.vm_id),
@@ -3257,6 +3261,24 @@ echo "Agent installation complete!"
3257
3261
  timeout=timeout,
3258
3262
  )
3259
3263
 
3264
+ def flush_disk(self, *, timeout: int = 120) -> bool:
3265
+ """Flush the VM's dirty pages to disk, so a snapshot of it is consistent.
3266
+
3267
+ Hetzner snapshots a running server's disk as it is, and ext4 can hold
3268
+ a new file's contents in memory for ~30s after journaling that it exists.
3269
+ """
3270
+ if not self.vm_ip:
3271
+ return False
3272
+ try:
3273
+ result = self.run_remote("sync && sync", timeout=timeout, connect_timeout=15)
3274
+ except (OSError, subprocess.SubprocessError) as exc:
3275
+ log.warning("Could not flush the disk of %s: %s", self.name, exc)
3276
+ return False
3277
+ if result.returncode != 0:
3278
+ log.warning("Could not flush the disk of %s: %s", self.name, (result.stderr or "").strip())
3279
+ return False
3280
+ return True
3281
+
3260
3282
  # --- live agents -------------------------------------------------------
3261
3283
 
3262
3284
  def live_agents(self, *, connect_timeout: int = 10) -> list[LiveAgent] | None:
@@ -4141,6 +4163,7 @@ AUTHORIZE_PLAYBOOK = r"""---
4141
4163
  # --- Skip first-run prompts (theme picker, login wizard, folder trust) ---
4142
4164
  # Runs on every create (authorize is never snapshotted) and merges into any
4143
4165
  # existing file: the installer can create ~/.claude.json before we get here.
4166
+ # A file can be empty (a snapshot taken before its contents reached disk): read it as {}.
4144
4167
  - name: Ensure Claude config directory exists for seeding
4145
4168
  file:
4146
4169
  path: /root/.claude
@@ -4171,7 +4194,8 @@ AUTHORIZE_PLAYBOOK = r"""---
4171
4194
  | map(attribute='item.item') | zip(
4172
4195
  _claude_state_contents.results | default([])
4173
4196
  | map(attribute='content')
4174
- | map('b64decode') | map('from_json')) ) }}
4197
+ | map('b64decode') | map('trim') | map('default', '{}', true)
4198
+ | map('from_json')) ) }}
4175
4199
  _ws: "{{ workspace_root | default('/workspace') }}"
4176
4200
  _state_seed:
4177
4201
  hasCompletedOnboarding: true
@@ -5504,8 +5528,12 @@ class Workspace:
5504
5528
  agent_types: list[str] | None = None,
5505
5529
  editor: str | None = None,
5506
5530
  editors: list[str] | None = None,
5531
+ devcontainers: bool | None = None,
5507
5532
  ) -> bool:
5508
- """Idempotently initialize workspace config and register selected repos."""
5533
+ """Idempotently initialize workspace config and register selected repos.
5534
+
5535
+ ``devcontainers`` sets ``editor.devcontainers``; None leaves it as it is.
5536
+ """
5509
5537
  workspace_name = name or os.path.basename(self.path.rstrip(os.sep)) or "workspace"
5510
5538
  if not _valid_component_name(workspace_name):
5511
5539
  print(f"Error: invalid workspace name '{workspace_name}'")
@@ -5554,6 +5582,8 @@ class Workspace:
5554
5582
  project.config["name"] = workspace_name
5555
5583
  project._set_agent_selection(chosen_agents, default=chosen_agent)
5556
5584
  apply_editor_selection(project.config, chosen_editors, default=chosen_editor)
5585
+ if devcontainers is not None:
5586
+ project.config["editor"]["devcontainers"] = devcontainers
5557
5587
  project.set_vars("coding_agent_type", chosen_agent)
5558
5588
  project.set_vars("coding_agent_types", list(chosen_agents))
5559
5589
 
@@ -5660,6 +5690,8 @@ class Workspace:
5660
5690
  # Re-apply after add_repo/load cycles so agent/editor choice is not lost.
5661
5691
  project._set_agent_selection(chosen_agents, default=chosen_agent)
5662
5692
  apply_editor_selection(project.config, chosen_editors, default=chosen_editor)
5693
+ if devcontainers is not None:
5694
+ project.config["editor"]["devcontainers"] = devcontainers
5663
5695
  project.set_vars("coding_agent_type", chosen_agent)
5664
5696
  project.set_vars("coding_agent_types", list(chosen_agents))
5665
5697
 
@@ -5850,6 +5882,16 @@ def interactive_env_init(
5850
5882
  print(f"Error: {exc}")
5851
5883
  return False
5852
5884
 
5885
+ from cli.devcontainers import find_local_devcontainers, prompt_devcontainers
5886
+
5887
+ editor_block = existing.get("editor")
5888
+ earlier = editor_block.get("devcontainers") if isinstance(editor_block, dict) else None
5889
+ devcontainers = prompt_devcontainers(
5890
+ find_local_devcontainers(selected),
5891
+ earlier if isinstance(earlier, bool) else None,
5892
+ input_fn or input,
5893
+ )
5894
+
5853
5895
  # Collect PATs before writing config so password_var can be attached on add.
5854
5896
  pat_assignments, default_pats = collect_repo_pats(
5855
5897
  selected,
@@ -5870,6 +5912,7 @@ def interactive_env_init(
5870
5912
  agent_types=agent_types,
5871
5913
  editor=editor,
5872
5914
  editors=editors,
5915
+ devcontainers=devcontainers,
5873
5916
  ):
5874
5917
  return False
5875
5918
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mystack-rig
3
- Version: 1.6.0
3
+ Version: 1.6.2
4
4
  Summary: Ephemeral remotes with full local parity for coding agents
5
5
  Author: mystack-cloud
6
6
  License-Expression: MIT
@@ -166,7 +166,7 @@ Chosen at `rig init` (`editor.enabled` in `rig.yml`, same multi-select as git pr
166
166
 
167
167
  ### Dev Containers
168
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.
169
+ `rig init` looks for Dev Containers in the Repos you select and, when it finds any, asks whether to enable support (default yes). It records the answer in `rig.yml` and doesn't ask again. To enable it by hand, set `editor.devcontainers: true`; then `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
170
 
171
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
172
  - Not supported with `--browser`. Agents still run on the VM, not in the container.
@@ -1,7 +1,7 @@
1
1
  {
2
- "tag": "1.6.0",
2
+ "tag": "1.6.2",
3
3
  "distance": 0,
4
- "node": "gbfaddab18fb85da7fe4f570e40ace1bfeecef1c2",
4
+ "node": "gba75e43ded7c08e65cbbf5ee2ef24cb98e0c027e",
5
5
  "dirty": false,
6
6
  "branch": "HEAD",
7
7
  "node_date": "2026-11-24"
@@ -239,3 +239,59 @@ def test_scan_reports_an_unreachable_environment():
239
239
  env.run_remote.side_effect = OSError("ssh not found")
240
240
  with pytest.raises(DevContainerScanError, match="could not reach"):
241
241
  scan_environment(env, [("api", "/workspace/api")])
242
+
243
+
244
+ # --- rig init ---------------------------------------------------------------
245
+
246
+
247
+ def _touch(root, rel):
248
+ path = root / rel
249
+ path.parent.mkdir(parents=True, exist_ok=True)
250
+ path.write_text("{}\n")
251
+
252
+
253
+ def test_local_scan_finds_dev_containers_in_selected_repos(tmp_path):
254
+ from cli.devcontainers import find_local_devcontainers
255
+
256
+ _touch(tmp_path / "api", ".devcontainer/devcontainer.json")
257
+ _touch(tmp_path / "mono", "svc/.devcontainer.json")
258
+ _touch(tmp_path / "mono", "a/b/.devcontainer.json") # too deep
259
+ _touch(tmp_path / "mono", "node_modules/x/.devcontainer.json")
260
+ _touch(tmp_path / "web", "README.md")
261
+ repos = [{"name": n, "path": str(tmp_path / n)} for n in ("api", "mono", "web")]
262
+ assert find_local_devcontainers(repos) == [
263
+ DevTarget("api", ".devcontainer/devcontainer.json"),
264
+ DevTarget("mono", "svc/.devcontainer.json"),
265
+ ]
266
+
267
+
268
+ def test_local_scan_skips_repos_without_a_local_path(tmp_path):
269
+ from cli.devcontainers import find_local_devcontainers
270
+
271
+ assert find_local_devcontainers([{"name": "x"}, {"name": "y", "path": str(tmp_path / "gone")}]) == []
272
+
273
+
274
+ def test_init_asks_to_enable_only_when_found_and_never_answered():
275
+ from cli.devcontainers import prompt_devcontainers
276
+
277
+ found = [API_DEFAULT, WEB_SUB]
278
+ asked = []
279
+
280
+ def ask(prompt):
281
+ asked.append(prompt)
282
+ return ""
283
+
284
+ assert prompt_devcontainers(found, None, ask) is True # Enter defaults to yes
285
+ assert "api" in asked[0] and "web" in asked[0]
286
+ assert prompt_devcontainers(found, None, lambda _p: "n") is False
287
+ assert prompt_devcontainers(found, None, lambda _p: "No") is False
288
+ assert prompt_devcontainers(found, None, lambda _p: "y") is True
289
+
290
+
291
+ def test_init_does_not_ask_when_nothing_found_or_already_decided():
292
+ from cli.devcontainers import prompt_devcontainers
293
+
294
+ assert prompt_devcontainers([], None, _no_input) is None
295
+ assert prompt_devcontainers([], True, _no_input) is True
296
+ assert prompt_devcontainers([API_DEFAULT], False, _no_input) is False
297
+ assert prompt_devcontainers([API_DEFAULT], True, _no_input) is True
@@ -1005,3 +1005,73 @@ def test_save_creates_shared_vars_when_missing_without_personal_keys(tmp_path, m
1005
1005
 
1006
1006
  shared = yaml.safe_load((rig / "vars.yml").read_text(encoding="utf-8"))
1007
1007
  assert "gitlab_pat" not in (shared or {})
1008
+
1009
+
1010
+ def _init_with_devcontainer(tmp_path, *extra_answers, existing_flag=None):
1011
+ root = tmp_path / "ws"
1012
+ api = root / "api"
1013
+ _git_init(api, "https://github.com/org/api.git")
1014
+ dc = api / ".devcontainer"
1015
+ dc.mkdir()
1016
+ (dc / "devcontainer.json").write_text("{}\n")
1017
+ if existing_flag is not None:
1018
+ (api / "rig.yml").write_text(yaml.safe_dump({"kind": "workspace", "editor": {"devcontainers": existing_flag}}))
1019
+ data_key = tmp_path / "data-key"
1020
+ data_key.write_text("vault-pass\n")
1021
+ asked = []
1022
+ answers = _answers("", "api", "", "", *extra_answers) # repo, name, agent, editor, ...
1023
+
1024
+ def ask(prompt):
1025
+ asked.append(prompt)
1026
+ return next(answers)
1027
+
1028
+ assert interactive_env_init(
1029
+ str(api),
1030
+ input_fn=ask,
1031
+ secret_fn=_secrets(),
1032
+ config_path=str(tmp_path / "rig-config"),
1033
+ data_key_path=str(data_key),
1034
+ )
1035
+ return yaml.safe_load((api / "rig.yml").read_text()), asked
1036
+
1037
+
1038
+ def test_init_enables_dev_containers_by_default_when_found(tmp_path):
1039
+ manifest, asked = _init_with_devcontainer(tmp_path, "")
1040
+ assert manifest["editor"]["devcontainers"] is True
1041
+ assert any("Dev Container" in prompt for prompt in asked)
1042
+
1043
+
1044
+ def test_init_records_a_no_answer(tmp_path):
1045
+ manifest, _ = _init_with_devcontainer(tmp_path, "n")
1046
+ assert manifest["editor"]["devcontainers"] is False
1047
+
1048
+
1049
+ def test_init_keeps_an_earlier_decision_without_asking(tmp_path):
1050
+ manifest, asked = _init_with_devcontainer(tmp_path, existing_flag=False)
1051
+ assert manifest["editor"]["devcontainers"] is False
1052
+ assert not any("Dev Container" in prompt for prompt in asked)
1053
+
1054
+
1055
+ def test_init_without_dev_containers_asks_nothing_and_leaves_the_flag_unset(tmp_path):
1056
+ root = tmp_path / "ws"
1057
+ api = root / "api"
1058
+ _git_init(api, "https://github.com/org/api.git")
1059
+ data_key = tmp_path / "data-key"
1060
+ data_key.write_text("vault-pass\n")
1061
+ answers = _answers("", "api", "", "")
1062
+ asked = []
1063
+
1064
+ def ask(prompt):
1065
+ asked.append(prompt)
1066
+ return next(answers)
1067
+
1068
+ assert interactive_env_init(
1069
+ str(api),
1070
+ input_fn=ask,
1071
+ secret_fn=_secrets(),
1072
+ config_path=str(tmp_path / "rig-config"),
1073
+ data_key_path=str(data_key),
1074
+ )
1075
+ manifest = yaml.safe_load((api / "rig.yml").read_text())
1076
+ assert "devcontainers" not in manifest["editor"]
1077
+ assert not any("Dev Container" in prompt for prompt in asked)
@@ -1035,6 +1035,7 @@ class TestRemoteDevEnvironmentMore:
1035
1035
  env.vm_id = "vm1"
1036
1036
  env.manager = MagicMock()
1037
1037
  env.manager.create_snapshot.return_value = {"id": "img"}
1038
+ env.flush_disk = MagicMock(return_value=True)
1038
1039
  # Patch helpers in-place — never replace sys.modules["cli.snapshots"].
1039
1040
  monkeypatch.setattr("cli.snapshots.package_version", lambda: "0")
1040
1041
  monkeypatch.setattr(
@@ -1177,3 +1177,28 @@ def test_authorize_fails_loudly_on_an_invalid_mcp_json(tmp_path):
1177
1177
  _root, result = _run_authorize_mcp_tasks(tmp_path, {"mcpServers": {"a": {}}}, ["claude"])
1178
1178
  assert result.returncode != 0
1179
1179
  assert "exactly one of" in result.stdout + result.stderr
1180
+
1181
+
1182
+ def test_authorize_treats_empty_claude_state_files_as_empty_json():
1183
+ """A snapshot can hold a 0-byte settings.json; seeding must merge into {}."""
1184
+ import base64
1185
+
1186
+ import yaml
1187
+
1188
+ pytest.importorskip("ansible")
1189
+ from ansible.parsing.dataloader import DataLoader
1190
+ from ansible.template import Templar, trust_as_template
1191
+
1192
+ from cli.remote_dev import AUTHORIZE_PLAYBOOK
1193
+
1194
+ tasks = yaml.safe_load(AUTHORIZE_PLAYBOOK)[0]["tasks"]
1195
+ seed = next(t for t in tasks if t.get("name", "").startswith("Seed Claude Code onboarding"))
1196
+ results = [
1197
+ {"item": {"item": "/root/.claude/settings.json"}, "content": ""},
1198
+ {"item": {"item": "/root/.claude.json"}, "content": base64.b64encode(b'{"a": 1}').decode()},
1199
+ ]
1200
+ templar = Templar(loader=DataLoader(), variables={"_claude_state_contents": {"results": results}})
1201
+ assert templar.template(trust_as_template(seed["vars"]["_existing"])) == {
1202
+ "/root/.claude/settings.json": {},
1203
+ "/root/.claude.json": {"a": 1},
1204
+ }
@@ -308,6 +308,7 @@ def test_snapshot_after_playbook_only_after_configure(tmp_path):
308
308
  env = RemoteDevEnvironment(name="dev-x")
309
309
  env.vm_id = 99
310
310
  env.manager.create_snapshot = MagicMock(return_value={"id": 1})
311
+ env.flush_disk = MagicMock(return_value=True)
311
312
 
312
313
  # provision alone does not snapshot.
313
314
  assert env._snapshot_after_playbook("provision", project) is True
@@ -742,3 +743,58 @@ def test_system_hash_follows_provision_and_configure_playbooks(tmp_path):
742
743
  base = system_content_hash(project_dir=str(tmp_path))
743
744
  (rig / "configure.yml").write_text("# c2\n")
744
745
  assert system_content_hash(project_dir=str(tmp_path)) != base
746
+
747
+
748
+ def _snapshot_project(tmp_path):
749
+ (tmp_path / "rig.yml").write_text("name: demo\nkind: workspace\nagent:\n type: opencode\n")
750
+ (tmp_path / ".rig").mkdir()
751
+ for name in ("provision", "configure", "materialize"):
752
+ (tmp_path / ".rig" / f"{name}.yml").write_text("---\n")
753
+
754
+ from cli.remote_dev import ProjectConfig
755
+
756
+ project = ProjectConfig(str(tmp_path))
757
+ assert project.load()
758
+ return project
759
+
760
+
761
+ def test_snapshot_flushes_the_disk_before_creating_the_image(tmp_path):
762
+ project = _snapshot_project(tmp_path)
763
+ env = RemoteDevEnvironment(name="dev-x")
764
+ env.vm_id = 99
765
+ calls = MagicMock()
766
+ env.flush_disk = calls.flush
767
+ calls.flush.return_value = True
768
+ env.manager.create_snapshot = calls.create
769
+ calls.create.return_value = {"id": 1}
770
+
771
+ assert env._snapshot_after_playbook("configure", project) is True
772
+ assert [c[0] for c in calls.mock_calls] == ["flush", "create"]
773
+
774
+
775
+ def test_snapshot_is_skipped_when_the_disk_cannot_be_flushed(tmp_path):
776
+ project = _snapshot_project(tmp_path)
777
+ env = RemoteDevEnvironment(name="dev-x")
778
+ env.vm_id = 99
779
+ env.flush_disk = MagicMock(return_value=False)
780
+ env.manager.create_snapshot = MagicMock(return_value={"id": 1})
781
+
782
+ assert env._snapshot_after_playbook("configure", project) is False
783
+ env.manager.create_snapshot.assert_not_called()
784
+
785
+
786
+ def test_flush_disk_runs_sync_on_the_vm():
787
+ env = RemoteDevEnvironment(name="dev-x")
788
+ env.vm_ip = "198.51.100.7"
789
+ env.run_remote = MagicMock(return_value=MagicMock(returncode=0, stderr=""))
790
+ assert env.flush_disk() is True
791
+ assert env.run_remote.call_args.args[0].split()[0] == "sync"
792
+
793
+ env.run_remote.return_value = MagicMock(returncode=255, stderr="refused")
794
+ assert env.flush_disk() is False
795
+
796
+ env.run_remote.side_effect = OSError("no ssh")
797
+ assert env.flush_disk() is False
798
+
799
+ env.vm_ip = None
800
+ assert env.flush_disk() is False
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