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.
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/CLAUDE.md +1 -1
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/PKG-INFO +1 -1
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/agents.py +18 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/encrypt.py +56 -2
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/main.py +3 -1
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/remote_dev.py +3 -1
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/vault_keys.py +1 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/mystack_rig.egg-info/PKG-INFO +1 -1
- mystack_rig-1.8.0/src/mystack_rig.egg-info/scm_version.json +8 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_encrypt_coverage.py +59 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_main_coverage.py +24 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_setup_provision.py +12 -2
- mystack_rig-1.7.3/src/mystack_rig.egg-info/scm_version.json +0 -8
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/.coveragerc +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/.git-blame-ignore-revs +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/.github/workflows/release.yml +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/.github/workflows/tests.yml +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/.gitignore +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/.rig/playbooks/README.md +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/.rig/playbooks/vpn-gateway.yml +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/CLI_STORAGE_SUMMARY.md +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/Dockerfile +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/GIT_CLONE_FEATURE.md +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/GLOSSARY.md +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/HETZNER_STORAGE_GUIDE.md +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/HETZNER_STORAGE_SECURITY_GUIDE.md +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/LICENSE +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/Makefile +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/README.md +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/README_REAL_E2E.md +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/STORAGE_CLI_GUIDE.md +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/docs/adr/0001-per-profile-generated-state-bucket.md +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/docs/adr/0002-outputs-as-separate-object-via-file-handoff.md +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/docs/adr/0003-mcp-servers-declared-once-rendered-at-authorize.md +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/docs/adr/0004-agents-run-as-live-agents-in-tmux.md +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/docs/adr/0005-docker-in-configure-for-devcontainers.md +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/docs/adr/0006-workspace-user-instead-of-root.md +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/docs/architecture.md +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/docs/architecture.png +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/docs/architecture.svg +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/forged-idea.md +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/pyproject.toml +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/pytest.ini +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/requirements.txt +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/sample.env +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/scripts/coverage_badge.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/scripts/pypi_version.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/setup.cfg +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/__init__.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/__init__.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/__main__.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/ansible_filters/__init__.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/ansible_filters/rig_live.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/ansible_filters/rig_mcp.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/assets/rig-agent-queue +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/assets/rig-agent-state +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/assets/tmux.conf +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/config.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/devcontainers.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/git.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/git_author.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/last_env.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/last_session.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/last_target.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/live_agent.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/log.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/mcp.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/outputs.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/requirements.txt +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/snapshots.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/state_bucket.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/storage.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/vpn.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/cli/workspace_user.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/mystack_rig.egg-info/SOURCES.txt +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/mystack_rig.egg-info/dependency_links.txt +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/mystack_rig.egg-info/entry_points.txt +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/mystack_rig.egg-info/requires.txt +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/mystack_rig.egg-info/scm_file_list.json +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/src/mystack_rig.egg-info/top_level.txt +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/test_hetzner_integration.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/conftest.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_agents.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_ansible_galaxy.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_attach_command.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_credential_security.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_destroy_command.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_dev_command.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_devcontainers.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_encrypt_command.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_firewall_client_ip.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_git_clone_unit.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_git_credentials_and_author.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_git_manager.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_gitignore_init.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_hetzner_storage.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_init_command.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_inspect_describe.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_last_env.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_last_session.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_last_target.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_live_agent.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_live_agent_cli.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_log.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_mcp_command.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_mcp_render.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_outputs.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_outputs_storage.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_pypi_version.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_python_floor.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_r2_storage.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_real_e2e_integration.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_real_e2e_storage.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_real_e2e_vpn.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_real_e2e_vpn_tunnel.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_remote_dev.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_remote_dev_coverage_extensions.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_rig_ansible_vars.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_rig_config.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_secret_prompt_hidden.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_simulation_storage.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_small_module_coverage.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_snapshots.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_state_bucket.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_storage_basic.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_vault_keys.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_vpn_optional.py +0 -0
- {mystack_rig-1.7.3 → mystack_rig-1.8.0}/tests/test_vpn_unit.py +0 -0
- {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. **
|
|
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)
|
|
@@ -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
|
-
{
|
|
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 }}
|
|
@@ -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
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mystack_rig-1.7.3 → mystack_rig-1.8.0}/docs/adr/0002-outputs-as-separate-object-via-file-handoff.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mystack_rig-1.7.3 → mystack_rig-1.8.0}/docs/adr/0005-docker-in-configure-for-devcontainers.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|