claudemol 0.2.0__py3-none-any.whl → 0.3.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.
claudemol/__init__.py CHANGED
@@ -6,15 +6,18 @@ Connect to PyMOL via socket for AI-assisted molecular visualization.
6
6
 
7
7
  from claudemol.connection import (
8
8
  PyMOLConnection,
9
+ check_pymol_installed,
9
10
  connect_or_launch,
10
- launch_pymol,
11
11
  find_pymol_command,
12
- check_pymol_installed,
12
+ get_config,
13
+ get_configured_python,
14
+ launch_pymol,
15
+ save_config,
13
16
  )
14
17
  from claudemol.session import (
15
18
  PyMOLSession,
16
- get_session,
17
19
  ensure_running,
20
+ get_session,
18
21
  stop_pymol,
19
22
  )
20
23
 
@@ -26,6 +29,9 @@ __all__ = [
26
29
  "launch_pymol",
27
30
  "find_pymol_command",
28
31
  "check_pymol_installed",
32
+ "get_config",
33
+ "save_config",
34
+ "get_configured_python",
29
35
  "get_session",
30
36
  "ensure_running",
31
37
  "stop_pymol",
claudemol/cli.py CHANGED
@@ -12,10 +12,14 @@ import sys
12
12
  from pathlib import Path
13
13
 
14
14
  from claudemol.connection import (
15
+ CONFIG_FILE,
15
16
  PyMOLConnection,
16
17
  check_pymol_installed,
17
18
  find_pymol_command,
19
+ get_config,
20
+ get_configured_python,
18
21
  get_plugin_path,
22
+ save_config,
19
23
  )
20
24
 
21
25
 
@@ -34,10 +38,13 @@ def setup_pymol():
34
38
  if "claudemol" in content or "claude_socket_plugin" in content:
35
39
  print("PyMOL already configured for claudemol.")
36
40
  print(f"Plugin: {plugin_path}")
41
+ # Still save config (in case Python path changed)
42
+ save_config({"python_path": sys.executable})
43
+ print(f"Saved Python path: {sys.executable}")
37
44
  return 0
38
45
 
39
46
  # Add to .pymolrc
40
- run_command = f'\n# claudemol: Claude Code integration\nrun {plugin_path}\n'
47
+ run_command = f"\n# claudemol: Claude Code integration\nrun {plugin_path}\n"
41
48
 
42
49
  if pymolrc_path.exists():
43
50
  with open(pymolrc_path, "a") as f:
@@ -58,6 +65,10 @@ def setup_pymol():
58
65
  print(" - brew install pymol (macOS)")
59
66
  print(" - Download from https://pymol.org")
60
67
 
68
+ # Save Python path for SessionStart hook and skills
69
+ save_config({"python_path": sys.executable})
70
+ print(f"Saved Python path: {sys.executable}")
71
+
61
72
  return 0
62
73
 
63
74
 
@@ -65,6 +76,11 @@ def check_status():
65
76
  """Check PyMOL connection status."""
66
77
  print("Checking PyMOL status...")
67
78
 
79
+ # Show configured Python if available
80
+ configured_python = get_configured_python()
81
+ if configured_python:
82
+ print(f"Configured Python: {configured_python}")
83
+
68
84
  # Check if PyMOL is installed
69
85
  pymol_cmd = find_pymol_command()
70
86
  if pymol_cmd:
@@ -125,6 +141,14 @@ def show_info():
125
141
  pymol_cmd = find_pymol_command()
126
142
  print(f" PyMOL command: {' '.join(pymol_cmd) if pymol_cmd else 'not found'}")
127
143
 
144
+ print(f" Config file: {CONFIG_FILE}")
145
+ config = get_config()
146
+ if config:
147
+ for key, value in config.items():
148
+ print(f" Config {key}: {value}")
149
+ else:
150
+ print(" Config: not set (run 'claudemol setup' to configure)")
151
+
128
152
 
129
153
  def main():
130
154
  parser = argparse.ArgumentParser(
claudemol/connection.py CHANGED
@@ -17,6 +17,9 @@ DEFAULT_PORT = 9880
17
17
  CONNECT_TIMEOUT = 5.0
18
18
  RECV_TIMEOUT = 30.0
19
19
 
20
+ CONFIG_DIR = Path.home() / ".claudemol"
21
+ CONFIG_FILE = CONFIG_DIR / "config.json"
22
+
20
23
  # Common PyMOL installation paths
21
24
  PYMOL_PATHS = [
22
25
  # uv environment (created by /pymol-setup)
@@ -247,3 +250,28 @@ def connect_or_launch(file_path=None):
247
250
  process = launch_pymol(file_path=file_path)
248
251
  conn.connect()
249
252
  return conn, process
253
+
254
+
255
+ def get_config():
256
+ """Read persisted claudemol config."""
257
+ if CONFIG_FILE.exists():
258
+ try:
259
+ return json.loads(CONFIG_FILE.read_text())
260
+ except (json.JSONDecodeError, OSError):
261
+ return {}
262
+ return {}
263
+
264
+
265
+ def save_config(config):
266
+ """Save claudemol config."""
267
+ CONFIG_DIR.mkdir(parents=True, exist_ok=True)
268
+ CONFIG_FILE.write_text(json.dumps(config, indent=2) + "\n")
269
+
270
+
271
+ def get_configured_python():
272
+ """Get the Python path from persisted config. Returns path string or None."""
273
+ config = get_config()
274
+ python_path = config.get("python_path")
275
+ if python_path and os.path.isfile(python_path) and os.access(python_path, os.X_OK):
276
+ return python_path
277
+ return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: claudemol
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: PyMOL integration for Claude Code - control molecular visualization via natural language
5
5
  Project-URL: Homepage, https://github.com/ANaka/claudemol
6
6
  Project-URL: Repository, https://github.com/ANaka/claudemol
@@ -30,6 +30,7 @@ Control PyMOL through natural language using Claude Code. This integration enabl
30
30
  - **Direct socket communication**: Claude Code talks directly to PyMOL (no intermediary server)
31
31
  - **Full PyMOL access**: Manipulate representations, colors, views, perform measurements, alignments, and more
32
32
  - **Skill-based workflows**: Built-in skills for common tasks like binding site visualization and publication figures
33
+ - **Connect to anything**: Because Claude is the bridge, it can pull in data from online databases (UniProt, PDB, OPM), literature, protein language model annotations, or local analysis scripts and map them directly onto your structure
33
34
 
34
35
  ## Architecture
35
36
 
@@ -45,22 +46,47 @@ Claude Code → TCP Socket (port 9880) → PyMOL Plugin → cmd.* execution
45
46
  - [Claude Code](https://docs.anthropic.com/en/docs/claude-code) CLI installed
46
47
  - Python 3.10+
47
48
 
48
- ### Installation
49
+ ### 1. Install claudemol
49
50
 
50
51
  ```bash
51
52
  pip install claudemol
52
53
  claudemol setup
53
54
  ```
54
55
 
55
- This installs the package and configures PyMOL to auto-load the socket plugin.
56
+ This configures PyMOL to auto-load the socket plugin and saves your Python path to `~/.claudemol/config.json` so future Claude Code sessions can find it automatically.
56
57
 
57
- ### Start Using It
58
+ ### 2. Install the Claude Code plugin
59
+
60
+ ```
61
+ /plugin marketplace add ANaka/claudemol?path=claude-plugin
62
+ /plugin install claudemol-skills
63
+ ```
64
+
65
+ This gives Claude the skills and hooks to work with PyMOL.
66
+
67
+ ### 3. Start using it
58
68
 
59
69
  Open Claude Code and say:
60
70
 
61
71
  > "Open PyMOL and load structure 1UBQ"
62
72
 
63
- Claude will launch PyMOL (with the socket listener active) and load the structure.
73
+ Claude will launch PyMOL, connect via socket, and load the structure.
74
+
75
+ ### Optional: Seamless permissions
76
+
77
+ By default, Claude asks for approval before running each command. To auto-approve PyMOL-related commands, add to your project's `.claude/settings.json`:
78
+
79
+ ```json
80
+ {
81
+ "permissions": {
82
+ "allow": [
83
+ "Bash(claudemol*)",
84
+ "Bash(*python*claudemol*)",
85
+ "Bash(pymol*)"
86
+ ]
87
+ }
88
+ }
89
+ ```
64
90
 
65
91
  ## Usage
66
92
 
@@ -72,15 +98,15 @@ Simply ask Claude to open PyMOL or load a structure:
72
98
  - "Load PDB 4HHB and show as cartoon"
73
99
  - "Fetch 1UBQ from the PDB"
74
100
 
75
- Claude will launch PyMOL if it's not already running.
101
+ Claude connects to an existing PyMOL if one is running, or launches a new instance.
76
102
 
77
103
  ### Example Commands
78
104
 
79
105
  - "Color the protein by secondary structure"
80
- - "Show the binding site residues within of the ligand as sticks"
106
+ - "Show the binding site residues within 5A of the ligand as sticks"
81
107
  - "Align these two structures and calculate RMSD"
82
108
  - "Create a publication-quality figure with ray tracing"
83
- - "Make a 360° rotation movie"
109
+ - "Make a 360 degree rotation movie"
84
110
 
85
111
  ### PyMOL Console Commands
86
112
 
@@ -94,7 +120,7 @@ claude_start # Start the listener
94
120
 
95
121
  ### Available Skills
96
122
 
97
- Claude Code has built-in skills for common workflows:
123
+ The plugin includes skills for common workflows:
98
124
 
99
125
  - **pymol-fundamentals** - Basic visualization, selections, coloring
100
126
  - **protein-structure-basics** - Secondary structure, B-factor, representations
@@ -104,6 +130,19 @@ Claude Code has built-in skills for common workflows:
104
130
  - **publication-figures** - High-quality figure export
105
131
  - **movie-creation** - Animations and rotations
106
132
 
133
+ ## How It Works
134
+
135
+ ### Connection Lifecycle
136
+
137
+ 1. On session start, a hook runs `claudemol status` to check if PyMOL is reachable
138
+ 2. When you ask Claude to work with PyMOL, it uses `connect_or_launch()` — connecting to an existing instance or starting a new one
139
+ 3. Commands are sent as Python code over TCP and executed inside PyMOL via the socket plugin
140
+ 4. If the connection drops, `conn.execute()` auto-reconnects (up to 3 attempts)
141
+
142
+ ### Venv Support
143
+
144
+ `claudemol setup` saves your Python interpreter path to `~/.claudemol/config.json`. This means claudemol works even when installed in a project virtualenv — the SessionStart hook and skills read the config to find the right Python.
145
+
107
146
  ## Troubleshooting
108
147
 
109
148
  ### Connection Issues
@@ -117,18 +156,30 @@ Claude Code has built-in skills for common workflows:
117
156
  - Run `claudemol setup` to configure PyMOL
118
157
  - Check PyMOL's output for any error messages on startup
119
158
 
159
+ ### claudemol Not Found
160
+
161
+ If Claude reports `ModuleNotFoundError`, claudemol may be installed in a venv that isn't active. Fix:
162
+
163
+ ```bash
164
+ # Re-run setup from the venv that has claudemol
165
+ .venv/bin/claudemol setup
166
+ ```
167
+
168
+ This updates `~/.claudemol/config.json` so future sessions find it.
169
+
120
170
  ### First-Time Setup Help
121
171
 
122
- Run the `/pymol-setup` skill in Claude Code for guided setup assistance.
172
+ Run `/pymol-setup` in Claude Code for guided setup assistance.
123
173
 
124
174
  ## Configuration
125
175
 
126
- The default socket port is **9880**. Both the plugin and Claude Code connection module use this port.
176
+ The default socket port is **9880**. Both the plugin and connection module use this port.
127
177
 
128
178
  Key files:
129
- - `src/claudemol/plugin.py` - PyMOL plugin (auto-loads via pymolrc)
179
+ - `~/.pymolrc` - PyMOL startup script (loads the socket plugin)
180
+ - `~/.claudemol/config.json` - Persisted Python path for venv discovery
181
+ - `src/claudemol/plugin.py` - Socket listener plugin (runs inside PyMOL)
130
182
  - `src/claudemol/connection.py` - Python module for socket communication
131
- - `claude-plugin/skills/` - Claude Code skills for PyMOL workflows
132
183
 
133
184
  ## Limitations
134
185
 
@@ -0,0 +1,11 @@
1
+ claudemol/__init__.py,sha256=SaNeozowULmMoX3-9qAlG9sNk--xgkreurxppLkVE4A,744
2
+ claudemol/cli.py,sha256=fF3hfDLZVx5W6LYO2OOoPGnkvTHbQqF1H6FX1pIfMeQ,5850
3
+ claudemol/connection.py,sha256=pJXO5eBXir8NHXohOl5gk3YSE5bv0zggDK9cfnP0hE0,8333
4
+ claudemol/plugin.py,sha256=xRqpd9Ncn2vDZnmZsKHcFrhISJng38FAZv_0Thy-axc,5513
5
+ claudemol/session.py,sha256=BtaIx9UalvnnlmQ1Zr9HFAlvt_0HzrAnT952HPpFG4w,8258
6
+ claudemol/view.py,sha256=k5wzx2jOeYgZKJKNJfk-3Aat3iDvKU-8y9dMAjb4E-A,4103
7
+ claudemol-0.3.0.dist-info/METADATA,sha256=qv5TatSb0fhnNjx30iqiuvmiyUR6gX_Va6E7IpWdJLY,6593
8
+ claudemol-0.3.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
9
+ claudemol-0.3.0.dist-info/entry_points.txt,sha256=zHSqaPcqaXWoGEavppdq_zTrMARmjjrTqLHa5KEBchw,49
10
+ claudemol-0.3.0.dist-info/licenses/LICENSE,sha256=sZWsSm99w9tlHsmCnA7_6KzEAqQaD7nSQlgYesvvWMQ,1075
11
+ claudemol-0.3.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.27.0
2
+ Generator: hatchling 1.28.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,11 +0,0 @@
1
- claudemol/__init__.py,sha256=RZDmQTql01kKApSDdMC3qy07Bz71CE1f6vyOJ_l7wHk,618
2
- claudemol/cli.py,sha256=YMOWlO5fLsczb-fLztnEj8xhj1M9H6Bog16maw_A7ME,5011
3
- claudemol/connection.py,sha256=lvHb6wJ2uxKiVxpQU-KXUyWD4R_hkNttw12dO1CcXC0,7519
4
- claudemol/plugin.py,sha256=xRqpd9Ncn2vDZnmZsKHcFrhISJng38FAZv_0Thy-axc,5513
5
- claudemol/session.py,sha256=BtaIx9UalvnnlmQ1Zr9HFAlvt_0HzrAnT952HPpFG4w,8258
6
- claudemol/view.py,sha256=k5wzx2jOeYgZKJKNJfk-3Aat3iDvKU-8y9dMAjb4E-A,4103
7
- claudemol-0.2.0.dist-info/METADATA,sha256=bomqdT1MfSEAGo5GB-WrXO2tjWTxaPLr5bcRnDguDb8,4686
8
- claudemol-0.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
- claudemol-0.2.0.dist-info/entry_points.txt,sha256=zHSqaPcqaXWoGEavppdq_zTrMARmjjrTqLHa5KEBchw,49
10
- claudemol-0.2.0.dist-info/licenses/LICENSE,sha256=sZWsSm99w9tlHsmCnA7_6KzEAqQaD7nSQlgYesvvWMQ,1075
11
- claudemol-0.2.0.dist-info/RECORD,,