repl-toolkit 2.0.2__tar.gz → 2.0.3__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.
Files changed (33) hide show
  1. {repl_toolkit-2.0.2/repl_toolkit.egg-info → repl_toolkit-2.0.3}/PKG-INFO +9 -6
  2. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/README.md +8 -5
  3. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/pyproject.toml +1 -1
  4. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/__init__.py +9 -2
  5. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/async_repl.py +15 -0
  6. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/formatting.py +1 -0
  7. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/headless_repl.py +6 -0
  8. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3/repl_toolkit.egg-info}/PKG-INFO +9 -6
  9. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/LICENSE +0 -0
  10. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/actions/__init__.py +0 -0
  11. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/actions/action.py +0 -0
  12. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/actions/registry.py +0 -0
  13. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/completion/__init__.py +0 -0
  14. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/completion/prefix.py +0 -0
  15. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/completion/shell_expansion.py +0 -0
  16. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/images.py +0 -0
  17. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/ptypes.py +0 -0
  18. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/tests/__init__.py +0 -0
  19. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/tests/conftest.py +0 -0
  20. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/tests/test_actions.py +0 -0
  21. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/tests/test_async_repl.py +0 -0
  22. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/tests/test_completion.py +0 -0
  23. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/tests/test_ctrl_c_cancel.py +0 -0
  24. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/tests/test_formatting.py +0 -0
  25. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/tests/test_headless.py +0 -0
  26. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/tests/test_image_utils.py +0 -0
  27. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/tests/test_images.py +0 -0
  28. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit/tests/test_types.py +0 -0
  29. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit.egg-info/SOURCES.txt +0 -0
  30. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit.egg-info/dependency_links.txt +0 -0
  31. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit.egg-info/requires.txt +0 -0
  32. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/repl_toolkit.egg-info/top_level.txt +0 -0
  33. {repl_toolkit-2.0.2 → repl_toolkit-2.0.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: repl-toolkit
3
- Version: 2.0.2
3
+ Version: 2.0.3
4
4
  Summary: A Python toolkit for building interactive REPL and headless interfaces with action support
5
5
  Author-email: REPL Toolkit Contributors <martin.j.bartlett@gmail.com>
6
6
  License: MIT
@@ -45,13 +45,16 @@ Dynamic: license-file
45
45
 
46
46
  # REPL Toolkit
47
47
 
48
- [![Tests](https://github.com/bassmanitram/repl-toolkit/workflows/Test/badge.svg?branch=main)](https://github.com/bassmanitram/repl-toolkit/actions/workflows/test.yml)
49
- [![Lint](https://github.com/bassmanitram/repl-toolkit/workflows/Lint/badge.svg?branch=main)](https://github.com/bassmanitram/repl-toolkit/actions/workflows/lint.yml)
50
- [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
51
- [![PyPI version](https://badge.fury.io/py/repl-toolkit.svg)](https://badge.fury.io/py/repl-toolkit)
52
-
53
48
  Build interactive command-line applications with async Python. Create REPLs (Read-Eval-Print Loops) that feel like modern chat interfaces, complete with keyboard shortcuts, command history, and clipboard support.
54
49
 
50
+ [![Tests](https://github.com/bassmanitram/repl-toolkit/actions/workflows/test.yml/badge.svg)](https://github.com/bassmanitram/repl-toolkit/actions/workflows/test.yml)
51
+ [![Lint](https://github.com/bassmanitram/repl-toolkit/actions/workflows/lint.yml/badge.svg)](https://github.com/bassmanitram/repl-toolkit/actions/workflows/lint.yml)
52
+ [![Code Quality](https://github.com/bassmanitram/repl-toolkit/actions/workflows/quality.yml/badge.svg)](https://github.com/bassmanitram/repl-toolkit/actions/workflows/quality.yml)
53
+ [![Examples](https://github.com/bassmanitram/repl-toolkit/actions/workflows/examples.yml/badge.svg)](https://github.com/bassmanitram/repl-toolkit/actions/workflows/examples.yml)
54
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
55
+ [![PyPI version](https://img.shields.io/pypi/v/repl-toolkit.svg)](https://pypi.org/project/repl-toolkit/)
56
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
57
+
55
58
  ## What is this for?
56
59
 
57
60
  Build interactive terminal apps where users type messages and get responses - like chat bots, database queries, or system monitoring tools. REPL Toolkit handles the terminal UI, keyboard shortcuts, and command routing so you focus on your application's logic.
@@ -1,12 +1,15 @@
1
1
  # REPL Toolkit
2
2
 
3
- [![Tests](https://github.com/bassmanitram/repl-toolkit/workflows/Test/badge.svg?branch=main)](https://github.com/bassmanitram/repl-toolkit/actions/workflows/test.yml)
4
- [![Lint](https://github.com/bassmanitram/repl-toolkit/workflows/Lint/badge.svg?branch=main)](https://github.com/bassmanitram/repl-toolkit/actions/workflows/lint.yml)
5
- [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
6
- [![PyPI version](https://badge.fury.io/py/repl-toolkit.svg)](https://badge.fury.io/py/repl-toolkit)
7
-
8
3
  Build interactive command-line applications with async Python. Create REPLs (Read-Eval-Print Loops) that feel like modern chat interfaces, complete with keyboard shortcuts, command history, and clipboard support.
9
4
 
5
+ [![Tests](https://github.com/bassmanitram/repl-toolkit/actions/workflows/test.yml/badge.svg)](https://github.com/bassmanitram/repl-toolkit/actions/workflows/test.yml)
6
+ [![Lint](https://github.com/bassmanitram/repl-toolkit/actions/workflows/lint.yml/badge.svg)](https://github.com/bassmanitram/repl-toolkit/actions/workflows/lint.yml)
7
+ [![Code Quality](https://github.com/bassmanitram/repl-toolkit/actions/workflows/quality.yml/badge.svg)](https://github.com/bassmanitram/repl-toolkit/actions/workflows/quality.yml)
8
+ [![Examples](https://github.com/bassmanitram/repl-toolkit/actions/workflows/examples.yml/badge.svg)](https://github.com/bassmanitram/repl-toolkit/actions/workflows/examples.yml)
9
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
10
+ [![PyPI version](https://img.shields.io/pypi/v/repl-toolkit.svg)](https://pypi.org/project/repl-toolkit/)
11
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
12
+
10
13
  ## What is this for?
11
14
 
12
15
  Build interactive terminal apps where users type messages and get responses - like chat bots, database queries, or system monitoring tools. REPL Toolkit handles the terminal UI, keyboard shortcuts, and command routing so you focus on your application's logic.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "repl-toolkit"
7
- version = "2.0.2"
7
+ version = "2.0.3"
8
8
  description = "A Python toolkit for building interactive REPL and headless interfaces with action support"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -34,12 +34,18 @@ import logging
34
34
  # Applications using this library should configure their own handlers
35
35
  logging.getLogger(__name__).addHandler(logging.NullHandler())
36
36
 
37
- __version__ = "2.0.2"
37
+ __version__ = "2.0.3"
38
38
 
39
39
  from .actions import Action, ActionContext, ActionRegistry
40
40
  from .async_repl import AsyncREPL, run_async_repl
41
41
  from .completion import PrefixCompleter, ShellExpansionCompleter
42
- from .formatting import auto_format, create_auto_printer, detect_format_type, print_auto_formatted
42
+ from .formatting import (
43
+ auto_format,
44
+ create_auto_printer,
45
+ detect_format_type,
46
+ print_auto_formatted,
47
+ print_formatted_text,
48
+ )
43
49
  from .headless_repl import HeadlessREPL, run_headless_mode
44
50
  from .images import (
45
51
  ImageData,
@@ -69,6 +75,7 @@ __all__ = [
69
75
  "create_auto_printer",
70
76
  "detect_format_type",
71
77
  "print_auto_formatted",
78
+ "print_formatted_text",
72
79
  # Images
73
80
  "ImageData",
74
81
  "ParsedContent",
@@ -158,6 +158,8 @@ class AsyncREPL:
158
158
  Built-in Key Bindings:
159
159
  - Enter: Add new line
160
160
  - Alt+Enter: Send message
161
+ - F7: Clear buffer
162
+ - Escape, Escape: Clear buffer
161
163
  - Ctrl+C: Cancel operation (during processing)
162
164
  - Alt+C: Cancel operation (during processing)
163
165
 
@@ -188,6 +190,14 @@ class AsyncREPL:
188
190
  event.app.current_buffer.validate_and_handle()
189
191
 
190
192
  # Register dynamic key bindings from action registry
193
+
194
+ # Buffer clear binding
195
+ @bindings.add(Keys.F7)
196
+ @bindings.add(Keys.Escape, Keys.Escape)
197
+ def _(event):
198
+ """Clear buffer with F7 or Escape Escape."""
199
+ event.app.current_buffer.reset()
200
+
191
201
  self._register_action_shortcuts(bindings)
192
202
 
193
203
  logger.debug("AsyncREPL._create_key_bindings() exit")
@@ -333,6 +343,11 @@ class AsyncREPL:
333
343
  if user_input.strip().startswith("/"):
334
344
  # Handle commands synchronously
335
345
  self.action_registry.handle_command(user_input.strip())
346
+ # Yield to event loop to ensure any pending async work completes
347
+ # before accepting the next user input. This prevents race conditions
348
+ # where commands like /undo modify agent state and the next message
349
+ # is processed before the modifications are fully visible.
350
+ await asyncio.sleep(0)
336
351
  continue
337
352
 
338
353
  logger.debug(f"Processing user input: {user_input}")
@@ -149,4 +149,5 @@ __all__ = [
149
149
  "auto_format",
150
150
  "print_auto_formatted",
151
151
  "create_auto_printer",
152
+ "print_formatted_text",
152
153
  ]
@@ -1,3 +1,4 @@
1
+ import asyncio
1
2
  import logging
2
3
  import sys
3
4
  from typing import Optional
@@ -112,6 +113,11 @@ class HeadlessREPL:
112
113
  else:
113
114
  # Synchronous command processing
114
115
  self._execute_command(line)
116
+ # Yield to event loop to ensure any pending async work completes
117
+ # before processing the next line. This prevents race conditions
118
+ # where commands modify backend state and the next line
119
+ # is processed before the modifications are fully visible.
120
+ await asyncio.sleep(0)
115
121
  else:
116
122
  # Synchronous buffer addition
117
123
  self._add_to_buffer(line)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: repl-toolkit
3
- Version: 2.0.2
3
+ Version: 2.0.3
4
4
  Summary: A Python toolkit for building interactive REPL and headless interfaces with action support
5
5
  Author-email: REPL Toolkit Contributors <martin.j.bartlett@gmail.com>
6
6
  License: MIT
@@ -45,13 +45,16 @@ Dynamic: license-file
45
45
 
46
46
  # REPL Toolkit
47
47
 
48
- [![Tests](https://github.com/bassmanitram/repl-toolkit/workflows/Test/badge.svg?branch=main)](https://github.com/bassmanitram/repl-toolkit/actions/workflows/test.yml)
49
- [![Lint](https://github.com/bassmanitram/repl-toolkit/workflows/Lint/badge.svg?branch=main)](https://github.com/bassmanitram/repl-toolkit/actions/workflows/lint.yml)
50
- [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
51
- [![PyPI version](https://badge.fury.io/py/repl-toolkit.svg)](https://badge.fury.io/py/repl-toolkit)
52
-
53
48
  Build interactive command-line applications with async Python. Create REPLs (Read-Eval-Print Loops) that feel like modern chat interfaces, complete with keyboard shortcuts, command history, and clipboard support.
54
49
 
50
+ [![Tests](https://github.com/bassmanitram/repl-toolkit/actions/workflows/test.yml/badge.svg)](https://github.com/bassmanitram/repl-toolkit/actions/workflows/test.yml)
51
+ [![Lint](https://github.com/bassmanitram/repl-toolkit/actions/workflows/lint.yml/badge.svg)](https://github.com/bassmanitram/repl-toolkit/actions/workflows/lint.yml)
52
+ [![Code Quality](https://github.com/bassmanitram/repl-toolkit/actions/workflows/quality.yml/badge.svg)](https://github.com/bassmanitram/repl-toolkit/actions/workflows/quality.yml)
53
+ [![Examples](https://github.com/bassmanitram/repl-toolkit/actions/workflows/examples.yml/badge.svg)](https://github.com/bassmanitram/repl-toolkit/actions/workflows/examples.yml)
54
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
55
+ [![PyPI version](https://img.shields.io/pypi/v/repl-toolkit.svg)](https://pypi.org/project/repl-toolkit/)
56
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
57
+
55
58
  ## What is this for?
56
59
 
57
60
  Build interactive terminal apps where users type messages and get responses - like chat bots, database queries, or system monitoring tools. REPL Toolkit handles the terminal UI, keyboard shortcuts, and command routing so you focus on your application's logic.
File without changes
File without changes