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.
Files changed (251) hide show
  1. package/.changeset/config.json +9 -9
  2. package/.claude/settings.local.json +25 -0
  3. package/.github/workflows/claude-code-review.yml +44 -0
  4. package/.github/workflows/claude.yml +85 -0
  5. package/CONTRIBUTING.md +186 -0
  6. package/NOTES/NOTES +44 -0
  7. package/README.md +206 -3
  8. package/biome.json +1 -1
  9. package/dist/chunk-23UPXDNL.js +3044 -0
  10. package/dist/chunk-2W7MO2DL.js +1366 -0
  11. package/dist/chunk-3NUAZGMA.js +1689 -0
  12. package/dist/chunk-7TOWB2XB.js +366 -0
  13. package/dist/chunk-7XOTOADQ.js +3065 -0
  14. package/dist/chunk-AH2PDM2K.js +3042 -0
  15. package/dist/chunk-BNXWSZ63.js +3742 -0
  16. package/dist/chunk-BTL5DJVU.js +3222 -0
  17. package/dist/chunk-HDHYG7E4.js +104 -0
  18. package/dist/chunk-HLR4KZBP.js +3234 -0
  19. package/dist/chunk-IP3FRFEB.js +1045 -0
  20. package/dist/chunk-KHU56VDO.js +3042 -0
  21. package/dist/chunk-KRYIFLQR.js +85 -89
  22. package/dist/chunk-LBSDNLEM.js +287 -0
  23. package/dist/chunk-MNTQ7HCP.js +2643 -0
  24. package/dist/chunk-MUJELQQ6.js +1387 -0
  25. package/dist/chunk-MXJGMSLV.js +2199 -0
  26. package/dist/chunk-N6QJGC3Z.js +2636 -0
  27. package/dist/chunk-OBELGBPM.js +1713 -0
  28. package/dist/chunk-OT7R5XTA.js +3192 -0
  29. package/dist/chunk-P7X4RA2T.js +106 -0
  30. package/dist/chunk-PIDUQNC2.js +3185 -0
  31. package/dist/chunk-POGCDIH4.js +3187 -0
  32. package/dist/chunk-PSIEOQGZ.js +3043 -0
  33. package/dist/chunk-PVRT3IHA.js +3238 -0
  34. package/dist/chunk-QNN4TT23.js +1430 -0
  35. package/dist/chunk-RE3R45RJ.js +3042 -0
  36. package/dist/chunk-S7E6TFX6.js +718 -657
  37. package/dist/chunk-SG6GLU4U.js +1378 -0
  38. package/dist/chunk-SJCDV2ST.js +274 -0
  39. package/dist/chunk-SYE5XLF3.js +104 -0
  40. package/dist/chunk-T5VLYBZD.js +103 -0
  41. package/dist/chunk-TOQB7VWU.js +3238 -0
  42. package/dist/chunk-VFNMZ4ZQ.js +3228 -0
  43. package/dist/chunk-VVTGZNBT.js +1533 -1423
  44. package/dist/chunk-W7Q4RFEV.js +104 -0
  45. package/dist/chunk-XTYYVRLO.js +3190 -0
  46. package/dist/chunk-Y6MDYVJD.js +3063 -0
  47. package/dist/cli/main.js +4072 -629
  48. package/dist/index.d.ts +420 -33
  49. package/dist/index.js +8 -15
  50. package/dist/mcp/server.js +103 -7
  51. package/dist/schema-BAWSG7KY.js +22 -0
  52. package/dist/schema-E3QUPL26.js +20 -0
  53. package/dist/schema-EHL7WUT6.js +20 -0
  54. package/docs/019-USAGE.md +44 -5
  55. package/docs/020-current-implementation.md +8 -8
  56. package/docs/021-DOGFOODING-FINDINGS.md +1 -1
  57. package/docs/CONFIG.md +1123 -0
  58. package/docs/ERRORS.md +383 -0
  59. package/docs/summarization.md +320 -0
  60. package/justfile +40 -0
  61. package/package.json +39 -33
  62. package/research/INDEX.md +315 -0
  63. package/research/code-review/README.md +90 -0
  64. package/research/code-review/cli-error-handling-review.md +979 -0
  65. package/research/code-review/code-review-validation-report.md +464 -0
  66. package/research/code-review/main-ts-review.md +1128 -0
  67. package/research/config-docs/SUMMARY.md +357 -0
  68. package/research/config-docs/TEST-RESULTS.md +776 -0
  69. package/research/config-docs/TODO.md +542 -0
  70. package/research/config-docs/analysis.md +744 -0
  71. package/research/config-docs/fix-validation.md +502 -0
  72. package/research/config-docs/help-audit.md +264 -0
  73. package/research/config-docs/help-system-analysis.md +890 -0
  74. package/research/frontmatter/COMMENTS-ARE-SKIPPED.md +149 -0
  75. package/research/frontmatter/LLM-CODE-NAVIGATION.md +276 -0
  76. package/research/issue-review.md +603 -0
  77. package/research/llm-summarization/agent-cli-tools-2026.md +1082 -0
  78. package/research/llm-summarization/alternative-providers-2026.md +1428 -0
  79. package/research/llm-summarization/anthropic-2026.md +367 -0
  80. package/research/llm-summarization/claude-cli-integration.md +1706 -0
  81. package/research/llm-summarization/cli-integration-patterns.md +3155 -0
  82. package/research/llm-summarization/openai-2026.md +473 -0
  83. package/research/llm-summarization/openai-compatible-providers-2026.md +1022 -0
  84. package/research/llm-summarization/opencode-cli-integration.md +1552 -0
  85. package/research/llm-summarization/prompt-engineering-2026.md +1426 -0
  86. package/research/llm-summarization/prototype-results.md +56 -0
  87. package/research/llm-summarization/provider-switching-patterns-2026.md +2153 -0
  88. package/research/llm-summarization/typescript-llm-libraries-2026.md +2436 -0
  89. package/research/mdcontext-pudding/00-EXECUTIVE-SUMMARY.md +282 -0
  90. package/research/mdcontext-pudding/01-index-embed.md +956 -0
  91. package/research/mdcontext-pudding/02-search-COMMANDS.md +142 -0
  92. package/research/mdcontext-pudding/02-search-SUMMARY.md +146 -0
  93. package/research/mdcontext-pudding/02-search.md +970 -0
  94. package/research/mdcontext-pudding/03-context.md +779 -0
  95. package/research/mdcontext-pudding/04-navigation-and-analytics.md +803 -0
  96. package/research/mdcontext-pudding/04-tree.md +704 -0
  97. package/research/mdcontext-pudding/05-config.md +1038 -0
  98. package/research/mdcontext-pudding/06-links-summary.txt +87 -0
  99. package/research/mdcontext-pudding/06-links.md +679 -0
  100. package/research/mdcontext-pudding/07-stats.md +693 -0
  101. package/research/mdcontext-pudding/BUG-FIX-PLAN.md +388 -0
  102. package/research/mdcontext-pudding/P0-BUG-VALIDATION.md +167 -0
  103. package/research/mdcontext-pudding/README.md +168 -0
  104. package/research/mdcontext-pudding/TESTING-SUMMARY.md +128 -0
  105. package/research/research-quality-review.md +834 -0
  106. package/research/semantic-search/embedding-text-analysis.md +156 -0
  107. package/research/semantic-search/multi-word-failure-reproduction.md +171 -0
  108. package/research/semantic-search/query-processing-analysis.md +207 -0
  109. package/research/semantic-search/root-cause-and-solution.md +114 -0
  110. package/research/semantic-search/threshold-validation-report.md +69 -0
  111. package/research/semantic-search/vector-search-analysis.md +63 -0
  112. package/research/test-path-issues.md +276 -0
  113. package/review/ALP-76/1-error-type-design.md +962 -0
  114. package/review/ALP-76/2-error-handling-patterns.md +906 -0
  115. package/review/ALP-76/3-error-presentation.md +624 -0
  116. package/review/ALP-76/4-test-coverage.md +625 -0
  117. package/review/ALP-76/5-migration-completeness.md +440 -0
  118. package/review/ALP-76/6-effect-best-practices.md +755 -0
  119. package/scripts/apply-branch-protection.sh +47 -0
  120. package/scripts/branch-protection-templates.json +79 -0
  121. package/scripts/prototype-summarization.ts +346 -0
  122. package/scripts/rebuild-hnswlib.js +32 -37
  123. package/scripts/setup-branch-protection.sh +64 -0
  124. package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/active-provider.json +7 -0
  125. package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/bm25.json +541 -0
  126. package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/bm25.meta.json +5 -0
  127. package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/config.json +8 -0
  128. package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/embeddings/openai_text-embedding-3-small_512/vectors.bin +0 -0
  129. package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/embeddings/openai_text-embedding-3-small_512/vectors.meta.bin +0 -0
  130. package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/indexes/documents.json +60 -0
  131. package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/indexes/links.json +13 -0
  132. package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/indexes/sections.json +1197 -0
  133. package/src/__tests__/fixtures/semantic-search/multi-word-corpus/configuration-management.md +99 -0
  134. package/src/__tests__/fixtures/semantic-search/multi-word-corpus/distributed-systems.md +92 -0
  135. package/src/__tests__/fixtures/semantic-search/multi-word-corpus/error-handling.md +78 -0
  136. package/src/__tests__/fixtures/semantic-search/multi-word-corpus/failure-automation.md +55 -0
  137. package/src/__tests__/fixtures/semantic-search/multi-word-corpus/job-context.md +69 -0
  138. package/src/__tests__/fixtures/semantic-search/multi-word-corpus/process-orchestration.md +99 -0
  139. package/src/cli/argv-preprocessor.test.ts +2 -2
  140. package/src/cli/cli.test.ts +230 -33
  141. package/src/cli/commands/config-cmd.ts +642 -0
  142. package/src/cli/commands/context.ts +97 -9
  143. package/src/cli/commands/duplicates.ts +122 -0
  144. package/src/cli/commands/embeddings.ts +529 -0
  145. package/src/cli/commands/index-cmd.ts +210 -30
  146. package/src/cli/commands/index.ts +3 -0
  147. package/src/cli/commands/search.ts +894 -64
  148. package/src/cli/commands/stats.ts +3 -0
  149. package/src/cli/commands/tree.ts +26 -5
  150. package/src/cli/config-layer.ts +176 -0
  151. package/src/cli/error-handler.test.ts +235 -0
  152. package/src/cli/error-handler.ts +655 -0
  153. package/src/cli/flag-schemas.ts +66 -0
  154. package/src/cli/help.ts +209 -7
  155. package/src/cli/main.ts +348 -58
  156. package/src/cli/options.ts +10 -0
  157. package/src/cli/shared-error-handling.ts +199 -0
  158. package/src/cli/utils.ts +150 -17
  159. package/src/config/file-provider.test.ts +320 -0
  160. package/src/config/file-provider.ts +273 -0
  161. package/src/config/index.ts +72 -0
  162. package/src/config/integration.test.ts +667 -0
  163. package/src/config/precedence.test.ts +277 -0
  164. package/src/config/precedence.ts +451 -0
  165. package/src/config/schema.test.ts +414 -0
  166. package/src/config/schema.ts +603 -0
  167. package/src/config/service.test.ts +320 -0
  168. package/src/config/service.ts +243 -0
  169. package/src/config/testing.test.ts +264 -0
  170. package/src/config/testing.ts +110 -0
  171. package/src/core/types.ts +6 -33
  172. package/src/duplicates/detector.test.ts +183 -0
  173. package/src/duplicates/detector.ts +414 -0
  174. package/src/duplicates/index.ts +18 -0
  175. package/src/embeddings/embedding-namespace.test.ts +300 -0
  176. package/src/embeddings/embedding-namespace.ts +947 -0
  177. package/src/embeddings/heading-boost.test.ts +222 -0
  178. package/src/embeddings/hnsw-build-options.test.ts +198 -0
  179. package/src/embeddings/hyde.test.ts +272 -0
  180. package/src/embeddings/hyde.ts +264 -0
  181. package/src/embeddings/index.ts +2 -0
  182. package/src/embeddings/openai-provider.ts +332 -83
  183. package/src/embeddings/pricing.json +22 -0
  184. package/src/embeddings/provider-constants.ts +204 -0
  185. package/src/embeddings/provider-errors.test.ts +967 -0
  186. package/src/embeddings/provider-errors.ts +565 -0
  187. package/src/embeddings/provider-factory.test.ts +240 -0
  188. package/src/embeddings/provider-factory.ts +225 -0
  189. package/src/embeddings/provider-integration.test.ts +788 -0
  190. package/src/embeddings/query-preprocessing.test.ts +187 -0
  191. package/src/embeddings/semantic-search-threshold.test.ts +508 -0
  192. package/src/embeddings/semantic-search.ts +780 -93
  193. package/src/embeddings/types.ts +293 -16
  194. package/src/embeddings/vector-store.ts +486 -77
  195. package/src/embeddings/voyage-provider.ts +313 -0
  196. package/src/errors/errors.test.ts +845 -0
  197. package/src/errors/index.ts +533 -0
  198. package/src/index/ignore-patterns.test.ts +354 -0
  199. package/src/index/ignore-patterns.ts +305 -0
  200. package/src/index/indexer.ts +286 -48
  201. package/src/index/storage.ts +94 -30
  202. package/src/index/types.ts +40 -2
  203. package/src/index/watcher.ts +67 -9
  204. package/src/index.ts +22 -0
  205. package/src/integration/search-keyword.test.ts +678 -0
  206. package/src/mcp/server.ts +135 -6
  207. package/src/parser/parser.ts +18 -19
  208. package/src/parser/section-filter.test.ts +277 -0
  209. package/src/parser/section-filter.ts +125 -3
  210. package/src/search/__tests__/hybrid-search.test.ts +650 -0
  211. package/src/search/bm25-store.ts +366 -0
  212. package/src/search/cross-encoder.test.ts +253 -0
  213. package/src/search/cross-encoder.ts +406 -0
  214. package/src/search/fuzzy-search.test.ts +419 -0
  215. package/src/search/fuzzy-search.ts +273 -0
  216. package/src/search/hybrid-search.ts +448 -0
  217. package/src/search/path-matcher.test.ts +276 -0
  218. package/src/search/path-matcher.ts +33 -0
  219. package/src/search/searcher.test.ts +99 -1
  220. package/src/search/searcher.ts +189 -67
  221. package/src/search/wink-bm25.d.ts +30 -0
  222. package/src/summarization/cli-providers/claude.ts +202 -0
  223. package/src/summarization/cli-providers/detection.test.ts +273 -0
  224. package/src/summarization/cli-providers/detection.ts +118 -0
  225. package/src/summarization/cli-providers/index.ts +8 -0
  226. package/src/summarization/cost.test.ts +139 -0
  227. package/src/summarization/cost.ts +102 -0
  228. package/src/summarization/error-handler.test.ts +127 -0
  229. package/src/summarization/error-handler.ts +111 -0
  230. package/src/summarization/index.ts +102 -0
  231. package/src/summarization/pipeline.test.ts +498 -0
  232. package/src/summarization/pipeline.ts +231 -0
  233. package/src/summarization/prompts.test.ts +269 -0
  234. package/src/summarization/prompts.ts +133 -0
  235. package/src/summarization/provider-factory.test.ts +396 -0
  236. package/src/summarization/provider-factory.ts +178 -0
  237. package/src/summarization/types.ts +184 -0
  238. package/src/summarize/summarizer.ts +104 -35
  239. package/src/types/huggingface-transformers.d.ts +66 -0
  240. package/tests/fixtures/cli/.mdcontext/active-provider.json +7 -0
  241. package/tests/fixtures/cli/.mdcontext/embeddings/openai_text-embedding-3-small_512/vectors.bin +0 -0
  242. package/tests/fixtures/cli/.mdcontext/embeddings/openai_text-embedding-3-small_512/vectors.meta.bin +0 -0
  243. package/tests/fixtures/cli/.mdcontext/indexes/documents.json +4 -4
  244. package/tests/fixtures/cli/.mdcontext/indexes/sections.json +14 -0
  245. package/tests/integration/embed-index.test.ts +712 -0
  246. package/tests/integration/search-context.test.ts +469 -0
  247. package/tests/integration/search-semantic.test.ts +522 -0
  248. package/vitest.config.ts +1 -6
  249. package/AGENTS.md +0 -46
  250. package/tests/fixtures/cli/.mdcontext/vectors.bin +0 -0
  251. package/tests/fixtures/cli/.mdcontext/vectors.meta.json +0 -1264
