@jafreck/lore 0.3.6 → 0.3.7

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 (78) hide show
  1. package/README.md +20 -33
  2. package/dist/cli.js +17 -3
  3. package/dist/cli.js.map +1 -1
  4. package/dist/db/schema.d.ts.map +1 -1
  5. package/dist/db/schema.js +7 -0
  6. package/dist/db/schema.js.map +1 -1
  7. package/dist/embeddings/embedder.d.ts +12 -8
  8. package/dist/embeddings/embedder.d.ts.map +1 -1
  9. package/dist/embeddings/embedder.js +35 -19
  10. package/dist/embeddings/embedder.js.map +1 -1
  11. package/dist/indexer/index.d.ts.map +1 -1
  12. package/dist/indexer/index.js +41 -9
  13. package/dist/indexer/index.js.map +1 -1
  14. package/dist/indexer/pipeline.d.ts +22 -10
  15. package/dist/indexer/pipeline.d.ts.map +1 -1
  16. package/dist/indexer/pipeline.js +41 -20
  17. package/dist/indexer/pipeline.js.map +1 -1
  18. package/dist/indexer/stages/lsp-enrichment.d.ts +1 -1
  19. package/dist/indexer/stages/lsp-enrichment.d.ts.map +1 -1
  20. package/dist/indexer/stages/lsp-enrichment.js +24 -20
  21. package/dist/indexer/stages/lsp-enrichment.js.map +1 -1
  22. package/dist/indexer/stages/scip-enrichment.d.ts +1 -1
  23. package/dist/indexer/stages/scip-enrichment.d.ts.map +1 -1
  24. package/dist/indexer/stages/scip-enrichment.js +12 -14
  25. package/dist/indexer/stages/scip-enrichment.js.map +1 -1
  26. package/dist/indexer/stages/scip-source.d.ts.map +1 -1
  27. package/dist/indexer/stages/scip-source.js +12 -10
  28. package/dist/indexer/stages/scip-source.js.map +1 -1
  29. package/dist/indexer/stages/source-index.d.ts +1 -1
  30. package/dist/indexer/stages/source-index.d.ts.map +1 -1
  31. package/dist/indexer/stages/source-index.js +90 -19
  32. package/dist/indexer/stages/source-index.js.map +1 -1
  33. package/dist/parsing/extractors/typescript.d.ts.map +1 -1
  34. package/dist/parsing/extractors/typescript.js +16 -0
  35. package/dist/parsing/extractors/typescript.js.map +1 -1
  36. package/dist/resolution/resolver.d.ts +6 -0
  37. package/dist/resolution/resolver.d.ts.map +1 -1
  38. package/dist/resolution/resolver.js +21 -0
  39. package/dist/resolution/resolver.js.map +1 -1
  40. package/dist/scip/enrichment.d.ts.map +1 -1
  41. package/dist/scip/enrichment.js +4 -4
  42. package/dist/scip/enrichment.js.map +1 -1
  43. package/dist/server/server.d.ts +1 -2
  44. package/dist/server/server.d.ts.map +1 -1
  45. package/dist/server/server.js +1 -10
  46. package/dist/server/server.js.map +1 -1
  47. package/dist/server/tool-registry.d.ts.map +1 -1
  48. package/dist/server/tool-registry.js +1 -26
  49. package/dist/server/tool-registry.js.map +1 -1
  50. package/dist/server/tools/graph.d.ts +7 -3
  51. package/dist/server/tools/graph.d.ts.map +1 -1
  52. package/dist/server/tools/graph.js +15 -85
  53. package/dist/server/tools/graph.js.map +1 -1
  54. package/dist/server/tools/metrics.d.ts +5 -30
  55. package/dist/server/tools/metrics.d.ts.map +1 -1
  56. package/dist/server/tools/metrics.js +21 -57
  57. package/dist/server/tools/metrics.js.map +1 -1
  58. package/package.json +1 -1
  59. package/dist/server/tools/annotations.d.ts +0 -40
  60. package/dist/server/tools/annotations.d.ts.map +0 -1
  61. package/dist/server/tools/annotations.js +0 -35
  62. package/dist/server/tools/annotations.js.map +0 -1
  63. package/dist/server/tools/architecture.d.ts +0 -67
  64. package/dist/server/tools/architecture.d.ts.map +0 -1
  65. package/dist/server/tools/architecture.js +0 -209
  66. package/dist/server/tools/architecture.js.map +0 -1
  67. package/dist/server/tools/coverage.d.ts +0 -67
  68. package/dist/server/tools/coverage.d.ts.map +0 -1
  69. package/dist/server/tools/coverage.js +0 -74
  70. package/dist/server/tools/coverage.js.map +0 -1
  71. package/dist/server/tools/graph-analysis.d.ts +0 -64
  72. package/dist/server/tools/graph-analysis.d.ts.map +0 -1
  73. package/dist/server/tools/graph-analysis.js +0 -82
  74. package/dist/server/tools/graph-analysis.js.map +0 -1
  75. package/dist/server/tools/writeback.d.ts +0 -49
  76. package/dist/server/tools/writeback.d.ts.map +0 -1
  77. package/dist/server/tools/writeback.js +0 -68
  78. package/dist/server/tools/writeback.js.map +0 -1
