@daogee/mdgraph 1.0.0 → 1.2.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 +51 -0
- package/README-ZH.md +66 -4
- package/README.md +84 -22
- package/agent-pack/README.md +2 -0
- package/agent-pack/mdgraph-agent-instructions.md +3 -1
- package/agent-pack/prompts/wiki-authoring.md +12 -0
- package/agent-pack/skills/wiki-authoring/SKILL.md +38 -0
- package/agent-pack/skills/wiki-authoring/agents/openai.yaml +4 -0
- package/dist/analysis/status-freshness.d.ts +8 -1
- package/dist/analysis/status-freshness.js +19 -6
- package/dist/bin/mdgraph.js +260 -25
- package/dist/config/limits.d.ts +2 -0
- package/dist/config/limits.js +3 -1
- package/dist/config/load-config.js +8 -2
- package/dist/db/connection.js +17 -1
- package/dist/db/repositories.d.ts +55 -4
- package/dist/db/repositories.js +458 -11
- package/dist/db/sqlite-adapter.js +8 -2
- package/dist/evaluation/context-packing-evaluation.d.ts +29 -0
- package/dist/evaluation/context-packing-evaluation.js +134 -0
- package/dist/evaluation/entity-extraction-evaluation.d.ts +38 -0
- package/dist/evaluation/entity-extraction-evaluation.js +118 -0
- package/dist/evaluation/historical-baseline.d.ts +70 -0
- package/dist/evaluation/historical-baseline.js +278 -0
- package/dist/evaluation/related-documents-evaluation.d.ts +26 -0
- package/dist/evaluation/related-documents-evaluation.js +163 -0
- package/dist/evaluation/retrieval-eval.d.ts +25 -5
- package/dist/evaluation/retrieval-eval.js +79 -7
- package/dist/evaluation/structured-query-evaluation.d.ts +27 -0
- package/dist/evaluation/structured-query-evaluation.js +156 -0
- package/dist/extraction/entity-extractor.js +42 -22
- package/dist/extraction/graph-builder.js +2 -18
- package/dist/index.d.ts +24 -4
- package/dist/index.js +12 -4
- package/dist/indexer.js +80 -4
- package/dist/mcp/server.d.ts +4 -0
- package/dist/mcp/server.js +21 -11
- package/dist/mcp/tools.d.ts +5 -1
- package/dist/mcp/tools.js +116 -18
- package/dist/parser/markdown-parser.js +2 -0
- package/dist/query/context-builder.d.ts +32 -2
- package/dist/query/context-builder.js +191 -12
- package/dist/query/knowledge-card.d.ts +90 -0
- package/dist/query/knowledge-card.js +676 -0
- package/dist/query/search.d.ts +5 -1
- package/dist/query/search.js +85 -16
- package/dist/query/structured-query-executor.d.ts +28 -0
- package/dist/query/structured-query-executor.js +138 -0
- package/dist/query/structured-query.d.ts +50 -0
- package/dist/query/structured-query.js +390 -0
- package/dist/relationships/derive-related.d.ts +86 -0
- package/dist/relationships/derive-related.js +322 -0
- package/dist/reporting/report.js +2 -2
- package/dist/semantic/embed-chunks.d.ts +2 -0
- package/dist/semantic/embed-chunks.js +31 -0
- package/dist/semantic/ollama-provider.d.ts +6 -0
- package/dist/semantic/ollama-provider.js +136 -0
- package/dist/semantic/provider-registry.d.ts +8 -0
- package/dist/semantic/provider-registry.js +66 -0
- package/dist/semantic/provider.d.ts +35 -0
- package/dist/semantic/provider.js +29 -0
- package/dist/semantic/status.d.ts +6 -1
- package/dist/semantic/status.js +49 -3
- package/dist/types.d.ts +7 -2
- package/dist/types.js +2 -1
- package/dist/utils/path-safety.d.ts +3 -0
- package/dist/utils/path-safety.js +27 -0
- package/dist/watcher/file-watcher.d.ts +4 -0
- package/dist/watcher/file-watcher.js +151 -17
- package/dist/watcher/watch-health.d.ts +34 -0
- package/dist/watcher/watch-health.js +75 -0
- package/dist/wiki/wiki-dependencies.d.ts +20 -0
- package/dist/wiki/wiki-dependencies.js +45 -0
- package/dist/wiki/wiki-domains.d.ts +13 -0
- package/dist/wiki/wiki-domains.js +55 -0
- package/dist/wiki/wiki-evidence.d.ts +27 -0
- package/dist/wiki/wiki-evidence.js +112 -0
- package/dist/wiki/wiki-plan.d.ts +121 -0
- package/dist/wiki/wiki-plan.js +616 -0
- package/dist/wiki/wiki-status.d.ts +67 -0
- package/dist/wiki/wiki-status.js +451 -0
- package/docs/EN/Agent_Integration.md +15 -5
- package/docs/EN/Architecture.md +52 -16
- package/docs/EN/Evaluation_Questions.md +35 -5
- package/docs/EN/Knowledge_Cards_and_Wiki_Workflow.md +97 -0
- package/docs/EN/Operations.md +111 -0
- package/docs/EN/Output_Contracts.md +83 -10
- package/docs/EN/Public_Contracts.md +25 -16
- package/docs/EN/Public_Contracts_1.0.md +32 -18
- package/docs/EN/README.md +24 -0
- package/docs/EN/Release_Checklist.md +27 -13
- package/docs/EN/Retrieval_and_Context.md +118 -0
- package/docs/EN/Structured_Query_and_Relationships.md +111 -0
- package/docs/ZH/Agent_Integration.md +15 -5
- package/docs/ZH/Architecture.md +52 -21
- package/docs/ZH/Evaluation_Questions.md +36 -6
- package/docs/ZH/Knowledge_Cards_and_Wiki_Workflow.md +99 -0
- package/docs/ZH/Operations.md +111 -0
- package/docs/ZH/Output_Contracts.md +83 -10
- package/docs/ZH/Public_Contracts.md +24 -15
- package/docs/ZH/Public_Contracts_1.0.md +31 -17
- package/docs/ZH/README.md +24 -0
- package/docs/ZH/Release_Checklist.md +27 -13
- package/docs/ZH/Retrieval_and_Context.md +118 -0
- package/docs/ZH/Structured_Query_and_Relationships.md +111 -0
- package/package.json +50 -19
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,57 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to MDGraph are documented here. MDGraph follows semantic versioning for its public releases.
|
|
4
4
|
|
|
5
|
+
## 1.2.0 - 2026-09-12
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Experimental deterministic Knowledge Cards on `node` plus spare-budget Card summaries in `context`.
|
|
10
|
+
- Experimental `wiki plan/brief/status/verify` commands for evidence-backed user-maintained Wiki planning, impact status, and read-only verification.
|
|
11
|
+
- A reusable Wiki authoring prompt/skill without changing the five-tool MCP surface or adding a generation provider.
|
|
12
|
+
- Returned-evidence retrieval metrics alongside unchanged legacy index-coverage metrics, plus a reproducible performance sampling script.
|
|
13
|
+
- CI coverage for Node 22 and 26 and early SQLite compatibility; packaged CLI checks for cards and Wiki briefs.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- Knowledge Cards distinguish direct, inherited, and related evidence, preserve source ownership, and provide bounded next-read paths.
|
|
18
|
+
- WikiPlan v2 preserves authored page selections during updates, records the output directory and dependency snapshots, and separates suggested pages/sources from selected evidence. Version 1 plans remain readable.
|
|
19
|
+
- Wiki briefs and status share dependency assessment, explain unavailable or changed sources, and preserve user-selected references during review. Verification explicitly reports that prose correctness is not evaluated.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- Enforce real served-project boundaries for MCP roots and SQLite/configuration paths, including symbolic links.
|
|
24
|
+
- Apply embedding deadlines through complete response bodies and retain lexical fallback and existing indexes on failure.
|
|
25
|
+
- Reconcile incremental graph relationships and extraction settings, reuse matching vectors, detect concurrent index commits, and reload watcher configuration without dropping the previous watch.
|
|
26
|
+
- Match complete Chinese/entity/configuration-key queries and retain definition evidence; enforce serialized Knowledge Card budgets.
|
|
27
|
+
- Verify Wiki evidence against current Markdown hashes and validate maintenance field types.
|
|
28
|
+
- Normalize early node:sqlite empty-row behavior and provide actionable recovery when FTS5 is unavailable.
|
|
29
|
+
- Update test dependencies to audited Vitest and nanoid versions so the release workflow reports no known vulnerabilities.
|
|
30
|
+
|
|
31
|
+
### Compatibility
|
|
32
|
+
|
|
33
|
+
- Deterministic indexing, the default context-packing strategy, stable `search`, the five-tool MCP surface, schema version 1, and the public `alpha | cjk` evaluation query-set enum remain unchanged.
|
|
34
|
+
- Supported Node.js builds must provide FTS5 through `node:sqlite`; Node 22.23.2 and 26.5.0 are verified.
|
|
35
|
+
|
|
36
|
+
## 1.1.0 - 2026-08-03
|
|
37
|
+
|
|
38
|
+
### Added
|
|
39
|
+
|
|
40
|
+
- Opt-in Ollama embeddings through a provider interface, with batched asynchronous indexing, provider-aware query paths, runtime diagnostics, and atomic failure behavior.
|
|
41
|
+
- Source-aware entity extraction for higher-precision technical symbols plus Unicode-aware CJK API routes, configuration keys, and function identifiers.
|
|
42
|
+
- Opt-in true MMR context packing, persistent watcher health, and explicit polling fallbacks for environments where native file watching is unreliable.
|
|
43
|
+
- An experimental, parameterized `query` DSL for document metadata, tags, outgoing edges, dates, sorting, limits, and selected documentation-health predicates.
|
|
44
|
+
- An experimental `relationships derive` workflow for conservative, provider-gated `RELATED_TO` edges with independent evidence, reciprocal-neighbor checks, provenance, and atomic replacement.
|
|
45
|
+
|
|
46
|
+
### Changed
|
|
47
|
+
|
|
48
|
+
- `local-hash` is documented and reported as a deterministic lexical feature hash rather than a language-model embedding.
|
|
49
|
+
- Public documentation is organized by user task instead of implementation-stage pages, and the npm package uses an explicit documentation allowlist.
|
|
50
|
+
- Internal regression suites, evaluation APIs, and release commands use capability names instead of implementation milestone labels.
|
|
51
|
+
|
|
52
|
+
### Compatibility
|
|
53
|
+
|
|
54
|
+
- Deterministic indexing, the default context-packing strategy, stable `search`, the five-tool MCP surface, schema version 1, and the public `alpha | cjk` evaluation query-set enum remain unchanged.
|
|
55
|
+
|
|
5
56
|
## 1.0.0 - 2026-07-12
|
|
6
57
|
|
|
7
58
|
### Added
|
package/README-ZH.md
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
[](https://opensource.org/licenses/MIT)
|
|
10
10
|
[](https://github.com/daoGEE/mdgraph/actions/workflows/ci.yml)
|
|
11
|
-
[](https://nodejs.org/)
|
|
12
12
|
[](https://github.com/daoGEE/mdgraph/releases)
|
|
13
13
|
|
|
14
|
-
<a href="./README.md">English</a> · <a href="./docs/ZH/
|
|
14
|
+
<a href="./README.md">English</a> · <a href="./docs/ZH/README.md">文档</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>
|
|
15
15
|
|
|
16
16
|
</div>
|
|
17
17
|
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
```text
|
|
27
27
|
$ mdgraph context "Markdown 文件如何经过索引流程变成代理上下文?"
|
|
28
28
|
|
|
29
|
-
docs/EN/Architecture.md:
|
|
29
|
+
docs/EN/Architecture.md:59 · Indexing Flow
|
|
30
30
|
Reason: FTS5 content match; RRF fusion
|
|
31
31
|
|
|
32
32
|
1. scanMarkdownFiles 选择候选 Markdown 文件。
|
|
@@ -119,6 +119,7 @@ mdgraph status --freshness --path /your/project
|
|
|
119
119
|
# CLI 搜索和上下文打包
|
|
120
120
|
mdgraph search --path /your/project "authentication timeout"
|
|
121
121
|
mdgraph context --path /your/project "why does RedisTimeoutError affect login"
|
|
122
|
+
mdgraph context --packing mmr --debug --path /your/project "why does RedisTimeoutError affect login"
|
|
122
123
|
|
|
123
124
|
# 解析单个节点或追溯图谱路径
|
|
124
125
|
mdgraph node --path /your/project "AuthService"
|
|
@@ -128,12 +129,69 @@ mdgraph trace --path /your/project "AuthService" "RedisTimeoutError"
|
|
|
128
129
|
mdgraph doctor --path /your/project
|
|
129
130
|
mdgraph doctor --since origin/main --fail-on warn --json --path /your/project
|
|
130
131
|
|
|
132
|
+
# 实验性结构化治理查询
|
|
133
|
+
mdgraph query --path /your/project 'type:adr AND status:accepted ORDER BY updated DESC'
|
|
134
|
+
|
|
135
|
+
# 实验性的 provider 门禁相关文档层
|
|
136
|
+
mdgraph relationships derive --dry-run --json --path /your/project
|
|
137
|
+
mdgraph relationships derive --threshold 0.86 --json --path /your/project
|
|
138
|
+
|
|
139
|
+
# 实验性的用户维护 Wiki 工作流
|
|
140
|
+
mdgraph wiki plan --out .mdgraph/wiki-plan.json --path /your/project
|
|
141
|
+
mdgraph wiki brief architecture --plan .mdgraph/wiki-plan.json --json --path /your/project
|
|
142
|
+
mdgraph wiki status wiki --plan .mdgraph/wiki-plan.json --json --path /your/project
|
|
143
|
+
mdgraph wiki verify wiki --plan .mdgraph/wiki-plan.json --json --path /your/project
|
|
144
|
+
|
|
131
145
|
# Agent 友好的使用指引
|
|
132
146
|
mdgraph usage --path /your/project
|
|
133
147
|
```
|
|
134
148
|
|
|
135
149
|
完整 CLI 参考请使用 `mdgraph help` 或 `mdgraph help <command>`。
|
|
136
150
|
|
|
151
|
+
真 MMR 打包为 opt-in,文档轮询继续作为兼容默认值,详见[检索与上下文](./docs/ZH/Retrieval_and_Context.md)。Watcher polling 也必须显式启用(`watch --poll` 或 `serve --mcp --watch-poll`),因为它可能增加 I/O 和 CPU;详见[运行与故障处理](./docs/ZH/Operations.md)。
|
|
152
|
+
|
|
153
|
+
实验性的 `query` 命令提供有界、参数化的文档治理 DSL,不改变 `search` 或五工具 MCP surface。
|
|
154
|
+
|
|
155
|
+
实验性的 `relationships derive` 只会基于 fresh、完整的 semantic-model index,在独立 evidence 与 reciprocal-neighbor 门禁通过后创建低权重 `RELATED_TO` edge;它不会在 indexing 或 watch mode 中自动运行。两个实验性工作流均记录在[结构化查询与派生关系](./docs/ZH/Structured_Query_and_Relationships.md)。
|
|
156
|
+
|
|
157
|
+
实验性的 `wiki` group 会确定性规划页面、准备有界证据 brief、报告更新影响,并验证维护字段、source 和相对链接。MDGraph 不生成或覆盖 Wiki 正文;宿主 Agent 工作流见 [Knowledge Card 与 Wiki 工作流](./docs/ZH/Knowledge_Cards_and_Wiki_Workflow.md)。
|
|
158
|
+
|
|
159
|
+
更新已有 Wiki 计划时,使用 `mdgraph wiki plan --from <plan> --out <next-plan> --path <project>` 保留人工调整的页面。迁移 v1 计划时增加 `--wiki-dir wiki`。新计划使用 v2,新增页面和来源需审视后采纳。`current` 表示依赖一致,`wiki verify` 不判断正文是否正确。
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## 可选 Ollama Embedding
|
|
164
|
+
|
|
165
|
+
真实语义检索需要显式启用;确定性的 FTS5/entity/graph 流水线仍是默认行为。先在本机启动 Ollama 并安装 embedding 模型:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
ollama pull nomic-embed-text
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
配置 `.mdgraph/config.json`(其他配置 section 可保持不变):
|
|
172
|
+
|
|
173
|
+
```json
|
|
174
|
+
{
|
|
175
|
+
"embedding": {
|
|
176
|
+
"enabled": true,
|
|
177
|
+
"provider": "ollama",
|
|
178
|
+
"model": "nomic-embed-text",
|
|
179
|
+
"dimensions": 768,
|
|
180
|
+
"endpoint": "http://127.0.0.1:11434",
|
|
181
|
+
"timeoutMs": 30000,
|
|
182
|
+
"batchSize": 16
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
mdgraph index --full --semantic --path /your/project
|
|
189
|
+
mdgraph semantic status --path /your/project
|
|
190
|
+
mdgraph search --semantic --path /your/project "authentication login"
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
查询时 provider 失败会降级到 FTS5/entity/graph 结果并输出诊断。显式 semantic indexing 会在替换现有 graph 前失败,因此不会提交部分 vector coverage。`local-hash` 为兼容继续可用,但它是词法 feature hash,不是语言模型 embedding。
|
|
194
|
+
|
|
137
195
|
---
|
|
138
196
|
|
|
139
197
|
## 为什么团队可以信任它
|
|
@@ -148,8 +206,12 @@ mdgraph usage --path /your/project
|
|
|
148
206
|
|
|
149
207
|
## 文档导航
|
|
150
208
|
|
|
209
|
+
- `docs/ZH/README.md` — 按任务组织的文档入口。
|
|
151
210
|
- `docs/ZH/Architecture.md` — 流水线、模块边界、数据流和取舍。
|
|
152
211
|
- `docs/ZH/Agent_Integration.md` — MCP 配置、共享 agent 指令和宿主说明。
|
|
212
|
+
- `docs/ZH/Retrieval_and_Context.md` — 搜索通道、embedding provider、实体抽取、CJK 行为和上下文打包。
|
|
213
|
+
- `docs/ZH/Structured_Query_and_Relationships.md` — 结构化治理 DSL 和显式派生关系。
|
|
214
|
+
- `docs/ZH/Operations.md` — 索引新鲜度、watcher health、polling 和 provider 恢复。
|
|
153
215
|
- `docs/ZH/Public_Contracts.md` — 稳定公开表面、兼容策略和发布门禁。
|
|
154
216
|
- `docs/ZH/Public_Contracts_1.0.md` — 1.0 契约冻结附录,列出当前 `1.0.0` 基线下冻结的 CLI、配置、MCP、JSON 与 schema 清单。
|
|
155
217
|
- `docs/ZH/Output_Contracts.md` — CLI 和 MCP 消费者使用的 JSON 输出形状。
|
|
@@ -170,7 +232,7 @@ mdgraph usage --path /your/project
|
|
|
170
232
|
|
|
171
233
|
## 环境要求
|
|
172
234
|
|
|
173
|
-
- Node.js `>=22.5.0`
|
|
235
|
+
- Node.js `>=22.5.0`,且内置 `node:sqlite` 启用了 FTS5。已验证 22.23.2 和 26.5.0;仅满足版本号不保证具备 FTS5,请使用当前 Node 22 或更新发行版。
|
|
174
236
|
- Node 内置 `node:sqlite` 支持
|
|
175
237
|
- 本地项目目录中的 Markdown 文件
|
|
176
238
|
|
package/README.md
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
[](https://opensource.org/licenses/MIT)
|
|
10
10
|
[](https://github.com/daoGEE/mdgraph/actions/workflows/ci.yml)
|
|
11
|
-
[](https://nodejs.org/)
|
|
12
12
|
[](https://github.com/daoGEE/mdgraph/releases)
|
|
13
13
|
|
|
14
|
-
<a href="./README-ZH.md">简体中文</a> · <a href="./docs/EN/
|
|
14
|
+
<a href="./README-ZH.md">简体中文</a> · <a href="./docs/EN/README.md">Documentation</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>
|
|
15
15
|
|
|
16
16
|
</div>
|
|
17
17
|
|
|
@@ -26,7 +26,7 @@ Text search finds matching words. MDGraph finds the surrounding decision, the co
|
|
|
26
26
|
```text
|
|
27
27
|
$ mdgraph context "How does indexing flow from Markdown files to agent context?"
|
|
28
28
|
|
|
29
|
-
docs/EN/Architecture.md:
|
|
29
|
+
docs/EN/Architecture.md:59 · Indexing Flow
|
|
30
30
|
Reason: FTS5 content match; RRF fusion
|
|
31
31
|
|
|
32
32
|
1. scanMarkdownFiles selects candidate Markdown files.
|
|
@@ -117,26 +117,84 @@ mdgraph index --path /your/project
|
|
|
117
117
|
mdgraph status --freshness --path /your/project
|
|
118
118
|
|
|
119
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"
|
|
120
|
+
mdgraph search --path /your/project "authentication timeout"
|
|
121
|
+
mdgraph context --path /your/project "why does RedisTimeoutError affect login"
|
|
122
|
+
mdgraph context --packing mmr --debug --path /your/project "why does RedisTimeoutError affect login"
|
|
122
123
|
|
|
123
124
|
# Resolve one node or trace a graph path
|
|
124
125
|
mdgraph node --path /your/project "AuthService"
|
|
125
126
|
mdgraph trace --path /your/project "AuthService" "RedisTimeoutError"
|
|
126
127
|
|
|
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
|
-
#
|
|
132
|
-
mdgraph
|
|
128
|
+
# Documentation health checks
|
|
129
|
+
mdgraph doctor --path /your/project
|
|
130
|
+
mdgraph doctor --since origin/main --fail-on warn --json --path /your/project
|
|
131
|
+
|
|
132
|
+
# Experimental structured governance query
|
|
133
|
+
mdgraph query --path /your/project 'type:adr AND status:accepted ORDER BY updated DESC'
|
|
134
|
+
|
|
135
|
+
# Experimental provider-gated related-document layer
|
|
136
|
+
mdgraph relationships derive --dry-run --json --path /your/project
|
|
137
|
+
mdgraph relationships derive --threshold 0.86 --json --path /your/project
|
|
138
|
+
|
|
139
|
+
# Experimental user-maintained Wiki workflow
|
|
140
|
+
mdgraph wiki plan --out .mdgraph/wiki-plan.json --path /your/project
|
|
141
|
+
mdgraph wiki brief architecture --plan .mdgraph/wiki-plan.json --json --path /your/project
|
|
142
|
+
mdgraph wiki status wiki --plan .mdgraph/wiki-plan.json --json --path /your/project
|
|
143
|
+
mdgraph wiki verify wiki --plan .mdgraph/wiki-plan.json --json --path /your/project
|
|
144
|
+
|
|
145
|
+
# Agent-friendly workflow guide
|
|
146
|
+
mdgraph usage --path /your/project
|
|
133
147
|
```
|
|
134
148
|
|
|
135
|
-
Use `mdgraph help` or `mdgraph help <command>` for the full CLI reference.
|
|
136
|
-
|
|
137
|
-
|
|
149
|
+
Use `mdgraph help` or `mdgraph help <command>` for the full CLI reference.
|
|
150
|
+
|
|
151
|
+
True MMR packing is opt-in; document round-robin remains the compatibility default. See [Retrieval and Context](./docs/EN/Retrieval_and_Context.md). Watcher polling is also explicit (`watch --poll` or `serve --mcp --watch-poll`) because it can increase I/O and CPU use; see [Operations](./docs/EN/Operations.md).
|
|
152
|
+
|
|
153
|
+
The experimental `query` command provides a bounded, parameterized DSL for document governance without changing `search` or the five-tool MCP surface.
|
|
154
|
+
|
|
155
|
+
The experimental `relationships derive` command creates low-weight `RELATED_TO` edges only from a fresh, complete semantic-model index after independent-evidence and reciprocal-neighbor gates pass. It never runs automatically during indexing or watch mode. Both experimental workflows are documented in [Structured Query and Relationships](./docs/EN/Structured_Query_and_Relationships.md).
|
|
138
156
|
|
|
139
|
-
|
|
157
|
+
The experimental `wiki` group deterministically plans pages, prepares bounded evidence briefs, reports update impact, and verifies maintenance fields, sources, and relative links. MDGraph does not generate or overwrite Wiki prose; use the host-agent workflow in [Knowledge Cards and Wiki Workflow](./docs/EN/Knowledge_Cards_and_Wiki_Workflow.md).
|
|
158
|
+
|
|
159
|
+
To preserve a Wiki plan's authored pages while refreshing its evidence, use `mdgraph wiki plan --from <plan> --out <next-plan> --path <project>`. Add `--wiki-dir wiki` when migrating a v1 plan. New plans use v2; review suggestions before adopting them. `current` describes dependency consistency, and `wiki verify` does not evaluate prose correctness.
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Optional Ollama Embeddings
|
|
164
|
+
|
|
165
|
+
Real semantic retrieval is opt-in; the deterministic FTS5/entity/graph pipeline remains the default. Start Ollama locally and install an embedding model:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
ollama pull nomic-embed-text
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Configure `.mdgraph/config.json` (the other config sections may remain unchanged):
|
|
172
|
+
|
|
173
|
+
```json
|
|
174
|
+
{
|
|
175
|
+
"embedding": {
|
|
176
|
+
"enabled": true,
|
|
177
|
+
"provider": "ollama",
|
|
178
|
+
"model": "nomic-embed-text",
|
|
179
|
+
"dimensions": 768,
|
|
180
|
+
"endpoint": "http://127.0.0.1:11434",
|
|
181
|
+
"timeoutMs": 30000,
|
|
182
|
+
"batchSize": 16
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
mdgraph index --full --semantic --path /your/project
|
|
189
|
+
mdgraph semantic status --path /your/project
|
|
190
|
+
mdgraph search --semantic --path /your/project "authentication login"
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Query-time provider failures fall back to FTS5/entity/graph results and emit a diagnostic. Explicit semantic indexing fails before replacing the existing graph, so it cannot commit partial vector coverage. `local-hash` remains available for compatibility but is a lexical feature hash, not a language-model embedding.
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Why Teams Can Trust It
|
|
140
198
|
|
|
141
199
|
- **Local by default.** Markdown, chunks, vectors, and SQLite artifacts stay in the project environment.
|
|
142
200
|
- **Explainable by design.** Results retain matching reasons, entities, edge provenance, confidence, paths, and budget information where relevant.
|
|
@@ -146,15 +204,19 @@ Use `mdgraph help` or `mdgraph help <command>` for the full CLI reference.
|
|
|
146
204
|
|
|
147
205
|
---
|
|
148
206
|
|
|
149
|
-
## Documentation Map
|
|
150
|
-
|
|
151
|
-
- `docs/EN/
|
|
152
|
-
- `docs/EN/
|
|
153
|
-
- `docs/EN/
|
|
207
|
+
## Documentation Map
|
|
208
|
+
|
|
209
|
+
- `docs/EN/README.md` — task-oriented documentation index.
|
|
210
|
+
- `docs/EN/Architecture.md` — pipeline, module boundaries, data flow, tradeoffs.
|
|
211
|
+
- `docs/EN/Agent_Integration.md` — MCP setup, shared agent instructions, host notes.
|
|
212
|
+
- `docs/EN/Retrieval_and_Context.md` — search channels, embedding providers, entity extraction, CJK behavior, and context packing.
|
|
213
|
+
- `docs/EN/Structured_Query_and_Relationships.md` — structured governance DSL and explicit derived relationships.
|
|
214
|
+
- `docs/EN/Operations.md` — index freshness, watcher health, polling, and provider recovery.
|
|
215
|
+
- `docs/EN/Public_Contracts.md` — stable public surfaces, compatibility policy, release gates.
|
|
154
216
|
- `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
217
|
- `docs/EN/Output_Contracts.md` — JSON output shapes for CLI and MCP consumers.
|
|
156
218
|
- `docs/EN/Evaluation_Questions.md` — retrieval/evaluation prompts.
|
|
157
|
-
- `docs/EN/Release_Checklist.md` — release validation checklist.
|
|
219
|
+
- `docs/EN/Release_Checklist.md` — release validation checklist.
|
|
158
220
|
- `agent-pack/` — reusable MCP config, instructions, and prompt templates.
|
|
159
221
|
|
|
160
222
|
---
|
|
@@ -170,7 +232,7 @@ Use `mdgraph help` or `mdgraph help <command>` for the full CLI reference.
|
|
|
170
232
|
|
|
171
233
|
## Requirements
|
|
172
234
|
|
|
173
|
-
- Node.js `>=22.5.0`
|
|
235
|
+
- Node.js `>=22.5.0` with an FTS5-enabled `node:sqlite` build. Node 22.23.2 and 26.5.0 are verified; the version number alone does not guarantee FTS5. Use a current Node 22 or newer release.
|
|
174
236
|
- SQLite support from Node's built-in `node:sqlite`
|
|
175
237
|
- Markdown files in a local project directory
|
|
176
238
|
|
package/agent-pack/README.md
CHANGED
|
@@ -10,6 +10,8 @@ This pack contains reusable guidance for MCP-capable coding agents. It keeps hos
|
|
|
10
10
|
- [`prompts/task-start-context.md`](prompts/task-start-context.md): prompt template for task-start documentation briefs.
|
|
11
11
|
- [`prompts/relationship-trace.md`](prompts/relationship-trace.md): prompt template for relationship and dependency questions.
|
|
12
12
|
- [`prompts/status-doctor.md`](prompts/status-doctor.md): prompt template for readiness, stale-index, and documentation health checks.
|
|
13
|
+
- [`prompts/wiki-authoring.md`](prompts/wiki-authoring.md): prompt template for evidence-backed Wiki page creation and maintenance.
|
|
14
|
+
- [`skills/wiki-authoring/SKILL.md`](skills/wiki-authoring/SKILL.md): reusable skill for WikiPlan, per-page brief, status, and verification workflows.
|
|
13
15
|
|
|
14
16
|
## Host Placement
|
|
15
17
|
|
|
@@ -18,4 +18,6 @@ Default order for Markdown/documentation questions:
|
|
|
18
18
|
- Prefer returned context when it includes enough content, reasons, provenance, source refs, and risk notes.
|
|
19
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
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.
|
|
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.
|
|
22
|
+
|
|
23
|
+
See the [Agent Integration guide](../docs/EN/Agent_Integration.md) for the shared setup and host-specific placement notes.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Create or update a project Wiki
|
|
2
|
+
|
|
3
|
+
Use MDGraph to prepare evidence, then author the Markdown after reading the sources.
|
|
4
|
+
|
|
5
|
+
1. Check the index and existing Wiki status. Refresh stale evidence within the requested maintenance scope.
|
|
6
|
+
2. Create a plan or preserve an existing one with `wiki plan --from <plan> --out <next-plan>`. Specify `--wiki-dir` for v1 migration. Review suggested pages, sources, and gaps before adopting changes.
|
|
7
|
+
3. For each affected page, obtain `wiki brief`. Use the primary documents, supplementary material, source inspection paths, and Card ownership labels. Resolve stale or unknown evidence before accepting its hash.
|
|
8
|
+
4. Preserve correct prose and selected sources. Update `wiki_id`, `evidence_hash`, `source_docs`, and `source_refs` from the reviewed plan. Both source fields are arrays; additional author-selected sources should be added to the plan instead of silently removed.
|
|
9
|
+
5. Run `wiki verify`; fix the affected page's maintenance, link, and evidence issues. Do not delete orphaned pages automatically.
|
|
10
|
+
6. Execute the key documented user steps and record the revision, commands, results, and limitations separately. Verification does not evaluate prose correctness.
|
|
11
|
+
|
|
12
|
+
See the [Knowledge Cards and Wiki Workflow](../../docs/EN/Knowledge_Cards_and_Wiki_Workflow.md) guide and the [reusable Wiki authoring skill](../skills/wiki-authoring/SKILL.md) for the full maintenance contract.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wiki-authoring
|
|
3
|
+
description: Author or update a user-maintained project Wiki from MDGraph plans and page evidence. Use for project handbook creation and maintenance.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Wiki Authoring
|
|
7
|
+
|
|
8
|
+
MDGraph locates evidence and reports dependency changes. The host agent reads source material and writes the prose.
|
|
9
|
+
|
|
10
|
+
## Workflow
|
|
11
|
+
|
|
12
|
+
1. Check index availability and refresh stale Markdown evidence within the user's requested maintenance scope.
|
|
13
|
+
2. For a new Wiki, run `mdgraph wiki plan --wiki-dir <wiki-dir> --out <plan-file> --path <project>`. For an existing Wiki, first run `wiki status <wiki-dir> --plan <plan-file> --json --path <project>`.
|
|
14
|
+
3. Update an existing plan with `wiki plan --from <plan-file> --out <next-plan> --path <project>`. Add `--wiki-dir <wiki-dir>` when migrating a v1 plan. Review suggestions and gaps. Keep stable page IDs, user-authored goals, outlines, and source selections. Explicitly adopt useful suggested pages/sources before refreshing the plan. Preserve the previous file for recovery.
|
|
15
|
+
4. Run `wiki brief <page-id> --plan <reviewed-plan> --json --path <project>` for each affected page. Inspect `strictFreshness`, `dependencyEvidence`, and `evidenceGaps`. A stale or unknown brief can be read, but its evidence hash must not be treated as current.
|
|
16
|
+
5. Read `sourceDocuments` as the selected primary material. Use `supplementaryDocuments` for additional context and perform the listed `sourceInspections` before making implementation claims. Card association distinguishes direct evidence, inherited context, and related background.
|
|
17
|
+
6. Preserve correct existing prose. Update only affected pages unless the user asks for a broader rewrite. Maintain:
|
|
18
|
+
|
|
19
|
+
```yaml
|
|
20
|
+
---
|
|
21
|
+
wiki_id: <page-id>
|
|
22
|
+
evidence_hash: <hash from the current reviewed brief>
|
|
23
|
+
source_docs:
|
|
24
|
+
- <project-relative-markdown-path>
|
|
25
|
+
source_refs:
|
|
26
|
+
- <project-relative-source-path>
|
|
27
|
+
---
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Both source fields are arrays; use `[]` when empty. If the author needs additional sources, add them to the plan's selected dependencies and refresh its evidence before synchronizing the page. Do not discard user-selected references merely to make verification pass.
|
|
31
|
+
7. Run `wiki verify <wiki-dir> --plan <reviewed-plan> --json --path <project>`. Repair issues attributable to the current page and preserve unrelated pages. Review orphaned pages without automatically deleting them.
|
|
32
|
+
8. Separately check prose correctness: execute the key documented workflow, inspect supporting source, and record commands, outcomes, the code revision, and unverified claims. `current` and `valid: true` describe dependency/maintenance consistency; they do not prove prose accuracy.
|
|
33
|
+
|
|
34
|
+
## Recovery
|
|
35
|
+
|
|
36
|
+
Restore the previous plan or page copy if an update is unsuitable. For changed dependencies, refresh the index and plan, then obtain a new brief. For unavailable paths, inspect the reported source and restore it or explicitly revise the selection. Keep Wiki output outside its own source evidence.
|
|
37
|
+
|
|
38
|
+
The workflow remains usable without embeddings, a Source Bridge, or a generation provider. MDGraph commands never generate or overwrite Wiki prose.
|
|
@@ -10,4 +10,11 @@ export interface StatusFreshness {
|
|
|
10
10
|
reason: "added" | "deleted" | "modified";
|
|
11
11
|
}>;
|
|
12
12
|
}
|
|
13
|
-
export
|
|
13
|
+
export interface StatusFreshnessOptions {
|
|
14
|
+
/** Compare Markdown bytes with the indexed document hashes. This detects edits
|
|
15
|
+
* whose mtime was intentionally preserved; the default remains the cheap mtime check. */
|
|
16
|
+
strictContentHash?: boolean;
|
|
17
|
+
/** Project-relative Markdown paths outside the source snapshot being evaluated. */
|
|
18
|
+
ignorePaths?: string[];
|
|
19
|
+
}
|
|
20
|
+
export declare function computeStatusFreshness(projectRoot: string, config: MDGraphConfig, repository: GraphRepository, options?: StatusFreshnessOptions): StatusFreshness;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { scanMarkdownFilesSync } from "../scanner/file-scanner.js";
|
|
4
|
+
import { contentHash } from "../utils/id.js";
|
|
4
5
|
import { normalizePath } from "../utils/text.js";
|
|
5
|
-
export function computeStatusFreshness(projectRoot, config, repository) {
|
|
6
|
+
export function computeStatusFreshness(projectRoot, config, repository, options = {}) {
|
|
6
7
|
const lastIndexedAt = repository.latestIndexedAt();
|
|
7
8
|
const checkedAt = new Date().toISOString();
|
|
8
9
|
if (!lastIndexedAt) {
|
|
@@ -16,19 +17,26 @@ export function computeStatusFreshness(projectRoot, config, repository) {
|
|
|
16
17
|
const indexedAtMs = Date.parse(lastIndexedAt);
|
|
17
18
|
const scanned = scanMarkdownFilesSync(projectRoot, config);
|
|
18
19
|
const indexed = repository.documentHashes();
|
|
19
|
-
const
|
|
20
|
+
const ignored = new Set((options.ignorePaths ?? []).map(normalizePath));
|
|
21
|
+
const isIgnored = (relativePath) => [...ignored].some((ignoredPath) => relativePath === ignoredPath || relativePath.startsWith(`${ignoredPath}/`));
|
|
22
|
+
const scannedByPath = new Map(scanned
|
|
23
|
+
.map((filePath) => [normalizePath(path.relative(projectRoot, filePath)), filePath])
|
|
24
|
+
.filter(([relativePath]) => !isIgnored(relativePath)));
|
|
20
25
|
const issues = [];
|
|
21
26
|
for (const [relativePath, absolutePath] of scannedByPath) {
|
|
22
27
|
if (!indexed.has(relativePath)) {
|
|
23
28
|
issues.push({ path: relativePath, reason: "added" });
|
|
24
29
|
continue;
|
|
25
30
|
}
|
|
26
|
-
|
|
31
|
+
const changed = options.strictContentHash
|
|
32
|
+
? contentHash(fs.readFileSync(absolutePath, "utf8")) !== indexed.get(relativePath).hash
|
|
33
|
+
: Number.isFinite(indexedAtMs) && fs.statSync(absolutePath).mtimeMs > indexedAtMs + 1;
|
|
34
|
+
if (changed) {
|
|
27
35
|
issues.push({ path: relativePath, reason: "modified" });
|
|
28
36
|
}
|
|
29
37
|
}
|
|
30
38
|
for (const documentPath of indexed.keys()) {
|
|
31
|
-
if (!scannedByPath.has(documentPath)) {
|
|
39
|
+
if (!isIgnored(documentPath) && !scannedByPath.has(documentPath)) {
|
|
32
40
|
issues.push({ path: documentPath, reason: "deleted" });
|
|
33
41
|
}
|
|
34
42
|
}
|
|
@@ -39,8 +47,13 @@ export function computeStatusFreshness(projectRoot, config, repository) {
|
|
|
39
47
|
checkedAt,
|
|
40
48
|
recommendation: sortedIssues.length
|
|
41
49
|
? "Markdown files changed since indexing; run `mdgraph index` before relying on results"
|
|
42
|
-
:
|
|
43
|
-
|
|
50
|
+
: options.strictContentHash
|
|
51
|
+
? "indexed Markdown files match the strict content-hash freshness check"
|
|
52
|
+
: "indexed Markdown files match the lightweight status freshness check",
|
|
53
|
+
// Strict callers make policy decisions from this list (for example, which
|
|
54
|
+
// Wiki pages depend on a changed document), so never truncate their evidence.
|
|
55
|
+
// Existing lightweight status callers retain the bounded public payload.
|
|
56
|
+
issues: sortedIssues.length ? (options.strictContentHash ? sortedIssues : sortedIssues.slice(0, 20)) : undefined
|
|
44
57
|
};
|
|
45
58
|
}
|
|
46
59
|
catch (error) {
|