mystack-rig 1.3.1__tar.gz → 1.4.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.4.0/.git-blame-ignore-revs +7 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/.github/workflows/tests.yml +7 -6
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/CLI_STORAGE_SUMMARY.md +1 -1
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/GLOSSARY.md +8 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/HETZNER_STORAGE_GUIDE.md +1 -1
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/Makefile +11 -2
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/PKG-INFO +62 -6
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/README.md +60 -3
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/README_REAL_E2E.md +4 -2
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/STORAGE_CLI_GUIDE.md +1 -1
- mystack_rig-1.4.0/docs/adr/0004-agents-run-as-live-agents-in-tmux.md +20 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/pyproject.toml +26 -2
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/requirements.txt +1 -2
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/scripts/coverage_badge.py +1 -3
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/scripts/pypi_version.py +6 -16
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/agents.py +39 -58
- mystack_rig-1.4.0/src/cli/ansible_filters/rig_live.py +88 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/ansible_filters/rig_mcp.py +32 -44
- mystack_rig-1.4.0/src/cli/assets/rig-agent-queue +33 -0
- mystack_rig-1.4.0/src/cli/assets/rig-agent-state +12 -0
- mystack_rig-1.4.0/src/cli/assets/tmux.conf +27 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/config.py +16 -26
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/encrypt.py +106 -160
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/git.py +131 -123
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/git_author.py +5 -4
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/last_env.py +4 -4
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/last_session.py +12 -12
- mystack_rig-1.4.0/src/cli/live_agent.py +238 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/log.py +3 -3
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/main.py +272 -95
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/mcp.py +46 -38
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/outputs.py +14 -13
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/remote_dev.py +975 -825
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/snapshots.py +75 -107
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/state_bucket.py +8 -10
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/storage.py +26 -27
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/vault_keys.py +28 -32
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/vpn.py +84 -135
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/mystack_rig.egg-info/PKG-INFO +62 -6
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/mystack_rig.egg-info/SOURCES.txt +10 -1
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/mystack_rig.egg-info/requires.txt +0 -3
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/mystack_rig.egg-info/scm_file_list.json +10 -1
- mystack_rig-1.4.0/src/mystack_rig.egg-info/scm_version.json +8 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/test_hetzner_integration.py +98 -113
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/conftest.py +29 -34
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_agents.py +8 -24
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_attach_command.py +148 -118
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_credential_security.py +14 -13
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_destroy_command.py +42 -34
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_dev_command.py +61 -70
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_encrypt_command.py +32 -26
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_encrypt_coverage.py +42 -31
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_firewall_client_ip.py +10 -21
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_git_clone_unit.py +128 -128
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_git_credentials_and_author.py +7 -6
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_git_manager.py +1 -3
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_gitignore_init.py +1 -3
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_hetzner_storage.py +31 -37
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_init_command.py +41 -62
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_inspect_describe.py +30 -12
- mystack_rig-1.4.0/tests/test_live_agent.py +614 -0
- mystack_rig-1.4.0/tests/test_live_agent_cli.py +507 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_main_coverage.py +165 -147
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_mcp_command.py +33 -21
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_mcp_render.py +10 -9
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_outputs.py +5 -8
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_outputs_storage.py +3 -3
- mystack_rig-1.4.0/tests/test_python_floor.py +38 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_real_e2e_integration.py +33 -47
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_real_e2e_storage.py +38 -39
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_real_e2e_vpn.py +27 -23
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_real_e2e_vpn_tunnel.py +45 -39
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_remote_dev.py +145 -163
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_remote_dev_coverage_extensions.py +143 -120
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_rig_ansible_vars.py +5 -5
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_rig_config.py +30 -22
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_secret_prompt_hidden.py +6 -3
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_setup_provision.py +127 -77
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_simulation_storage.py +69 -76
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_snapshots.py +81 -73
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_state_bucket.py +9 -16
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_storage_basic.py +97 -109
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_vault_keys.py +1 -4
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_vpn_optional.py +13 -9
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_vpn_unit.py +5 -10
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_workspace_git_clone.py +91 -102
- mystack_rig-1.3.1/.flake8 +0 -5
- mystack_rig-1.3.1/src/mystack_rig.egg-info/scm_version.json +0 -8
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/.coveragerc +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/.github/workflows/release.yml +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/.gitignore +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/.rig/playbooks/README.md +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/.rig/playbooks/vpn-gateway.yml +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/Dockerfile +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/GIT_CLONE_FEATURE.md +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/HETZNER_STORAGE_SECURITY_GUIDE.md +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/LICENSE +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/docs/adr/0001-per-profile-generated-state-bucket.md +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/docs/adr/0002-outputs-as-separate-object-via-file-handoff.md +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/docs/adr/0003-mcp-servers-declared-once-rendered-at-authorize.md +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/docs/architecture.md +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/docs/architecture.png +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/docs/architecture.svg +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/forged-idea.md +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/pytest.ini +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/sample.env +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/setup.cfg +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/__init__.py +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/__init__.py +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/__main__.py +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/ansible_filters/__init__.py +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/cli/requirements.txt +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/mystack_rig.egg-info/dependency_links.txt +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/mystack_rig.egg-info/entry_points.txt +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/src/mystack_rig.egg-info/top_level.txt +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_ansible_galaxy.py +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_last_env.py +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_last_session.py +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_log.py +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_pypi_version.py +0 -0
- {mystack_rig-1.3.1 → mystack_rig-1.4.0}/tests/test_small_module_coverage.py +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Commits that only reformat or mechanically rewrite code. GitHub's blame view honours
|
|
2
|
+
# this file automatically. Locally: git config blame.ignoreRevsFile .git-blame-ignore-revs
|
|
3
|
+
|
|
4
|
+
# style: ruff format
|
|
5
|
+
f42c9851ff199fa27c6515764108f7224f81fc2b
|
|
6
|
+
# style: ruff check --fix (import sorting and pyupgrade for py310)
|
|
7
|
+
e1dd627b910a96078d0d8f5559efc0acabd574ab
|
|
@@ -29,15 +29,16 @@ jobs:
|
|
|
29
29
|
with:
|
|
30
30
|
python-version: '3.11'
|
|
31
31
|
|
|
32
|
-
- name: Install
|
|
32
|
+
- name: Install ruff
|
|
33
33
|
run: |
|
|
34
34
|
python -m pip install --upgrade pip
|
|
35
|
-
pip install
|
|
36
|
-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
35
|
+
pip install "ruff==0.17.5"
|
|
37
36
|
|
|
38
|
-
- name: Lint with
|
|
39
|
-
run:
|
|
40
|
-
|
|
37
|
+
- name: Lint with ruff
|
|
38
|
+
run: ruff check .
|
|
39
|
+
|
|
40
|
+
- name: Check formatting with ruff
|
|
41
|
+
run: ruff format --check .
|
|
41
42
|
|
|
42
43
|
type-check:
|
|
43
44
|
name: Type Check
|
|
@@ -32,6 +32,14 @@ _Avoid_: Dev bucket
|
|
|
32
32
|
A coding CLI that rig installs on an Environment: OpenCode, Claude Code or Cursor CLI.
|
|
33
33
|
_Avoid_: Coding agent type, CLI, assistant
|
|
34
34
|
|
|
35
|
+
**Agent session**:
|
|
36
|
+
An Agent's saved conversation, which can be resumed by its id.
|
|
37
|
+
_Avoid_: Chat, thread
|
|
38
|
+
|
|
39
|
+
**Live agent**:
|
|
40
|
+
An Agent's running process on an Environment, kept alive when no terminal is connected. Attaching joins it; ending the Agent ends it.
|
|
41
|
+
_Avoid_: Background agent, daemon, detached session
|
|
42
|
+
|
|
35
43
|
**Stage**:
|
|
36
44
|
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
45
|
_Avoid_: Phase, step
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
VENV := .venv
|
|
2
2
|
PY := $(VENV)/bin/python3
|
|
3
3
|
|
|
4
|
-
.PHONY: venv install test test-e2e test-remote-dev test-remote-dev-e2e coverage run lint clean
|
|
4
|
+
.PHONY: venv install test test-e2e test-remote-dev test-remote-dev-e2e coverage run lint format clean
|
|
5
5
|
|
|
6
6
|
# Create local venv (avoids PEP 668 on Homebrew/system Python)
|
|
7
7
|
venv: $(PY)
|
|
@@ -46,8 +46,17 @@ test-remote-dev-e2e: venv
|
|
|
46
46
|
$(PY) -m pytest tests/test_workspace_git_clone.py -v -m e2e
|
|
47
47
|
|
|
48
48
|
# Run linting
|
|
49
|
+
# Same checks as CI (ruff version pinned there)
|
|
49
50
|
lint: venv
|
|
50
|
-
$(PY) -m
|
|
51
|
+
$(PY) -m pip install -q "ruff==0.17.5"
|
|
52
|
+
$(PY) -m ruff check .
|
|
53
|
+
$(PY) -m ruff format --check .
|
|
54
|
+
|
|
55
|
+
# Apply ruff's formatting and safe lint fixes
|
|
56
|
+
format: venv
|
|
57
|
+
$(PY) -m pip install -q "ruff==0.17.5"
|
|
58
|
+
$(PY) -m ruff check --fix .
|
|
59
|
+
$(PY) -m ruff format .
|
|
51
60
|
|
|
52
61
|
# Clean build artifacts
|
|
53
62
|
clean:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mystack-rig
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: Ephemeral remotes with full local parity for coding agents
|
|
5
5
|
Author: mystack-cloud
|
|
6
6
|
License-Expression: MIT
|
|
@@ -10,7 +10,7 @@ Project-URL: Issues, https://github.com/mystack-cloud/rig/issues
|
|
|
10
10
|
Keywords: remote-development,coding-agents,hetzner
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
12
|
Classifier: Operating System :: OS Independent
|
|
13
|
-
Requires-Python: >=3.
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
14
|
Description-Content-Type: text/markdown
|
|
15
15
|
License-File: LICENSE
|
|
16
16
|
Requires-Dist: requests>=2.25.0
|
|
@@ -18,12 +18,13 @@ Requires-Dist: ansible>=4.0.0
|
|
|
18
18
|
Requires-Dist: boto3>=1.26.0
|
|
19
19
|
Requires-Dist: PyYAML>=6.0
|
|
20
20
|
Requires-Dist: cryptography>=41.0.0
|
|
21
|
-
Requires-Dist: importlib-metadata>=4.0; python_version < "3.8"
|
|
22
21
|
Dynamic: license-file
|
|
23
22
|
|
|
24
23
|
[](https://pypi.org/project/mystack-rig/)
|
|
25
24
|
[](https://github.com/mystack-cloud/rig/actions/workflows/tests.yml)
|
|
26
25
|
[](https://codecov.io/gh/mystack-cloud/rig)
|
|
26
|
+
[](https://github.com/mystack-cloud/rig/blob/master/LICENSE)
|
|
27
|
+
[](https://github.com/astral-sh/ruff)
|
|
27
28
|
|
|
28
29
|
# rig
|
|
29
30
|
|
|
@@ -101,6 +102,48 @@ rig mcp remove awx
|
|
|
101
102
|
- 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
103
|
- 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`.
|
|
103
104
|
|
|
105
|
+
## Live agents
|
|
106
|
+
|
|
107
|
+
`rig attach` runs the agent as a **live agent**: a process kept running on the Environment inside its own tmux session (`tmux -L rig`, with a config rig ships, so it never touches a tmux you use yourself). Closing the terminal or losing the connection only detaches; the agent keeps working, and the next `rig attach` joins it.
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
rig attach # start the live agent, or join the running one
|
|
111
|
+
# leave: close the terminal, or detach with Ctrl+b d. Ctrl+C still goes to the agent.
|
|
112
|
+
rig attach --restart # replace it with a fresh process (resumes the same conversation)
|
|
113
|
+
rig attach --no-persist # old behaviour: the agent ends with the SSH session
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- One live agent per Agent type per Environment. A second `rig attach` joins the first (both terminals see the same screen). Resume flags (`-c`, `--resume`, `--session`) apply only when a live agent is *started*; joining ignores them with a warning.
|
|
117
|
+
- A bare `rig attach` joins whichever live agent is running. `--agent` picks another.
|
|
118
|
+
- `rig inspect` lists live agents. `rig apply` and `rig delete` warn when there are any: a live agent keeps the credentials and MCP config it started with until `rig attach --restart`, and deleting the Environment ends it.
|
|
119
|
+
- If the agent exits while nobody is attached, tmux has logged its output on the VM, and the next `rig attach` recovers the resume id from that log.
|
|
120
|
+
|
|
121
|
+
### `rig exec`
|
|
122
|
+
|
|
123
|
+
Start an agent on a task and leave:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
rig exec "fix the failing tests in /workspace/api"
|
|
127
|
+
rig exec @task.md # prompt from a file
|
|
128
|
+
echo "review the diff" | rig exec - # prompt from stdin
|
|
129
|
+
rig exec --name dev-ab12cd34 --agent claude "..."
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
`rig exec` starts the live agent with the prompt, prints how to attach, and returns. It never creates an Environment and never waits.
|
|
133
|
+
|
|
134
|
+
- **Approvals are skipped by default** (`--permission-mode bypassPermissions` for Claude Code, `--force` for Cursor, `--auto` for OpenCode), because an unattended agent that stops at a prompt just sits there. Claude Code refuses bypass mode as root unless it is told it runs in a sandbox, so rig sets `IS_SANDBOX=1` for that run, and authorize pre-accepts Claude's first-use warning dialog (`skipDangerousModePermissionPrompt`), whose default answer is "exit". The Environment has internet access, your tokens and root, so an agent reading untrusted text could be talked into acting on it. Use `--no-auto-approve` to supervise the run; it then pauses at each approval until you attach.
|
|
135
|
+
- **If a live agent is already running**, `rig exec` queues the prompt into it for Claude Code, which runs it after the current turn. rig does this only when Claude's hooks report it idle or working, never while it waits at an approval dialog (typing there would answer the dialog). If it is waiting, the state is unknown, or the agent is OpenCode or Cursor (queue behaviour not yet verified), `rig exec` refuses with the reason; `--restart` replaces the live agent instead. A queued prompt runs under the existing agent's permission mode.
|
|
136
|
+
- The agent's startup is checked: if it exits within a couple of seconds (for example no credentials), `rig exec` prints its output and fails.
|
|
137
|
+
|
|
138
|
+
The prompt reaches the VM on stdin and a private temporary file that is deleted when the agent starts, never on a command line.
|
|
139
|
+
|
|
140
|
+
### How it works
|
|
141
|
+
|
|
142
|
+
- tmux is installed at provision. The tmux config, two small helper scripts (`rig-agent-state`, `rig-agent-queue`) and Claude Code's state hooks are deployed by `authorize.yml`, so changing them never rebuilds the cached image. The hooks are merged into `~/.claude/settings.json` next to any hooks you added.
|
|
143
|
+
- The hooks record `idle`, `working`, `waiting` or `ended` in `/run/rig/agents/claude.state`; `rig-agent-queue` reads it before pasting.
|
|
144
|
+
- A failed agent leaves its (dead) pane so the error stays readable; the next `rig attach` or `rig exec` replaces it.
|
|
145
|
+
- Agent output is logged to `/var/log/rig/rig-<agent>.log` (the previous run's log is kept as `.prev`).
|
|
146
|
+
|
|
104
147
|
## IDEs
|
|
105
148
|
|
|
106
149
|
`rig dev` opens the remote `/workspace`. Default is local editor + Remote-SSH; `--browser` uses code-server on the VM.
|
|
@@ -220,7 +263,8 @@ destroy playbooks:
|
|
|
220
263
|
| **init** | Scaffold `rig.yml` + `.rig/`. Collect Hetzner creds, repo PATs, agent choices and a key per agent. |
|
|
221
264
|
| **create** | Boot VM (base/system snapshot). Run provision → configure → authorize → materialize. Snapshot after **configure** only. |
|
|
222
265
|
| **apply** | Default: authorize → materialize. Flags: `--provision` / `--configure` / `--authorize` / `--materialize` / `--finalize` / `--destroy` (playbooks only; the VM stays). `--tags` is passed to every playbook in the run. |
|
|
223
|
-
| **attach** | SSH TTY into
|
|
266
|
+
| **attach** | SSH TTY into the agent's [live agent](#live-agents) on `/workspace` (started if needed, joined if running). `--agent` picks among installed agents. |
|
|
267
|
+
| **exec** | Start a live agent with a prompt and return; the work continues unattended. See [Live agents](#live-agents). |
|
|
224
268
|
| **dev** | Open VS Code/Cursor via Remote-SSH on `/workspace` (or `--browser` for code-server). |
|
|
225
269
|
| **delete** | Run finalize → destroy playbooks, then delete VM / firewall / SSH key. `--tags` is passed to both playbooks. |
|
|
226
270
|
|
|
@@ -262,11 +306,12 @@ Global: `-v` playbook tasks and debug · `-vv`/`-vvv`/`-vvvv` ansible verbosity
|
|
|
262
306
|
| `init` | | Interactive scaffold |
|
|
263
307
|
| `create` | `[--name]` `[--provider]` `[--type]` `[--availability-zone]` `[--image]` `[--no-attach]` `[--force-playbooks\|--force-system\|--force-workspace]` | Host defaults from `rig.yml`. `--provider` defaults to `hetzner`. `--type` sets `host.server_type`. `host.type` defaults to `vm`. `--region` aliases `--availability-zone`. |
|
|
264
308
|
| `apply` | `[name]` `[--provision\|--configure\|--authorize\|--materialize\|--finalize\|--destroy]` `[--tags TAGS]` | Default: authorize then materialize. Each flag runs that playbook (`--provision` also runs configure and authorize; `--materialize` also runs authorize). `--finalize` and `--destroy` do not delete the VM. `--tags` limits every playbook in the run |
|
|
265
|
-
| `attach` | `[name]` `[-c\|--continue]` `[-s\|--session ID]` `[--resume [ID]]` `[--agent opencode\|claude\|cursor]` `[-- …agent args]` |
|
|
309
|
+
| `attach` | `[name]` `[-c\|--continue]` `[-s\|--session ID]` `[--resume [ID]]` `[--agent opencode\|claude\|cursor]` `[--restart]` `[--no-persist]` `[-- …agent args]` | Joins the running live agent, or starts one (reopening the last remembered session). `--restart` replaces it; `--no-persist` runs the agent as the SSH session's own process |
|
|
310
|
+
| `exec` | `PROMPT\|@FILE\|-` `[--name]` `[--agent opencode\|claude\|cursor]` `[--restart]` `[--no-auto-approve]` | Start a live agent with the prompt and return; approvals are skipped unless `--no-auto-approve`. Queues into a running Claude Code when that is safe |
|
|
266
311
|
| `ssh` | `[name]` `[-- command]` | Shell on the VM in `/workspace`. A command after `--` runs instead of a login shell |
|
|
267
312
|
| `dev` | `[name]` `[--path /workspace]` `[--browser]` `[--editor code\|cursor\|…]` | Remote-SSH by default; `--editor` opens another IDE from `editor.enabled`. Defaults to `editor.default` |
|
|
268
313
|
| `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 |
|
|
314
|
+
| `inspect` | `[name]` `[--json]` | Technical details of one env: stored record plus live Hetzner status, and its live agents when the VM is running. Falls back to stored data (flagged stale) if the API is unreachable. Data goes to stdout |
|
|
270
315
|
| `describe` | `[name]` `[--json]` `[--show-secrets]` | Outputs published by the env's playbooks (see below). Sensitive values are masked unless `--show-secrets` |
|
|
271
316
|
| `delete` | `[name …]` `[--tags TAGS]` | Runs finalize then destroy playbooks, then deletes the VM; multi-name OK. `--tags` limits both playbooks |
|
|
272
317
|
| `cache` | `list\|clear` `[--system\|--workspace] [--all] [-y]` | List or clear; unused by default, `--all` includes current |
|
|
@@ -356,6 +401,17 @@ pip install -e .
|
|
|
356
401
|
rig --version
|
|
357
402
|
```
|
|
358
403
|
|
|
404
|
+
### Code style
|
|
405
|
+
|
|
406
|
+
[Ruff](https://docs.astral.sh/ruff/) does linting and formatting (configured in `pyproject.toml`: line length 120, double quotes, Python 3.10 syntax). CI runs `ruff check .` and `ruff format --check .`.
|
|
407
|
+
|
|
408
|
+
```bash
|
|
409
|
+
make format # apply ruff's formatting and safe lint fixes
|
|
410
|
+
make lint # the same checks as CI
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
`mypy src/` also runs in CI. Commits that only reformat code are listed in `.git-blame-ignore-revs`; run `git config blame.ignoreRevsFile .git-blame-ignore-revs` to make local `git blame` skip them (GitHub does this automatically).
|
|
414
|
+
|
|
359
415
|
## Tests
|
|
360
416
|
|
|
361
417
|
```bash
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
[](https://pypi.org/project/mystack-rig/)
|
|
2
2
|
[](https://github.com/mystack-cloud/rig/actions/workflows/tests.yml)
|
|
3
3
|
[](https://codecov.io/gh/mystack-cloud/rig)
|
|
4
|
+
[](https://github.com/mystack-cloud/rig/blob/master/LICENSE)
|
|
5
|
+
[](https://github.com/astral-sh/ruff)
|
|
4
6
|
|
|
5
7
|
# rig
|
|
6
8
|
|
|
@@ -78,6 +80,48 @@ rig mcp remove awx
|
|
|
78
80
|
- 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
81
|
- 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`.
|
|
80
82
|
|
|
83
|
+
## Live agents
|
|
84
|
+
|
|
85
|
+
`rig attach` runs the agent as a **live agent**: a process kept running on the Environment inside its own tmux session (`tmux -L rig`, with a config rig ships, so it never touches a tmux you use yourself). Closing the terminal or losing the connection only detaches; the agent keeps working, and the next `rig attach` joins it.
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
rig attach # start the live agent, or join the running one
|
|
89
|
+
# leave: close the terminal, or detach with Ctrl+b d. Ctrl+C still goes to the agent.
|
|
90
|
+
rig attach --restart # replace it with a fresh process (resumes the same conversation)
|
|
91
|
+
rig attach --no-persist # old behaviour: the agent ends with the SSH session
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
- One live agent per Agent type per Environment. A second `rig attach` joins the first (both terminals see the same screen). Resume flags (`-c`, `--resume`, `--session`) apply only when a live agent is *started*; joining ignores them with a warning.
|
|
95
|
+
- A bare `rig attach` joins whichever live agent is running. `--agent` picks another.
|
|
96
|
+
- `rig inspect` lists live agents. `rig apply` and `rig delete` warn when there are any: a live agent keeps the credentials and MCP config it started with until `rig attach --restart`, and deleting the Environment ends it.
|
|
97
|
+
- If the agent exits while nobody is attached, tmux has logged its output on the VM, and the next `rig attach` recovers the resume id from that log.
|
|
98
|
+
|
|
99
|
+
### `rig exec`
|
|
100
|
+
|
|
101
|
+
Start an agent on a task and leave:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
rig exec "fix the failing tests in /workspace/api"
|
|
105
|
+
rig exec @task.md # prompt from a file
|
|
106
|
+
echo "review the diff" | rig exec - # prompt from stdin
|
|
107
|
+
rig exec --name dev-ab12cd34 --agent claude "..."
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
`rig exec` starts the live agent with the prompt, prints how to attach, and returns. It never creates an Environment and never waits.
|
|
111
|
+
|
|
112
|
+
- **Approvals are skipped by default** (`--permission-mode bypassPermissions` for Claude Code, `--force` for Cursor, `--auto` for OpenCode), because an unattended agent that stops at a prompt just sits there. Claude Code refuses bypass mode as root unless it is told it runs in a sandbox, so rig sets `IS_SANDBOX=1` for that run, and authorize pre-accepts Claude's first-use warning dialog (`skipDangerousModePermissionPrompt`), whose default answer is "exit". The Environment has internet access, your tokens and root, so an agent reading untrusted text could be talked into acting on it. Use `--no-auto-approve` to supervise the run; it then pauses at each approval until you attach.
|
|
113
|
+
- **If a live agent is already running**, `rig exec` queues the prompt into it for Claude Code, which runs it after the current turn. rig does this only when Claude's hooks report it idle or working, never while it waits at an approval dialog (typing there would answer the dialog). If it is waiting, the state is unknown, or the agent is OpenCode or Cursor (queue behaviour not yet verified), `rig exec` refuses with the reason; `--restart` replaces the live agent instead. A queued prompt runs under the existing agent's permission mode.
|
|
114
|
+
- The agent's startup is checked: if it exits within a couple of seconds (for example no credentials), `rig exec` prints its output and fails.
|
|
115
|
+
|
|
116
|
+
The prompt reaches the VM on stdin and a private temporary file that is deleted when the agent starts, never on a command line.
|
|
117
|
+
|
|
118
|
+
### How it works
|
|
119
|
+
|
|
120
|
+
- tmux is installed at provision. The tmux config, two small helper scripts (`rig-agent-state`, `rig-agent-queue`) and Claude Code's state hooks are deployed by `authorize.yml`, so changing them never rebuilds the cached image. The hooks are merged into `~/.claude/settings.json` next to any hooks you added.
|
|
121
|
+
- The hooks record `idle`, `working`, `waiting` or `ended` in `/run/rig/agents/claude.state`; `rig-agent-queue` reads it before pasting.
|
|
122
|
+
- A failed agent leaves its (dead) pane so the error stays readable; the next `rig attach` or `rig exec` replaces it.
|
|
123
|
+
- Agent output is logged to `/var/log/rig/rig-<agent>.log` (the previous run's log is kept as `.prev`).
|
|
124
|
+
|
|
81
125
|
## IDEs
|
|
82
126
|
|
|
83
127
|
`rig dev` opens the remote `/workspace`. Default is local editor + Remote-SSH; `--browser` uses code-server on the VM.
|
|
@@ -197,7 +241,8 @@ destroy playbooks:
|
|
|
197
241
|
| **init** | Scaffold `rig.yml` + `.rig/`. Collect Hetzner creds, repo PATs, agent choices and a key per agent. |
|
|
198
242
|
| **create** | Boot VM (base/system snapshot). Run provision → configure → authorize → materialize. Snapshot after **configure** only. |
|
|
199
243
|
| **apply** | Default: authorize → materialize. Flags: `--provision` / `--configure` / `--authorize` / `--materialize` / `--finalize` / `--destroy` (playbooks only; the VM stays). `--tags` is passed to every playbook in the run. |
|
|
200
|
-
| **attach** | SSH TTY into
|
|
244
|
+
| **attach** | SSH TTY into the agent's [live agent](#live-agents) on `/workspace` (started if needed, joined if running). `--agent` picks among installed agents. |
|
|
245
|
+
| **exec** | Start a live agent with a prompt and return; the work continues unattended. See [Live agents](#live-agents). |
|
|
201
246
|
| **dev** | Open VS Code/Cursor via Remote-SSH on `/workspace` (or `--browser` for code-server). |
|
|
202
247
|
| **delete** | Run finalize → destroy playbooks, then delete VM / firewall / SSH key. `--tags` is passed to both playbooks. |
|
|
203
248
|
|
|
@@ -239,11 +284,12 @@ Global: `-v` playbook tasks and debug · `-vv`/`-vvv`/`-vvvv` ansible verbosity
|
|
|
239
284
|
| `init` | | Interactive scaffold |
|
|
240
285
|
| `create` | `[--name]` `[--provider]` `[--type]` `[--availability-zone]` `[--image]` `[--no-attach]` `[--force-playbooks\|--force-system\|--force-workspace]` | Host defaults from `rig.yml`. `--provider` defaults to `hetzner`. `--type` sets `host.server_type`. `host.type` defaults to `vm`. `--region` aliases `--availability-zone`. |
|
|
241
286
|
| `apply` | `[name]` `[--provision\|--configure\|--authorize\|--materialize\|--finalize\|--destroy]` `[--tags TAGS]` | Default: authorize then materialize. Each flag runs that playbook (`--provision` also runs configure and authorize; `--materialize` also runs authorize). `--finalize` and `--destroy` do not delete the VM. `--tags` limits every playbook in the run |
|
|
242
|
-
| `attach` | `[name]` `[-c\|--continue]` `[-s\|--session ID]` `[--resume [ID]]` `[--agent opencode\|claude\|cursor]` `[-- …agent args]` |
|
|
287
|
+
| `attach` | `[name]` `[-c\|--continue]` `[-s\|--session ID]` `[--resume [ID]]` `[--agent opencode\|claude\|cursor]` `[--restart]` `[--no-persist]` `[-- …agent args]` | Joins the running live agent, or starts one (reopening the last remembered session). `--restart` replaces it; `--no-persist` runs the agent as the SSH session's own process |
|
|
288
|
+
| `exec` | `PROMPT\|@FILE\|-` `[--name]` `[--agent opencode\|claude\|cursor]` `[--restart]` `[--no-auto-approve]` | Start a live agent with the prompt and return; approvals are skipped unless `--no-auto-approve`. Queues into a running Claude Code when that is safe |
|
|
243
289
|
| `ssh` | `[name]` `[-- command]` | Shell on the VM in `/workspace`. A command after `--` runs instead of a login shell |
|
|
244
290
|
| `dev` | `[name]` `[--path /workspace]` `[--browser]` `[--editor code\|cursor\|…]` | Remote-SSH by default; `--editor` opens another IDE from `editor.enabled`. Defaults to `editor.default` |
|
|
245
291
|
| `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 |
|
|
292
|
+
| `inspect` | `[name]` `[--json]` | Technical details of one env: stored record plus live Hetzner status, and its live agents when the VM is running. Falls back to stored data (flagged stale) if the API is unreachable. Data goes to stdout |
|
|
247
293
|
| `describe` | `[name]` `[--json]` `[--show-secrets]` | Outputs published by the env's playbooks (see below). Sensitive values are masked unless `--show-secrets` |
|
|
248
294
|
| `delete` | `[name …]` `[--tags TAGS]` | Runs finalize then destroy playbooks, then deletes the VM; multi-name OK. `--tags` limits both playbooks |
|
|
249
295
|
| `cache` | `list\|clear` `[--system\|--workspace] [--all] [-y]` | List or clear; unused by default, `--all` includes current |
|
|
@@ -333,6 +379,17 @@ pip install -e .
|
|
|
333
379
|
rig --version
|
|
334
380
|
```
|
|
335
381
|
|
|
382
|
+
### Code style
|
|
383
|
+
|
|
384
|
+
[Ruff](https://docs.astral.sh/ruff/) does linting and formatting (configured in `pyproject.toml`: line length 120, double quotes, Python 3.10 syntax). CI runs `ruff check .` and `ruff format --check .`.
|
|
385
|
+
|
|
386
|
+
```bash
|
|
387
|
+
make format # apply ruff's formatting and safe lint fixes
|
|
388
|
+
make lint # the same checks as CI
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
`mypy src/` also runs in CI. Commits that only reformat code are listed in `.git-blame-ignore-revs`; run `git config blame.ignoreRevsFile .git-blame-ignore-revs` to make local `git blame` skip them (GitHub does this automatically).
|
|
392
|
+
|
|
336
393
|
## Tests
|
|
337
394
|
|
|
338
395
|
```bash
|
|
@@ -31,15 +31,16 @@ Replace the simulation methods in `src/cli/storage.py` with actual Hetzner Objec
|
|
|
31
31
|
import boto3
|
|
32
32
|
from botocore.exceptions import ClientError
|
|
33
33
|
|
|
34
|
+
|
|
34
35
|
def create_bucket(self, bucket_name: str) -> bool:
|
|
35
36
|
"""Create a new bucket using Hetzner Object Storage"""
|
|
36
37
|
try:
|
|
37
38
|
# Initialize S3 client with Hetzner endpoint
|
|
38
39
|
s3_client = boto3.client(
|
|
39
|
-
|
|
40
|
+
"s3",
|
|
40
41
|
endpoint_url=self.endpoint_url,
|
|
41
42
|
aws_access_key_id=self.hetzner_token, # This would be handled by Hetzner
|
|
42
|
-
aws_secret_access_key=self.hetzner_token # This would be handled by Hetzner
|
|
43
|
+
aws_secret_access_key=self.hetzner_token, # This would be handled by Hetzner
|
|
43
44
|
)
|
|
44
45
|
s3_client.create_bucket(Bucket=bucket_name)
|
|
45
46
|
print(f"Bucket '{bucket_name}' created successfully")
|
|
@@ -48,6 +49,7 @@ def create_bucket(self, bucket_name: str) -> bool:
|
|
|
48
49
|
print(f"Error creating bucket: {e}")
|
|
49
50
|
return False
|
|
50
51
|
|
|
52
|
+
|
|
51
53
|
# Similar implementations for other methods...
|
|
52
54
|
```
|
|
53
55
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Agents run as live agents in a rig-owned tmux, and `rig exec` starts them unattended
|
|
2
|
+
|
|
3
|
+
`rig attach` used to run the agent as the SSH session's own process, so closing the terminal killed it. Agents now run as live agents in a tmux session on a socket of their own (`tmux -L rig`, a config rig ships), which keeps them alive when the terminal goes away. `rig exec` starts one with a prompt and returns; it skips the agent's approval prompts by default, and queues a prompt into an already-running Claude Code only when Claude's hooks say that is safe.
|
|
4
|
+
|
|
5
|
+
## Considered Options
|
|
6
|
+
|
|
7
|
+
- **dtach / abduco**: rejected. They keep no screen state and give no scrollback, the redraw on reattach is uncertain, and abduco was not confirmed in Ubuntu 24.04. tmux is in the default repositories (3.4), and Claude Code documents a tmux configuration.
|
|
8
|
+
- **screen**: rejected. No evidence it handles the Agents' key sequences, and Cursor's docs say it intercepts Shift+Enter like tmux does.
|
|
9
|
+
- **Sharing the user's tmux or a default tmux config**: rejected. A separate socket and `-f` file mean rig never changes the behaviour of a tmux someone runs on the VM, and rig can set status bar off and the settings Claude Code recommends.
|
|
10
|
+
- **Queueing by sending keystrokes to every Agent**: rejected. A pasted prompt and Enter would answer an approval or trust dialog, and the Agents differ (Claude queues, OpenCode steers, Cursor is undocumented). Queueing is gated on Claude's hook-written state and supported for Claude Code only; the others refuse with a reason until verified.
|
|
11
|
+
- **Opt-in persistence (`--persist`)**: rejected. Losing an agent's work to a dropped connection is the worse default; `--no-persist` keeps the old behaviour.
|
|
12
|
+
- **A separate flag for unattended approval skipping**: rejected in favour of making it the default for `rig exec`, because an unattended agent that stops at a prompt is not unattended. `--no-auto-approve` opts out.
|
|
13
|
+
|
|
14
|
+
## Consequences
|
|
15
|
+
|
|
16
|
+
- Claude Code refuses its bypass mode as root, so `rig exec` launches it with `IS_SANDBOX=1`, and authorize pre-accepts its first-use warning dialog. Both were found by running against a real VM, and both would otherwise stop an unattended run silently.
|
|
17
|
+
- An unattended agent can run any command on the Environment, which has internet access, tokens and root. Prompt injection from repository content is a real risk, and `rig exec` says so every time it skips approvals.
|
|
18
|
+
- A live agent keeps the credentials and MCP config it started with; `rig attach --restart` picks up changes. `rig apply` and `rig delete` warn about running live agents but do not stop.
|
|
19
|
+
- tmux is part of the provisioned image, and Claude Code's settings carry rig-owned hooks (merged with the user's, identified by their command path).
|
|
20
|
+
- Agent output is logged on the VM so a resume id survives an unattended exit. The log can contain whatever the agent printed.
|
|
@@ -10,7 +10,7 @@ authors = [
|
|
|
10
10
|
]
|
|
11
11
|
description = "Ephemeral remotes with full local parity for coding agents"
|
|
12
12
|
readme = "README.md"
|
|
13
|
-
requires-python = ">=3.
|
|
13
|
+
requires-python = ">=3.10"
|
|
14
14
|
keywords = ["remote-development", "coding-agents", "hetzner"]
|
|
15
15
|
license = "MIT"
|
|
16
16
|
license-files = ["LICENSE"]
|
|
@@ -24,7 +24,6 @@ dependencies = [
|
|
|
24
24
|
"boto3>=1.26.0",
|
|
25
25
|
"PyYAML>=6.0",
|
|
26
26
|
"cryptography>=41.0.0",
|
|
27
|
-
"importlib-metadata>=4.0; python_version < '3.8'",
|
|
28
27
|
]
|
|
29
28
|
|
|
30
29
|
[project.urls]
|
|
@@ -38,5 +37,30 @@ rig = "cli.main:main"
|
|
|
38
37
|
[tool.setuptools.packages.find]
|
|
39
38
|
where = ["src"]
|
|
40
39
|
|
|
40
|
+
[tool.setuptools.package-data]
|
|
41
|
+
cli = ["assets/*"]
|
|
42
|
+
|
|
41
43
|
[tool.setuptools_scm]
|
|
42
44
|
fallback_version = "0.0.0"
|
|
45
|
+
|
|
46
|
+
[tool.ruff]
|
|
47
|
+
line-length = 120
|
|
48
|
+
target-version = "py310"
|
|
49
|
+
|
|
50
|
+
[tool.ruff.lint]
|
|
51
|
+
select = ["E", "F", "I", "UP"]
|
|
52
|
+
# Mirrors the old .flake8 ignores where enabling the rule would flood the diff.
|
|
53
|
+
# Tighten these gradually rather than all at once.
|
|
54
|
+
ignore = [
|
|
55
|
+
"E501", # line length: the formatter wraps code; long strings (playbooks) are left alone
|
|
56
|
+
"E402", # module-level import not at top
|
|
57
|
+
"F401", # unused import
|
|
58
|
+
"F841", # unused variable
|
|
59
|
+
"F541", # f-string without placeholders
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
[tool.ruff.lint.per-file-ignores]
|
|
63
|
+
"tests/*" = ["E731", "E741"]
|
|
64
|
+
|
|
65
|
+
[tool.ruff.format]
|
|
66
|
+
quote-style = "double"
|
|
@@ -10,9 +10,7 @@ from pathlib import Path
|
|
|
10
10
|
ROOT = Path(__file__).resolve().parents[1]
|
|
11
11
|
README = ROOT / "README.md"
|
|
12
12
|
COVERAGE_XML = ROOT / "coverage.xml"
|
|
13
|
-
BADGE_RE = re.compile(
|
|
14
|
-
r"https://img\.shields\.io/badge/coverage-\d+%25-[a-z]+"
|
|
15
|
-
)
|
|
13
|
+
BADGE_RE = re.compile(r"https://img\.shields\.io/badge/coverage-\d+%25-[a-z]+")
|
|
16
14
|
|
|
17
15
|
|
|
18
16
|
def line_percent(xml_path: Path) -> int:
|
|
@@ -26,13 +26,12 @@ def version_from_tag(tag: str) -> str:
|
|
|
26
26
|
"""
|
|
27
27
|
raw = tag.strip()
|
|
28
28
|
if raw.startswith("refs/tags/"):
|
|
29
|
-
raw = raw[len("refs/tags/"):]
|
|
29
|
+
raw = raw[len("refs/tags/") :]
|
|
30
30
|
if raw[:1] in ("v", "V"):
|
|
31
31
|
raw = raw[1:]
|
|
32
32
|
if not _VERSION.fullmatch(raw):
|
|
33
33
|
raise ValueError(
|
|
34
|
-
f"release tag {tag!r} is not a public PEP 440 version "
|
|
35
|
-
"(expected vX.Y.Z, optional a/b/rc/post/dev suffix)"
|
|
34
|
+
f"release tag {tag!r} is not a public PEP 440 version (expected vX.Y.Z, optional a/b/rc/post/dev suffix)"
|
|
36
35
|
)
|
|
37
36
|
return raw
|
|
38
37
|
|
|
@@ -55,17 +54,11 @@ def archive_metadata(path: Path) -> tuple[str, str]:
|
|
|
55
54
|
"""Return ``(name, version)`` from a wheel or sdist."""
|
|
56
55
|
if path.name.endswith(".whl"):
|
|
57
56
|
with zipfile.ZipFile(path) as archive:
|
|
58
|
-
name = next(
|
|
59
|
-
item for item in archive.namelist()
|
|
60
|
-
if item.endswith(".dist-info/METADATA")
|
|
61
|
-
)
|
|
57
|
+
name = next(item for item in archive.namelist() if item.endswith(".dist-info/METADATA"))
|
|
62
58
|
text = archive.read(name).decode()
|
|
63
59
|
elif path.name.endswith(".tar.gz"):
|
|
64
60
|
with tarfile.open(path) as archive:
|
|
65
|
-
member = next(
|
|
66
|
-
item for item in archive.getmembers()
|
|
67
|
-
if item.name.endswith("/PKG-INFO")
|
|
68
|
-
)
|
|
61
|
+
member = next(item for item in archive.getmembers() if item.name.endswith("/PKG-INFO"))
|
|
69
62
|
extracted = archive.extractfile(member)
|
|
70
63
|
if extracted is None:
|
|
71
64
|
raise ValueError(f"{path} is missing PKG-INFO")
|
|
@@ -78,8 +71,7 @@ def archive_metadata(path: Path) -> tuple[str, str]:
|
|
|
78
71
|
def check_dist(dist_dir: Path, expected_version: str, expected_name: str = "mystack-rig") -> None:
|
|
79
72
|
"""Fail unless dist contains one sdist and one wheel at the tag version."""
|
|
80
73
|
archives = [
|
|
81
|
-
path for path in sorted(dist_dir.iterdir())
|
|
82
|
-
if path.name.endswith(".whl") or path.name.endswith(".tar.gz")
|
|
74
|
+
path for path in sorted(dist_dir.iterdir()) if path.name.endswith(".whl") or path.name.endswith(".tar.gz")
|
|
83
75
|
]
|
|
84
76
|
wheels = [path for path in archives if path.name.endswith(".whl")]
|
|
85
77
|
sdists = [path for path in archives if path.name.endswith(".tar.gz")]
|
|
@@ -89,9 +81,7 @@ def check_dist(dist_dir: Path, expected_version: str, expected_name: str = "myst
|
|
|
89
81
|
for path in archives:
|
|
90
82
|
name, version = archive_metadata(path)
|
|
91
83
|
if name != expected_name or version != expected_version:
|
|
92
|
-
raise ValueError(
|
|
93
|
-
f"{path.name} is {name} {version}, expected {expected_name} {expected_version}"
|
|
94
|
-
)
|
|
84
|
+
raise ValueError(f"{path.name} is {name} {version}, expected {expected_name} {expected_version}")
|
|
95
85
|
|
|
96
86
|
|
|
97
87
|
def main(argv: list[str] | None = None) -> int:
|