mystack-rig 1.2.0__tar.gz → 1.3.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 (109) hide show
  1. mystack_rig-1.3.0/GLOSSARY.md +45 -0
  2. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/PKG-INFO +71 -5
  3. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/README.md +70 -4
  4. mystack_rig-1.3.0/docs/adr/0002-outputs-as-separate-object-via-file-handoff.md +16 -0
  5. mystack_rig-1.3.0/docs/adr/0003-mcp-servers-declared-once-rendered-at-authorize.md +18 -0
  6. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/cli/agents.py +12 -51
  7. mystack_rig-1.3.0/src/cli/ansible_filters/__init__.py +0 -0
  8. mystack_rig-1.3.0/src/cli/ansible_filters/rig_mcp.py +318 -0
  9. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/cli/main.py +189 -1
  10. mystack_rig-1.3.0/src/cli/mcp.py +267 -0
  11. mystack_rig-1.3.0/src/cli/outputs.py +102 -0
  12. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/cli/remote_dev.py +422 -118
  13. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/cli/snapshots.py +10 -28
  14. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/cli/vault_keys.py +9 -1
  15. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/mystack_rig.egg-info/PKG-INFO +71 -5
  16. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/mystack_rig.egg-info/SOURCES.txt +11 -0
  17. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/mystack_rig.egg-info/scm_file_list.json +11 -0
  18. mystack_rig-1.3.0/src/mystack_rig.egg-info/scm_version.json +8 -0
  19. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_agents.py +3 -3
  20. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_ansible_galaxy.py +12 -32
  21. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_init_command.py +4 -4
  22. mystack_rig-1.3.0/tests/test_inspect_describe.py +261 -0
  23. mystack_rig-1.3.0/tests/test_mcp_command.py +293 -0
  24. mystack_rig-1.3.0/tests/test_mcp_render.py +199 -0
  25. mystack_rig-1.3.0/tests/test_outputs.py +209 -0
  26. mystack_rig-1.3.0/tests/test_outputs_storage.py +210 -0
  27. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_remote_dev_coverage_extensions.py +91 -0
  28. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_setup_provision.py +306 -0
  29. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_snapshots.py +34 -3
  30. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_vault_keys.py +21 -0
  31. mystack_rig-1.2.0/GLOSSARY.md +0 -21
  32. mystack_rig-1.2.0/src/mystack_rig.egg-info/scm_version.json +0 -8
  33. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/.coveragerc +0 -0
  34. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/.flake8 +0 -0
  35. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/.github/workflows/release.yml +0 -0
  36. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/.github/workflows/tests.yml +0 -0
  37. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/.gitignore +0 -0
  38. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/.rig/playbooks/README.md +0 -0
  39. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/.rig/playbooks/vpn-gateway.yml +0 -0
  40. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/CLI_STORAGE_SUMMARY.md +0 -0
  41. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/Dockerfile +0 -0
  42. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/GIT_CLONE_FEATURE.md +0 -0
  43. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/HETZNER_STORAGE_GUIDE.md +0 -0
  44. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/HETZNER_STORAGE_SECURITY_GUIDE.md +0 -0
  45. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/LICENSE +0 -0
  46. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/Makefile +0 -0
  47. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/README_REAL_E2E.md +0 -0
  48. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/STORAGE_CLI_GUIDE.md +0 -0
  49. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/docs/adr/0001-per-profile-generated-state-bucket.md +0 -0
  50. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/docs/architecture.md +0 -0
  51. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/docs/architecture.png +0 -0
  52. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/docs/architecture.svg +0 -0
  53. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/forged-idea.md +0 -0
  54. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/pyproject.toml +0 -0
  55. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/pytest.ini +0 -0
  56. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/requirements.txt +0 -0
  57. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/sample.env +0 -0
  58. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/scripts/coverage_badge.py +0 -0
  59. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/scripts/pypi_version.py +0 -0
  60. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/setup.cfg +0 -0
  61. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/__init__.py +0 -0
  62. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/cli/__init__.py +0 -0
  63. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/cli/__main__.py +0 -0
  64. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/cli/config.py +0 -0
  65. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/cli/encrypt.py +0 -0
  66. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/cli/git.py +0 -0
  67. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/cli/last_env.py +0 -0
  68. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/cli/last_session.py +0 -0
  69. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/cli/log.py +0 -0
  70. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/cli/requirements.txt +0 -0
  71. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/cli/state_bucket.py +0 -0
  72. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/cli/storage.py +0 -0
  73. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/cli/vpn.py +0 -0
  74. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/mystack_rig.egg-info/dependency_links.txt +0 -0
  75. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/mystack_rig.egg-info/entry_points.txt +0 -0
  76. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/mystack_rig.egg-info/requires.txt +0 -0
  77. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/src/mystack_rig.egg-info/top_level.txt +0 -0
  78. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/test_hetzner_integration.py +0 -0
  79. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/conftest.py +0 -0
  80. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_attach_command.py +0 -0
  81. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_credential_security.py +0 -0
  82. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_destroy_command.py +0 -0
  83. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_dev_command.py +0 -0
  84. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_encrypt_command.py +0 -0
  85. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_encrypt_coverage.py +0 -0
  86. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_firewall_client_ip.py +0 -0
  87. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_git_clone_unit.py +0 -0
  88. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_git_manager.py +0 -0
  89. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_gitignore_init.py +0 -0
  90. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_hetzner_storage.py +0 -0
  91. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_last_env.py +0 -0
  92. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_last_session.py +0 -0
  93. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_log.py +0 -0
  94. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_main_coverage.py +0 -0
  95. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_pypi_version.py +0 -0
  96. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_real_e2e_integration.py +0 -0
  97. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_real_e2e_storage.py +0 -0
  98. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_real_e2e_vpn.py +0 -0
  99. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_real_e2e_vpn_tunnel.py +0 -0
  100. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_remote_dev.py +0 -0
  101. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_rig_ansible_vars.py +0 -0
  102. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_rig_config.py +0 -0
  103. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_simulation_storage.py +0 -0
  104. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_small_module_coverage.py +0 -0
  105. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_state_bucket.py +0 -0
  106. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_storage_basic.py +0 -0
  107. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_vpn_optional.py +0 -0
  108. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_vpn_unit.py +0 -0
  109. {mystack_rig-1.2.0 → mystack_rig-1.3.0}/tests/test_workspace_git_clone.py +0 -0
