dialoghelper 0.0.34__tar.gz → 0.0.35__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.
Potentially problematic release.
This version of dialoghelper might be problematic. Click here for more details.
- {dialoghelper-0.0.34/dialoghelper.egg-info → dialoghelper-0.0.35}/PKG-INFO +1 -1
- dialoghelper-0.0.35/dialoghelper/__init__.py +2 -0
- {dialoghelper-0.0.34 → dialoghelper-0.0.35}/dialoghelper/_modidx.py +4 -0
- {dialoghelper-0.0.34 → dialoghelper-0.0.35}/dialoghelper/core.py +77 -23
- {dialoghelper-0.0.34 → dialoghelper-0.0.35/dialoghelper.egg-info}/PKG-INFO +1 -1
- {dialoghelper-0.0.34 → dialoghelper-0.0.35}/settings.ini +1 -1
- dialoghelper-0.0.34/dialoghelper/__init__.py +0 -2
- {dialoghelper-0.0.34 → dialoghelper-0.0.35}/LICENSE +0 -0
- {dialoghelper-0.0.34 → dialoghelper-0.0.35}/MANIFEST.in +0 -0
- {dialoghelper-0.0.34 → dialoghelper-0.0.35}/README.md +0 -0
- {dialoghelper-0.0.34 → dialoghelper-0.0.35}/dialoghelper/db_dc.py +0 -0
- {dialoghelper-0.0.34 → dialoghelper-0.0.35}/dialoghelper/experimental.py +0 -0
- {dialoghelper-0.0.34 → dialoghelper-0.0.35}/dialoghelper/screenshot.js +0 -0
- {dialoghelper-0.0.34 → dialoghelper-0.0.35}/dialoghelper.egg-info/SOURCES.txt +0 -0
- {dialoghelper-0.0.34 → dialoghelper-0.0.35}/dialoghelper.egg-info/dependency_links.txt +0 -0
- {dialoghelper-0.0.34 → dialoghelper-0.0.35}/dialoghelper.egg-info/entry_points.txt +0 -0
- {dialoghelper-0.0.34 → dialoghelper-0.0.35}/dialoghelper.egg-info/not-zip-safe +0 -0
- {dialoghelper-0.0.34 → dialoghelper-0.0.35}/dialoghelper.egg-info/requires.txt +0 -0
- {dialoghelper-0.0.34 → dialoghelper-0.0.35}/dialoghelper.egg-info/top_level.txt +0 -0
- {dialoghelper-0.0.34 → dialoghelper-0.0.35}/pyproject.toml +0 -0
- {dialoghelper-0.0.34 → dialoghelper-0.0.35}/setup.cfg +0 -0
- {dialoghelper-0.0.34 → dialoghelper-0.0.35}/setup.py +0 -0
|
@@ -26,6 +26,10 @@ d = { 'settings': { 'branch': 'main',
|
|
|
26
26
|
'dialoghelper.core.load_gist': ('core.html#load_gist', 'dialoghelper/core.py'),
|
|
27
27
|
'dialoghelper.core.mk_toollist': ('core.html#mk_toollist', 'dialoghelper/core.py'),
|
|
28
28
|
'dialoghelper.core.msg_idx': ('core.html#msg_idx', 'dialoghelper/core.py'),
|
|
29
|
+
'dialoghelper.core.msg_insert_line': ('core.html#msg_insert_line', 'dialoghelper/core.py'),
|
|
30
|
+
'dialoghelper.core.msg_replace_lines': ('core.html#msg_replace_lines', 'dialoghelper/core.py'),
|
|
31
|
+
'dialoghelper.core.msg_str_replace': ('core.html#msg_str_replace', 'dialoghelper/core.py'),
|
|
32
|
+
'dialoghelper.core.msg_strs_replace': ('core.html#msg_strs_replace', 'dialoghelper/core.py'),
|
|
29
33
|
'dialoghelper.core.read_msg': ('core.html#read_msg', 'dialoghelper/core.py'),
|
|
30
34
|
'dialoghelper.core.run_msg': ('core.html#run_msg', 'dialoghelper/core.py'),
|
|
31
35
|
'dialoghelper.core.tool_info': ('core.html#tool_info', 'dialoghelper/core.py'),
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# %% auto 0
|
|
4
4
|
__all__ = ['Placements', 'empty', 'find_var', 'call_endp', 'find_dname', 'find_msg_id', 'curr_dialog', 'find_msgs', 'msg_idx',
|
|
5
|
-
'
|
|
6
|
-
'
|
|
7
|
-
'fc_tool_info', 'asdict']
|
|
5
|
+
'add_html', 'add_msg', 'del_msg', 'update_msg', 'url2note', 'ast_py', 'ast_grep', 'read_msg', 'run_msg',
|
|
6
|
+
'msg_insert_line', 'msg_str_replace', 'msg_strs_replace', 'msg_replace_lines', 'load_gist', 'gist_file',
|
|
7
|
+
'import_string', 'is_usable_tool', 'mk_toollist', 'import_gist', 'tool_info', 'fc_tool_info', 'asdict']
|
|
8
8
|
|
|
9
9
|
# %% ../nbs/00_core.ipynb
|
|
10
10
|
import json, importlib, linecache
|
|
@@ -88,17 +88,6 @@ def msg_idx(
|
|
|
88
88
|
if not msgid: msgid = find_msg_id()
|
|
89
89
|
return call_endp('msg_idx_', dname, json=True, msgid=msgid)['msgid']
|
|
90
90
|
|
|
91
|
-
# %% ../nbs/00_core.ipynb
|
|
92
|
-
def read_msg(
|
|
93
|
-
n:int=-1, # Message index (if relative, +ve is downwards)
|
|
94
|
-
msgid=None, # Message id to find (defaults to current message)
|
|
95
|
-
relative:bool=True, # Is `n` relative to current message (True) or absolute (False)?
|
|
96
|
-
dname:str='' # Running dialog to get info for; defaults to current dialog
|
|
97
|
-
):
|
|
98
|
-
"Get the `Message` object indexed in the current dialog."
|
|
99
|
-
if not msgid: msgid = find_msg_id()
|
|
100
|
-
return call_endp('read_msg_', dname, json=True, msgid=msgid, n=n, relative=relative)['msg']
|
|
101
|
-
|
|
102
91
|
# %% ../nbs/00_core.ipynb
|
|
103
92
|
def add_html(
|
|
104
93
|
content:str, # The HTML to send to the client (generally should include hx-swap-oob)
|
|
@@ -107,14 +96,6 @@ def add_html(
|
|
|
107
96
|
"Send HTML to the browser to be swapped into the DOM"
|
|
108
97
|
call_endp('add_html_', dname, content=to_xml(content))
|
|
109
98
|
|
|
110
|
-
# %% ../nbs/00_core.ipynb
|
|
111
|
-
def run_msg(
|
|
112
|
-
msgid:str=None, # id of message to execute
|
|
113
|
-
dname:str='' # Running dialog to get info for; defaults to current dialog
|
|
114
|
-
):
|
|
115
|
-
"Adds a message to the run queue. Use read_msg to see the output once it runs."
|
|
116
|
-
return call_endp('add_runq_', dname, msgid=msgid, api=True)
|
|
117
|
-
|
|
118
99
|
# %% ../nbs/00_core.ipynb
|
|
119
100
|
Placements = str_enum('Placements', 'add_after', 'add_before', 'at_start', 'at_end')
|
|
120
101
|
|
|
@@ -221,6 +202,71 @@ def ast_grep(
|
|
|
221
202
|
res = subprocess.run(cmd, shell=True, capture_output=True, text=True)
|
|
222
203
|
return json.loads(res.stdout) if res.stdout else res.stderr
|
|
223
204
|
|
|
205
|
+
# %% ../nbs/00_core.ipynb
|
|
206
|
+
def read_msg(
|
|
207
|
+
n:int=-1, # Message index (if relative, +ve is downwards)
|
|
208
|
+
relative:bool=True, # Is `n` relative to current message (True) or absolute (False)?
|
|
209
|
+
msgid:str=None, # Message id to find (defaults to current message)
|
|
210
|
+
view_range:list[int,int]=None, # Optional 1-indexed (start, end) line range for files, end=-1 for EOF
|
|
211
|
+
nums:bool=False, # Whether to show line numbers
|
|
212
|
+
dname:str='' # Running dialog to get info for; defaults to current dialog
|
|
213
|
+
):
|
|
214
|
+
"Get the `Message` object indexed in the current dialog."
|
|
215
|
+
if not msgid: msgid = find_msg_id()
|
|
216
|
+
data = dict(n=n, relative=relative, msgid=msgid)
|
|
217
|
+
if view_range: data['view_range'] = view_range # None gets converted to '' so we avoid passing it to use the p.default
|
|
218
|
+
if nums: data['nums'] = nums
|
|
219
|
+
return call_endp('read_msg_', dname, json=True, **data)
|
|
220
|
+
|
|
221
|
+
# %% ../nbs/00_core.ipynb
|
|
222
|
+
def run_msg(
|
|
223
|
+
msgid:str=None, # id of message to execute
|
|
224
|
+
dname:str='' # Running dialog to get info for; defaults to current dialog
|
|
225
|
+
):
|
|
226
|
+
"Adds a message to the run queue. Use read_msg to see the output once it runs."
|
|
227
|
+
return call_endp('add_runq_', dname, msgid=msgid, api=True)
|
|
228
|
+
|
|
229
|
+
# %% ../nbs/00_core.ipynb
|
|
230
|
+
def msg_insert_line(
|
|
231
|
+
msgid:str, # Message id to edit
|
|
232
|
+
insert_line: int, # The line number after which to insert the text (0 for beginning of file)
|
|
233
|
+
new_str: str, # The text to insert
|
|
234
|
+
dname:str='' # Running dialog to get info for; defaults to current dialog
|
|
235
|
+
):
|
|
236
|
+
"Insert text at a specific line number in a message"
|
|
237
|
+
return call_endp('msg_insert_line_', dname, json=True, msgid=msgid, insert_line=insert_line, new_str=new_str)
|
|
238
|
+
|
|
239
|
+
# %% ../nbs/00_core.ipynb
|
|
240
|
+
def msg_str_replace(
|
|
241
|
+
msgid:str, # Message id to edit
|
|
242
|
+
old_str: str, # Text to find and replace
|
|
243
|
+
new_str: str, # Text to replace with
|
|
244
|
+
dname:str='' # Running dialog to get info for; defaults to current dialog
|
|
245
|
+
):
|
|
246
|
+
"Replace first occurrence of old_str with new_str in a message"
|
|
247
|
+
return call_endp('msg_str_replace_', dname, json=True, msgid=msgid, old_str=old_str, new_str=new_str)
|
|
248
|
+
|
|
249
|
+
# %% ../nbs/00_core.ipynb
|
|
250
|
+
def msg_strs_replace(
|
|
251
|
+
msgid:str, # Message id to edit
|
|
252
|
+
old_strs:list[str], # List of strings to find and replace
|
|
253
|
+
new_strs:list[str], # List of replacement strings (must match length of old_strs)
|
|
254
|
+
dname:str='' # Running dialog to get info for; defaults to current dialog
|
|
255
|
+
):
|
|
256
|
+
"Replace multiple strings simultaneously in a message"
|
|
257
|
+
return call_endp('msg_strs_replace_', dname, json=True, msgid=msgid, old_strs=old_strs, new_strs=new_strs)
|
|
258
|
+
|
|
259
|
+
# %% ../nbs/00_core.ipynb
|
|
260
|
+
def msg_replace_lines(
|
|
261
|
+
msgid:str, # Message id to edit
|
|
262
|
+
start_line:int, # Starting line number to replace (1-based indexing)
|
|
263
|
+
end_line:int, # Ending line number to replace (1-based indexing, inclusive)
|
|
264
|
+
new_content:str, # New content to replace the specified lines
|
|
265
|
+
dname:str='' # Running dialog to get info for; defaults to current dialog
|
|
266
|
+
):
|
|
267
|
+
"Replace a range of lines with new content in a message"
|
|
268
|
+
return call_endp('msg_replace_lines_', dname, json=True, msgid=msgid, start_line=start_line, end_line=end_line, new_content=new_content)
|
|
269
|
+
|
|
224
270
|
# %% ../nbs/00_core.ipynb
|
|
225
271
|
def load_gist(gist_id:str):
|
|
226
272
|
"Retrieve a gist"
|
|
@@ -298,10 +344,18 @@ def tool_info():
|
|
|
298
344
|
- &`find_msgs`: Find messages in current specific dialog that contain the given information.
|
|
299
345
|
- (solveit can often get this id directly from its context, and will not need to use this if the required information is already available to it.)
|
|
300
346
|
- &`read_msg`: Get the message indexed in the current dialog.
|
|
347
|
+
- To get the exact message use `n=0` and `relative=True` together with `msgid`.
|
|
348
|
+
- To get a relative message use `n` (relative position index).
|
|
349
|
+
- To get the nth message use `n` with `relative=False`, e.g `n=0` first message, `n=-1` last message.
|
|
301
350
|
- &`del_msg`: Delete a message from the dialog.
|
|
302
351
|
- &`add_msg`: Add/update a message to the queue to show after code execution completes.
|
|
303
352
|
- &`update_msg`: Update an existing message.
|
|
304
|
-
- &`url2note`: Read URL as markdown, and add a note below current message with the result
|
|
353
|
+
- &`url2note`: Read URL as markdown, and add a note below current message with the result
|
|
354
|
+
- &`msg_insert_line`: Insert text at a specific location in a message.
|
|
355
|
+
- &`msg_str_replace`: Find and replace text in a message.
|
|
356
|
+
- &`msg_strs_replace`: Find and replace multiple strings in a message.
|
|
357
|
+
- &`msg_replace_lines`: Replace a range of lines in a message with new content.
|
|
358
|
+
- Always first use `read_msg( msgid=msgid, n=0, relative=True, nums=True)` to view the content with line numbers.'''
|
|
305
359
|
add_msg(cts)
|
|
306
360
|
|
|
307
361
|
# %% ../nbs/00_core.ipynb
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|