FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cecli/cecli/coders/architect_coder.py at main · cecli-dev/cecli · GitHub
cecli-dev
cecli
Repository navigation
Code
Issues
11
(11)
Pull requests
8
(8)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cecli
/
cecli
/
coders
/
architect_coder.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
98 lines (76 loc) · 3.25 KB
Breadcrumbs
cecli
/
cecli
/
coders
/
architect_coder.py
Copy path
File metadata and controls
98 lines (76 loc) · 3.25 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import
asyncio
from
..
commands
import
SwitchCoderSignal
from
..
helpers
.
conversation
import
ConversationService
from
.
ask_coder
import
AskCoder
from
.
base_coder
import
Coder
class
ArchitectCoder
(
AskCoder
):
edit_format
=
"architect"
prompt_format
=
"architect"
auto_accept_architect
=
False
async
def
reply_completed
(
self
):
content
=
self
.
partial_response_content
if
not
content
or
not
content
.
strip
():
return
tweak_responses
=
getattr
(
self
.
args
,
"tweak_responses"
,
False
)
confirmation
=
await
self
.
io
.
confirm_ask
(
"Edit the files?"
,
allow_tweak
=
tweak_responses
,
explicit_yes_required
=
not
self
.
auto_accept_architect
,
)
if
not
confirmation
:
return
if
confirmation
==
"tweak"
:
if
self
.
tui
and
self
.
tui
():
content
=
self
.
tui
().
get_response_from_editor
(
content
)
else
:
content
=
self
.
io
.
edit_in_editor
(
content
)
await
asyncio
.
sleep
(
0.1
)
kwargs
=
dict
()
# Use the editor_model from the main_model if it exists, otherwise use the main_model itself
editor_model
=
self
.
main_model
.
editor_model
or
self
.
main_model
kwargs
[
"main_model"
]
=
editor_model
kwargs
[
"edit_format"
]
=
self
.
main_model
.
editor_edit_format
kwargs
[
"args"
]
=
self
.
args
kwargs
[
"suggest_shell_commands"
]
=
False
kwargs
[
"map_tokens"
]
=
0
kwargs
[
"cache_prompts"
]
=
False
kwargs
[
"num_cache_warming_pings"
]
=
0
kwargs
[
"summarize_from_coder"
]
=
False
kwargs
[
"done_messages"
]
=
[]
kwargs
[
"cur_messages"
]
=
[]
new_kwargs
=
dict
(
io
=
self
.
io
,
from_coder
=
self
)
new_kwargs
.
update
(
kwargs
)
# Save current conversation state
original_coder
=
self
editor_coder
=
await
Coder
.
create
(
**
new_kwargs
)
# Re-initialize ConversationManager with editor coder
ConversationService
.
get_manager
(
editor_coder
).
initialize
(
reset
=
True
,
reformat
=
True
,
preserve_tags
=
True
)
if
self
.
verbose
:
editor_coder
.
show_announcements
()
postamble
=
"""
The above changes are proposed changes.
You must repeat SEARCH/REPLACE blocks in order to apply edits.
Shell commands must also be duplicated in order to run them.
"""
content
=
f"Please implement all requested changes from:
\n
{
content
}
\n
{
postamble
}
"
try
:
await
editor_coder
.
generate
(
user_message
=
content
,
preproc
=
False
)
# Clear manager and restore original state
ConversationService
.
get_manager
(
original_coder
or
self
).
initialize
(
reset
=
True
,
reformat
=
True
,
preserve_tags
=
True
,
)
self
.
total_cost
=
editor_coder
.
total_cost
self
.
coder_commit_hashes
=
editor_coder
.
coder_commit_hashes
except
Exception
as
e
:
self
.
io
.
tool_error
(
str
(
e
))
# Restore original state on error
ConversationService
.
get_manager
(
original_coder
or
self
).
initialize
(
reset
=
True
,
reformat
=
True
,
preserve_tags
=
True
,
)
raise
SwitchCoderSignal
(
main_model
=
self
.
main_model
,
edit_format
=
"architect"
)
Back
|
FazBrowse Home
|
New Git URL