@@ -0,0 +1,45 @@
1
+ # Rig
2
+
3
+ Rig provisions and tracks remote development environments on Hetzner Cloud for a team.
4
+
5
+ ## Language
6
+
7
+ **Profile**:
8
+ A named set of credentials for one Hetzner Cloud project, stored in the developer's personal rig config.
9
+ _Avoid_: Installation, account
10
+
11
+ **State bucket**:
12
+ The storage bucket holding environment state for one Profile within one workspace, shared by everyone working in that workspace.
13
+ _Avoid_: Production bucket, installation bucket
14
+
15
+ **Workspace**:
16
+ A project repository containing a `.rig/` directory, which owns its own State buckets.
17
+ _Avoid_: Project (ambiguous with a Hetzner Cloud project)
18
+
19
+ **Environment**:
20
+ A remote development machine provisioned by rig, owned by one identity and tracked in a State bucket.
21
+ _Avoid_: Instance, VM, server
22
+
23
+ **Outputs**:
24
+ The named values that an Environment's playbooks publish for the user (URLs, ports, credentials), kept alongside the Environment and shown by `rig describe`.
25
+ _Avoid_: Facts, results
26
+
27
+ **Test bucket**:
28
+ A throwaway state bucket used only by automated test runs.
29
+ _Avoid_: Dev bucket
30
+
31
+ **Agent**:
32
+ A coding CLI that rig installs on an Environment: OpenCode, Claude Code or Cursor CLI.
33
+ _Avoid_: Coding agent type, CLI, assistant
34
+
35
+ **Stage**:
36
+ One of the playbook steps rig runs in order when creating an Environment: provision, configure, authorize, materialize, finalize. Only provision and configure are cached in a snapshot.
37
+ _Avoid_: Phase, step
38
+
39
+ **MCP server**:
40
+ A tool server declared once in the Workspace and installed into every Agent on its Environments.
41
+ _Avoid_: Plugin, tool, integration
42
+
43
+ **MCP variable**:
44
+ A named value an MCP server needs at runtime, resolved from the vaulted variable whose name matches it ignoring case.
45
+ _Avoid_: MCP secret, MCP env
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mystack-rig
3
- Version: 1.2.0
3
+ Version: 1.3.0
4
4
  Summary: Ephemeral remotes with full local parity for coding agents
5
5
  Author: mystack-cloud
6
6
  License-Expression: MIT
