mini-context-graph
它能做什么
这个系统可以构建一个会不断成长的知识库。它会把信息整理成一个内部“维基”,再生成一张由各个概念之间的联系组成的“图谱”,并保存原始文档以便随时检索。
适用场景
- ✓当你有大量文档需要整理和查阅时。
- ✓当你想建立一份持续更新的信息历史记录时。
- ✓当你想基于已经处理过的文档来回答问题时。
技能链接
https://github.com/github/awesome-copilot/blob/main/skills/mini-context-graph/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“帮我整理这些事故报告,并告诉我哪些问题会导致系统崩溃。”
每周 5 个新技能,1 分钟读完。
工作原理
它会阅读文档、提取重要信息并建立关联。然后,它会生成维基风格的摘要,以及一张展示数据关系的可视化图谱。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Mini Context Graph Skill
The Core Idea
Standard RAG re-discovers knowledge from scratch on every query. This skill is different:
- Wiki layer — The LLM writes and maintains persistent markdown pages (summaries, entity pages, topic syntheses). Cross-references are already there. The wiki gets richer with every ingest.
- Graph layer — Entities and relations are extracted once and stored as a navigable knowledge graph. BFS traversal answers structural queries without re-reading sources.
- Raw source layer — Original documents are stored immutably with chunks. Provenance links tie every graph node and edge back to the exact text that supports it.
The LLM writes; the Python tools handle all bookkeeping.
Three Layers
| Layer | Where | What the LLM does | What Python does |
|---|---|---|---|
| Raw Sources | data/documents.json |
Reads (never modifies) | Stores chunks + metadata |
| Wiki | wiki/ (markdown) |
Writes/updates pages | Manages index.md + log.md |
| Graph | data/graph.json |
Extracts entities + relations | Persists, deduplicates, traverses |
⚡ Quick Start for Agents
A complete runnable version of this workflow is in scripts/template_agent_workflow.py — copy and adapt it.
from scripts.contextgraph import ContextGraphSkill
from scripts.tools import wiki_store
skill = ContextGraphSkill()
# ===== INGEST WITH FULL RAG + WIKI =====
# 1. Read references/ingestion.md and references/ontology.md first
# 2. Extract entities and relations (LLM reasoning step)
entities = [
{"name": "memory leak", "type": "issue", "supporting_text": "memory leaks cause crashes"},
{"name": "system crash", "type": "issue", "supporting_text": "system crashes due to memory leaks"},
]
relations = [
{"source": "memory leak", "target": "system crash", "type": "causes",
"confidence": 1.0, "supporting_text": "System crashes due to memory leaks."},
]
result = skill.ingest_with_content(
doc_id="doc_001",
title="System Crash Analysis",
source="/docs/incident_report.pdf",
raw_content="System crashes due to memory leaks. Memory leaks occur when objects are not released.",
entities=entities,
relations=relations,
)
# result = {"doc_id": "doc_001", "chunk_count": 1, "nodes_added": 2, "edges_added": 1}
# 3. Write a wiki summary page for this document
wiki_store.write_page(
category="summary",
title="System Crash Analysis Summary",
content="""---
title: System Crash Analysis
source_document: doc_001
tags: [summary, incident]
---
# System Crash Analysis
**Source:** incident_report.pdf
## Key Claims
- [[memory-leak]] causes [[system-crash]] (confidence: 1.0)
## Entities
- [[memory-leak]] (issue)
- [[system-crash]] (issue)
""",
summary="Incident report: memory leaks cause system crashes.",
)
# ===== QUERY WITH EVIDENCE =====
result = skill.query_with_evidence("Why does the system crash?")
# Returns: {"query": ..., "subgraph": ..., "supporting_documents": [...], "evidence_chain": ...}
# ===== WIKI SEARCH (read wiki before answering) =====
pages = wiki_store.search_wiki("memory leak")
# Returns: [{slug, category, path, snippet}, ...]
Operations
Ingest
When a user provides a new document:
- Read
references/ingestion.md— entity/relation extraction rules. - Read
references/ontology.md— type normalization rules. - Extract entities and relations using your LLM reasoning.
- Call
skill.ingest_with_content(...)— stores raw content + chunks + graph nodes + provenance. - Write a wiki summary page using
wiki_store.write_page(category="summary", ...). - Update entity pages — for each new/updated entity, write or update
wiki_store.write_page(category="entity", ...). - Update topic pages if the document touches an existing synthesis topic.
- A single document ingest will typically touch 3–10 wiki pages.
Query
When a user asks a question:
- Check the wiki first —
wiki_store.search_wiki(query)to find relevant pages. Read them. - If the wiki has a good answer, synthesize from wiki pages (fast path).
- If deeper graph traversal is needed, call
skill.query_with_evidence(query). - Return the answer with evidence citations from
supporting_documents. - If the answer is valuable, file it back as a new wiki topic page.
Lint
Periodically health-check the wiki:
from scripts.tools import wiki_store
…
常见问题
什么是“知识图谱”?
它就像一张地图,展示了不同信息(比如人物、地点、概念)之间是如何相互关联的。
为什么要保存原始文档?
这样可以确保回答基于真实事实,也便于核实信息的来源。
知识库是如何“成长”的?
每添加一份新文档,系统都会学到更多内容并建立新的关联,让知识库变得更加完整、更有用。
详情
作者的原始描述
A persistent, compounding knowledge base combining Karpathy's LLM Wiki pattern with a structured knowledge graph. Ingest documents once — the LLM writes wiki pages, extracts entities/relations into the graph, and stores raw content for evidence retrieval. Knowledge accumulates and cross-references; it is never re-derived from scratch.
repo: github/awesome-copilot
热度
- GitHub 星标
- 40k
- 排名
- #7297
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
acquire-codebase-knowledge
40k帮你的智能体理解并编写现有代码项目的文档。它有助于新成员快速上手,或者快速了解项目架构。
acreadiness-assess
40k让你的智能体评估一个项目对 AI 的准备程度,并生成报告。它有助于了解项目在使用 AI 工具方面的准备情况。
acreadiness-generate-instructions
40k帮你的智能体根据评估结果编写 AI 工具的指令文件。它有助于改善 AI 与代码的交互方式,并弥补已发现的不足。
acreadiness-policy
40k让你的智能体协助制定或应用 AI 项目评估的政策。它有助于规范项目的评估方式,并确保合规。