1414from typing import Literal
1515
1616from .bots import Action , Bot , Goal
17- from .common import Feedback , JSONObject , qualified_class_name , reindent
17+ from .common import JSONObject , Progress , qualified_class_name , reindent
1818from .git import SHA , Repo
1919from .prompt import TemplatedPrompt
2020from .store import Store , sql
@@ -89,16 +89,16 @@ def _active_folio(repo: Repo) -> Folio | None:
8989class Drafter :
9090 """Draft state orchestrator"""
9191
92- def __init__ (self , store : Store , repo : Repo , feedback : Feedback ) -> None :
92+ def __init__ (self , store : Store , repo : Repo , progress : Progress ) -> None :
9393 self ._store = store
9494 self ._repo = repo
95- self ._feedback = feedback
95+ self ._progress = progress
9696
9797 @classmethod
98- def create (cls , repo : Repo , store : Store , feedback : Feedback ) -> Drafter :
98+ def create (cls , repo : Repo , store : Store , progress : Progress ) -> Drafter :
9999 with store .cursor () as cursor :
100100 cursor .executescript (sql ("create-tables" ))
101- return cls (store , repo , feedback )
101+ return cls (store , repo , progress )
102102
103103 async def generate_draft (
104104 self ,
@@ -107,7 +107,7 @@ async def generate_draft(
107107 merge_strategy : DraftMergeStrategy | None = None ,
108108 prompt_transform : Callable [[str ], str ] | None = None ,
109109 ) -> Draft :
110- with self ._feedback .spinner ("Preparing prompt..." ) as spinner :
110+ with self ._progress .spinner ("Preparing prompt..." ) as spinner :
111111 # Handle prompt templating and editing. We do this first in case
112112 # this fails, to avoid creating unnecessary branches.
113113 toolbox , dirty = RepoToolbox .for_working_dir (self ._repo )
@@ -141,8 +141,8 @@ async def generate_draft(
141141 )
142142
143143 # Run the bot to generate the change.
144- operation_recorder = _OperationRecorder (self ._feedback )
145- with self ._feedback .spinner ("Running bot..." ) as spinner :
144+ operation_recorder = _OperationRecorder (self ._progress )
145+ with self ._progress .spinner ("Running bot..." ) as spinner :
146146 change = await self ._generate_change (
147147 bot ,
148148 Goal (prompt_contents ),
@@ -151,7 +151,7 @@ async def generate_draft(
151151 ),
152152 )
153153 if change .action .question :
154- self ._feedback .report ("Requested feedback ." )
154+ self ._progress .report ("Requested progress ." )
155155 spinner .update (
156156 "Completed bot run." ,
157157 runtime = round (change .walltime .total_seconds (), 1 ),
@@ -167,7 +167,7 @@ async def generate_draft(
167167 walltime = change .walltime ,
168168 token_count = change .action .token_count ,
169169 )
170- with self ._feedback .spinner ("Creating draft commit..." ) as spinner :
170+ with self ._progress .spinner ("Creating draft commit..." ) as spinner :
171171 if dirty :
172172 parent_commit_rev = self ._commit_tree (
173173 toolbox .tree_sha (), "HEAD" , "sync(prompt)"
@@ -214,7 +214,7 @@ async def generate_draft(
214214 _logger .info ("Created new draft in folio %s." , folio .id )
215215
216216 if merge_strategy :
217- with self ._feedback .spinner ("Merging changes..." ) as spinner :
217+ with self ._progress .spinner ("Merging changes..." ) as spinner :
218218 if parent_commit_rev != "HEAD" :
219219 # If there was a sync(prompt) commit, we move forward to
220220 # it. This will avoid conflicts with earlier changes.
@@ -260,7 +260,7 @@ def quit_folio(self) -> None:
260260 if check_call .code :
261261 raise RuntimeError ("Origin branch diverged, please rebase first" )
262262
263- with self ._feedback .spinner ("Switching branch..." ) as spinner :
263+ with self ._progress .spinner ("Switching branch..." ) as spinner :
264264 # Create a reference to the current state for later analysis.
265265 self ._sync_head ("finalize" )
266266 self ._repo .git ("update-ref" , _draft_ref (folio .id , "@" ), "HEAD" )
@@ -287,7 +287,7 @@ def quit_folio(self) -> None:
287287 _logger .info ("Quit %s." , folio )
288288
289289 def _create_folio (self ) -> Folio :
290- with self ._feedback .spinner ("Creating draft branch..." ) as spinner :
290+ with self ._progress .spinner ("Creating draft branch..." ) as spinner :
291291 origin_branch = self ._repo .active_branch ()
292292 if origin_branch is None :
293293 raise RuntimeError ("No currently active branch" )
@@ -436,33 +436,33 @@ class _OperationRecorder(ToolVisitor):
436436 analysis.
437437 """
438438
439- def __init__ (self , feedback : Feedback ) -> None :
439+ def __init__ (self , progress : Progress ) -> None :
440440 self .operations = list [_Operation ]()
441- self ._feedback = feedback
441+ self ._progress = progress
442442
443443 def on_list_files (
444444 self , paths : Sequence [PurePosixPath ], reason : str | None
445445 ) -> None :
446446 count = len (paths )
447- self ._feedback .report ("Listed available files." , count = count )
447+ self ._progress .report ("Listed available files." , count = count )
448448 self ._record (reason , "list_files" , count = count )
449449
450450 def on_read_file (
451451 self , path : PurePosixPath , contents : str | None , reason : str | None
452452 ) -> None :
453453 size = - 1 if contents is None else len (contents )
454- self ._feedback .report (f"Read { path } ." , length = size )
454+ self ._progress .report (f"Read { path } ." , length = size )
455455 self ._record (reason , "read_file" , path = str (path ), size = size )
456456
457457 def on_write_file (
458458 self , path : PurePosixPath , contents : str , reason : str | None
459459 ) -> None :
460460 size = len (contents )
461- self ._feedback .report (f"Wrote { path } ." , length = size )
461+ self ._progress .report (f"Wrote { path } ." , length = size )
462462 self ._record (reason , "write_file" , path = str (path ), size = size )
463463
464464 def on_delete_file (self , path : PurePosixPath , reason : str | None ) -> None :
465- self ._feedback .report (f"Deleted { path } ." )
465+ self ._progress .report (f"Deleted { path } ." )
466466 self ._record (reason , "delete_file" , path = str (path ))
467467
468468 def on_rename_file (
@@ -471,7 +471,7 @@ def on_rename_file(
471471 dst_path : PurePosixPath ,
472472 reason : str | None ,
473473 ) -> None :
474- self ._feedback .report (f"Renamed { src_path } to { dst_path } ." )
474+ self ._progress .report (f"Renamed { src_path } to { dst_path } ." )
475475 self ._record (
476476 reason ,
477477 "rename_file" ,
0 commit comments