mystack-rig 1.7.3__tar.gz → 1.8.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/CLAUDE.md +1 -1
  2. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/PKG-INFO +1 -1
  3. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/agents.py +18 -0
  4. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/encrypt.py +56 -2
  5. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/main.py +3 -1
  6. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/remote_dev.py +3 -1
  7. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/vault_keys.py +1 -0
  8. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/mystack_rig.egg-info/PKG-INFO +1 -1
  9. mystack_rig-1.8.0/src/mystack_rig.egg-info/scm_version.json +8 -0
  10. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_encrypt_coverage.py +59 -0
  11. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_main_coverage.py +24 -0
  12. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_setup_provision.py +12 -2
  13. mystack_rig-1.7.3/src/mystack_rig.egg-info/scm_version.json +0 -8
  14. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/.coveragerc +0 -0
  15. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/.git-blame-ignore-revs +0 -0
  16. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/.github/workflows/release.yml +0 -0
  17. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/.github/workflows/tests.yml +0 -0
  18. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/.gitignore +0 -0
  19. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/.rig/playbooks/README.md +0 -0
  20. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/.rig/playbooks/vpn-gateway.yml +0 -0
  21. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/CLI_STORAGE_SUMMARY.md +0 -0
  22. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/Dockerfile +0 -0
  23. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/GIT_CLONE_FEATURE.md +0 -0
  24. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/GLOSSARY.md +0 -0
  25. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/HETZNER_STORAGE_GUIDE.md +0 -0
  26. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/HETZNER_STORAGE_SECURITY_GUIDE.md +0 -0
  27. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/LICENSE +0 -0
  28. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/Makefile +0 -0
  29. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/README.md +0 -0
  30. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/README_REAL_E2E.md +0 -0
  31. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/STORAGE_CLI_GUIDE.md +0 -0
  32. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/docs/adr/0001-per-profile-generated-state-bucket.md +0 -0
  33. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/docs/adr/0002-outputs-as-separate-object-via-file-handoff.md +0 -0
  34. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/docs/adr/0003-mcp-servers-declared-once-rendered-at-authorize.md +0 -0
  35. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/docs/adr/0004-agents-run-as-live-agents-in-tmux.md +0 -0
  36. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/docs/adr/0005-docker-in-configure-for-devcontainers.md +0 -0
  37. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/docs/adr/0006-workspace-user-instead-of-root.md +0 -0
  38. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/docs/architecture.md +0 -0
  39. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/docs/architecture.png +0 -0
  40. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/docs/architecture.svg +0 -0
  41. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/forged-idea.md +0 -0
  42. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/pyproject.toml +0 -0
  43. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/pytest.ini +0 -0
  44. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/requirements.txt +0 -0
  45. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/sample.env +0 -0
  46. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/scripts/coverage_badge.py +0 -0
  47. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/scripts/pypi_version.py +0 -0
  48. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/setup.cfg +0 -0
  49. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/__init__.py +0 -0
  50. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/__init__.py +0 -0
  51. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/__main__.py +0 -0
  52. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/ansible_filters/__init__.py +0 -0
  53. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/ansible_filters/rig_live.py +0 -0
  54. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/ansible_filters/rig_mcp.py +0 -0
  55. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/assets/rig-agent-queue +0 -0
  56. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/assets/rig-agent-state +0 -0
  57. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/assets/tmux.conf +0 -0
  58. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/config.py +0 -0
  59. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/devcontainers.py +0 -0
  60. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/git.py +0 -0
  61. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/git_author.py +0 -0
  62. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/last_env.py +0 -0
  63. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/last_session.py +0 -0
  64. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/last_target.py +0 -0
  65. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/live_agent.py +0 -0
  66. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/log.py +0 -0
  67. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/mcp.py +0 -0
  68. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/outputs.py +0 -0
  69. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/requirements.txt +0 -0
  70. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/snapshots.py +0 -0
  71. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/state_bucket.py +0 -0
  72. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/storage.py +0 -0
  73. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/vpn.py +0 -0
  74. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/workspace_user.py +0 -0
  75. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/mystack_rig.egg-info/SOURCES.txt +0 -0
  76. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/mystack_rig.egg-info/dependency_links.txt +0 -0
  77. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/mystack_rig.egg-info/entry_points.txt +0 -0
  78. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/mystack_rig.egg-info/requires.txt +0 -0
  79. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/mystack_rig.egg-info/scm_file_list.json +0 -0
  80. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/mystack_rig.egg-info/top_level.txt +0 -0
  81. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/test_hetzner_integration.py +0 -0
  82. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/conftest.py +0 -0
  83. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_agents.py +0 -0
  84. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_ansible_galaxy.py +0 -0
  85. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_attach_command.py +0 -0
  86. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_credential_security.py +0 -0
  87. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_destroy_command.py +0 -0
  88. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_dev_command.py +0 -0
  89. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_devcontainers.py +0 -0
  90. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_encrypt_command.py +0 -0
  91. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_firewall_client_ip.py +0 -0
  92. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_git_clone_unit.py +0 -0
  93. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_git_credentials_and_author.py +0 -0
  94. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_git_manager.py +0 -0
  95. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_gitignore_init.py +0 -0
  96. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_hetzner_storage.py +0 -0
  97. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_init_command.py +0 -0
  98. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_inspect_describe.py +0 -0
  99. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_last_env.py +0 -0
  100. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_last_session.py +0 -0
  101. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_last_target.py +0 -0
  102. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_live_agent.py +0 -0
  103. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_live_agent_cli.py +0 -0
  104. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_log.py +0 -0
  105. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_mcp_command.py +0 -0
  106. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_mcp_render.py +0 -0
  107. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_outputs.py +0 -0
  108. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_outputs_storage.py +0 -0
  109. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_pypi_version.py +0 -0
  110. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_python_floor.py +0 -0
  111. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_r2_storage.py +0 -0
  112. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_real_e2e_integration.py +0 -0
  113. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_real_e2e_storage.py +0 -0
  114. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_real_e2e_vpn.py +0 -0
  115. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_real_e2e_vpn_tunnel.py +0 -0
  116. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_remote_dev.py +0 -0
  117. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_remote_dev_coverage_extensions.py +0 -0
  118. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_rig_ansible_vars.py +0 -0
  119. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_rig_config.py +0 -0
  120. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_secret_prompt_hidden.py +0 -0
  121. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_simulation_storage.py +0 -0
  122. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_small_module_coverage.py +0 -0
  123. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_snapshots.py +0 -0
  124. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_state_bucket.py +0 -0
  125. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_storage_basic.py +0 -0
  126. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_vault_keys.py +0 -0
  127. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_vpn_optional.py +0 -0
  128. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_vpn_unit.py +0 -0
  129. {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_workspace_git_clone.py +0 -0
@@ -6,7 +6,7 @@ Vocabulary is in `GLOSSARY.md`; decisions are in `docs/adr/`.
6
6
 
7
7
  Do every step, in order. Don't stop after the PR.
8
8
 
9
- 1. **Branch** off `master`: `fix/<what>` or `feat/<what>`. Never commit to `master`.
9
+ 1. **Sync, then branch.** `git checkout master && git pull --ff-only origin master`, then branch off it: `fix/<what>` or `feat/<what>`. Never commit to `master`.
10
10
  2. **Test first.** Add a test that fails without the fix. Keep the diff to what the bug needs.
11
11
  3. **Run the CI gates locally** (same versions as CI):
12
12
  - `uvx ruff@0.17.5 check .` and `uvx ruff@0.17.5 format --check .` (run `format .` to fix)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mystack-rig
3
- Version: 1.7.3
3
+ Version: 1.8.0
4
4
  Summary: Ephemeral remotes with full local parity for coding agents
5
5
  Author: mystack-cloud
6
6
  License-Expression: MIT
@@ -44,6 +44,24 @@ AGENT_API_KEY_ENVS = {
44
44
 
45
45
  LEGACY_CODING_AGENT_API_KEY = "coding_agent_api_key"
46
46
 
47
+ # Claude Code takes either an OAuth token (``claude setup-token``) or an
48
+ # Anthropic API key, and only one of CLAUDE_CODE_OAUTH_TOKEN / ANTHROPIC_API_KEY
49
+ # may be set. The kind is detected from the key prefix; when that is not
50
+ # conclusive the user is asked and the answer is stored here.
51
+ CLAUDE_AUTH_TYPE_VAR = "claude_auth_type"
52
+ CLAUDE_AUTH_TYPES = ("oauth", "api_key")
53
+
54
+
55
+ def detect_claude_auth_type(key: str | None) -> str | None:
56
+ """Return ``"oauth"`` or ``"api_key"`` from the key prefix, or None if unsure."""
57
+ value = (key or "").strip()
58
+ if value.startswith("sk-ant-oat"):
59
+ return "oauth"
60
+ if value.startswith("sk-ant-api"):
61
+ return "api_key"
62
+ return None
63
+
64
+
47
65
  # Env var name referenced from generated configs; set by authorize.yml on the VM.
48
66
  CODING_AGENT_API_KEY_ENV = "CODING_AGENT_API_KEY"
49
67
 
@@ -724,6 +724,54 @@ def prompt_and_store_git_pat(
724
724
  return password_vars
725
725
 
726
726
 
727
+ def _resolve_claude_auth_type(api_key: str, input_fn: Callable[..., str] | None = None) -> str | None:
728
+ """Detect whether a Claude key is an OAuth token or an API key; ask if unsure.
729
+
730
+ Returns None when undetectable and the user gives no answer; the VM then
731
+ falls back to prefix detection (and API-key behaviour for unknown prefixes).
732
+ """
733
+ from cli.agents import detect_claude_auth_type
734
+
735
+ detected = detect_claude_auth_type(api_key)
736
+ if detected:
737
+ return detected
738
+ ask = input_fn or input
739
+ answer = (
740
+ ask(
741
+ "Can't tell what kind of Claude credential this is. "
742
+ "Is it an OAuth token from `claude setup-token` (o) or an Anthropic API key (k)? [o/k, Enter = API key]: "
743
+ )
744
+ .strip()
745
+ .lower()
746
+ )
747
+ if answer.startswith("o"):
748
+ return "oauth"
749
+ if answer.startswith("k"):
750
+ return "api_key"
751
+ return None
752
+
753
+
754
+ def _store_claude_auth_type(
755
+ api_key: str,
756
+ *,
757
+ root: str,
758
+ key_path: str,
759
+ personal: bool,
760
+ input_fn: Callable[..., str] | None = None,
761
+ ) -> None:
762
+ from cli.agents import CLAUDE_AUTH_TYPE_VAR
763
+
764
+ kind = _resolve_claude_auth_type(api_key, input_fn)
765
+ if kind:
766
+ store_encrypted_var(
767
+ CLAUDE_AUTH_TYPE_VAR,
768
+ kind,
769
+ project_dir=root,
770
+ data_key_path=key_path,
771
+ personal=personal,
772
+ )
773
+
774
+
727
775
  def prompt_and_store_coding_agent_credentials(
728
776
  project_dir: str | None = None,
729
777
  data_key_path: str | None = None,
@@ -770,7 +818,7 @@ def prompt_and_store_coding_agent_credentials(
770
818
  elif agent_normalized == "cursor":
771
819
  skip_hint = " [Enter = skip; Cursor CLI needs CURSOR_API_KEY on the VM]"
772
820
  elif agent_normalized == "claude":
773
- skip_hint = " [Enter = skip; Claude Code needs an Anthropic API key]"
821
+ skip_hint = " [Enter = skip; Claude Code needs an Anthropic API key or OAuth token]"
774
822
  else:
775
823
  skip_hint = ""
776
824
  api_key = _prompt_secret_with_env_fallback(
@@ -800,6 +848,8 @@ def prompt_and_store_coding_agent_credentials(
800
848
  )
801
849
  scope = "personal" if personal else "shared"
802
850
  print(f"Stored {stored_name} as a {scope} secret")
851
+ if agent_normalized == "claude":
852
+ _store_claude_auth_type(api_key, root=root, key_path=key_path, personal=bool(personal), input_fn=input_fn)
803
853
  return True
804
854
 
805
855
 
@@ -836,7 +886,7 @@ def prompt_and_store_coding_agents_credentials(
836
886
  elif agent == "cursor":
837
887
  skip_hint = " [Enter = skip; Cursor CLI needs CURSOR_API_KEY on the VM]"
838
888
  else:
839
- skip_hint = " [Enter = skip; Claude Code needs an Anthropic API key]"
889
+ skip_hint = " [Enter = skip; Claude Code needs an Anthropic API key or OAuth token]"
840
890
  api_key = _prompt_secret_with_env_fallback(
841
891
  f"{label}{skip_hint}",
842
892
  AGENT_API_KEY_ENVS[agent],
@@ -871,6 +921,10 @@ def prompt_and_store_coding_agents_credentials(
871
921
  personal=bool(personal),
872
922
  )
873
923
  print(f"Stored {var_name} as a {scope} secret")
924
+ if agent == "claude":
925
+ _store_claude_auth_type(
926
+ api_key, root=root, key_path=key_path, personal=bool(personal), input_fn=input_fn
927
+ )
874
928
  return {agent: agent in collected for agent in selected}
875
929
 
876
930
 
@@ -117,6 +117,9 @@ def _cmd_create(args: argparse.Namespace) -> int:
117
117
  force_workspace = bool(getattr(args, "force_workspace", False) or getattr(args, "force_playbooks", False))
118
118
  if not env.setup(project_dir=os.getcwd()):
119
119
  return 1
120
+ # The VM exists now: remember it before provisioning so a playbook
121
+ # failure still leaves `rig attach/delete` with a default target.
122
+ remember_last_env(env.name)
120
123
 
121
124
  # Provision via Ansible (system.yml then workspace.yml) with live output.
122
125
  # Matching snapshots skip covered playbooks unless --force-* is set.
@@ -129,7 +132,6 @@ def _cmd_create(args: argparse.Namespace) -> int:
129
132
  return 1
130
133
 
131
134
  log.info("Environment '%s' created", env.name)
132
- remember_last_env(env.name)
133
135
  if getattr(args, "no_attach", False):
134
136
  log.info("Skipped agent attach; reconnect with: rig attach / rig dev")
135
137
  log.debug("Reconnect: rig attach %s", env.name)
@@ -4468,7 +4468,9 @@ AUTHORIZE_PLAYBOOK = r"""---
4468
4468
  mode: "0600"
4469
4469
  content: |
4470
4470
  CODING_AGENT_API_KEY={{ rig_claude_api_key }}
4471
- {% if rig_claude_api_key.startswith('sk-ant-oat01') %}
4471
+ {# Only one of the two may be set. An explicit claude_auth_type (asked at setup) wins; else the key prefix decides. #}
4472
+ {% set _kind = claude_auth_type | default('') %}
4473
+ {% if _kind == 'oauth' or (_kind != 'api_key' and rig_claude_api_key.startswith('sk-ant-oat')) %}
4472
4474
  CLAUDE_CODE_OAUTH_TOKEN={{ rig_claude_api_key }}
4473
4475
  {% else %}
4474
4476
  ANTHROPIC_API_KEY={{ rig_claude_api_key }}
@@ -441,6 +441,7 @@ def is_personal_secret_name(name: str) -> bool:
441
441
  "coding_agent_api_key",
442
442
  "opencode_api_key",
443
443
  "claude_api_key",
444
+ "claude_auth_type",
444
445
  "cursor_api_key",
445
446
  "github_pat",
446
447
  "gitlab_pat",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mystack-rig
3
- Version: 1.7.3
3
+ Version: 1.8.0
4
4
  Summary: Ephemeral remotes with full local parity for coding agents
5
5
  Author: mystack-cloud
6
6
  License-Expression: MIT
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "1.8.0",
3
+ "distance": 0,
4
+ "node": "g6af0c516330825ca0af01ca0aeff338aa4c8dca5",
5
+ "dirty": false,
6
+ "branch": "HEAD",
7
+ "node_date": "2026-11-28"
8
+ }
@@ -226,3 +226,62 @@ def test_detect_git_provider_self_hosted_gitlab(url, expected):
226
226
  from cli import encrypt as enc
227
227
 
228
228
  assert enc.detect_git_provider(url) == expected
229
+
230
+
231
+ def test_detect_claude_auth_type():
232
+ from cli.agents import detect_claude_auth_type
233
+
234
+ assert detect_claude_auth_type("sk-ant-oat01-x") == "oauth"
235
+ assert detect_claude_auth_type("sk-ant-api03-x") == "api_key"
236
+ assert detect_claude_auth_type("mystery") is None
237
+ assert detect_claude_auth_type(None) is None
238
+
239
+
240
+ def _store_claude_key(tmp_path, monkeypatch, key, answers, agents=None):
241
+ from cli import encrypt as enc
242
+
243
+ monkeypatch.chdir(tmp_path)
244
+ (tmp_path / "rig.yml").write_text("name: demo\nkind: workspace\n")
245
+ (tmp_path / ".rig").mkdir(exist_ok=True)
246
+ asked = []
247
+
248
+ def ask(prompt=""):
249
+ asked.append(prompt)
250
+ return answers
251
+
252
+ with (
253
+ patch("cli.encrypt.unlock_data_keys", return_value=("p", "s")),
254
+ patch("cli.encrypt.store_encrypted_var") as store,
255
+ patch("cli.encrypt._prompt_secret_with_env_fallback", return_value=key),
256
+ ):
257
+ if agents:
258
+ enc.prompt_and_store_coding_agents_credentials(
259
+ agents, project_dir=str(tmp_path), input_fn=ask, secret_fn=lambda *_: "", personal=True
260
+ )
261
+ else:
262
+ enc.prompt_and_store_coding_agent_credentials(
263
+ project_dir=str(tmp_path), agent_type="claude", input_fn=ask, secret_fn=lambda *_: "", personal=True
264
+ )
265
+ stored = {c.args[0]: c.args[1] for c in store.call_args_list}
266
+ return stored, asked
267
+
268
+
269
+ def test_claude_auth_type_detected_without_asking(tmp_path, monkeypatch):
270
+ stored, asked = _store_claude_key(tmp_path, monkeypatch, "sk-ant-oat01-x", "")
271
+ assert stored["claude_auth_type"] == "oauth"
272
+ assert asked == []
273
+
274
+
275
+ def test_claude_auth_type_asks_when_unknown(tmp_path, monkeypatch):
276
+ stored, asked = _store_claude_key(tmp_path, monkeypatch, "mystery", "o")
277
+ assert stored["claude_auth_type"] == "oauth"
278
+ assert len(asked) == 1
279
+ stored, _ = _store_claude_key(tmp_path, monkeypatch, "mystery", "k")
280
+ assert stored["claude_auth_type"] == "api_key"
281
+ stored, _ = _store_claude_key(tmp_path, monkeypatch, "mystery", "")
282
+ assert "claude_auth_type" not in stored
283
+
284
+
285
+ def test_claude_auth_type_stored_for_multi_agent(tmp_path, monkeypatch):
286
+ stored, _ = _store_claude_key(tmp_path, monkeypatch, "sk-ant-api03-x", "", agents=["claude"])
287
+ assert stored["claude_auth_type"] == "api_key"
@@ -284,6 +284,30 @@ def test_create_success_and_no_attach(tok_env, tmp_path, capsys):
284
284
  remember.assert_called()
285
285
 
286
286
 
287
+ def test_create_remembers_env_when_provision_fails(tok_env, tmp_path):
288
+ (tmp_path / "rig.yml").write_text("name: p\n")
289
+ with (
290
+ patch("cli.main._load_credentials"),
291
+ patch("cli.main.StorageManager", side_effect=ValueError("no storage")),
292
+ patch("cli.main.ProjectConfig") as pc_cls,
293
+ patch("cli.main.RemoteDevEnvironment") as env_cls,
294
+ patch("cli.main.remember_last_env") as remember,
295
+ patch("cli.main.os.getcwd", return_value=str(tmp_path)),
296
+ ):
297
+ pc = MagicMock()
298
+ pc.config = {"vm": {}}
299
+ pc.load.return_value = True
300
+ pc_cls.return_value = pc
301
+ inst = MagicMock()
302
+ inst.name = "dev-c1"
303
+ inst.setup.return_value = True
304
+ inst.provision.return_value = False
305
+ env_cls.return_value = inst
306
+
307
+ assert main(["create", "--name", "c1"]) == 1
308
+ remember.assert_called_once_with("dev-c1")
309
+
310
+
287
311
  def test_create_setup_fails(tok_env, tmp_path, capsys):
288
312
  (tmp_path / "rig.yml").write_text("name: p\n")
289
313
  with (
@@ -847,7 +847,7 @@ def test_create_provider_override(tmp_path, monkeypatch, capsys):
847
847
  assert "gcp" in err
848
848
 
849
849
 
850
- def _render_claude_credentials(token):
850
+ def _render_claude_credentials(token, **extra):
851
851
  import jinja2
852
852
  import yaml
853
853
 
@@ -857,7 +857,7 @@ def _render_claude_credentials(token):
857
857
  task = next(t for t in play["tasks"] if t["name"] == "Write Claude credentials env file")
858
858
  # Ansible templates with trim_blocks enabled.
859
859
  env = jinja2.Environment(trim_blocks=True)
860
- return env.from_string(task["copy"]["content"]).render(rig_claude_api_key=token)
860
+ return env.from_string(task["copy"]["content"]).render(rig_claude_api_key=token, **extra)
861
861
 
862
862
 
863
863
  def test_claude_oauth_token_exported_as_claude_code_oauth_token():
@@ -873,6 +873,16 @@ def test_claude_api_key_still_exported_as_anthropic_api_key():
873
873
  assert "CLAUDE_CODE_OAUTH_TOKEN" not in out
874
874
 
875
875
 
876
+ def test_claude_auth_type_overrides_prefix_and_never_sets_both():
877
+ out = _render_claude_credentials("opaque-token", claude_auth_type="oauth")
878
+ assert "CLAUDE_CODE_OAUTH_TOKEN=opaque-token\n" in out
879
+ assert "ANTHROPIC_API_KEY" not in out
880
+ out = _render_claude_credentials("sk-ant-oat01-abc", claude_auth_type="api_key")
881
+ assert "ANTHROPIC_API_KEY=sk-ant-oat01-abc\n" in out
882
+ assert "CLAUDE_CODE_OAUTH_TOKEN" not in out
883
+ assert "{#" not in out and "\n\n" not in out
884
+
885
+
876
886
  def _authorize_tasks():
877
887
  import yaml
878
888
 
@@ -1,8 +0,0 @@
1
- {
2
- "tag": "1.7.3",
3
- "distance": 0,
4
- "node": "g2225e2ef4f75670af0950c25b440ccee3a3f9e55",
5
- "dirty": false,
6
- "branch": "HEAD",
7
- "node_date": "2026-11-27"
8
- }
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