autopilot-code 0.8.0 → 0.9.0
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.
- package/package.json +1 -1
- package/scripts/run_autopilot.py +67 -11
package/package.json
CHANGED
package/scripts/run_autopilot.py
CHANGED
|
@@ -25,6 +25,12 @@ from dataclasses import dataclass
|
|
|
25
25
|
from pathlib import Path
|
|
26
26
|
from typing import Any
|
|
27
27
|
import shutil
|
|
28
|
+
from sys import path as sys_path
|
|
29
|
+
|
|
30
|
+
# Add scripts directory to path for imports
|
|
31
|
+
script_dir = Path(__file__).parent
|
|
32
|
+
sys_path.insert(0, str(script_dir))
|
|
33
|
+
from issue_runner import IssueRunner
|
|
28
34
|
|
|
29
35
|
STATE_DIR = ".autopilot"
|
|
30
36
|
STATE_FILE = "state.json"
|
|
@@ -87,6 +93,8 @@ class RepoConfig:
|
|
|
87
93
|
auto_fix_checks: bool
|
|
88
94
|
auto_fix_checks_max_attempts: int
|
|
89
95
|
auto_update: bool
|
|
96
|
+
use_new_runner: bool = False
|
|
97
|
+
config: dict[str, Any] = None
|
|
90
98
|
|
|
91
99
|
|
|
92
100
|
def load_config(repo_root: Path) -> RepoConfig | None:
|
|
@@ -136,6 +144,8 @@ def load_config(repo_root: Path) -> RepoConfig | None:
|
|
|
136
144
|
auto_fix_checks=auto_fix_checks,
|
|
137
145
|
auto_fix_checks_max_attempts=auto_fix_checks_max_attempts,
|
|
138
146
|
auto_update=data.get("autoUpdate", False),
|
|
147
|
+
use_new_runner=data.get("useNewRunner", False),
|
|
148
|
+
config=data,
|
|
139
149
|
)
|
|
140
150
|
|
|
141
151
|
|
|
@@ -366,6 +376,18 @@ def claim_issue(cfg: RepoConfig, issue: dict[str, Any], note: str) -> None:
|
|
|
366
376
|
touch_heartbeat(cfg, num)
|
|
367
377
|
|
|
368
378
|
|
|
379
|
+
def clear_active_issue(cfg: RepoConfig, issue_number: int) -> None:
|
|
380
|
+
"""Clear an issue from active issues state."""
|
|
381
|
+
state = load_state(cfg.root)
|
|
382
|
+
active_issues = state.get("activeIssues", {})
|
|
383
|
+
if isinstance(active_issues, dict):
|
|
384
|
+
issue_key = str(issue_number)
|
|
385
|
+
if issue_key in active_issues:
|
|
386
|
+
del active_issues[issue_key]
|
|
387
|
+
state["activeIssues"] = active_issues
|
|
388
|
+
write_state(cfg.root, state)
|
|
389
|
+
|
|
390
|
+
|
|
369
391
|
def list_in_progress_issues(cfg: RepoConfig, limit: int = 20) -> list[dict[str, Any]]:
|
|
370
392
|
cmd = [
|
|
371
393
|
"gh",
|
|
@@ -736,6 +758,49 @@ def maybe_mark_blocked(cfg: RepoConfig, issue: dict[str, Any]) -> None:
|
|
|
736
758
|
)
|
|
737
759
|
|
|
738
760
|
|
|
761
|
+
def run_issue(cfg: RepoConfig, issue_number: int) -> bool:
|
|
762
|
+
"""
|
|
763
|
+
Run the agent on an issue.
|
|
764
|
+
|
|
765
|
+
Uses either the new Python runner or legacy bash script
|
|
766
|
+
based on configuration.
|
|
767
|
+
"""
|
|
768
|
+
if cfg.use_new_runner:
|
|
769
|
+
return run_issue_new(cfg, issue_number)
|
|
770
|
+
else:
|
|
771
|
+
return run_issue_legacy(cfg, issue_number)
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
def run_issue_new(cfg: RepoConfig, issue_number: int) -> bool:
|
|
775
|
+
"""Run issue using new Python state machine runner."""
|
|
776
|
+
# Touch heartbeat before starting
|
|
777
|
+
touch_heartbeat(cfg, issue_number)
|
|
778
|
+
|
|
779
|
+
runner = IssueRunner(
|
|
780
|
+
repo=cfg.repo,
|
|
781
|
+
repo_root=cfg.root,
|
|
782
|
+
config=cfg.config
|
|
783
|
+
)
|
|
784
|
+
|
|
785
|
+
try:
|
|
786
|
+
success = runner.run(issue_number)
|
|
787
|
+
finally:
|
|
788
|
+
# Clear from active issues when done
|
|
789
|
+
clear_active_issue(cfg, issue_number)
|
|
790
|
+
|
|
791
|
+
return success
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
def run_issue_legacy(cfg: RepoConfig, issue_number: int) -> bool:
|
|
795
|
+
"""Run issue using legacy bash script (existing behavior)."""
|
|
796
|
+
script_path = Path(__file__).parent / "run_opencode_issue.sh"
|
|
797
|
+
result = subprocess.run(
|
|
798
|
+
[str(script_path), str(cfg.root), str(issue_number)],
|
|
799
|
+
cwd=cfg.root
|
|
800
|
+
)
|
|
801
|
+
return result.returncode == 0
|
|
802
|
+
|
|
803
|
+
|
|
739
804
|
def run_cycle(
|
|
740
805
|
all_configs: list[RepoConfig],
|
|
741
806
|
dry_run: bool = False,
|
|
@@ -816,18 +881,9 @@ def run_cycle(
|
|
|
816
881
|
start_msg = f"🚀 Autopilot is now starting work on issue #{issue['number']}.\n\nI'll post regular progress updates as I work through the implementation."
|
|
817
882
|
sh(["gh", "issue", "comment", str(issue["number"]), "--repo", cfg.repo, "--body", start_msg])
|
|
818
883
|
|
|
819
|
-
#
|
|
884
|
+
# Run the issue using the appropriate runner
|
|
820
885
|
if cfg.agent == "opencode":
|
|
821
|
-
|
|
822
|
-
script_dir = Path(__file__).parent
|
|
823
|
-
script_path = script_dir / "run_opencode_issue.sh"
|
|
824
|
-
sh(
|
|
825
|
-
[
|
|
826
|
-
str(script_path),
|
|
827
|
-
str(cfg.root),
|
|
828
|
-
str(issue["number"]),
|
|
829
|
-
]
|
|
830
|
-
)
|
|
886
|
+
run_issue(cfg, issue["number"])
|
|
831
887
|
|
|
832
888
|
# Check if autopilot needs to update
|
|
833
889
|
if not dry_run and check_autopilot_needs_update():
|