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.json
中的知识图谱,回答关于此代码库的问题。

Graph Structure Reference

图谱结构参考

The knowledge graph JSON has this structure:
  • project
    — {name, description, languages, frameworks, analyzedAt, gitCommitHash}
  • nodes[]
    — each has {id, type, name, filePath, summary, tags[], complexity, languageNotes?}
    • Node types: file, function, class, module, concept
    • IDs:
      file:path
      ,
      func:path:name
      ,
      class:path:name
  • edges[]
    — each has {source, target, type, direction, weight}
    • Key types: imports, contains, calls, depends_on
  • layers[]
    — each has {id, name, description, nodeIds[]}
  • tour[]
    — each has {order, title, description, nodeIds[]}
知识图谱JSON的结构如下:
  • project
    — {name, description, languages, frameworks, analyzedAt, gitCommitHash}
  • nodes[]
    — 每个节点包含{id, type, name, filePath, summary, tags[], complexity, languageNotes?}
    • 节点类型:file、function、class、module、concept
    • ID格式:
      file:path
      func:path:name
      class:path:name
  • edges[]
    — 每条边包含{source, target, type, direction, weight}
    • 主要边类型:imports、contains、calls、depends_on
  • layers[]
    — 每个层级包含{id, name, description, nodeIds[]}
  • tour[]
    — 每个导览项包含{order, title, description, nodeIds[]}

How to Read Efficiently

高效阅读方法

  1. Use Grep to search within the JSON for relevant entries BEFORE reading the full file
  2. Only read sections you need — don't dump the entire graph into context
  3. Node names and summaries are the most useful fields for understanding
  4. Edges tell you how components connect — follow imports and calls for dependency chains
  1. 在通读整个文件之前,先用Grep在JSON中搜索相关条目
  2. 只阅读你需要的部分——不要将整个图谱都加载到上下文里
  3. 节点名称和摘要部分是理解代码最有用的字段
  4. 边信息展示了组件之间的关联——通过imports和calls追踪依赖链

Instructions

操作步骤

  1. Check that
    .understand-anything/knowledge-graph.json
    exists in the current project root. If not, tell the user to run
    /understand
    first.
  2. Read project metadata only — use Grep or Read with a line limit to extract just the
    "project"
    section from the top of the file for context (name, description, languages, frameworks).
  3. Search for relevant nodes — use Grep to search the knowledge graph file for the user's query keywords: "$ARGUMENTS"
    • Search
      "name"
      fields:
      grep -i "query_keyword"
      in the graph file
    • Search
      "summary"
      fields for semantic matches
    • Search
      "tags"
      arrays for topic matches
    • Note the
      id
      values of all matching nodes
  4. Find connected edges — for each matched node ID, Grep for that ID in the
    edges
    section to find:
    • What it imports or depends on (downstream)
    • What calls or imports it (upstream)
    • This gives you the 1-hop subgraph around the query
  5. Read layer context — Grep for
    "layers"
    to understand which architectural layers the matched nodes belong to.
  6. 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
  1. 检查当前项目根目录下是否存在
    .understand-anything/knowledge-graph.json
    。如果不存在,告知用户先运行
    /understand
    命令。
  2. 仅读取项目元数据——使用Grep或限制行数的读取方式,从文件顶部提取
    "project"
    部分的内容作为上下文(包括名称、描述、使用的语言和框架)。
  3. 搜索相关节点——使用Grep在知识图谱文件中搜索用户查询的关键词:"$ARGUMENTS"
    • 搜索
      "name"
      字段:在图谱文件中使用
      grep -i "query_keyword"
      命令
    • 搜索
      "summary"
      字段以找到语义匹配的内容
    • 搜索
      "tags"
      数组以找到主题匹配的内容
    • 记录所有匹配节点的
      id
  4. 查找关联的边——对于每个匹配的节点ID,在
    edges
    部分中用Grep搜索该ID,以找到:
    • 它导入或依赖的内容(下游)
    • 调用或导入它的内容(上游)
    • 这将为你提供查询内容周围的1跳子图谱
  5. 读取层级上下文——使用Grep搜索
    "layers"
    部分,以了解匹配节点所属的架构层级。
  6. 仅使用相关子图谱回答查询
    • 引用图谱中的具体文件、函数和关系
    • 说明哪些层级相关以及原因
    • 表述简洁但全面——将概念与实际代码位置关联起来
    • 如果查询未匹配到任何节点,告知用户这一情况,并建议使用图谱中的相关术语