74 lines
2.7 KiB
Python
74 lines
2.7 KiB
Python
# SPDX-FileCopyrightText: 2026 Art Sea LLC
|
|
#
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
|
|
from band_aider.context.contex_bag import ContextBag
|
|
from band_aider.judgement.file_manager import FileManager
|
|
from band_aider.judgement.code_editor import EditorRecord
|
|
|
|
|
|
@dataclass
|
|
class BootstrapContext(ContextBag):
|
|
"""BootstrapContext stores durable reusable-construct mapping state."""
|
|
|
|
upstream_file_manager: FileManager = field()
|
|
iteration: int = 0
|
|
max_iterations: int = 3
|
|
stage: str = "initialized"
|
|
completed: bool = False
|
|
blocked_summary: str = ""
|
|
search_anchors: tuple[str, ...] = ()
|
|
visible_locations: list[str] = field(default_factory=list)
|
|
beats_by_location: dict[str, list[str]] = field(default_factory=dict)
|
|
cross_cutting_concerns: list[dict[str, object]] = field(default_factory=list)
|
|
selected_concern: dict[str, object] | None = None
|
|
idiom_catalog: list[dict[str, object]] = field(default_factory=list)
|
|
pending_idiom_pairs: list[tuple[str, ...]] = field(default_factory=list)
|
|
design_plan: dict[str, object] = field(default_factory=dict)
|
|
implementation_prompt: str = ""
|
|
created_locations: list[str] = field(default_factory=list)
|
|
involved_locations: list[str] = field(default_factory=list)
|
|
editor_summaries: list[str] = field(default_factory=list)
|
|
editor_records: list[EditorRecord] = field(default_factory=list)
|
|
refreshed_locations: list[str] = field(default_factory=list)
|
|
|
|
def __getstate__(self) -> dict[str, object]:
|
|
"""Return durable bootstrap state while stripping runtime-owned collaborators."""
|
|
|
|
state = super().__getstate__()
|
|
state.pop("upstream_file_manager", None)
|
|
state.pop("new_files_callback", None)
|
|
state.pop("editor", None)
|
|
state.pop("aider_worker", None)
|
|
state.pop("language_strategy_set", None)
|
|
state.pop("source_discovery_strategy", None)
|
|
state.pop("cross_cutting_concern_check_factory", None)
|
|
state.pop("repository_idiom_check_factory", None)
|
|
state.pop("tighten_design_work_check_factory", None)
|
|
return state
|
|
|
|
def mark_stage(self, stage: str) -> None:
|
|
"""Persist a meaningful bootstrap stage transition."""
|
|
|
|
self.stage = stage
|
|
self.persist()
|
|
|
|
def mark_completed(self) -> None:
|
|
"""Persist the completed bootstrap state."""
|
|
|
|
self.completed = True
|
|
self.stage = "completed"
|
|
self.editor_records = []
|
|
self.persist()
|
|
|
|
def mark_blocked(self, summary: str) -> None:
|
|
"""Persist a mechanical bootstrap stop with evidence."""
|
|
|
|
self.blocked_summary = summary
|
|
self.completed = True
|
|
self.stage = "blocked"
|
|
self.persist()
|