understand-chat
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese/understand-chat
/understand-chat
Answer questions about this codebase using the knowledge graph at .
.understand-anything/knowledge-graph.json借助中的知识图谱,回答关于此代码库的问题。
.understand-anything/knowledge-graph.jsonGraph Structure Reference
图谱结构参考
The knowledge graph JSON has this structure:
- — {name, description, languages, frameworks, analyzedAt, gitCommitHash}
project - — each has {id, type, name, filePath, summary, tags[], complexity, languageNotes?}
nodes[]- Node types: file, function, class, module, concept
- IDs: ,
file:path,func:path:nameclass:path:name
- — each has {source, target, type, direction, weight}
edges[]- Key types: imports, contains, calls, depends_on
- — each has {id, name, description, nodeIds[]}
layers[] - — each has {order, title, description, nodeIds[]}
tour[]
知识图谱JSON的结构如下:
- — {name, description, languages, frameworks, analyzedAt, gitCommitHash}
project - — 每个节点包含{id, type, name, filePath, summary, tags[], complexity, languageNotes?}
nodes[]- 节点类型:file、function、class、module、concept
- ID格式:、
file:path、func:path:nameclass:path:name
- — 每条边包含{source, target, type, direction, weight}
edges[]- 主要边类型:imports、contains、calls、depends_on
- — 每个层级包含{id, name, description, nodeIds[]}
layers[] - — 每个导览项包含{order, title, description, nodeIds[]}
tour[]
How to Read Efficiently
高效阅读方法
- Use Grep to search within the JSON for relevant entries BEFORE reading the full file
- Only read sections you need — don't dump the entire graph into context
- Node names and summaries are the most useful fields for understanding
- Edges tell you how components connect — follow imports and calls for dependency chains
- 在通读整个文件之前,先用Grep在JSON中搜索相关条目
- 只阅读你需要的部分——不要将整个图谱都加载到上下文里
- 节点名称和摘要部分是理解代码最有用的字段
- 边信息展示了组件之间的关联——通过imports和calls追踪依赖链
Instructions
操作步骤
-
Check thatexists in the current project root. If not, tell the user to run
.understand-anything/knowledge-graph.jsonfirst./understand -
Read project metadata only — use Grep or Read with a line limit to extract just thesection from the top of the file for context (name, description, languages, frameworks).
"project" -
Search for relevant nodes — use Grep to search the knowledge graph file for the user's query keywords: "$ARGUMENTS"
- Search fields:
"name"in the graph filegrep -i "query_keyword" - Search fields for semantic matches
"summary" - Search arrays for topic matches
"tags" - Note the values of all matching nodes
id
- Search
-
Find connected edges — for each matched node ID, Grep for that ID in thesection to find:
edges- What it imports or depends on (downstream)
- What calls or imports it (upstream)
- This gives you the 1-hop subgraph around the query
-
Read layer context — Grep forto understand which architectural layers the matched nodes belong to.
"layers" -
Answer the query using only the relevant subgraph:
- Reference specific files, functions, and relationships from the graph
- Explain which layer(s) are relevant and why
- Be concise but thorough — link concepts to actual code locations
- If the query doesn't match any nodes, say so and suggest related terms from the graph
-
检查当前项目根目录下是否存在。如果不存在,告知用户先运行
.understand-anything/knowledge-graph.json命令。/understand -
仅读取项目元数据——使用Grep或限制行数的读取方式,从文件顶部提取部分的内容作为上下文(包括名称、描述、使用的语言和框架)。
"project" -
搜索相关节点——使用Grep在知识图谱文件中搜索用户查询的关键词:"$ARGUMENTS"
- 搜索字段:在图谱文件中使用
"name"命令grep -i "query_keyword" - 搜索字段以找到语义匹配的内容
"summary" - 搜索数组以找到主题匹配的内容
"tags" - 记录所有匹配节点的值
id
- 搜索
-
查找关联的边——对于每个匹配的节点ID,在部分中用Grep搜索该ID,以找到:
edges- 它导入或依赖的内容(下游)
- 调用或导入它的内容(上游)
- 这将为你提供查询内容周围的1跳子图谱
-
读取层级上下文——使用Grep搜索部分,以了解匹配节点所属的架构层级。
"layers" -
仅使用相关子图谱回答查询:
- 引用图谱中的具体文件、函数和关系
- 说明哪些层级相关以及原因
- 表述简洁但全面——将概念与实际代码位置关联起来
- 如果查询未匹配到任何节点,告知用户这一情况,并建议使用图谱中的相关术语