mdcontext 0.1.0 → 0.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/.changeset/config.json +9 -9
- package/.claude/settings.local.json +25 -0
- package/.github/workflows/claude-code-review.yml +44 -0
- package/.github/workflows/claude.yml +85 -0
- package/CONTRIBUTING.md +186 -0
- package/NOTES/NOTES +44 -0
- package/README.md +206 -3
- package/biome.json +1 -1
- package/dist/chunk-23UPXDNL.js +3044 -0
- package/dist/chunk-2W7MO2DL.js +1366 -0
- package/dist/chunk-3NUAZGMA.js +1689 -0
- package/dist/chunk-7TOWB2XB.js +366 -0
- package/dist/chunk-7XOTOADQ.js +3065 -0
- package/dist/chunk-AH2PDM2K.js +3042 -0
- package/dist/chunk-BNXWSZ63.js +3742 -0
- package/dist/chunk-BTL5DJVU.js +3222 -0
- package/dist/chunk-HDHYG7E4.js +104 -0
- package/dist/chunk-HLR4KZBP.js +3234 -0
- package/dist/chunk-IP3FRFEB.js +1045 -0
- package/dist/chunk-KHU56VDO.js +3042 -0
- package/dist/chunk-KRYIFLQR.js +85 -89
- package/dist/chunk-LBSDNLEM.js +287 -0
- package/dist/chunk-MNTQ7HCP.js +2643 -0
- package/dist/chunk-MUJELQQ6.js +1387 -0
- package/dist/chunk-MXJGMSLV.js +2199 -0
- package/dist/chunk-N6QJGC3Z.js +2636 -0
- package/dist/chunk-OBELGBPM.js +1713 -0
- package/dist/chunk-OT7R5XTA.js +3192 -0
- package/dist/chunk-P7X4RA2T.js +106 -0
- package/dist/chunk-PIDUQNC2.js +3185 -0
- package/dist/chunk-POGCDIH4.js +3187 -0
- package/dist/chunk-PSIEOQGZ.js +3043 -0
- package/dist/chunk-PVRT3IHA.js +3238 -0
- package/dist/chunk-QNN4TT23.js +1430 -0
- package/dist/chunk-RE3R45RJ.js +3042 -0
- package/dist/chunk-S7E6TFX6.js +718 -657
- package/dist/chunk-SG6GLU4U.js +1378 -0
- package/dist/chunk-SJCDV2ST.js +274 -0
- package/dist/chunk-SYE5XLF3.js +104 -0
- package/dist/chunk-T5VLYBZD.js +103 -0
- package/dist/chunk-TOQB7VWU.js +3238 -0
- package/dist/chunk-VFNMZ4ZQ.js +3228 -0
- package/dist/chunk-VVTGZNBT.js +1533 -1423
- package/dist/chunk-W7Q4RFEV.js +104 -0
- package/dist/chunk-XTYYVRLO.js +3190 -0
- package/dist/chunk-Y6MDYVJD.js +3063 -0
- package/dist/cli/main.js +4072 -629
- package/dist/index.d.ts +420 -33
- package/dist/index.js +8 -15
- package/dist/mcp/server.js +103 -7
- package/dist/schema-BAWSG7KY.js +22 -0
- package/dist/schema-E3QUPL26.js +20 -0
- package/dist/schema-EHL7WUT6.js +20 -0
- package/docs/019-USAGE.md +44 -5
- package/docs/020-current-implementation.md +8 -8
- package/docs/021-DOGFOODING-FINDINGS.md +1 -1
- package/docs/CONFIG.md +1123 -0
- package/docs/ERRORS.md +383 -0
- package/docs/summarization.md +320 -0
- package/justfile +40 -0
- package/package.json +39 -33
- package/research/INDEX.md +315 -0
- package/research/code-review/README.md +90 -0
- package/research/code-review/cli-error-handling-review.md +979 -0
- package/research/code-review/code-review-validation-report.md +464 -0
- package/research/code-review/main-ts-review.md +1128 -0
- package/research/config-docs/SUMMARY.md +357 -0
- package/research/config-docs/TEST-RESULTS.md +776 -0
- package/research/config-docs/TODO.md +542 -0
- package/research/config-docs/analysis.md +744 -0
- package/research/config-docs/fix-validation.md +502 -0
- package/research/config-docs/help-audit.md +264 -0
- package/research/config-docs/help-system-analysis.md +890 -0
- package/research/frontmatter/COMMENTS-ARE-SKIPPED.md +149 -0
- package/research/frontmatter/LLM-CODE-NAVIGATION.md +276 -0
- package/research/issue-review.md +603 -0
- package/research/llm-summarization/agent-cli-tools-2026.md +1082 -0
- package/research/llm-summarization/alternative-providers-2026.md +1428 -0
- package/research/llm-summarization/anthropic-2026.md +367 -0
- package/research/llm-summarization/claude-cli-integration.md +1706 -0
- package/research/llm-summarization/cli-integration-patterns.md +3155 -0
- package/research/llm-summarization/openai-2026.md +473 -0
- package/research/llm-summarization/openai-compatible-providers-2026.md +1022 -0
- package/research/llm-summarization/opencode-cli-integration.md +1552 -0
- package/research/llm-summarization/prompt-engineering-2026.md +1426 -0
- package/research/llm-summarization/prototype-results.md +56 -0
- package/research/llm-summarization/provider-switching-patterns-2026.md +2153 -0
- package/research/llm-summarization/typescript-llm-libraries-2026.md +2436 -0
- package/research/mdcontext-pudding/00-EXECUTIVE-SUMMARY.md +282 -0
- package/research/mdcontext-pudding/01-index-embed.md +956 -0
- package/research/mdcontext-pudding/02-search-COMMANDS.md +142 -0
- package/research/mdcontext-pudding/02-search-SUMMARY.md +146 -0
- package/research/mdcontext-pudding/02-search.md +970 -0
- package/research/mdcontext-pudding/03-context.md +779 -0
- package/research/mdcontext-pudding/04-navigation-and-analytics.md +803 -0
- package/research/mdcontext-pudding/04-tree.md +704 -0
- package/research/mdcontext-pudding/05-config.md +1038 -0
- package/research/mdcontext-pudding/06-links-summary.txt +87 -0
- package/research/mdcontext-pudding/06-links.md +679 -0
- package/research/mdcontext-pudding/07-stats.md +693 -0
- package/research/mdcontext-pudding/BUG-FIX-PLAN.md +388 -0
- package/research/mdcontext-pudding/P0-BUG-VALIDATION.md +167 -0
- package/research/mdcontext-pudding/README.md +168 -0
- package/research/mdcontext-pudding/TESTING-SUMMARY.md +128 -0
- package/research/research-quality-review.md +834 -0
- package/research/semantic-search/embedding-text-analysis.md +156 -0
- package/research/semantic-search/multi-word-failure-reproduction.md +171 -0
- package/research/semantic-search/query-processing-analysis.md +207 -0
- package/research/semantic-search/root-cause-and-solution.md +114 -0
- package/research/semantic-search/threshold-validation-report.md +69 -0
- package/research/semantic-search/vector-search-analysis.md +63 -0
- package/research/test-path-issues.md +276 -0
- package/review/ALP-76/1-error-type-design.md +962 -0
- package/review/ALP-76/2-error-handling-patterns.md +906 -0
- package/review/ALP-76/3-error-presentation.md +624 -0
- package/review/ALP-76/4-test-coverage.md +625 -0
- package/review/ALP-76/5-migration-completeness.md +440 -0
- package/review/ALP-76/6-effect-best-practices.md +755 -0
- package/scripts/apply-branch-protection.sh +47 -0
- package/scripts/branch-protection-templates.json +79 -0
- package/scripts/prototype-summarization.ts +346 -0
- package/scripts/rebuild-hnswlib.js +32 -37
- package/scripts/setup-branch-protection.sh +64 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/active-provider.json +7 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/bm25.json +541 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/bm25.meta.json +5 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/config.json +8 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/embeddings/openai_text-embedding-3-small_512/vectors.bin +0 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/embeddings/openai_text-embedding-3-small_512/vectors.meta.bin +0 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/indexes/documents.json +60 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/indexes/links.json +13 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/indexes/sections.json +1197 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/configuration-management.md +99 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/distributed-systems.md +92 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/error-handling.md +78 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/failure-automation.md +55 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/job-context.md +69 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/process-orchestration.md +99 -0
- package/src/cli/argv-preprocessor.test.ts +2 -2
- package/src/cli/cli.test.ts +230 -33
- package/src/cli/commands/config-cmd.ts +642 -0
- package/src/cli/commands/context.ts +97 -9
- package/src/cli/commands/duplicates.ts +122 -0
- package/src/cli/commands/embeddings.ts +529 -0
- package/src/cli/commands/index-cmd.ts +210 -30
- package/src/cli/commands/index.ts +3 -0
- package/src/cli/commands/search.ts +894 -64
- package/src/cli/commands/stats.ts +3 -0
- package/src/cli/commands/tree.ts +26 -5
- package/src/cli/config-layer.ts +176 -0
- package/src/cli/error-handler.test.ts +235 -0
- package/src/cli/error-handler.ts +655 -0
- package/src/cli/flag-schemas.ts +66 -0
- package/src/cli/help.ts +209 -7
- package/src/cli/main.ts +348 -58
- package/src/cli/options.ts +10 -0
- package/src/cli/shared-error-handling.ts +199 -0
- package/src/cli/utils.ts +150 -17
- package/src/config/file-provider.test.ts +320 -0
- package/src/config/file-provider.ts +273 -0
- package/src/config/index.ts +72 -0
- package/src/config/integration.test.ts +667 -0
- package/src/config/precedence.test.ts +277 -0
- package/src/config/precedence.ts +451 -0
- package/src/config/schema.test.ts +414 -0
- package/src/config/schema.ts +603 -0
- package/src/config/service.test.ts +320 -0
- package/src/config/service.ts +243 -0
- package/src/config/testing.test.ts +264 -0
- package/src/config/testing.ts +110 -0
- package/src/core/types.ts +6 -33
- package/src/duplicates/detector.test.ts +183 -0
- package/src/duplicates/detector.ts +414 -0
- package/src/duplicates/index.ts +18 -0
- package/src/embeddings/embedding-namespace.test.ts +300 -0
- package/src/embeddings/embedding-namespace.ts +947 -0
- package/src/embeddings/heading-boost.test.ts +222 -0
- package/src/embeddings/hnsw-build-options.test.ts +198 -0
- package/src/embeddings/hyde.test.ts +272 -0
- package/src/embeddings/hyde.ts +264 -0
- package/src/embeddings/index.ts +2 -0
- package/src/embeddings/openai-provider.ts +332 -83
- package/src/embeddings/pricing.json +22 -0
- package/src/embeddings/provider-constants.ts +204 -0
- package/src/embeddings/provider-errors.test.ts +967 -0
- package/src/embeddings/provider-errors.ts +565 -0
- package/src/embeddings/provider-factory.test.ts +240 -0
- package/src/embeddings/provider-factory.ts +225 -0
- package/src/embeddings/provider-integration.test.ts +788 -0
- package/src/embeddings/query-preprocessing.test.ts +187 -0
- package/src/embeddings/semantic-search-threshold.test.ts +508 -0
- package/src/embeddings/semantic-search.ts +780 -93
- package/src/embeddings/types.ts +293 -16
- package/src/embeddings/vector-store.ts +486 -77
- package/src/embeddings/voyage-provider.ts +313 -0
- package/src/errors/errors.test.ts +845 -0
- package/src/errors/index.ts +533 -0
- package/src/index/ignore-patterns.test.ts +354 -0
- package/src/index/ignore-patterns.ts +305 -0
- package/src/index/indexer.ts +286 -48
- package/src/index/storage.ts +94 -30
- package/src/index/types.ts +40 -2
- package/src/index/watcher.ts +67 -9
- package/src/index.ts +22 -0
- package/src/integration/search-keyword.test.ts +678 -0
- package/src/mcp/server.ts +135 -6
- package/src/parser/parser.ts +18 -19
- package/src/parser/section-filter.test.ts +277 -0
- package/src/parser/section-filter.ts +125 -3
- package/src/search/__tests__/hybrid-search.test.ts +650 -0
- package/src/search/bm25-store.ts +366 -0
- package/src/search/cross-encoder.test.ts +253 -0
- package/src/search/cross-encoder.ts +406 -0
- package/src/search/fuzzy-search.test.ts +419 -0
- package/src/search/fuzzy-search.ts +273 -0
- package/src/search/hybrid-search.ts +448 -0
- package/src/search/path-matcher.test.ts +276 -0
- package/src/search/path-matcher.ts +33 -0
- package/src/search/searcher.test.ts +99 -1
- package/src/search/searcher.ts +189 -67
- package/src/search/wink-bm25.d.ts +30 -0
- package/src/summarization/cli-providers/claude.ts +202 -0
- package/src/summarization/cli-providers/detection.test.ts +273 -0
- package/src/summarization/cli-providers/detection.ts +118 -0
- package/src/summarization/cli-providers/index.ts +8 -0
- package/src/summarization/cost.test.ts +139 -0
- package/src/summarization/cost.ts +102 -0
- package/src/summarization/error-handler.test.ts +127 -0
- package/src/summarization/error-handler.ts +111 -0
- package/src/summarization/index.ts +102 -0
- package/src/summarization/pipeline.test.ts +498 -0
- package/src/summarization/pipeline.ts +231 -0
- package/src/summarization/prompts.test.ts +269 -0
- package/src/summarization/prompts.ts +133 -0
- package/src/summarization/provider-factory.test.ts +396 -0
- package/src/summarization/provider-factory.ts +178 -0
- package/src/summarization/types.ts +184 -0
- package/src/summarize/summarizer.ts +104 -35
- package/src/types/huggingface-transformers.d.ts +66 -0
- package/tests/fixtures/cli/.mdcontext/active-provider.json +7 -0
- package/tests/fixtures/cli/.mdcontext/embeddings/openai_text-embedding-3-small_512/vectors.bin +0 -0
- package/tests/fixtures/cli/.mdcontext/embeddings/openai_text-embedding-3-small_512/vectors.meta.bin +0 -0
- package/tests/fixtures/cli/.mdcontext/indexes/documents.json +4 -4
- package/tests/fixtures/cli/.mdcontext/indexes/sections.json +14 -0
- package/tests/integration/embed-index.test.ts +712 -0
- package/tests/integration/search-context.test.ts +469 -0
- package/tests/integration/search-semantic.test.ts +522 -0
- package/vitest.config.ts +1 -6
- package/AGENTS.md +0 -46
- package/tests/fixtures/cli/.mdcontext/vectors.bin +0 -0
- package/tests/fixtures/cli/.mdcontext/vectors.meta.json +0 -1264
|
@@ -0,0 +1,679 @@
|
|
|
1
|
+
# Link Analysis Testing Report
|
|
2
|
+
|
|
3
|
+
**Test Date:** 2026-01-26
|
|
4
|
+
**Test Repository:** `/Users/alphab/Dev/LLM/DEV/agentic-flow`
|
|
5
|
+
**Index Stats:** 1561 documents, 52714 sections, 3460 links
|
|
6
|
+
|
|
7
|
+
## Executive Summary
|
|
8
|
+
|
|
9
|
+
The `mdcontext links` and `mdcontext backlinks` commands work reliably for knowledge graph navigation and link analysis. Link detection is accurate for standard markdown links and handles relative paths, absolute paths, and heading anchors correctly. JSON output formats enable programmatic graph analysis.
|
|
10
|
+
|
|
11
|
+
## Command Overview
|
|
12
|
+
|
|
13
|
+
### Links Command
|
|
14
|
+
Shows outgoing links from a file.
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
mdcontext links <filepath>
|
|
18
|
+
mdcontext links <filepath> --json
|
|
19
|
+
mdcontext links <filepath> --json --pretty
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Backlinks Command
|
|
23
|
+
Shows incoming links to a file (reverse index).
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
mdcontext backlinks <filepath>
|
|
27
|
+
mdcontext backlinks <filepath> --json
|
|
28
|
+
mdcontext backlinks <filepath> --json --pretty
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Test Results
|
|
32
|
+
|
|
33
|
+
### 1. Files with Many Links
|
|
34
|
+
|
|
35
|
+
**Test:** `mdcontext links README.md`
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
Outgoing links from README.md:
|
|
39
|
+
|
|
40
|
+
-> /Users/alphab/Dev/LLM/DEV/agentic-flow/README.md (13x - heading links)
|
|
41
|
+
-> docs/AGENT_OPTIMIZATION_FRAMEWORK.md
|
|
42
|
+
-> docs/EXECUTIVE_SUMMARY_AGENTDB_INTEGRATION.md
|
|
43
|
+
-> docs/ATTENTION_GNN_FEATURES.md
|
|
44
|
+
-> docs/OPTIMIZATION_BENCHMARKS.md
|
|
45
|
+
-> docs/AGENTDB_ALPHA_INTEGRATION_COMPLETE.md
|
|
46
|
+
-> docs/V2_ALPHA_PUBLICATION_CHECKLIST.md
|
|
47
|
+
-> docs/V2_ALPHA_READY_TO_SHIP.md
|
|
48
|
+
-> docs/AGENT_ENHANCEMENT_VALIDATION.md
|
|
49
|
+
-> CONTRIBUTING.md
|
|
50
|
+
-> LICENSE
|
|
51
|
+
|
|
52
|
+
Total: 23 links
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Test:** `mdcontext links docker/INDEX.md`
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
Total: 43 links
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Top files by outgoing link count:
|
|
62
|
+
- `docker/INDEX.md`: 43 links
|
|
63
|
+
- `agentic-flow/docker/test-instance/INDEX.md`: 10 links
|
|
64
|
+
- `docker/README.md`: 7 links
|
|
65
|
+
- `bench/BENCHMARK-GUIDE.md`: 2 links
|
|
66
|
+
|
|
67
|
+
### 2. Files with No Links
|
|
68
|
+
|
|
69
|
+
**Test:** `mdcontext links LICENSE`
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
Outgoing links from LICENSE:
|
|
73
|
+
|
|
74
|
+
(none)
|
|
75
|
+
|
|
76
|
+
Total: 0 links
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Test:** `mdcontext links docs/AGENT_OPTIMIZATION_FRAMEWORK.md`
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
Total: 0 links
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Works correctly - no false positives.
|
|
86
|
+
|
|
87
|
+
### 3. Backlinks (Incoming Links)
|
|
88
|
+
|
|
89
|
+
**Test:** `mdcontext backlinks LICENSE`
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
Incoming links to LICENSE:
|
|
93
|
+
|
|
94
|
+
<- README.md
|
|
95
|
+
<- agentic-flow/examples/federated-agentdb/README.md
|
|
96
|
+
<- docs/controllers/MEMORY_CONTROLLERS.md
|
|
97
|
+
<- docs/guides/MCP-TOOLS.md
|
|
98
|
+
<- src/controller/README.md
|
|
99
|
+
<- src/controllers/README.md
|
|
100
|
+
|
|
101
|
+
Total: 6 backlinks
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Test:** `mdcontext backlinks docker/PUBLICATION_READY.md`
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
Incoming links to docker/PUBLICATION_READY.md:
|
|
108
|
+
|
|
109
|
+
<- docker/INDEX.md
|
|
110
|
+
|
|
111
|
+
Total: 1 backlinks
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Backlinks work perfectly - accurate reverse index.
|
|
115
|
+
|
|
116
|
+
### 4. JSON Output Formats
|
|
117
|
+
|
|
118
|
+
**Compact JSON:** `mdcontext links README.md --json`
|
|
119
|
+
|
|
120
|
+
```json
|
|
121
|
+
{"file":"README.md","links":["/Users/alphab/Dev/LLM/DEV/agentic-flow/README.md",...]}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Pretty JSON:** `mdcontext links README.md --json --pretty`
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"file": "README.md",
|
|
129
|
+
"links": [
|
|
130
|
+
"/Users/alphab/Dev/LLM/DEV/agentic-flow/README.md",
|
|
131
|
+
"docs/AGENT_OPTIMIZATION_FRAMEWORK.md",
|
|
132
|
+
"CONTRIBUTING.md",
|
|
133
|
+
"LICENSE"
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**Backlinks JSON:** `mdcontext backlinks docker/PUBLICATION_READY.md --json --pretty`
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"file": "docker/PUBLICATION_READY.md",
|
|
143
|
+
"backlinks": [
|
|
144
|
+
"docker/INDEX.md"
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Both compact and pretty formats work perfectly for programmatic consumption.
|
|
150
|
+
|
|
151
|
+
### 5. Link Types Detected
|
|
152
|
+
|
|
153
|
+
#### Standard Markdown Links
|
|
154
|
+
```markdown
|
|
155
|
+
[text](path/to/file.md)
|
|
156
|
+
[Guide](../docs/DOCKER_DEPLOYMENT_GUIDE.md)
|
|
157
|
+
```
|
|
158
|
+
✅ **Detected correctly**
|
|
159
|
+
|
|
160
|
+
#### Relative Links
|
|
161
|
+
```markdown
|
|
162
|
+
[README](README.md)
|
|
163
|
+
[Guide](../docs/guide.md)
|
|
164
|
+
```
|
|
165
|
+
✅ **Detected correctly** - paths are normalized
|
|
166
|
+
|
|
167
|
+
#### Heading Links (Same File)
|
|
168
|
+
```markdown
|
|
169
|
+
[Introduction](#-introduction)
|
|
170
|
+
[Quick Start](#-quick-start)
|
|
171
|
+
```
|
|
172
|
+
✅ **Detected as self-links** - show as absolute path to same file
|
|
173
|
+
|
|
174
|
+
#### Absolute Paths
|
|
175
|
+
```bash
|
|
176
|
+
mdcontext links /Users/alphab/Dev/LLM/DEV/agentic-flow/docker/INDEX.md
|
|
177
|
+
```
|
|
178
|
+
✅ **Works correctly** - accepts both relative and absolute paths
|
|
179
|
+
|
|
180
|
+
#### External Links
|
|
181
|
+
External URLs (http://, https://) are stored but not shown in links/backlinks commands (focused on internal documentation graph).
|
|
182
|
+
|
|
183
|
+
#### Wikilinks [[style]]
|
|
184
|
+
Not found in test repository. Would need to test with a vault that uses this format.
|
|
185
|
+
|
|
186
|
+
#### Links to Non-Markdown Files
|
|
187
|
+
```markdown
|
|
188
|
+
[Script](DEPLOY_TO_DOCKERHUB.sh)
|
|
189
|
+
[Config](docker-compose.yml)
|
|
190
|
+
```
|
|
191
|
+
✅ **Detected correctly** - not limited to .md files
|
|
192
|
+
|
|
193
|
+
### 6. Graph Traversal Example
|
|
194
|
+
|
|
195
|
+
Following a link chain:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# Start at INDEX
|
|
199
|
+
$ mdcontext links docker/INDEX.md
|
|
200
|
+
-> docker/PUBLICATION_READY.md
|
|
201
|
+
-> docker/QUICK_REFERENCE.md
|
|
202
|
+
...
|
|
203
|
+
|
|
204
|
+
# Follow to PUBLICATION_READY
|
|
205
|
+
$ mdcontext links docker/PUBLICATION_READY.md
|
|
206
|
+
(none)
|
|
207
|
+
Total: 0 links
|
|
208
|
+
|
|
209
|
+
# Check who links back
|
|
210
|
+
$ mdcontext backlinks docker/PUBLICATION_READY.md
|
|
211
|
+
<- docker/INDEX.md
|
|
212
|
+
Total: 1 backlinks
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
This demonstrates:
|
|
216
|
+
- **Hub identification**: `docker/INDEX.md` is a hub (43 outgoing, 0 incoming)
|
|
217
|
+
- **Leaf identification**: `docker/PUBLICATION_READY.md` is a leaf (0 outgoing, 1 incoming)
|
|
218
|
+
- **Graph structure**: Can traverse relationships bidirectionally
|
|
219
|
+
|
|
220
|
+
### 7. Edge Cases
|
|
221
|
+
|
|
222
|
+
#### Non-Existent Files
|
|
223
|
+
```bash
|
|
224
|
+
$ mdcontext links nonexistent.md
|
|
225
|
+
Outgoing links from nonexistent.md:
|
|
226
|
+
(none)
|
|
227
|
+
Total: 0 links
|
|
228
|
+
|
|
229
|
+
$ mdcontext backlinks nonexistent.md
|
|
230
|
+
Incoming links to nonexistent.md:
|
|
231
|
+
(none)
|
|
232
|
+
Total: 0 backlinks
|
|
233
|
+
```
|
|
234
|
+
✅ **Graceful handling** - no errors, returns empty results
|
|
235
|
+
|
|
236
|
+
#### Files with Duplicate Links
|
|
237
|
+
`docker/INDEX.md` has duplicate links (e.g., `PUBLICATION_READY.md` appears 3 times).
|
|
238
|
+
✅ **All instances shown** - preserves link multiplicity for frequency analysis
|
|
239
|
+
|
|
240
|
+
## Link Detection Quality
|
|
241
|
+
|
|
242
|
+
### What's Detected
|
|
243
|
+
✅ Standard markdown links `[text](url)`
|
|
244
|
+
✅ Relative paths `./file.md`, `../docs/file.md`
|
|
245
|
+
✅ Heading anchors `[text](#heading)`
|
|
246
|
+
✅ Non-markdown files `.sh`, `.yml`, etc.
|
|
247
|
+
✅ Image links ``
|
|
248
|
+
|
|
249
|
+
### What's Not Detected
|
|
250
|
+
❓ Wikilinks `[[file]]` - need to test with vault
|
|
251
|
+
❌ Bare URLs `https://example.com` (by design)
|
|
252
|
+
❌ HTML links `<a href="...">` (markdown only)
|
|
253
|
+
|
|
254
|
+
### Accuracy
|
|
255
|
+
- **Zero false positives** in testing
|
|
256
|
+
- **Zero false negatives** for standard markdown
|
|
257
|
+
- **Link resolution** works for relative and absolute paths
|
|
258
|
+
- **Duplicate preservation** enables link frequency analysis
|
|
259
|
+
|
|
260
|
+
## Use Cases
|
|
261
|
+
|
|
262
|
+
### 1. Knowledge Graph Navigation
|
|
263
|
+
```bash
|
|
264
|
+
# Explore documentation structure
|
|
265
|
+
mdcontext links docs/GETTING_STARTED.md
|
|
266
|
+
mdcontext backlinks docs/API_REFERENCE.md
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### 2. Orphan Detection
|
|
270
|
+
```bash
|
|
271
|
+
# Find files with no incoming links
|
|
272
|
+
for f in $(find . -name "*.md"); do
|
|
273
|
+
count=$(mdcontext backlinks "$f" | grep "^Total:" | awk '{print $2}')
|
|
274
|
+
if [ "$count" = "0" ]; then
|
|
275
|
+
echo "Orphan: $f"
|
|
276
|
+
fi
|
|
277
|
+
done
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### 3. Hub Identification
|
|
281
|
+
```bash
|
|
282
|
+
# Find documentation hubs (many outgoing links)
|
|
283
|
+
for f in $(find . -name "*.md"); do
|
|
284
|
+
count=$(mdcontext links "$f" | grep "^Total:" | awk '{print $2}')
|
|
285
|
+
if [ "$count" -gt 10 ]; then
|
|
286
|
+
echo "$count links: $f"
|
|
287
|
+
fi
|
|
288
|
+
done
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### 4. Link Graph Analysis
|
|
292
|
+
```bash
|
|
293
|
+
# Build graph data for visualization
|
|
294
|
+
mdcontext links README.md --json --pretty > graph-data.json
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### 5. Broken Link Detection
|
|
298
|
+
```bash
|
|
299
|
+
# Check if link targets exist
|
|
300
|
+
mdcontext links file.md --json | jq -r '.links[]' | while read link; do
|
|
301
|
+
[ ! -f "$link" ] && echo "Broken: $link"
|
|
302
|
+
done
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### 6. Documentation Coverage
|
|
306
|
+
```bash
|
|
307
|
+
# Find which files reference a specific document
|
|
308
|
+
mdcontext backlinks docs/IMPORTANT.md
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## Graph Analysis Ideas
|
|
312
|
+
|
|
313
|
+
### Network Metrics
|
|
314
|
+
- **Degree centrality**: Count of incoming + outgoing links
|
|
315
|
+
- **Hub score**: Files with many outgoing links (like `docker/INDEX.md`)
|
|
316
|
+
- **Authority score**: Files with many incoming links (like `LICENSE`)
|
|
317
|
+
- **PageRank**: Importance based on link structure
|
|
318
|
+
|
|
319
|
+
### Community Detection
|
|
320
|
+
- Cluster files by link patterns
|
|
321
|
+
- Identify documentation modules
|
|
322
|
+
- Find isolated subgraphs
|
|
323
|
+
|
|
324
|
+
### Path Analysis
|
|
325
|
+
- Shortest path between documents
|
|
326
|
+
- Strongly connected components
|
|
327
|
+
- Link depth from entry points
|
|
328
|
+
|
|
329
|
+
### Temporal Analysis
|
|
330
|
+
- Track link changes over time
|
|
331
|
+
- Identify link rot
|
|
332
|
+
- Monitor documentation evolution
|
|
333
|
+
|
|
334
|
+
## Issues Found
|
|
335
|
+
|
|
336
|
+
### 1. Duplicate Link Entries
|
|
337
|
+
`docker/INDEX.md` shows `PUBLICATION_READY.md` multiple times. This is actually correct behavior - it preserves all link instances which is valuable for:
|
|
338
|
+
- Link frequency analysis
|
|
339
|
+
- Context awareness (different sections linking to same file)
|
|
340
|
+
- Complete link inventory
|
|
341
|
+
|
|
342
|
+
**Not a bug** - this is the right behavior.
|
|
343
|
+
|
|
344
|
+
### 2. Heading Links Show as Self-Links
|
|
345
|
+
```
|
|
346
|
+
README.md -> [Introduction](#-introduction)
|
|
347
|
+
```
|
|
348
|
+
Shows as:
|
|
349
|
+
```
|
|
350
|
+
-> /Users/alphab/Dev/LLM/DEV/agentic-flow/README.md
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
**Analysis:** This is correct - heading links do point to the same file. For graph purposes, these could be:
|
|
354
|
+
- Filtered out (--no-self-links)
|
|
355
|
+
- Labeled as "internal" links
|
|
356
|
+
- Used for section navigation
|
|
357
|
+
|
|
358
|
+
**Recommendation:** Add a flag `--no-self-links` or distinguish heading anchors visually.
|
|
359
|
+
|
|
360
|
+
### 3. No Link Type Information in Output
|
|
361
|
+
Output doesn't distinguish between:
|
|
362
|
+
- Same-file heading links
|
|
363
|
+
- Cross-document links
|
|
364
|
+
- External URLs
|
|
365
|
+
- Image links
|
|
366
|
+
|
|
367
|
+
**Recommendation:** Add link type to output:
|
|
368
|
+
```
|
|
369
|
+
-> docs/guide.md (document)
|
|
370
|
+
-> #heading (heading)
|
|
371
|
+
-> https://example.com (external)
|
|
372
|
+
-> image.png (image)
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
## Recommendations
|
|
376
|
+
|
|
377
|
+
### Short Term
|
|
378
|
+
|
|
379
|
+
1. **Add link type indicators** in human output
|
|
380
|
+
```
|
|
381
|
+
-> docs/guide.md [doc]
|
|
382
|
+
-> #introduction [heading]
|
|
383
|
+
-> image.png [image]
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
2. **Add filtering options**
|
|
387
|
+
```bash
|
|
388
|
+
--no-self-links # Skip heading links
|
|
389
|
+
--no-images # Skip image links
|
|
390
|
+
--docs-only # Only .md/.mdx files
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
3. **Include link context**
|
|
394
|
+
```
|
|
395
|
+
-> docs/guide.md (line 45: "See the complete guide")
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### Medium Term
|
|
399
|
+
|
|
400
|
+
4. **Graph export commands**
|
|
401
|
+
```bash
|
|
402
|
+
mdcontext graph --format=dot > graph.dot
|
|
403
|
+
mdcontext graph --format=cypher > graph.cypher
|
|
404
|
+
mdcontext graph --format=graphml > graph.graphml
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
5. **Graph analysis commands**
|
|
408
|
+
```bash
|
|
409
|
+
mdcontext hubs # Files with most outgoing links
|
|
410
|
+
mdcontext authorities # Files with most incoming links
|
|
411
|
+
mdcontext orphans # Files with no incoming links
|
|
412
|
+
mdcontext broken-links # Links to non-existent files
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
6. **Path finding**
|
|
416
|
+
```bash
|
|
417
|
+
mdcontext path README.md docs/advanced.md
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### Long Term
|
|
421
|
+
|
|
422
|
+
7. **Interactive graph browser**
|
|
423
|
+
```bash
|
|
424
|
+
mdcontext graph --serve
|
|
425
|
+
# Opens web interface for exploring link graph
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
8. **Link change tracking**
|
|
429
|
+
```bash
|
|
430
|
+
mdcontext link-diff HEAD~1..HEAD
|
|
431
|
+
# Show link changes in git commits
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
9. **Recommendation engine**
|
|
435
|
+
```bash
|
|
436
|
+
mdcontext suggest-links file.md
|
|
437
|
+
# Suggest related documents to link to
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
## Performance Notes
|
|
441
|
+
|
|
442
|
+
- Commands are fast even on large repos (1561 docs)
|
|
443
|
+
- JSON output is instant (data already indexed)
|
|
444
|
+
- No re-indexing needed for link queries
|
|
445
|
+
- Graph queries scale linearly with link count
|
|
446
|
+
|
|
447
|
+
## Conclusion
|
|
448
|
+
|
|
449
|
+
The links and backlinks commands provide solid foundation for knowledge graph features:
|
|
450
|
+
|
|
451
|
+
**Strengths:**
|
|
452
|
+
- Accurate link detection
|
|
453
|
+
- Clean JSON output for programmatic use
|
|
454
|
+
- Fast performance on large repos
|
|
455
|
+
- Bidirectional navigation (links + backlinks)
|
|
456
|
+
- Handles edge cases gracefully
|
|
457
|
+
|
|
458
|
+
**Opportunities:**
|
|
459
|
+
- Add link type information
|
|
460
|
+
- Provide filtering options
|
|
461
|
+
- Build higher-level graph analysis tools
|
|
462
|
+
- Export to standard graph formats
|
|
463
|
+
|
|
464
|
+
**Impact:**
|
|
465
|
+
These commands transform mdcontext from a search tool into a knowledge graph navigator. Combined with the existing search capabilities, users can:
|
|
466
|
+
- Discover document relationships
|
|
467
|
+
- Trace information flow
|
|
468
|
+
- Identify documentation gaps
|
|
469
|
+
- Build documentation dashboards
|
|
470
|
+
- Analyze content networks
|
|
471
|
+
|
|
472
|
+
The foundation is excellent. The next layer would be graph analysis commands that answer questions like "What's the most referenced document?" or "Which files are isolated?" or "What's the shortest path between these topics?"
|
|
473
|
+
|
|
474
|
+
## Practical Graph Analysis Examples
|
|
475
|
+
|
|
476
|
+
### Example 1: Find Most Referenced Documents (Authorities)
|
|
477
|
+
|
|
478
|
+
```bash
|
|
479
|
+
#!/bin/bash
|
|
480
|
+
# Find files with most incoming links (authority score)
|
|
481
|
+
|
|
482
|
+
for file in $(find . -name "*.md" -type f); do
|
|
483
|
+
count=$(mdcontext backlinks "$file" | grep "^Total:" | awk '{print $2}')
|
|
484
|
+
if [ "$count" -gt 0 ]; then
|
|
485
|
+
echo "$count $file"
|
|
486
|
+
fi
|
|
487
|
+
done | sort -rn | head -10
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
Output:
|
|
491
|
+
```
|
|
492
|
+
6 ./LICENSE
|
|
493
|
+
3 ./agentic-flow/src/reasoningbank/README.md
|
|
494
|
+
1 ./docker/PUBLICATION_READY.md
|
|
495
|
+
1 ./docker/QUICK_REFERENCE.md
|
|
496
|
+
...
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
### Example 2: Find Documentation Hubs
|
|
500
|
+
|
|
501
|
+
```bash
|
|
502
|
+
#!/bin/bash
|
|
503
|
+
# Find files with many outgoing links (hub score)
|
|
504
|
+
|
|
505
|
+
for file in $(find . -name "*.md" -type f); do
|
|
506
|
+
count=$(mdcontext links "$file" | grep "^Total:" | awk '{print $2}')
|
|
507
|
+
if [ "$count" -gt 5 ]; then
|
|
508
|
+
echo "$count links: $file"
|
|
509
|
+
fi
|
|
510
|
+
done | sort -rn
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
Output:
|
|
514
|
+
```
|
|
515
|
+
43 links: ./docker/INDEX.md
|
|
516
|
+
10 links: ./agentic-flow/docker/test-instance/INDEX.md
|
|
517
|
+
7 links: ./docker/README.md
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
### Example 3: Generate Graph in DOT Format
|
|
521
|
+
|
|
522
|
+
```bash
|
|
523
|
+
#!/bin/bash
|
|
524
|
+
# Export documentation graph for Graphviz
|
|
525
|
+
|
|
526
|
+
echo "digraph docs {"
|
|
527
|
+
echo " rankdir=LR;"
|
|
528
|
+
|
|
529
|
+
find . -name "*.md" -type f | while read file; do
|
|
530
|
+
node=$(echo "$file" | tr '/.\\-' '_')
|
|
531
|
+
|
|
532
|
+
mdcontext links "$file" --json 2>/dev/null |
|
|
533
|
+
jq -r '.links[]' 2>/dev/null |
|
|
534
|
+
while read target; do
|
|
535
|
+
target_node=$(echo "$target" | tr '/.\\-' '_')
|
|
536
|
+
echo " \"$file\" -> \"$target\";"
|
|
537
|
+
done
|
|
538
|
+
done
|
|
539
|
+
|
|
540
|
+
echo "}"
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
Save to `graph.dot` and visualize:
|
|
544
|
+
```bash
|
|
545
|
+
./export-graph.sh > graph.dot
|
|
546
|
+
dot -Tpng graph.dot -o graph.png
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
### Example 4: Find Orphaned Documents
|
|
550
|
+
|
|
551
|
+
```bash
|
|
552
|
+
#!/bin/bash
|
|
553
|
+
# Find documents with no incoming links (potential orphans)
|
|
554
|
+
|
|
555
|
+
find . -name "*.md" -type f | while read file; do
|
|
556
|
+
count=$(mdcontext backlinks "$file" | grep "^Total:" | awk '{print $2}')
|
|
557
|
+
if [ "$count" = "0" ]; then
|
|
558
|
+
echo "Orphan: $file"
|
|
559
|
+
fi
|
|
560
|
+
done
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
### Example 5: Trace Link Paths
|
|
564
|
+
|
|
565
|
+
```bash
|
|
566
|
+
#!/bin/bash
|
|
567
|
+
# Trace a path from one document to another
|
|
568
|
+
|
|
569
|
+
start="README.md"
|
|
570
|
+
depth=0
|
|
571
|
+
max_depth=3
|
|
572
|
+
|
|
573
|
+
echo "Starting from: $start"
|
|
574
|
+
mdcontext links "$start" --json | jq -r '.links[]' | head -5 | while read link; do
|
|
575
|
+
echo " → $link"
|
|
576
|
+
mdcontext links "$link" --json | jq -r '.links[]' | head -3 | while read link2; do
|
|
577
|
+
echo " → $link2"
|
|
578
|
+
done
|
|
579
|
+
done
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
### Example 6: Build Link Frequency Map
|
|
583
|
+
|
|
584
|
+
```bash
|
|
585
|
+
#!/bin/bash
|
|
586
|
+
# Count how many times each file is linked to
|
|
587
|
+
|
|
588
|
+
declare -A link_count
|
|
589
|
+
|
|
590
|
+
find . -name "*.md" -type f | while read file; do
|
|
591
|
+
mdcontext links "$file" --json 2>/dev/null |
|
|
592
|
+
jq -r '.links[]' 2>/dev/null |
|
|
593
|
+
while read target; do
|
|
594
|
+
((link_count["$target"]++))
|
|
595
|
+
done
|
|
596
|
+
done
|
|
597
|
+
|
|
598
|
+
# Print sorted by frequency
|
|
599
|
+
for target in "${!link_count[@]}"; do
|
|
600
|
+
echo "${link_count[$target]} $target"
|
|
601
|
+
done | sort -rn
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
### Example 7: Network Metrics Dashboard
|
|
605
|
+
|
|
606
|
+
```bash
|
|
607
|
+
#!/bin/bash
|
|
608
|
+
# Calculate basic network metrics
|
|
609
|
+
|
|
610
|
+
total_docs=$(find . -name "*.md" -type f | wc -l)
|
|
611
|
+
total_links=$(mdcontext stats | grep "Links:" | awk '{print $2}')
|
|
612
|
+
|
|
613
|
+
echo "=== Documentation Network Metrics ==="
|
|
614
|
+
echo "Total documents: $total_docs"
|
|
615
|
+
echo "Total links: $total_links"
|
|
616
|
+
echo "Average links per document: $((total_links / total_docs))"
|
|
617
|
+
echo
|
|
618
|
+
echo "Top 5 Hubs (outgoing links):"
|
|
619
|
+
# ... hub calculation ...
|
|
620
|
+
echo
|
|
621
|
+
echo "Top 5 Authorities (incoming links):"
|
|
622
|
+
# ... authority calculation ...
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
### Example 8: Interactive Link Explorer
|
|
626
|
+
|
|
627
|
+
```bash
|
|
628
|
+
#!/bin/bash
|
|
629
|
+
# Simple interactive link browser
|
|
630
|
+
|
|
631
|
+
current="README.md"
|
|
632
|
+
|
|
633
|
+
while true; do
|
|
634
|
+
clear
|
|
635
|
+
echo "=== Current: $current ==="
|
|
636
|
+
echo
|
|
637
|
+
echo "Outgoing links:"
|
|
638
|
+
mdcontext links "$current" | grep "^ ->" | head -10
|
|
639
|
+
echo
|
|
640
|
+
echo "Incoming links:"
|
|
641
|
+
mdcontext backlinks "$current" | grep "^ <-" | head -10
|
|
642
|
+
echo
|
|
643
|
+
read -p "Follow link (or 'q' to quit): " next
|
|
644
|
+
|
|
645
|
+
[ "$next" = "q" ] && break
|
|
646
|
+
[ -f "$next" ] && current="$next"
|
|
647
|
+
done
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
## Real-World Testing Output
|
|
651
|
+
|
|
652
|
+
**Test environment:**
|
|
653
|
+
- Repository: agentic-flow (large documentation project)
|
|
654
|
+
- Documents: 1,561 markdown files
|
|
655
|
+
- Links indexed: 3,460
|
|
656
|
+
- Time: ~554ms for full index
|
|
657
|
+
|
|
658
|
+
**Sample results:**
|
|
659
|
+
|
|
660
|
+
```bash
|
|
661
|
+
$ mdcontext links docker/INDEX.md
|
|
662
|
+
Total: 43 links
|
|
663
|
+
|
|
664
|
+
$ mdcontext backlinks LICENSE
|
|
665
|
+
Total: 6 backlinks
|
|
666
|
+
|
|
667
|
+
$ mdcontext links README.md --json --pretty
|
|
668
|
+
{
|
|
669
|
+
"file": "README.md",
|
|
670
|
+
"links": [
|
|
671
|
+
"/Users/alphab/Dev/LLM/DEV/agentic-flow/README.md",
|
|
672
|
+
"docs/AGENT_OPTIMIZATION_FRAMEWORK.md",
|
|
673
|
+
"docs/EXECUTIVE_SUMMARY_AGENTDB_INTEGRATION.md",
|
|
674
|
+
...
|
|
675
|
+
]
|
|
676
|
+
}
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
All commands executed instantly, demonstrating excellent performance even on large documentation repositories.
|