MCPcopy
hub / github.com/Aider-AI/aider / cmd_chat_mode

Method cmd_chat_mode

aider/commands.py:138–203  ·  view source on GitHub ↗

Switch to a new chat mode

(self, args)

Source from the content-addressed store, hash-verified

136 raise SwitchCoder(main_model=model)
137
138 def cmd_chat_mode(self, args):
139 "Switch to a new chat mode"
140
141 from aider import coders
142
143 ef = args.strip()
144 valid_formats = OrderedDict(
145 sorted(
146 (
147 coder.edit_format,
148 coder.__doc__.strip().split("\n")[0] if coder.__doc__ else "No description",
149 )
150 for coder in coders.__all__
151 if getattr(coder, "edit_format", None)
152 )
153 )
154
155 show_formats = OrderedDict(
156 [
157 ("help", "Get help about using aider (usage, config, troubleshoot)."),
158 ("ask", "Ask questions about your code without making any changes."),
159 ("code", "Ask for changes to your code (using the best edit format)."),
160 (
161 "architect",
162 (
163 "Work with an architect model to design code changes, and an editor to make"
164 " them."
165 ),
166 ),
167 (
168 "context",
169 "Automatically identify which files will need to be edited.",
170 ),
171 ]
172 )
173
174 if ef not in valid_formats and ef not in show_formats:
175 if ef:
176 self.io.tool_error(f'Chat mode "{ef}" should be one of these:\n')
177 else:
178 self.io.tool_output("Chat mode should be one of these:\n")
179
180 max_format_length = max(len(format) for format in valid_formats.keys())
181 for format, description in show_formats.items():
182 self.io.tool_output(f"- {format:<{max_format_length}} : {description}")
183
184 self.io.tool_output("\nOr a valid edit format:\n")
185 for format, description in valid_formats.items():
186 if format not in show_formats:
187 self.io.tool_output(f"- {format:<{max_format_length}} : {description}")
188
189 return
190
191 summarize_from_coder = True
192 edit_format = ef
193
194 if ef == "code":
195 edit_format = self.coder.main_model.edit_format

Callers 1

_generic_chat_commandMethod · 0.95

Calls 3

SwitchCoderClass · 0.85
tool_errorMethod · 0.45
tool_outputMethod · 0.45

Tested by

no test coverage detected