MCPcopy Create free account
hub / github.com/Louisym/MiniCC / build

Method build

tutorials/06_system_prompt_builder.py:328–369  ·  view source on GitHub ↗

组装所有部分,生成最终的 system prompt。 返回一个字符串列表,每个元素是一个"段落"。 对应源码: prompt.rs:134-156

(self)

Source from the content-addressed store, hash-verified

326 return self
327
328 def build(self) -> list[str]:
329 """
330 组装所有部分,生成最终的 system prompt。
331
332 返回一个字符串列表,每个元素是一个"段落"
333 对应源码: prompt.rs:134-156
334 """
335 sections = []
336
337 # 第 1 层:角色介绍(固定)
338 sections.append(
339 "You are an interactive agent that helps users with software engineering tasks. "
340 "Use the instructions below and the tools available to you to assist the user."
341 )
342
343 # 第 2 层:系统规则(固定)
344 sections.append(self._system_section())
345
346 # 第 3 层:任务准则(固定)
347 sections.append(self._doing_tasks_section())
348
349 # 第 4 层:操作安全(固定)
350 sections.append(self._actions_section())
351
352 # ═══ 动态分界线 ═══
353 sections.append(DYNAMIC_BOUNDARY)
354
355 # 第 5 层:环境信息(动态)
356 sections.append(self._environment_section())
357
358 # 第 6 层:项目上下文(动态)
359 if self._project_context:
360 sections.append(self._project_context_section())
361
362 # 第 7 层:指令文件(动态)
363 if self._project_context.instruction_files:
364 sections.append(self._instruction_files_section())
365
366 # 第 8 层:额外段落
367 sections.extend(self._extra_sections)
368
369 return sections
370
371 def render(self) -> str:
372 """把所有段落拼成一个完整的字符串(段落之间用两个换行分隔)"""

Callers 2

renderMethod · 0.95
mainFunction · 0.45

Calls 7

_system_sectionMethod · 0.95
_doing_tasks_sectionMethod · 0.95
_actions_sectionMethod · 0.95
_environment_sectionMethod · 0.95
appendMethod · 0.80

Tested by

no test coverage detected