dynra 0.1.1__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.
- dynra-0.1.1/LICENSE +201 -0
- dynra-0.1.1/PKG-INFO +294 -0
- dynra-0.1.1/README.md +265 -0
- dynra-0.1.1/pyproject.toml +53 -0
- dynra-0.1.1/setup.cfg +4 -0
- dynra-0.1.1/src/dynra/__init__.py +6 -0
- dynra-0.1.1/src/dynra/__main__.py +5 -0
- dynra-0.1.1/src/dynra/client.py +69 -0
- dynra-0.1.1/src/dynra/core.py +1334 -0
- dynra-0.1.1/src/dynra/mcp.py +123 -0
- dynra-0.1.1/src/dynra/project.py +166 -0
- dynra-0.1.1/src/dynra/runtime.py +191 -0
- dynra-0.1.1/src/dynra.egg-info/PKG-INFO +294 -0
- dynra-0.1.1/src/dynra.egg-info/SOURCES.txt +22 -0
- dynra-0.1.1/src/dynra.egg-info/dependency_links.txt +1 -0
- dynra-0.1.1/src/dynra.egg-info/entry_points.txt +4 -0
- dynra-0.1.1/src/dynra.egg-info/requires.txt +5 -0
- dynra-0.1.1/src/dynra.egg-info/top_level.txt +1 -0
- dynra-0.1.1/tests/test_client.py +29 -0
- dynra-0.1.1/tests/test_mcp.py +121 -0
- dynra-0.1.1/tests/test_patching.py +47 -0
- dynra-0.1.1/tests/test_registry_safety.py +139 -0
- dynra-0.1.1/tests/test_repl.py +69 -0
- dynra-0.1.1/tests/test_workflow.py +293 -0
dynra-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
dynra-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dynra
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Live Python runtime for LLM coding agents
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://github.com/antlobach/Dynra
|
|
7
|
+
Project-URL: Documentation, https://github.com/antlobach/Dynra#readme
|
|
8
|
+
Project-URL: Repository, https://github.com/antlobach/Dynra
|
|
9
|
+
Project-URL: Issues, https://github.com/antlobach/Dynra/issues
|
|
10
|
+
Keywords: development,live-coding,mcp,repl
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Topic :: Software Development :: Debuggers
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: ipython>=8.0
|
|
26
|
+
Requires-Dist: mcp<2,>=1.0
|
|
27
|
+
Requires-Dist: tomli>=2.0; python_version < "3.11"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
<p align="center">
|
|
31
|
+
<img src="assets/dynra-logo.svg" alt="Dynra" width="860">
|
|
32
|
+
</p>
|
|
33
|
+
|
|
34
|
+
<p align="center">
|
|
35
|
+
<strong>Live Python runtime for coding agents.</strong><br>
|
|
36
|
+
Inspect, patch, and verify running software without restarting the process or losing its state.
|
|
37
|
+
</p>
|
|
38
|
+
|
|
39
|
+
<p align="center">
|
|
40
|
+
<a href="https://github.com/antlobach/Dynra/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/antlobach/Dynra/ci.yml?branch=main&style=flat-square&label=tests" alt="Tests" height="20"></a>
|
|
41
|
+
<a href="https://github.com/antlobach/Dynra/actions/workflows/ci.yml"><img src="https://img.shields.io/badge/coverage-%E2%89%A565%25-brightgreen?style=flat-square" alt="Coverage ≥65%" height="20"></a>
|
|
42
|
+
<img src="https://img.shields.io/badge/python-3.10--3.14-3776AB?style=flat-square&logo=python&logoColor=white" alt="Python 3.10–3.14" height="20">
|
|
43
|
+
<a href="https://github.com/antlobach/Dynra/releases/latest"><img src="https://img.shields.io/github/v/release/antlobach/Dynra?style=flat-square&display_name=tag&cacheSeconds=300" alt="Latest release" height="20"></a>
|
|
44
|
+
<a href="LICENSE"><img src="https://img.shields.io/github/license/antlobach/Dynra?style=flat-square" alt="Apache-2.0 license" height="20"></a>
|
|
45
|
+
<a href="https://deepwiki.com/antlobach/Dynra"><img src="assets/deepwiki-badge.svg" alt="Ask DeepWiki" height="20"></a>
|
|
46
|
+
</p>
|
|
47
|
+
|
|
48
|
+
## Overview
|
|
49
|
+
|
|
50
|
+
Dynra lets a coding agent develop Python software interactively inside a persistent process. The agent can navigate project modules, execute arbitrary Python in their namespaces, add or redefine functions and classes, and exercise each change immediately against the running application.
|
|
51
|
+
|
|
52
|
+
Compatible function and class identities stay stable while the software evolves. Existing imports, registries, closures, partials, and class instances can continue to refer to the patched objects.
|
|
53
|
+
|
|
54
|
+
```mermaid
|
|
55
|
+
flowchart LR
|
|
56
|
+
A[Coding agent] -->|dynra_repl| M[MCP adapter]
|
|
57
|
+
M --> R[Long-lived IPython process]
|
|
58
|
+
R --> N[Project module namespaces]
|
|
59
|
+
R --> P[Live patch engine]
|
|
60
|
+
P --> O[Existing references and instances]
|
|
61
|
+
O --> V[Verification against preserved state]
|
|
62
|
+
V --> A
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Capabilities
|
|
66
|
+
|
|
67
|
+
- Discovers modules from the repository root, `src/`, and configured setuptools, Poetry, or Hatch source roots.
|
|
68
|
+
- Lists an unloaded module's public symbols without importing it.
|
|
69
|
+
- Executes arbitrary Python in a selected module namespace.
|
|
70
|
+
- Preserves compatible function and class identities across redefinitions.
|
|
71
|
+
- Updates existing imported references and mutable holders.
|
|
72
|
+
- Migrates existing instances through an optional `__dynra_update__` hook.
|
|
73
|
+
- Skips registration decorators when replacing an existing decorated definition.
|
|
74
|
+
- Rolls back definition changes when a multi-definition evaluation fails.
|
|
75
|
+
- Shows, reverts, and persists live changes.
|
|
76
|
+
|
|
77
|
+
## Install and start
|
|
78
|
+
|
|
79
|
+
Add Dynra as a development dependency of the target project:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
cd /path/to/target-project
|
|
83
|
+
uv add --dev dynra
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Start Dynra from the target project's root:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
uv run dynra
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Dynra runs in the target project's virtual environment, so project dependencies
|
|
93
|
+
are importable. It reads the target's `pyproject.toml`, activates its source
|
|
94
|
+
roots, and indexes its Python modules without importing them. Dynra does not
|
|
95
|
+
start the application; import or bootstrap the application explicitly when its
|
|
96
|
+
live state is needed. The runtime listens on `127.0.0.1:9999` by default. Use
|
|
97
|
+
`uv run dynra --port PORT` to select another port.
|
|
98
|
+
|
|
99
|
+
## Agents
|
|
100
|
+
|
|
101
|
+
The repository includes a [Dynra agent skill](.agents/skills/dynra/SKILL.md). Give that skill to an agent that can call the MCP server. It defines the live-development loop, patching constraints, failure handling, and the point at which a verified live change should become a source edit.
|
|
102
|
+
|
|
103
|
+
In a project-local MCP configuration, run the installed adapter through the
|
|
104
|
+
project environment:
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"mcpServers": {
|
|
109
|
+
"dynra": {
|
|
110
|
+
"command": "uv",
|
|
111
|
+
"args": ["run", "dynra-mcp"]
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The MCP client must launch this command with the target project as its working
|
|
118
|
+
directory. If the configuration is global, set its supported `cwd` option to
|
|
119
|
+
the target project. Start `uv run dynra` separately before using the tool.
|
|
120
|
+
|
|
121
|
+
The adapter exposes one tool:
|
|
122
|
+
|
|
123
|
+
```text
|
|
124
|
+
dynra_repl(code, module="user", create=False, port=9999)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
`port` selects an existing long-running Dynra/IPython process on `127.0.0.1`; it does not start a new process. The value must match the runtime's `dynra --port PORT` option. `module` selects the namespace before evaluation. Imports are strict, so missing modules and import-time failures return errors. Set `create=True` only for an intentional synthetic scratch module. Responses always contain `success`. Dynra includes `result`, `stdout`, `stderr`, and `error` only when they carry information, and includes `source_sync` only for live changes, healing, conflicts, or source errors. An absent `source_sync` means the selected module is clean.
|
|
128
|
+
|
|
129
|
+
### Agent workflow
|
|
130
|
+
|
|
131
|
+
1. Discover the project's modules without importing them.
|
|
132
|
+
2. Enter a module and inspect its live namespace.
|
|
133
|
+
3. Execute focused expressions to explore behavior or build the next increment.
|
|
134
|
+
4. Add or redefine a complete function or class in its owning module.
|
|
135
|
+
5. Exercise the change through a real consumer while process state remains alive.
|
|
136
|
+
6. Inspect the live-versus-disk diff.
|
|
137
|
+
7. Persist the definition or apply the equivalent source edit, then run the project's durable checks.
|
|
138
|
+
|
|
139
|
+
Example:
|
|
140
|
+
|
|
141
|
+
```text
|
|
142
|
+
dynra_repl(code="ls_md()")
|
|
143
|
+
dynra_repl(code="dir_md('shop.pricing')")
|
|
144
|
+
|
|
145
|
+
dynra_repl(
|
|
146
|
+
module="shop.pricing",
|
|
147
|
+
code="source(calculate_total)",
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
dynra_repl(
|
|
151
|
+
module="shop.pricing",
|
|
152
|
+
code="def calculate_total(cart):\n return sum(item.price * item.quantity for item in cart)",
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
dynra_repl(
|
|
156
|
+
module="shop.checkout",
|
|
157
|
+
code="active_checkout.total()",
|
|
158
|
+
port=9999,
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
dynra_repl(
|
|
162
|
+
module="shop.pricing",
|
|
163
|
+
code="source_patch()",
|
|
164
|
+
)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
A successful live patch proves the behavior in the current process. It does not replace source control or the project's test suite.
|
|
168
|
+
|
|
169
|
+
## Namespace model
|
|
170
|
+
|
|
171
|
+
Dynra starts in a synthetic `user` namespace. Use the `module` argument on `dynra_repl` for atomic namespace selection. Within the REPL, these commands manage namespaces:
|
|
172
|
+
|
|
173
|
+
- `require_md(name)` imports a real module and preserves the original import failure.
|
|
174
|
+
- `create_md(name)` creates a synthetic namespace without entering it.
|
|
175
|
+
- `in_md(name)` enters an existing real or synthetic namespace.
|
|
176
|
+
- `ls_md()` separates discovered, loaded-project, synthetic, and external modules.
|
|
177
|
+
- `dir_md(name)` statically inspects an unloaded project module or lists a loaded module.
|
|
178
|
+
|
|
179
|
+
Dynra supplies its commands through REPL builtins. It does not add those names to application module globals.
|
|
180
|
+
|
|
181
|
+
## Source healing
|
|
182
|
+
|
|
183
|
+
Before each evaluation, Dynra checks the source-file signatures of tracked project modules. The clean path performs metadata checks only. Dynra parses a file after its signature changes.
|
|
184
|
+
|
|
185
|
+
External edits to top-level functions and classes are applied automatically to the existing live objects. Prior imports and compatible instances therefore receive the new behavior without module reloads. Added definitions are evaluated in the live namespace. Deleted definitions are removed from the owning module and direct module imports. Each healed batch increments the module generation and appears in the response's `source_sync` field.
|
|
186
|
+
|
|
187
|
+
A module can repair derived state through an opt-in hook:
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
def __dynra_reconcile__(changes):
|
|
191
|
+
if any(change[\"definition\"].endswith(\".build_routes\") for change in changes):
|
|
192
|
+
rebuild_routes_in_place()
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Dynra does not rerun arbitrary assignments, imports, or top-level side effects. Constants and copied values retain normal Python semantics. If both disk and the REPL changed the same definition, Dynra keeps the live definition and reports a conflict instead of guessing. `persist_source()` uses the captured base definition and refuses to overwrite an external edit.
|
|
196
|
+
|
|
197
|
+
## Live patch model
|
|
198
|
+
|
|
199
|
+
Remote code executes one top-level statement at a time. After each function or class definition, Dynra reconciles the new object with the live object:
|
|
200
|
+
|
|
201
|
+
- Safe function mode refuses incompatible closure layouts and sync/async changes when old objects still have direct holders.
|
|
202
|
+
- Safe class mode refuses incompatible metaclass, base-class, and `__slots__` changes.
|
|
203
|
+
- Existing decorated definitions retain their registration because Dynra does not rerun their decorators.
|
|
204
|
+
- A multi-definition request restores changed definitions if a definition is refused or evaluation fails.
|
|
205
|
+
|
|
206
|
+
Transactions cover definition changes. They cannot undo arbitrary external side effects from ordinary statements or a first-time decorator. Native extension state, process configuration, and incompatible object layouts can still require a restart.
|
|
207
|
+
|
|
208
|
+
### Evolving existing instances
|
|
209
|
+
|
|
210
|
+
Add `__dynra_update__` when a compatible class patch needs to initialize state on existing instances:
|
|
211
|
+
|
|
212
|
+
```python
|
|
213
|
+
class Session:
|
|
214
|
+
def __init__(self, user):
|
|
215
|
+
self.user = user
|
|
216
|
+
|
|
217
|
+
def label(self):
|
|
218
|
+
return f"{self.user}:{self.status}"
|
|
219
|
+
|
|
220
|
+
def __dynra_update__(self):
|
|
221
|
+
if not hasattr(self, "status"):
|
|
222
|
+
self.status = "active"
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
After the patch, existing `Session` instances use the new methods and run `__dynra_update__`.
|
|
226
|
+
|
|
227
|
+
## Runtime commands
|
|
228
|
+
|
|
229
|
+
| Command | Purpose |
|
|
230
|
+
| --- | --- |
|
|
231
|
+
| `create_md(name)` | Create a synthetic scratch module. |
|
|
232
|
+
| `require_md(name)` | Import a real module and surface its complete import error. |
|
|
233
|
+
| `in_md(name)` | Enter an existing real or synthetic module. |
|
|
234
|
+
| `ls_md()` | List discovered, loaded-project, synthetic, and external modules. |
|
|
235
|
+
| `dir_md(module=None)` | List symbols, including static inspection of unloaded project modules. |
|
|
236
|
+
| `doc(obj)` / `source(obj)` | Show documentation or live source. |
|
|
237
|
+
| `find_var(pattern)` | Search loaded modules for matching symbol names. |
|
|
238
|
+
| `function_patch_mode(mode=None)` | Read or set `safe` or `permissive` function patching. |
|
|
239
|
+
| `class_patch_mode(mode=None)` | Read or set `safe` or `permissive` class patching. |
|
|
240
|
+
| `unmap(name)` | Delete a binding and report remaining direct holders and qualified module aliases. |
|
|
241
|
+
| `patch_log()` | Show applied, refused, reverted, and persisted operations. |
|
|
242
|
+
| `revert(target)` / `revert_all()` | Restore one or all live definition snapshots; `target` may be the live function/class object or a qualified name. |
|
|
243
|
+
| `diverged()` / `source_patch()` | Show unified diffs between live definitions and source files. |
|
|
244
|
+
| `persist_source(target=None)` | Write exact evaluated definitions to their project source files. |
|
|
245
|
+
| `source_sync_status(module=None)` | Show source freshness, conflicts, live definitions, and generation. |
|
|
246
|
+
| `help_dynra()` | Show runtime help. |
|
|
247
|
+
|
|
248
|
+
## Terminal client
|
|
249
|
+
|
|
250
|
+
The interactive runtime accepts normal IPython input. `dynra-client` sends a one-off evaluation to an existing runtime:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
dynra-client --module package.module "expression"
|
|
254
|
+
dynra-client --module scratch --create "value = 1"
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Security
|
|
258
|
+
|
|
259
|
+
Dynra executes arbitrary Python by design. Use it only for trusted local development. Do not expose its TCP port to untrusted networks, and do not grant untrusted agents access to the MCP server.
|
|
260
|
+
|
|
261
|
+
## Development
|
|
262
|
+
|
|
263
|
+
Develop Dynra in its own environment:
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
git clone https://github.com/antlobach/Dynra.git
|
|
267
|
+
cd Dynra
|
|
268
|
+
uv sync --frozen --group dev
|
|
269
|
+
uv run pytest -q
|
|
270
|
+
uv build
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
To exercise an unreleased checkout from another project, install it there as an
|
|
274
|
+
editable development dependency:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
cd /path/to/target-project
|
|
278
|
+
uv add --dev --editable /path/to/Dynra
|
|
279
|
+
uv run dynra
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
Before committing that project's dependency files, replace the local path with
|
|
283
|
+
the published package:
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
uv remove --dev dynra
|
|
287
|
+
uv add --dev dynra
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
CI runs the test suite on Python 3.10 through 3.14 and builds the package.
|
|
291
|
+
|
|
292
|
+
## License
|
|
293
|
+
|
|
294
|
+
Dynra is licensed under the [Apache License 2.0](LICENSE).
|