Generate a compact human-readable description for a graph node.
(label: str, source_file: str, file_type: str, lang: str)
| 1335 | |
| 1336 | |
| 1337 | def _describe_node(label: str, source_file: str, file_type: str, lang: str) -> str: |
| 1338 | """Generate a compact human-readable description for a graph node.""" |
| 1339 | lower = label.lower() |
| 1340 | source = source_file or pick_text(lang, "项目", "project") |
| 1341 | if file_type == "rationale": |
| 1342 | return pick_text(lang, f"设计说明:{label}", f"Design note for {label}.") |
| 1343 | if file_type == "document": |
| 1344 | return pick_text(lang, f"文档入口,描述 {label} 相关能力。", f"Documentation node describing {label}.") |
| 1345 | if label.endswith(".py") or label.endswith(".tsx") or label.endswith(".ts"): |
| 1346 | return pick_text(lang, f"{source} 中的模块文件,承载该层主要实现。", f"Module file in {source}.") |
| 1347 | if "config" in lower: |
| 1348 | return pick_text(lang, "读取、解析或持久化项目配置。", "Reads, resolves, or persists project configuration.") |
| 1349 | if "scan" in lower: |
| 1350 | return pick_text(lang, "触发项目扫描或处理扫描状态。", "Starts scanning or handles scan status.") |
| 1351 | if "ingest" in lower or "clone" in lower or "git" in lower: |
| 1352 | return pick_text(lang, "把本地目录或远程仓库转换为分析上下文。", "Turns a local path or remote repository into analysis context.") |
| 1353 | if "prompt" in lower: |
| 1354 | return pick_text(lang, "构造发送给 LLM 的结构化提示。", "Builds structured prompts for model calls.") |
| 1355 | if "analy" in lower: |
| 1356 | return pick_text(lang, "编排分析流程并产出结构化文档数据。", "Orchestrates analysis and returns structured documentation data.") |
| 1357 | if "graph" in lower or "dependency" in lower: |
| 1358 | return pick_text(lang, "构建依赖关系并提供排序或图形化数据。", "Builds dependency relationships and graph data.") |
| 1359 | if "export" in lower or "markdown" in lower or "html" in lower: |
| 1360 | return pick_text(lang, "将文档数据导出为目标格式。", "Exports documentation data to a target format.") |
| 1361 | if "chat" in lower or "rag" in lower or "retrieve" in lower: |
| 1362 | return pick_text(lang, "支撑检索增强问答或流式聊天。", "Supports retrieval-augmented Q&A or streaming chat.") |
| 1363 | if "wiki" in lower or "page" in lower or "sidebar" in lower: |
| 1364 | return pick_text(lang, "组织文档页面、侧边栏或内容读取。", "Organizes documentation pages, navigation, or content lookup.") |
| 1365 | if "cache" in lower or "hash" in lower: |
| 1366 | return pick_text(lang, "缓存分析结果或生成缓存键。", "Caches analysis results or computes cache keys.") |
| 1367 | if "test" in lower: |
| 1368 | return pick_text(lang, "验证导入、入口点或版本等基础行为。", "Verifies imports, entry points, or version behavior.") |
| 1369 | return pick_text(lang, f"{source} 中的 {label} 节点。", f"{label} node in {source}.") |
| 1370 | |
| 1371 | |
| 1372 | def generate_header(sections: list, meta: dict, lang: str) -> str: |
no test coverage detected