MCPcopy Create free account
hub / github.com/FSoft-AI4Code/CodeWiki / format_user_prompt

Function format_user_prompt

codewiki/src/be/prompt_template.py:251–327  ·  view source on GitHub ↗

Format the user prompt with module name and organized core component codes. Args: module_name: Name of the module to document core_component_ids: List of component IDs to include components: Dictionary mapping component IDs to CodeComponent objects Retu

(module_name: str, core_component_ids: list[str], components: Dict[str, Any], module_tree: dict[str, any])

Source from the content-addressed store, hash-verified

249""".strip()
250
251FILTER_FOLDERS_PROMPT = """
252Here is the list of relative paths of files, folders in 2-depth of project {project_name}:
253```
254{files}
255```
256
257In order to analyze the core functionality of the project, we need to analyze the files, folders representing the core functionality of the project.
258
259Please shortlist the files, folders representing the core functionality and ignore the files, folders that are not essential to the core functionality of the project (e.g. test files, documentation files, etc.) from the list above.
260
261Reasoning at first, then return the list of relative paths in JSON format.
262"""
263
264import logging
265from collections import defaultdict
266from typing import Any
267
268from codewiki.src.utils import file_manager
269
270logger = logging.getLogger(__name__)
271
272# codex rejects any turn whose total input exceeds 1,048,576 characters
273# (input_too_large, code -32602 — server-side, not configurable). Cap the
274# user prompt below that, leaving headroom for the system prompt, tool
275# schemas and protocol overhead.
276MAX_USER_PROMPT_CHARS = 900_000
277
278MODULE_TREE_TRIMMED_NOTE = (
279 "NOTE: per-module component listings were omitted because the full module "
280 "tree exceeds the model input limit. Module names and hierarchy are "
281 "complete; read the referenced modules' documentation files or use your "
282 "code-reading tools when you need component-level detail."
283)
284
285CODE_TRUNCATED_NOTE = (
286 "\n... [file contents truncated to fit the model input limit — use your "
287 "file-reading tools to read the full files]"
288)
289
290# Appended to the user prompt (after USER_PROMPT) when the dependency graph
291# contains artifact nodes. Kept out of USER_PROMPT itself so callers that
292# format the template directly (MCP prompt server) keep working.
293ARTIFACT_USAGE_NOTE = (
294 "* NOTE: when this module's behaviour depends on how the system is built, "
295 "configured, packaged, deployed or tested, read the relevant artifact file "
296 'with `str_replace_editor` (`command="view"`, `working_dir="repo"`, path as '
297 "listed above) and cite the file path in the documentation."
298)
299
300REPO_OVERVIEW_ARTIFACT_ADDENDUM = """
301The repository also contains the following build, CI, container, packaging, manifest and configuration artifacts:
302{artifact_index}
303
304Include a short section titled "How it is built and run" that summarises how the project is built, tested, packaged and deployed, and links to the module documentation that covers these artifacts (for example a `Build, Deployment and Configuration` module) instead of repeating its content.
305""".strip()
306
307EXTENSION_TO_LANGUAGE = {
308 ".py": "python",

Callers 3

run_module_agentMethod · 0.90

Calls 3

_format_module_treeFunction · 0.85
load_textMethod · 0.80
formatMethod · 0.80

Tested by

no test coverage detected