mystack-rig 1.3.0__tar.gz → 1.3.1__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 (111) hide show
  1. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/PKG-INFO +37 -1
  2. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/README.md +36 -0
  3. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/cli/encrypt.py +51 -10
  4. mystack_rig-1.3.1/src/cli/git_author.py +65 -0
  5. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/cli/remote_dev.py +140 -4
  6. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/mystack_rig.egg-info/PKG-INFO +37 -1
  7. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/mystack_rig.egg-info/SOURCES.txt +3 -0
  8. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/mystack_rig.egg-info/scm_file_list.json +3 -0
  9. mystack_rig-1.3.1/src/mystack_rig.egg-info/scm_version.json +8 -0
  10. mystack_rig-1.3.1/tests/test_git_credentials_and_author.py +294 -0
  11. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_rig_ansible_vars.py +36 -0
  12. mystack_rig-1.3.1/tests/test_secret_prompt_hidden.py +269 -0
  13. mystack_rig-1.3.0/src/mystack_rig.egg-info/scm_version.json +0 -8
  14. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/.coveragerc +0 -0
  15. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/.flake8 +0 -0
  16. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/.github/workflows/release.yml +0 -0
  17. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/.github/workflows/tests.yml +0 -0
  18. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/.gitignore +0 -0
  19. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/.rig/playbooks/README.md +0 -0
  20. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/.rig/playbooks/vpn-gateway.yml +0 -0
  21. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/CLI_STORAGE_SUMMARY.md +0 -0
  22. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/Dockerfile +0 -0
  23. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/GIT_CLONE_FEATURE.md +0 -0
  24. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/GLOSSARY.md +0 -0
  25. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/HETZNER_STORAGE_GUIDE.md +0 -0
  26. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/HETZNER_STORAGE_SECURITY_GUIDE.md +0 -0
  27. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/LICENSE +0 -0
  28. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/Makefile +0 -0
  29. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/README_REAL_E2E.md +0 -0
  30. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/STORAGE_CLI_GUIDE.md +0 -0
  31. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/docs/adr/0001-per-profile-generated-state-bucket.md +0 -0
  32. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/docs/adr/0002-outputs-as-separate-object-via-file-handoff.md +0 -0
  33. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/docs/adr/0003-mcp-servers-declared-once-rendered-at-authorize.md +0 -0
  34. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/docs/architecture.md +0 -0
  35. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/docs/architecture.png +0 -0
  36. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/docs/architecture.svg +0 -0
  37. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/forged-idea.md +0 -0
  38. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/pyproject.toml +0 -0
  39. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/pytest.ini +0 -0
  40. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/requirements.txt +0 -0
  41. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/sample.env +0 -0
  42. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/scripts/coverage_badge.py +0 -0
  43. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/scripts/pypi_version.py +0 -0
  44. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/setup.cfg +0 -0
  45. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/__init__.py +0 -0
  46. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/cli/__init__.py +0 -0
  47. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/cli/__main__.py +0 -0
  48. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/cli/agents.py +0 -0
  49. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/cli/ansible_filters/__init__.py +0 -0
  50. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/cli/ansible_filters/rig_mcp.py +0 -0
  51. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/cli/config.py +0 -0
  52. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/cli/git.py +0 -0
  53. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/cli/last_env.py +0 -0
  54. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/cli/last_session.py +0 -0
  55. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/cli/log.py +0 -0
  56. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/cli/main.py +0 -0
  57. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/cli/mcp.py +0 -0
  58. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/cli/outputs.py +0 -0
  59. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/cli/requirements.txt +0 -0
  60. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/cli/snapshots.py +0 -0
  61. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/cli/state_bucket.py +0 -0
  62. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/cli/storage.py +0 -0
  63. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/cli/vault_keys.py +0 -0
  64. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/cli/vpn.py +0 -0
  65. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/mystack_rig.egg-info/dependency_links.txt +0 -0
  66. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/mystack_rig.egg-info/entry_points.txt +0 -0
  67. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/mystack_rig.egg-info/requires.txt +0 -0
  68. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/src/mystack_rig.egg-info/top_level.txt +0 -0
  69. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/test_hetzner_integration.py +0 -0
  70. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/conftest.py +0 -0
  71. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_agents.py +0 -0
  72. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_ansible_galaxy.py +0 -0
  73. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_attach_command.py +0 -0
  74. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_credential_security.py +0 -0
  75. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_destroy_command.py +0 -0
  76. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_dev_command.py +0 -0
  77. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_encrypt_command.py +0 -0
  78. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_encrypt_coverage.py +0 -0
  79. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_firewall_client_ip.py +0 -0
  80. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_git_clone_unit.py +0 -0
  81. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_git_manager.py +0 -0
  82. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_gitignore_init.py +0 -0
  83. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_hetzner_storage.py +0 -0
  84. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_init_command.py +0 -0
  85. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_inspect_describe.py +0 -0
  86. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_last_env.py +0 -0
  87. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_last_session.py +0 -0
  88. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_log.py +0 -0
  89. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_main_coverage.py +0 -0
  90. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_mcp_command.py +0 -0
  91. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_mcp_render.py +0 -0
  92. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_outputs.py +0 -0
  93. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_outputs_storage.py +0 -0
  94. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_pypi_version.py +0 -0
  95. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_real_e2e_integration.py +0 -0
  96. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_real_e2e_storage.py +0 -0
  97. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_real_e2e_vpn.py +0 -0
  98. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_real_e2e_vpn_tunnel.py +0 -0
  99. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_remote_dev.py +0 -0
  100. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_remote_dev_coverage_extensions.py +0 -0
  101. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_rig_config.py +0 -0
  102. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_setup_provision.py +0 -0
  103. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_simulation_storage.py +0 -0
  104. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_small_module_coverage.py +0 -0
  105. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_snapshots.py +0 -0
  106. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_state_bucket.py +0 -0
  107. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_storage_basic.py +0 -0
  108. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_vault_keys.py +0 -0
  109. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_vpn_optional.py +0 -0
  110. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/tests/test_vpn_unit.py +0 -0
  111. {mystack_rig-1.3.0 → mystack_rig-1.3.1}/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.3.0