@@ -61,7 +61,45 @@ Chosen at `rig init` (`agent.enabled` in `rig.yml`, same multi-select as git pro
61
61
  | [Claude Code](https://docs.anthropic.com/en/docs/claude-code) | `claude` | One agent: `coding_agent_api_key` (Anthropic). Several agents: `claude_api_key` |
62
62
  | [Cursor CLI](https://cursor.com/docs/cli/overview) | `cursor` | One agent: `coding_agent_api_key` (`CURSOR_API_KEY`). Several agents: `cursor_api_key` |
63
63
 
64
- Each selected agent is asked for its own key. Scaffolds land under `.rig/.opencode/`, `.rig/.claude/`, and `.rig/.cursor/` (plus shared `AGENTS.md`). Independent of `editor` (local IDE for `rig dev`).
64
+ Each selected agent is asked for its own key. Scaffolds land under `.rig/.opencode/`, `.rig/.claude/`, and `.rig/.cursor/` (plus shared `AGENTS.md`). MCP servers are declared once in `.rig/mcp.json` ([below](#mcp-servers)). Independent of `editor` (local IDE for `rig dev`).
65
+
66
+ ## MCP servers
67
+
68
+ Declare an MCP server once in `.rig/mcp.json` and every enabled agent gets it. The file uses Claude's `.mcp.json` schema, and values may reference **MCP variables** as `${NAME}` or `${NAME:-default}`:
69
+
70
+ ```json
71
+ {
72
+ "mcpServers": {
73
+ "awx": {
74
+ "command": "python3",
75
+ "args": ["-u", "/root/awx-mcp-stdio.py"],
76
+ "env": { "AWX_MCP_API_KEY": "${AWX_MCP_API_KEY}" }
77
+ },
78
+ "context7": {
79
+ "url": "https://mcp.context7.com/mcp",
80
+ "headers": { "CONTEXT7_API_KEY": "${CONTEXT7_API_KEY}" }
81
+ }
82
+ }
83
+ }
84
+ ```
85
+
86
+ ```bash
87
+ rig mcp add awx --env AWX_MCP_API_KEY -- python3 -u /root/awx-mcp-stdio.py
88
+ rig mcp add context7 --url https://mcp.context7.com/mcp --header 'CONTEXT7_API_KEY=${CONTEXT7_API_KEY}'
89
+ rig mcp list # servers, and whether each variable resolves
90
+ rig mcp check # same, exit 1 on any problem (also lists ignored legacy files)
91
+ rig mcp remove awx
92
+ ```
93
+
94
+ - Bare `--env KEY` means `KEY=${KEY}`; `--env KEY=value` stores a literal. `add` prompts for each `${NAME}` that has no default and no value yet, and vaults it (shared `vars.yml`; `--personal` for `vars.<identity>.yml`).
95
+ - A variable resolves to the vaulted variable with the same name, **ignoring case**: `AWX_MCP_API_KEY` finds `awx_mcp_api_key`. Two variables that differ only by case are an error. Values come from the vars files, inventory and extra vars, not from play-level `vars:`.
96
+ - The authorize Stage renders each enabled agent's own format and writes it into `~/.claude.json` (`mcpServers`), `~/.cursor/mcp.json` and `opencode.json` (`mcp`) on the Environment. A server with the same name is replaced; servers you added by hand there are kept. Secrets are written into those files (mode 0600).
97
+ - A server whose variable has no value is **skipped with a warning**; the create still succeeds. An invalid `.rig/mcp.json` fails the Stage.
98
+ - Fields rig does not translate (anything other than `type`, `command`, `args`, `env`, `url`, `headers`) are dropped with a warning.
99
+ - `rig mcp add/remove` only edit local files. Push to a running Environment with `rig apply --authorize`; `remove` leaves the old entry on Environments that already have it until they are recreated.
100
+ - Cursor's launcher passes `--approve-mcps`, so servers rig installs never prompt.
101
+ - Support files for a server (for example a stdio wrapper script) are not managed by rig: install them from your own playbook (provision, configure or authorize) and point `command` at that path.
102
+ - The per-agent `.rig/.claude|.cursor|.opencode/mcp.json` files from earlier versions are no longer deployed. If one still declares servers, `rig apply`/`create` and `rig mcp check` warn; move them to `.rig/mcp.json`.
65
103
 
66
104
  ## IDEs
67
105
 
@@ -93,12 +131,13 @@ rig.yml # workspace manifest (vm, agent, playbooks, repos)
93
131
  requirements.yml # Galaxy collections/roles
94
132
  local_roles/ # committed Ansible roles (searched first)
95
133
  AGENTS.md # agent instructions
96
- .opencode/ | .claude/ | .cursor/ # agent config + MCP
134
+ .opencode/ | .claude/ | .cursor/ # agent config
135
+ mcp.json # user; MCP servers for every agent (see `rig mcp`)
97
136
  inventory.yml # generated at create/apply (gitignored)
98
137
  collections/ roles/ # Galaxy installs (gitignored)
99
138
  ```
100
139
 
101
- Put a committed role at `.rig/local_roles/<name>/` (`tasks/main.yml` and the usual role layout). `rig init` creates the directory. Galaxy roles install into `.rig/roles/` and stay gitignored. Ansible checks that directory before the configured path, so each committed role is linked there and wins over a Galaxy role of the same name. An older `.rig/galaxy_roles/` directory is moved into `roles` on the next init or apply.
140
+ Put a committed role at `.rig/local_roles/<name>/` (`tasks/main.yml` and the usual role layout). `rig init` creates the directory. Galaxy roles install into `.rig/roles/` and stay gitignored. `.rig/local_roles` comes first in the roles path. Give a committed role a name that no Galaxy role uses: if both exist, Ansible's own lookup finds the one in `.rig/roles` first. An older `.rig/galaxy_roles/` directory is moved into `roles` on the next init or apply.
102
141
 
103
142
  `rig.yml` defaults (edit to configure):
104
143
 
@@ -198,7 +237,7 @@ After you leave an agent TTY, rig captures the printed session / resume id (when
198
237
  | `rig-{version}-{hash}` | provision + configure (`authorize` + `materialize` still run) |
199
238
  | base image | nothing |
200
239
 
201
- **System hash** = var map (`coding_agent_type`, `coding_agent_types`, `git_providers`, `code_server_*`, `workspace_root`) + `provision.yml` + `configure.yml`. Secrets and `authorize.yml` / `materialize.yml` are not included.
240
+ **System hash** = var map (`coding_agent_type`, `coding_agent_types`, `git_providers`, `code_server_*`, `workspace_root`) + `provision.yml` + `configure.yml` + `requirements.yml` (pins Galaxy role versions). Secrets, `authorize.yml`, `materialize.yml` and the role directories (`.rig/local_roles`, `.rig/roles`) are not included, so editing a role used from `materialize.yml` does not discard the cached image. If `configure.yml` uses a local role, run `rig cache clear` after changing it.
202
241
 
203
242
  Override with `--force-playbooks` / `--force-system` (force provision+configure) / `--force-workspace` (force materialize).
204
243
 
@@ -227,6 +266,8 @@ Global: `-v` playbook tasks and debug · `-vv`/`-vvv`/`-vvvv` ansible verbosity
227
266
  | `ssh` | `[name]` `[-- command]` | Shell on the VM in `/workspace`. A command after `--` runs instead of a login shell |
228
267
  | `dev` | `[name]` `[--path /workspace]` `[--browser]` `[--editor code\|cursor\|…]` | Remote-SSH by default; `--editor` opens another IDE from `editor.enabled`. Defaults to `editor.default` |
229
268
  | `list` | | Lists envs, or `No remote environments` |
269
+ | `inspect` | `[name]` `[--json]` | Technical details of one env: stored record plus live Hetzner status. Falls back to stored data (flagged stale) if the API is unreachable. Data goes to stdout |
270
+ | `describe` | `[name]` `[--json]` `[--show-secrets]` | Outputs published by the env's playbooks (see below). Sensitive values are masked unless `--show-secrets` |
230
271
  | `delete` | `[name …]` `[--tags TAGS]` | Runs finalize then destroy playbooks, then deletes the VM; multi-name OK. `--tags` limits both playbooks |
231
272
  | `cache` | `list\|clear` `[--system\|--workspace] [--all] [-y]` | List or clear; unused by default, `--all` includes current |
232
273
  | `vars encrypt` | `[--stdin-name VAR]` `[--personal]` | Vault into shared or identity vars (after master-key unlock) |
@@ -265,6 +306,31 @@ Also available from vars files (defaults): `workspace_root`, `coding_agent_type`
265
306
 
266
307
  `vscode_browser_password` is auto-generated (vaulted) for code-server browser login (`rig dev --browser`). Reveal with `rig vars decrypt vscode_browser_password` (also printed when opening browser mode).
267
308
 
309
+ ## Playbook outputs
310
+
311
+ `rig describe` shows the values your playbooks publish. A playbook publishes them by writing YAML to the path in the `rig_outputs_file` extra var, which rig sets on every run. Add a task like this to any playbook, including custom ones:
312
+
313
+ ```yaml
314
+ - name: Publish outputs
315
+ delegate_to: localhost
316
+ become: false
317
+ ansible.builtin.copy:
318
+ dest: "{{ rig_outputs_file }}"
319
+ content: "{{ {'rig_outputs': rig_outputs, 'rig_outputs_sensitive': ['my_api_key']} | to_nice_yaml }}"
320
+ vars:
321
+ rig_outputs:
322
+ vscode_url: "https://{{ rig_vm_ip }}:8443"
323
+ my_api_key: "{{ some_secret }}"
324
+ ```
325
+
326
+ - `rig_outputs` (required) is a dict of name to value. Without it the file is ignored.
327
+ - `rig_outputs_sensitive` (optional) lists extra keys to mask. Keys containing `password`, `secret`, `token` or `key` are always masked.
328
+ - After each successful create-side stage (`provision`, `configure`, `authorize`, `materialize`, `finalize`) rig shallow-merges the file into the stored outputs, so later runs overwrite only the keys they emit. Failed runs and `destroy` store nothing.
329
+ - Outputs are stored as written in the State bucket at `remote-dev/outputs/<name>.yml`, readable by anyone with bucket credentials. Masking is a display default, not access control. `rig delete` removes them.
330
+ - Environment names are unique across owners in a State bucket, and `create` rejects a name another owner already uses.
331
+
332
+ See `docs/adr/0002-outputs-as-separate-object-via-file-handoff.md`.
333
+
268
334
  ## Credentials
269
335
 
270
336
  | Source | Purpose |
@@ -38,7 +38,45 @@ Chosen at `rig init` (`agent.enabled` in `rig.yml`, same multi-select as git pro
38
38
  | [Claude Code](https://docs.anthropic.com/en/docs/claude-code) | `claude` | One agent: `coding_agent_api_key` (Anthropic). Several agents: `claude_api_key` |
39
39
  | [Cursor CLI](https://cursor.com/docs/cli/overview) | `cursor` | One agent: `coding_agent_api_key` (`CURSOR_API_KEY`). Several agents: `cursor_api_key` |
40
40
 
41
- Each selected agent is asked for its own key. Scaffolds land under `.rig/.opencode/`, `.rig/.claude/`, and `.rig/.cursor/` (plus shared `AGENTS.md`). Independent of `editor` (local IDE for `rig dev`).
41
+ Each selected agent is asked for its own key. Scaffolds land under `.rig/.opencode/`, `.rig/.claude/`, and `.rig/.cursor/` (plus shared `AGENTS.md`). MCP servers are declared once in `.rig/mcp.json` ([below](#mcp-servers)). Independent of `editor` (local IDE for `rig dev`).
42
+
43
+ ## MCP servers
44
+
45
+ Declare an MCP server once in `.rig/mcp.json` and every enabled agent gets it. The file uses Claude's `.mcp.json` schema, and values may reference **MCP variables** as `${NAME}` or `${NAME:-default}`:
46
+
47
+ ```json
48
+ {
49
+ "mcpServers": {
50
+ "awx": {
51
+ "command": "python3",
52
+ "args": ["-u", "/root/awx-mcp-stdio.py"],
53
+ "env": { "AWX_MCP_API_KEY": "${AWX_MCP_API_KEY}" }
54
+ },
55
+ "context7": {
56
+ "url": "https://mcp.context7.com/mcp",
57
+ "headers": { "CONTEXT7_API_KEY": "${CONTEXT7_API_KEY}" }
58
+ }
59
+ }
60
+ }
61
+ ```
62
+
63
+ ```bash
64
+ rig mcp add awx --env AWX_MCP_API_KEY -- python3 -u /root/awx-mcp-stdio.py
65
+ rig mcp add context7 --url https://mcp.context7.com/mcp --header 'CONTEXT7_API_KEY=${CONTEXT7_API_KEY}'
66
+ rig mcp list # servers, and whether each variable resolves
67
+ rig mcp check # same, exit 1 on any problem (also lists ignored legacy files)
68
+ rig mcp remove awx
69
+ ```
70
+
71
+ - Bare `--env KEY` means `KEY=${KEY}`; `--env KEY=value` stores a literal. `add` prompts for each `${NAME}` that has no default and no value yet, and vaults it (shared `vars.yml`; `--personal` for `vars.<identity>.yml`).
72
+ - A variable resolves to the vaulted variable with the same name, **ignoring case**: `AWX_MCP_API_KEY` finds `awx_mcp_api_key`. Two variables that differ only by case are an error. Values come from the vars files, inventory and extra vars, not from play-level `vars:`.
73
+ - The authorize Stage renders each enabled agent's own format and writes it into `~/.claude.json` (`mcpServers`), `~/.cursor/mcp.json` and `opencode.json` (`mcp`) on the Environment. A server with the same name is replaced; servers you added by hand there are kept. Secrets are written into those files (mode 0600).
74
+ - A server whose variable has no value is **skipped with a warning**; the create still succeeds. An invalid `.rig/mcp.json` fails the Stage.
75
+ - Fields rig does not translate (anything other than `type`, `command`, `args`, `env`, `url`, `headers`) are dropped with a warning.
76
+ - `rig mcp add/remove` only edit local files. Push to a running Environment with `rig apply --authorize`; `remove` leaves the old entry on Environments that already have it until they are recreated.
77
+ - Cursor's launcher passes `--approve-mcps`, so servers rig installs never prompt.
78
+ - Support files for a server (for example a stdio wrapper script) are not managed by rig: install them from your own playbook (provision, configure or authorize) and point `command` at that path.
79
+ - The per-agent `.rig/.claude|.cursor|.opencode/mcp.json` files from earlier versions are no longer deployed. If one still declares servers, `rig apply`/`create` and `rig mcp check` warn; move them to `.rig/mcp.json`.
42
80
 
43
81
  ## IDEs
44
82
 
@@ -70,12 +108,13 @@ rig.yml # workspace manifest (vm, agent, playbooks, repos)
70
108
  requirements.yml # Galaxy collections/roles
71
109
  local_roles/ # committed Ansible roles (searched first)
72
110
  AGENTS.md # agent instructions
73
- .opencode/ | .claude/ | .cursor/ # agent config + MCP
111
+ .opencode/ | .claude/ | .cursor/ # agent config
112
+ mcp.json # user; MCP servers for every agent (see `rig mcp`)
74
113
  inventory.yml # generated at create/apply (gitignored)
75
114
  collections/ roles/ # Galaxy installs (gitignored)
76
115
  ```
77
116
 
78
- Put a committed role at `.rig/local_roles/<name>/` (`tasks/main.yml` and the usual role layout). `rig init` creates the directory. Galaxy roles install into `.rig/roles/` and stay gitignored. Ansible checks that directory before the configured path, so each committed role is linked there and wins over a Galaxy role of the same name. An older `.rig/galaxy_roles/` directory is moved into `roles` on the next init or apply.
117
+ Put a committed role at `.rig/local_roles/<name>/` (`tasks/main.yml` and the usual role layout). `rig init` creates the directory. Galaxy roles install into `.rig/roles/` and stay gitignored. `.rig/local_roles` comes first in the roles path. Give a committed role a name that no Galaxy role uses: if both exist, Ansible's own lookup finds the one in `.rig/roles` first. An older `.rig/galaxy_roles/` directory is moved into `roles` on the next init or apply.
79
118
 
80
119
  `rig.yml` defaults (edit to configure):
81
120
 
@@ -175,7 +214,7 @@ After you leave an agent TTY, rig captures the printed session / resume id (when
175
214
  | `rig-{version}-{hash}` | provision + configure (`authorize` + `materialize` still run) |
176
215
  | base image | nothing |
177
216
 
178
- **System hash** = var map (`coding_agent_type`, `coding_agent_types`, `git_providers`, `code_server_*`, `workspace_root`) + `provision.yml` + `configure.yml`. Secrets and `authorize.yml` / `materialize.yml` are not included.
217
+ **System hash** = var map (`coding_agent_type`, `coding_agent_types`, `git_providers`, `code_server_*`, `workspace_root`) + `provision.yml` + `configure.yml` + `requirements.yml` (pins Galaxy role versions). Secrets, `authorize.yml`, `materialize.yml` and the role directories (`.rig/local_roles`, `.rig/roles`) are not included, so editing a role used from `materialize.yml` does not discard the cached image. If `configure.yml` uses a local role, run `rig cache clear` after changing it.
179
218
 
180
219
  Override with `--force-playbooks` / `--force-system` (force provision+configure) / `--force-workspace` (force materialize).
181
220
 
@@ -204,6 +243,8 @@ Global: `-v` playbook tasks and debug · `-vv`/`-vvv`/`-vvvv` ansible verbosity
204
243
  | `ssh` | `[name]` `[-- command]` | Shell on the VM in `/workspace`. A command after `--` runs instead of a login shell |
205
244
  | `dev` | `[name]` `[--path /workspace]` `[--browser]` `[--editor code\|cursor\|…]` | Remote-SSH by default; `--editor` opens another IDE from `editor.enabled`. Defaults to `editor.default` |
206
245
  | `list` | | Lists envs, or `No remote environments` |
246
+ | `inspect` | `[name]` `[--json]` | Technical details of one env: stored record plus live Hetzner status. Falls back to stored data (flagged stale) if the API is unreachable. Data goes to stdout |
247
+ | `describe` | `[name]` `[--json]` `[--show-secrets]` | Outputs published by the env's playbooks (see below). Sensitive values are masked unless `--show-secrets` |
207
248
  | `delete` | `[name …]` `[--tags TAGS]` | Runs finalize then destroy playbooks, then deletes the VM; multi-name OK. `--tags` limits both playbooks |
208
249
  | `cache` | `list\|clear` `[--system\|--workspace] [--all] [-y]` | List or clear; unused by default, `--all` includes current |
209
250
  | `vars encrypt` | `[--stdin-name VAR]` `[--personal]` | Vault into shared or identity vars (after master-key unlock) |
@@ -242,6 +283,31 @@ Also available from vars files (defaults): `workspace_root`, `coding_agent_type`
242
283
 
243
284
  `vscode_browser_password` is auto-generated (vaulted) for code-server browser login (`rig dev --browser`). Reveal with `rig vars decrypt vscode_browser_password` (also printed when opening browser mode).
244
285
 
286
+ ## Playbook outputs
287
+
288
+ `rig describe` shows the values your playbooks publish. A playbook publishes them by writing YAML to the path in the `rig_outputs_file` extra var, which rig sets on every run. Add a task like this to any playbook, including custom ones:
289
+
290
+ ```yaml
291
+ - name: Publish outputs
292
+ delegate_to: localhost
293
+ become: false
294
+ ansible.builtin.copy:
295
+ dest: "{{ rig_outputs_file }}"
296
+ content: "{{ {'rig_outputs': rig_outputs, 'rig_outputs_sensitive': ['my_api_key']} | to_nice_yaml }}"
297
+ vars:
298
+ rig_outputs:
299
+ vscode_url: "https://{{ rig_vm_ip }}:8443"
300
+ my_api_key: "{{ some_secret }}"
301
+ ```
302
+
303
+ - `rig_outputs` (required) is a dict of name to value. Without it the file is ignored.
304
+ - `rig_outputs_sensitive` (optional) lists extra keys to mask. Keys containing `password`, `secret`, `token` or `key` are always masked.
305
+ - After each successful create-side stage (`provision`, `configure`, `authorize`, `materialize`, `finalize`) rig shallow-merges the file into the stored outputs, so later runs overwrite only the keys they emit. Failed runs and `destroy` store nothing.
306
+ - Outputs are stored as written in the State bucket at `remote-dev/outputs/<name>.yml`, readable by anyone with bucket credentials. Masking is a display default, not access control. `rig delete` removes them.
307
+ - Environment names are unique across owners in a State bucket, and `create` rejects a name another owner already uses.
308
+
309
+ See `docs/adr/0002-outputs-as-separate-object-via-file-handoff.md`.
310
+
245
311
  ## Credentials
246
312
 
247
313
  | Source | Purpose |
@@ -0,0 +1,16 @@
1
+ # Outputs are a separate per-name object, handed off from Ansible via a file
2
+
3
+ `rig describe` shows the Outputs that an Environment's playbooks publish. Playbooks write a `rig_outputs` dict to a controller-side file whose path rig passes as `rig_outputs_file`. After each successful non-destroy stage rig shallow-merges that file into the stored Outputs. The Outputs are stored as one object per Environment name at `remote-dev/outputs/<name>.yml` in the State bucket, separate from the Environment record.
4
+
5
+ ## Considered Options
6
+
7
+ - **Parse Ansible stdout or a JSON callback**: rejected. Rig only gets a bool from `ansible-playbook` today, and parsing output is fragile and ties rig to a callback plugin.
8
+ - **Store Outputs inside the Environment record**: rejected. `_save_state` merges and rewrites the whole record on every update, and `list` scans the records prefix, so a growing and sensitive blob there raises the cost of every save and list.
9
+ - **Key Outputs by owner like records**: rejected. Outputs are a property of the Environment, so `describe <name>` returns one result for everyone in the Workspace and Profile.
10
+
11
+ ## Consequences
12
+
13
+ - Playbook authors must opt in by writing `rig_outputs_file`. Rig's default playbooks ship a snippet that does this, and custom playbooks follow the documented convention.
14
+ - Environment names must be unique across owners within a State bucket, so `create` rejects a name that already exists under any owner.
15
+ - Outputs are stored as written. The bucket is shared by the whole team, so sensitive values are readable by anyone with bucket credentials. `describe` masks them by default (keys matching `password`, `secret`, `token` or `key`, or listed in `rig_outputs_sensitive`). Encrypting them with the vault shared key is a follow-up.
16
+ - `rig delete` removes the Outputs object together with the Environment record. A failed playbook writes nothing, and the destroy stage captures nothing.
@@ -0,0 +1,18 @@
1
+ # MCP servers are declared once and rendered per Agent at authorize
2
+
3
+ A Workspace declares MCP servers once in `.rig/mcp.json`, in Claude's `.mcp.json` schema with `${NAME}` MCP variables. The authorize Stage renders each enabled Agent's own config from it and writes the resolved values into the Environment. Each MCP variable resolves to the vaulted variable with the same name, ignoring case, using an Ansible filter plugin that ships with rig.
4
+
5
+ ## Considered Options
6
+
7
+ - **Per-agent files** (`.rig/.claude/mcp.json`, `.cursor/`, `.opencode/`): rejected. One server had to be written three times in three syntaxes, and an Agent enabled later silently lacked servers added earlier. They are retired; rig warns when one still declares servers.
8
+ - **Deploy MCP config in provision**: rejected. Provision is cached in a snapshot and `mcp.json` is not part of the snapshot hash, so edits would not reach new Environments. It also cannot hold secrets.
9
+ - **Leave placeholders in the Agent configs and write the values to an env file**: rejected. It only works if every launch path sources the file and each Agent expands its own syntax. OpenCode turns an unset variable into an empty string without a warning, and Cursor leaves it as literal text.
10
+ - **Resolve secrets in rig and pass them to Ansible as extra vars**: rejected. It would put secrets on the `ansible-playbook` command line.
11
+
12
+ ## Consequences
13
+
14
+ - Secrets are written into the Agents' config files on the Environment (mode 0600), as well as sitting in the vault.
15
+ - A server whose variable has no value is skipped with a warning and does not fail the create. An invalid `.rig/mcp.json` does fail it.
16
+ - A same-name server is replaced whole; servers added by hand on the Environment are kept.
17
+ - Removing a server from `.rig/mcp.json` does not remove it from Environments that already have it.
18
+ - rig does not install a server's support files (for example a stdio wrapper script). The Workspace's own playbooks do.
@@ -7,11 +7,9 @@ Layout under the project (committed, user-editable):
7
7
 
8
8
  .rig/AGENTS.md # shared workspace rules
9
9
  .rig/.opencode/opencode.json # OpenCode config (API key via env)
10
- .rig/.opencode/mcp.json # OpenCode MCP servers
11
10
  .rig/.claude/settings.json # Claude Code settings
12
- .rig/.claude/mcp.json # Claude Code MCP servers (.mcp.json on remote)
13
11
  .rig/.cursor/cli-config.json # Cursor CLI config
14
- .rig/.cursor/mcp.json # Cursor CLI MCP servers
12
+ .rig/mcp.json # MCP servers for every Agent (see `rig mcp`)
15
13
  """
16
14
 
17
15
  from __future__ import annotations
@@ -122,43 +120,24 @@ def sync_opencode_config(
122
120
  _write_json(config_path, opencode_config(has_api_key=has_api_key))
123
121
  return ".rig/.opencode/opencode.json"
124
122
 
125
- OPENCODE_MCP: Dict[str, Any] = {
126
- "mcp": {
127
- # Example (disabled). Uncomment / extend as needed:
128
- # "context7": {
129
- # "type": "remote",
130
- # "url": "https://mcp.context7.com/mcp",
131
- # "enabled": false,
132
- # "headers": {"CONTEXT7_API_KEY": "{env:CONTEXT7_API_KEY}"},
133
- # },
134
- }
135
- }
136
-
137
123
  CLAUDE_SETTINGS = {
124
+ # Bare tool names allow every path; "Tool(*)" warns on recent Claude Code.
138
125
  "permissions": {
139
126
  "allow": [
140
- "Bash(*)",
141
- "Edit(*)",
142
- "Read(*)",
143
- "Write(*)",
144
- "Glob(*)",
145
- "Grep(*)",
127
+ "Bash",
128
+ "Edit",
129
+ "Read",
130
+ "Write",
131
+ "Glob",
132
+ "Grep",
146
133
  ]
147
134
  },
135
+ # Skips the first-run theme picker.
136
+ "theme": "dark",
148
137
  # API key is injected via /etc/profile.d/rig-coding-agent.sh and
149
138
  # ~/.claude/credentials.env (CODING_AGENT_API_KEY / ANTHROPIC_API_KEY).
150
139
  }
151
140
 
152
- CLAUDE_MCP: Dict[str, Any] = {
153
- "mcpServers": {
154
- # Example (disabled). Add servers as needed for Claude Code:
155
- # "filesystem": {
156
- # "command": "npx",
157
- # "args": ["-y", "@modelcontextprotocol/server-filesystem", "/root"],
158
- # },
159
- }
160
- }
161
-
162
141
  # Cursor CLI (~/.cursor/cli-config.json). API key via CURSOR_API_KEY on the VM.
163
142
  CURSOR_CLI_CONFIG: Dict[str, Any] = {
164
143
  "permissions": {
@@ -170,11 +149,6 @@ CURSOR_CLI_CONFIG: Dict[str, Any] = {
170
149
  },
171
150
  }
172
151
 
173
- CURSOR_MCP: Dict[str, Any] = {
174
- "mcpServers": {},
175
- }
176
-
177
-
178
152
  def normalize_agent_type(value: Optional[str]) -> str:
179
153
  raw = (value or "").strip().lower().replace(" ", "-").replace("_", "-")
180
154
  aliases = {
@@ -212,7 +186,7 @@ def agent_remote_paths(agent_type: str) -> Dict[str, str]:
212
186
  return {
213
187
  "config_dir": "/root/.config/opencode",
214
188
  "config_file": "/root/.config/opencode/opencode.json",
215
- "mcp_file": "/root/.config/opencode/mcp.json",
189
+ "mcp_file": "/root/.config/opencode/opencode.json", # `mcp` key, merged at authorize
216
190
  "rules_file": "/root/.config/opencode/AGENTS.md",
217
191
  "env_file": "/root/.config/opencode/credentials.env",
218
192
  }
@@ -227,7 +201,7 @@ def agent_remote_paths(agent_type: str) -> Dict[str, str]:
227
201
  return {
228
202
  "config_dir": "/root/.claude",
229
203
  "config_file": "/root/.claude/settings.json",
230
- "mcp_file": "/root/.mcp.json",
204
+ "mcp_file": "/root/.claude.json", # `mcpServers` key, merged at authorize
231
205
  "rules_file": "/root/.claude/CLAUDE.md",
232
206
  "env_file": "/root/.claude/credentials.env",
233
207
  }
@@ -274,31 +248,18 @@ def ensure_agent_scaffold(
274
248
  )
275
249
  if written:
276
250
  created.append(written)
277
- cfg_dir = os.path.join(rig_dir, ".opencode")
278
- mcp_path = os.path.join(cfg_dir, "mcp.json")
279
- if force or not os.path.exists(mcp_path):
280
- _write_json(mcp_path, OPENCODE_MCP)
281
- created.append(".rig/.opencode/mcp.json")
282
251
  elif agent == "cursor":
283
252
  cfg_dir = os.path.join(rig_dir, ".cursor")
284
253
  config_path = os.path.join(cfg_dir, "cli-config.json")
285
- mcp_path = os.path.join(cfg_dir, "mcp.json")
286
254
  if force or not os.path.exists(config_path):
287
255
  _write_json(config_path, CURSOR_CLI_CONFIG)
288
256
  created.append(".rig/.cursor/cli-config.json")
289
- if force or not os.path.exists(mcp_path):
290
- _write_json(mcp_path, CURSOR_MCP)
291
- created.append(".rig/.cursor/mcp.json")
292
257
  else:
293
258
  cfg_dir = os.path.join(rig_dir, ".claude")
294
259
  config_path = os.path.join(cfg_dir, "settings.json")
295
- mcp_path = os.path.join(cfg_dir, "mcp.json")
296
260
  if force or not os.path.exists(config_path):
297
261
  _write_json(config_path, CLAUDE_SETTINGS)
298
262
  created.append(".rig/.claude/settings.json")
299
- if force or not os.path.exists(mcp_path):
300
- _write_json(mcp_path, CLAUDE_MCP)
301
- created.append(".rig/.claude/mcp.json")
302
263
 
303
264
  return created
304
265
 
File without changes