@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
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @module kb-server/tools/history
3
+ *
4
+ * MCP tool: query commit history by file, commit SHA, author, or recency.
5
+ */
6
+ import type { Database } from '../db.js';
7
+ import { type CommitRow, type CommitFileRow, type CommitRefRow } from '../db.js';
8
+ export declare const toolDef: {
9
+ readonly name: "kb_history";
10
+ readonly description: string;
11
+ readonly inputSchema: {
12
+ readonly type: "object";
13
+ readonly properties: {
14
+ readonly mode: {
15
+ readonly type: "string";
16
+ readonly enum: readonly ["file", "commit", "author", "ref", "recent"];
17
+ readonly description: "Query mode.";
18
+ };
19
+ readonly query: {
20
+ readonly type: "string";
21
+ readonly description: string;
22
+ };
23
+ readonly limit: {
24
+ readonly type: "number";
25
+ readonly description: "Max results to return (default 20, max 200).";
26
+ };
27
+ };
28
+ readonly required: readonly ["mode"];
29
+ };
30
+ };
31
+ export interface HistoryArgs {
32
+ mode: 'file' | 'commit' | 'author' | 'ref' | 'recent';
33
+ query?: string;
34
+ limit?: number;
35
+ }
36
+ export interface CommitWithFiles extends CommitRow {
37
+ files?: CommitFileRow[];
38
+ refs?: CommitRefRow[];
39
+ }
40
+ export interface HistoryResult {
41
+ mode: string;
42
+ results: CommitWithFiles[];
43
+ count: number;
44
+ }
45
+ /** Handle a kb_history tool invocation against the open read-only database. */
46
+ export declare function handler(db: Database.Database, args: HistoryArgs): HistoryResult;
47
+ //# sourceMappingURL=history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../src/kb-server/tools/history.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAQL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAIlB,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;CAkCV,CAAC;AAIX,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,CAAC;IACtD,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,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;CACf;AAUD,+EAA+E;AAC/E,wBAAgB,OAAO,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,WAAW,GAAG,aAAa,CA8C/E"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * @module kb-server/tools/history
3
+ *
4
+ * MCP tool: query commit history by file, commit SHA, author, or recency.
5
+ */
6
+ import { getCommitBySha, listRecentCommits, listCommitsByFile, listCommitsByAuthor, listCommitsByRef, listCommitFiles, listCommitRefs, } from '../db.js';
7
+ // ─── Tool definition ──────────────────────────────────────────────────────────
8
+ export const toolDef = {
9
+ name: 'kb_history',
10
+ description: 'Query git commit history indexed in the knowledge base. ' +
11
+ 'Supports four modes: "file" (commits that touched a file path), ' +
12
+ '"commit" (look up a commit by full or partial SHA), ' +
13
+ '"author" (commits by a given author name or email), ' +
14
+ '"ref" (commits matching branch/tag refs), and ' +
15
+ '"recent" (most recent commits). ' +
16
+ 'All modes support an optional `limit` parameter (default 20, max 200).',
17
+ inputSchema: {
18
+ type: 'object',
19
+ properties: {
20
+ mode: {
21
+ type: 'string',
22
+ enum: ['file', 'commit', 'author', 'ref', 'recent'],
23
+ description: 'Query mode.',
24
+ },
25
+ query: {
26
+ type: 'string',
27
+ description: 'For mode="file": the file path. ' +
28
+ 'For mode="commit": full or partial commit SHA. ' +
29
+ 'For mode="author": author name or email substring. ' +
30
+ 'For mode="ref": branch/tag ref name or substring (e.g. refs/heads/main, main, v1.2.0). ' +
31
+ 'Not required for mode="recent".',
32
+ },
33
+ limit: {
34
+ type: 'number',
35
+ description: 'Max results to return (default 20, max 200).',
36
+ },
37
+ },
38
+ required: ['mode'],
39
+ },
40
+ };
41
+ const DEFAULT_LIMIT = 20;
42
+ const MAX_LIMIT = 200;
43
+ function clampLimit(limit) {
44
+ if (limit == null)
45
+ return DEFAULT_LIMIT;
46
+ return Math.min(Math.max(1, Math.floor(limit)), MAX_LIMIT);
47
+ }
48
+ /** Handle a kb_history tool invocation against the open read-only database. */
49
+ export function handler(db, args) {
50
+ const limit = clampLimit(args.limit);
51
+ switch (args.mode) {
52
+ case 'file': {
53
+ const filePath = args.query?.trim() ?? '';
54
+ const rows = filePath
55
+ ? listCommitsByFile(db, filePath, limit)
56
+ : listRecentCommits(db, limit);
57
+ return { mode: 'file', results: rows, count: rows.length };
58
+ }
59
+ case 'commit': {
60
+ const sha = args.query?.trim() ?? '';
61
+ if (!sha) {
62
+ return { mode: 'commit', results: [], count: 0 };
63
+ }
64
+ const commit = getCommitBySha(db, sha);
65
+ if (!commit) {
66
+ return { mode: 'commit', results: [], count: 0 };
67
+ }
68
+ const files = listCommitFiles(db, commit.sha);
69
+ const refs = listCommitRefs(db, commit.sha);
70
+ const result = { ...commit, files, refs };
71
+ return { mode: 'commit', results: [result], count: 1 };
72
+ }
73
+ case 'author': {
74
+ const author = args.query?.trim() ?? '';
75
+ const rows = author
76
+ ? listCommitsByAuthor(db, author, limit)
77
+ : listRecentCommits(db, limit);
78
+ return { mode: 'author', results: rows, count: rows.length };
79
+ }
80
+ case 'ref': {
81
+ const ref = args.query?.trim() ?? '';
82
+ const rows = listCommitsByRef(db, ref, limit);
83
+ return { mode: 'ref', results: rows, count: rows.length };
84
+ }
85
+ case 'recent': {
86
+ const rows = listRecentCommits(db, limit);
87
+ return { mode: 'recent', results: rows, count: rows.length };
88
+ }
89
+ }
90
+ }
91
+ //# sourceMappingURL=history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.js","sourceRoot":"","sources":["../../../src/kb-server/tools/history.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,cAAc,GAIf,MAAM,UAAU,CAAC;AAElB,iFAAiF;AAEjF,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,YAAY;IAClB,WAAW,EACT,0DAA0D;QAC1D,kEAAkE;QAClE,sDAAsD;QACtD,sDAAsD;QACtD,gDAAgD;QAChD,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,QAAQ,CAAC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MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YACrC,MAAM,IAAI,GAAG,gBAAgB,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;YAC9C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QAC5D,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,36 @@
1
+ /**
2
+ * @module kb-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
+ export declare const toolDef: {
8
+ readonly name: "kb_lookup";
9
+ readonly description: string;
10
+ readonly inputSchema: {
11
+ readonly type: "object";
12
+ readonly properties: {
13
+ readonly kind: {
14
+ readonly type: "string";
15
+ readonly enum: readonly ["symbol", "file"];
16
+ readonly description: "Whether to look up a symbol or a file.";
17
+ };
18
+ readonly query: {
19
+ readonly type: "string";
20
+ readonly description: string;
21
+ };
22
+ };
23
+ readonly required: readonly ["kind", "query"];
24
+ };
25
+ };
26
+ export interface LookupArgs {
27
+ kind: 'symbol' | 'file';
28
+ query: string;
29
+ branch?: string;
30
+ }
31
+ export interface LookupResult {
32
+ results: unknown[];
33
+ }
34
+ /** Resolve a lookup request against the open read-only database. */
35
+ export declare function handler(db: Database.Database, args: LookupArgs): LookupResult;
36
+ //# sourceMappingURL=lookup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../../src/kb-server/tools/lookup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKzC,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;CAsBV,CAAC;AAIX,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB;AAED,oEAAoE;AACpE,wBAAgB,OAAO,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,UAAU,GAAG,YAAY,CAa7E"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @module kb-server/tools/lookup
3
+ *
4
+ * MCP tool: look up symbols by name or files by path.
5
+ */
6
+ import { getSymbolsByName, getFileByPath, listSymbols, listFiles } from '../db.js';
7
+ // ─── Tool definition ──────────────────────────────────────────────────────────
8
+ export const toolDef = {
9
+ name: 'kb_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". Returns an array of matching rows.',
12
+ inputSchema: {
13
+ type: 'object',
14
+ properties: {
15
+ kind: {
16
+ type: 'string',
17
+ enum: ['symbol', 'file'],
18
+ description: 'Whether to look up a symbol or a file.',
19
+ },
20
+ query: {
21
+ type: 'string',
22
+ description: 'For kind="symbol": the symbol name to look up (case-insensitive). ' +
23
+ 'For kind="file": the exact file path stored in the index.',
24
+ },
25
+ },
26
+ required: ['kind', 'query'],
27
+ },
28
+ };
29
+ /** Resolve a lookup request against the open read-only database. */
30
+ export function handler(db, args) {
31
+ if (args.kind === 'symbol') {
32
+ const rows = args.query.trim()
33
+ ? getSymbolsByName(db, args.query, args.branch)
34
+ : listSymbols(db, 20, args.branch);
35
+ return { results: rows };
36
+ }
37
+ else {
38
+ if (args.query.trim()) {
39
+ const row = getFileByPath(db, args.query, args.branch);
40
+ return { results: row ? [row] : [] };
41
+ }
42
+ return { results: listFiles(db, 20, args.branch) };
43
+ }
44
+ }
45
+ //# sourceMappingURL=lookup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup.js","sourceRoot":"","sources":["../../../src/kb-server/tools/lookup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEnF,iFAAiF;AAEjF,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,WAAW;IACjB,WAAW,EACT,+EAA+E;QAC/E,sEAAsE;IACxE,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;SACF;QACD,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;KAC5B;CACO,CAAC;AAcX,oEAAoE;AACpE,MAAM,UAAU,OAAO,CAAC,EAAqB,EAAE,IAAgB;IAC7D,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;YAC5B,CAAC,CAAC,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;YAC/C,CAAC,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;SAAM,CAAC;QACN,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;YACtB,MAAM,GAAG,GAAG,aAAa,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YACvD,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACvC,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;IACrD,CAAC;AACH,CAAC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * @module kb-server/tools/metrics
3
+ *
4
+ * MCP tool: return high-level code metrics from the knowledge-base index.
5
+ */
6
+ import type { Database } from '../db.js';
7
+ export declare const toolDef: {
8
+ readonly name: "kb_metrics";
9
+ readonly description: "Return aggregate KB metrics or top symbols by stored complexity.";
10
+ readonly inputSchema: {
11
+ readonly type: "object";
12
+ readonly properties: {
13
+ readonly mode: {
14
+ readonly type: "string";
15
+ readonly enum: readonly ["aggregate", "complexity"];
16
+ readonly description: "Metrics mode: aggregate counts (default) or complexity-ranked symbols.";
17
+ };
18
+ readonly limit: {
19
+ readonly type: "number";
20
+ readonly description: "Max symbols returned for complexity mode (default 20, max 200).";
21
+ };
22
+ readonly min_cyclomatic: {
23
+ readonly type: "number";
24
+ readonly description: "Minimum cyclomatic score filter for complexity mode (default 0).";
25
+ };
26
+ };
27
+ readonly required: readonly [];
28
+ };
29
+ };
30
+ export interface MetricsArgs {
31
+ mode?: 'aggregate' | 'complexity';
32
+ limit?: number;
33
+ min_cyclomatic?: number;
34
+ }
35
+ export interface AggregateMetricsResult {
36
+ symbol_count: number;
37
+ file_count: number;
38
+ import_edge_count: number;
39
+ coverage_available: boolean;
40
+ coverage_commit: string | null;
41
+ current_commit: string | null;
42
+ commits_behind: number;
43
+ stale: boolean;
44
+ global_lines_found: number | null;
45
+ global_lines_hit: number | null;
46
+ global_coverage_percent: number | null;
47
+ per_branch: Array<{
48
+ branch: string;
49
+ file_count: number;
50
+ symbol_count: number;
51
+ }>;
52
+ }
53
+ export interface ComplexitySymbolRow {
54
+ id: number;
55
+ file_id: number;
56
+ name: string;
57
+ kind: string;
58
+ start_line: number;
59
+ end_line: number;
60
+ signature: string | null;
61
+ doc_comment: string | null;
62
+ line_count: number;
63
+ param_count: number;
64
+ cyclomatic: number;
65
+ max_nesting: number;
66
+ }
67
+ export interface ComplexityMetricsResult {
68
+ symbols: ComplexitySymbolRow[];
69
+ }
70
+ export type MetricsResult = AggregateMetricsResult | ComplexityMetricsResult;
71
+ /** Collect aggregate counts from the knowledge-base tables. */
72
+ export declare function handler(db: Database.Database, args: MetricsArgs): MetricsResult;
73
+ //# sourceMappingURL=metrics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../../src/kb-server/tools/metrics.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKzC,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;CAuBV,CAAC;AAIX,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,WAAW,GAAG,YAAY,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;IACf,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,uBAAuB,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,UAAU,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACjF;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,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"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * @module kb-server/tools/metrics
3
+ *
4
+ * MCP tool: return high-level code metrics from the knowledge-base index.
5
+ */
6
+ import { getCoverageStaleness, getLatestCoverageTotals } from '../db.js';
7
+ // ─── Tool definition ──────────────────────────────────────────────────────────
8
+ export const toolDef = {
9
+ name: 'kb_metrics',
10
+ description: 'Return aggregate KB metrics or top symbols by stored complexity.',
11
+ inputSchema: {
12
+ type: 'object',
13
+ properties: {
14
+ mode: {
15
+ type: 'string',
16
+ enum: ['aggregate', 'complexity'],
17
+ description: 'Metrics mode: aggregate counts (default) or complexity-ranked symbols.',
18
+ },
19
+ limit: {
20
+ type: 'number',
21
+ description: 'Max symbols returned for complexity mode (default 20, max 200).',
22
+ },
23
+ min_cyclomatic: {
24
+ type: 'number',
25
+ description: 'Minimum cyclomatic score filter for complexity mode (default 0).',
26
+ },
27
+ },
28
+ required: [],
29
+ },
30
+ };
31
+ /** Collect aggregate counts from the knowledge-base tables. */
32
+ export function handler(db, args) {
33
+ if (args.mode === 'complexity') {
34
+ const minCyclomatic = Math.max(0, args.min_cyclomatic ?? 0);
35
+ const limit = Math.min(Math.max(1, args.limit ?? 20), 200);
36
+ const symbols = db
37
+ .prepare(`SELECT s.*,
38
+ sm.line_count,
39
+ sm.param_count,
40
+ sm.cyclomatic,
41
+ sm.max_nesting
42
+ FROM symbol_metrics sm
43
+ JOIN symbols s ON s.id = sm.symbol_id
44
+ WHERE sm.cyclomatic >= ?
45
+ ORDER BY sm.cyclomatic DESC, s.id ASC
46
+ LIMIT ?`)
47
+ .all(minCyclomatic, limit);
48
+ return { symbols };
49
+ }
50
+ const symbolCount = db.prepare('SELECT COUNT(*) AS c FROM symbols').get().c;
51
+ const fileCount = db.prepare('SELECT COUNT(*) AS c FROM files').get().c;
52
+ const importEdgeCount = db.prepare('SELECT COUNT(*) AS c FROM file_imports').get().c;
53
+ const perBranch = db
54
+ .prepare(`SELECT f.branch,
55
+ COUNT(DISTINCT f.id) AS file_count,
56
+ COUNT(DISTINCT s.id) AS symbol_count
57
+ FROM files f
58
+ LEFT JOIN symbols s ON s.file_id = f.id
59
+ GROUP BY f.branch
60
+ ORDER BY f.branch`)
61
+ .all();
62
+ const coverageTotals = getLatestCoverageTotals(db);
63
+ const staleness = getCoverageStaleness(db);
64
+ return {
65
+ symbol_count: symbolCount,
66
+ file_count: fileCount,
67
+ import_edge_count: importEdgeCount,
68
+ coverage_available: coverageTotals !== undefined,
69
+ coverage_commit: staleness.coverage_commit,
70
+ current_commit: staleness.current_commit,
71
+ commits_behind: staleness.commits_behind,
72
+ stale: staleness.stale,
73
+ global_lines_found: coverageTotals?.lines_found ?? null,
74
+ global_lines_hit: coverageTotals?.lines_hit ?? null,
75
+ global_coverage_percent: coverageTotals?.coverage_percent ?? null,
76
+ per_branch: perBranch,
77
+ };
78
+ }
79
+ //# sourceMappingURL=metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../src/kb-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,YAAY;IAClB,WAAW,EACT,kEAAkE;IACpE,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,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iEAAiE;aAC/E;YACD,cAAc,EAAE;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,kEAAkE;aAChF;SACF;QACD,QAAQ,EAAE,EAAE;KACb;CACO,CAAC;AA8CX,+DAA+D;AAC/D,MAAM,UAAU,OAAO,CAAC,EAAqB,EAAE,IAAiB;IAC9D,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QAC/B,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,cAAc,IAAI,CAAC,CAAC,CAAC;QAC5D,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,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kb-server/tools/notes
3
+ *
4
+ * MCP tools:
5
+ * - kb_notes_write: upsert notes by (key, scope)
6
+ * - kb_notes_read: retrieve notes with staleness/recency metadata
7
+ */
8
+ import type { Database as KbDatabase } from '../db.js';
9
+ export declare const kbNotesWriteToolDef: {
10
+ readonly name: "kb_notes_write";
11
+ readonly description: string;
12
+ readonly inputSchema: {
13
+ readonly type: "object";
14
+ readonly properties: {
15
+ readonly key: {
16
+ readonly type: "string";
17
+ readonly description: "Topic identifier, e.g. \"architecture/overview\".";
18
+ };
19
+ readonly scope: {
20
+ readonly type: "string";
21
+ readonly description: "Optional scope (default \"global\"), e.g. file:<path>, module:<name>.";
22
+ };
23
+ readonly content: {
24
+ readonly type: "string";
25
+ readonly description: "The note text.";
26
+ };
27
+ readonly model: {
28
+ readonly type: "string";
29
+ readonly description: "Model identifier that authored the note.";
30
+ };
31
+ readonly source_hash: {
32
+ readonly type: "string";
33
+ readonly description: "Optional source hash used for staleness detection.";
34
+ };
35
+ };
36
+ readonly required: readonly ["key", "content"];
37
+ };
38
+ };
39
+ export declare const kbNotesReadToolDef: {
40
+ readonly name: "kb_notes_read";
41
+ readonly description: string;
42
+ readonly inputSchema: {
43
+ readonly type: "object";
44
+ readonly properties: {
45
+ readonly key: {
46
+ readonly type: "string";
47
+ readonly description: "Exact key match.";
48
+ };
49
+ readonly key_prefix: {
50
+ readonly type: "string";
51
+ readonly description: "Prefix match (e.g. \"architecture/\").";
52
+ };
53
+ readonly scope: {
54
+ readonly type: "string";
55
+ readonly description: "Optional scope filter.";
56
+ };
57
+ readonly limit: {
58
+ readonly type: "number";
59
+ readonly description: "Max notes to return (default 20, max 200).";
60
+ };
61
+ };
62
+ readonly required: readonly [];
63
+ };
64
+ };
65
+ export interface NotesWriteArgs {
66
+ key: string;
67
+ scope?: string;
68
+ content: string;
69
+ model?: string;
70
+ source_hash?: string;
71
+ }
72
+ export interface NotesWriteResult {
73
+ ok: boolean;
74
+ key: string;
75
+ scope: string;
76
+ updated_at: number;
77
+ }
78
+ interface NoteRow {
79
+ key: string;
80
+ scope: string;
81
+ content: string;
82
+ model: string;
83
+ source_hash: string | null;
84
+ created_at: number;
85
+ updated_at: number;
86
+ }
87
+ export interface NotesReadArgs {
88
+ key?: string;
89
+ key_prefix?: string;
90
+ scope?: string;
91
+ limit?: number;
92
+ }
93
+ export interface NoteWithMetadata extends NoteRow {
94
+ stale: boolean;
95
+ stale_reason: 'source_hash_mismatch' | 'file_missing' | 'indexed_after_note' | 'kb_reindexed_since_note' | null;
96
+ file_last_hash: string | null;
97
+ file_indexed_at: number | null;
98
+ kb_indexed_at: number | null;
99
+ }
100
+ export interface NotesReadResult {
101
+ notes: NoteWithMetadata[];
102
+ count: number;
103
+ }
104
+ export declare function kbNotesWriteHandler(dbPath: string, args: NotesWriteArgs): NotesWriteResult;
105
+ export declare function kbNotesReadHandler(db: KbDatabase.Database, args: NotesReadArgs): NotesReadResult;
106
+ export declare const writeToolDef: {
107
+ readonly name: "kb_notes_write";
108
+ readonly description: string;
109
+ readonly inputSchema: {
110
+ readonly type: "object";
111
+ readonly properties: {
112
+ readonly key: {
113
+ readonly type: "string";
114
+ readonly description: "Topic identifier, e.g. \"architecture/overview\".";
115
+ };
116
+ readonly scope: {
117
+ readonly type: "string";
118
+ readonly description: "Optional scope (default \"global\"), e.g. file:<path>, module:<name>.";
119
+ };
120
+ readonly content: {
121
+ readonly type: "string";
122
+ readonly description: "The note text.";
123
+ };
124
+ readonly model: {
125
+ readonly type: "string";
126
+ readonly description: "Model identifier that authored the note.";
127
+ };
128
+ readonly source_hash: {
129
+ readonly type: "string";
130
+ readonly description: "Optional source hash used for staleness detection.";
131
+ };
132
+ };
133
+ readonly required: readonly ["key", "content"];
134
+ };
135
+ };
136
+ export declare const readToolDef: {
137
+ readonly name: "kb_notes_read";
138
+ readonly description: string;
139
+ readonly inputSchema: {
140
+ readonly type: "object";
141
+ readonly properties: {
142
+ readonly key: {
143
+ readonly type: "string";
144
+ readonly description: "Exact key match.";
145
+ };
146
+ readonly key_prefix: {
147
+ readonly type: "string";
148
+ readonly description: "Prefix match (e.g. \"architecture/\").";
149
+ };
150
+ readonly scope: {
151
+ readonly type: "string";
152
+ readonly description: "Optional scope filter.";
153
+ };
154
+ readonly limit: {
155
+ readonly type: "number";
156
+ readonly description: "Max notes to return (default 20, max 200).";
157
+ };
158
+ };
159
+ readonly required: readonly [];
160
+ };
161
+ };
162
+ export declare const writeHandler: typeof kbNotesWriteHandler;
163
+ export declare const readHandler: typeof kbNotesReadHandler;
164
+ export {};
165
+ //# sourceMappingURL=notes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notes.d.ts","sourceRoot":"","sources":["../../../src/kb-server/tools/notes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,UAAU,CAAC;AAMvD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsBtB,CAAC;AAEX,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;CAerB,CAAC;AAEX,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,OAAO,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,OAAO;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE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