3
+ Version: 1.3.1
4
4
  Summary: Ephemeral remotes with full local parity for coding agents
5
5
  Author: mystack-cloud
6
6
  License-Expression: MIT
@@ -301,6 +301,8 @@ Playbooks load `.rig/vars.yml` then `.rig/vars.{identity}.yml` (personal wins),
301
301
  | `rig_firewall_name` | Firewall resource name |
302
302
  | `rig_repos` | `[{name, url, path}, …]` (no secrets) |
303
303
  | `rig_git_providers` | e.g. `github`, `gitlab` |
304
+ | `rig_identity` | Developer identity (the `.rig/vars.{identity}.yml` handle) |
305
+ | `rig_git_author_name` / `rig_git_author_email` | Git author set on the VM (see [Git credentials and author](#git-credentials-and-author)) |
304
306
 
305
307
  Also available from vars files (defaults): `workspace_root`, `coding_agent_type`, `coding_agent_types`, `git.clone_repos`. On `rig init`, git PATs and each coding agent API key default to **personal** storage in `vars.{identity}.yml` (you are asked to confirm once); shared secrets such as `vscode_browser_password` live in `vars.yml`.
306
308
 
@@ -367,3 +369,37 @@ Push a version tag to publish that version to PyPI. The package version is the t
367
369
  ## License
368
370
 
369
371
  MIT
372
+
373
+ ## Git credentials and author
374
+
375
+ **Provider tokens never go into repo URLs.** `authorize.yml` (managed) takes
376
+ `github_pat` / `gitlab_pat` from the vars files and writes them to
377
+ `/root/.config/rig/git-provider.env` (mode `0600`, root only). From there:
378
+
379
+ - login shells get `GH_TOKEN` / `GITLAB_TOKEN` via `/etc/profile.d`, and `rig attach`
380
+ exports them to the agent process itself (it starts the agent in a non-login
381
+ shell, which never reads `/etc/profile.d`), so `gh` and `glab` work out of the
382
+ box in both;
383
+ - a system-wide git credential helper (`/usr/local/bin/rig-git-credential`)
384
+ answers `github.com` / `gitlab.com` HTTPS requests from that same file, so
385
+ `git clone`, `git push` and the `materialize.yml` clone task all use plain
386
+ URLs (`https://github.com/org/repo.git`) and nothing sits in `.git/config`
387
+ or `git remote -v`. Other users on the VM can't read the file and get no
388
+ credentials.
389
+
390
+ The `materialize.yml` clone task passes the token to git through an inline
391
+ helper fed from the task's environment (a per-repo `password_var` still wins over
392
+ `github_pat` / `gitlab_pat`), so it never touches the URL or disk. Projects
393
+ scaffolded by an older rig still have the token-in-URL clone task in their
394
+ `materialize.yml` (user-owned, never overwritten): copy the `vars:` and
395
+ `environment:` blocks of the current template and set `repo: "{{ item.repo }}"`.
396
+
397
+ **Git author.** A fresh VM has no git identity, so the first commit would fail
398
+ with *Author identity unknown*. `authorize.yml` sets `user.name` / `user.email`
399
+ (global) from `rig_git_author_name` / `rig_git_author_email`, which rig derives
400
+ from your identity: the identity as the name and `<identity>@rig.local` as the
401
+ email. Set `git_author_name` / `git_author_email` in `.rig/vars.yml`, or in your
402
+ personal `.rig/vars.{identity}.yml`, to use a real name and a GitHub-linked
403
+ email (the derived `rig.local` address is deliberately not a
404
+ `users.noreply.github.com` one, which GitHub would attribute to whoever owns
405
+ that handle).
@@ -278,6 +278,8 @@ Playbooks load `.rig/vars.yml` then `.rig/vars.{identity}.yml` (personal wins),
278
278
  | `rig_firewall_name` | Firewall resource name |
279
279
  | `rig_repos` | `[{name, url, path}, …]` (no secrets) |
280
280
  | `rig_git_providers` | e.g. `github`, `gitlab` |
281
+ | `rig_identity` | Developer identity (the `.rig/vars.{identity}.yml` handle) |
282
+ | `rig_git_author_name` / `rig_git_author_email` | Git author set on the VM (see [Git credentials and author](#git-credentials-and-author)) |
281
283
 
282
284
  Also available from vars files (defaults): `workspace_root`, `coding_agent_type`, `coding_agent_types`, `git.clone_repos`. On `rig init`, git PATs and each coding agent API key default to **personal** storage in `vars.{identity}.yml` (you are asked to confirm once); shared secrets such as `vscode_browser_password` live in `vars.yml`.
283
285
 
@@ -344,3 +346,37 @@ Push a version tag to publish that version to PyPI. The package version is the t
344
346
  ## License
345
347
 
346
348
  MIT
349
+
350
+ ## Git credentials and author
351
+
352
+ **Provider tokens never go into repo URLs.** `authorize.yml` (managed) takes
353
+ `github_pat` / `gitlab_pat` from the vars files and writes them to
354
+ `/root/.config/rig/git-provider.env` (mode `0600`, root only). From there:
355
+
356
+ - login shells get `GH_TOKEN` / `GITLAB_TOKEN` via `/etc/profile.d`, and `rig attach`
357
+ exports them to the agent process itself (it starts the agent in a non-login
358
+ shell, which never reads `/etc/profile.d`), so `gh` and `glab` work out of the
359
+ box in both;
360
+ - a system-wide git credential helper (`/usr/local/bin/rig-git-credential`)
361
+ answers `github.com` / `gitlab.com` HTTPS requests from that same file, so
362
+ `git clone`, `git push` and the `materialize.yml` clone task all use plain
363
+ URLs (`https://github.com/org/repo.git`) and nothing sits in `.git/config`
364
+ or `git remote -v`. Other users on the VM can't read the file and get no
365
+ credentials.
366
+
367
+ The `materialize.yml` clone task passes the token to git through an inline
368
+ helper fed from the task's environment (a per-repo `password_var` still wins over
369
+ `github_pat` / `gitlab_pat`), so it never touches the URL or disk. Projects
370
+ scaffolded by an older rig still have the token-in-URL clone task in their
371
+ `materialize.yml` (user-owned, never overwritten): copy the `vars:` and
372
+ `environment:` blocks of the current template and set `repo: "{{ item.repo }}"`.
373
+
374
+ **Git author.** A fresh VM has no git identity, so the first commit would fail
375
+ with *Author identity unknown*. `authorize.yml` sets `user.name` / `user.email`
376
+ (global) from `rig_git_author_name` / `rig_git_author_email`, which rig derives
377
+ from your identity: the identity as the name and `<identity>@rig.local` as the
378
+ email. Set `git_author_name` / `git_author_email` in `.rig/vars.yml`, or in your
379
+ personal `.rig/vars.{identity}.yml`, to use a real name and a GitHub-linked
380
+ email (the derived `rig.local` address is deliberately not a
381
+ `users.noreply.github.com` one, which GitHub would attribute to whoever owns
382
+ that handle).
@@ -9,6 +9,7 @@ in the identity file.
9
9
 
10
10
  from __future__ import annotations
11
11
 
12
+ import contextlib
12
13
  import getpass
13
14
  import os
14
15
  import re
@@ -266,21 +267,54 @@ def encrypt_named_value(
266
267
  return result.stdout.rstrip("\n")
267
268
 
268
269
 
270
+ @contextlib.contextmanager
271
+ def _echo_disabled(stream: TextIO):
272
+ """Turn terminal echo off on ``stream`` while typing a secret.
273
+
274
+ Yields True when echo was disabled, False when it could not be (not a
275
+ terminal, or no ``termios``); the original settings are always restored.
276
+ """
277
+ try:
278
+ import termios
279
+
280
+ fd = stream.fileno()
281
+ saved = termios.tcgetattr(fd)
282
+ except Exception:
283
+ yield False
284
+ return
285
+ hidden = list(saved)
286
+ hidden[3] &= ~termios.ECHO
287
+ try:
288
+ termios.tcsetattr(fd, termios.TCSAFLUSH, hidden)
289
+ yield True
290
+ finally:
291
+ termios.tcsetattr(fd, termios.TCSAFLUSH, saved)
292
+
293
+
269
294
  def encrypt_stdin(
270
295
  vault_password_file: str = DEFAULT_DATA_KEY_PATH,
271
296
  stdin_name: str = "",
272
297
  stdin: Optional[TextIO] = None,
273
298
  vault_id: Optional[str] = None,
274
299
  ) -> str:
275
- """Encrypt stdin until EOF (Ctrl+D) using ansible-vault --stdin-name."""
300
+ """Encrypt stdin until EOF (Ctrl+D) using ansible-vault --stdin-name.
301
+
302
+ On a terminal the typed value is not echoed.
303
+ """
276
304
  name = validate_var_name(stdin_name)
277
305
  source = stdin if stdin is not None else sys.stdin
278
306
  if source.isatty():
279
- print(
280
- f"Reading multiline value for '{name}'. Finish with Ctrl+D (EOF).",
281
- file=sys.stderr,
282
- )
283
- plaintext = source.read()
307
+ with _echo_disabled(source) as hidden:
308
+ note = "input hidden; " if hidden else ""
309
+ print(
310
+ f"Reading multiline value for '{name}' ({note}finish with Ctrl+D).",
311
+ file=sys.stderr,
312
+ )
313
+ plaintext = source.read()
314
+ if hidden:
315
+ print(file=sys.stderr) # the Enter/Ctrl+D newline was not echoed
316
+ else:
317
+ plaintext = source.read()
284
318
  if plaintext == "":
285
319
  raise ValueError("Value to encrypt is required")
286
320
  return encrypt_named_value(
@@ -302,10 +336,17 @@ def read_variable_name(
302
336
  return validate_var_name(answer)
303
337
 
304
338
 
305
- def read_single_line_value(input_fn: Optional[Callable[..., str]] = None) -> str:
306
- """Read one line to encrypt (default encrypt mode)."""
307
- ask = input_fn or input
308
- value = ask("Enter value to encrypt: ")
339
+ def read_single_line_value(
340
+ input_fn: Optional[Callable[..., str]] = None,
341
+ secret_fn: Optional[Callable[..., str]] = None,
342
+ ) -> str:
343
+ """Read one line to encrypt (default encrypt mode), hidden while typing.
344
+
345
+ ``input_fn`` / ``secret_fn`` are injection points for tests; without them
346
+ the value is read with ``getpass`` so it is never echoed.
347
+ """
348
+ ask = secret_fn or input_fn or getpass.getpass
349
+ value = ask("Enter value to encrypt (input hidden): ")
309
350
  if value is None or value == "":
310
351
  raise ValueError("Value to encrypt is required")
311
352
  return value
@@ -0,0 +1,65 @@
1
+ """Git author (``user.name`` / ``user.email``) for commits made on a rig VM.
2
+
3
+ The VM starts with no git identity, so the first ``git commit`` (by the
4
+ developer or by a coding agent) fails with "Author identity unknown". rig
5
+ derives one from the developer's rig *identity* (``rig_identity``) and hands
6
+ it to the playbooks as ``rig_git_author_name`` / ``rig_git_author_email``.
7
+
8
+ Resolution order (first non-empty wins, per field):
9
+
10
+ 1. ``git_author_name`` / ``git_author_email`` in ``.rig/vars.yml`` or the
11
+ identity's personal ``.rig/vars.<identity>.yml`` (personal wins) — the place
12
+ to put a real name and a GitHub-linked email;
13
+ 2. derived from the identity: the identity itself as the name and
14
+ ``<identity>@rig.local`` as the email.
15
+
16
+ The derived email is deliberately not a ``users.noreply.github.com`` address:
17
+ GitHub links that form to whichever account owns the handle, which could
18
+ attribute the commits to somebody else.
19
+ """
20
+
21
+ from __future__ import annotations
22
+
23
+ from typing import Any, Callable, Dict, Optional
24
+
25
+ NAME_VAR = "git_author_name"
26
+ EMAIL_VAR = "git_author_email"
27
+ DERIVED_EMAIL_DOMAIN = "rig.local"
28
+
29
+
30
+ def _clean(value: Any) -> str:
31
+ """One-line, trimmed string; anything that is not text counts as unset."""
32
+ if not isinstance(value, str):
33
+ return ""
34
+ return " ".join(value.split())
35
+
36
+
37
+ def derive_git_author(identity: str) -> Dict[str, str]:
38
+ """Author derived from the rig identity alone."""
39
+ name = _clean(identity)
40
+ return {
41
+ "name": name,
42
+ "email": f"{name}@{DERIVED_EMAIL_DOMAIN}" if name else "",
43
+ }
44
+
45
+
46
+ def resolve_git_author(
47
+ identity: str,
48
+ get_var: Optional[Callable[[str], Any]] = None,
49
+ ) -> Dict[str, str]:
50
+ """Resolve ``{"name": ..., "email": ...}``; either may override separately.
51
+
52
+ ``get_var`` looks a key up in the project vars (``project.get_vars``).
53
+ """
54
+ derived = derive_git_author(identity)
55
+ name = email = ""
56
+ if get_var is not None:
57
+ try:
58
+ name = _clean(get_var(NAME_VAR))
59
+ email = _clean(get_var(EMAIL_VAR))
60
+ except Exception:
61
+ name = email = ""
62
+ return {
63
+ "name": name or derived["name"],
64
+ "email": email or derived["email"],
65
+ }
@@ -395,6 +395,13 @@ def ssh_option_log_level() -> str:
395
395
  return "ERROR"
396
396
 
397
397
 
398
+ # Ansible SSH tolerance for freshly booted VMs (seconds / attempts).
399
+ ANSIBLE_SSH_DEFAULTS = {
400
+ 'ANSIBLE_TIMEOUT': '60',
401
+ 'ANSIBLE_SSH_RETRIES': '3',
402
+ }
403
+
404
+
398
405
  def rig_filter_plugins_path(existing: Optional[str] = None) -> str:
399
406
  """Ansible filter-plugin path: rig's own filters, then any already configured."""
400
407
  from cli.ansible_filters import rig_mcp
@@ -653,6 +660,23 @@ def build_rig_ansible_vars(
653
660
  "rig_repos": repos,
654
661
  "rig_git_providers": list(providers or []),
655
662
  }
663
+ # Git author for commits made on the VM, derived from the developer identity
664
+ # (overridable with git_author_name / git_author_email in the vars files).
665
+ try:
666
+ from cli.vault_keys import resolve_identity
667
+ from cli.git_author import resolve_git_author
668
+
669
+ identity = resolve_identity()
670
+ author = resolve_git_author(
671
+ identity,
672
+ project.get_vars if project is not None else None,
673
+ )
674
+ except Exception:
675
+ identity = ""
676
+ author = {"name": "", "email": ""}
677
+ vars_out["rig_identity"] = identity
678
+ vars_out["rig_git_author_name"] = author["name"]
679
+ vars_out["rig_git_author_email"] = author["email"]
656
680
  if action:
657
681
  vars_out["rig_action"] = action
658
682
  return vars_out
@@ -1820,6 +1844,16 @@ class RemoteDevManager:
1820
1844
  return dev_envs
1821
1845
 
1822
1846
 
1847
+ # Provider tokens (GH_TOKEN / GITLAB_TOKEN) written by authorize.yml. The agent
1848
+ # is started with `ssh host '<command>'`, a non-login shell, so /etc/profile.d
1849
+ # is never read: source the file here or `gh` / `glab` inside the agent's shell
1850
+ # commands have no token.
1851
+ PROVIDER_TOKENS_ENV_FILE = "/root/.config/rig/git-provider.env"
1852
+ SOURCE_PROVIDER_TOKENS = (
1853
+ f"[ -f {PROVIDER_TOKENS_ENV_FILE} ] && . {PROVIDER_TOKENS_ENV_FILE}; "
1854
+ )
1855
+
1856
+
1823
1857
  class RemoteDevEnvironment:
1824
1858
  """Manages a complete remote development environment"""
1825
1859
 
@@ -3005,6 +3039,7 @@ echo "Agent installation complete!"
3005
3039
  'export PATH="$HOME/.local/bin:$PATH"; '
3006
3040
  "set -a; "
3007
3041
  "[ -f /root/.claude/credentials.env ] && . /root/.claude/credentials.env; "
3042
+ f"{SOURCE_PROVIDER_TOKENS}"
3008
3043
  "set +a; "
3009
3044
  f"mkdir -p {REMOTE_WORKSPACE_ROOT} && "
3010
3045
  f"cd {REMOTE_WORKSPACE_ROOT} && exec claude{suffix}"
@@ -3014,6 +3049,7 @@ echo "Agent installation complete!"
3014
3049
  'export PATH="$HOME/.local/bin:$PATH"; '
3015
3050
  "set -a; "
3016
3051
  "[ -f /root/.cursor/credentials.env ] && . /root/.cursor/credentials.env; "
3052
+ f"{SOURCE_PROVIDER_TOKENS}"
3017
3053
  "set +a; "
3018
3054
  f"mkdir -p {REMOTE_WORKSPACE_ROOT} && "
3019
3055
  f"cd {REMOTE_WORKSPACE_ROOT} && exec agent --approve-mcps{suffix}"
@@ -3023,6 +3059,7 @@ echo "Agent installation complete!"
3023
3059
  "set -a; "
3024
3060
  "[ -f /root/.config/opencode/credentials.env ] && "
3025
3061
  ". /root/.config/opencode/credentials.env; "
3062
+ f"{SOURCE_PROVIDER_TOKENS}"
3026
3063
  "set +a; "
3027
3064
  f"mkdir -p {REMOTE_WORKSPACE_ROOT} && "
3028
3065
  f"cd {REMOTE_WORKSPACE_ROOT} && exec opencode{suffix}"
@@ -4129,6 +4166,89 @@ AUTHORIZE_PLAYBOOK = r"""---
4129
4166
  (rig_opencode_api_key | default('') | length > 0)
4130
4167
  or (rig_claude_api_key | default('') | length > 0)
4131
4168
  or (rig_cursor_api_key | default('') | length > 0)
4169
+
4170
+ # Git author: a fresh VM has none, so the first commit fails with
4171
+ # "Author identity unknown". Derived from the rig identity (see
4172
+ # cli/git_author.py); override with git_author_name / git_author_email.
4173
+ - name: Set the git author for commits made on the VM
4174
+ command:
4175
+ argv: ["git", "config", "--global", "{{ item.key }}", "{{ item.value }}"]
4176
+ loop:
4177
+ - { key: user.name, value: "{{ rig_git_author_name | default('') }}" }
4178
+ - { key: user.email, value: "{{ rig_git_author_email | default('') }}" }
4179
+ loop_control:
4180
+ label: "{{ item.key }}"
4181
+ changed_when: false
4182
+ when: item.value | length > 0
4183
+
4184
+ # Provider tokens: kept in one root-only file instead of being embedded in
4185
+ # repo URLs (where they would sit in every clone's .git/config and show up
4186
+ # in `git remote -v`). gh / glab read GH_TOKEN / GITLAB_TOKEN out of the box.
4187
+ - name: Provider tokens for git, gh and glab
4188
+ vars:
4189
+ _rig_gh_token: "{{ github_pat | default('') }}"
4190
+ _rig_gl_token: "{{ gitlab_pat | default('') }}"
4191
+ when: (_rig_gh_token | length > 0) or (_rig_gl_token | length > 0)
4192
+ block:
4193
+ - name: Ensure the rig config directory exists
4194
+ file:
4195
+ path: /root/.config/rig
4196
+ state: directory
4197
+ mode: "0700"
4198
+
4199
+ - name: Write the provider token file (root only)
4200
+ copy:
4201
+ dest: /root/.config/rig/git-provider.env
4202
+ mode: "0600"
4203
+ content: |
4204
+ {% if _rig_gh_token | length > 0 %}
4205
+ GH_TOKEN={{ _rig_gh_token }}
4206
+ {% endif %}
4207
+ {% if _rig_gl_token | length > 0 %}
4208
+ GITLAB_TOKEN={{ _rig_gl_token }}
4209
+ {% endif %}
4210
+ no_log: true
4211
+
4212
+ - name: Export the tokens in login shells (gh and glab work out of the box)
4213
+ copy:
4214
+ dest: /etc/profile.d/rig-git-provider.sh
4215
+ mode: "0644"
4216
+ content: |
4217
+ if [ -r /root/.config/rig/git-provider.env ]; then
4218
+ set -a
4219
+ . /root/.config/rig/git-provider.env
4220
+ set +a
4221
+ fi
4222
+
4223
+ - name: Install the git credential helper (answers from the root-only file)
4224
+ copy:
4225
+ dest: /usr/local/bin/rig-git-credential
4226
+ mode: "0755"
4227
+ content: |
4228
+ #!/bin/sh
4229
+ # git credential helper: serves GitHub/GitLab HTTPS credentials from
4230
+ # /root/.config/rig/git-provider.env so repo URLs stay plain. Only
4231
+ # root can read that file; any other user simply gets no answer.
4232
+ [ "$1" = get ] || exit 0
4233
+ host=""
4234
+ while IFS='=' read -r key value; do
4235
+ [ -z "$key" ] && break
4236
+ [ "$key" = host ] && host="$value"
4237
+ done
4238
+ [ -r /root/.config/rig/git-provider.env ] || exit 0
4239
+ . /root/.config/rig/git-provider.env
4240
+ case "$host" in
4241
+ github.com) user=x-access-token; pass="${GH_TOKEN:-}" ;;
4242
+ gitlab.com) user=oauth2; pass="${GITLAB_TOKEN:-}" ;;
4243
+ *) exit 0 ;;
4244
+ esac
4245
+ [ -n "$pass" ] || exit 0
4246
+ printf 'username=%s\npassword=%s\n' "$user" "$pass"
4247
+
4248
+ - name: Use the helper for every git HTTPS operation
4249
+ command:
4250
+ argv: ["git", "config", "--system", "credential.helper", "/usr/local/bin/rig-git-credential"]
4251
+ changed_when: false
4132
4252
  """
4133
4253
 
4134
4254
  # Materialize playbook (.rig/materialize.yml). Project content after authorize.
@@ -4150,6 +4270,12 @@ MATERIALIZE_PLAYBOOK = """---
4150
4270
  group: root
4151
4271
  mode: "0755"
4152
4272
 
4273
+ # Plain repo URLs: the token reaches git through an inline credential
4274
+ # helper fed from this task's environment, so it is never embedded in the
4275
+ # URL (where it would end up in every clone's .git/config and in
4276
+ # `git remote -v`) and never written to disk. Honours a per-repo
4277
+ # password_var, else github_pat / gitlab_pat. authorize.yml additionally
4278
+ # installs a system-wide helper so later `git pull/push` work too.
4153
4279
  - name: Clone configured git repositories
4154
4280
  vars:
4155
4281
  _pat_var: "{{ item.password_var | default('') }}"
@@ -4166,11 +4292,16 @@ MATERIALIZE_PLAYBOOK = """---
4166
4292
  environment:
4167
4293
  # Never hang on an interactive username/password prompt (missing PAT).
4168
4294
  GIT_TERMINAL_PROMPT: "0"
4295
+ RIG_GIT_USERNAME: "{{ _auth_user }}"
4296
+ RIG_GIT_PASSWORD: "{{ _pat }}"
4297
+ # Empty helper first: reset anything inherited, then answer from env.
4298
+ GIT_CONFIG_COUNT: "{{ 2 if (_pat | length > 0) else 0 }}"
4299
+ GIT_CONFIG_KEY_0: credential.helper
4300
+ GIT_CONFIG_VALUE_0: ""
4301
+ GIT_CONFIG_KEY_1: credential.helper
4302
+ GIT_CONFIG_VALUE_1: '!f() { test "$1" = get && { echo "username=$RIG_GIT_USERNAME"; echo "password=$RIG_GIT_PASSWORD"; }; }; f'
4169
4303
  git:
4170
- repo: >-
4171
- {{ item.repo
4172
- if (_pat | length == 0 or not item.repo.startswith('https://'))
4173
- else item.repo.replace('https://', 'https://' ~ _auth_user ~ ':' ~ _pat ~ '@', 1) }}
4304
+ repo: "{{ item.repo }}"
4174
4305
  dest: "{{ item.dest }}"
4175
4306
  version: "{{ item.version | default(omit) }}"
4176
4307
  accept_hostkey: "{{ item.accept_hostkey | default(true) }}"
@@ -6136,6 +6267,11 @@ class AnsibleManager:
6136
6267
  self.ansible_env['ANSIBLE_FILTER_PLUGINS'] = rig_filter_plugins_path(
6137
6268
  self.ansible_env.get('ANSIBLE_FILTER_PLUGINS')
6138
6269
  )
6270
+ # A fresh VM can be slow to answer the SSH banner while cloud-init is busy.
6271
+ # Ansible's 10s default fails the first task as UNREACHABLE, so allow longer
6272
+ # and retry. Anything the user already set in the environment wins.
6273
+ for key, value in ANSIBLE_SSH_DEFAULTS.items():
6274
+ self.ansible_env.setdefault(key, value)
6139
6275
  if os.path.basename(playbook_path) == ProjectConfig.AUTHORIZE_YAML:
6140
6276
  from cli.mcp import legacy_files_with_servers, legacy_warning
6141
6277
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mystack-rig
3
- Version: 1.3.0
3
+ Version: 1.3.1
4
4
  Summary: Ephemeral remotes with full local parity for coding agents
5
5
  Author: mystack-cloud
6
6
  License-Expression: MIT
@@ -301,6 +301,8 @@ Playbooks load `.rig/vars.yml` then `.rig/vars.{identity}.yml` (personal wins),
301
301
  | `rig_firewall_name` | Firewall resource name |
302
302
  | `rig_repos` | `[{name, url, path}, …]` (no secrets) |
303
303
  | `rig_git_providers` | e.g. `github`, `gitlab` |
304
+ | `rig_identity` | Developer identity (the `.rig/vars.{identity}.yml` handle) |
305
+ | `rig_git_author_name` / `rig_git_author_email` | Git author set on the VM (see [Git credentials and author](#git-credentials-and-author)) |
304
306
 
305
307
  Also available from vars files (defaults): `workspace_root`, `coding_agent_type`, `coding_agent_types`, `git.clone_repos`. On `rig init`, git PATs and each coding agent API key default to **personal** storage in `vars.{identity}.yml` (you are asked to confirm once); shared secrets such as `vscode_browser_password` live in `vars.yml`.
306
308
 
@@ -367,3 +369,37 @@ Push a version tag to publish that version to PyPI. The package version is the t
367
369
  ## License
368
370
 
369
371
  MIT
372
+
373
+ ## Git credentials and author
374
+
375
+ **Provider tokens never go into repo URLs.** `authorize.yml` (managed) takes
376
+ `github_pat` / `gitlab_pat` from the vars files and writes them to
377
+ `/root/.config/rig/git-provider.env` (mode `0600`, root only). From there:
378
+
379
+ - login shells get `GH_TOKEN` / `GITLAB_TOKEN` via `/etc/profile.d`, and `rig attach`
380
+ exports them to the agent process itself (it starts the agent in a non-login
381
+ shell, which never reads `/etc/profile.d`), so `gh` and `glab` work out of the
382
+ box in both;
383
+ - a system-wide git credential helper (`/usr/local/bin/rig-git-credential`)
384
+ answers `github.com` / `gitlab.com` HTTPS requests from that same file, so
385
+ `git clone`, `git push` and the `materialize.yml` clone task all use plain
386
+ URLs (`https://github.com/org/repo.git`) and nothing sits in `.git/config`
387
+ or `git remote -v`. Other users on the VM can't read the file and get no
388
+ credentials.
389
+
390
+ The `materialize.yml` clone task passes the token to git through an inline
391
+ helper fed from the task's environment (a per-repo `password_var` still wins over
392
+ `github_pat` / `gitlab_pat`), so it never touches the URL or disk. Projects
393
+ scaffolded by an older rig still have the token-in-URL clone task in their
394
+ `materialize.yml` (user-owned, never overwritten): copy the `vars:` and
395
+ `environment:` blocks of the current template and set `repo: "{{ item.repo }}"`.
396
+
397
+ **Git author.** A fresh VM has no git identity, so the first commit would fail
398
+ with *Author identity unknown*. `authorize.yml` sets `user.name` / `user.email`
399
+ (global) from `rig_git_author_name` / `rig_git_author_email`, which rig derives
400
+ from your identity: the identity as the name and `<identity>@rig.local` as the
401
+ email. Set `git_author_name` / `git_author_email` in `.rig/vars.yml`, or in your
402
+ personal `.rig/vars.{identity}.yml`, to use a real name and a GitHub-linked
403
+ email (the derived `rig.local` address is deliberately not a
404
+ `users.noreply.github.com` one, which GitHub would attribute to whoever owns
405
+ that handle).
@@ -37,6 +37,7 @@ src/cli/agents.py
37
37
  src/cli/config.py
38
38
  src/cli/encrypt.py
39
39
  src/cli/git.py
40
+ src/cli/git_author.py
40
41
  src/cli/last_env.py
41
42
  src/cli/last_session.py
42
43
  src/cli/log.py
@@ -71,6 +72,7 @@ tests/test_encrypt_command.py
71
72
  tests/test_encrypt_coverage.py
72
73
  tests/test_firewall_client_ip.py
73
74
  tests/test_git_clone_unit.py
75
+ tests/test_git_credentials_and_author.py
74
76
  tests/test_git_manager.py
75
77
  tests/test_gitignore_init.py
76
78
  tests/test_hetzner_storage.py
@@ -93,6 +95,7 @@ tests/test_remote_dev.py
93
95
  tests/test_remote_dev_coverage_extensions.py
94
96
  tests/test_rig_ansible_vars.py
95
97
  tests/test_rig_config.py
98
+ tests/test_secret_prompt_hidden.py
96
99
  tests/test_setup_provision.py
97
100
  tests/test_simulation_storage.py
98
101
  tests/test_small_module_coverage.py
@@ -40,6 +40,7 @@
40
40
  "src/cli/config.py",
41
41
  "src/cli/encrypt.py",
42
42
  "src/cli/git.py",
43
+ "src/cli/git_author.py",
43
44
  "src/cli/last_env.py",
44
45
  "src/cli/last_session.py",
45
46
  "src/cli/log.py",
@@ -65,6 +66,7 @@
65
66
  "tests/test_encrypt_coverage.py",
66
67
  "tests/test_firewall_client_ip.py",
67
68
  "tests/test_git_clone_unit.py",
69
+ "tests/test_git_credentials_and_author.py",
68
70
  "tests/test_git_manager.py",
69
71
  "tests/test_gitignore_init.py",
70
72
  "tests/test_hetzner_storage.py",
@@ -87,6 +89,7 @@
87
89
  "tests/test_remote_dev_coverage_extensions.py",
88
90
  "tests/test_rig_ansible_vars.py",
89
91
  "tests/test_rig_config.py",
92
+ "tests/test_secret_prompt_hidden.py",
90
93
  "tests/test_setup_provision.py",
91
94
  "tests/test_simulation_storage.py",
92
95
  "tests/test_small_module_coverage.py",
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "1.3.1",
3
+ "distance": 0,
4
+ "node": "g57c75aa7416e449fcfc837170081ef6c0f31d434",
5
+ "dirty": false,
6
+ "branch": "HEAD",
7
+ "node_date": "2026-11-18"
8
+ }