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[]- Code node types: file, function, class, module, concept
- Non-code node types: config, document, service, table, endpoint, pipeline, schema, resource
- Domain/knowledge node types: domain, flow, step, article, entity, topic, claim, source
- IDs use the node type as prefix, e.g. ,
file:path,function:path:name,config:patharticle:path
- — each has {source, target, type, direction, weight}
edges[]- Key types: imports, contains, calls, depends_on, configures, documents, deploys, triggers, contains_flow, flow_step, related, cites
- — 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
- 非代码节点类型:config、document、service、table、endpoint、pipeline、schema、resource
- 领域/知识节点类型:domain、flow、step、article、entity、topic、claim、source
- ID以节点类型作为前缀,例如 、
file:path、function:path:name、config:patharticle:path
- — 每个边包含 {source, target, type, direction, weight}
edges[]- 核心类型:imports、contains、calls、depends_on、configures、documents、deploys、triggers、contains_flow、flow_step、related、cites
- — 每个层包含 {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或限制行数的读取方式,从文件顶部提取部分的内容作为上下文(包含name、description、languages、frameworks)。
"project" -
搜索相关节点——使用Grep在知识图谱文件中搜索用户查询的关键词:"$ARGUMENTS"
- 搜索字段:在图谱文件中执行
"name"grep -i "query_keyword" - 搜索字段以匹配语义内容
"summary" - 搜索数组以匹配主题
"tags" - 记录所有匹配节点的值
id
- 搜索
-
查找关联边——针对每个匹配的节点ID,在部分用Grep搜索该ID,以找到:
edges- 它导入或依赖的内容(下游)
- 调用或导入它的内容(上游)
- 这能为你提供查询内容周围的1跳子图谱
-
读取层上下文——用Grep搜索,了解匹配节点所属的架构层。
"layers" -
仅使用相关子图谱回答查询:
- 引用图谱中的具体文件、函数和关系
- 说明相关的架构层及其原因
- 内容要简洁但全面——将概念与实际代码位置关联起来
- 如果查询未匹配到任何节点,请告知用户,并建议使用图谱中的相关术语