@jafreck/lore 0.2.0 → 0.2.2

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 (180) hide show
  1. package/README.md +399 -199
  2. package/dist/cli.js +139 -18
  3. package/dist/cli.js.map +1 -1
  4. package/dist/index.d.ts +7 -6
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +3 -3
  7. package/dist/index.js.map +1 -1
  8. package/dist/indexer/db.d.ts +12 -11
  9. package/dist/indexer/db.d.ts.map +1 -1
  10. package/dist/indexer/db.js +118 -18
  11. package/dist/indexer/db.js.map +1 -1
  12. package/dist/indexer/docs.d.ts +42 -0
  13. package/dist/indexer/docs.d.ts.map +1 -0
  14. package/dist/indexer/docs.js +214 -0
  15. package/dist/indexer/docs.js.map +1 -0
  16. package/dist/indexer/embedder.d.ts +7 -0
  17. package/dist/indexer/embedder.d.ts.map +1 -1
  18. package/dist/indexer/embedder.js +10 -0
  19. package/dist/indexer/embedder.js.map +1 -1
  20. package/dist/indexer/ensure-python-deps.d.ts +1 -1
  21. package/dist/indexer/ensure-python-deps.js +1 -1
  22. package/dist/indexer/extractors/types.d.ts +22 -0
  23. package/dist/indexer/extractors/types.d.ts.map +1 -1
  24. package/dist/indexer/extractors/types.js +12 -0
  25. package/dist/indexer/extractors/types.js.map +1 -1
  26. package/dist/indexer/extractors/typescript.d.ts +1 -1
  27. package/dist/indexer/extractors/typescript.d.ts.map +1 -1
  28. package/dist/indexer/extractors/typescript.js +38 -8
  29. package/dist/indexer/extractors/typescript.js.map +1 -1
  30. package/dist/indexer/git-history.d.ts.map +1 -1
  31. package/dist/indexer/git-history.js +4 -4
  32. package/dist/indexer/git-history.js.map +1 -1
  33. package/dist/indexer/git-hooks.d.ts +1 -0
  34. package/dist/indexer/git-hooks.d.ts.map +1 -1
  35. package/dist/indexer/git-hooks.js +3 -2
  36. package/dist/indexer/git-hooks.js.map +1 -1
  37. package/dist/indexer/index.d.ts +35 -9
  38. package/dist/indexer/index.d.ts.map +1 -1
  39. package/dist/indexer/index.js +470 -30
  40. package/dist/indexer/index.js.map +1 -1
  41. package/dist/indexer/lsp/client.d.ts +61 -0
  42. package/dist/indexer/lsp/client.d.ts.map +1 -0
  43. package/dist/indexer/lsp/client.js +217 -0
  44. package/dist/indexer/lsp/client.js.map +1 -0
  45. package/dist/indexer/lsp/config.d.ts +16 -0
  46. package/dist/indexer/lsp/config.d.ts.map +1 -0
  47. package/dist/indexer/lsp/config.js +78 -0
  48. package/dist/indexer/lsp/config.js.map +1 -0
  49. package/dist/indexer/lsp/enrichment.d.ts +55 -0
  50. package/dist/indexer/lsp/enrichment.d.ts.map +1 -0
  51. package/dist/indexer/lsp/enrichment.js +211 -0
  52. package/dist/indexer/lsp/enrichment.js.map +1 -0
  53. package/dist/indexer/lsp/registry.d.ts +19 -0
  54. package/dist/indexer/lsp/registry.d.ts.map +1 -0
  55. package/dist/indexer/lsp/registry.js +118 -0
  56. package/dist/indexer/lsp/registry.js.map +1 -0
  57. package/dist/indexer/parser.d.ts +7 -0
  58. package/dist/indexer/parser.d.ts.map +1 -1
  59. package/dist/indexer/parser.js +3 -1
  60. package/dist/indexer/parser.js.map +1 -1
  61. package/dist/indexer/poller.d.ts +8 -1
  62. package/dist/indexer/poller.d.ts.map +1 -1
  63. package/dist/indexer/poller.js +7 -1
  64. package/dist/indexer/poller.js.map +1 -1
  65. package/dist/indexer/walker.d.ts +22 -0
  66. package/dist/indexer/walker.d.ts.map +1 -1
  67. package/dist/indexer/walker.js +15 -0
  68. package/dist/indexer/walker.js.map +1 -1
  69. package/dist/indexer/watcher.d.ts +8 -1
  70. package/dist/indexer/watcher.d.ts.map +1 -1
  71. package/dist/indexer/watcher.js +7 -1
  72. package/dist/indexer/watcher.js.map +1 -1
  73. package/dist/{kb-server → lore-server}/db.d.ts +158 -4
  74. package/dist/lore-server/db.d.ts.map +1 -0
  75. package/dist/{kb-server → lore-server}/db.js +457 -26
  76. package/dist/lore-server/db.js.map +1 -0
  77. package/dist/lore-server/server.d.ts +43 -0
  78. package/dist/lore-server/server.d.ts.map +1 -0
  79. package/dist/lore-server/server.js +385 -0
  80. package/dist/lore-server/server.js.map +1 -0
  81. package/dist/{kb-server → lore-server}/tools/annotations.d.ts +2 -2
  82. package/dist/lore-server/tools/annotations.d.ts.map +1 -0
  83. package/dist/{kb-server → lore-server}/tools/annotations.js +2 -2
  84. package/dist/lore-server/tools/annotations.js.map +1 -0
  85. package/dist/{kb-server → lore-server}/tools/architecture.d.ts +9 -2
  86. package/dist/lore-server/tools/architecture.d.ts.map +1 -0
  87. package/dist/{kb-server → lore-server}/tools/architecture.js +37 -2
  88. package/dist/lore-server/tools/architecture.js.map +1 -0
  89. package/dist/lore-server/tools/blame.d.ts +159 -0
  90. package/dist/lore-server/tools/blame.d.ts.map +1 -0
  91. package/dist/lore-server/tools/blame.js +595 -0
  92. package/dist/lore-server/tools/blame.js.map +1 -0
  93. package/dist/{kb-server → lore-server}/tools/coverage.d.ts +2 -2
  94. package/dist/lore-server/tools/coverage.d.ts.map +1 -0
  95. package/dist/{kb-server → lore-server}/tools/coverage.js +2 -2
  96. package/dist/lore-server/tools/coverage.js.map +1 -0
  97. package/dist/lore-server/tools/docs.d.ts +86 -0
  98. package/dist/lore-server/tools/docs.d.ts.map +1 -0
  99. package/dist/lore-server/tools/docs.js +243 -0
  100. package/dist/lore-server/tools/docs.js.map +1 -0
  101. package/dist/{kb-server → lore-server}/tools/graph.d.ts +40 -3
  102. package/dist/lore-server/tools/graph.d.ts.map +1 -0
  103. package/dist/{kb-server → lore-server}/tools/graph.js +122 -11
  104. package/dist/lore-server/tools/graph.js.map +1 -0
  105. package/dist/{kb-server → lore-server}/tools/history.d.ts +13 -6
  106. package/dist/lore-server/tools/history.d.ts.map +1 -0
  107. package/dist/{kb-server → lore-server}/tools/history.js +43 -10
  108. package/dist/lore-server/tools/history.js.map +1 -0
  109. package/dist/lore-server/tools/lookup.d.ts +75 -0
  110. package/dist/lore-server/tools/lookup.d.ts.map +1 -0
  111. package/dist/lore-server/tools/lookup.js +148 -0
  112. package/dist/lore-server/tools/lookup.js.map +1 -0
  113. package/dist/{kb-server → lore-server}/tools/metrics.d.ts +3 -3
  114. package/dist/lore-server/tools/metrics.d.ts.map +1 -0
  115. package/dist/{kb-server → lore-server}/tools/metrics.js +3 -3
  116. package/dist/lore-server/tools/metrics.js.map +1 -0
  117. package/dist/{kb-server → lore-server}/tools/notes.d.ts +16 -16
  118. package/dist/lore-server/tools/notes.d.ts.map +1 -0
  119. package/dist/{kb-server → lore-server}/tools/notes.js +55 -20
  120. package/dist/lore-server/tools/notes.js.map +1 -0
  121. package/dist/{kb-server → lore-server}/tools/routes.d.ts +2 -2
  122. package/dist/lore-server/tools/routes.d.ts.map +1 -0
  123. package/dist/{kb-server → lore-server}/tools/routes.js +2 -2
  124. package/dist/lore-server/tools/routes.js.map +1 -0
  125. package/dist/{kb-server → lore-server}/tools/search.d.ts +57 -13
  126. package/dist/lore-server/tools/search.d.ts.map +1 -0
  127. package/dist/{kb-server → lore-server}/tools/search.js +123 -23
  128. package/dist/lore-server/tools/search.js.map +1 -0
  129. package/dist/{kb-server → lore-server}/tools/snippet.d.ts +20 -4
  130. package/dist/lore-server/tools/snippet.d.ts.map +1 -0
  131. package/dist/lore-server/tools/snippet.js +116 -0
  132. package/dist/lore-server/tools/snippet.js.map +1 -0
  133. package/dist/{kb-server → lore-server}/tools/test-map.d.ts +2 -2
  134. package/dist/lore-server/tools/test-map.d.ts.map +1 -0
  135. package/dist/{kb-server → lore-server}/tools/test-map.js +2 -2
  136. package/dist/lore-server/tools/test-map.js.map +1 -0
  137. package/dist/{kb-server → lore-server}/tools/writeback.d.ts +2 -2
  138. package/dist/lore-server/tools/writeback.d.ts.map +1 -0
  139. package/dist/{kb-server → lore-server}/tools/writeback.js +3 -3
  140. package/dist/lore-server/tools/writeback.js.map +1 -0
  141. package/package.json +14 -14
  142. package/dist/kb-server/db.d.ts.map +0 -1
  143. package/dist/kb-server/db.js.map +0 -1
  144. package/dist/kb-server/server.d.ts +0 -42
  145. package/dist/kb-server/server.d.ts.map +0 -1
  146. package/dist/kb-server/server.js +0 -241
  147. package/dist/kb-server/server.js.map +0 -1
  148. package/dist/kb-server/tools/annotations.d.ts.map +0 -1
  149. package/dist/kb-server/tools/annotations.js.map +0 -1
  150. package/dist/kb-server/tools/architecture.d.ts.map +0 -1
  151. package/dist/kb-server/tools/architecture.js.map +0 -1
  152. package/dist/kb-server/tools/blame.d.ts +0 -67
  153. package/dist/kb-server/tools/blame.d.ts.map +0 -1
  154. package/dist/kb-server/tools/blame.js +0 -162
  155. package/dist/kb-server/tools/blame.js.map +0 -1
  156. package/dist/kb-server/tools/coverage.d.ts.map +0 -1
  157. package/dist/kb-server/tools/coverage.js.map +0 -1
  158. package/dist/kb-server/tools/graph.d.ts.map +0 -1
  159. package/dist/kb-server/tools/graph.js.map +0 -1
  160. package/dist/kb-server/tools/history.d.ts.map +0 -1
  161. package/dist/kb-server/tools/history.js.map +0 -1
  162. package/dist/kb-server/tools/lookup.d.ts +0 -36
  163. package/dist/kb-server/tools/lookup.d.ts.map +0 -1
  164. package/dist/kb-server/tools/lookup.js +0 -45
  165. package/dist/kb-server/tools/lookup.js.map +0 -1
  166. package/dist/kb-server/tools/metrics.d.ts.map +0 -1
  167. package/dist/kb-server/tools/metrics.js.map +0 -1
  168. package/dist/kb-server/tools/notes.d.ts.map +0 -1
  169. package/dist/kb-server/tools/notes.js.map +0 -1
  170. package/dist/kb-server/tools/routes.d.ts.map +0 -1
  171. package/dist/kb-server/tools/routes.js.map +0 -1
  172. package/dist/kb-server/tools/search.d.ts.map +0 -1
  173. package/dist/kb-server/tools/search.js.map +0 -1
  174. package/dist/kb-server/tools/snippet.d.ts.map +0 -1
  175. package/dist/kb-server/tools/snippet.js +0 -49
  176. package/dist/kb-server/tools/snippet.js.map +0 -1
  177. package/dist/kb-server/tools/test-map.d.ts.map +0 -1
  178. package/dist/kb-server/tools/test-map.js.map +0 -1
  179. package/dist/kb-server/tools/writeback.d.ts.map +0 -1
  180. package/dist/kb-server/tools/writeback.js.map +0 -1
@@ -1,19 +1,20 @@
1
1
  /**
2
- * @module kb-server/tools/history
2
+ * @module lore-server/tools/history
3
3
  *
4
4
  * MCP tool: query commit history by file, commit SHA, author, or recency.
5
5
  */
6
6
  import type { Database } from '../db.js';
7
7
  import { type CommitRow, type CommitFileRow, type CommitRefRow } from '../db.js';
8
+ import type { EmbeddingProvider } from '../../indexer/embedder.js';
8
9
  export declare const toolDef: {
9
- readonly name: "kb_history";
10
+ readonly name: "lore_history";
10
11
  readonly description: string;
11
12
  readonly inputSchema: {
12
13
  readonly type: "object";
13
14
  readonly properties: {
14
15
  readonly mode: {
15
16
  readonly type: "string";
16
- readonly enum: readonly ["file", "commit", "author", "ref", "recent"];
17
+ readonly enum: readonly ["file", "commit", "author", "ref", "semantic", "recent"];
17
18
  readonly description: "Query mode.";
18
19
  };
19
20
  readonly query: {
@@ -29,7 +30,7 @@ export declare const toolDef: {
29
30
  };
30
31
  };
31
32
  export interface HistoryArgs {
32
- mode: 'file' | 'commit' | 'author' | 'ref' | 'recent';
33
+ mode: 'file' | 'commit' | 'author' | 'ref' | 'semantic' | 'recent';
33
34
  query?: string;
34
35
  limit?: number;
35
36
  }
@@ -37,11 +38,17 @@ export interface CommitWithFiles extends CommitRow {
37
38
  files?: CommitFileRow[];
38
39
  refs?: CommitRefRow[];
39
40
  }
41
+ export interface CommitEnrichmentOptions {
42
+ includeFiles?: boolean;
43
+ includeRefs?: boolean;
44
+ }
40
45
  export interface HistoryResult {
41
46
  mode: string;
42
47
  results: CommitWithFiles[];
43
48
  count: number;
44
49
  }
45
- /** Handle a kb_history tool invocation against the open read-only database. */
46
- export declare function handler(db: Database.Database, args: HistoryArgs): HistoryResult;
50
+ /** Enrich commit rows with touched files and refs metadata. */
51
+ export declare function enrichCommitsWithContext(db: Database.Database, commits: CommitRow[], options?: CommitEnrichmentOptions): CommitWithFiles[];
52
+ /** Handle a lore_history tool invocation against the open read-only database. */
53
+ export declare function handler(db: Database.Database, args: HistoryArgs, embedder?: EmbeddingProvider): Promise<HistoryResult>;
47
54
  //# sourceMappingURL=history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../src/lore-server/tools/history.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAUL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAInE,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;CAoCV,CAAC;AAIX,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,UAAU,GAAG,QAAQ,CAAC;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAChD,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;IACxB,IAAI,CAAC,EAAE,YAAY,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,uBAAuB;IACtC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;CACf;AAUD,+DAA+D;AAC/D,wBAAgB,wBAAwB,CACtC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,OAAO,EAAE,SAAS,EAAE,EACpB,OAAO,GAAE,uBAA4B,GACpC,eAAe,EAAE,CASnB;AAED,iFAAiF;AACjF,wBAAsB,OAAO,CAC3B,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,IAAI,EAAE,WAAW,EACjB,QAAQ,CAAC,EAAE,iBAAiB,GAC3B,OAAO,CAAC,aAAa,CAAC,CAmExB"}
@@ -1,17 +1,18 @@
1
1
  /**
2
- * @module kb-server/tools/history
2
+ * @module lore-server/tools/history
3
3
  *
4
4
  * MCP tool: query commit history by file, commit SHA, author, or recency.
5
5
  */
6
- import { getCommitBySha, listRecentCommits, listCommitsByFile, listCommitsByAuthor, listCommitsByRef, listCommitFiles, listCommitRefs, } from '../db.js';
6
+ import { getCommitBySha, listRecentCommits, listCommitsByFile, listCommitsByAuthor, listCommitsByRef, hasCommitEmbeddings, listCommitsBySemanticQuery, listCommitFiles, listCommitRefs, } from '../db.js';
7
7
  // ─── Tool definition ──────────────────────────────────────────────────────────
8
8
  export const toolDef = {
9
- name: 'kb_history',
9
+ name: 'lore_history',
10
10
  description: 'Query git commit history indexed in the knowledge base. ' +
11
- 'Supports four modes: "file" (commits that touched a file path), ' +
11
+ 'Supports six modes: "file" (commits that touched a file path), ' +
12
12
  '"commit" (look up a commit by full or partial SHA), ' +
13
13
  '"author" (commits by a given author name or email), ' +
14
14
  '"ref" (commits matching branch/tag refs), and ' +
15
+ '"semantic" (semantic commit-message matching), and ' +
15
16
  '"recent" (most recent commits). ' +
16
17
  'All modes support an optional `limit` parameter (default 20, max 200).',
17
18
  inputSchema: {
@@ -19,7 +20,7 @@ export const toolDef = {
19
20
  properties: {
20
21
  mode: {
21
22
  type: 'string',
22
- enum: ['file', 'commit', 'author', 'ref', 'recent'],
23
+ enum: ['file', 'commit', 'author', 'ref', 'semantic', 'recent'],
23
24
  description: 'Query mode.',
24
25
  },
25
26
  query: {
@@ -28,6 +29,7 @@ export const toolDef = {
28
29
  'For mode="commit": full or partial commit SHA. ' +
29
30
  'For mode="author": author name or email substring. ' +
30
31
  'For mode="ref": branch/tag ref name or substring (e.g. refs/heads/main, main, v1.2.0). ' +
32
+ 'For mode="semantic": natural-language commit search query. ' +
31
33
  'Not required for mode="recent".',
32
34
  },
33
35
  limit: {
@@ -45,8 +47,18 @@ function clampLimit(limit) {
45
47
  return DEFAULT_LIMIT;
46
48
  return Math.min(Math.max(1, Math.floor(limit)), MAX_LIMIT);
47
49
  }
48
- /** Handle a kb_history tool invocation against the open read-only database. */
49
- export function handler(db, args) {
50
+ /** Enrich commit rows with touched files and refs metadata. */
51
+ export function enrichCommitsWithContext(db, commits, options = {}) {
52
+ const includeFiles = options.includeFiles ?? true;
53
+ const includeRefs = options.includeRefs ?? true;
54
+ return commits.map((commit) => ({
55
+ ...commit,
56
+ ...(includeFiles ? { files: listCommitFiles(db, commit.sha) } : {}),
57
+ ...(includeRefs ? { refs: listCommitRefs(db, commit.sha) } : {}),
58
+ }));
59
+ }
60
+ /** Handle a lore_history tool invocation against the open read-only database. */
61
+ export async function handler(db, args, embedder) {
50
62
  const limit = clampLimit(args.limit);
51
63
  switch (args.mode) {
52
64
  case 'file': {
@@ -65,9 +77,10 @@ export function handler(db, args) {
65
77
  if (!commit) {
66
78
  return { mode: 'commit', results: [], count: 0 };
67
79
  }
68
- const files = listCommitFiles(db, commit.sha);
69
- const refs = listCommitRefs(db, commit.sha);
70
- const result = { ...commit, files, refs };
80
+ const [result] = enrichCommitsWithContext(db, [commit]);
81
+ if (!result) {
82
+ throw new Error('Failed to enrich commit context.');
83
+ }
71
84
  return { mode: 'commit', results: [result], count: 1 };
72
85
  }
73
86
  case 'author': {
@@ -82,6 +95,26 @@ export function handler(db, args) {
82
95
  const rows = listCommitsByRef(db, ref, limit);
83
96
  return { mode: 'ref', results: rows, count: rows.length };
84
97
  }
98
+ case 'semantic': {
99
+ const query = args.query?.trim() ?? '';
100
+ if (!query || !embedder || !hasCommitEmbeddings(db)) {
101
+ const rows = listRecentCommits(db, limit);
102
+ return { mode: 'semantic', results: rows, count: rows.length };
103
+ }
104
+ try {
105
+ const [queryVector] = await embedder.embed([query]);
106
+ if (!queryVector || queryVector.length === 0) {
107
+ const rows = listRecentCommits(db, limit);
108
+ return { mode: 'semantic', results: rows, count: rows.length };
109
+ }
110
+ const rows = listCommitsBySemanticQuery(db, queryVector, limit);
111
+ return { mode: 'semantic', results: rows, count: rows.length };
112
+ }
113
+ catch {
114
+ const rows = listRecentCommits(db, limit);
115
+ return { mode: 'semantic', results: rows, count: rows.length };
116
+ }
117
+ }
85
118
  case 'recent': {
86
119
  const rows = listRecentCommits(db, limit);
87
120
  return { mode: 'recent', results: rows, count: rows.length };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.js","sourceRoot":"","sources":["../../../src/lore-server/tools/history.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,0BAA0B,EAC1B,eAAe,EACf,cAAc,GAIf,MAAM,UAAU,CAAC;AAGlB,iFAAiF;AAEjF,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,cAAc;IACpB,WAAW,EACT,0DAA0D;QAC1D,iEAAiE;QACjE,sDAAsD;QACtD,sDAAsD;QACtD,gDAAgD;QAChD,qDAAqD;QACrD,kCAAkC;QAClC,wEAAwE;IAC1E,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,CAAC;gBAC/D,WAAW,EAAE,aAAa;aAC3B;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,kCAAkC;oBAClC,iDAAiD;oBACjD,qDAAqD;oBACrD,yFAAyF;oBACzF,6DAA6D;oBAC7D,iCAAiC;aACpC;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;g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AC,EAAE,CAAC;oBAC7C,MAAM,IAAI,GAAG,iBAAiB,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;oBAC1C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;gBACjE,CAAC;gBACD,MAAM,IAAI,GAAG,0BAA0B,CAAC,EAAE,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;gBAChE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;YACjE,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,IAAI,GAAG,iBAAiB,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;gBAC1C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;YACjE,CAAC;QACH,CAAC;QAED,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,IAAI,GAAG,iBAAiB,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;YAC1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QAC/D,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * @module lore-server/tools/lookup
3
+ *
4
+ * MCP tool: look up symbols by name or files by path.
5
+ */
6
+ import type { Database } from '../db.js';
7
+ import type { EmbeddingProvider } from '../../indexer/embedder.js';
8
+ export declare const toolDef: {
9
+ readonly name: "lore_lookup";
10
+ readonly description: string;
11
+ readonly inputSchema: {
12
+ readonly type: "object";
13
+ readonly properties: {
14
+ readonly kind: {
15
+ readonly type: "string";
16
+ readonly enum: readonly ["symbol", "file"];
17
+ readonly description: "Whether to look up a symbol or a file.";
18
+ };
19
+ readonly query: {
20
+ readonly type: "string";
21
+ readonly description: string;
22
+ };
23
+ readonly mode: {
24
+ readonly type: "string";
25
+ readonly enum: readonly ["exact", "semantic", "fused"];
26
+ readonly description: "For kind=\"symbol\", choose exact, semantic, or fused retrieval mode (default: \"exact\").";
27
+ };
28
+ readonly match_mode: {
29
+ readonly type: "string";
30
+ readonly enum: readonly ["exact", "prefix", "contains"];
31
+ readonly description: "For kind=\"symbol\": name matching mode. Defaults to \"exact\" (case-insensitive).";
32
+ };
33
+ readonly symbol_kind: {
34
+ readonly type: "string";
35
+ readonly description: "For kind=\"symbol\": optional symbol kind filter (for example \"function\" or \"class\").";
36
+ };
37
+ readonly path_prefix: {
38
+ readonly type: "string";
39
+ readonly description: "For kind=\"symbol\": optional indexed file-path prefix filter.";
40
+ };
41
+ readonly language: {
42
+ readonly type: "string";
43
+ readonly description: "For kind=\"symbol\": optional indexed file language filter.";
44
+ };
45
+ readonly limit: {
46
+ readonly type: "number";
47
+ readonly description: "For kind=\"symbol\" with empty query: maximum rows to return (default 20).";
48
+ };
49
+ readonly offset: {
50
+ readonly type: "number";
51
+ readonly description: "For kind=\"symbol\" with empty query: rows to skip before returning results (default 0).";
52
+ };
53
+ };
54
+ readonly required: readonly ["kind", "query"];
55
+ };
56
+ };
57
+ export interface LookupArgs {
58
+ kind: 'symbol' | 'file';
59
+ query: string;
60
+ mode?: 'exact' | 'semantic' | 'fused';
61
+ branch?: string;
62
+ match_mode?: 'exact' | 'prefix' | 'contains';
63
+ symbol_kind?: string;
64
+ path_prefix?: string;
65
+ language?: string;
66
+ limit?: number;
67
+ offset?: number;
68
+ }
69
+ export interface LookupResult {
70
+ results: unknown[];
71
+ mode_used?: string;
72
+ }
73
+ /** Resolve a lookup request against the open read-only database. */
74
+ export declare function handler(db: Database.Database, args: LookupArgs, embedder?: EmbeddingProvider): Promise<LookupResult>;
75
+ //# sourceMappingURL=lookup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../../src/lore-server/tools/lookup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAWzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAInE,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyDV,CAAC;AAIX,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAC;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAyCD,oEAAoE;AACpE,wBAAsB,OAAO,CAC3B,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,IAAI,EAAE,UAAU,EAChB,QAAQ,CAAC,EAAE,iBAAiB,GAC3B,OAAO,CAAC,YAAY,CAAC,CA2EvB"}
@@ -0,0 +1,148 @@
1
+ /**
2
+ * @module lore-server/tools/lookup
3
+ *
4
+ * MCP tool: look up symbols by name or files by path.
5
+ */
6
+ import { getSymbolsByName, getExternalSymbolsByName, getFileByPath, listSymbols, listFiles, semanticSearchSymbols, } from '../db.js';
7
+ // ─── Tool definition ──────────────────────────────────────────────────────────
8
+ export const toolDef = {
9
+ name: 'lore_lookup',
10
+ description: 'Look up symbols by name or source files by path in the knowledge-base index. ' +
11
+ 'Set `kind` to "symbol" or "file". For kind="symbol", mode="exact" matches names, mode="semantic" prioritizes embedding-nearest symbols, and mode="fused" combines both. ' +
12
+ 'Returns an array of matching rows, including persisted enrichment metadata when available.',
13
+ inputSchema: {
14
+ type: 'object',
15
+ properties: {
16
+ kind: {
17
+ type: 'string',
18
+ enum: ['symbol', 'file'],
19
+ description: 'Whether to look up a symbol or a file.',
20
+ },
21
+ query: {
22
+ type: 'string',
23
+ description: 'For kind="symbol": the symbol name to look up (case-insensitive). ' +
24
+ 'For kind="file": the exact file path stored in the index.',
25
+ },
26
+ mode: {
27
+ type: 'string',
28
+ enum: ['exact', 'semantic', 'fused'],
29
+ description: 'For kind="symbol", choose exact, semantic, or fused retrieval mode (default: "exact").',
30
+ },
31
+ match_mode: {
32
+ type: 'string',
33
+ enum: ['exact', 'prefix', 'contains'],
34
+ description: 'For kind="symbol": name matching mode. Defaults to "exact" (case-insensitive).',
35
+ },
36
+ symbol_kind: {
37
+ type: 'string',
38
+ description: 'For kind="symbol": optional symbol kind filter (for example "function" or "class").',
39
+ },
40
+ path_prefix: {
41
+ type: 'string',
42
+ description: 'For kind="symbol": optional indexed file-path prefix filter.',
43
+ },
44
+ language: {
45
+ type: 'string',
46
+ description: 'For kind="symbol": optional indexed file language filter.',
47
+ },
48
+ limit: {
49
+ type: 'number',
50
+ description: 'For kind="symbol" with empty query: maximum rows to return (default 20).',
51
+ },
52
+ offset: {
53
+ type: 'number',
54
+ description: 'For kind="symbol" with empty query: rows to skip before returning results (default 0).',
55
+ },
56
+ },
57
+ required: ['kind', 'query'],
58
+ },
59
+ };
60
+ const SYMBOL_LIMIT = 20;
61
+ function symbolKey(row) {
62
+ return `symbol:${row.id}`;
63
+ }
64
+ function mergeSemanticPreferred(exactRows, semanticRows) {
65
+ const seen = new Set(semanticRows.map((row) => symbolKey(row)));
66
+ return [...semanticRows, ...exactRows.filter((row) => !seen.has(symbolKey(row)))];
67
+ }
68
+ function mergeFused(exactRows, semanticRows) {
69
+ const seen = new Set(exactRows.map((row) => symbolKey(row)));
70
+ return [...exactRows, ...semanticRows.filter((row) => !seen.has(symbolKey(row)))];
71
+ }
72
+ async function semanticLookup(db, query, branch, embedder) {
73
+ try {
74
+ const [queryVector] = await embedder.embed([query]);
75
+ if (!queryVector || queryVector.length === 0) {
76
+ return null;
77
+ }
78
+ return semanticSearchSymbols(db, { queryVector, branch, limit: SYMBOL_LIMIT });
79
+ }
80
+ catch {
81
+ return null;
82
+ }
83
+ }
84
+ /** Resolve a lookup request against the open read-only database. */
85
+ export async function handler(db, args, embedder) {
86
+ if (args.kind === 'symbol') {
87
+ const query = args.query.trim();
88
+ const mode = args.mode ?? 'exact';
89
+ const matchMode = args.match_mode ?? 'exact';
90
+ const symbolLookupOptions = {
91
+ branch: args.branch,
92
+ matchMode,
93
+ kind: args.symbol_kind,
94
+ pathPrefix: args.path_prefix,
95
+ language: args.language,
96
+ };
97
+ const exactInternalRows = query
98
+ ? getSymbolsByName(db, query, symbolLookupOptions)
99
+ : listSymbols(db, {
100
+ ...symbolLookupOptions,
101
+ limit: args.limit ?? 20,
102
+ offset: args.offset ?? 0,
103
+ });
104
+ const includeExternalRows = !!query
105
+ && matchMode === 'exact'
106
+ && args.path_prefix === undefined
107
+ && args.language === undefined;
108
+ const externalRows = includeExternalRows
109
+ ? getExternalSymbolsByName(db, query).filter((row) => (args.symbol_kind === undefined || row.symbol_kind === args.symbol_kind))
110
+ : [];
111
+ const exactRows = [...exactInternalRows, ...externalRows];
112
+ if (!query) {
113
+ return { results: exactRows, mode_used: 'exact' };
114
+ }
115
+ if (mode === 'exact') {
116
+ return { results: exactRows, mode_used: 'exact' };
117
+ }
118
+ if (!embedder) {
119
+ return {
120
+ results: exactRows,
121
+ mode_used: 'exact (fallback: no query-time embedder)',
122
+ };
123
+ }
124
+ const semanticRows = await semanticLookup(db, query, args.branch, embedder);
125
+ if (!semanticRows) {
126
+ return {
127
+ results: exactRows,
128
+ mode_used: 'exact (fallback: no embeddings)',
129
+ };
130
+ }
131
+ if (mode === 'semantic') {
132
+ return {
133
+ results: [...mergeSemanticPreferred(exactInternalRows, semanticRows), ...externalRows],
134
+ mode_used: 'semantic',
135
+ };
136
+ }
137
+ return {
138
+ results: [...mergeFused(exactInternalRows, semanticRows), ...externalRows],
139
+ mode_used: 'fused',
140
+ };
141
+ }
142
+ if (args.query.trim()) {
143
+ const row = getFileByPath(db, args.query, args.branch);
144
+ return { results: row ? [row] : [] };
145
+ }
146
+ return { results: listFiles(db, SYMBOL_LIMIT, args.branch) };
147
+ }
148
+ //# sourceMappingURL=lookup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup.js","sourceRoot":"","sources":["../../../src/lore-server/tools/lookup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,EACb,WAAW,EACX,SAAS,EACT,qBAAqB,GAGtB,MAAM,UAAU,CAAC;AAGlB,iFAAiF;AAEjF,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,+EAA+E;QAC/E,0KAA0K;QAC1K,4FAA4F;IAC9F,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC;gBACxB,WAAW,EAAE,wCAAwC;aACtD;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,oEAAoE;oBACpE,2DAA2D;aAC9D;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC;gBACpC,WAAW,EAAE,wFAAwF;aACtG;YACD,UAAU,EAAE;gBACV,IAAI,EAA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I,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO;gBACL,OAAO,EAAE,SAAS;gBAClB,SAAS,EAAE,iCAAiC;aAC7C,CAAC;QACJ,CAAC;QAED,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;YACxB,OAAO;gBACL,OAAO,EAAE,CAAC,GAAG,sBAAsB,CAAC,iBAAiB,EAAE,YAAY,CAAC,EAAE,GAAG,YAAY,CAAC;gBACtF,SAAS,EAAE,UAAU;aACtB,CAAC;QACJ,CAAC;QAED,OAAO;YACL,OAAO,EAAE,CAAC,GAAG,UAAU,CAAC,iBAAiB,EAAE,YAAY,CAAC,EAAE,GAAG,YAAY,CAAC;YAC1E,SAAS,EAAE,OAAO;SACnB,CAAC;IACJ,CAAC;IAED,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,aAAa,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACvD,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACvC,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;AAC/D,CAAC"}
@@ -1,12 +1,12 @@
1
1
  /**
2
- * @module kb-server/tools/metrics
2
+ * @module lore-server/tools/metrics
3
3
  *
4
4
  * MCP tool: return high-level code metrics from the knowledge-base index.
5
5
  */
6
6
  import type { Database } from '../db.js';
7
7
  export declare const toolDef: {
8
- readonly name: "kb_metrics";
9
- readonly description: "Return aggregate KB metrics or top symbols by stored complexity.";
8
+ readonly name: "lore_metrics";
9
+ readonly description: "Return aggregate Lore metrics or top symbols by stored complexity.";
10
10
  readonly inputSchema: {
11
11
  readonly type: "object";
12
12
  readonly properties: {
@@ -0,0 +1 @@
1
+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,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,mBAAmB,EAAE,CAAC;CAChC;AAED,MAAM,MAAM,aAAa,GAAG,sBAAsB,GAAG,uBAAuB,CAAC;AAE7E,+DAA+D;AAC/D,wBAAgB,OAAO,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,WAAW,GAAG,aAAa,CA+D/E"}
@@ -1,13 +1,13 @@
1
1
  /**
2
- * @module kb-server/tools/metrics
2
+ * @module lore-server/tools/metrics
3
3
  *
4
4
  * MCP tool: return high-level code metrics from the knowledge-base index.
5
5
  */
6
6
  import { getCoverageStaleness, getLatestCoverageTotals } from '../db.js';
7
7
  // ─── Tool definition ──────────────────────────────────────────────────────────
8
8
  export const toolDef = {
9
- name: 'kb_metrics',
10
- description: 'Return aggregate KB metrics or top symbols by stored complexity.',
9
+ name: 'lore_metrics',
10
+ description: 'Return aggregate Lore metrics or top symbols by stored complexity.',
11
11
  inputSchema: {
12
12
  type: 'object',
13
13
  properties: {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../src/lore-server/tools/metrics.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAEzE,iFAAiF;AAEjF,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,cAAc;IACpB,WAAW,EACT,oEAAoE;IACtE,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,WAAW,EAAE,YAAY,CAAC;gBACjC,WAAW,EAAE,wEAAwE;aACtF;YACD,KAAK,EA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;QACL,YAAY,EAAE,WAAW;QACzB,UAAU,EAAE,SAAS;QACrB,iBAAiB,EAAE,eAAe;QAClC,kBAAkB,EAAE,cAAc,KAAK,SAAS;QAChD,eAAe,EAAE,SAAS,CAAC,eAAe;QAC1C,cAAc,EAAE,SAAS,CAAC,cAAc;QACxC,cAAc,EAAE,SAAS,CAAC,cAAc;QACxC,KAAK,EAAE,SAAS,CAAC,KAAK;QACtB,kBAAkB,EAAE,cAAc,EAAE,WAAW,IAAI,IAAI;QACvD,gBAAgB,EAAE,cAAc,EAAE,SAAS,IAAI,IAAI;QACnD,uBAAuB,EAAE,cAAc,EAAE,gBAAgB,IAAI,IAAI;QACjE,UAAU,EAAE,SAAS;KACtB,CAAC;AACJ,CAAC"}
@@ -1,13 +1,13 @@
1
1
  /**
2
- * @module kb-server/tools/notes
2
+ * @module lore-server/tools/notes
3
3
  *
4
4
  * MCP tools:
5
- * - kb_notes_write: upsert notes by (key, scope)
6
- * - kb_notes_read: retrieve notes with staleness/recency metadata
5
+ * - lore_notes_write: upsert notes by (key, scope)
6
+ * - lore_notes_read: retrieve notes with staleness/recency metadata
7
7
  */
8
- import type { Database as KbDatabase } from '../db.js';
9
- export declare const kbNotesWriteToolDef: {
10
- readonly name: "kb_notes_write";
8
+ import type { Database as LoreDatabase } from '../db.js';
9
+ export declare const loreNotesWriteToolDef: {
10
+ readonly name: "lore_notes_write";
11
11
  readonly description: string;
12
12
  readonly inputSchema: {
13
13
  readonly type: "object";
@@ -36,8 +36,8 @@ export declare const kbNotesWriteToolDef: {
36
36
  readonly required: readonly ["key", "content"];
37
37
  };
38
38
  };
39
- export declare const kbNotesReadToolDef: {
40
- readonly name: "kb_notes_read";
39
+ export declare const loreNotesReadToolDef: {
40
+ readonly name: "lore_notes_read";
41
41
  readonly description: string;
42
42
  readonly inputSchema: {
43
43
  readonly type: "object";
@@ -92,19 +92,19 @@ export interface NotesReadArgs {
92
92
  }
93
93
  export interface NoteWithMetadata extends NoteRow {
94
94
  stale: boolean;
95
- stale_reason: 'source_hash_mismatch' | 'file_missing' | 'indexed_after_note' | 'kb_reindexed_since_note' | null;
95
+ stale_reason: 'source_hash_mismatch' | 'file_missing' | 'doc_missing' | 'indexed_after_note' | 'lore_reindexed_since_note' | null;
96
96
  file_last_hash: string | null;
97
97
  file_indexed_at: number | null;
98
- kb_indexed_at: number | null;
98
+ lore_indexed_at: number | null;
99
99
  }
100
100
  export interface NotesReadResult {
101
101
  notes: NoteWithMetadata[];
102
102
  count: number;
103
103
  }
104
- export declare function kbNotesWriteHandler(dbPath: string, args: NotesWriteArgs): NotesWriteResult;
105
- export declare function kbNotesReadHandler(db: KbDatabase.Database, args: NotesReadArgs): NotesReadResult;
104
+ export declare function loreNotesWriteHandler(dbPath: string, args: NotesWriteArgs): NotesWriteResult;
105
+ export declare function loreNotesReadHandler(db: LoreDatabase.Database, args: NotesReadArgs): NotesReadResult;
106
106
  export declare const writeToolDef: {
107
- readonly name: "kb_notes_write";
107
+ readonly name: "lore_notes_write";
108
108
  readonly description: string;
109
109
  readonly inputSchema: {
110
110
  readonly type: "object";
@@ -134,7 +134,7 @@ export declare const writeToolDef: {
134
134
  };
135
135
  };
136
136
  export declare const readToolDef: {
137
- readonly name: "kb_notes_read";
137
+ readonly name: "lore_notes_read";
138
138
  readonly description: string;
139
139
  readonly inputSchema: {
140
140
  readonly type: "object";
@@ -159,7 +159,7 @@ export declare const readToolDef: {
159
159
  readonly required: readonly [];
160
160
  };
161
161
  };
162
- export declare const writeHandler: typeof kbNotesWriteHandler;
163
- export declare const readHandler: typeof kbNotesReadHandler;
162
+ export declare const writeHandler: typeof loreNotesWriteHandler;
163
+ export declare const readHandler: typeof loreNotesReadHandler;
164
164
  export {};
165
165
  //# sourceMappingURL=notes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notes.d.ts","sourceRoot":"","sources":["../../../src/lore-server/tools/notes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,Q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