dynamic-ralph 0.1.0__py3-none-any.whl

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.
bin/__init__.py ADDED
File without changes
bin/run_agent.py ADDED
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env python3
2
+ """Run an interactive Claude Code session inside the ralph-agent container.
3
+
4
+ Mounts host credentials (~/.claude, ~/.config/claude), the current directory
5
+ as /workspace, and the Docker socket. Uses ``os.execvp`` so the container
6
+ gets direct TTY access for a regular interactive Claude experience.
7
+
8
+ Extra arguments after ``--`` are forwarded to the ``claude`` CLI.
9
+ """
10
+
11
+ import os
12
+ import sys
13
+ from pathlib import Path
14
+
15
+ from multi_agent.constants import GIT_EMAIL, RALPH_IMAGE, RALPH_MODE, get_git_author_identity
16
+ from multi_agent.docker import build_image, docker_sock_gid, image_exists
17
+
18
+
19
+ def build_interactive_docker_command(
20
+ *,
21
+ image: str = RALPH_IMAGE,
22
+ workspace: str | None = None,
23
+ extra_args: list[str] | None = None,
24
+ ) -> list[str]:
25
+ """Build a ``docker run -it`` command for interactive Claude Code use."""
26
+ if workspace is None:
27
+ workspace = os.getcwd()
28
+
29
+ author_name, author_email = get_git_author_identity()
30
+ home = Path.home()
31
+ claude_dir = home / '.claude'
32
+ config_claude = home / '.config' / 'claude'
33
+
34
+ cmd: list[str] = [
35
+ 'docker',
36
+ 'run',
37
+ '-it',
38
+ '--rm',
39
+ '--group-add',
40
+ docker_sock_gid(),
41
+ '-e',
42
+ 'IS_SANDBOX=1',
43
+ '-e',
44
+ 'UV_PROJECT_ENVIRONMENT=/tmp/venv',
45
+ '-e',
46
+ f'GIT_AUTHOR_NAME={author_name}',
47
+ '-e',
48
+ f'GIT_AUTHOR_EMAIL={author_email}',
49
+ '-e',
50
+ 'GIT_COMMITTER_NAME=Claude Agent',
51
+ '-e',
52
+ f'GIT_COMMITTER_EMAIL={GIT_EMAIL}',
53
+ '-e',
54
+ f'RALPH_MODE={RALPH_MODE}',
55
+ '-v',
56
+ '/var/run/docker.sock:/var/run/docker.sock',
57
+ '-v',
58
+ f'{workspace}:/workspace',
59
+ '-v',
60
+ '/workspace/.venv',
61
+ '-v',
62
+ f'{claude_dir}:/home/agent/.claude',
63
+ '-v',
64
+ f'{config_claude}:/home/agent/.config/claude',
65
+ '-w',
66
+ '/workspace',
67
+ image,
68
+ 'claude',
69
+ '--dangerously-skip-permissions',
70
+ ]
71
+
72
+ if extra_args:
73
+ cmd.extend(extra_args)
74
+
75
+ return cmd
76
+
77
+
78
+ def main() -> None:
79
+ # Ensure the Docker image is available
80
+ if not image_exists():
81
+ build_image()
82
+
83
+ # Everything after '--' is forwarded to claude
84
+ extra: list[str] = []
85
+ if '--' in sys.argv:
86
+ sep = sys.argv.index('--')
87
+ extra = sys.argv[sep + 1 :]
88
+
89
+ cmd = build_interactive_docker_command(extra_args=extra or None)
90
+ os.execvp(cmd[0], cmd)
91
+
92
+
93
+ if __name__ == '__main__':
94
+ main()