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

Class SystemPromptBuilder

mini_claude_code/prompt.py:234–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232# ============================================================
233
234class SystemPromptBuilder:
235 def __init__(self):
236 self._os_name: Optional[str] = None
237 self._os_version: Optional[str] = None
238 self._project_context: Optional[ProjectContext] = None
239 self._config = None # RuntimeConfig, 用 duck typing 避免循环依赖
240 self._append_sections: list[str] = []
241
242 def with_os(self, name: str, version: str) -> "SystemPromptBuilder":
243 """源码: prompt.rs:109-113"""
244 self._os_name = name
245 self._os_version = version
246 return self
247
248 def with_project_context(self, ctx: ProjectContext) -> "SystemPromptBuilder":
249 """源码: prompt.rs:116-119"""
250 self._project_context = ctx
251 return self
252
253 def with_config(self, config) -> "SystemPromptBuilder":
254 """源码: prompt.rs:122-125"""
255 self._config = config
256 return self
257
258 def append_section(self, section: str) -> "SystemPromptBuilder":
259 """源码: prompt.rs:128-131"""
260 self._append_sections.append(section)
261 return self
262
263 def build(self) -> list[str]:
264 """构建系统提示词分段列表。源码: prompt.rs:134-156
265
266 结构:
267 [0-4] 静态部分 (可缓存)
268 [---] DYNAMIC_BOUNDARY
269 [5+] 动态部分 (每次可能变)
270 """
271 sections: list[str] = []
272
273 # --- 静态部分 (边界以上,可缓存) ---
274 sections.append(self._intro_section())
275 sections.append(self._system_section())
276 sections.append(self._doing_tasks_section())
277 sections.append(self._actions_section())
278
279 # --- 动态边界 ---
280 sections.append(SYSTEM_PROMPT_DYNAMIC_BOUNDARY)
281
282 # --- 动态部分 (边界以下) ---
283 sections.append(self._environment_section())
284
285 if self._project_context is not None:
286 sections.append(self._render_project_context())
287 if self._project_context.instruction_files:
288 sections.append(self._render_instruction_files())
289
290 if self._config is not None:
291 sections.append(self._render_config_section())

Callers 1

build_system_promptFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected