@esankhan3/anvil-knowledge-core 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 (126) hide show
  1. package/README.md +194 -0
  2. package/dist/__tests__/chunker.test.d.ts +10 -0
  3. package/dist/__tests__/chunker.test.d.ts.map +1 -0
  4. package/dist/__tests__/chunker.test.js +161 -0
  5. package/dist/__tests__/chunker.test.js.map +1 -0
  6. package/dist/__tests__/query-classifier.test.d.ts +5 -0
  7. package/dist/__tests__/query-classifier.test.d.ts.map +1 -0
  8. package/dist/__tests__/query-classifier.test.js +158 -0
  9. package/dist/__tests__/query-classifier.test.js.map +1 -0
  10. package/dist/__tests__/retriever-defaults.test.d.ts +12 -0
  11. package/dist/__tests__/retriever-defaults.test.d.ts.map +1 -0
  12. package/dist/__tests__/retriever-defaults.test.js +37 -0
  13. package/dist/__tests__/retriever-defaults.test.js.map +1 -0
  14. package/dist/__tests__/structural-hasher.test.d.ts +5 -0
  15. package/dist/__tests__/structural-hasher.test.d.ts.map +1 -0
  16. package/dist/__tests__/structural-hasher.test.js +185 -0
  17. package/dist/__tests__/structural-hasher.test.js.map +1 -0
  18. package/dist/ast-graph-builder.d.ts +38 -0
  19. package/dist/ast-graph-builder.d.ts.map +1 -0
  20. package/dist/ast-graph-builder.js +1041 -0
  21. package/dist/ast-graph-builder.js.map +1 -0
  22. package/dist/chunker.d.ts +47 -0
  23. package/dist/chunker.d.ts.map +1 -0
  24. package/dist/chunker.js +428 -0
  25. package/dist/chunker.js.map +1 -0
  26. package/dist/claude-runner.d.ts +10 -0
  27. package/dist/claude-runner.d.ts.map +1 -0
  28. package/dist/claude-runner.js +10 -0
  29. package/dist/claude-runner.js.map +1 -0
  30. package/dist/config.d.ts +36 -0
  31. package/dist/config.d.ts.map +1 -0
  32. package/dist/config.js +83 -0
  33. package/dist/config.js.map +1 -0
  34. package/dist/cross-repo-detector.d.ts +7 -0
  35. package/dist/cross-repo-detector.d.ts.map +1 -0
  36. package/dist/cross-repo-detector.js +990 -0
  37. package/dist/cross-repo-detector.js.map +1 -0
  38. package/dist/embedder.d.ts +84 -0
  39. package/dist/embedder.d.ts.map +1 -0
  40. package/dist/embedder.js +378 -0
  41. package/dist/embedder.js.map +1 -0
  42. package/dist/file-walker.d.ts +18 -0
  43. package/dist/file-walker.d.ts.map +1 -0
  44. package/dist/file-walker.js +221 -0
  45. package/dist/file-walker.js.map +1 -0
  46. package/dist/git-diff.d.ts +32 -0
  47. package/dist/git-diff.d.ts.map +1 -0
  48. package/dist/git-diff.js +145 -0
  49. package/dist/git-diff.js.map +1 -0
  50. package/dist/graph-metrics.d.ts +31 -0
  51. package/dist/graph-metrics.d.ts.map +1 -0
  52. package/dist/graph-metrics.js +277 -0
  53. package/dist/graph-metrics.js.map +1 -0
  54. package/dist/graph-query.d.ts +8 -0
  55. package/dist/graph-query.d.ts.map +1 -0
  56. package/dist/graph-query.js +79 -0
  57. package/dist/graph-query.js.map +1 -0
  58. package/dist/index.d.ts +27 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +43 -0
  61. package/dist/index.js.map +1 -0
  62. package/dist/indexer.d.ts +98 -0
  63. package/dist/indexer.d.ts.map +1 -0
  64. package/dist/indexer.js +635 -0
  65. package/dist/indexer.js.map +1 -0
  66. package/dist/project-graph-builder-core.d.ts +48 -0
  67. package/dist/project-graph-builder-core.d.ts.map +1 -0
  68. package/dist/project-graph-builder-core.js +213 -0
  69. package/dist/project-graph-builder-core.js.map +1 -0
  70. package/dist/project-graph-builder.d.ts +39 -0
  71. package/dist/project-graph-builder.d.ts.map +1 -0
  72. package/dist/project-graph-builder.js +640 -0
  73. package/dist/project-graph-builder.js.map +1 -0
  74. package/dist/query-classifier.d.ts +38 -0
  75. package/dist/query-classifier.d.ts.map +1 -0
  76. package/dist/query-classifier.js +199 -0
  77. package/dist/query-classifier.js.map +1 -0
  78. package/dist/query-router.d.ts +82 -0
  79. package/dist/query-router.d.ts.map +1 -0
  80. package/dist/query-router.js +278 -0
  81. package/dist/query-router.js.map +1 -0
  82. package/dist/rag-evaluator.d.ts +53 -0
  83. package/dist/rag-evaluator.d.ts.map +1 -0
  84. package/dist/rag-evaluator.js +217 -0
  85. package/dist/rag-evaluator.js.map +1 -0
  86. package/dist/repo-profiler.d.ts +62 -0
  87. package/dist/repo-profiler.d.ts.map +1 -0
  88. package/dist/repo-profiler.js +488 -0
  89. package/dist/repo-profiler.js.map +1 -0
  90. package/dist/reranker.d.ts +8 -0
  91. package/dist/reranker.d.ts.map +1 -0
  92. package/dist/reranker.js +250 -0
  93. package/dist/reranker.js.map +1 -0
  94. package/dist/retriever.d.ts +42 -0
  95. package/dist/retriever.d.ts.map +1 -0
  96. package/dist/retriever.js +320 -0
  97. package/dist/retriever.js.map +1 -0
  98. package/dist/semantic-edge-detector.d.ts +28 -0
  99. package/dist/semantic-edge-detector.d.ts.map +1 -0
  100. package/dist/semantic-edge-detector.js +191 -0
  101. package/dist/semantic-edge-detector.js.map +1 -0
  102. package/dist/service-mesh-inferrer.d.ts +57 -0
  103. package/dist/service-mesh-inferrer.d.ts.map +1 -0
  104. package/dist/service-mesh-inferrer.js +322 -0
  105. package/dist/service-mesh-inferrer.js.map +1 -0
  106. package/dist/structural-hasher.d.ts +57 -0
  107. package/dist/structural-hasher.d.ts.map +1 -0
  108. package/dist/structural-hasher.js +350 -0
  109. package/dist/structural-hasher.js.map +1 -0
  110. package/dist/tree-sitter-parser.d.ts +71 -0
  111. package/dist/tree-sitter-parser.d.ts.map +1 -0
  112. package/dist/tree-sitter-parser.js +633 -0
  113. package/dist/tree-sitter-parser.js.map +1 -0
  114. package/dist/types.d.ts +179 -0
  115. package/dist/types.d.ts.map +1 -0
  116. package/dist/types.js +2 -0
  117. package/dist/types.js.map +1 -0
  118. package/dist/vector-store.d.ts +56 -0
  119. package/dist/vector-store.d.ts.map +1 -0
  120. package/dist/vector-store.js +299 -0
  121. package/dist/vector-store.js.map +1 -0
  122. package/dist/workspace-detector.d.ts +11 -0
  123. package/dist/workspace-detector.d.ts.map +1 -0
  124. package/dist/workspace-detector.js +587 -0
  125. package/dist/workspace-detector.js.map +1 -0
  126. package/package.json +41 -0
