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])
| 249 | """.strip() |
| 250 | |
| 251 | FILTER_FOLDERS_PROMPT = """ |
| 252 | Here is the list of relative paths of files, folders in 2-depth of project {project_name}: |
| 253 | ``` |
| 254 | {files} |
| 255 | ``` |
| 256 | |
| 257 | In order to analyze the core functionality of the project, we need to analyze the files, folders representing the core functionality of the project. |
| 258 | |
| 259 | Please 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 | |
| 261 | Reasoning at first, then return the list of relative paths in JSON format. |
| 262 | """ |
| 263 | |
| 264 | import logging |
| 265 | from collections import defaultdict |
| 266 | from typing import Any |
| 267 | |
| 268 | from codewiki.src.utils import file_manager |
| 269 | |
| 270 | logger = 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. |
| 276 | MAX_USER_PROMPT_CHARS = 900_000 |
| 277 | |
| 278 | MODULE_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 | |
| 285 | CODE_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. |
| 293 | ARTIFACT_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 | |
| 300 | REPO_OVERVIEW_ARTIFACT_ADDENDUM = """ |
| 301 | The repository also contains the following build, CI, container, packaging, manifest and configuration artifacts: |
| 302 | {artifact_index} |
| 303 | |
| 304 | Include 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 | |
| 307 | EXTENSION_TO_LANGUAGE = { |
| 308 | ".py": "python", |
no test coverage detected