alpiecode 10.8.1__tar.gz → 10.8.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.
- {alpiecode-10.8.1 → alpiecode-10.8.3}/PKG-INFO +1 -1
- {alpiecode-10.8.1 → alpiecode-10.8.3}/pyproject.toml +1 -1
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/alpiecode.egg-info/PKG-INFO +1 -1
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/alpiecode.egg-info/SOURCES.txt +1 -1
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/__init__.py +1 -1
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/agent.py +99 -22
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/cli.py +32 -3
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/executor.py +10 -7
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/orchestrator.py +60 -4
- alpiecode-10.8.3/src/codeagent/session.py +302 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/slash.py +41 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/system1.py +72 -10
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/tools.py +9 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/verifier.py +21 -7
- alpiecode-10.8.3/test/test_deloop_and_sessions.py +150 -0
- alpiecode-10.8.1/src/codeagent/extension/alpiecode.vsix +0 -0
- alpiecode-10.8.1/src/codeagent/session.py +0 -77
- {alpiecode-10.8.1 → alpiecode-10.8.3}/README.md +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/setup.cfg +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/alpiecode/__init__.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/alpiecode.egg-info/dependency_links.txt +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/alpiecode.egg-info/entry_points.txt +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/alpiecode.egg-info/requires.txt +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/alpiecode.egg-info/top_level.txt +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/assessment.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/backends/__init__.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/backends/base.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/backends/local_backend.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/backends/openai_backend.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/blueprints.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/cache.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/client.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/compaction.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/config.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/context.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/diff_preview.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/discovery.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/doctor.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/dream_rsi.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/git_ops.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/github.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/guardian.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/guardrails.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/ipython_ext.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/local_model.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/media.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/memory.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/metrics.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/paths.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/progress.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/project_template.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/prompt.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/rephraser.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/server.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/subagent.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/updater.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/vscode_installer.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/src/codeagent/walkthrough.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/test/test_adaptive_resilience.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/test/test_cli_ui.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/test/test_context_and_trajectory.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/test/test_dream_rsi.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/test/test_local_model_download.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/test/test_non_thinking_and_local_stream.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/test/test_project_templates.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/test/test_slash_and_diff.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/test/test_subagents.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/test/test_task_assessment.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/test/test_verifier.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/test/test_walkthrough.py +0 -0
- {alpiecode-10.8.1 → alpiecode-10.8.3}/test/test_web_resilience_and_guardrails.py +0 -0
|
@@ -51,10 +51,10 @@ src/codeagent/backends/__init__.py
|
|
|
51
51
|
src/codeagent/backends/base.py
|
|
52
52
|
src/codeagent/backends/local_backend.py
|
|
53
53
|
src/codeagent/backends/openai_backend.py
|
|
54
|
-
src/codeagent/extension/alpiecode.vsix
|
|
55
54
|
test/test_adaptive_resilience.py
|
|
56
55
|
test/test_cli_ui.py
|
|
57
56
|
test/test_context_and_trajectory.py
|
|
57
|
+
test/test_deloop_and_sessions.py
|
|
58
58
|
test/test_dream_rsi.py
|
|
59
59
|
test/test_local_model_download.py
|
|
60
60
|
test/test_non_thinking_and_local_stream.py
|
|
@@ -17,7 +17,7 @@ Supports:
|
|
|
17
17
|
from pathlib import Path
|
|
18
18
|
from typing import Optional, Any, Dict
|
|
19
19
|
|
|
20
|
-
__version__ = "10.8.
|
|
20
|
+
__version__ = "10.8.3"
|
|
21
21
|
|
|
22
22
|
def run(task: str, workdir: str = ".", reasoning_level: str = "thinking", **kwargs):
|
|
23
23
|
"""Run an autonomous coding task programmatically."""
|
|
@@ -304,6 +304,8 @@ def run_agent(
|
|
|
304
304
|
server_url: str = None,
|
|
305
305
|
complexity: str = None,
|
|
306
306
|
debug: bool = False,
|
|
307
|
+
resume_id: Optional[str] = None,
|
|
308
|
+
continue_session: bool = False,
|
|
307
309
|
) -> AgentRunResult:
|
|
308
310
|
"""Run non-interactive agent task with Rich presentation."""
|
|
309
311
|
workdir = workdir.resolve()
|
|
@@ -337,7 +339,26 @@ def run_agent(
|
|
|
337
339
|
backend = resolve_backend(cfg)
|
|
338
340
|
orchestrator = AgentOrchestrator(backend)
|
|
339
341
|
session_mgr = SessionManager()
|
|
340
|
-
|
|
342
|
+
max_ctx = backend.context_window if hasattr(backend, 'context_window') and backend.context_window else (cfg.n_ctx if cfg.base_url == 'offline' else 262_144)
|
|
343
|
+
|
|
344
|
+
session = None
|
|
345
|
+
if continue_session:
|
|
346
|
+
sid = session_mgr.get_latest_session_id(workdir)
|
|
347
|
+
if sid:
|
|
348
|
+
session = session_mgr.load_session(sid, workdir, max_tokens=max_ctx)
|
|
349
|
+
if session and verbose:
|
|
350
|
+
console.print(f"🔄 [cyan]Continuing session[/cyan] [bold]{session.id}[/bold] ({len(session.context.messages)} prior messages)")
|
|
351
|
+
elif resume_id:
|
|
352
|
+
session = session_mgr.load_session(resume_id, workdir, max_tokens=max_ctx)
|
|
353
|
+
if session and verbose:
|
|
354
|
+
console.print(f"🔄 [cyan]Resumed session[/cyan] [bold]{session.id}[/bold] ({len(session.context.messages)} prior messages)")
|
|
355
|
+
|
|
356
|
+
if not session:
|
|
357
|
+
session = session_mgr.create_session(workdir, max_tokens=max_ctx, task_description=task)
|
|
358
|
+
|
|
359
|
+
from .session import setup_sigint_handler
|
|
360
|
+
setup_sigint_handler(session, session_mgr)
|
|
361
|
+
|
|
341
362
|
event_stream = orchestrator.run_task(
|
|
342
363
|
session=session,
|
|
343
364
|
task=task,
|
|
@@ -544,10 +565,16 @@ def run_agent(
|
|
|
544
565
|
sys.stdout.write("\n")
|
|
545
566
|
sys.stdout.flush()
|
|
546
567
|
has_streamed_tokens = False
|
|
547
|
-
|
|
548
|
-
has_printed_anything = True
|
|
568
|
+
|
|
549
569
|
tc_name = event.data.get("name", "")
|
|
550
570
|
args = event.data.get("arguments", {})
|
|
571
|
+
is_deliverable_action = tc_name in ("write_file", "edit_file", "apply_patch", "download_asset")
|
|
572
|
+
|
|
573
|
+
# Professional presentation: Print deliverables / edits or in debug mode
|
|
574
|
+
if is_deliverable_action or debug:
|
|
575
|
+
_print_tool_call(event.data["turn"], event.data["name"], event.data["arguments"])
|
|
576
|
+
has_printed_anything = True
|
|
577
|
+
|
|
551
578
|
if tc_name == "bash":
|
|
552
579
|
cmd = args.get("command", "").strip()
|
|
553
580
|
status_spinner.resume(f"Executing bash: {cmd[:60]}...", style="bold yellow")
|
|
@@ -557,12 +584,15 @@ def run_agent(
|
|
|
557
584
|
elif tc_name in ("write_file", "edit_file"):
|
|
558
585
|
p = args.get("path", "")
|
|
559
586
|
status_spinner.resume(f"Saving {p}...", style="bold cyan")
|
|
587
|
+
elif tc_name == "download_asset":
|
|
588
|
+
k = args.get("category") or args.get("query") or ""
|
|
589
|
+
status_spinner.resume(f"Downloading asset '{k}'...", style="bold cyan")
|
|
560
590
|
else:
|
|
561
591
|
status_spinner.resume(f"Executing {tc_name}...", style="bold cyan")
|
|
562
592
|
|
|
563
593
|
elif event.type == "tool_result":
|
|
564
594
|
status_spinner.pause()
|
|
565
|
-
if verbose:
|
|
595
|
+
if verbose and debug:
|
|
566
596
|
_print_tool_result(event.data["content"])
|
|
567
597
|
_checkpoint(workdir, f"checkpoint: turn {event.data['turn']}")
|
|
568
598
|
status_spinner.resume("Evaluating result & planning next step...", style="bold cyan")
|
|
@@ -619,23 +649,26 @@ def run_agent(
|
|
|
619
649
|
style="dim"
|
|
620
650
|
)
|
|
621
651
|
|
|
622
|
-
elif event.type == "system1_intervention"
|
|
623
|
-
status_spinner.pause()
|
|
652
|
+
elif event.type == "system1_intervention":
|
|
624
653
|
data = event.data
|
|
625
654
|
action = data.get("action", "")
|
|
626
655
|
err_type = data.get("error_type", "")
|
|
627
656
|
directive = data.get("directive", "")
|
|
628
|
-
if
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
657
|
+
if debug and verbose:
|
|
658
|
+
status_spinner.pause()
|
|
659
|
+
if HAS_RICH:
|
|
660
|
+
console.print(Panel(
|
|
661
|
+
f"[bold yellow]⚡ System 1 (Jev) Intervention[/bold yellow] (Turn {data.get('turn')})\n"
|
|
662
|
+
f"• Action: [cyan]{action}[/cyan] | Error Type: [red]{err_type}[/red]\n"
|
|
663
|
+
f"• Directive: {directive}",
|
|
664
|
+
border_style="yellow",
|
|
665
|
+
padding=(0, 1)
|
|
666
|
+
))
|
|
667
|
+
else:
|
|
668
|
+
print(f"\n⚡ [System 1 Intervention] {action}: {directive}")
|
|
669
|
+
status_spinner.resume()
|
|
636
670
|
else:
|
|
637
|
-
|
|
638
|
-
status_spinner.resume()
|
|
671
|
+
status_spinner.update(f"⚡ Jev ({err_type}): {directive[:60]}...", style="bold yellow")
|
|
639
672
|
|
|
640
673
|
elif event.type == "metrics" and verbose:
|
|
641
674
|
status_spinner.stop()
|
|
@@ -750,12 +783,24 @@ def run_agent(
|
|
|
750
783
|
print(f"\n⚠️ Safety ceiling ({event.data['max_turns']}) reached.")
|
|
751
784
|
finally:
|
|
752
785
|
status_spinner.stop()
|
|
786
|
+
if "session_mgr" in locals() and "session" in locals() and session:
|
|
787
|
+
try:
|
|
788
|
+
session_mgr.save_session(session)
|
|
789
|
+
except Exception:
|
|
790
|
+
pass
|
|
753
791
|
|
|
754
792
|
msgs = session.context.messages if "session" in locals() else []
|
|
755
793
|
return AgentRunResult(msgs, success=task_success, outcome=task_outcome)
|
|
756
794
|
|
|
757
795
|
|
|
758
|
-
def run_chat(
|
|
796
|
+
def run_chat(
|
|
797
|
+
workdir: Path,
|
|
798
|
+
cfg: Config,
|
|
799
|
+
verbose: bool = True,
|
|
800
|
+
debug: bool = False,
|
|
801
|
+
resume_id: Optional[str] = None,
|
|
802
|
+
continue_session: bool = False,
|
|
803
|
+
) -> None:
|
|
759
804
|
"""Run interactive chat session with Rich presentation."""
|
|
760
805
|
workdir = workdir.resolve()
|
|
761
806
|
_ensure_git(workdir)
|
|
@@ -763,7 +808,25 @@ def run_chat(workdir: Path, cfg: Config, verbose: bool = True, debug: bool = Fal
|
|
|
763
808
|
backend = resolve_backend(cfg)
|
|
764
809
|
orchestrator = AgentOrchestrator(backend)
|
|
765
810
|
session_mgr = SessionManager()
|
|
766
|
-
|
|
811
|
+
max_ctx = backend.context_window if hasattr(backend, 'context_window') and backend.context_window else (cfg.n_ctx if cfg.base_url == 'offline' else 262_144)
|
|
812
|
+
|
|
813
|
+
session = None
|
|
814
|
+
if continue_session:
|
|
815
|
+
sid = session_mgr.get_latest_session_id(workdir)
|
|
816
|
+
if sid:
|
|
817
|
+
session = session_mgr.load_session(sid, workdir, max_tokens=max_ctx)
|
|
818
|
+
if session and HAS_RICH:
|
|
819
|
+
console.print(f"🔄 Continuing session [bold cyan]{session.id}[/bold cyan] ({len(session.context.messages)} prior messages)")
|
|
820
|
+
elif resume_id:
|
|
821
|
+
session = session_mgr.load_session(resume_id, workdir, max_tokens=max_ctx)
|
|
822
|
+
if session and HAS_RICH:
|
|
823
|
+
console.print(f"🔄 Resumed session [bold cyan]{session.id}[/bold cyan] ({len(session.context.messages)} prior messages)")
|
|
824
|
+
|
|
825
|
+
if not session:
|
|
826
|
+
session = session_mgr.create_session(workdir, max_tokens=max_ctx, task_description="Interactive chat")
|
|
827
|
+
|
|
828
|
+
from .session import setup_sigint_handler
|
|
829
|
+
setup_sigint_handler(session, session_mgr)
|
|
767
830
|
|
|
768
831
|
is_offline = (
|
|
769
832
|
getattr(backend, "is_offline", False) is True
|
|
@@ -779,7 +842,7 @@ def run_chat(workdir: Path, cfg: Config, verbose: bool = True, debug: bool = Fal
|
|
|
779
842
|
mode_line = f"🌐 Mode: [bold green]ONLINE[/bold green]\n🤖 Model: [bold cyan]{cur_model}[/bold cyan]" if not is_offline else f"🧠 Mode: [bold yellow]OFFLINE[/bold yellow]\n🤖 Model: [bold cyan]{cur_model} (Local GGUF)[/bold cyan]"
|
|
780
843
|
console.print(
|
|
781
844
|
Panel(
|
|
782
|
-
f"[bold cyan]AlpieCode[/bold cyan] interactive mode\n"
|
|
845
|
+
f"[bold cyan]AlpieCode[/bold cyan] interactive mode (Session: [bold]{session.id}[/bold])\n"
|
|
783
846
|
f"📂 Working in: [cyan]{workdir}[/cyan]\n"
|
|
784
847
|
f"{mode_line}\n\n"
|
|
785
848
|
"Type your request, or [bold red]exit[/bold red] / [bold red]quit[/bold red] to stop.",
|
|
@@ -788,7 +851,7 @@ def run_chat(workdir: Path, cfg: Config, verbose: bool = True, debug: bool = Fal
|
|
|
788
851
|
)
|
|
789
852
|
)
|
|
790
853
|
else:
|
|
791
|
-
console.print("\n💬 Chat Mode — type your request, or 'exit' to stop.")
|
|
854
|
+
console.print(f"\n💬 Chat Mode (Session: {session.id}) — type your request, or 'exit' to stop.")
|
|
792
855
|
console.print(f"📂 Working in: {workdir}")
|
|
793
856
|
|
|
794
857
|
while True:
|
|
@@ -798,7 +861,13 @@ def run_chat(workdir: Path, cfg: Config, verbose: bool = True, debug: bool = Fal
|
|
|
798
861
|
else:
|
|
799
862
|
user_input = input("\nYou ❯ ").strip()
|
|
800
863
|
except (EOFError, KeyboardInterrupt):
|
|
801
|
-
|
|
864
|
+
session_mgr.save_session(session)
|
|
865
|
+
if HAS_RICH:
|
|
866
|
+
console.print(f"\nSession saved (id: [bold cyan]{session.id}[/bold cyan]). Resume with: [bold]alpiecode --continue[/bold]")
|
|
867
|
+
console.print("Goodbye! 👋")
|
|
868
|
+
else:
|
|
869
|
+
print(f"\nSession saved (id: {session.id}). Resume with: alpiecode --continue")
|
|
870
|
+
print("Goodbye! 👋")
|
|
802
871
|
break
|
|
803
872
|
|
|
804
873
|
if not user_input:
|
|
@@ -807,9 +876,16 @@ def run_chat(workdir: Path, cfg: Config, verbose: bool = True, debug: bool = Fal
|
|
|
807
876
|
from .slash import handle_slash_command
|
|
808
877
|
slash_res = handle_slash_command(user_input, session, orchestrator, cfg, console, has_rich=HAS_RICH)
|
|
809
878
|
if slash_res is False:
|
|
810
|
-
|
|
879
|
+
session_mgr.save_session(session)
|
|
880
|
+
if HAS_RICH:
|
|
881
|
+
console.print(f"Session saved (id: [bold cyan]{session.id}[/bold cyan]). Resume with: [bold]alpiecode --continue[/bold]")
|
|
882
|
+
console.print("Goodbye! 👋")
|
|
883
|
+
else:
|
|
884
|
+
print(f"Session saved (id: {session.id}). Resume with: alpiecode --continue")
|
|
885
|
+
print("Goodbye! 👋")
|
|
811
886
|
break
|
|
812
887
|
elif slash_res is True:
|
|
888
|
+
session_mgr.save_session(session)
|
|
813
889
|
continue
|
|
814
890
|
|
|
815
891
|
has_streamed_chat = False
|
|
@@ -913,3 +989,4 @@ def run_chat(workdir: Path, cfg: Config, verbose: bool = True, debug: bool = Fal
|
|
|
913
989
|
break
|
|
914
990
|
finally:
|
|
915
991
|
chat_status.stop()
|
|
992
|
+
session_mgr.save_session(session)
|
|
@@ -109,6 +109,9 @@ def main():
|
|
|
109
109
|
common.add_argument("--debug", action="store_true", help="Show autonomous discovery and debug diagnostics")
|
|
110
110
|
common.add_argument("--offline", "--local", dest="offline", action="store_true", help="Run using local offline GGUF model on GPU without internet")
|
|
111
111
|
common.add_argument("--ctx-size", type=int, default=None, help="Context size in tokens (default: 8192 offline, 262144 online)")
|
|
112
|
+
common.add_argument("--resume", dest="resume_id", default=None, help="Resume an existing session by ID or transcript path")
|
|
113
|
+
common.add_argument("--continue", dest="continue_session", action="store_true", help="Continue the most recent session in this project")
|
|
114
|
+
common.add_argument("--sessions", action="store_true", help="List saved conversation sessions")
|
|
112
115
|
|
|
113
116
|
from . import __version__
|
|
114
117
|
parser = argparse.ArgumentParser(
|
|
@@ -166,10 +169,28 @@ def main():
|
|
|
166
169
|
|
|
167
170
|
args = parser.parse_args()
|
|
168
171
|
|
|
169
|
-
if
|
|
170
|
-
|
|
172
|
+
if getattr(args, "sessions", False):
|
|
173
|
+
import time
|
|
174
|
+
from .session import SessionManager
|
|
175
|
+
sm = SessionManager()
|
|
176
|
+
saved = sm.list_saved_sessions(Path(args.workdir))
|
|
177
|
+
if not saved:
|
|
178
|
+
print("ℹ️ No saved sessions found.")
|
|
179
|
+
else:
|
|
180
|
+
print("\n📋 Saved AlpieCode Sessions:")
|
|
181
|
+
for s in saved[:10]:
|
|
182
|
+
sid = s.get("id")
|
|
183
|
+
updated = time.ctime(s.get("updated_at", 0))
|
|
184
|
+
msgs = s.get("message_count", 0)
|
|
185
|
+
task_desc = (s.get("task_description") or "Interactive chat")[:50]
|
|
186
|
+
print(f" • {sid} ({updated}) [{msgs} msgs] {task_desc}")
|
|
187
|
+
print("\nResume a session with: alpiecode --resume <session_id> or alpiecode --continue\n")
|
|
171
188
|
return
|
|
172
189
|
|
|
190
|
+
if not args.command:
|
|
191
|
+
# Bare invocation (e.g. typing `alpiecode`): default directly to interactive conversation mode (like `agy` or `claude`)
|
|
192
|
+
args.command = "chat"
|
|
193
|
+
|
|
173
194
|
if args.command == "version":
|
|
174
195
|
print(f"alpiecode {__version__}")
|
|
175
196
|
return
|
|
@@ -319,6 +340,8 @@ def main():
|
|
|
319
340
|
url=getattr(args, "url", None),
|
|
320
341
|
github_repo=getattr(args, "github", None),
|
|
321
342
|
debug=getattr(args, "debug", False),
|
|
343
|
+
resume_id=getattr(args, "resume_id", None),
|
|
344
|
+
continue_session=getattr(args, "continue_session", False),
|
|
322
345
|
)
|
|
323
346
|
if not result:
|
|
324
347
|
sys.exit(1)
|
|
@@ -328,7 +351,13 @@ def main():
|
|
|
328
351
|
cfg.max_turns = args.max_turns
|
|
329
352
|
_show_banner()
|
|
330
353
|
from .agent import run_chat
|
|
331
|
-
run_chat(
|
|
354
|
+
run_chat(
|
|
355
|
+
Path(args.workdir), cfg,
|
|
356
|
+
verbose=not args.quiet,
|
|
357
|
+
debug=getattr(args, 'debug', False),
|
|
358
|
+
resume_id=getattr(args, "resume_id", None),
|
|
359
|
+
continue_session=getattr(args, "continue_session", False),
|
|
360
|
+
)
|
|
332
361
|
|
|
333
362
|
elif args.command == "plan":
|
|
334
363
|
plan_task = (
|
|
@@ -439,15 +439,18 @@ class ToolExecutor:
|
|
|
439
439
|
# Repetitive verification sequence guard
|
|
440
440
|
if tc.name == "bash":
|
|
441
441
|
cmd_str = safe_args.get("command", "").strip()
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
"
|
|
442
|
+
norm_cmd = re.sub(r"\s*\|\s*(?:head|tail|grep|sed|less|cat)\b.*", "", cmd_str)
|
|
443
|
+
norm_cmd = re.sub(r"\s*2>&1\s*", " ", norm_cmd).strip()
|
|
444
|
+
if norm_cmd and norm_cmd in self.successful_bash_commands:
|
|
445
|
+
res_str = (
|
|
446
|
+
"{\"stdout\": \"Check already verified with exit code 0. Deliverables ready.\", \"stderr\": \"\", \"exit_code\": 0}"
|
|
447
|
+
"\n\n🛑 CIRCUIT BREAKER TRIGGERED: This verification check has already passed with exit code 0, "
|
|
448
|
+
"and no files have been modified since. Stop running redundant inspection commands. "
|
|
449
|
+
"Finalize the task now with: DONE: <summary>."
|
|
447
450
|
)
|
|
448
451
|
elif '"exit_code": 0' in res_str:
|
|
449
|
-
if
|
|
450
|
-
self.successful_bash_commands.add(
|
|
452
|
+
if norm_cmd:
|
|
453
|
+
self.successful_bash_commands.add(norm_cmd)
|
|
451
454
|
|
|
452
455
|
# Smart error hint injection for failed bash commands
|
|
453
456
|
if tc.name == "bash" and '"exit_code"' in res_str:
|
|
@@ -337,6 +337,19 @@ class AgentOrchestrator:
|
|
|
337
337
|
if pre_read_ctx:
|
|
338
338
|
effective_task = rephrased_task + "\n\n" + pre_read_ctx
|
|
339
339
|
|
|
340
|
+
# Prepend explicit positional blueprint directive so Turn 1 adheres to the target architecture
|
|
341
|
+
bp = getattr(task_context, "blueprint", None)
|
|
342
|
+
if bp:
|
|
343
|
+
bp_directive = (
|
|
344
|
+
f"[ARCHITECTURE DIRECTIVE: {bp.name.upper()}]\n"
|
|
345
|
+
f"- Required Deliverables: {', '.join(bp.target_files)}\n"
|
|
346
|
+
f"- Primary Entry Point: {bp.entry_point}\n"
|
|
347
|
+
f"- Step 1 (Turn 1): Create '{bp.target_files[0]}' with complete static structure. NEVER generate React/JSX files, empty shells, or unneeded tooling.\n"
|
|
348
|
+
f"- Step 2: Implement styling and components sequentially.\n"
|
|
349
|
+
f"- Step 3: Implement client JavaScript (Universal IIFE, no unbundled ES modules).\n\n"
|
|
350
|
+
)
|
|
351
|
+
effective_task = bp_directive + effective_task
|
|
352
|
+
|
|
340
353
|
user_content = self.prompt_builder.build_user_content(
|
|
341
354
|
task=effective_task,
|
|
342
355
|
image_path=image_path,
|
|
@@ -488,12 +501,24 @@ class AgentOrchestrator:
|
|
|
488
501
|
|
|
489
502
|
yield AgentEvent("turn_start", {"turn": turn, "thinking": turn_enable_thinking})
|
|
490
503
|
|
|
491
|
-
#
|
|
492
|
-
if
|
|
504
|
+
# Guide the model with workspace progress and DOM element contract
|
|
505
|
+
if session_touched_files:
|
|
493
506
|
file_list = ", ".join(sorted(list(session_touched_files)))
|
|
494
507
|
state_hint = f"[Workspace State: Files created so far: {file_list}. Do NOT re-create these files. Proceed with remaining files or tests.]"
|
|
508
|
+
|
|
509
|
+
# If index.html exists but JavaScript hasn't been written yet, inject the exact declared DOM ID contract
|
|
510
|
+
html_p = session.workdir / "index.html"
|
|
511
|
+
if html_p.exists() and not any(f.endswith(".js") for f in session_touched_files):
|
|
512
|
+
try:
|
|
513
|
+
html_txt = html_p.read_text(encoding="utf-8", errors="replace")
|
|
514
|
+
d_ids = sorted(list(set(re.findall(r'id=["\']([a-zA-Z0-9_\-]+)["\']', html_txt))))
|
|
515
|
+
if d_ids:
|
|
516
|
+
state_hint += f"\n[DOM Schema Contract: 'index.html' defines declared element IDs: {', '.join(d_ids[:25])}. In client scripts, query ONLY these declared IDs.]"
|
|
517
|
+
except Exception:
|
|
518
|
+
pass
|
|
519
|
+
|
|
495
520
|
last_msgs = session.context.messages
|
|
496
|
-
if last_msgs and not any(
|
|
521
|
+
if last_msgs and not any("[Workspace State:" in str(m.get("content", "")) for m in last_msgs[-2:]):
|
|
497
522
|
session.context.add_user_message(state_hint)
|
|
498
523
|
|
|
499
524
|
try:
|
|
@@ -812,7 +837,7 @@ class AgentOrchestrator:
|
|
|
812
837
|
|
|
813
838
|
if not v_res.passed:
|
|
814
839
|
session._auto_verify_attempts = verify_attempts + 1
|
|
815
|
-
if session._auto_verify_attempts <
|
|
840
|
+
if session._auto_verify_attempts < 3:
|
|
816
841
|
replan_prompt = format_replan_directive(v_res, is_offline=is_offline)
|
|
817
842
|
session.context.add_user_message(replan_prompt)
|
|
818
843
|
|
|
@@ -921,6 +946,37 @@ class AgentOrchestrator:
|
|
|
921
946
|
"confidence": decision.confidence,
|
|
922
947
|
})
|
|
923
948
|
|
|
949
|
+
# ── Hard Circuit Breaker: Auto-verify and fast-forward to finish if inspection loop detected ──
|
|
950
|
+
if decision.action == ActionCategory.SKIP_LLM_FINISH:
|
|
951
|
+
from .verifier import IntelligentVerificationEngine
|
|
952
|
+
v_engine = IntelligentVerificationEngine(session.workdir)
|
|
953
|
+
v_res = v_engine.run_full_verification(
|
|
954
|
+
task=task,
|
|
955
|
+
session_touched_files=session_touched_files,
|
|
956
|
+
task_context=task_context,
|
|
957
|
+
run_bash_fn=session.executor.dispatch.get("bash", lambda a: ""),
|
|
958
|
+
is_offline=is_offline,
|
|
959
|
+
successful_commands=getattr(session.executor, "successful_bash_commands", None),
|
|
960
|
+
)
|
|
961
|
+
if v_res.passed:
|
|
962
|
+
task_metrics.finish()
|
|
963
|
+
yield AgentEvent("metrics", task_metrics.summary())
|
|
964
|
+
_ensure_trajectory_saved("success")
|
|
965
|
+
extract_and_save_memories(session.workdir, getattr(session.context, 'all_messages', session.context.messages))
|
|
966
|
+
_sync_project_memory_and_traces(
|
|
967
|
+
session.workdir, task, "Task deliverables completed and verified.", session_touched_files, session_executed_commands, task_metrics, turn
|
|
968
|
+
)
|
|
969
|
+
if any(f.endswith(".html") for f in session_touched_files) or (session.workdir / "index.html").exists():
|
|
970
|
+
yield AgentEvent("web_preview", {
|
|
971
|
+
"html_path": str((session.workdir / "index.html").resolve()),
|
|
972
|
+
"port": 8000,
|
|
973
|
+
})
|
|
974
|
+
yield AgentEvent("done", {
|
|
975
|
+
"summary": f"All deliverables verified successfully: {', '.join(sorted(list(session_touched_files))) if session_touched_files else 'complete'}.",
|
|
976
|
+
"success": True,
|
|
977
|
+
})
|
|
978
|
+
return
|
|
979
|
+
|
|
924
980
|
# Track touched files and commands for walkthrough
|
|
925
981
|
for tc in tool_calls:
|
|
926
982
|
tc_args = tc.arguments if isinstance(tc.arguments, dict) else {}
|