@daogee/mdgraph 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/LICENSE +21 -0
- package/README-ZH.md +203 -0
- package/README.md +203 -0
- package/agent-pack/README.md +26 -0
- package/agent-pack/host-examples.md +71 -0
- package/agent-pack/mcp-config.example.json +14 -0
- package/agent-pack/mdgraph-agent-instructions.md +21 -0
- package/agent-pack/prompts/relationship-trace.md +12 -0
- package/agent-pack/prompts/status-doctor.md +13 -0
- package/agent-pack/prompts/task-start-context.md +15 -0
- package/dist/analysis/doctor-scope.d.ts +8 -0
- package/dist/analysis/doctor-scope.js +109 -0
- package/dist/analysis/doctor.d.ts +148 -0
- package/dist/analysis/doctor.js +919 -0
- package/dist/analysis/status-freshness.d.ts +13 -0
- package/dist/analysis/status-freshness.js +55 -0
- package/dist/benchmark/benchmark.d.ts +118 -0
- package/dist/benchmark/benchmark.js +357 -0
- package/dist/bin/mdgraph.d.ts +2 -0
- package/dist/bin/mdgraph.js +877 -0
- package/dist/bundle/bundle.d.ts +66 -0
- package/dist/bundle/bundle.js +320 -0
- package/dist/config/limits.d.ts +24 -0
- package/dist/config/limits.js +24 -0
- package/dist/config/load-config.d.ts +14 -0
- package/dist/config/load-config.js +177 -0
- package/dist/db/connection.d.ts +15 -0
- package/dist/db/connection.js +145 -0
- package/dist/db/repositories.d.ts +159 -0
- package/dist/db/repositories.js +929 -0
- package/dist/db/schema.sql +110 -0
- package/dist/db/sqlite-adapter.d.ts +18 -0
- package/dist/db/sqlite-adapter.js +60 -0
- package/dist/diff/graph-diff.d.ts +41 -0
- package/dist/diff/graph-diff.js +334 -0
- package/dist/evaluation/retrieval-eval.d.ts +115 -0
- package/dist/evaluation/retrieval-eval.js +399 -0
- package/dist/export/diagram.d.ts +11 -0
- package/dist/export/diagram.js +41 -0
- package/dist/export/graphjson.d.ts +89 -0
- package/dist/export/graphjson.js +299 -0
- package/dist/export/markdown-index.d.ts +21 -0
- package/dist/export/markdown-index.js +89 -0
- package/dist/export/source-bridge.d.ts +22 -0
- package/dist/export/source-bridge.js +83 -0
- package/dist/extraction/entity-extractor.d.ts +12 -0
- package/dist/extraction/entity-extractor.js +153 -0
- package/dist/extraction/graph-builder.d.ts +2 -0
- package/dist/extraction/graph-builder.js +168 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +28 -0
- package/dist/indexer.d.ts +19 -0
- package/dist/indexer.js +100 -0
- package/dist/mcp/debug.d.ts +7 -0
- package/dist/mcp/debug.js +41 -0
- package/dist/mcp/server-instructions.d.ts +2 -0
- package/dist/mcp/server-instructions.js +40 -0
- package/dist/mcp/server.d.ts +28 -0
- package/dist/mcp/server.js +232 -0
- package/dist/mcp/tools.d.ts +31 -0
- package/dist/mcp/tools.js +506 -0
- package/dist/mcp/transport.d.ts +50 -0
- package/dist/mcp/transport.js +88 -0
- package/dist/parser/frontmatter.d.ts +10 -0
- package/dist/parser/frontmatter.js +191 -0
- package/dist/parser/links.d.ts +6 -0
- package/dist/parser/links.js +9 -0
- package/dist/parser/markdown-parser.d.ts +2 -0
- package/dist/parser/markdown-parser.js +267 -0
- package/dist/query/context-builder.d.ts +85 -0
- package/dist/query/context-builder.js +413 -0
- package/dist/query/search.d.ts +32 -0
- package/dist/query/search.js +237 -0
- package/dist/query/trace.d.ts +10 -0
- package/dist/query/trace.js +55 -0
- package/dist/reporting/report.d.ts +49 -0
- package/dist/reporting/report.js +143 -0
- package/dist/resolution/link-resolver.d.ts +17 -0
- package/dist/resolution/link-resolver.js +113 -0
- package/dist/scanner/file-scanner.d.ts +4 -0
- package/dist/scanner/file-scanner.js +144 -0
- package/dist/semantic/local-embedding.d.ts +4 -0
- package/dist/semantic/local-embedding.js +30 -0
- package/dist/semantic/status.d.ts +19 -0
- package/dist/semantic/status.js +70 -0
- package/dist/semantic/vector-codec.d.ts +3 -0
- package/dist/semantic/vector-codec.js +35 -0
- package/dist/types.d.ts +198 -0
- package/dist/types.js +15 -0
- package/dist/utils/bounded-json.d.ts +9 -0
- package/dist/utils/bounded-json.js +57 -0
- package/dist/utils/content-risk.d.ts +5 -0
- package/dist/utils/content-risk.js +20 -0
- package/dist/utils/fts.d.ts +3 -0
- package/dist/utils/fts.js +52 -0
- package/dist/utils/id.d.ts +2 -0
- package/dist/utils/id.js +8 -0
- package/dist/utils/path-safety.d.ts +4 -0
- package/dist/utils/path-safety.js +25 -0
- package/dist/utils/text.d.ts +7 -0
- package/dist/utils/text.js +36 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +11 -0
- package/dist/watcher/file-watcher.d.ts +11 -0
- package/dist/watcher/file-watcher.js +127 -0
- package/docs/EN/Agent_Integration.md +129 -0
- package/docs/EN/Architecture.md +135 -0
- package/docs/EN/Evaluation_Questions.md +68 -0
- package/docs/EN/Output_Contracts.md +274 -0
- package/docs/EN/Public_Contracts.md +88 -0
- package/docs/EN/Public_Contracts_1.0.md +234 -0
- package/docs/EN/Release_Checklist.md +82 -0
- package/docs/ZH/Agent_Integration.md +105 -0
- package/docs/ZH/Architecture.md +124 -0
- package/docs/ZH/Evaluation_Questions.md +66 -0
- package/docs/ZH/Output_Contracts.md +269 -0
- package/docs/ZH/Public_Contracts.md +81 -0
- package/docs/ZH/Public_Contracts_1.0.md +202 -0
- package/docs/ZH/Release_Checklist.md +83 -0
- package/package.json +94 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to MDGraph are documented here. MDGraph follows semantic versioning for its public releases.
|
|
4
|
+
|
|
5
|
+
## 1.0.0 - 2026-07-12
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Deterministic Markdown graph extraction for documents, sections, entities, source references, chunks, and explainable edges.
|
|
10
|
+
- Local SQLite and FTS5 storage with hash-based incremental indexing and optional local semantic reranking.
|
|
11
|
+
- CLI workflows for initialization, indexing, status, search, context packing, node inspection, graph tracing, evaluation, export/import verification, bundles, reports, watch mode, and documentation health checks.
|
|
12
|
+
- Five MCP tools for search, context, node inspection, tracing, and freshness-aware status.
|
|
13
|
+
- Explainable retrieval with reasons, matched entities, provenance, confidence, source references, risk notes, freshness metadata, and context budgets.
|
|
14
|
+
- Deterministic GraphJSON, Mermaid trace, WikiLink Markdown, docs-site data, and generic JSON source-bridge exports.
|
|
15
|
+
- Public English and Chinese documentation, agent integration templates, contribution guidance, security reporting, and GitHub community templates.
|
|
16
|
+
|
|
17
|
+
### Compatibility
|
|
18
|
+
|
|
19
|
+
- Freezes the documented 1.0 CLI, MCP, config, JSON, graph record, and schema compatibility baseline.
|
|
20
|
+
- Requires Node.js `>=22.5.0` and keeps the core indexing and query pipeline local-first without mandatory cloud or LLM services.
|
|
21
|
+
|
|
22
|
+
### Distribution
|
|
23
|
+
|
|
24
|
+
- Publishes the public npm package as `@daogee/mdgraph` while retaining the `mdgraph` executable.
|
|
25
|
+
- Includes built runtime files, the agent pack, public English and Chinese docs, both README files, the changelog, and the MIT license.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 daoGEE
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README-ZH.md
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# MDGraph
|
|
4
|
+
|
|
5
|
+
### 寥寥数语,万千尽显。
|
|
6
|
+
|
|
7
|
+
**MDGraph 把项目 Markdown 转成本地、可解释的图谱,让代理知道该读什么、文档如何关联,以及每条结果为什么重要。**
|
|
8
|
+
|
|
9
|
+
[](https://opensource.org/licenses/MIT)
|
|
10
|
+
[](https://github.com/daoGEE/mdgraph/actions/workflows/ci.yml)
|
|
11
|
+
[](https://nodejs.org/)
|
|
12
|
+
[](https://github.com/daoGEE/mdgraph/releases)
|
|
13
|
+
|
|
14
|
+
<a href="./README.md">English</a> · <a href="./docs/ZH/Architecture.md">架构说明</a> · <a href="./docs/ZH/Agent_Integration.md">Agent 集成</a> · <a href="./docs/ZH/Public_Contracts.md">公开契约</a> · <a href="./docs/ZH/Output_Contracts.md">输出契约</a>
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 不要再让代理反复考古同一套架构
|
|
21
|
+
|
|
22
|
+
答案通常已经在仓库里,只是分散在一条 ADR、一份设计文档、一段 API 说明,以及那篇没人想起来打开的 runbook 里。
|
|
23
|
+
|
|
24
|
+
文本搜索只能找到相同词语。MDGraph 会找到词语背后的决策、相关文档和它们之间的路径,再把结果压缩成一份带明确来源和入选原因的上下文。
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
$ mdgraph context "Markdown 文件如何经过索引流程变成代理上下文?"
|
|
28
|
+
|
|
29
|
+
docs/EN/Architecture.md:49 · Indexing Flow
|
|
30
|
+
Reason: FTS5 content match; RRF fusion
|
|
31
|
+
|
|
32
|
+
1. scanMarkdownFiles 选择候选 Markdown 文件。
|
|
33
|
+
2. parseMarkdownDocument 读取 front matter 和文档结构。
|
|
34
|
+
3. buildGraphRecords 创建节点、chunks、vectors 和 edges。
|
|
35
|
+
4. GraphRepository 写入完整或增量更新。
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
一个问题,命中正确章节,还能看见原因——不是黑盒答案。
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 从安装到第一个答案
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install -g @daogee/mdgraph
|
|
46
|
+
mdgraph init --path /path/to/your/project --docs "docs/**/*.md"
|
|
47
|
+
mdgraph context --path /path/to/your/project "哪些 ADR 限制了身份认证设计?"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`init` 会创建可跟踪的 `.mdgraph/config.json`,通过 `.gitignore` 保护本地图谱产物,并完成第一次索引。Markdown 和 SQLite 图谱都留在你的机器上。
|
|
51
|
+
|
|
52
|
+
### 连接 AI 编码代理
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"mcpServers": {
|
|
57
|
+
"mdgraph": {
|
|
58
|
+
"type": "stdio",
|
|
59
|
+
"command": "mdgraph",
|
|
60
|
+
"args": [
|
|
61
|
+
"serve",
|
|
62
|
+
"--mcp",
|
|
63
|
+
"--path",
|
|
64
|
+
"/absolute/path/to/project"
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
服务会在启动时索引一次,并随 Markdown 变化保持图谱最新。如果 MCP 宿主没有继承终端的 `PATH`,请把 `mdgraph` 替换为 `which mdgraph`(macOS/Linux)或 `where mdgraph`(Windows)返回的绝对路径。
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 五个工具,一层完整的文档上下文
|
|
76
|
+
|
|
77
|
+
| 当代理需要…… | 它调用…… | 得到什么 |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| 找到决策、命令、路径、API 或错误 | `mdgraph_search` | 带匹配原因的排序结果 |
|
|
80
|
+
| 带着正确文档开始任务 | `mdgraph_context` | 受预算约束、有来源的上下文包 |
|
|
81
|
+
| 查看已知文档、章节或实体 | `mdgraph_node` | 已解析节点和来源信息 |
|
|
82
|
+
| 理解两个对象如何连接 | `mdgraph_trace` | 可解释的图谱路径 |
|
|
83
|
+
| 判断结果是否足够新鲜 | `mdgraph_status` | 索引可用性和新鲜度 |
|
|
84
|
+
|
|
85
|
+
MDGraph 从标题、front matter、Markdown 链接、WikiLink、内联代码、代码块和显式 source refs 中提取关系。核心索引是确定性的:不依赖 LLM 生成摘要,也不要求远程 embedding 服务。
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 填补“搜到词语”和“理解项目”之间的空白
|
|
90
|
+
|
|
91
|
+
| 工具 | 最擅长 | MDGraph 补充什么 |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| `grep` / 文件搜索 | 精确文本和快速临时查找 | 文档关系、排序后的上下文、来源和新鲜度 |
|
|
94
|
+
| 向量 RAG | 在广泛内容中做模糊语义匹配 | 无需远程模型的确定性提取和本地检索 |
|
|
95
|
+
| 源代码图谱 | 符号、调用和实现结构 | 决策、runbook、规格说明等 Markdown 知识 |
|
|
96
|
+
|
|
97
|
+
MDGraph 不替代这些工具。它提供的是文档上下文层:补上源码本身无法承载的设计意图、架构决策、运维知识和跨文档关系。
|
|
98
|
+
|
|
99
|
+
### 给出证据,也保留证据的边界
|
|
100
|
+
|
|
101
|
+
- 仓库自有评估 fixtures 覆盖 ADR、设计、API、runbook、incident、source refs、被取代文档和 CJK 检索。
|
|
102
|
+
- 每个 search 和 context 结果都保留匹配原因;graph trace 保留边类型、来源和置信度。
|
|
103
|
+
- Linux 和 Windows 运行完整 CI 门禁,macOS 运行构建和包产物冒烟检查。
|
|
104
|
+
- `1.0.0` 的公开 CLI、MCP、配置、JSON 和 schema 已有明确兼容性基线。
|
|
105
|
+
|
|
106
|
+
这些是确定性的工程检查,不代表已经完成真实代理 benchmark。方法和限制详见[评估问题](./docs/ZH/Evaluation_Questions.md)和 [1.0 公开契约](./docs/ZH/Public_Contracts_1.0.md)。
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## 常用命令
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# 手动刷新图谱
|
|
114
|
+
mdgraph index --path /your/project
|
|
115
|
+
|
|
116
|
+
# 检查可用性、计数和新鲜度
|
|
117
|
+
mdgraph status --freshness --path /your/project
|
|
118
|
+
|
|
119
|
+
# CLI 搜索和上下文打包
|
|
120
|
+
mdgraph search --path /your/project "authentication timeout"
|
|
121
|
+
mdgraph context --path /your/project "why does RedisTimeoutError affect login"
|
|
122
|
+
|
|
123
|
+
# 解析单个节点或追溯图谱路径
|
|
124
|
+
mdgraph node --path /your/project "AuthService"
|
|
125
|
+
mdgraph trace --path /your/project "AuthService" "RedisTimeoutError"
|
|
126
|
+
|
|
127
|
+
# 文档健康检查
|
|
128
|
+
mdgraph doctor --path /your/project
|
|
129
|
+
mdgraph doctor --since origin/main --fail-on warn --json --path /your/project
|
|
130
|
+
|
|
131
|
+
# Agent 友好的使用指引
|
|
132
|
+
mdgraph usage --path /your/project
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
完整 CLI 参考请使用 `mdgraph help` 或 `mdgraph help <command>`。
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## 为什么团队可以信任它
|
|
140
|
+
|
|
141
|
+
- **默认留在本地。** Markdown、chunks、vectors 和 SQLite 产物都保留在项目环境中。
|
|
142
|
+
- **从设计上可解释。** 查询结果在相关位置保留匹配原因、实体、边来源、置信度、路径和预算信息。
|
|
143
|
+
- **核心流程确定性。** 同一份 Markdown 无需 LLM 即可生成稳定的图谱记录。
|
|
144
|
+
- **活跃工作中持续新鲜。** 基于哈希的增量索引只更新变化文档,MCP watch mode 让后续查询保持最新。
|
|
145
|
+
- **不回避风险。** `doctor` 会暴露失效链接、过期 source refs、缺失定义、内容风险、存储健康和陈旧索引。
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## 文档导航
|
|
150
|
+
|
|
151
|
+
- `docs/ZH/Architecture.md` — 流水线、模块边界、数据流和取舍。
|
|
152
|
+
- `docs/ZH/Agent_Integration.md` — MCP 配置、共享 agent 指令和宿主说明。
|
|
153
|
+
- `docs/ZH/Public_Contracts.md` — 稳定公开表面、兼容策略和发布门禁。
|
|
154
|
+
- `docs/ZH/Public_Contracts_1.0.md` — 1.0 契约冻结附录,列出当前 `1.0.0` 基线下冻结的 CLI、配置、MCP、JSON 与 schema 清单。
|
|
155
|
+
- `docs/ZH/Output_Contracts.md` — CLI 和 MCP 消费者使用的 JSON 输出形状。
|
|
156
|
+
- `docs/ZH/Evaluation_Questions.md` — 检索与评估问题。
|
|
157
|
+
- `docs/ZH/Release_Checklist.md` — 发布验证清单。
|
|
158
|
+
- `agent-pack/` — 可复用 MCP 配置、指令和 prompt 模板。
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## 社区参与
|
|
163
|
+
|
|
164
|
+
- 发现 bug 或有聚焦的功能建议?[提交 Issue](https://github.com/daoGEE/mdgraph/issues/new/choose)。
|
|
165
|
+
- 想改进 MDGraph?请阅读 [CONTRIBUTING.md](./CONTRIBUTING.md)。
|
|
166
|
+
- 发现安全问题?请按 [SECURITY.md](./SECURITY.md) 私下报告,不要公开敏感细节。
|
|
167
|
+
- 如果 MDGraph 对你的团队有帮助,欢迎 Star 仓库并分享实际工作流;真实案例是路线图最有价值的输入。
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## 环境要求
|
|
172
|
+
|
|
173
|
+
- Node.js `>=22.5.0`
|
|
174
|
+
- Node 内置 `node:sqlite` 支持
|
|
175
|
+
- 本地项目目录中的 Markdown 文件
|
|
176
|
+
|
|
177
|
+
当前 Node 版本可能会打印 `node:sqlite` 实验性警告。只要命令成功退出,该警告可视为信息提示。
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## 开发
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
npm install
|
|
185
|
+
npm run typecheck
|
|
186
|
+
npm test
|
|
187
|
+
npm run build
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
常用 smoke checks:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
npm run smoke:cli
|
|
194
|
+
npm run smoke:eval
|
|
195
|
+
npm run smoke:pack
|
|
196
|
+
npm run task:public-check
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## 许可证
|
|
202
|
+
|
|
203
|
+
MIT
|
package/README.md
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# MDGraph
|
|
4
|
+
|
|
5
|
+
### Your repository already explains itself. Make the connections visible to coding agents.
|
|
6
|
+
|
|
7
|
+
**MDGraph turns project Markdown into a local, explainable graph—so agents know what to read, how documents relate, and why each result matters.**
|
|
8
|
+
|
|
9
|
+
[](https://opensource.org/licenses/MIT)
|
|
10
|
+
[](https://github.com/daoGEE/mdgraph/actions/workflows/ci.yml)
|
|
11
|
+
[](https://nodejs.org/)
|
|
12
|
+
[](https://github.com/daoGEE/mdgraph/releases)
|
|
13
|
+
|
|
14
|
+
<a href="./README-ZH.md">简体中文</a> · <a href="./docs/EN/Architecture.md">Architecture</a> · <a href="./docs/EN/Agent_Integration.md">Agent Integration</a> · <a href="./docs/EN/Public_Contracts.md">Public Contracts</a> · <a href="./docs/EN/Output_Contracts.md">Output Contracts</a>
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Stop Rediscovering the Same Architecture
|
|
21
|
+
|
|
22
|
+
The answer is usually already in the repository—split across an ADR, a design doc, an API note, and the runbook nobody remembered to open.
|
|
23
|
+
|
|
24
|
+
Text search finds matching words. MDGraph finds the surrounding decision, the connected documents, and the path between them. It then gives the agent a compact context package with explicit reasons and provenance.
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
$ mdgraph context "How does indexing flow from Markdown files to agent context?"
|
|
28
|
+
|
|
29
|
+
docs/EN/Architecture.md:49 · Indexing Flow
|
|
30
|
+
Reason: FTS5 content match; RRF fusion
|
|
31
|
+
|
|
32
|
+
1. scanMarkdownFiles selects candidate Markdown files.
|
|
33
|
+
2. parseMarkdownDocument reads front matter and Markdown structure.
|
|
34
|
+
3. buildGraphRecords creates nodes, chunks, vectors, and edges.
|
|
35
|
+
4. GraphRepository writes a full or incremental update.
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
One question. The right section. A visible reason—not a black-box answer.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## From Install to First Answer
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install -g @daogee/mdgraph
|
|
46
|
+
mdgraph init --path /path/to/your/project --docs "docs/**/*.md"
|
|
47
|
+
mdgraph context --path /path/to/your/project "Which ADRs constrain the authentication design?"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`init` creates a trackable `.mdgraph/config.json`, protects local graph artifacts through `.gitignore`, and builds the first index. Your Markdown and SQLite graph stay on your machine.
|
|
51
|
+
|
|
52
|
+
### Connect an AI Coding Agent
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"mcpServers": {
|
|
57
|
+
"mdgraph": {
|
|
58
|
+
"type": "stdio",
|
|
59
|
+
"command": "mdgraph",
|
|
60
|
+
"args": [
|
|
61
|
+
"serve",
|
|
62
|
+
"--mcp",
|
|
63
|
+
"--path",
|
|
64
|
+
"/absolute/path/to/project"
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The server indexes on startup and keeps the graph fresh as Markdown changes. If your MCP host does not inherit the shell `PATH`, replace `mdgraph` with the absolute path reported by `which mdgraph` (macOS/Linux) or `where mdgraph` (Windows).
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Five Tools, One Documentation Layer
|
|
76
|
+
|
|
77
|
+
| When the agent needs to… | It calls… | What comes back |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| Find a decision, command, path, API, or error | `mdgraph_search` | Ranked matches with reasons |
|
|
80
|
+
| Start a task with the right documentation | `mdgraph_context` | A budgeted, source-backed context package |
|
|
81
|
+
| Inspect a known document, section, or entity | `mdgraph_node` | The resolved node and its provenance |
|
|
82
|
+
| Understand how two things connect | `mdgraph_trace` | An explainable graph path |
|
|
83
|
+
| Know whether results are safe to trust | `mdgraph_status` | Index availability and freshness |
|
|
84
|
+
|
|
85
|
+
MDGraph extracts relationships from headings, front matter, Markdown links, WikiLinks, inline code, code blocks, and explicit source references. The core index is deterministic: no LLM-generated summaries and no remote embedding service are required.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Built for the Gap Between Search and Understanding
|
|
90
|
+
|
|
91
|
+
| Tool | Best at | What MDGraph adds |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| `grep` / file search | Exact text and fast ad hoc lookup | Document relationships, ranked context, provenance, and freshness |
|
|
94
|
+
| Vector RAG | Fuzzy semantic similarity across broad content | Deterministic extraction and useful local retrieval without remote models |
|
|
95
|
+
| Source code graphs | Symbols, calls, and implementation structure | Decisions, runbooks, specs, and other Markdown knowledge |
|
|
96
|
+
|
|
97
|
+
MDGraph does not replace those tools. It gives coding agents a documentation layer for the intent, decisions, operational knowledge, and cross-file relationships that source code alone does not carry.
|
|
98
|
+
|
|
99
|
+
### Evidence With Its Limits Intact
|
|
100
|
+
|
|
101
|
+
- Repository-owned evaluation fixtures cover ADRs, designs, APIs, runbooks, incidents, source references, superseded documents, and CJK retrieval.
|
|
102
|
+
- Every search and context result retains a reason; graph traces retain edge kinds, provenance, and confidence.
|
|
103
|
+
- Linux and Windows run the full CI gate; macOS runs build and package smoke checks.
|
|
104
|
+
- The `1.0.0` public CLI, MCP, config, JSON, and schema surfaces have a documented compatibility baseline.
|
|
105
|
+
|
|
106
|
+
These are deterministic engineering checks, not a claim of a completed real-agent benchmark. See [Evaluation Questions](./docs/EN/Evaluation_Questions.md) and [Public Contracts 1.0](./docs/EN/Public_Contracts_1.0.md) for the methodology and limits.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Common Commands
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Refresh the graph manually
|
|
114
|
+
mdgraph index --path /your/project
|
|
115
|
+
|
|
116
|
+
# Check availability, counts, and freshness
|
|
117
|
+
mdgraph status --freshness --path /your/project
|
|
118
|
+
|
|
119
|
+
# Search and context-pack from the CLI
|
|
120
|
+
mdgraph search --path /your/project "authentication timeout"
|
|
121
|
+
mdgraph context --path /your/project "why does RedisTimeoutError affect login"
|
|
122
|
+
|
|
123
|
+
# Resolve one node or trace a graph path
|
|
124
|
+
mdgraph node --path /your/project "AuthService"
|
|
125
|
+
mdgraph trace --path /your/project "AuthService" "RedisTimeoutError"
|
|
126
|
+
|
|
127
|
+
# Documentation health checks
|
|
128
|
+
mdgraph doctor --path /your/project
|
|
129
|
+
mdgraph doctor --since origin/main --fail-on warn --json --path /your/project
|
|
130
|
+
|
|
131
|
+
# Agent-friendly workflow guide
|
|
132
|
+
mdgraph usage --path /your/project
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Use `mdgraph help` or `mdgraph help <command>` for the full CLI reference.
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Why Teams Can Trust It
|
|
140
|
+
|
|
141
|
+
- **Local by default.** Markdown, chunks, vectors, and SQLite artifacts stay in the project environment.
|
|
142
|
+
- **Explainable by design.** Results retain matching reasons, entities, edge provenance, confidence, paths, and budget information where relevant.
|
|
143
|
+
- **Deterministic at the core.** The same Markdown produces stable graph records without requiring an LLM.
|
|
144
|
+
- **Fresh during active work.** Hash-based incremental indexing updates changed documents; MCP watch mode keeps later queries current.
|
|
145
|
+
- **Honest about risk.** `doctor` surfaces dead links, stale source refs, missing definitions, content risks, storage health, and stale indexes.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Documentation Map
|
|
150
|
+
|
|
151
|
+
- `docs/EN/Architecture.md` — pipeline, module boundaries, data flow, tradeoffs.
|
|
152
|
+
- `docs/EN/Agent_Integration.md` — MCP setup, shared agent instructions, host notes.
|
|
153
|
+
- `docs/EN/Public_Contracts.md` — stable public surfaces, compatibility policy, release gates.
|
|
154
|
+
- `docs/EN/Public_Contracts_1.0.md` — 1.0 contract-freeze appendix with the frozen CLI, config, MCP, JSON, and schema inventory for the current `1.0.0` baseline.
|
|
155
|
+
- `docs/EN/Output_Contracts.md` — JSON output shapes for CLI and MCP consumers.
|
|
156
|
+
- `docs/EN/Evaluation_Questions.md` — retrieval/evaluation prompts.
|
|
157
|
+
- `docs/EN/Release_Checklist.md` — release validation checklist.
|
|
158
|
+
- `agent-pack/` — reusable MCP config, instructions, and prompt templates.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Community
|
|
163
|
+
|
|
164
|
+
- Found a bug or have a focused feature idea? [Open an issue](https://github.com/daoGEE/mdgraph/issues/new/choose).
|
|
165
|
+
- Want to improve MDGraph? Read [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
166
|
+
- Found a security issue? Follow [SECURITY.md](./SECURITY.md) instead of posting sensitive details publicly.
|
|
167
|
+
- If MDGraph helps your team, star the repository and share the workflow that worked for you. Real examples are the most useful signal for the roadmap.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Requirements
|
|
172
|
+
|
|
173
|
+
- Node.js `>=22.5.0`
|
|
174
|
+
- SQLite support from Node's built-in `node:sqlite`
|
|
175
|
+
- Markdown files in a local project directory
|
|
176
|
+
|
|
177
|
+
`node:sqlite` may print an experimental warning on current Node versions. Treat it as informational when commands exit successfully.
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Development
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
npm install
|
|
185
|
+
npm run typecheck
|
|
186
|
+
npm test
|
|
187
|
+
npm run build
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Useful smoke checks:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
npm run smoke:cli
|
|
194
|
+
npm run smoke:eval
|
|
195
|
+
npm run smoke:pack
|
|
196
|
+
npm run task:public-check
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## License
|
|
202
|
+
|
|
203
|
+
MIT
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# MDGraph Agent Pack
|
|
2
|
+
|
|
3
|
+
This pack contains reusable guidance for MCP-capable coding agents. It keeps host-specific setup thin: each host starts the same MDGraph MCP server and uses the same query-first, file-read-second behavior.
|
|
4
|
+
|
|
5
|
+
## Files
|
|
6
|
+
|
|
7
|
+
- [`mdgraph-agent-instructions.md`](mdgraph-agent-instructions.md): shared instruction template for project rules or agent guidance.
|
|
8
|
+
- [`mcp-config.example.json`](mcp-config.example.json): stdio MCP server configuration template.
|
|
9
|
+
- [`host-examples.md`](host-examples.md): host-specific setup notes for Claude Code, Cursor, Copilot Chat, Codex CLI, and generic MCP clients.
|
|
10
|
+
- [`prompts/task-start-context.md`](prompts/task-start-context.md): prompt template for task-start documentation briefs.
|
|
11
|
+
- [`prompts/relationship-trace.md`](prompts/relationship-trace.md): prompt template for relationship and dependency questions.
|
|
12
|
+
- [`prompts/status-doctor.md`](prompts/status-doctor.md): prompt template for readiness, stale-index, and documentation health checks.
|
|
13
|
+
|
|
14
|
+
## Host Placement
|
|
15
|
+
|
|
16
|
+
| Host | Suggested placement |
|
|
17
|
+
|---|---|
|
|
18
|
+
| Claude Code | Project/user instructions plus MCP config. |
|
|
19
|
+
| Cursor | Project rules plus MCP settings. |
|
|
20
|
+
| Copilot Chat | `.github/copilot-instructions.md` or equivalent workspace guidance plus MCP config when available. |
|
|
21
|
+
| Codex CLI | Repo instructions plus Codex MCP config. |
|
|
22
|
+
| Generic MCP client | Import the MCP config and instruction text directly. |
|
|
23
|
+
|
|
24
|
+
Install the CLI with `npm install -g @daogee/mdgraph`, then replace `/absolute/path/to/project` in `mcp-config.example.json`. If the host cannot resolve `mdgraph`, use the absolute executable path reported by `which mdgraph` (macOS/Linux) or `where mdgraph` (Windows).
|
|
25
|
+
|
|
26
|
+
Use `mdgraph report --benchmark <file>` for structured comparison records, and keep full transcripts or private evaluation corpora outside the public repository.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# MDGraph Host Examples
|
|
2
|
+
|
|
3
|
+
These examples all start the same stdio MCP server. Keep the shared behavior model in `mdgraph-agent-instructions.md`; only the host placement differs.
|
|
4
|
+
|
|
5
|
+
Install the CLI, then replace the project path before use:
|
|
6
|
+
|
|
7
|
+
- `npm install -g @daogee/mdgraph`
|
|
8
|
+
- `/absolute/path/to/project`
|
|
9
|
+
|
|
10
|
+
If the host does not inherit your shell `PATH`, replace `mdgraph` in the examples with the absolute path reported by `which mdgraph` (macOS/Linux) or `where mdgraph` (Windows).
|
|
11
|
+
|
|
12
|
+
## Claude Code
|
|
13
|
+
|
|
14
|
+
Use the shared MCP JSON shape in the Claude Code MCP configuration for the project or user profile. Put the contents of `mdgraph-agent-instructions.md` in project instructions.
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"mcpServers": {
|
|
19
|
+
"mdgraph": {
|
|
20
|
+
"type": "stdio",
|
|
21
|
+
"command": "mdgraph",
|
|
22
|
+
"args": [
|
|
23
|
+
"serve",
|
|
24
|
+
"--mcp",
|
|
25
|
+
"--path",
|
|
26
|
+
"/absolute/path/to/project"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Cursor
|
|
34
|
+
|
|
35
|
+
Add the same MCP server entry in Cursor's MCP settings. Put the shared instruction text in project rules so the agent queries MDGraph before broad Markdown reads.
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"mcpServers": {
|
|
40
|
+
"mdgraph": {
|
|
41
|
+
"type": "stdio",
|
|
42
|
+
"command": "mdgraph",
|
|
43
|
+
"args": ["serve", "--mcp", "--path", "/absolute/path/to/project"]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Copilot Chat
|
|
50
|
+
|
|
51
|
+
When MCP tools are available in the host environment, use the same stdio server entry. Put the shared instruction text in `.github/copilot-instructions.md` or the workspace guidance surface used by the project.
|
|
52
|
+
|
|
53
|
+
If MCP is unavailable, do not simulate hidden memory. Use normal file tools, or run MDGraph CLI commands only when the user asks.
|
|
54
|
+
|
|
55
|
+
## Codex CLI
|
|
56
|
+
|
|
57
|
+
Add the same stdio server entry to the Codex MCP configuration. Keep `mdgraph-agent-instructions.md` in repository instructions or the agent's project guidance.
|
|
58
|
+
|
|
59
|
+
Use `knownFiles` and `maxChars` with `mdgraph_context` when the task already names files or the context budget is tight.
|
|
60
|
+
|
|
61
|
+
## Generic MCP Client
|
|
62
|
+
|
|
63
|
+
Use `mcp-config.example.json` directly. The server exposes exactly five tools:
|
|
64
|
+
|
|
65
|
+
- `mdgraph_search`
|
|
66
|
+
- `mdgraph_context`
|
|
67
|
+
- `mdgraph_node`
|
|
68
|
+
- `mdgraph_trace`
|
|
69
|
+
- `mdgraph_status`
|
|
70
|
+
|
|
71
|
+
If `mdgraph_status` reports inactive, fall back to normal file reads unless the user explicitly asks to create or refresh the index.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# MDGraph Agent Instructions
|
|
2
|
+
|
|
3
|
+
Use MDGraph as the first stop for documentation work, before reading multiple Markdown files manually.
|
|
4
|
+
|
|
5
|
+
Default order for Markdown/documentation questions:
|
|
6
|
+
|
|
7
|
+
1. Start with `mdgraph_status` if index availability or freshness is unclear.
|
|
8
|
+
2. Use `mdgraph_context` first for task-start context when the task touches architecture, roadmap, public contracts, CLI/MCP behavior, release process, docs policy, ADRs, runbooks, incidents, source_refs, or cross-document feature chains.
|
|
9
|
+
3. Use `mdgraph_search` for exact docs keyword, entity, path, command, config key, API route, or error-code lookup before raw grep or manual file reads.
|
|
10
|
+
4. Use `mdgraph_node` or `mdgraph_trace` after search/context narrows the target.
|
|
11
|
+
5. Fall back to normal file reads or text search only when MDGraph is inactive, stale for the task, too sparse, exact neighboring prose is required, or the user explicitly asks for file-level inspection.
|
|
12
|
+
|
|
13
|
+
- Start with `mdgraph_status` if index availability is unclear.
|
|
14
|
+
- Use `mdgraph_context` for cross-document design, ADR, runbook, API, incident, source-ref, or feature-chain questions. Include `knownFiles` and `maxChars` when the host supports MCP arguments.
|
|
15
|
+
- Use `mdgraph_search` for quick keyword, entity, path, command, config key, API route, or error-code lookup.
|
|
16
|
+
- Use `mdgraph_node` for known document paths, section anchors, entities, source paths, or graph ids.
|
|
17
|
+
- Use `mdgraph_trace` for relationship questions between two known documents, entities, or source references.
|
|
18
|
+
- Prefer returned context when it includes enough content, reasons, provenance, source refs, and risk notes.
|
|
19
|
+
- Fall back to normal file reads when MDGraph is inactive, stale for the task, too sparse, or when exact source text is required.
|
|
20
|
+
|
|
21
|
+
Do not treat MDGraph as hidden memory, a source AST index, or an authority beyond the indexed Markdown corpus. Do not create or update an index unless the user asks for it.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Relationship Trace Prompt
|
|
2
|
+
|
|
3
|
+
Part of the [MDGraph Agent Pack](../README.md).
|
|
4
|
+
|
|
5
|
+
Use this when the user asks how two documents, entities, APIs, source refs, or decisions are related.
|
|
6
|
+
|
|
7
|
+
1. If either endpoint is fuzzy, call `mdgraph_search` for each endpoint first.
|
|
8
|
+
2. Call `mdgraph_trace` with the resolved endpoint names, paths, source refs, or graph ids.
|
|
9
|
+
3. If the trace path is not self-explanatory, call `mdgraph_context` with the relationship question and any known endpoint paths in `knownFiles`.
|
|
10
|
+
4. Explain the path using edge kinds, provenance, confidence, and cited document paths from the tool result.
|
|
11
|
+
|
|
12
|
+
Fall back to raw file reads only when MDGraph is unavailable or the returned trace/context is too sparse.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Status And Doctor Prompt
|
|
2
|
+
|
|
3
|
+
Part of the [MDGraph Agent Pack](../README.md).
|
|
4
|
+
|
|
5
|
+
Use this when the user asks whether MDGraph is ready, stale, healthy, or suitable for a documentation-gated workflow.
|
|
6
|
+
|
|
7
|
+
1. Call `mdgraph_status` first.
|
|
8
|
+
2. If status is inactive, explain that normal file tools should be used unless the user asks to run `mdgraph index`.
|
|
9
|
+
3. If status is active, use its counts and `fresh` / `stale` / `unknown` freshness metadata as a lightweight readiness check.
|
|
10
|
+
4. If the user asks about broken docs, CI gates, health risks, or full stale-index hash verification, run CLI `mdgraph doctor --json` rather than relying on `mdgraph_status` alone.
|
|
11
|
+
5. When reporting issues, cite affected document paths and the remediation hint from the doctor output.
|
|
12
|
+
|
|
13
|
+
Do not create, refresh, or repair an index unless the user explicitly asks.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Task-Start Documentation Brief
|
|
2
|
+
|
|
3
|
+
Part of the [MDGraph Agent Pack](../README.md).
|
|
4
|
+
|
|
5
|
+
Use this when a coding task mentions docs, designs, ADRs, runbooks, APIs, source refs, or known files.
|
|
6
|
+
|
|
7
|
+
1. Call `mdgraph_status` if index availability is unclear.
|
|
8
|
+
2. Call `mdgraph_context` with:
|
|
9
|
+
- `query`: the user's task text plus the main domain terms.
|
|
10
|
+
- `knownFiles`: project-relative paths the user already named, when available.
|
|
11
|
+
- `maxChars`: a smaller character budget when the host context is tight.
|
|
12
|
+
3. Use the returned context directly when it has enough content, reasons, provenance, source refs, and risk notes.
|
|
13
|
+
4. Read raw files only for exact sections that still need inspection.
|
|
14
|
+
|
|
15
|
+
Do not run `mdgraph index` unless the user asks to create or refresh the index.
|