Skip to content

Commit 481617e

Browse files
committed
Update dependencies, bump python version, and fix Windows VT support
1 parent a47527b commit 481617e

3 files changed

Lines changed: 536 additions & 638 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "basic-agent-chat-loop"
77
version = "1.9.0"
88
description = "Feature-rich interactive CLI for AWS Strands agents with token tracking, prompt templates, aliases, and configuration"
99
readme = "README.md"
10-
requires-python = ">=3.9"
10+
requires-python = ">=3.10"
1111
license-files = ["LICENSE"]
1212
authors = [
1313
{name = "Wes", email = "unseriousai@gmail.com"}

src/basic_agent_chat_loop/chat_loop.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,45 @@ def set_terminal_title(title: str) -> None:
216216
pass
217217

218218

219+
def enable_windows_vt_mode() -> bool:
220+
"""
221+
Enable Virtual Terminal Processing on Windows.
222+
223+
This allows ANSI escape codes to work in standard cmd.exe and PowerShell
224+
without needing an external library like colorama for every print.
225+
"""
226+
if sys.platform != "win32":
227+
return True
228+
229+
try:
230+
import ctypes
231+
232+
kernel32 = ctypes.windll.kernel32
233+
234+
# Get handle to stdout
235+
# STD_OUTPUT_HANDLE = -11
236+
handle = kernel32.GetStdHandle(-11)
237+
238+
# Get current mode
239+
mode = ctypes.c_ulong()
240+
if not kernel32.GetConsoleMode(handle, ctypes.byref(mode)):
241+
return False
242+
243+
# Add ENABLE_VIRTUAL_TERMINAL_PROCESSING (0x0004)
244+
enable_virtual_terminal_processing = 0x0004
245+
if not (mode.value & enable_virtual_terminal_processing):
246+
if kernel32.SetConsoleMode(
247+
handle, mode.value | enable_virtual_terminal_processing
248+
):
249+
return True
250+
return False
251+
252+
return True
253+
except Exception:
254+
# If we can't enable it, functionality degrades gracefully
255+
return False
256+
257+
219258
def setup_readline_history() -> Optional[Path]:
220259
"""
221260
Setup readline command history with persistence.
@@ -1282,6 +1321,9 @@ def run(self):
12821321

12831322
def main():
12841323
"""Main entry point for the chat loop."""
1324+
# Ensure Windows console supports ANSI colors
1325+
enable_windows_vt_mode()
1326+
12851327
parser = argparse.ArgumentParser(
12861328
description=(
12871329
"Interactive CLI for AI Agents with token tracking and rich features"

0 commit comments

Comments
 (0)