abstractcode 0.1.0__py3-none-any.whl → 0.2.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.
- abstractcode/__init__.py +6 -37
- abstractcode/cli.py +110 -0
- abstractcode/fullscreen_ui.py +656 -0
- abstractcode/input_handler.py +81 -0
- abstractcode/react_shell.py +1204 -0
- {abstractcode-0.1.0.dist-info → abstractcode-0.2.0.dist-info}/METADATA +51 -5
- abstractcode-0.2.0.dist-info/RECORD +11 -0
- abstractcode-0.1.0.dist-info/RECORD +0 -7
- {abstractcode-0.1.0.dist-info → abstractcode-0.2.0.dist-info}/WHEEL +0 -0
- {abstractcode-0.1.0.dist-info → abstractcode-0.2.0.dist-info}/entry_points.txt +0 -0
- {abstractcode-0.1.0.dist-info → abstractcode-0.2.0.dist-info}/licenses/LICENSE +0 -0
- {abstractcode-0.1.0.dist-info → abstractcode-0.2.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Input handling with prompt_toolkit for multi-line input and status footer."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Callable, Optional
|
|
6
|
+
|
|
7
|
+
from prompt_toolkit import PromptSession
|
|
8
|
+
from prompt_toolkit.formatted_text import HTML
|
|
9
|
+
from prompt_toolkit.key_binding import KeyBindings
|
|
10
|
+
from prompt_toolkit.styles import Style
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def create_prompt_session(
|
|
14
|
+
get_toolbar_text: Callable[[], str],
|
|
15
|
+
multiline: bool = True,
|
|
16
|
+
color: bool = True,
|
|
17
|
+
) -> PromptSession:
|
|
18
|
+
"""Create a configured prompt session with multi-line input and status footer.
|
|
19
|
+
|
|
20
|
+
Key bindings:
|
|
21
|
+
- Enter: Submit input
|
|
22
|
+
- Alt+Enter or Escape,Enter: Insert newline
|
|
23
|
+
- Ctrl+J: Insert newline (Unix tradition)
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
get_toolbar_text: Callable that returns the toolbar text (called on each render)
|
|
27
|
+
multiline: Enable multi-line input mode
|
|
28
|
+
color: Enable colored output
|
|
29
|
+
|
|
30
|
+
Returns:
|
|
31
|
+
Configured PromptSession instance
|
|
32
|
+
"""
|
|
33
|
+
kb = KeyBindings()
|
|
34
|
+
|
|
35
|
+
# Enter = submit (override default multiline behavior where Enter adds newline)
|
|
36
|
+
@kb.add("enter")
|
|
37
|
+
def handle_enter(event):
|
|
38
|
+
event.current_buffer.validate_and_handle()
|
|
39
|
+
|
|
40
|
+
# Alt+Enter = insert newline
|
|
41
|
+
@kb.add("escape", "enter")
|
|
42
|
+
def handle_alt_enter(event):
|
|
43
|
+
event.current_buffer.insert_text("\n")
|
|
44
|
+
|
|
45
|
+
# Ctrl+J = insert newline (Unix tradition, works in all terminals)
|
|
46
|
+
@kb.add("c-j")
|
|
47
|
+
def handle_ctrl_j(event):
|
|
48
|
+
event.current_buffer.insert_text("\n")
|
|
49
|
+
|
|
50
|
+
# Style for the bottom toolbar
|
|
51
|
+
style = Style.from_dict(
|
|
52
|
+
{
|
|
53
|
+
"bottom-toolbar": "bg:#1a1a2e #888888",
|
|
54
|
+
"bottom-toolbar.text": "#888888",
|
|
55
|
+
}
|
|
56
|
+
) if color else None
|
|
57
|
+
|
|
58
|
+
return PromptSession(
|
|
59
|
+
multiline=multiline,
|
|
60
|
+
key_bindings=kb,
|
|
61
|
+
bottom_toolbar=get_toolbar_text,
|
|
62
|
+
style=style,
|
|
63
|
+
mouse_support=True,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def create_simple_session(color: bool = True) -> PromptSession:
|
|
68
|
+
"""Create a simple single-line prompt session for quick responses.
|
|
69
|
+
|
|
70
|
+
Used for tool approvals, choice selection, etc.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
color: Enable colored output
|
|
74
|
+
|
|
75
|
+
Returns:
|
|
76
|
+
Simple PromptSession instance
|
|
77
|
+
"""
|
|
78
|
+
return PromptSession(
|
|
79
|
+
multiline=False,
|
|
80
|
+
mouse_support=False,
|
|
81
|
+
)
|