@@ -0,0 +1,28 @@
1
+ /**
2
+ * LLM-powered semantic edge detection.
3
+ *
4
+ * Finds structural relationships invisible to AST analysis:
5
+ * - Dependency injection bindings
6
+ * - Event emitter/listener wiring
7
+ * - Config-driven routing (decorators → handlers)
8
+ * - Dynamic dispatch (factory/registry patterns)
9
+ *
10
+ * Runs AFTER the AST graph is built, targeting files with orphan entities
11
+ * or known DI/event patterns. Results merge as INFERRED edges.
12
+ */
13
+ import type { GraphifyEdge, GraphifyOutput } from '@esankhan3/anvil-knowledge-core';
14
+ export interface SemanticEdgeResult {
15
+ edges: GraphifyEdge[];
16
+ filesAnalyzed: number;
17
+ tokensUsed: number;
18
+ }
19
+ type LLMCallFn = (prompt: string) => Promise<{
20
+ content: string;
21
+ inputTokens: number;
22
+ outputTokens: number;
23
+ }>;
24
+ export declare function detectSemanticEdges(repoPath: string, graph: GraphifyOutput, callLLM: LLMCallFn, opts?: {
25
+ maxFiles?: number;
26
+ }): Promise<SemanticEdgeResult>;
27
+ export {};
28
+ //# sourceMappingURL=semantic-edge-detector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semantic-edge-detector.d.ts","sourceRoot":"","sources":["../src/semantic-edge-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EAAgB,YAAY,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAMlG,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,KAAK,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AA6F7G,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,SAAS,EAClB,IAAI,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3B,OAAO,CAAC,kBAAkB,CAAC,CA+F7B"}
@@ -0,0 +1,191 @@
1
+ /**
2
+ * LLM-powered semantic edge detection.
3
+ *
4
+ * Finds structural relationships invisible to AST analysis:
5
+ * - Dependency injection bindings
6
+ * - Event emitter/listener wiring
7
+ * - Config-driven routing (decorators → handlers)
8
+ * - Dynamic dispatch (factory/registry patterns)
9
+ *
10
+ * Runs AFTER the AST graph is built, targeting files with orphan entities
11
+ * or known DI/event patterns. Results merge as INFERRED edges.
12
+ */
13
+ import { readFileSync } from 'node:fs';
14
+ import { join } from 'node:path';
15
+ // ---------------------------------------------------------------------------
16
+ // Pattern detection for candidate files
17
+ // ---------------------------------------------------------------------------
18
+ const DI_EVENT_PATTERNS = [
19
+ // DI patterns
20
+ /\@Injectable|\@Inject|\@Autowired/,
21
+ /container\.(?:register|bind|singleton|resolve)/,
22
+ /\$this->app->(?:bind|singleton|make)/,
23
+ /providers:\s*\[/,
24
+ // Event patterns
25
+ /\.on\s*\(|\.emit\s*\(|\.addEventListener/,
26
+ /EventEmitter|@Subscribe|@Listener|@EventHandler/,
27
+ /event\s*\(\s*['"`]/,
28
+ // Routing patterns
29
+ /\@Controller|\@Get|\@Post|\@Put|\@Delete|\@RequestMapping/,
30
+ /app\.(?:get|post|put|delete|use)\s*\(/,
31
+ /router\.(?:get|post|put|delete)\s*\(/,
32
+ // Factory/Registry patterns
33
+ /\.register\s*\(|\.factory\s*\(/,
34
+ /switch\s*\([^)]*type[^)]*\)/i,
35
+ ];
36
+ function fileMatchesDIPatterns(content) {
37
+ return DI_EVENT_PATTERNS.some(p => p.test(content));
38
+ }
39
+ // ---------------------------------------------------------------------------
40
+ // Find candidate files for semantic analysis
41
+ // ---------------------------------------------------------------------------
42
+ function findOrphanEntityFiles(graph) {
43
+ // Build outgoing edge map (excluding 'contains')
44
+ const outgoing = new Map();
45
+ for (const edge of graph.links) {
46
+ if (edge.type === 'contains')
47
+ continue;
48
+ outgoing.set(edge.source, (outgoing.get(edge.source) ?? 0) + 1);
49
+ }
50
+ // Find files that have entities with 0 outgoing non-contains edges
51
+ const orphanFiles = new Set();
52
+ for (const node of graph.nodes) {
53
+ if (node.type === 'module' || node.type === 'package')
54
+ continue;
55
+ if ((outgoing.get(node.id) ?? 0) === 0 && node.file) {
56
+ orphanFiles.add(node.file);
57
+ }
58
+ }
59
+ return orphanFiles;
60
+ }
61
+ // ---------------------------------------------------------------------------
62
+ // Prompt template
63
+ // ---------------------------------------------------------------------------
64
+ const SEMANTIC_EDGE_PROMPT = `You are analyzing source code to find structural relationships that static AST analysis missed.
65
+
66
+ Given code files and the list of known entities, identify relationships of these types ONLY:
67
+ 1. **di-inject**: A class receives another class via constructor injection, decorator, or container registration
68
+ 2. **event-wire**: An entity emits/publishes an event that another entity subscribes to/handles
69
+ 3. **config-route**: A config file or decorator maps a path/key to a handler function
70
+ 4. **dynamic-dispatch**: A factory/registry pattern where a string key maps to a class/function
71
+
72
+ Respond with ONLY valid JSON (no markdown, no explanation):
73
+ {
74
+ "edges": [
75
+ {
76
+ "source": "file/path.ext::EntityName",
77
+ "target": "file/path.ext::EntityName",
78
+ "type": "di-inject",
79
+ "evidence": "brief explanation",
80
+ "confidence": 0.8
81
+ }
82
+ ]
83
+ }
84
+
85
+ Rules:
86
+ - ONLY report edges between entities in the Known Entities list below
87
+ - ONLY report edges with confidence >= 0.7
88
+ - Do NOT report edges detectable by import analysis or direct function calls
89
+ - If no relationships found, return {"edges": []}
90
+
91
+ ## Known Entities
92
+ {ENTITY_LIST}
93
+
94
+ ## Code Files
95
+ {FILE_CONTENTS}`;
96
+ // ---------------------------------------------------------------------------
97
+ // Main detection function
98
+ // ---------------------------------------------------------------------------
99
+ export async function detectSemanticEdges(repoPath, graph, callLLM, opts) {
100
+ const maxFiles = opts?.maxFiles ?? 30;
101
+ const allEdges = [];
102
+ let totalTokens = 0;
103
+ // 1. Find candidate files
104
+ const orphanFiles = findOrphanEntityFiles(graph);
105
+ const patternFiles = new Set();
106
+ for (const node of graph.nodes) {
107
+ if (node.type !== 'module' || !node.file)
108
+ continue;
109
+ try {
110
+ const content = readFileSync(join(repoPath, node.file), 'utf-8');
111
+ if (fileMatchesDIPatterns(content)) {
112
+ patternFiles.add(node.file);
113
+ }
114
+ }
115
+ catch { /* skip unreadable */ }
116
+ }
117
+ const candidateFiles = [...new Set([...orphanFiles, ...patternFiles])].slice(0, maxFiles);
118
+ if (candidateFiles.length === 0)
119
+ return { edges: [], filesAnalyzed: 0, tokensUsed: 0 };
120
+ // 2. Build entity list (compact)
121
+ const nodeSet = new Set(graph.nodes.map(n => n.id));
122
+ const entityList = graph.nodes
123
+ .filter(n => n.type !== 'module' && n.type !== 'package')
124
+ .map(n => `${n.id} (${n.type})`)
125
+ .join('\n');
126
+ // 3. Batch files (~4000 chars per batch)
127
+ const batches = [];
128
+ let currentBatch = [];
129
+ let currentSize = 0;
130
+ for (const relPath of candidateFiles) {
131
+ try {
132
+ const content = readFileSync(join(repoPath, relPath), 'utf-8');
133
+ const trimmed = content.slice(0, 3000); // limit per file
134
+ if (currentSize + trimmed.length > 12000) {
135
+ if (currentBatch.length > 0)
136
+ batches.push(currentBatch);
137
+ currentBatch = [];
138
+ currentSize = 0;
139
+ }
140
+ currentBatch.push({ relPath, content: trimmed });
141
+ currentSize += trimmed.length;
142
+ }
143
+ catch { /* skip */ }
144
+ }
145
+ if (currentBatch.length > 0)
146
+ batches.push(currentBatch);
147
+ // 4. Run LLM on each batch
148
+ for (const batch of batches) {
149
+ const fileContents = batch
150
+ .map(f => `### ${f.relPath}\n\`\`\`\n${f.content}\n\`\`\``)
151
+ .join('\n\n');
152
+ const prompt = SEMANTIC_EDGE_PROMPT
153
+ .replace('{ENTITY_LIST}', entityList.slice(0, 5000))
154
+ .replace('{FILE_CONTENTS}', fileContents);
155
+ try {
156
+ const result = await callLLM(prompt);
157
+ totalTokens += result.inputTokens + result.outputTokens;
158
+ // Parse response — handle markdown-wrapped JSON
159
+ let jsonStr = result.content.trim();
160
+ const jsonMatch = jsonStr.match(/```(?:json)?\s*([\s\S]*?)```/);
161
+ if (jsonMatch)
162
+ jsonStr = jsonMatch[1].trim();
163
+ const parsed = JSON.parse(jsonStr);
164
+ if (!Array.isArray(parsed?.edges))
165
+ continue;
166
+ for (const edge of parsed.edges) {
167
+ // Validate: both source and target must exist in the graph
168
+ if (nodeSet.has(edge.source) && nodeSet.has(edge.target) && edge.source !== edge.target) {
169
+ const confidence = typeof edge.confidence === 'number' ? Math.min(edge.confidence, 0.95) : 0.75;
170
+ if (confidence >= 0.7) {
171
+ allEdges.push({
172
+ source: edge.source,
173
+ target: edge.target,
174
+ type: edge.type || 'semantic',
175
+ confidence,
176
+ });
177
+ }
178
+ }
179
+ }
180
+ }
181
+ catch {
182
+ // LLM call or parse failure — skip batch, don't crash pipeline
183
+ }
184
+ }
185
+ return {
186
+ edges: allEdges,
187
+ filesAnalyzed: candidateFiles.length,
188
+ tokensUsed: totalTokens,
189
+ };
190
+ }
191
+ //# sourceMappingURL=semantic-edge-detector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semantic-edge-detector.js","sourceRoot":"","sources":["../src/semantic-edge-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAY,MAAM,WAAW,CAAC;AAe3C,8EAA8E;AAC9E,wCAAwC;AACxC,8EAA8E;AAE9E,MAAM,iBAAiB,GAAG;IACxB,cAAc;IACd,mCAAmC;IACnC,gDAAgD;IAChD,sCAAsC;IACtC,iBAAiB;IACjB,iBAAiB;IACjB,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G,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;oBACxF,MAAM,UAAU,GAAG,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;oBAChG,IAAI,UAAU,IAAI,GAAG,EAAE,CAAC;wBACtB,QAAQ,CAAC,IAAI,CAAC;4BACZ,MAAM,EAAE,IAAI,CAAC,MAAM;4BACnB,MAAM,EAAE,IAAI,CAAC,MAAM;4BACnB,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,UAAU;4BAC7B,UAAU;yBACX,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,+DAA+D;QACjE,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE,QAAQ;QACf,aAAa,EAAE,cAAc,CAAC,MAAM;QACpC,UAAU,EAAE,WAAW;KACxB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * WS-2: Service Mesh Inference
3
+ *
4
+ * After all repos are profiled (WS-1 produces RepoProfile objects), this module
5
+ * infers the service mesh — how services connect to each other. It replaces the
6
+ * manual `connects:` section in project.yaml.
7
+ *
8
+ * Phase A: Deterministic bottom-up matching of exposed/consumed endpoints.
9
+ * Phase B: LLM gap-filling for orphan repos with no detected connections.
10
+ */
11
+ import type { RepoProfile, CrossRepoEdge } from '@esankhan3/anvil-knowledge-core';
12
+ /**
13
+ * Normalize a topic, path, or identifier for fuzzy matching.
14
+ * - Lowercase
15
+ * - Replace dots, dashes, underscores with a common separator
16
+ * - Strip leading/trailing slashes
17
+ * - Strip version prefixes like /api/v1/ or /api/v2/
18
+ */
19
+ export declare function normalizeIdentifier(id: string): string;
20
+ /**
21
+ * Return a 0-1 similarity score between two identifiers.
22
+ * - Exact match after normalization -> 1.0
23
+ * - One is a substring of the other -> 0.8
24
+ * - Jaccard similarity on path segments -> 0-0.7
25
+ */
26
+ export declare function identifierSimilarity(a: string, b: string): number;
27
+ /**
28
+ * Phase A: Bottom-up deterministic matching of endpoints across repos.
29
+ * Matches `exposes` from one repo with `consumes` from another using
30
+ * type-specific rules and fuzzy identifier comparison.
31
+ */
32
+ export declare function matchEndpoints(profiles: RepoProfile[]): CrossRepoEdge[];
33
+ /**
34
+ * Phase B: Use an LLM to infer connections for orphan repos (repos with no
35
+ * edges after deterministic matching). Batches orphans by domain proximity.
36
+ */
37
+ export declare function inferOrphanConnections(profiles: RepoProfile[], existingEdges: CrossRepoEdge[], opts?: {
38
+ model?: string;
39
+ provider?: 'claude' | 'gemini';
40
+ }): Promise<CrossRepoEdge[]>;
41
+ /**
42
+ * Infer the service mesh from a set of repo profiles.
43
+ *
44
+ * 1. Phase A: Deterministic endpoint matching (no LLM)
45
+ * 2. Identify orphan repos (no connections)
46
+ * 3. Phase B: LLM gap-filling for orphans (optional)
47
+ * 4. Merge and deduplicate edges
48
+ *
49
+ * @returns All inferred CrossRepoEdge connections
50
+ */
51
+ export declare function inferServiceMesh(profiles: RepoProfile[], opts?: {
52
+ model?: string;
53
+ provider?: 'claude' | 'gemini';
54
+ onProgress?: (msg: string) => void;
55
+ skipLlm?: boolean;
56
+ }): Promise<CrossRepoEdge[]>;
57
+ //# sourceMappingURL=service-mesh-inferrer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-mesh-inferrer.d.ts","sourceRoot":"","sources":["../src/service-mesh-inferrer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAmB,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAQnG;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAkBtD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAuBjE;AAoCD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,aAAa,EAAE,CAqDvE;AA0FD;;;GAGG;AACH,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,WAAW,EAAE,EACvB,aAAa,EAAE,aAAa,EAAE,EAC9B,IAAI,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;CAAE,GACxD,OAAO,CAAC,aAAa,EAAE,CAAC,CA2D1B;AAMD;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,WAAW,EAAE,EACvB,IAAI,CAAC,EAAE;IACL,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC/B,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GACA,OAAO,CAAC,aAAa,EAAE,CAAC,CA0C1B"}
@@ -0,0 +1,322 @@
1
+ /**
2
+ * WS-2: Service Mesh Inference
3
+ *
4
+ * After all repos are profiled (WS-1 produces RepoProfile objects), this module
5
+ * infers the service mesh — how services connect to each other. It replaces the
6
+ * manual `connects:` section in project.yaml.
7
+ *
8
+ * Phase A: Deterministic bottom-up matching of exposed/consumed endpoints.
9
+ * Phase B: LLM gap-filling for orphan repos with no detected connections.
10
+ */
11
+ import { runLLM } from './claude-runner.js';
12
+ // ---------------------------------------------------------------------------
13
+ // Helpers
14
+ // ---------------------------------------------------------------------------
15
+ const SEPARATOR = '/';
16
+ /**
17
+ * Normalize a topic, path, or identifier for fuzzy matching.
18
+ * - Lowercase
19
+ * - Replace dots, dashes, underscores with a common separator
20
+ * - Strip leading/trailing slashes
21
+ * - Strip version prefixes like /api/v1/ or /api/v2/
22
+ */
23
+ export function normalizeIdentifier(id) {
24
+ let normalized = id.toLowerCase();
25
+ // Replace common separators with a single canonical separator
26
+ normalized = normalized.replace(/[.\-_]+/g, SEPARATOR);
27
+ // Strip leading/trailing slashes
28
+ normalized = normalized.replace(/^\/+|\/+$/g, '');
29
+ // Strip version prefixes: api/v1/, api/v2/, v1/, etc.
30
+ normalized = normalized.replace(/^(?:api\/)?v\d+\//i, '');
31
+ // Normalize path params: :id, {id}, <id> -> :param
32
+ normalized = normalized.replace(/:[a-zA-Z_]+/g, ':param');
33
+ normalized = normalized.replace(/\{[a-zA-Z_]+\}/g, ':param');
34
+ normalized = normalized.replace(/<[a-zA-Z_]+>/g, ':param');
35
+ return normalized;
36
+ }
37
+ /**
38
+ * Return a 0-1 similarity score between two identifiers.
39
+ * - Exact match after normalization -> 1.0
40
+ * - One is a substring of the other -> 0.8
41
+ * - Jaccard similarity on path segments -> 0-0.7
42
+ */
43
+ export function identifierSimilarity(a, b) {
44
+ const na = normalizeIdentifier(a);
45
+ const nb = normalizeIdentifier(b);
46
+ // Exact match
47
+ if (na === nb)
48
+ return 1.0;
49
+ // Substring match (one contains the other)
50
+ if (na.includes(nb) || nb.includes(na))
51
+ return 0.8;
52
+ // Jaccard similarity on path segments
53
+ const segsA = new Set(na.split(SEPARATOR).filter(Boolean));
54
+ const segsB = new Set(nb.split(SEPARATOR).filter(Boolean));
55
+ if (segsA.size === 0 || segsB.size === 0)
56
+ return 0;
57
+ let intersection = 0;
58
+ for (const seg of segsA) {
59
+ if (segsB.has(seg))
60
+ intersection++;
61
+ }
62
+ const union = new Set([...segsA, ...segsB]).size;
63
+ return Math.min(0.7, intersection / union);
64
+ }
65
+ const MATCH_RULES = [
66
+ // Kafka: producer -> consumer on same topic
67
+ { producerType: 'kafka-producer', consumerType: 'kafka-consumer', edgeType: 'kafka', baseConfidence: 0.95, threshold: 0.8 },
68
+ // HTTP: exposed path -> consumed path
69
+ { producerType: 'http', consumerType: 'http', edgeType: 'http', baseConfidence: 0.85, threshold: 0.6 },
70
+ // gRPC: exposed service -> consumed service
71
+ { producerType: 'grpc', consumerType: 'grpc', edgeType: 'grpc', baseConfidence: 0.95, threshold: 0.8 },
72
+ // Database: shared table references
73
+ { producerType: 'database', consumerType: 'database', edgeType: 'database', baseConfidence: 0.8, threshold: 0.8 },
74
+ // Redis: shared key patterns
75
+ { producerType: 'redis', consumerType: 'redis', edgeType: 'redis', baseConfidence: 0.75, threshold: 0.7 },
76
+ // S3: shared bucket identifiers
77
+ { producerType: 's3', consumerType: 's3', edgeType: 's3', baseConfidence: 0.8, threshold: 0.8 },
78
+ ];
79
+ /**
80
+ * Phase A: Bottom-up deterministic matching of endpoints across repos.
81
+ * Matches `exposes` from one repo with `consumes` from another using
82
+ * type-specific rules and fuzzy identifier comparison.
83
+ */
84
+ export function matchEndpoints(profiles) {
85
+ const edges = [];
86
+ const seen = new Set();
87
+ for (const rule of MATCH_RULES) {
88
+ // Database/Redis/S3: bidirectional — both sides "consume" the same resource.
89
+ // Use exposes-to-exposes matching as well as exposes-to-consumes.
90
+ const isBidirectional = ['database', 'redis', 's3'].includes(rule.producerType);
91
+ for (let i = 0; i < profiles.length; i++) {
92
+ for (let j = 0; j < profiles.length; j++) {
93
+ if (i === j)
94
+ continue;
95
+ const repoA = profiles[i];
96
+ const repoB = profiles[j];
97
+ // For bidirectional resources, only match i < j to avoid duplicates
98
+ if (isBidirectional && i > j)
99
+ continue;
100
+ // Collect endpoints by matching type
101
+ const exposedA = repoA.exposes.filter(e => e.type === rule.producerType);
102
+ const consumedB = isBidirectional
103
+ // For shared resources, also look in exposes of the other repo
104
+ ? [...repoB.consumes.filter(e => e.type === rule.consumerType), ...repoB.exposes.filter(e => e.type === rule.producerType)]
105
+ : repoB.consumes.filter(e => e.type === rule.consumerType);
106
+ for (const exposed of exposedA) {
107
+ for (const consumed of consumedB) {
108
+ const similarity = identifierSimilarity(exposed.identifier, consumed.identifier);
109
+ if (similarity < rule.threshold)
110
+ continue;
111
+ const confidence = rule.baseConfidence * similarity;
112
+ const edgeKey = `${repoA.name}:${repoB.name}:${rule.edgeType}:${normalizeIdentifier(exposed.identifier)}`;
113
+ if (seen.has(edgeKey))
114
+ continue;
115
+ seen.add(edgeKey);
116
+ edges.push({
117
+ sourceRepo: repoA.name,
118
+ sourceNode: exposed.identifier,
119
+ targetRepo: repoB.name,
120
+ targetNode: consumed.identifier,
121
+ edgeType: rule.edgeType,
122
+ evidence: `${repoA.name} exposes ${exposed.type}:${exposed.identifier} matched with ${repoB.name} ${isBidirectional ? 'exposes' : 'consumes'} ${consumed.type}:${consumed.identifier} (similarity: ${similarity.toFixed(2)})`,
123
+ confidence: Math.round(confidence * 100) / 100,
124
+ });
125
+ }
126
+ }
127
+ }
128
+ }
129
+ }
130
+ return edges;
131
+ }
132
+ // ---------------------------------------------------------------------------
133
+ // Phase B: LLM gap-filling for orphan repos
134
+ // ---------------------------------------------------------------------------
135
+ const SYSTEM_PROMPT = `You are a software architect analyzing an organization's service architecture.
136
+ You will be given profiles of repositories that have NO detected connections to other repos.
137
+ Based on their roles, technologies, domains, and descriptions, identify likely connections.
138
+
139
+ Consider:
140
+ - Shared databases (same DB tech + similar domain = likely shared DB)
141
+ - Config-driven routing (gateway -> backend services)
142
+ - Cron/scheduler -> worker relationships
143
+ - Shared infrastructure services (logging, auth, notifications)
144
+ - Domain proximity (repos in same domain likely interact)
145
+
146
+ Respond with ONLY valid JSON array:
147
+ [
148
+ {
149
+ "source": "repo-name-a",
150
+ "target": "repo-name-b",
151
+ "type": "http|kafka|grpc|database|redis|s3|other",
152
+ "evidence": "Both repos are in email-delivery domain, A is gateway, B is worker",
153
+ "confidence": 0.7
154
+ }
155
+ ]
156
+
157
+ Rules:
158
+ - Only suggest connections with confidence >= 0.6
159
+ - Be conservative — better to miss a connection than hallucinate one
160
+ - Use the repo descriptions to understand actual purpose, not just names`;
161
+ /**
162
+ * Parse a JSON array from LLM output, handling markdown fences and partial JSON.
163
+ */
164
+ function parseJsonArray(raw) {
165
+ // Strip markdown code fences if present
166
+ let cleaned = raw.trim();
167
+ cleaned = cleaned.replace(/^```(?:json)?\s*\n?/i, '').replace(/\n?\s*```$/i, '');
168
+ cleaned = cleaned.trim();
169
+ // Try direct parse
170
+ try {
171
+ const parsed = JSON.parse(cleaned);
172
+ if (Array.isArray(parsed))
173
+ return parsed;
174
+ return [];
175
+ }
176
+ catch {
177
+ // Attempt to extract first JSON array from the text
178
+ const arrayMatch = cleaned.match(/\[[\s\S]*\]/);
179
+ if (arrayMatch) {
180
+ try {
181
+ return JSON.parse(arrayMatch[0]);
182
+ }
183
+ catch {
184
+ return [];
185
+ }
186
+ }
187
+ return [];
188
+ }
189
+ }
190
+ /**
191
+ * Map a raw type string from the LLM to a valid edgeType, falling back to 'llm-inferred'.
192
+ */
193
+ function toEdgeType(raw) {
194
+ const valid = [
195
+ 'http', 'kafka', 'grpc', 'database', 'redis', 's3',
196
+ ];
197
+ const lower = raw.toLowerCase();
198
+ const match = valid.find(v => v === lower);
199
+ return match ?? 'llm-inferred';
200
+ }
201
+ /**
202
+ * Phase B: Use an LLM to infer connections for orphan repos (repos with no
203
+ * edges after deterministic matching). Batches orphans by domain proximity.
204
+ */
205
+ export async function inferOrphanConnections(profiles, existingEdges, opts) {
206
+ // Identify repos that appear in no edges
207
+ const connectedRepos = new Set();
208
+ for (const edge of existingEdges) {
209
+ connectedRepos.add(edge.sourceRepo);
210
+ connectedRepos.add(edge.targetRepo);
211
+ }
212
+ const orphans = profiles.filter(p => !connectedRepos.has(p.name));
213
+ if (orphans.length === 0)
214
+ return [];
215
+ // Build slim profiles: orphans + their domain neighbors for context
216
+ const orphanDomains = new Set(orphans.map(p => p.domain));
217
+ const contextProfiles = profiles.filter(p => orphanDomains.has(p.domain) || !connectedRepos.has(p.name));
218
+ const slimProfiles = contextProfiles.map(p => ({
219
+ name: p.name,
220
+ role: p.role,
221
+ domain: p.domain,
222
+ description: p.description,
223
+ technologies: p.technologies,
224
+ }));
225
+ const orphanNames = orphans.map(p => p.name);
226
+ const userPrompt = `The following repos have NO detected connections to any other repo:\n${JSON.stringify(orphanNames, null, 2)}\n\nHere are profiles of those repos and their domain neighbors:\n${JSON.stringify(slimProfiles, null, 2)}\n\nIdentify likely connections between these orphan repos and any other repo listed above.`;
227
+ const model = opts?.model ?? 'claude-sonnet-4-6';
228
+ const result = await runLLM(userPrompt, SYSTEM_PROMPT, { model, provider: opts?.provider, timeoutMs: 600_000 });
229
+ const inferred = parseJsonArray(result.result);
230
+ // Validate repo names exist and confidence threshold
231
+ const profileNames = new Set(profiles.map(p => p.name));
232
+ return inferred
233
+ .filter(e => e.confidence >= 0.6 &&
234
+ profileNames.has(e.source) &&
235
+ profileNames.has(e.target) &&
236
+ e.source !== e.target)
237
+ .map(e => ({
238
+ sourceRepo: e.source,
239
+ sourceNode: 'inferred',
240
+ targetRepo: e.target,
241
+ targetNode: 'inferred',
242
+ edgeType: toEdgeType(e.type),
243
+ evidence: `[LLM-inferred] ${e.evidence}`,
244
+ confidence: Math.round(e.confidence * 100) / 100,
245
+ }));
246
+ }
247
+ // ---------------------------------------------------------------------------
248
+ // Main entry point
249
+ // ---------------------------------------------------------------------------
250
+ /**
251
+ * Infer the service mesh from a set of repo profiles.
252
+ *
253
+ * 1. Phase A: Deterministic endpoint matching (no LLM)
254
+ * 2. Identify orphan repos (no connections)
255
+ * 3. Phase B: LLM gap-filling for orphans (optional)
256
+ * 4. Merge and deduplicate edges
257
+ *
258
+ * @returns All inferred CrossRepoEdge connections
259
+ */
260
+ export async function inferServiceMesh(profiles, opts) {
261
+ const progress = opts?.onProgress ?? (() => { });
262
+ // Phase A: Deterministic matching
263
+ progress(`Matching endpoints across ${profiles.length} repos...`);
264
+ const deterministicEdges = matchEndpoints(profiles);
265
+ progress(`Phase A: Found ${deterministicEdges.length} deterministic edges.`);
266
+ // Identify orphans
267
+ const connectedRepos = new Set();
268
+ for (const edge of deterministicEdges) {
269
+ connectedRepos.add(edge.sourceRepo);
270
+ connectedRepos.add(edge.targetRepo);
271
+ }
272
+ const orphanCount = profiles.filter(p => !connectedRepos.has(p.name)).length;
273
+ // Phase B: LLM gap-filling
274
+ let llmEdges = [];
275
+ if (orphanCount > 0 && opts?.skipLlm !== true) {
276
+ progress(`Phase B: ${orphanCount} orphan repo(s) detected. Inferring connections via LLM...`);
277
+ try {
278
+ llmEdges = await inferOrphanConnections(profiles, deterministicEdges, {
279
+ model: opts?.model,
280
+ provider: opts?.provider,
281
+ });
282
+ progress(`Phase B: Inferred ${llmEdges.length} additional edges.`);
283
+ }
284
+ catch (err) {
285
+ const message = err instanceof Error ? err.message : String(err);
286
+ progress(`Phase B: LLM inference failed — ${message}. Continuing with deterministic edges only.`);
287
+ }
288
+ }
289
+ else if (orphanCount === 0) {
290
+ progress('Phase B: No orphan repos — skipping LLM inference.');
291
+ }
292
+ else {
293
+ progress('Phase B: Skipped (skipLlm=true).');
294
+ }
295
+ // Merge and deduplicate
296
+ const allEdges = [...deterministicEdges, ...llmEdges];
297
+ const deduped = deduplicateEdges(allEdges);
298
+ progress(`Service mesh: ${deduped.length} total edges (${deterministicEdges.length} deterministic, ${llmEdges.length} LLM-inferred).`);
299
+ return deduped;
300
+ }
301
+ /**
302
+ * Deduplicate edges by (sourceRepo, targetRepo, edgeType, normalizedIdentifier).
303
+ * When duplicates exist, keep the one with higher confidence.
304
+ */
305
+ function deduplicateEdges(edges) {
306
+ const map = new Map();
307
+ for (const edge of edges) {
308
+ const key = [
309
+ edge.sourceRepo,
310
+ edge.targetRepo,
311
+ edge.edgeType,
312
+ normalizeIdentifier(edge.sourceNode),
313
+ normalizeIdentifier(edge.targetNode),
314
+ ].join('::');
315
+ const existing = map.get(key);
316
+ if (!existing || edge.confidence > existing.confidence) {
317
+ map.set(key, edge);
318
+ }
319
+ }
320
+ return Array.from(map.values());
321
+ }
322
+ //# sourceMappingURL=service-mesh-inferrer.js.map
@@ -0,0 +1 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