@@ -1,11 +1,11 @@
1
1
  {
2
- "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
3
- "changelog": ["@changesets/changelog-github", { "repo": "alphab/mdcontext" }],
4
- "commit": false,
5
- "fixed": [],
6
- "linked": [],
7
- "access": "public",
8
- "baseBranch": "main",
9
- "updateInternalDependencies": "patch",
10
- "ignore": []
2
+ "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
3
+ "changelog": ["@changesets/changelog-github", { "repo": "alphab/mdcontext" }],
4
+ "commit": false,
5
+ "fixed": [],
6
+ "linked": [],
7
+ "access": "public",
8
+ "baseBranch": "main",
9
+ "updateInternalDependencies": "patch",
10
+ "ignore": []
11
11
  }
@@ -0,0 +1,25 @@
1
+ {
2
+ "permissions": {
3
+ "allow": ["mcp__linear-server", "Read", "Edit", "Write", "Bash", "WebFetch"]
4
+ },
5
+ "mcpServers": {
6
+ "linear-server": {
7
+ "type": "http",
8
+ "url": "https://mcp.linear.app/mcp"
9
+ }
10
+ },
11
+ "hooks": {
12
+ "PreToolUse": [
13
+ {
14
+ "matcher": "WebFetch|Read|Write|Edit",
15
+ "hooks": [
16
+ {
17
+ "type": "command",
18
+ "command": "/Users/alphab/Dev/LLM/DEV/TMP/nancy/skills/check-directives/check-directives.sh"
19
+ }
20
+ ]
21
+ }
22
+ ]
23
+ },
24
+ "outputStyle": "default"
25
+ }
@@ -0,0 +1,44 @@
1
+ name: Claude Code Review
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [main]
6
+ # Optional: Only run on specific file changes
7
+ # paths:
8
+ # - "src/**/*.ts"
9
+ # - "src/**/*.tsx"
10
+ # - "src/**/*.js"
11
+ # - "src/**/*.jsx"
12
+
13
+ jobs:
14
+ claude-review:
15
+ # Optional: Filter by PR author
16
+ # if: |
17
+ # github.event.pull_request.user.login == 'external-contributor' ||
18
+ # github.event.pull_request.user.login == 'new-developer' ||
19
+ # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
20
+
21
+ runs-on: ubuntu-latest
22
+ permissions:
23
+ contents: read
24
+ pull-requests: read
25
+ issues: read
26
+ id-token: write
27
+
28
+ steps:
29
+ - name: Checkout repository
30
+ uses: actions/checkout@v4
31
+ with:
32
+ fetch-depth: 1
33
+
34
+ - name: Run Claude Code Review
35
+ id: claude-review
36
+ uses: anthropics/claude-code-action@v1
37
+ with:
38
+ claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
39
+ plugin_marketplaces: 'https://github.com/anthropics/claude-code.git'
40
+ plugins: 'code-review@claude-code-plugins'
41
+ prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
42
+ # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
43
+ # or https://code.claude.com/docs/en/cli-reference for available options
44
+
@@ -0,0 +1,85 @@
1
+ name: Claude Code
2
+
3
+ on:
4
+ issue_comment:
5
+ types: [created]
6
+ pull_request_review_comment:
7
+ types: [created]
8
+ issues:
9
+ types: [opened, assigned]
10
+ pull_request_review:
11
+ types: [submitted]
12
+
13
+ jobs:
14
+ claude:
15
+ if: |
16
+ (
17
+ github.event_name == 'issue_comment' &&
18
+ contains(github.event.comment.body, '@claude') &&
19
+ (
20
+ github.event.comment.author_association == 'MEMBER' ||
21
+ github.event.comment.author_association == 'OWNER' ||
22
+ github.event.comment.author_association == 'COLLABORATOR'
23
+ )
24
+ ) ||
25
+ (
26
+ github.event_name == 'pull_request_review_comment' &&
27
+ contains(github.event.comment.body, '@claude') &&
28
+ (
29
+ github.event.comment.author_association == 'MEMBER' ||
30
+ github.event.comment.author_association == 'OWNER' ||
31
+ github.event.comment.author_association == 'COLLABORATOR'
32
+ )
33
+ ) ||
34
+ (
35
+ github.event_name == 'pull_request_review' &&
36
+ contains(github.event.review.body, '@claude') &&
37
+ (
38
+ github.event.review.author_association == 'MEMBER' ||
39
+ github.event.review.author_association == 'OWNER' ||
40
+ github.event.review.author_association == 'COLLABORATOR'
41
+ )
42
+ ) ||
43
+ (
44
+ github.event_name == 'issues' &&
45
+ (
46
+ contains(github.event.issue.body, '@claude') ||
47
+ contains(github.event.issue.title, '@claude')
48
+ ) &&
49
+ (
50
+ github.event.issue.author_association == 'MEMBER' ||
51
+ github.event.issue.author_association == 'OWNER' ||
52
+ github.event.issue.author_association == 'COLLABORATOR'
53
+ )
54
+ )
55
+ runs-on: ubuntu-latest
56
+ permissions:
57
+ contents: read
58
+ pull-requests: read
59
+ issues: read
60
+ id-token: write
61
+ actions: read # Required for Claude to read CI results on PRs
62
+ steps:
63
+ - name: Checkout repository
64
+ uses: actions/checkout@v4
65
+ with:
66
+ fetch-depth: 1
67
+
68
+ - name: Run Claude Code
69
+ id: claude
70
+ uses: anthropics/claude-code-action@v1
71
+ with:
72
+ claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
73
+
74
+ # This is an optional setting that allows Claude to read CI results on PRs
75
+ additional_permissions: |
76
+ actions: read
77
+
78
+ # Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
79
+ # prompt: 'Update the pull request description to include a summary of changes.'
80
+
81
+ # Optional: Add claude_args to customize behavior and configuration
82
+ # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
83
+ # or https://code.claude.com/docs/en/cli-reference for available options
84
+ # claude_args: '--allowed-tools Bash(gh pr:*)'
85
+
@@ -0,0 +1,186 @@
1
+ # Contributing to mdcontext
2
+
3
+ Thank you for your interest in contributing to mdcontext! This guide will help you get started.
4
+
5
+ ## Development Setup
6
+
7
+ ### Prerequisites
8
+
9
+ - Node.js >= 18.0.0
10
+ - pnpm (recommended, version 10+)
11
+ - Python 3.12+ (for native module compilation)
12
+
13
+ ### Getting Started
14
+
15
+ ```bash
16
+ # Clone the repository
17
+ git clone https://github.com/mdcontext/mdcontext.git
18
+ cd mdcontext
19
+
20
+ # Install dependencies
21
+ pnpm install
22
+
23
+ # Build the project
24
+ pnpm build
25
+
26
+ # Run tests
27
+ pnpm test
28
+ ```
29
+
30
+ ### Available Commands
31
+
32
+ | Command | Description |
33
+ |---------|-------------|
34
+ | `pnpm build` | Build the project |
35
+ | `pnpm test` | Run the test suite |
36
+ | `pnpm test:all` | Run tests including semantic search tests (requires `OPENAI_API_KEY`) |
37
+ | `pnpm typecheck` | Run TypeScript type checking |
38
+ | `pnpm lint` | Run Biome linter |
39
+ | `pnpm format` | Format code with Biome |
40
+ | `pnpm check` | Run format, lint, and typecheck |
41
+
42
+ ## Making Changes
43
+
44
+ 1. **Create a branch** for your changes:
45
+ ```bash
46
+ git checkout -b feature/my-awesome-feature
47
+ ```
48
+
49
+ 2. **Make your changes** and ensure:
50
+ - All tests pass: `pnpm test`
51
+ - Type checking passes: `pnpm typecheck`
52
+ - Code is formatted: `pnpm format`
53
+
54
+ 3. **Create a changeset** (see below)
55
+
56
+ 4. **Submit a pull request** to the `main` branch
57
+
58
+ ## Changeset Workflow
59
+
60
+ We use [Changesets](https://github.com/changesets/changesets) to manage versions and releases. **Every PR that affects the published package should include a changeset.**
61
+
62
+ ### Creating a Changeset
63
+
64
+ After making your changes, run:
65
+
66
+ ```bash
67
+ pnpm changeset
68
+ ```
69
+
70
+ This will prompt you to:
71
+ 1. Select the package (mdcontext)
72
+ 2. Choose a bump type (patch/minor/major)
73
+ 3. Write a summary of your changes
74
+
75
+ A markdown file will be created in the `.changeset/` directory. **Commit this file with your PR.**
76
+
77
+ ### Choosing a Bump Type
78
+
79
+ | Type | When to use | Example |
80
+ |------|-------------|---------|
81
+ | **patch** | Bug fixes, documentation updates, internal refactors | Fixing a search result formatting bug |
82
+ | **minor** | New features that are backwards compatible | Adding a new CLI flag or command |
83
+ | **major** | Breaking changes to public API or CLI | Changing command syntax, removing flags |
84
+
85
+ #### Examples
86
+
87
+ **Patch** (bug fix):
88
+ ```markdown
89
+ ---
90
+ "mdcontext": patch
91
+ ---
92
+
93
+ Fixed section extraction to correctly handle nested headings
94
+ ```
95
+
96
+ **Minor** (new feature):
97
+ ```markdown
98
+ ---
99
+ "mdcontext": minor
100
+ ---
101
+
102
+ Added --json flag to context command for structured output
103
+ ```
104
+
105
+ **Major** (breaking change):
106
+ ```markdown
107
+ ---
108
+ "mdcontext": major
109
+ ---
110
+
111
+ Changed search command syntax: path argument now comes before query
112
+
113
+ Migration: `mdcontext search "query" path/` becomes `mdcontext search path/ "query"`
114
+ ```
115
+
116
+ ### When You Don't Need a Changeset
117
+
118
+ - Documentation-only changes (README, comments)
119
+ - Test-only changes
120
+ - CI/tooling changes that don't affect the package
121
+ - Internal refactors with no user-facing changes
122
+
123
+ If the changesets bot comments on your PR asking for a changeset and you believe one isn't needed, you can add an empty changeset:
124
+
125
+ ```bash
126
+ pnpm changeset add --empty
127
+ ```
128
+
129
+ ## Release Process
130
+
131
+ Here's what happens after your PR is merged:
132
+
133
+ 1. **Changesets are collected**: The release workflow detects changeset files in `main`
134
+
135
+ 2. **Version Packages PR is created**: GitHub Actions creates a PR titled "chore: release packages" that:
136
+ - Bumps the version in `package.json`
137
+ - Updates `CHANGELOG.md` with your changeset descriptions
138
+ - Deletes the changeset files
139
+
140
+ 3. **Publish on merge**: When a maintainer merges the "Version Packages" PR:
141
+ - The package is automatically published to npm
142
+ - A GitHub release is created
143
+ - Package provenance is attached via npm's OIDC support
144
+
145
+ ### For Maintainers
146
+
147
+ To trigger a release:
148
+ 1. Review the auto-generated "Version Packages" PR
149
+ 2. Verify the version bump and changelog look correct
150
+ 3. Merge the PR
151
+ 4. The release happens automatically
152
+
153
+ ## Code Style
154
+
155
+ - We use [Biome](https://biomejs.dev/) for formatting and linting
156
+ - Run `pnpm format` before committing
157
+ - TypeScript strict mode is enabled
158
+ - Prefer functional patterns (Effect-TS is used throughout)
159
+
160
+ ## Testing
161
+
162
+ - Write tests for new features and bug fixes
163
+ - Tests are located in `*.test.ts` files alongside source files
164
+ - Use [Vitest](https://vitest.dev/) for testing
165
+ - Semantic search tests require `OPENAI_API_KEY` and are skipped by default
166
+
167
+ ### Running Specific Tests
168
+
169
+ ```bash
170
+ # Run a specific test file
171
+ pnpm vitest run src/search/searcher.test.ts
172
+
173
+ # Run tests matching a pattern
174
+ pnpm vitest run -t "keyword search"
175
+
176
+ # Watch mode during development
177
+ pnpm test:watch
178
+ ```
179
+
180
+ ## Questions?
181
+
182
+ - Open an issue for bugs or feature requests
183
+ - Check existing issues before creating new ones
184
+ - For questions about using mdcontext, see the README and docs/
185
+
186
+ Thank you for contributing!
package/NOTES/NOTES ADDED
@@ -0,0 +1,44 @@
1
+ ralph orchestrate search-enhancements
2
+ ralph orchestrate context-precision
3
+ ralph orchestrate embeddings-ux
4
+
5
+ - Semantic search with embeddings
6
+ - Boolean operators (AND, OR, NOT)
7
+ - Phrase search (exact match)
8
+ - Section-level context extraction
9
+ - Search context lines
10
+
11
+ Ideas for Part 3:
12
+ Option: A
13
+ Strategy: Feature Battle
14
+ Focus: Parallel agents each test ONE new feature (semantic,
15
+ boolean, phrase) - compare effectiveness
16
+ ────────────────────────────────────────
17
+ Option: B
18
+ Strategy: Meta-Dogfood
19
+ Focus: Use mdtldr to explore md-tldr's own codebase - eat our
20
+ own
21
+ dogfood
22
+ ────────────────────────────────────────
23
+ Option: C
24
+ Strategy: Query Refinement
25
+ Focus: Single agent that does iterative search, refining queries
26
+
27
+ based on results
28
+ ────────────────────────────────────────
29
+ Option: D
30
+ Strategy: Scale Test
31
+ Focus: Same docs corpus but with much larger token budgets, more
32
+
33
+ -----
34
+
35
+
36
+ Let have a subagent review
37
+ /Users/alphab/Dev/LLM/DEV/md-tldr/docs/002-research-embedding-
38
+ models.md
39
+ /Users/alphab/Dev/LLM/DEV/md-tldr/docs/003-research-rag-altern
40
+ atives.md
41
+ /Users/alphab/Dev/LLM/DEV/md-tldr/docs/004-research-vector-sea
42
+ rch.md
43
+
44
+ and document task candidates
package/README.md CHANGED
@@ -8,6 +8,7 @@ QUICK REFERENCE
8
8
  mdcontext search <query> [path] Search by meaning or structure
9
9
  mdcontext context <files...> Get LLM-ready summary
10
10
  mdcontext tree [path|file] Show files or document outline
11
+ mdcontext config <command> Configuration management (init, show, check)
11
12
  mdcontext links <file> Outgoing links
12
13
  mdcontext backlinks <file> Incoming links
13
14
  mdcontext stats [path] Index statistics
@@ -36,7 +37,7 @@ mdcontext context README.md # Get LLM-ready summary
36
37
  npm install -g mdcontext
37
38
  ```
38
39
 
39
- Requires Node.js 18+. Semantic search requires `OPENAI_API_KEY`.
40
+ Requires Node.js 18+. Semantic search requires an embedding provider (OpenAI, Ollama, LM Studio, OpenRouter, or Voyage). See [docs/CONFIG.md](./docs/CONFIG.md#embedding-providers) for provider setup.
40
41
 
41
42
  ---
42
43
 
@@ -63,7 +64,22 @@ Search by meaning (semantic) or keyword (text match).
63
64
  mdcontext search "how to authenticate" # Semantic search (if embeddings exist)
64
65
  mdcontext search -k "auth.*flow" # Keyword search (text match)
65
66
  mdcontext search -n 5 "setup" # Limit to 5 results
66
- mdcontext search --threshold 0.8 "deploy" # Higher similarity threshold
67
+ mdcontext search --threshold 0.25 "deploy" # Lower threshold for more results
68
+ ```
69
+
70
+ #### Similarity Threshold
71
+
72
+ Semantic search filters results by similarity score (0-1). Default: **0.35** (35%).
73
+
74
+ - **0 results?** Content may exist below the threshold. Try `--threshold 0.25`
75
+ - **Typical scores**: Single-word queries score ~30-40%, multi-word phrases ~50-70%
76
+ - **Higher threshold** = stricter matching, fewer results
77
+ - **Lower threshold** = more results, possibly less relevant
78
+
79
+ ```bash
80
+ mdcontext search "authentication" # Uses default 0.35 threshold
81
+ mdcontext search --threshold 0.25 "auth" # Lower threshold for broad queries
82
+ mdcontext search --threshold 0.6 "specific" # Higher threshold for precision
67
83
  ```
68
84
 
69
85
  #### Context Lines
@@ -77,6 +93,37 @@ mdcontext search "error" -B 2 -A 5 # 2 lines before, 5 lines after
77
93
 
78
94
  Auto-detection: Uses semantic search if embeddings exist and query looks like natural language. Use `-k` to force keyword search.
79
95
 
96
+ #### Advanced Search
97
+
98
+ **Quality Modes** - Control speed vs. accuracy tradeoff:
99
+ ```bash
100
+ mdcontext search "query" --quality fast # 40% faster, good recall
101
+ mdcontext search "query" -q thorough # Best recall, 30% slower
102
+ ```
103
+
104
+ **Re-ranking** - Boost precision by 20-35%:
105
+ ```bash
106
+ mdcontext search "query" --rerank # First use downloads 90MB model
107
+ npm install @huggingface/transformers # Required dependency
108
+ ```
109
+
110
+ **HyDE** - Better results for complex questions:
111
+ ```bash
112
+ mdcontext search "how to implement auth" --hyde # Expands query semantically
113
+ ```
114
+
115
+ #### AI Summarization
116
+
117
+ Generate AI-powered summaries of search results:
118
+
119
+ ```bash
120
+ mdcontext search "authentication" --summarize # Get AI summary of results
121
+ mdcontext search "error handling" -s --yes # Skip cost confirmation
122
+ mdcontext search "database" -s --stream # Stream output in real-time
123
+ ```
124
+
125
+ Uses your existing AI subscription (Claude Code, Copilot CLI) for free, or pay-per-use API providers. See [AI Summarization](#ai-summarization) for setup.
126
+
80
127
  ### context
81
128
 
82
129
  Get LLM-ready summaries from one or more files.
@@ -155,12 +202,29 @@ mdcontext search -k "Setup|Install" # By keyword pattern
155
202
 
156
203
  ### Setting Up Semantic Search
157
204
 
205
+ mdcontext supports multiple embedding providers for semantic search:
206
+
207
+ - **OpenAI** (default) - Cloud-based, requires API key
208
+ - **Ollama** - Free, local, daemon-based
209
+ - **LM Studio** - Free, local, GUI-based (development only)
210
+ - **OpenRouter** - Multi-provider gateway
211
+ - **Voyage** - Premium quality, competitive pricing
212
+
213
+ Quick start with OpenAI:
158
214
  ```bash
159
215
  export OPENAI_API_KEY=sk-...
160
216
  mdcontext index --embed # Build embeddings
161
217
  mdcontext search "how to deploy" # Now works semantically
162
218
  ```
163
219
 
220
+ Using Ollama (free, local):
221
+ ```bash
222
+ ollama serve && ollama pull nomic-embed-text
223
+ mdcontext index --embed --provider ollama --provider-model nomic-embed-text
224
+ ```
225
+
226
+ See [docs/CONFIG.md](./docs/CONFIG.md#embedding-providers) for complete provider setup, comparison, and configuration options.
227
+
164
228
  ---
165
229
 
166
230
  ## MCP Integration
@@ -203,6 +267,35 @@ For Claude Code, add to `.claude/settings.json`:
203
267
 
204
268
  ## Configuration
205
269
 
270
+ mdcontext supports a layered configuration system for persistent settings:
271
+
272
+ ```bash
273
+ # Create a config file
274
+ mdcontext config init
275
+
276
+ # Check your configuration
277
+ mdcontext config check
278
+
279
+ # Customize settings in mdcontext.config.js
280
+ ```
281
+
282
+ ```javascript
283
+ // mdcontext.config.js
284
+ /** @type {import('mdcontext').PartialMdContextConfig} */
285
+ export default {
286
+ index: {
287
+ excludePatterns: ['node_modules', '.git', 'dist', 'vendor']
288
+ },
289
+ search: {
290
+ defaultLimit: 20
291
+ }
292
+ }
293
+ ```
294
+
295
+ Configuration precedence: CLI flags > Environment variables > Config file > Defaults
296
+
297
+ **See [docs/CONFIG.md](./docs/CONFIG.md) for the complete configuration reference.**
298
+
206
299
  ### Index Location
207
300
 
208
301
  Indexes are stored in `.mdcontext/` in your project root:
@@ -220,7 +313,117 @@ Indexes are stored in `.mdcontext/` in your project root:
220
313
 
221
314
  | Variable | Description |
222
315
  |----------|-------------|
223
- | `OPENAI_API_KEY` | Required for semantic search |
316
+ | `OPENAI_API_KEY` | Required for OpenAI semantic search (default provider) |
317
+ | `OPENROUTER_API_KEY` | Required for OpenRouter semantic search |
318
+ | `MDCONTEXT_*` | Configuration overrides (see [CONFIG.md](./docs/CONFIG.md)) |
319
+
320
+ ---
321
+
322
+ ## AI Summarization
323
+
324
+ Transform search results into actionable insights using AI.
325
+
326
+ ### Quick Start
327
+
328
+ ```bash
329
+ # Basic usage (auto-detects installed CLI tools)
330
+ mdcontext search "authentication" --summarize
331
+
332
+ # Skip confirmation for scripts
333
+ mdcontext search "error handling" --summarize --yes
334
+
335
+ # Stream output in real-time
336
+ mdcontext search "database" --summarize --stream
337
+ ```
338
+
339
+ ### First-Time Setup
340
+
341
+ On first use, mdcontext auto-detects available providers:
342
+
343
+ ```
344
+ Using claude (subscription - FREE)
345
+
346
+ --- AI Summary ---
347
+
348
+ Based on the search results, here are the key findings...
349
+ ```
350
+
351
+ ### Providers
352
+
353
+ **CLI Providers (FREE with subscription):**
354
+
355
+ | Provider | Command | Subscription Required |
356
+ |----------|---------|----------------------|
357
+ | Claude Code | `claude` | Claude Pro/Team |
358
+ | GitHub Copilot | `copilot` | Copilot subscription |
359
+ | OpenCode | `opencode` | BYOK (any provider) |
360
+
361
+ **API Providers (pay-per-use):**
362
+
363
+ | Provider | Cost per 1M tokens | Notes |
364
+ |----------|-------------------|-------|
365
+ | DeepSeek | $0.14-0.56 | Ultra-cheap |
366
+ | Qwen | $0.03-0.12 | Budget option |
367
+ | Google Gemini | $0.30-2.50 | Balanced |
368
+ | OpenAI GPT | $1.75-14.00 | Premium |
369
+ | Anthropic Claude | $3.00-15.00 | Premium |
370
+
371
+ ### Configuration
372
+
373
+ **Option 1: Auto-detection (recommended)**
374
+
375
+ Just run `--summarize` - mdcontext finds installed CLI tools automatically.
376
+
377
+ **Option 2: Config file**
378
+
379
+ ```javascript
380
+ // mdcontext.config.js
381
+ /** @type {import('mdcontext').PartialMdContextConfig} */
382
+ export default {
383
+ aiSummarization: {
384
+ mode: 'cli', // 'cli' (free) or 'api' (paid)
385
+ provider: 'claude', // Provider name
386
+ },
387
+ }
388
+ ```
389
+
390
+ **Option 3: Environment variables**
391
+
392
+ ```bash
393
+ export MDCONTEXT_AISUMMARIZATION_MODE=api
394
+ export MDCONTEXT_AISUMMARIZATION_PROVIDER=deepseek
395
+ export DEEPSEEK_API_KEY=sk-...
396
+ ```
397
+
398
+ ### CLI Flags
399
+
400
+ | Flag | Short | Description |
401
+ |------|-------|-------------|
402
+ | `--summarize` | `-s` | Enable AI summarization |
403
+ | `--yes` | `-y` | Skip cost confirmation |
404
+ | `--stream` | | Stream output in real-time |
405
+
406
+ ### Cost Transparency
407
+
408
+ API providers show cost estimates before proceeding:
409
+
410
+ ```
411
+ Cost Estimate:
412
+ Provider: deepseek
413
+ Input tokens: ~2,500
414
+ Output tokens: ~500
415
+ Estimated cost: $0.0007
416
+
417
+ Continue with summarization? [Y/n]:
418
+ ```
419
+
420
+ CLI providers show free status:
421
+
422
+ ```
423
+ Using claude (subscription - FREE)
424
+ ```
425
+
426
+ See [docs/summarization.md](./docs/summarization.md) for architecture details and troubleshooting.
224
427
 
225
428
  ---
226
429
 
package/biome.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://biomejs.dev/schemas/2.3.11/schema.json",
2
+ "$schema": "https://biomejs.dev/schemas/2.3.12/schema.json",
3
3
  "assist": {
4
4
  "actions": {
5
5
  "source": {