Build a context prompt string (legacy API). Uses the new WS-5 context system under the hood. For new code, prefer fetch_system_prompt_parts() directly.
(
workspace_root: str | Path,
*,
cwd: str | Path | None = None,
)
| 14 | |
| 15 | |
| 16 | def build_context_prompt( |
| 17 | workspace_root: str | Path, |
| 18 | *, |
| 19 | cwd: str | Path | None = None, |
| 20 | ) -> str: |
| 21 | """ |
| 22 | Build a context prompt string (legacy API). |
| 23 | |
| 24 | Uses the new WS-5 context system under the hood. |
| 25 | For new code, prefer fetch_system_prompt_parts() directly. |
| 26 | """ |
| 27 | root = Path(workspace_root).expanduser().resolve() |
| 28 | current = Path(cwd).expanduser().resolve() if cwd is not None else root |
| 29 | |
| 30 | sections: list[str] = [] |
| 31 | |
| 32 | # Workspace info section |
| 33 | sections.append(_build_workspace_section(root, current)) |
| 34 | |
| 35 | # Git context (sync wrapper around async collect) |
| 36 | git_section = _build_git_section(str(root)) |
| 37 | if git_section: |
| 38 | sections.append(git_section) |
| 39 | |
| 40 | # CLAUDE.md context (sync wrapper around async get_memory_files) |
| 41 | claude_section = _build_claude_md_section(str(current), root) |
| 42 | if claude_section: |
| 43 | sections.append(claude_section) |
| 44 | |
| 45 | return "\n\n".join(section for section in sections if section.strip()) |
| 46 | |
| 47 | |
| 48 | def _run_async(coro): |