alpiecode 10.9.0__tar.gz → 10.9.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.
Files changed (133) hide show
  1. {alpiecode-10.9.0 → alpiecode-10.9.1}/PKG-INFO +1 -1
  2. {alpiecode-10.9.0 → alpiecode-10.9.1}/pyproject.toml +1 -1
  3. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/alpiecode.egg-info/PKG-INFO +1 -1
  4. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/__init__.py +1 -1
  5. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/blueprints.py +85 -28
  6. {alpiecode-10.9.0 → alpiecode-10.9.1}/test/test_lifecycle_and_portfolio.py +100 -0
  7. {alpiecode-10.9.0 → alpiecode-10.9.1}/README.md +0 -0
  8. {alpiecode-10.9.0 → alpiecode-10.9.1}/setup.cfg +0 -0
  9. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/alpiecode/__init__.py +0 -0
  10. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/alpiecode.egg-info/SOURCES.txt +0 -0
  11. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/alpiecode.egg-info/dependency_links.txt +0 -0
  12. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/alpiecode.egg-info/entry_points.txt +0 -0
  13. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/alpiecode.egg-info/requires.txt +0 -0
  14. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/alpiecode.egg-info/top_level.txt +0 -0
  15. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/agent.py +0 -0
  16. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/assessment.py +0 -0
  17. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/backends/__init__.py +0 -0
  18. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/backends/base.py +0 -0
  19. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/backends/local_backend.py +0 -0
  20. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/backends/openai_backend.py +0 -0
  21. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/cache.py +0 -0
  22. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/cli.py +0 -0
  23. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/client.py +0 -0
  24. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/compaction.py +0 -0
  25. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/config.py +0 -0
  26. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/context.py +0 -0
  27. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/diff_preview.py +0 -0
  28. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/discovery.py +0 -0
  29. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/doctor.py +0 -0
  30. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/dream_rsi.py +0 -0
  31. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/executor.py +0 -0
  32. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/git_ops.py +0 -0
  33. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/github.py +0 -0
  34. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/guardian.py +0 -0
  35. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/guardrails.py +0 -0
  36. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/ipython_ext.py +0 -0
  37. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/local_model.py +0 -0
  38. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/media.py +0 -0
  39. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/memory.py +0 -0
  40. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/metrics.py +0 -0
  41. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/orchestrator.py +0 -0
  42. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/paths.py +0 -0
  43. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/progress.py +0 -0
  44. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/project_template.py +0 -0
  45. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/prompt.py +0 -0
  46. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/rephraser.py +0 -0
  47. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/server.py +0 -0
  48. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/session.py +0 -0
  49. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/accessibility-audit/SKILL.md +0 -0
  50. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/accessibility-testing/SKILL.md +0 -0
  51. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/accessibility-ui-components/SKILL.md +0 -0
  52. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/agentic-workflows/SKILL.md +0 -0
  53. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/api-design/SKILL.md +0 -0
  54. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/architecture-design/SKILL.md +0 -0
  55. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/backend-engineering/SKILL.md +0 -0
  56. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/browser-automation/SKILL.md +0 -0
  57. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/cli-development/SKILL.md +0 -0
  58. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/cloud-infrastructure/SKILL.md +0 -0
  59. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/code-generation/SKILL.md +0 -0
  60. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/code-review/SKILL.md +0 -0
  61. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/codebase-onboarding/SKILL.md +0 -0
  62. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/cost-optimization/SKILL.md +0 -0
  63. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/data-analysis/SKILL.md +0 -0
  64. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/data-engineering/SKILL.md +0 -0
  65. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/database-engineering/SKILL.md +0 -0
  66. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/dependency-management/SKILL.md +0 -0
  67. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/dependency-security/SKILL.md +0 -0
  68. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/dependency-upgrades/SKILL.md +0 -0
  69. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/devops-ci-cd/SKILL.md +0 -0
  70. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/docker-containers/SKILL.md +0 -0
  71. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/documentation/SKILL.md +0 -0
  72. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/documentation-site/SKILL.md +0 -0
  73. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/e2e-testing/SKILL.md +0 -0
  74. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/error-handling-resilience/SKILL.md +0 -0
  75. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/feature-development/SKILL.md +0 -0
  76. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/frontend-engineering/SKILL.md +0 -0
  77. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/git-workflow/SKILL.md +0 -0
  78. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/incident-response/SKILL.md +0 -0
  79. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/legacy-code-modernization/SKILL.md +0 -0
  80. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/llm-application-engineering/SKILL.md +0 -0
  81. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/localization-i18n/SKILL.md +0 -0
  82. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/mcp-server-development/SKILL.md +0 -0
  83. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/migration-engineering/SKILL.md +0 -0
  84. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/mobile-development/SKILL.md +0 -0
  85. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/model-evaluation/SKILL.md +0 -0
  86. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/nodejs-services/SKILL.md +0 -0
  87. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/observability/SKILL.md +0 -0
  88. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/performance-optimization/SKILL.md +0 -0
  89. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/privacy-data-protection/SKILL.md +0 -0
  90. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/prompt-engineering/SKILL.md +0 -0
  91. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/python-engineering/SKILL.md +0 -0
  92. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/rag-retrieval/SKILL.md +0 -0
  93. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/react-engineering/SKILL.md +0 -0
  94. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/release-management/SKILL.md +0 -0
  95. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/requirements-analysis/SKILL.md +0 -0
  96. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/responsive-design/SKILL.md +0 -0
  97. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/safe-refactoring/SKILL.md +0 -0
  98. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/secure-coding/SKILL.md +0 -0
  99. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/systematic-debugging/SKILL.md +0 -0
  100. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/technical-planning/SKILL.md +0 -0
  101. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/technical-research/SKILL.md +0 -0
  102. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/technical-writing/SKILL.md +0 -0
  103. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/test-engineering/SKILL.md +0 -0
  104. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/tool-integration/SKILL.md +0 -0
  105. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/typescript-engineering/SKILL.md +0 -0
  106. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/visual-regression-testing/SKILL.md +0 -0
  107. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/web-performance/SKILL.md +0 -0
  108. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/web-security-testing/SKILL.md +0 -0
  109. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills/workflow-automation/SKILL.md +0 -0
  110. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/skills.py +0 -0
  111. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/slash.py +0 -0
  112. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/subagent.py +0 -0
  113. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/system1.py +0 -0
  114. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/tools.py +0 -0
  115. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/updater.py +0 -0
  116. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/verifier.py +0 -0
  117. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/vscode_installer.py +0 -0
  118. {alpiecode-10.9.0 → alpiecode-10.9.1}/src/codeagent/walkthrough.py +0 -0
  119. {alpiecode-10.9.0 → alpiecode-10.9.1}/test/test_adaptive_resilience.py +0 -0
  120. {alpiecode-10.9.0 → alpiecode-10.9.1}/test/test_cli_ui.py +0 -0
  121. {alpiecode-10.9.0 → alpiecode-10.9.1}/test/test_context_and_trajectory.py +0 -0
  122. {alpiecode-10.9.0 → alpiecode-10.9.1}/test/test_deloop_and_sessions.py +0 -0
  123. {alpiecode-10.9.0 → alpiecode-10.9.1}/test/test_dream_rsi.py +0 -0
  124. {alpiecode-10.9.0 → alpiecode-10.9.1}/test/test_local_model_download.py +0 -0
  125. {alpiecode-10.9.0 → alpiecode-10.9.1}/test/test_non_thinking_and_local_stream.py +0 -0
  126. {alpiecode-10.9.0 → alpiecode-10.9.1}/test/test_project_templates.py +0 -0
  127. {alpiecode-10.9.0 → alpiecode-10.9.1}/test/test_skills_engine.py +0 -0
  128. {alpiecode-10.9.0 → alpiecode-10.9.1}/test/test_slash_and_diff.py +0 -0
  129. {alpiecode-10.9.0 → alpiecode-10.9.1}/test/test_subagents.py +0 -0
  130. {alpiecode-10.9.0 → alpiecode-10.9.1}/test/test_task_assessment.py +0 -0
  131. {alpiecode-10.9.0 → alpiecode-10.9.1}/test/test_verifier.py +0 -0
  132. {alpiecode-10.9.0 → alpiecode-10.9.1}/test/test_walkthrough.py +0 -0
  133. {alpiecode-10.9.0 → alpiecode-10.9.1}/test/test_web_resilience_and_guardrails.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alpiecode
3
- Version: 10.9.0
3
+ Version: 10.9.1
4
4
  Summary: AlpieCode
5
5
  Requires-Python: >=3.9
6
6
  Requires-Dist: huggingface_hub>=0.20.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "alpiecode"
7
- version = "10.9.0"
7
+ version = "10.9.1"
8
8
  description = "AlpieCode"
9
9
  requires-python = ">=3.9"
10
10
  dependencies = [
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alpiecode
3
- Version: 10.9.0
3
+ Version: 10.9.1
4
4
  Summary: AlpieCode
5
5
  Requires-Python: >=3.9
6
6
  Requires-Dist: huggingface_hub>=0.20.0
@@ -17,7 +17,7 @@ Supports:
17
17
  from pathlib import Path
18
18
  from typing import Optional, Any, Dict
19
19
 
20
- __version__ = "10.9.0"
20
+ __version__ = "10.9.1"
21
21
 
22
22
  def run(task: str, workdir: str = ".", reasoning_level: str = "thinking", **kwargs):
23
23
  """Run an autonomous coding task programmatically."""
@@ -537,7 +537,7 @@ def is_ambiguous_web_task(task: str) -> bool:
537
537
 
538
538
 
539
539
  def _read_terminal_key() -> str:
540
- """Read a single keypress or escape sequence from terminal in raw mode."""
540
+ """Read a single keypress or escape sequence from terminal directly without TextIOWrapper buffering."""
541
541
  import sys
542
542
  if sys.platform == "win32":
543
543
  try:
@@ -545,43 +545,93 @@ def _read_terminal_key() -> str:
545
545
  ch = msvcrt.getch()
546
546
  if ch in (b"\x00", b"\xe0"):
547
547
  ch2 = msvcrt.getch()
548
- if ch2 == b"H":
548
+ if ch2 in (b"H", b"w", b"K"):
549
549
  return "up"
550
- if ch2 == b"P":
550
+ elif ch2 in (b"P", b"s", b"M"):
551
551
  return "down"
552
552
  return ""
553
+ if ch == b"\x1b":
554
+ import time
555
+ time.sleep(0.02)
556
+ if msvcrt.kbhit():
557
+ ch2 = msvcrt.getch()
558
+ if ch2 in (b"[", b"O") and msvcrt.kbhit():
559
+ ch3 = msvcrt.getch()
560
+ if ch3 in (b"A", b"a"):
561
+ return "up"
562
+ elif ch3 in (b"B", b"b"):
563
+ return "down"
564
+ return "esc"
553
565
  if ch in (b"\r", b"\n"):
554
566
  return "enter"
567
+ if ch == b" ":
568
+ return "enter"
555
569
  if ch == b"\x03":
556
570
  raise KeyboardInterrupt
557
571
  return ch.decode("utf-8", errors="ignore")
558
572
  except Exception:
559
573
  return ""
560
574
  else:
561
- import tty, termios, select
562
- fd = sys.stdin.fileno()
563
- old_settings = termios.tcgetattr(fd)
575
+ import tty, termios, os, select
564
576
  try:
577
+ fd = sys.stdin.fileno()
578
+ except Exception:
579
+ return ""
580
+
581
+ old_settings = None
582
+ has_termios = False
583
+ try:
584
+ old_settings = termios.tcgetattr(fd)
565
585
  tty.setraw(fd)
566
- ch = sys.stdin.read(1)
567
- if ch == "\x1b":
568
- r, _, _ = select.select([sys.stdin], [], [], 0.05)
569
- if r:
570
- ch2 = sys.stdin.read(1)
571
- if ch2 in ("[", "O"):
572
- ch3 = sys.stdin.read(1)
573
- if ch3 == "A":
574
- return "up"
575
- elif ch3 == "B":
576
- return "down"
586
+ has_termios = True
587
+ except Exception:
588
+ has_termios = False
589
+
590
+ try:
591
+ # Read first byte directly from OS file descriptor bypassing TextIOWrapper buffer
592
+ b = os.read(fd, 1)
593
+ if not b:
594
+ return ""
595
+ if b == b"\x1b":
596
+ r, _, _ = select.select([fd], [], [], 0.05)
597
+ if not r:
598
+ return "esc"
599
+ b2 = os.read(fd, 1)
600
+ if b2 in (b"[", b"O"):
601
+ b3 = os.read(fd, 1)
602
+ if b3 in (b"A", b"a"):
603
+ return "up"
604
+ elif b3 in (b"B", b"b"):
605
+ return "down"
606
+ elif b3 in (b"1", b"2", b"3", b"4", b"5", b"6"):
607
+ # Handle extended sequences like \x1b[1;5A or \x1b[2~
608
+ while True:
609
+ r_extra, _, _ = select.select([fd], [], [], 0.01)
610
+ if not r_extra:
611
+ break
612
+ extra = os.read(fd, 1)
613
+ if extra in (b"A", b"a"):
614
+ return "up"
615
+ elif extra in (b"B", b"b"):
616
+ return "down"
617
+ if extra in (b"~", b"A", b"B", b"C", b"D"):
618
+ break
619
+ return ""
620
+ return ""
577
621
  return "esc"
578
- elif ch in ("\r", "\n"):
622
+ elif b in (b"\r", b"\n"):
623
+ return "enter"
624
+ elif b == b" ":
579
625
  return "enter"
580
- elif ch == "\x03":
626
+ elif b == b"\x03":
581
627
  raise KeyboardInterrupt
582
- return ch
628
+ return b.decode("utf-8", errors="ignore")
583
629
  finally:
584
- termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
630
+ if has_termios and old_settings is not None:
631
+ try:
632
+ termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
633
+ except Exception:
634
+ pass
585
635
 
586
636
 
587
637
  def _interactive_arrow_select(title: str, options: list, default_index: int = 0) -> int:
@@ -589,7 +639,7 @@ def _interactive_arrow_select(title: str, options: list, default_index: int = 0)
589
639
  Render an interactive Up/Down arrow selection menu in the terminal.
590
640
  Allows navigating with Up/Down arrows (or j/k) and confirming with Enter.
591
641
  """
592
- import sys
642
+ import sys, time
593
643
  selected = default_index
594
644
  total = len(options)
595
645
 
@@ -598,28 +648,34 @@ def _interactive_arrow_select(title: str, options: list, default_index: int = 0)
598
648
  sys.stdout.flush()
599
649
 
600
650
  first_render = True
651
+ num_rendered_lines = 0
601
652
  try:
602
653
  while True:
603
654
  lines = []
604
655
  lines.append(f"\x1b[1;33m? \x1b[1;37m{title}\x1b[0m")
605
656
  for i, (name, desc) in enumerate(options):
606
657
  if i == selected:
607
- lines.append(f" \x1b[1;36m❯ {name}\x1b[0m \x1b[2m— {desc}\x1b[0m")
658
+ lines.append(f" \x1b[1;36m❯ {name:<10}\x1b[0m \x1b[2m— {desc}\x1b[0m")
608
659
  else:
609
- lines.append(f" \x1b[37m{name}\x1b[0m \x1b[2m— {desc}\x1b[0m")
660
+ lines.append(f" \x1b[37m{name:<10}\x1b[0m \x1b[2m— {desc}\x1b[0m")
610
661
  lines.append("\x1b[2m (Use ↑/↓ arrow keys to navigate, press Enter to select)\x1b[0m")
611
662
 
612
663
  if not first_render:
613
- sys.stdout.write(f"\r\x1b[{len(lines)}A\x1b[J")
664
+ sys.stdout.write(f"\r\x1b[{num_rendered_lines}A\x1b[J")
614
665
 
615
666
  sys.stdout.write("\n".join(lines) + "\n")
616
667
  sys.stdout.flush()
617
668
  first_render = False
669
+ num_rendered_lines = len(lines)
618
670
 
619
671
  key = _read_terminal_key()
620
- if key in ("up", "k"):
672
+ if not key:
673
+ time.sleep(0.01)
674
+ continue
675
+
676
+ if key in ("up", "k", "w"):
621
677
  selected = (selected - 1) % total
622
- elif key in ("down", "j"):
678
+ elif key in ("down", "j", "s"):
623
679
  selected = (selected + 1) % total
624
680
  elif key in ("enter", " "):
625
681
  break
@@ -630,7 +686,8 @@ def _interactive_arrow_select(title: str, options: list, default_index: int = 0)
630
686
  break
631
687
 
632
688
  # Clear menu and print confirmation line
633
- sys.stdout.write(f"\r\x1b[{len(options) + 2}A\x1b[J")
689
+ if num_rendered_lines > 0:
690
+ sys.stdout.write(f"\r\x1b[{num_rendered_lines}A\x1b[J")
634
691
  chosen_name = options[selected][0]
635
692
  sys.stdout.write(f"\x1b[1;32m✔\x1b[0m \x1b[1m{title}\x1b[0m \x1b[1;36m{chosen_name}\x1b[0m\n\n")
636
693
  sys.stdout.flush()
@@ -297,3 +297,103 @@ class TestDomainBlueprintsAndTheming:
297
297
  monkeypatch.setattr("codeagent.blueprints._read_terminal_key", lambda: next(key_seq2))
298
298
  idx2 = _interactive_arrow_select("Choose framework", options, default_index=0)
299
299
  assert idx2 == 4
300
+
301
+ # Case 3: Press 'j' (vim down) then 'enter' -> Selects index 1 (React.js)
302
+ key_seq3 = iter(["j", "enter"])
303
+ monkeypatch.setattr("codeagent.blueprints._read_terminal_key", lambda: next(key_seq3))
304
+ idx3 = _interactive_arrow_select("Choose framework", options, default_index=0)
305
+ assert idx3 == 1
306
+
307
+ # Case 4: Press number key '3' -> Instantly selects index 2 (Vue.js)
308
+ key_seq4 = iter(["3"])
309
+ monkeypatch.setattr("codeagent.blueprints._read_terminal_key", lambda: next(key_seq4))
310
+ idx4 = _interactive_arrow_select("Choose framework", options, default_index=0)
311
+ assert idx4 == 2
312
+
313
+ def test_read_terminal_key_ansi_escape_parsing(self, monkeypatch):
314
+ import os
315
+ from codeagent.blueprints import _read_terminal_key
316
+
317
+ # Test ANSI sequences using real OS pipe descriptors
318
+ test_cases = [
319
+ (b"\x1b[A", "up"),
320
+ (b"\x1b[B", "down"),
321
+ (b"\x1bOA", "up"),
322
+ (b"\x1bOB", "down"),
323
+ (b"\r", "enter"),
324
+ (b"\n", "enter"),
325
+ (b" ", "enter"),
326
+ (b"k", "k"),
327
+ (b"j", "j"),
328
+ (b"2", "2"),
329
+ ]
330
+
331
+ for byte_seq, expected_key in test_cases:
332
+ r_fd, w_fd = os.pipe()
333
+ try:
334
+ os.write(w_fd, byte_seq)
335
+ # Mock sys.stdin.fileno() to return r_fd
336
+ monkeypatch.setattr("sys.stdin.fileno", lambda fd=r_fd: fd)
337
+ key = _read_terminal_key()
338
+ assert key == expected_key, f"Expected {expected_key} for {byte_seq}, got {key}"
339
+ finally:
340
+ os.close(r_fd)
341
+ os.close(w_fd)
342
+
343
+ def test_read_terminal_key_rapid_sequence(self, monkeypatch):
344
+ import os
345
+ from codeagent.blueprints import _read_terminal_key
346
+
347
+ r_fd, w_fd = os.pipe()
348
+ try:
349
+ # Write a stream of keys into the pipe all at once
350
+ os.write(w_fd, b"\x1b[B\x1b[B\x1b[A\r")
351
+ monkeypatch.setattr("sys.stdin.fileno", lambda fd=r_fd: fd)
352
+
353
+ k1 = _read_terminal_key()
354
+ k2 = _read_terminal_key()
355
+ k3 = _read_terminal_key()
356
+ k4 = _read_terminal_key()
357
+
358
+ assert k1 == "down"
359
+ assert k2 == "down"
360
+ assert k3 == "up"
361
+ assert k4 == "enter"
362
+ finally:
363
+ os.close(r_fd)
364
+ os.close(w_fd)
365
+
366
+ def test_interactive_arrow_select_real_pipe_stream(self, monkeypatch):
367
+ import os
368
+ from codeagent.blueprints import _interactive_arrow_select
369
+
370
+ options = [
371
+ ("Vanilla", "HTML/CSS/JS"),
372
+ ("React.js", "React hooks"),
373
+ ("Vue.js", "Vue 3"),
374
+ ("Angular", "TypeScript"),
375
+ ("Golang", "Go net/http"),
376
+ ]
377
+
378
+ r_fd, w_fd = os.pipe()
379
+ try:
380
+ # Send Down twice then Enter via pipe stream
381
+ os.write(w_fd, b"\x1b[B\x1b[B\r")
382
+ monkeypatch.setattr("sys.stdin.fileno", lambda fd=r_fd: fd)
383
+ idx = _interactive_arrow_select("Choose framework", options, default_index=0)
384
+ # 0 -> 1 -> 2 (Vue.js)
385
+ assert idx == 2
386
+ finally:
387
+ os.close(r_fd)
388
+ os.close(w_fd)
389
+
390
+ # Test Up arrow wraparound via real pipe: 0 -> 4 (Golang)
391
+ r_fd2, w_fd2 = os.pipe()
392
+ try:
393
+ os.write(w_fd2, b"\x1b[A\r")
394
+ monkeypatch.setattr("sys.stdin.fileno", lambda fd=r_fd2: fd)
395
+ idx2 = _interactive_arrow_select("Choose framework", options, default_index=0)
396
+ assert idx2 == 4
397
+ finally:
398
+ os.close(r_fd2)
399
+ os.close(w_fd2)
File without changes
File without changes