@@ -1,209 +0,0 @@
1
- /**
2
- * @module lore-server/tools/architecture
3
- *
4
- * MCP tool: return a high-level architecture view grouped by path depth.
5
- */
6
- export const toolDef = {
7
- name: 'lore_architecture',
8
- description: 'Return an architecture overview grouped by path prefix, including component summaries, ' +
9
- 'inter-component edges, entry points, leaf nodes, and external dependency usage.',
10
- inputSchema: {
11
- type: 'object',
12
- properties: {
13
- depth: {
14
- type: 'number',
15
- description: 'Optional path depth used to group files into components (default 2).',
16
- },
17
- branch: {
18
- type: 'string',
19
- description: 'Optional branch name to filter architecture output.',
20
- },
21
- },
22
- required: [],
23
- },
24
- };
25
- function toComponent(path, depth) {
26
- const parts = path.split('/').filter(Boolean);
27
- if (parts.length === 0) {
28
- return '.';
29
- }
30
- return parts.slice(0, depth).join('/');
31
- }
32
- function hasDocsTable(db) {
33
- const row = db
34
- .prepare("SELECT 1 AS present FROM sqlite_master WHERE type = 'table' AND name = 'docs' LIMIT 1")
35
- .get();
36
- return row?.present === 1;
37
- }
38
- export function handler(db, args) {
39
- const depth = Math.max(1, Math.floor(args.depth ?? 2));
40
- const fileRows = (args.branch !== undefined
41
- ? db
42
- .prepare(`SELECT f.id,
43
- f.path,
44
- f.branch,
45
- COUNT(DISTINCT s.id) AS symbol_count,
46
- COUNT(DISTINCT m.id) AS module_count
47
- FROM files f
48
- LEFT JOIN symbols s ON s.file_id = f.id
49
- LEFT JOIN file_modules fm ON fm.file_id = f.id
50
- LEFT JOIN modules m ON m.id = fm.module_id
51
- WHERE f.branch = ?
52
- GROUP BY f.id, f.path, f.branch`)
53
- .all(args.branch)
54
- : db
55
- .prepare(`SELECT f.id,
56
- f.path,
57
- f.branch,
58
- COUNT(DISTINCT s.id) AS symbol_count,
59
- COUNT(DISTINCT m.id) AS module_count
60
- FROM files f
61
- LEFT JOIN symbols s ON s.file_id = f.id
62
- LEFT JOIN file_modules fm ON fm.file_id = f.id
63
- LEFT JOIN modules m ON m.id = fm.module_id
64
- GROUP BY f.id, f.path, f.branch`)
65
- .all());
66
- const filesById = new Map(fileRows.map((row) => [row.id, row]));
67
- const componentsMap = new Map();
68
- for (const row of fileRows) {
69
- const component = toComponent(row.path, depth);
70
- const key = `${row.branch}\u0000${component}`;
71
- const existing = componentsMap.get(key);
72
- if (existing !== undefined) {
73
- existing.file_count += 1;
74
- existing.symbol_count += row.symbol_count;
75
- existing.module_count += row.module_count;
76
- continue;
77
- }
78
- componentsMap.set(key, {
79
- component,
80
- branch: row.branch,
81
- file_count: 1,
82
- symbol_count: row.symbol_count,
83
- module_count: row.module_count,
84
- docs_context: [],
85
- });
86
- }
87
- if (hasDocsTable(db)) {
88
- const docRows = (args.branch !== undefined
89
- ? db
90
- .prepare(`SELECT path, branch, kind, title, indexed_at
91
- FROM docs
92
- WHERE branch = ?
93
- ORDER BY path ASC, id ASC`)
94
- .all(args.branch)
95
- : db
96
- .prepare(`SELECT path, branch, kind, title, indexed_at
97
- FROM docs
98
- ORDER BY path ASC, id ASC`)
99
- .all());
100
- for (const doc of docRows) {
101
- const component = toComponent(doc.path, depth);
102
- const key = `${doc.branch}\u0000${component}`;
103
- const target = componentsMap.get(key);
104
- if (!target) {
105
- continue;
106
- }
107
- target.docs_context.push({
108
- path: doc.path,
109
- kind: doc.kind,
110
- title: doc.title,
111
- indexed_at: doc.indexed_at,
112
- });
113
- }
114
- }
115
- const importRows = (args.branch !== undefined
116
- ? db
117
- .prepare(`SELECT fi.file_id, fi.resolved_id, f_src.branch
118
- FROM file_imports fi
119
- JOIN files f_src ON f_src.id = fi.file_id
120
- WHERE f_src.branch = ?`)
121
- .all(args.branch)
122
- : db
123
- .prepare(`SELECT fi.file_id, fi.resolved_id, f_src.branch
124
- FROM file_imports fi
125
- JOIN files f_src ON f_src.id = fi.file_id`)
126
- .all());
127
- const edgesMap = new Map();
128
- const inboundByNode = new Map();
129
- const outboundByNode = new Map();
130
- for (const row of importRows) {
131
- if (row.resolved_id === null) {
132
- continue;
133
- }
134
- const srcFile = filesById.get(row.file_id);
135
- const dstFile = filesById.get(row.resolved_id);
136
- if (srcFile === undefined || dstFile === undefined || srcFile.branch !== dstFile.branch) {
137
- continue;
138
- }
139
- const sourceComponent = toComponent(srcFile.path, depth);
140
- const targetComponent = toComponent(dstFile.path, depth);
141
- const edgeKey = `${row.branch}\u0000${sourceComponent}\u0000${targetComponent}`;
142
- const existing = edgesMap.get(edgeKey);
143
- if (existing !== undefined) {
144
- existing.edge_count += 1;
145
- }
146
- else {
147
- edgesMap.set(edgeKey, {
148
- source_component: sourceComponent,
149
- target_component: targetComponent,
150
- branch: row.branch,
151
- edge_count: 1,
152
- });
153
- }
154
- const sourceNodeKey = `${row.branch}\u0000${sourceComponent}`;
155
- const targetNodeKey = `${row.branch}\u0000${targetComponent}`;
156
- outboundByNode.set(sourceNodeKey, (outboundByNode.get(sourceNodeKey) ?? 0) + 1);
157
- inboundByNode.set(targetNodeKey, (inboundByNode.get(targetNodeKey) ?? 0) + 1);
158
- }
159
- const entryPoints = [];
160
- const leafNodes = [];
161
- for (const component of componentsMap.values()) {
162
- const nodeKey = `${component.branch}\u0000${component.component}`;
163
- if ((inboundByNode.get(nodeKey) ?? 0) === 0) {
164
- entryPoints.push({ branch: component.branch, component: component.component });
165
- }
166
- if ((outboundByNode.get(nodeKey) ?? 0) === 0) {
167
- leafNodes.push({ branch: component.branch, component: component.component });
168
- }
169
- }
170
- const externalDepsRows = (args.branch !== undefined
171
- ? db
172
- .prepare(`SELECT f.path, f.branch, ed.package, COUNT(DISTINCT f.id) AS file_count
173
- FROM external_deps ed
174
- JOIN files f ON f.id = ed.file_id
175
- WHERE f.branch = ?
176
- GROUP BY f.path, f.branch, ed.package`)
177
- .all(args.branch)
178
- : db
179
- .prepare(`SELECT f.path, f.branch, ed.package, COUNT(DISTINCT f.id) AS file_count
180
- FROM external_deps ed
181
- JOIN files f ON f.id = ed.file_id
182
- GROUP BY f.path, f.branch, ed.package`)
183
- .all());
184
- const externalDepsMap = new Map();
185
- for (const row of externalDepsRows) {
186
- const component = toComponent(row.path, depth);
187
- const depKey = `${row.branch}\u0000${component}\u0000${row.package}`;
188
- const existing = externalDepsMap.get(depKey);
189
- if (existing !== undefined) {
190
- existing.file_count += row.file_count;
191
- }
192
- else {
193
- externalDepsMap.set(depKey, {
194
- component,
195
- branch: row.branch,
196
- package: row.package,
197
- file_count: row.file_count,
198
- });
199
- }
200
- }
201
- return {
202
- components: Array.from(componentsMap.values()),
203
- edges: Array.from(edgesMap.values()),
204
- entry_points: entryPoints,
205
- leaf_nodes: leafNodes,
206
- external_deps: Array.from(externalDepsMap.values()),
207
- };
208
- }
209
- //# sourceMappingURL=architecture.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"architecture.js","sourceRoot":"","sources":["../../../src/server/tools/architecture.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,mBAAmB;IACzB,WAAW,EACT,yFAAyF;QACzF,iFAAiF;IACnF,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,sEAAsE;aACpF;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,qDAAqD;aACnE;SACF;QACD,QAAQ,EAAE,EAAE;KACb;CACO,CAAC;AAkDX,SAAS,WAAW,CAAC,IAAY,EAAE,KAAa;IAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC9C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,KA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SAAS;QACrB,aAAa,EAAE,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC;KACpD,CAAC;AACJ,CAAC"}
@@ -1,67 +0,0 @@
1
- /**
2
- * @module lore-server/tools/coverage
3
- *
4
- * MCP tool: query symbol-level coverage and coverage staleness metadata.
5
- */
6
- import type { Database } from '../../db/read-only.js';
7
- export declare const toolDef: {
8
- readonly name: "lore_coverage";
9
- readonly description: string;
10
- readonly inputSchema: {
11
- readonly type: "object";
12
- readonly properties: {
13
- readonly symbol_id: {
14
- readonly type: "number";
15
- readonly description: "Optional symbol id to fetch exact coverage for.";
16
- };
17
- readonly symbol_name: {
18
- readonly type: "string";
19
- readonly description: "Optional symbol name filter (case-insensitive).";
20
- };
21
- readonly path: {
22
- readonly type: "string";
23
- readonly description: "Optional file path filter.";
24
- };
25
- readonly branch: {
26
- readonly type: "string";
27
- readonly description: "Optional branch filter.";
28
- };
29
- readonly limit: {
30
- readonly type: "number";
31
- readonly description: "Maximum symbols to return (default 50).";
32
- };
33
- };
34
- readonly required: readonly [];
35
- };
36
- };
37
- export interface CoverageArgs {
38
- symbol_id?: number;
39
- symbol_name?: string;
40
- path?: string;
41
- branch?: string;
42
- limit?: number;
43
- }
44
- export interface CoverageSymbolResult {
45
- symbol_id: number;
46
- symbol_name: string;
47
- file_path: string;
48
- start_line: number;
49
- end_line: number;
50
- total_lines: number;
51
- covered_lines: number;
52
- uncovered_lines: number[];
53
- coverage_percent: number | null;
54
- }
55
- export interface CoverageResult {
56
- coverage_available: boolean;
57
- coverage_commit: string | null;
58
- current_commit: string | null;
59
- commits_behind: number;
60
- stale: boolean;
61
- global_lines_found: number | null;
62
- global_lines_hit: number | null;
63
- global_coverage_percent: number | null;
64
- symbols: CoverageSymbolResult[];
65
- }
66
- export declare function handler(db: Database.Database, args: CoverageArgs): CoverageResult;
67
- //# sourceMappingURL=coverage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"coverage.d.ts","sourceRoot":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**
2
- * @module lore-server/tools/coverage
3
- *
4
- * MCP tool: query symbol-level coverage and coverage staleness metadata.
5
- */
6
- import { getCoverageStaleness, getLatestCoverageRun, getLatestCoverageTotals, getSymbolCoverageAggregates, getSymbolsByName, } from '../../db/read-only.js';
7
- export const toolDef = {
8
- name: 'lore_coverage',
9
- description: 'Return symbol-level coverage percentages, uncovered lines, and staleness metadata ' +
10
- 'for the latest ingested coverage run.',
11
- inputSchema: {
12
- type: 'object',
13
- properties: {
14
- symbol_id: {
15
- type: 'number',
16
- description: 'Optional symbol id to fetch exact coverage for.',
17
- },
18
- symbol_name: {
19
- type: 'string',
20
- description: 'Optional symbol name filter (case-insensitive).',
21
- },
22
- path: {
23
- type: 'string',
24
- description: 'Optional file path filter.',
25
- },
26
- branch: {
27
- type: 'string',
28
- description: 'Optional branch filter.',
29
- },
30
- limit: {
31
- type: 'number',
32
- description: 'Maximum symbols to return (default 50).',
33
- },
34
- },
35
- required: [],
36
- },
37
- };
38
- const DEFAULT_LIMIT = 50;
39
- export function handler(db, args) {
40
- const latestRun = getLatestCoverageRun(db);
41
- const staleness = getCoverageStaleness(db);
42
- const totals = getLatestCoverageTotals(db);
43
- const limit = Math.max(1, Math.floor(args.limit ?? DEFAULT_LIMIT));
44
- let symbolIds;
45
- if (args.symbol_id !== undefined) {
46
- symbolIds = [args.symbol_id];
47
- }
48
- else if (args.symbol_name !== undefined) {
49
- symbolIds = getSymbolsByName(db, args.symbol_name, args.branch).map((symbol) => symbol.id);
50
- if (symbolIds.length === 0) {
51
- symbolIds = [-1];
52
- }
53
- }
54
- const symbols = latestRun
55
- ? getSymbolCoverageAggregates(db, {
56
- symbolIds,
57
- path: args.path,
58
- branch: args.branch,
59
- limit,
60
- })
61
- : [];
62
- return {
63
- coverage_available: latestRun !== undefined,
64
- coverage_commit: staleness.coverage_commit,
65
- current_commit: staleness.current_commit,
66
- commits_behind: staleness.commits_behind,
67
- stale: staleness.stale,
68
- global_lines_found: totals?.lines_found ?? null,
69
- global_lines_hit: totals?.lines_hit ?? null,
70
- global_coverage_percent: totals?.coverage_percent ?? null,
71
- symbols,
72
- };
73
- }
74
- //# sourceMappingURL=coverage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"coverage.js","sourceRoot":"","sources":["../../../src/server/tools/coverage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,2BAA2B,EAC3B,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,eAAe;IACrB,WAAW,EACT,oFAAoF;QACpF,uCAAuC;IACzC,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iDAAiD;aAC/D;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iDAAiD;aAC/D;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,4BAA4B;aAC1C;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yBAAyB;aACvC;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yCAAyC;aACvD;SACF;QACD,QAAQ,EAAE,EAAE;KACb;CACO,CAAC;AAkCX,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,MAAM,UAAU,OAAO,CAAC,EAAqB,EAAE,IAAkB;IAC/D,MAAM,SAAS,GAAG,oBAAoB,CAAC,EAAE,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,oBAAoB,CAAC,EAAE,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,uBAAuB,CAAC,EAAE,CAAC,CAAC;IAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,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
- * MCP tool: run graph analysis primitives (symbol cycles, connected
5
- * components, symbol clustering, codebase summary).
6
- */
7
- import type { Database } from '../../db/read-only.js';
8
- import type { EdgeKind, SymbolCluster, CodebaseSummary } from '../../resolution/graph-analysis.js';
9
- export declare const toolDef: {
10
- readonly name: "lore_analyze";
11
- readonly description: string;
12
- readonly inputSchema: {
13
- readonly type: "object";
14
- readonly properties: {
15
- readonly mode: {
16
- readonly type: "string";
17
- readonly enum: readonly ["cycles", "components", "clusters", "summary"];
18
- readonly description: string;
19
- };
20
- readonly edge_kinds: {
21
- readonly type: "string";
22
- readonly enum: readonly ["call", "type", "both"];
23
- readonly description: "Which edge types to traverse. Default: \"both\".";
24
- };
25
- readonly scope: {
26
- readonly type: "string";
27
- readonly enum: readonly ["file", "symbol"];
28
- readonly description: "Scope for components mode. Default: \"symbol\".";
29
- };
30
- readonly branch: {
31
- readonly type: "string";
32
- readonly description: "Optional branch filter.";
33
- };
34
- readonly max_lines: {
35
- readonly type: "number";
36
- readonly description: "Maximum lines per cluster/module (for clusters and summary modes). Default: 500.";
37
- readonly minimum: 1;
38
- };
39
- };
40
- readonly required: readonly ["mode"];
41
- };
42
- };
43
- export interface AnalyzeArgs {
44
- mode: 'cycles' | 'components' | 'clusters' | 'summary';
45
- edge_kinds?: EdgeKind;
46
- scope?: 'file' | 'symbol';
47
- branch?: string;
48
- max_lines?: number;
49
- }
50
- export type AnalyzeResult = {
51
- mode: 'cycles';
52
- sccs: number[][];
53
- } | {
54
- mode: 'components';
55
- components: number[][];
56
- } | {
57
- mode: 'clusters';
58
- clusters: SymbolCluster[];
59
- } | {
60
- mode: 'summary';
61
- summary: CodebaseSummary;
62
- };
63
- export declare function handler(db: Database.Database, args: AnalyzeArgs): AnalyzeResult;
64
- //# sourceMappingURL=graph-analysis.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"graph-analysis.d.ts","sourceRoot":"","sources":["../../../src/server/tools/graph-analysis.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAOtD,OAAO,KAAK,EACV,QAAQ,EACR,aAAa,EACb,eAAe,EAChB,MAAM,oCAAoC,CAAC;AAI5C,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCV,CAAC;AAIX,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,GAAG,YAAY,GAAG,UAAU,GAAG,SAAS,CAAC;IACvD,UAAU,CAAC,EAAE,QAAQ,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,EAAE,CAAA;CAAE,GAC9C;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,aAAa,EAAE,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,eAAe,CAAA;CAAE,CAAC;AAElD,wBAAgB,OAAO,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,WAAW,GAAG,aAAa,CAqC/E"}
@@ -1,82 +0,0 @@
1
- /**
2
- * @module lore-server/tools/graph-analysis
3
- *
4
- * MCP tool: run graph analysis primitives (symbol cycles, connected
5
- * components, symbol clustering, codebase summary).
6
- */
7
- import { detectSymbolCycles, findConnectedComponents, clusterSymbols, buildCodebaseSummary, } from '../../resolution/graph-analysis.js';
8
- // ─── Tool definition ──────────────────────────────────────────────────────────
9
- export const toolDef = {
10
- name: 'lore_analyze',
11
- description: 'Run graph analysis on the knowledge-base. Supports four modes: ' +
12
- '"cycles" (symbol-level strongly connected components / mutual recursion), ' +
13
- '"components" (connected components at file or symbol level), ' +
14
- '"clusters" (partition symbol graph into bounded-size coherent chunks), ' +
15
- '"summary" (condensed codebase dependency overview with modules, SCCs, and components).',
16
- inputSchema: {
17
- type: 'object',
18
- properties: {
19
- mode: {
20
- type: 'string',
21
- enum: ['cycles', 'components', 'clusters', 'summary'],
22
- description: 'Analysis mode. "cycles": symbol-level SCC detection; "components": connected components; ' +
23
- '"clusters": bounded-size symbol clustering; "summary": full codebase summary.',
24
- },
25
- edge_kinds: {
26
- type: 'string',
27
- enum: ['call', 'type', 'both'],
28
- description: 'Which edge types to traverse. Default: "both".',
29
- },
30
- scope: {
31
- type: 'string',
32
- enum: ['file', 'symbol'],
33
- description: 'Scope for components mode. Default: "symbol".',
34
- },
35
- branch: {
36
- type: 'string',
37
- description: 'Optional branch filter.',
38
- },
39
- max_lines: {
40
- type: 'number',
41
- description: 'Maximum lines per cluster/module (for clusters and summary modes). Default: 500.',
42
- minimum: 1,
43
- },
44
- },
45
- required: ['mode'],
46
- },
47
- };
48
- export function handler(db, args) {
49
- const opts = {
50
- edgeKinds: args.edge_kinds ?? 'both',
51
- branch: args.branch,
52
- };
53
- switch (args.mode) {
54
- case 'cycles':
55
- return { mode: 'cycles', sccs: detectSymbolCycles(db, opts) };
56
- case 'components':
57
- return {
58
- mode: 'components',
59
- components: findConnectedComponents(db, {
60
- ...opts,
61
- scope: args.scope ?? 'symbol',
62
- }),
63
- };
64
- case 'clusters':
65
- return {
66
- mode: 'clusters',
67
- clusters: clusterSymbols(db, {
68
- ...opts,
69
- maxLinesPerCluster: args.max_lines,
70
- }),
71
- };
72
- case 'summary':
73
- return {
74
- mode: 'summary',
75
- summary: buildCodebaseSummary(db, {
76
- ...opts,
77
- maxLinesPerModule: args.max_lines,
78
- }),
79
- };
80
- }
81
- }
82
- //# sourceMappingURL=graph-analysis.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"graph-anal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,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,QAAQ;YACX,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,kBAAkB,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;QAEhE,KAAK,YAAY;YACf,OAAO;gBACL,IAAI,EAAE,YAAY;gBAClB,UAAU,EAAE,uBAAuB,CAAC,EAAE,EAAE;oBACtC,GAAG,IAAI;oBACP,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,QAAQ;iBAC9B,CAAC;aACH,CAAC;QAEJ,KAAK,UAAU;YACb,OAAO;gBACL,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,cAAc,CAAC,EAAE,EAAE;oBAC3B,GAAG,IAAI;oBACP,kBAAkB,EAAE,IAAI,CAAC,SAAS;iBACnC,CAAC;aACH,CAAC;QAEJ,KAAK,SAAS;YACZ,OAAO;gBACL,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,oBAAoB,CAAC,EAAE,EAAE;oBAChC,GAAG,IAAI;oBACP,iBAAiB,EAAE,IAAI,CAAC,SAAS;iBAClC,CAAC;aACH,CAAC;IACN,CAAC;AACH,CAAC"}
@@ -1,49 +0,0 @@
1
- /**
2
- * @module lore-server/tools/writeback
3
- *
4
- * MCP tool: write LLM-generated summaries back to the `symbol_summaries`
5
- * table. Unlike other tools this handler opens a **read-write** DB
6
- * connection so it can INSERT/REPLACE rows.
7
- */
8
- export declare const toolDef: {
9
- readonly name: "lore_writeback";
10
- readonly description: string;
11
- readonly inputSchema: {
12
- readonly type: "object";
13
- readonly properties: {
14
- readonly symbol_id: {
15
- readonly type: "number";
16
- readonly description: "The id of the symbol row to attach the summary to.";
17
- };
18
- readonly summary: {
19
- readonly type: "string";
20
- readonly description: "The natural-language summary text.";
21
- };
22
- readonly model: {
23
- readonly type: "string";
24
- readonly description: "Identifier of the LLM model that produced the summary.";
25
- };
26
- };
27
- readonly required: readonly ["symbol_id", "summary", "model"];
28
- };
29
- };
30
- export interface WritebackArgs {
31
- symbol_id: number;
32
- summary: string;
33
- model: string;
34
- branch?: string;
35
- }
36
- export interface WritebackResult {
37
- ok: boolean;
38
- symbol_id: number;
39
- }
40
- /**
41
- * Upsert a symbol summary.
42
- *
43
- * @param dbPath Absolute path to the knowledge-base SQLite file.
44
- * A **new** read-write connection is opened for each call so
45
- * this function can safely be used alongside read-only handles.
46
- * @param args Tool arguments.
47
- */
48
- export declare function handler(dbPath: string, args: WritebackArgs): WritebackResult;
49
- //# sourceMappingURL=writeback.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"writeback.d.ts","sourceRoot":"","sources":["../../../src/server/tools/writeback.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;CAwBV,CAAC;AAIX,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,OAAO,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,eAAe,CAgC5E"}
@@ -1,68 +0,0 @@
1
- /**
2
- * @module lore-server/tools/writeback
3
- *
4
- * MCP tool: write LLM-generated summaries back to the `symbol_summaries`
5
- * table. Unlike other tools this handler opens a **read-write** DB
6
- * connection so it can INSERT/REPLACE rows.
7
- */
8
- import Database from 'better-sqlite3';
9
- // ─── Tool definition ──────────────────────────────────────────────────────────
10
- export const toolDef = {
11
- name: 'lore_writeback',
12
- description: 'Persist an LLM-generated natural-language summary for a symbol back into ' +
13
- 'the knowledge-base `symbol_summaries` table. The summary can be retrieved ' +
14
- 'later via lore_lookup.',
15
- inputSchema: {
16
- type: 'object',
17
- properties: {
18
- symbol_id: {
19
- type: 'number',
20
- description: 'The id of the symbol row to attach the summary to.',
21
- },
22
- summary: {
23
- type: 'string',
24
- description: 'The natural-language summary text.',
25
- },
26
- model: {
27
- type: 'string',
28
- description: 'Identifier of the LLM model that produced the summary.',
29
- },
30
- },
31
- required: ['symbol_id', 'summary', 'model'],
32
- },
33
- };
34
- /**
35
- * Upsert a symbol summary.
36
- *
37
- * @param dbPath Absolute path to the knowledge-base SQLite file.
38
- * A **new** read-write connection is opened for each call so
39
- * this function can safely be used alongside read-only handles.
40
- * @param args Tool arguments.
41
- */
42
- export function handler(dbPath, args) {
43
- // Open a fresh read-write connection (separate from any read-only handle).
44
- const db = new Database(dbPath);
45
- try {
46
- db.pragma('foreign_keys = ON');
47
- // When branch is supplied, verify the symbol belongs to that branch.
48
- if (args.branch !== undefined) {
49
- const row = db
50
- .prepare(`SELECT s.id FROM symbols s
51
- JOIN files f ON f.id = s.file_id
52
- WHERE s.id = ? AND f.branch = ?`)
53
- .get(args.symbol_id, args.branch);
54
- if (!row) {
55
- throw new Error(`Symbol ${args.symbol_id} not found in branch '${args.branch}'`);
56
- }
57
- }
58
- db
59
- .prepare(`INSERT OR REPLACE INTO symbol_summaries (symbol_id, summary, model, created_at)
60
- VALUES (?, ?, ?, unixepoch())`)
61
- .run(args.symbol_id, args.summary, args.model);
62
- return { ok: true, symbol_id: args.symbol_id };
63
- }
64
- finally {
65
- db.close();
66
- }
67
- }
68
- //# sourceMappingURL=writeback.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"writeback.js","sourceRoot":"","sources":["../../../src/server/tools/writeback.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,iFAAiF;AAEjF,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACT,2EAA2E;QAC3E,6EAA6E;QAC7E,wBAA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