@jafreck/lore 0.1.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 (239) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +405 -0
  3. package/dist/cli.d.ts +19 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +345 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/index.d.ts +22 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +16 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/indexer/call-graph.d.ts +39 -0
  12. package/dist/indexer/call-graph.d.ts.map +1 -0
  13. package/dist/indexer/call-graph.js +193 -0
  14. package/dist/indexer/call-graph.js.map +1 -0
  15. package/dist/indexer/complexity.d.ts +9 -0
  16. package/dist/indexer/complexity.d.ts.map +1 -0
  17. package/dist/indexer/complexity.js +66 -0
  18. package/dist/indexer/complexity.js.map +1 -0
  19. package/dist/indexer/config-parser.d.ts +16 -0
  20. package/dist/indexer/config-parser.d.ts.map +1 -0
  21. package/dist/indexer/config-parser.js +261 -0
  22. package/dist/indexer/config-parser.js.map +1 -0
  23. package/dist/indexer/coverage.d.ts +13 -0
  24. package/dist/indexer/coverage.d.ts.map +1 -0
  25. package/dist/indexer/coverage.js +84 -0
  26. package/dist/indexer/coverage.js.map +1 -0
  27. package/dist/indexer/db.d.ts +38 -0
  28. package/dist/indexer/db.d.ts.map +1 -0
  29. package/dist/indexer/db.js +275 -0
  30. package/dist/indexer/db.js.map +1 -0
  31. package/dist/indexer/embedder.d.ts +70 -0
  32. package/dist/indexer/embedder.d.ts.map +1 -0
  33. package/dist/indexer/embedder.js +186 -0
  34. package/dist/indexer/embedder.js.map +1 -0
  35. package/dist/indexer/ensure-python-deps.d.ts +22 -0
  36. package/dist/indexer/ensure-python-deps.d.ts.map +1 -0
  37. package/dist/indexer/ensure-python-deps.js +47 -0
  38. package/dist/indexer/ensure-python-deps.js.map +1 -0
  39. package/dist/indexer/extractors/bash.d.ts +12 -0
  40. package/dist/indexer/extractors/bash.d.ts.map +1 -0
  41. package/dist/indexer/extractors/bash.js +57 -0
  42. package/dist/indexer/extractors/bash.js.map +1 -0
  43. package/dist/indexer/extractors/c.d.ts +12 -0
  44. package/dist/indexer/extractors/c.d.ts.map +1 -0
  45. package/dist/indexer/extractors/c.js +106 -0
  46. package/dist/indexer/extractors/c.js.map +1 -0
  47. package/dist/indexer/extractors/cpp.d.ts +12 -0
  48. package/dist/indexer/extractors/cpp.d.ts.map +1 -0
  49. package/dist/indexer/extractors/cpp.js +84 -0
  50. package/dist/indexer/extractors/cpp.js.map +1 -0
  51. package/dist/indexer/extractors/csharp.d.ts +12 -0
  52. package/dist/indexer/extractors/csharp.d.ts.map +1 -0
  53. package/dist/indexer/extractors/csharp.js +79 -0
  54. package/dist/indexer/extractors/csharp.js.map +1 -0
  55. package/dist/indexer/extractors/dart.d.ts +12 -0
  56. package/dist/indexer/extractors/dart.d.ts.map +1 -0
  57. package/dist/indexer/extractors/dart.js +80 -0
  58. package/dist/indexer/extractors/dart.js.map +1 -0
  59. package/dist/indexer/extractors/elixir.d.ts +12 -0
  60. package/dist/indexer/extractors/elixir.d.ts.map +1 -0
  61. package/dist/indexer/extractors/elixir.js +87 -0
  62. package/dist/indexer/extractors/elixir.js.map +1 -0
  63. package/dist/indexer/extractors/elm.d.ts +12 -0
  64. package/dist/indexer/extractors/elm.d.ts.map +1 -0
  65. package/dist/indexer/extractors/elm.js +87 -0
  66. package/dist/indexer/extractors/elm.js.map +1 -0
  67. package/dist/indexer/extractors/go.d.ts +12 -0
  68. package/dist/indexer/extractors/go.d.ts.map +1 -0
  69. package/dist/indexer/extractors/go.js +158 -0
  70. package/dist/indexer/extractors/go.js.map +1 -0
  71. package/dist/indexer/extractors/haskell.d.ts +12 -0
  72. package/dist/indexer/extractors/haskell.d.ts.map +1 -0
  73. package/dist/indexer/extractors/haskell.js +104 -0
  74. package/dist/indexer/extractors/haskell.js.map +1 -0
  75. package/dist/indexer/extractors/java.d.ts +12 -0
  76. package/dist/indexer/extractors/java.d.ts.map +1 -0
  77. package/dist/indexer/extractors/java.js +68 -0
  78. package/dist/indexer/extractors/java.js.map +1 -0
  79. package/dist/indexer/extractors/javascript.d.ts +13 -0
  80. package/dist/indexer/extractors/javascript.d.ts.map +1 -0
  81. package/dist/indexer/extractors/javascript.js +180 -0
  82. package/dist/indexer/extractors/javascript.js.map +1 -0
  83. package/dist/indexer/extractors/julia.d.ts +12 -0
  84. package/dist/indexer/extractors/julia.d.ts.map +1 -0
  85. package/dist/indexer/extractors/julia.js +94 -0
  86. package/dist/indexer/extractors/julia.js.map +1 -0
  87. package/dist/indexer/extractors/kotlin.d.ts +12 -0
  88. package/dist/indexer/extractors/kotlin.d.ts.map +1 -0
  89. package/dist/indexer/extractors/kotlin.js +71 -0
  90. package/dist/indexer/extractors/kotlin.js.map +1 -0
  91. package/dist/indexer/extractors/lua.d.ts +12 -0
  92. package/dist/indexer/extractors/lua.d.ts.map +1 -0
  93. package/dist/indexer/extractors/lua.js +68 -0
  94. package/dist/indexer/extractors/lua.js.map +1 -0
  95. package/dist/indexer/extractors/objc.d.ts +12 -0
  96. package/dist/indexer/extractors/objc.d.ts.map +1 -0
  97. package/dist/indexer/extractors/objc.js +129 -0
  98. package/dist/indexer/extractors/objc.js.map +1 -0
  99. package/dist/indexer/extractors/ocaml.d.ts +12 -0
  100. package/dist/indexer/extractors/ocaml.d.ts.map +1 -0
  101. package/dist/indexer/extractors/ocaml.js +92 -0
  102. package/dist/indexer/extractors/ocaml.js.map +1 -0
  103. package/dist/indexer/extractors/php.d.ts +12 -0
  104. package/dist/indexer/extractors/php.d.ts.map +1 -0
  105. package/dist/indexer/extractors/php.js +99 -0
  106. package/dist/indexer/extractors/php.js.map +1 -0
  107. package/dist/indexer/extractors/python.d.ts +12 -0
  108. package/dist/indexer/extractors/python.d.ts.map +1 -0
  109. package/dist/indexer/extractors/python.js +129 -0
  110. package/dist/indexer/extractors/python.js.map +1 -0
  111. package/dist/indexer/extractors/ruby.d.ts +12 -0
  112. package/dist/indexer/extractors/ruby.d.ts.map +1 -0
  113. package/dist/indexer/extractors/ruby.js +100 -0
  114. package/dist/indexer/extractors/ruby.js.map +1 -0
  115. package/dist/indexer/extractors/rust.d.ts +12 -0
  116. package/dist/indexer/extractors/rust.d.ts.map +1 -0
  117. package/dist/indexer/extractors/rust.js +82 -0
  118. package/dist/indexer/extractors/rust.js.map +1 -0
  119. package/dist/indexer/extractors/scala.d.ts +12 -0
  120. package/dist/indexer/extractors/scala.d.ts.map +1 -0
  121. package/dist/indexer/extractors/scala.js +91 -0
  122. package/dist/indexer/extractors/scala.js.map +1 -0
  123. package/dist/indexer/extractors/swift.d.ts +12 -0
  124. package/dist/indexer/extractors/swift.d.ts.map +1 -0
  125. package/dist/indexer/extractors/swift.js +90 -0
  126. package/dist/indexer/extractors/swift.js.map +1 -0
  127. package/dist/indexer/extractors/types.d.ts +118 -0
  128. package/dist/indexer/extractors/types.d.ts.map +1 -0
  129. package/dist/indexer/extractors/types.js +43 -0
  130. package/dist/indexer/extractors/types.js.map +1 -0
  131. package/dist/indexer/extractors/typescript.d.ts +14 -0
  132. package/dist/indexer/extractors/typescript.d.ts.map +1 -0
  133. package/dist/indexer/extractors/typescript.js +172 -0
  134. package/dist/indexer/extractors/typescript.js.map +1 -0
  135. package/dist/indexer/extractors/zig.d.ts +12 -0
  136. package/dist/indexer/extractors/zig.d.ts.map +1 -0
  137. package/dist/indexer/extractors/zig.js +95 -0
  138. package/dist/indexer/extractors/zig.js.map +1 -0
  139. package/dist/indexer/git-history.d.ts +23 -0
  140. package/dist/indexer/git-history.d.ts.map +1 -0
  141. package/dist/indexer/git-history.js +144 -0
  142. package/dist/indexer/git-history.js.map +1 -0
  143. package/dist/indexer/git-hooks.d.ts +19 -0
  144. package/dist/indexer/git-hooks.d.ts.map +1 -0
  145. package/dist/indexer/git-hooks.js +74 -0
  146. package/dist/indexer/git-hooks.js.map +1 -0
  147. package/dist/indexer/index.d.ts +83 -0
  148. package/dist/indexer/index.d.ts.map +1 -0
  149. package/dist/indexer/index.js +431 -0
  150. package/dist/indexer/index.js.map +1 -0
  151. package/dist/indexer/parser.d.ts +30 -0
  152. package/dist/indexer/parser.d.ts.map +1 -0
  153. package/dist/indexer/parser.js +114 -0
  154. package/dist/indexer/parser.js.map +1 -0
  155. package/dist/indexer/poller.d.ts +50 -0
  156. package/dist/indexer/poller.d.ts.map +1 -0
  157. package/dist/indexer/poller.js +140 -0
  158. package/dist/indexer/poller.js.map +1 -0
  159. package/dist/indexer/resolver.d.ts +52 -0
  160. package/dist/indexer/resolver.d.ts.map +1 -0
  161. package/dist/indexer/resolver.js +271 -0
  162. package/dist/indexer/resolver.js.map +1 -0
  163. package/dist/indexer/test-mapper.d.ts +6 -0
  164. package/dist/indexer/test-mapper.d.ts.map +1 -0
  165. package/dist/indexer/test-mapper.js +48 -0
  166. package/dist/indexer/test-mapper.js.map +1 -0
  167. package/dist/indexer/walker.d.ts +51 -0
  168. package/dist/indexer/walker.d.ts.map +1 -0
  169. package/dist/indexer/walker.js +100 -0
  170. package/dist/indexer/walker.js.map +1 -0
  171. package/dist/indexer/watcher.d.ts +51 -0
  172. package/dist/indexer/watcher.d.ts.map +1 -0
  173. package/dist/indexer/watcher.js +107 -0
  174. package/dist/indexer/watcher.js.map +1 -0
  175. package/dist/kb-server/db.d.ts +241 -0
  176. package/dist/kb-server/db.d.ts.map +1 -0
  177. package/dist/kb-server/db.js +659 -0
  178. package/dist/kb-server/db.js.map +1 -0
  179. package/dist/kb-server/server.d.ts +35 -0
  180. package/dist/kb-server/server.d.ts.map +1 -0
  181. package/dist/kb-server/server.js +240 -0
  182. package/dist/kb-server/server.js.map +1 -0
  183. package/dist/kb-server/tools/annotations.d.ts +40 -0
  184. package/dist/kb-server/tools/annotations.d.ts.map +1 -0
  185. package/dist/kb-server/tools/annotations.js +35 -0
  186. package/dist/kb-server/tools/annotations.js.map +1 -0
  187. package/dist/kb-server/tools/architecture.d.ts +60 -0
  188. package/dist/kb-server/tools/architecture.d.ts.map +1 -0
  189. package/dist/kb-server/tools/architecture.js +174 -0
  190. package/dist/kb-server/tools/architecture.js.map +1 -0
  191. package/dist/kb-server/tools/blame.d.ts +67 -0
  192. package/dist/kb-server/tools/blame.d.ts.map +1 -0
  193. package/dist/kb-server/tools/blame.js +162 -0
  194. package/dist/kb-server/tools/blame.js.map +1 -0
  195. package/dist/kb-server/tools/coverage.d.ts +67 -0
  196. package/dist/kb-server/tools/coverage.d.ts.map +1 -0
  197. package/dist/kb-server/tools/coverage.js +74 -0
  198. package/dist/kb-server/tools/coverage.js.map +1 -0
  199. package/dist/kb-server/tools/graph.d.ts +56 -0
  200. package/dist/kb-server/tools/graph.d.ts.map +1 -0
  201. package/dist/kb-server/tools/graph.js +188 -0
  202. package/dist/kb-server/tools/graph.js.map +1 -0
  203. package/dist/kb-server/tools/history.d.ts +47 -0
  204. package/dist/kb-server/tools/history.d.ts.map +1 -0
  205. package/dist/kb-server/tools/history.js +91 -0
  206. package/dist/kb-server/tools/history.js.map +1 -0
  207. package/dist/kb-server/tools/lookup.d.ts +36 -0
  208. package/dist/kb-server/tools/lookup.d.ts.map +1 -0
  209. package/dist/kb-server/tools/lookup.js +45 -0
  210. package/dist/kb-server/tools/lookup.js.map +1 -0
  211. package/dist/kb-server/tools/metrics.d.ts +73 -0
  212. package/dist/kb-server/tools/metrics.d.ts.map +1 -0
  213. package/dist/kb-server/tools/metrics.js +79 -0
  214. package/dist/kb-server/tools/metrics.js.map +1 -0
  215. package/dist/kb-server/tools/notes.d.ts +165 -0
  216. package/dist/kb-server/tools/notes.d.ts.map +1 -0
  217. package/dist/kb-server/tools/notes.js +175 -0
  218. package/dist/kb-server/tools/notes.js.map +1 -0
  219. package/dist/kb-server/tools/routes.d.ts +38 -0
  220. package/dist/kb-server/tools/routes.d.ts.map +1 -0
  221. package/dist/kb-server/tools/routes.js +38 -0
  222. package/dist/kb-server/tools/routes.js.map +1 -0
  223. package/dist/kb-server/tools/search.d.ts +60 -0
  224. package/dist/kb-server/tools/search.d.ts.map +1 -0
  225. package/dist/kb-server/tools/search.js +170 -0
  226. package/dist/kb-server/tools/search.js.map +1 -0
  227. package/dist/kb-server/tools/snippet.d.ts +44 -0
  228. package/dist/kb-server/tools/snippet.d.ts.map +1 -0
  229. package/dist/kb-server/tools/snippet.js +49 -0
  230. package/dist/kb-server/tools/snippet.js.map +1 -0
  231. package/dist/kb-server/tools/test-map.d.ts +38 -0
  232. package/dist/kb-server/tools/test-map.d.ts.map +1 -0
  233. package/dist/kb-server/tools/test-map.js +32 -0
  234. package/dist/kb-server/tools/test-map.js.map +1 -0
  235. package/dist/kb-server/tools/writeback.d.ts +49 -0
  236. package/dist/kb-server/tools/writeback.d.ts.map +1 -0
  237. package/dist/kb-server/tools/writeback.js +68 -0
  238. package/dist/kb-server/tools/writeback.js.map +1 -0
  239. package/package.json +92 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jacob Freck
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,405 @@
1
+ # Lore
2
+
3
+ [![CI](https://github.com/jafreck/Lore/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/jafreck/Lore/actions/workflows/ci.yml)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
5
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D22.0.0-brightgreen)](https://nodejs.org)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.9+-blue)](https://www.typescriptlang.org)
7
+
8
+ **The teammate that has seen it all** Lore is your agent's institutional knowledge over the codebase — it knows what was built, why it changed, and how it all connects. Lore indexes your code and git history into a structured knowledge base that agents query through MCP. It maps symbols, imports, call relationships, and git history — with optional embeddings for semantic search — so agents can reason about your codebase
9
+ without re-reading it from scratch.
10
+
11
+ ## What Lore does
12
+
13
+ - Parses source files and extracts symbols, imports, and call refs
14
+ - Resolves internal vs external imports and builds call/import graph edges
15
+ - Stores everything in a normalized SQL schema with optional vector search
16
+ - Enables RAG-style retrieval with semantic/fused search
17
+ - Indexes git history (commits, touched files, refs/branches/tags)
18
+ - Supports line-level git blame through MCP
19
+ - Supports automatic refresh via watch mode, poll mode, and git hooks
20
+
21
+ ## How Lore integrates with LLMs
22
+
23
+ ```mermaid
24
+ flowchart LR
25
+ subgraph Codebase
26
+ SRC[Source Files]
27
+ GIT[Git Repo]
28
+ COV[Coverage Reports]
29
+ end
30
+
31
+ subgraph Lore Indexer
32
+ WALK[Walker]
33
+ PARSE[Parser]
34
+ EXTRACT[Extractors<br/>symbols · imports · call refs]
35
+ RESOLVE[Import Resolver<br/>internal ↔ external]
36
+ CALLGRAPH[Call-Graph Builder]
37
+ EMBED[Embedder]
38
+ GITHIST[Git History Ingest<br/>commits · diffs · refs]
39
+ COVINGEST[Coverage Ingest<br/>lcov · cobertura]
40
+ end
41
+
42
+ DB[(SQL DB)]
43
+
44
+ subgraph MCP Server
45
+ LOOKUP[kb_lookup]
46
+ SEARCH[kb_search]
47
+ GRAPH[kb_graph]
48
+ SNIPPET[kb_snippet]
49
+ BLAME[kb_blame]
50
+ HISTORY[kb_history]
51
+ METRICS[kb_metrics]
52
+ WRITEBACK[kb_writeback]
53
+ end
54
+
55
+ subgraph LLM_AGENTS[Agents]
56
+ CLAUDE[Claude]
57
+ COPILOT[GitHub Copilot]
58
+ CUSTOM_AGENT[Custom Agents]
59
+ CLAUDE ~~~ COPILOT ~~~ CUSTOM_AGENT
60
+ end
61
+
62
+ subgraph ENTRY[User Entrypoints]
63
+ VSCODE[VS Code]
64
+ CURSOR[Cursor]
65
+ CHAT[Chat UI]
66
+ ORCH[Agent Frameworks]
67
+ VSCODE ~~~ CURSOR ~~~ CHAT ~~~ ORCH
68
+ end
69
+
70
+ SRC --> WALK --> PARSE --> EXTRACT
71
+ EXTRACT --> RESOLVE & CALLGRAPH
72
+ EXTRACT & RESOLVE & CALLGRAPH --> DB
73
+ EMBED -.->|optional| DB
74
+ GIT --> GITHIST --> DB
75
+ COV --> COVINGEST --> DB
76
+
77
+ DB --- LOOKUP & SEARCH & GRAPH & SNIPPET & BLAME & HISTORY & METRICS & WRITEBACK
78
+
79
+ LOOKUP & SEARCH & GRAPH & SNIPPET & BLAME & HISTORY & METRICS & WRITEBACK <--> LLM_AGENTS
80
+
81
+ LLM_AGENTS <--- ENTRY
82
+ ```
83
+
84
+ Lore sits between your codebase and any LLM-powered tool. The **indexer**
85
+ pipeline walks source files, parses them into ASTs, and extracts
86
+ symbols/imports/call-refs via language-specific extractors, then resolves
87
+ imports (internal vs external) and builds the call graph. An optional
88
+ **embedder** generates dense vectors for semantic search, and a parallel
89
+ **git history** ingest captures commits, diffs, and refs. Everything is
90
+ persisted to a normalized SQL database. The **MCP server** then exposes that
91
+ database as a set of tools that any MCP-compatible client can call to look up
92
+ symbols, search code, traverse call graphs, read snippets, query
93
+ blame/history, and write summaries back.
94
+
95
+ The index stays fresh automatically. You can install **git hooks**
96
+ (`post-commit`, `post-merge`, etc.) that trigger an incremental refresh on
97
+ every commit, run a **watch** mode that reacts to filesystem events in
98
+ real time, or use **poll** mode for environments where watch events are
99
+ unreliable. Each refresh only re-processes files whose content hash has
100
+ changed, so updates are fast even on large repositories.
101
+
102
+ See [docs/architecture.md](docs/architecture.md) for the full schema and
103
+ pipeline breakdown.
104
+
105
+ ## Supported languages
106
+
107
+ Lore currently supports extractors for:
108
+
109
+ - C, C++, C#
110
+ - Rust, Go, Java, Kotlin, Scala, Swift, Objective-C, Zig, Dart
111
+ - Python, JavaScript, TypeScript, PHP, Ruby, Lua, Bash, Elixir
112
+ - OCaml, Haskell, Julia, Elm
113
+
114
+ ## Install
115
+
116
+ ```bash
117
+ npm install @jafreck/lore
118
+ ```
119
+
120
+ Note: Lore uses native add-ons (`tree-sitter`, `better-sqlite3`). A working
121
+ C/C++ toolchain is required the first time dependencies are built.
122
+
123
+ ## Publish authentication (npm)
124
+
125
+ Lore publish operations use `NODE_AUTH_TOKEN` (see `.npmrc`) and never commit
126
+ tokens to the repository.
127
+
128
+ Local publish flow:
129
+
130
+ ```bash
131
+ export NODE_AUTH_TOKEN=<npm automation token>
132
+ npm publish --access public
133
+ ```
134
+
135
+ CI publish flow:
136
+
137
+ - Add `NODE_AUTH_TOKEN` as a secret in your CI provider (for GitHub Actions,
138
+ use a repository or environment secret).
139
+ - Ensure publish jobs expose that secret as the `NODE_AUTH_TOKEN` environment
140
+ variable before running `npm publish`.
141
+
142
+ ## Release publish workflow (`@jafreck/lore@0.1.0`)
143
+
144
+ Publishing is automated by `.github/workflows/publish.yml`. Creating a version
145
+ tag (for example, `v0.1.0`) or publishing a GitHub Release triggers the npm
146
+ publish job.
147
+
148
+ Release steps for `@jafreck/lore@0.1.0`:
149
+
150
+ 1. Ensure `package.json` has `"version": "0.1.0"`.
151
+ 2. Push the tag: `git tag v0.1.0 && git push origin v0.1.0` (or publish a
152
+ GitHub Release for `v0.1.0`).
153
+ 3. Confirm the workflow logs show `npm publish --dry-run` output before the
154
+ live `npm publish` step.
155
+
156
+ Post-publish verification:
157
+
158
+ - Check the package metadata: `npm view @jafreck/lore version` returns `0.1.0`.
159
+ - Confirm installability: `npm view @jafreck/lore@0.1.0 name version`.
160
+
161
+ ## Quick start (CLI)
162
+
163
+ ```bash
164
+ # 1) Build an index
165
+ npx @jafreck/lore index --root ./my-project --db ./kb.db
166
+
167
+ # 2) Start MCP server over stdio
168
+ npx @jafreck/lore mcp --db ./kb.db
169
+ ```
170
+
171
+ ## Quick start (programmatic)
172
+
173
+ ```ts
174
+ import { IndexBuilder } from '@jafreck/lore';
175
+
176
+ const builder = new IndexBuilder(
177
+ './kb.db',
178
+ { rootDir: './my-project' },
179
+ undefined,
180
+ { history: true },
181
+ );
182
+
183
+ await builder.build();
184
+ ```
185
+
186
+ ### Programmatic configuration examples
187
+
188
+ ```ts
189
+ import { IndexBuilder } from '@jafreck/lore';
190
+
191
+ // Index with embedding model + history options
192
+ await new IndexBuilder(
193
+ './kb.db',
194
+ {
195
+ rootDir: './my-project',
196
+ includeGlobs: ['src/**'],
197
+ excludeGlobs: ['**/*.gen.ts'],
198
+ extensions: ['.ts', '.tsx'],
199
+ },
200
+ undefined,
201
+ {
202
+ embeddingModel: 'Qwen/Qwen3-Embedding-4B',
203
+ history: { all: true, depth: 2000 },
204
+ },
205
+ ).build();
206
+ ```
207
+
208
+ ## CLI reference
209
+
210
+ ### lore index
211
+
212
+ Build or update a knowledge base.
213
+
214
+ ```bash
215
+ npx @jafreck/lore index --root <dir> --db <path> [--embedding-model <id>] [--history] [--history-depth <n>] [--history-all] [--include <glob>] [--exclude <glob>] [--language <lang>]
216
+ ```
217
+
218
+ Key flags:
219
+
220
+ - `--root <dir>` required source root
221
+ - `--db <path>` required SQLite output path
222
+ - `--embedding-model <id>` embedding model identifier
223
+ - `--history` enable git history ingestion
224
+ - `--history-depth <n>` cap number of ingested commits
225
+ - `--history-all` traverse all refs (branches/tags)
226
+ - `--include` repeatable glob include filter
227
+ - `--exclude` repeatable glob exclude filter
228
+ - `--language` repeatable language filter (mapped to extensions)
229
+
230
+ ### lore refresh
231
+
232
+ Incremental refresh flow for an existing index.
233
+
234
+ ```bash
235
+ npx @jafreck/lore refresh --db <path> --root <dir> [--history] [--history-depth <n>] [--history-all]
236
+ npx @jafreck/lore refresh --db <path> --root <dir> --watch [--history]
237
+ npx @jafreck/lore refresh --db <path> --root <dir> --poll [--history]
238
+ ```
239
+
240
+ Modes:
241
+
242
+ - Manual: one-shot incremental refresh and exit
243
+ - Watch: filesystem event driven (`fs.watch`), low latency
244
+ - Poll: periodic mtime diffing, most reliable across filesystems
245
+
246
+ Coverage reports are auto-detected during build/update/refresh from known paths (`coverage/lcov.info`, `coverage/cobertura-coverage.xml`, `coverage.xml`) and only ingested when newer than the last stored coverage run.
247
+
248
+ ### lore hooks
249
+
250
+ Install repo-local git hooks that trigger Lore refresh automatically on:
251
+
252
+ - `post-commit`
253
+ - `post-merge`
254
+ - `post-checkout`
255
+ - `post-rewrite`
256
+
257
+ ```bash
258
+ npx @jafreck/lore hooks --root <repo> --db <path>
259
+ npx @jafreck/lore hooks --root <repo> --db <path> --history
260
+ ```
261
+
262
+ Note: for `lore hooks`, any history-related flag currently enables history in
263
+ hook-triggered refreshes.
264
+
265
+ ### lore ingest-coverage
266
+
267
+ Manually ingest an explicit coverage report (useful for CI or non-standard report locations).
268
+
269
+ ```bash
270
+ npx @jafreck/lore ingest-coverage --db <path> --root <dir> --file <path> --format <lcov|cobertura> [--commit <sha>]
271
+ ```
272
+
273
+ Key flags:
274
+
275
+ - `--db <path>` required SQLite output path
276
+ - `--root <dir>` required repository root used to normalize relative coverage paths
277
+ - `--file <path>` required coverage report file path
278
+ - `--format <lcov|cobertura>` required coverage format
279
+ - `--commit <sha>` optional commit override (defaults to `HEAD`)
280
+
281
+ ### lore mcp
282
+
283
+ Start the built-in MCP server over stdio.
284
+
285
+ ```bash
286
+ npx @jafreck/lore mcp --db <path>
287
+ ```
288
+
289
+ If the embedding model cannot initialize at runtime, semantic/fused search
290
+ gracefully degrades to structural search.
291
+
292
+ ## MCP tools
293
+
294
+ | Tool | Purpose |
295
+ |------|---------|
296
+ | `kb_lookup` | Find symbols by name or files by path (optional branch filter) |
297
+ | `kb_search` | Structural BM25, semantic vector, or fused RRF search |
298
+ | `kb_graph` | Query call/import/module/inheritance edges; call edges include `callee_coverage_percent` |
299
+ | `kb_snippet` | Return source snippets by file path and line range |
300
+ | `kb_blame` | Return git blame metadata for a line or line range |
301
+ | `kb_history` | Query history by file, commit, author, ref, or recency |
302
+ | `kb_metrics` | Return aggregate index metrics plus coverage/staleness fields (`coverage_available`, `coverage_commit`, `current_commit`, `commits_behind`, `stale`, global coverage totals) |
303
+ | `kb_coverage` | Return symbol-level coverage, uncovered lines, and staleness metadata for the latest coverage run |
304
+ | `kb_writeback` | Persist symbol summaries into `symbol_summaries` |
305
+
306
+ ### MCP config example
307
+
308
+ ```json
309
+ {
310
+ "mcpServers": {
311
+ "lore": {
312
+ "command": "npx",
313
+ "args": ["@jafreck/lore", "mcp", "--db", "/path/to/kb.db"]
314
+ }
315
+ }
316
+ }
317
+ ```
318
+
319
+ ## Git history indexing
320
+
321
+ Lore can ingest full git history and expose it through `kb_history`.
322
+
323
+ ### Indexed history tables
324
+
325
+ - `commits`: sha, author, author_email, timestamp, message, parents
326
+ - `commit_files`: per-commit touched paths with change type and diff stats
327
+ - `commit_refs`: refs currently pointing at commits (`branch`/`tag`/`other`)
328
+
329
+ ### kb_history modes
330
+
331
+ - `recent`: newest commits
332
+ - `file`: commits that touched a path
333
+ - `commit`: full/prefix sha lookup (+files +refs)
334
+ - `author`: commits by author/email substring
335
+ - `ref`: commits matching branch/tag ref name substring
336
+
337
+ ## Blame queries
338
+
339
+ Use `kb_blame` for line-level attribution.
340
+
341
+ Examples:
342
+
343
+ ```json
344
+ { "path": "/repo/src/index.ts", "line": 120 }
345
+ { "path": "/repo/src/index.ts", "start_line": 120, "end_line": 140 }
346
+ { "path": "/repo/src/index.ts", "line": 120, "ref": "main" }
347
+ ```
348
+
349
+ ## Automatic freshness patterns
350
+
351
+ If you want Lore to stay updated without explicit requests:
352
+
353
+ 1. Run `lore hooks` once in the repo (git lifecycle updates)
354
+ 2. Optionally run `lore refresh --watch` in a background session for near-real-time updates during active editing
355
+ 3. Use `--poll` on filesystems where watch events are unreliable
356
+
357
+ ## Benchmarking index performance (500+ file repos)
358
+
359
+ Use this procedure when you need measurable before/after evidence for indexing changes:
360
+
361
+ 1. Pick a repository with at least 500 source files and note the exact commit SHA you will test.
362
+ 2. Capture a baseline timing from the same machine and environment:
363
+
364
+ ```bash
365
+ time npx @jafreck/lore index --root /path/to/repo --db ./kb-baseline.db
366
+ ```
367
+
368
+ 3. Apply your change, rebuild Lore, then capture a post-change timing against the same repository commit:
369
+
370
+ ```bash
371
+ npm run build
372
+ time npx @jafreck/lore index --root /path/to/repo --db ./kb-after.db
373
+ ```
374
+
375
+ 4. Record both timings (baseline and post-change) in the related GitHub issue or PR under an "Acceptance Evidence" section, including repo name, commit SHA, and command used.
376
+
377
+ ## Build from source
378
+
379
+ ```bash
380
+ git clone https://github.com/jafreck/Lore.git
381
+ cd Lore
382
+ npm install
383
+ npm run build
384
+ ```
385
+
386
+ ## Contributing
387
+
388
+ Environment expectations:
389
+
390
+ - Node.js `>=22.0.0`
391
+ - Native build toolchain for `tree-sitter` and `better-sqlite3`
392
+
393
+ Common local workflow:
394
+
395
+ ```bash
396
+ npm run build
397
+ npm test
398
+ npm run coverage
399
+ ```
400
+
401
+ CI enforces a minimum 95% coverage threshold.
402
+
403
+ ## License
404
+
405
+ [MIT](LICENSE)
package/dist/cli.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @module cli
4
+ *
5
+ * Lore CLI — unified entry point for indexing and the MCP server.
6
+ *
7
+ * Usage:
8
+ * lore index --root <dir> --db <path> [--embedding-model <id>]
9
+ * Index a codebase into a knowledge-base file.
10
+ * lore mcp --db <path> Start the knowledge-base MCP server (stdio transport).
11
+ * lore refresh --db <path> --root <dir> Run an incremental index update and exit.
12
+ * lore refresh --db <path> --root <dir> --watch Watch for changes and refresh automatically.
13
+ * lore refresh --db <path> --root <dir> --poll Poll for changes and refresh automatically.
14
+ * lore hooks --root <dir> --db <path> Install git hooks for automatic Lore refresh.
15
+ * lore ingest-coverage --db <path> --root <dir> --file <path> --format <lcov|cobertura>
16
+ * Ingest a coverage report file into the knowledge base.
17
+ */
18
+ export {};
19
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;GAeG"}