MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / build_context_prompt

Function build_context_prompt

src/context_system/builder.py:16–45  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

14
15
16def 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
48def _run_async(coro):

Calls 5

_build_workspace_sectionFunction · 0.85
_build_git_sectionFunction · 0.85
_build_claude_md_sectionFunction · 0.85
joinMethod · 0.80
appendMethod · 0.45