@duytransipher/gitnexus 1.4.6-sipher.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 (224) hide show
  1. package/LICENSE +73 -0
  2. package/README.md +261 -0
  3. package/dist/cli/ai-context.d.ts +23 -0
  4. package/dist/cli/ai-context.js +265 -0
  5. package/dist/cli/analyze.d.ts +12 -0
  6. package/dist/cli/analyze.js +345 -0
  7. package/dist/cli/augment.d.ts +13 -0
  8. package/dist/cli/augment.js +33 -0
  9. package/dist/cli/clean.d.ts +10 -0
  10. package/dist/cli/clean.js +60 -0
  11. package/dist/cli/eval-server.d.ts +37 -0
  12. package/dist/cli/eval-server.js +389 -0
  13. package/dist/cli/index.d.ts +2 -0
  14. package/dist/cli/index.js +137 -0
  15. package/dist/cli/lazy-action.d.ts +6 -0
  16. package/dist/cli/lazy-action.js +18 -0
  17. package/dist/cli/list.d.ts +6 -0
  18. package/dist/cli/list.js +30 -0
  19. package/dist/cli/mcp.d.ts +8 -0
  20. package/dist/cli/mcp.js +36 -0
  21. package/dist/cli/serve.d.ts +4 -0
  22. package/dist/cli/serve.js +6 -0
  23. package/dist/cli/setup.d.ts +8 -0
  24. package/dist/cli/setup.js +367 -0
  25. package/dist/cli/sipher-patched.d.ts +2 -0
  26. package/dist/cli/sipher-patched.js +77 -0
  27. package/dist/cli/skill-gen.d.ts +26 -0
  28. package/dist/cli/skill-gen.js +549 -0
  29. package/dist/cli/status.d.ts +6 -0
  30. package/dist/cli/status.js +36 -0
  31. package/dist/cli/tool.d.ts +60 -0
  32. package/dist/cli/tool.js +180 -0
  33. package/dist/cli/wiki.d.ts +15 -0
  34. package/dist/cli/wiki.js +365 -0
  35. package/dist/config/ignore-service.d.ts +26 -0
  36. package/dist/config/ignore-service.js +284 -0
  37. package/dist/config/supported-languages.d.ts +15 -0
  38. package/dist/config/supported-languages.js +16 -0
  39. package/dist/core/augmentation/engine.d.ts +26 -0
  40. package/dist/core/augmentation/engine.js +240 -0
  41. package/dist/core/embeddings/embedder.d.ts +60 -0
  42. package/dist/core/embeddings/embedder.js +251 -0
  43. package/dist/core/embeddings/embedding-pipeline.d.ts +51 -0
  44. package/dist/core/embeddings/embedding-pipeline.js +356 -0
  45. package/dist/core/embeddings/index.d.ts +9 -0
  46. package/dist/core/embeddings/index.js +9 -0
  47. package/dist/core/embeddings/text-generator.d.ts +24 -0
  48. package/dist/core/embeddings/text-generator.js +182 -0
  49. package/dist/core/embeddings/types.d.ts +87 -0
  50. package/dist/core/embeddings/types.js +32 -0
  51. package/dist/core/graph/graph.d.ts +2 -0
  52. package/dist/core/graph/graph.js +66 -0
  53. package/dist/core/graph/types.d.ts +66 -0
  54. package/dist/core/graph/types.js +1 -0
  55. package/dist/core/ingestion/ast-cache.d.ts +11 -0
  56. package/dist/core/ingestion/ast-cache.js +35 -0
  57. package/dist/core/ingestion/call-processor.d.ts +23 -0
  58. package/dist/core/ingestion/call-processor.js +793 -0
  59. package/dist/core/ingestion/call-routing.d.ts +68 -0
  60. package/dist/core/ingestion/call-routing.js +129 -0
  61. package/dist/core/ingestion/cluster-enricher.d.ts +38 -0
  62. package/dist/core/ingestion/cluster-enricher.js +170 -0
  63. package/dist/core/ingestion/community-processor.d.ts +39 -0
  64. package/dist/core/ingestion/community-processor.js +312 -0
  65. package/dist/core/ingestion/constants.d.ts +16 -0
  66. package/dist/core/ingestion/constants.js +16 -0
  67. package/dist/core/ingestion/entry-point-scoring.d.ts +40 -0
  68. package/dist/core/ingestion/entry-point-scoring.js +353 -0
  69. package/dist/core/ingestion/export-detection.d.ts +18 -0
  70. package/dist/core/ingestion/export-detection.js +231 -0
  71. package/dist/core/ingestion/filesystem-walker.d.ts +28 -0
  72. package/dist/core/ingestion/filesystem-walker.js +81 -0
  73. package/dist/core/ingestion/framework-detection.d.ts +54 -0
  74. package/dist/core/ingestion/framework-detection.js +411 -0
  75. package/dist/core/ingestion/heritage-processor.d.ts +28 -0
  76. package/dist/core/ingestion/heritage-processor.js +251 -0
  77. package/dist/core/ingestion/import-processor.d.ts +34 -0
  78. package/dist/core/ingestion/import-processor.js +398 -0
  79. package/dist/core/ingestion/language-config.d.ts +46 -0
  80. package/dist/core/ingestion/language-config.js +167 -0
  81. package/dist/core/ingestion/mro-processor.d.ts +45 -0
  82. package/dist/core/ingestion/mro-processor.js +369 -0
  83. package/dist/core/ingestion/named-binding-extraction.d.ts +61 -0
  84. package/dist/core/ingestion/named-binding-extraction.js +363 -0
  85. package/dist/core/ingestion/parsing-processor.d.ts +19 -0
  86. package/dist/core/ingestion/parsing-processor.js +315 -0
  87. package/dist/core/ingestion/pipeline.d.ts +6 -0
  88. package/dist/core/ingestion/pipeline.js +401 -0
  89. package/dist/core/ingestion/process-processor.d.ts +51 -0
  90. package/dist/core/ingestion/process-processor.js +315 -0
  91. package/dist/core/ingestion/resolution-context.d.ts +53 -0
  92. package/dist/core/ingestion/resolution-context.js +132 -0
  93. package/dist/core/ingestion/resolvers/csharp.d.ts +22 -0
  94. package/dist/core/ingestion/resolvers/csharp.js +109 -0
  95. package/dist/core/ingestion/resolvers/go.d.ts +19 -0
  96. package/dist/core/ingestion/resolvers/go.js +42 -0
  97. package/dist/core/ingestion/resolvers/index.d.ts +18 -0
  98. package/dist/core/ingestion/resolvers/index.js +13 -0
  99. package/dist/core/ingestion/resolvers/jvm.d.ts +23 -0
  100. package/dist/core/ingestion/resolvers/jvm.js +87 -0
  101. package/dist/core/ingestion/resolvers/php.d.ts +15 -0
  102. package/dist/core/ingestion/resolvers/php.js +35 -0
  103. package/dist/core/ingestion/resolvers/python.d.ts +19 -0
  104. package/dist/core/ingestion/resolvers/python.js +52 -0
  105. package/dist/core/ingestion/resolvers/ruby.d.ts +12 -0
  106. package/dist/core/ingestion/resolvers/ruby.js +15 -0
  107. package/dist/core/ingestion/resolvers/rust.d.ts +15 -0
  108. package/dist/core/ingestion/resolvers/rust.js +73 -0
  109. package/dist/core/ingestion/resolvers/standard.d.ts +28 -0
  110. package/dist/core/ingestion/resolvers/standard.js +123 -0
  111. package/dist/core/ingestion/resolvers/utils.d.ts +33 -0
  112. package/dist/core/ingestion/resolvers/utils.js +122 -0
  113. package/dist/core/ingestion/structure-processor.d.ts +2 -0
  114. package/dist/core/ingestion/structure-processor.js +36 -0
  115. package/dist/core/ingestion/symbol-table.d.ts +63 -0
  116. package/dist/core/ingestion/symbol-table.js +85 -0
  117. package/dist/core/ingestion/tree-sitter-queries.d.ts +15 -0
  118. package/dist/core/ingestion/tree-sitter-queries.js +888 -0
  119. package/dist/core/ingestion/type-env.d.ts +49 -0
  120. package/dist/core/ingestion/type-env.js +613 -0
  121. package/dist/core/ingestion/type-extractors/c-cpp.d.ts +2 -0
  122. package/dist/core/ingestion/type-extractors/c-cpp.js +385 -0
  123. package/dist/core/ingestion/type-extractors/csharp.d.ts +2 -0
  124. package/dist/core/ingestion/type-extractors/csharp.js +383 -0
  125. package/dist/core/ingestion/type-extractors/go.d.ts +2 -0
  126. package/dist/core/ingestion/type-extractors/go.js +467 -0
  127. package/dist/core/ingestion/type-extractors/index.d.ts +22 -0
  128. package/dist/core/ingestion/type-extractors/index.js +31 -0
  129. package/dist/core/ingestion/type-extractors/jvm.d.ts +3 -0
  130. package/dist/core/ingestion/type-extractors/jvm.js +681 -0
  131. package/dist/core/ingestion/type-extractors/php.d.ts +2 -0
  132. package/dist/core/ingestion/type-extractors/php.js +549 -0
  133. package/dist/core/ingestion/type-extractors/python.d.ts +2 -0
  134. package/dist/core/ingestion/type-extractors/python.js +455 -0
  135. package/dist/core/ingestion/type-extractors/ruby.d.ts +2 -0
  136. package/dist/core/ingestion/type-extractors/ruby.js +389 -0
  137. package/dist/core/ingestion/type-extractors/rust.d.ts +2 -0
  138. package/dist/core/ingestion/type-extractors/rust.js +456 -0
  139. package/dist/core/ingestion/type-extractors/shared.d.ts +145 -0
  140. package/dist/core/ingestion/type-extractors/shared.js +810 -0
  141. package/dist/core/ingestion/type-extractors/swift.d.ts +2 -0
  142. package/dist/core/ingestion/type-extractors/swift.js +137 -0
  143. package/dist/core/ingestion/type-extractors/types.d.ts +127 -0
  144. package/dist/core/ingestion/type-extractors/types.js +1 -0
  145. package/dist/core/ingestion/type-extractors/typescript.d.ts +2 -0
  146. package/dist/core/ingestion/type-extractors/typescript.js +494 -0
  147. package/dist/core/ingestion/utils.d.ts +138 -0
  148. package/dist/core/ingestion/utils.js +1290 -0
  149. package/dist/core/ingestion/workers/parse-worker.d.ts +122 -0
  150. package/dist/core/ingestion/workers/parse-worker.js +1126 -0
  151. package/dist/core/ingestion/workers/worker-pool.d.ts +16 -0
  152. package/dist/core/ingestion/workers/worker-pool.js +128 -0
  153. package/dist/core/lbug/csv-generator.d.ts +33 -0
  154. package/dist/core/lbug/csv-generator.js +366 -0
  155. package/dist/core/lbug/lbug-adapter.d.ts +103 -0
  156. package/dist/core/lbug/lbug-adapter.js +769 -0
  157. package/dist/core/lbug/schema.d.ts +53 -0
  158. package/dist/core/lbug/schema.js +430 -0
  159. package/dist/core/search/bm25-index.d.ts +23 -0
  160. package/dist/core/search/bm25-index.js +96 -0
  161. package/dist/core/search/hybrid-search.d.ts +49 -0
  162. package/dist/core/search/hybrid-search.js +118 -0
  163. package/dist/core/tree-sitter/parser-loader.d.ts +5 -0
  164. package/dist/core/tree-sitter/parser-loader.js +63 -0
  165. package/dist/core/wiki/generator.d.ts +120 -0
  166. package/dist/core/wiki/generator.js +939 -0
  167. package/dist/core/wiki/graph-queries.d.ts +80 -0
  168. package/dist/core/wiki/graph-queries.js +238 -0
  169. package/dist/core/wiki/html-viewer.d.ts +10 -0
  170. package/dist/core/wiki/html-viewer.js +297 -0
  171. package/dist/core/wiki/llm-client.d.ts +43 -0
  172. package/dist/core/wiki/llm-client.js +186 -0
  173. package/dist/core/wiki/prompts.d.ts +53 -0
  174. package/dist/core/wiki/prompts.js +174 -0
  175. package/dist/lib/utils.d.ts +1 -0
  176. package/dist/lib/utils.js +3 -0
  177. package/dist/mcp/compatible-stdio-transport.d.ts +25 -0
  178. package/dist/mcp/compatible-stdio-transport.js +200 -0
  179. package/dist/mcp/core/embedder.d.ts +27 -0
  180. package/dist/mcp/core/embedder.js +108 -0
  181. package/dist/mcp/core/lbug-adapter.d.ts +57 -0
  182. package/dist/mcp/core/lbug-adapter.js +455 -0
  183. package/dist/mcp/local/local-backend.d.ts +181 -0
  184. package/dist/mcp/local/local-backend.js +1722 -0
  185. package/dist/mcp/resources.d.ts +31 -0
  186. package/dist/mcp/resources.js +411 -0
  187. package/dist/mcp/server.d.ts +23 -0
  188. package/dist/mcp/server.js +296 -0
  189. package/dist/mcp/staleness.d.ts +15 -0
  190. package/dist/mcp/staleness.js +29 -0
  191. package/dist/mcp/tools.d.ts +24 -0
  192. package/dist/mcp/tools.js +292 -0
  193. package/dist/server/api.d.ts +10 -0
  194. package/dist/server/api.js +344 -0
  195. package/dist/server/mcp-http.d.ts +13 -0
  196. package/dist/server/mcp-http.js +100 -0
  197. package/dist/storage/git.d.ts +6 -0
  198. package/dist/storage/git.js +35 -0
  199. package/dist/storage/repo-manager.d.ts +138 -0
  200. package/dist/storage/repo-manager.js +299 -0
  201. package/dist/types/pipeline.d.ts +32 -0
  202. package/dist/types/pipeline.js +18 -0
  203. package/dist/unreal/bridge.d.ts +4 -0
  204. package/dist/unreal/bridge.js +113 -0
  205. package/dist/unreal/config.d.ts +6 -0
  206. package/dist/unreal/config.js +55 -0
  207. package/dist/unreal/types.d.ts +105 -0
  208. package/dist/unreal/types.js +1 -0
  209. package/hooks/claude/gitnexus-hook.cjs +238 -0
  210. package/hooks/claude/pre-tool-use.sh +79 -0
  211. package/hooks/claude/session-start.sh +42 -0
  212. package/package.json +100 -0
  213. package/scripts/ensure-cli-executable.cjs +21 -0
  214. package/scripts/patch-tree-sitter-swift.cjs +74 -0
  215. package/scripts/setup-unreal-gitnexus.ps1 +191 -0
  216. package/skills/gitnexus-cli.md +82 -0
  217. package/skills/gitnexus-debugging.md +89 -0
  218. package/skills/gitnexus-exploring.md +78 -0
  219. package/skills/gitnexus-guide.md +64 -0
  220. package/skills/gitnexus-impact-analysis.md +97 -0
  221. package/skills/gitnexus-pr-review.md +163 -0
  222. package/skills/gitnexus-refactoring.md +121 -0
  223. package/vendor/leiden/index.cjs +355 -0
  224. package/vendor/leiden/utils.cjs +392 -0
@@ -0,0 +1,251 @@
1
+ /**
2
+ * Heritage Processor
3
+ *
4
+ * Extracts class inheritance relationships:
5
+ * - EXTENDS: Class extends another Class (TS, JS, Python, C#, C++)
6
+ * - IMPLEMENTS: Class implements an Interface (TS, C#, Java, Kotlin, PHP)
7
+ *
8
+ * Languages like C# use a single `base_list` for both class and interface parents.
9
+ * We resolve the correct edge type by checking the symbol table: if the parent is
10
+ * registered as an Interface, we emit IMPLEMENTS; otherwise EXTENDS. For unresolved
11
+ * external symbols, the fallback heuristic is language-gated:
12
+ * - C# / Java: apply the `I[A-Z]` naming convention (e.g. IDisposable → IMPLEMENTS)
13
+ * - Swift: default to IMPLEMENTS (protocol conformance is more common than class inheritance)
14
+ * - All other languages: default to EXTENDS
15
+ */
16
+ import Parser from 'tree-sitter';
17
+ import { isLanguageAvailable, loadParser, loadLanguage } from '../tree-sitter/parser-loader.js';
18
+ import { LANGUAGE_QUERIES } from './tree-sitter-queries.js';
19
+ import { generateId } from '../../lib/utils.js';
20
+ import { getLanguageFromFilename, isVerboseIngestionEnabled, yieldToEventLoop } from './utils.js';
21
+ import { SupportedLanguages } from '../../config/supported-languages.js';
22
+ import { getTreeSitterBufferSize } from './constants.js';
23
+ /** C#/Java convention: interfaces start with I followed by an uppercase letter */
24
+ const INTERFACE_NAME_RE = /^I[A-Z]/;
25
+ /**
26
+ * Determine whether a heritage.extends capture is actually an IMPLEMENTS relationship.
27
+ * Uses the symbol table first (authoritative — Tier 1); falls back to a language-gated
28
+ * heuristic for external symbols not present in the graph:
29
+ * - C# / Java: `I[A-Z]` naming convention
30
+ * - Swift: default IMPLEMENTS (protocol conformance is the norm)
31
+ * - All others: default EXTENDS
32
+ */
33
+ const resolveExtendsType = (parentName, currentFilePath, ctx, language) => {
34
+ const resolved = ctx.resolve(parentName, currentFilePath);
35
+ if (resolved && resolved.candidates.length > 0) {
36
+ const isInterface = resolved.candidates[0].type === 'Interface';
37
+ return isInterface
38
+ ? { type: 'IMPLEMENTS', idPrefix: 'Interface' }
39
+ : { type: 'EXTENDS', idPrefix: 'Class' };
40
+ }
41
+ // Unresolved symbol — fall back to language-specific heuristic
42
+ if (language === SupportedLanguages.CSharp || language === SupportedLanguages.Java) {
43
+ if (INTERFACE_NAME_RE.test(parentName)) {
44
+ return { type: 'IMPLEMENTS', idPrefix: 'Interface' };
45
+ }
46
+ }
47
+ else if (language === SupportedLanguages.Swift) {
48
+ // Protocol conformance is far more common than class inheritance in Swift
49
+ return { type: 'IMPLEMENTS', idPrefix: 'Interface' };
50
+ }
51
+ return { type: 'EXTENDS', idPrefix: 'Class' };
52
+ };
53
+ /**
54
+ * Resolve a symbol ID for heritage, with fallback to generated ID.
55
+ * Uses ctx.resolve() → pick first candidate's nodeId → generate synthetic ID.
56
+ */
57
+ const resolveHeritageId = (name, filePath, ctx, fallbackLabel, fallbackKey) => {
58
+ const resolved = ctx.resolve(name, filePath);
59
+ if (resolved && resolved.candidates.length > 0) {
60
+ // For global with multiple candidates, refuse (a wrong edge is worse than no edge)
61
+ if (resolved.tier === 'global' && resolved.candidates.length > 1) {
62
+ return generateId(fallbackLabel, fallbackKey ?? name);
63
+ }
64
+ return resolved.candidates[0].nodeId;
65
+ }
66
+ return generateId(fallbackLabel, fallbackKey ?? name);
67
+ };
68
+ export const processHeritage = async (graph, files, astCache, ctx, onProgress) => {
69
+ const parser = await loadParser();
70
+ const logSkipped = isVerboseIngestionEnabled();
71
+ const skippedByLang = logSkipped ? new Map() : null;
72
+ for (let i = 0; i < files.length; i++) {
73
+ const file = files[i];
74
+ onProgress?.(i + 1, files.length);
75
+ if (i % 20 === 0)
76
+ await yieldToEventLoop();
77
+ // 1. Check language support
78
+ const language = getLanguageFromFilename(file.path);
79
+ if (!language)
80
+ continue;
81
+ if (!isLanguageAvailable(language)) {
82
+ if (skippedByLang) {
83
+ skippedByLang.set(language, (skippedByLang.get(language) ?? 0) + 1);
84
+ }
85
+ continue;
86
+ }
87
+ const queryStr = LANGUAGE_QUERIES[language];
88
+ if (!queryStr)
89
+ continue;
90
+ // 2. Load the language
91
+ await loadLanguage(language, file.path);
92
+ // 3. Get AST
93
+ let tree = astCache.get(file.path);
94
+ if (!tree) {
95
+ // Use larger bufferSize for files > 32KB
96
+ try {
97
+ tree = parser.parse(file.content, undefined, { bufferSize: getTreeSitterBufferSize(file.content.length) });
98
+ }
99
+ catch (parseError) {
100
+ // Skip files that can't be parsed
101
+ continue;
102
+ }
103
+ // Cache re-parsed tree for potential future use
104
+ astCache.set(file.path, tree);
105
+ }
106
+ let query;
107
+ let matches;
108
+ try {
109
+ const language = parser.getLanguage();
110
+ query = new Parser.Query(language, queryStr);
111
+ matches = query.matches(tree.rootNode);
112
+ }
113
+ catch (queryError) {
114
+ console.warn(`Heritage query error for ${file.path}:`, queryError);
115
+ continue;
116
+ }
117
+ // 4. Process heritage matches
118
+ matches.forEach(match => {
119
+ const captureMap = {};
120
+ match.captures.forEach(c => {
121
+ captureMap[c.name] = c.node;
122
+ });
123
+ // EXTENDS or IMPLEMENTS: resolve via symbol table for languages where
124
+ // the tree-sitter query can't distinguish classes from interfaces (C#, Java)
125
+ if (captureMap['heritage.class'] && captureMap['heritage.extends']) {
126
+ // Go struct embedding: skip named fields (only anonymous fields are embedded)
127
+ const extendsNode = captureMap['heritage.extends'];
128
+ const fieldDecl = extendsNode.parent;
129
+ if (fieldDecl?.type === 'field_declaration' && fieldDecl.childForFieldName('name')) {
130
+ return; // Named field, not struct embedding
131
+ }
132
+ const className = captureMap['heritage.class'].text;
133
+ const parentClassName = captureMap['heritage.extends'].text;
134
+ const { type: relType, idPrefix } = resolveExtendsType(parentClassName, file.path, ctx, language);
135
+ const childId = resolveHeritageId(className, file.path, ctx, 'Class', `${file.path}:${className}`);
136
+ const parentId = resolveHeritageId(parentClassName, file.path, ctx, idPrefix);
137
+ if (childId && parentId && childId !== parentId) {
138
+ graph.addRelationship({
139
+ id: generateId(relType, `${childId}->${parentId}`),
140
+ sourceId: childId,
141
+ targetId: parentId,
142
+ type: relType,
143
+ confidence: 1.0,
144
+ reason: '',
145
+ });
146
+ }
147
+ }
148
+ // IMPLEMENTS: Class implements Interface (TypeScript only)
149
+ if (captureMap['heritage.class'] && captureMap['heritage.implements']) {
150
+ const className = captureMap['heritage.class'].text;
151
+ const interfaceName = captureMap['heritage.implements'].text;
152
+ const classId = resolveHeritageId(className, file.path, ctx, 'Class', `${file.path}:${className}`);
153
+ const interfaceId = resolveHeritageId(interfaceName, file.path, ctx, 'Interface');
154
+ if (classId && interfaceId) {
155
+ graph.addRelationship({
156
+ id: generateId('IMPLEMENTS', `${classId}->${interfaceId}`),
157
+ sourceId: classId,
158
+ targetId: interfaceId,
159
+ type: 'IMPLEMENTS',
160
+ confidence: 1.0,
161
+ reason: '',
162
+ });
163
+ }
164
+ }
165
+ // IMPLEMENTS (Rust): impl Trait for Struct
166
+ if (captureMap['heritage.trait'] && captureMap['heritage.class']) {
167
+ const structName = captureMap['heritage.class'].text;
168
+ const traitName = captureMap['heritage.trait'].text;
169
+ const structId = resolveHeritageId(structName, file.path, ctx, 'Struct', `${file.path}:${structName}`);
170
+ const traitId = resolveHeritageId(traitName, file.path, ctx, 'Trait');
171
+ if (structId && traitId) {
172
+ graph.addRelationship({
173
+ id: generateId('IMPLEMENTS', `${structId}->${traitId}`),
174
+ sourceId: structId,
175
+ targetId: traitId,
176
+ type: 'IMPLEMENTS',
177
+ confidence: 1.0,
178
+ reason: 'trait-impl',
179
+ });
180
+ }
181
+ }
182
+ });
183
+ // Tree is now owned by the LRU cache — no manual delete needed
184
+ }
185
+ if (skippedByLang && skippedByLang.size > 0) {
186
+ for (const [lang, count] of skippedByLang.entries()) {
187
+ console.warn(`[ingestion] Skipped ${count} ${lang} file(s) in heritage processing — ${lang} parser not available.`);
188
+ }
189
+ }
190
+ };
191
+ /**
192
+ * Fast path: resolve pre-extracted heritage from workers.
193
+ * No AST parsing — workers already extracted className + parentName + kind.
194
+ */
195
+ export const processHeritageFromExtracted = async (graph, extractedHeritage, ctx, onProgress) => {
196
+ const total = extractedHeritage.length;
197
+ for (let i = 0; i < extractedHeritage.length; i++) {
198
+ if (i % 500 === 0) {
199
+ onProgress?.(i, total);
200
+ await yieldToEventLoop();
201
+ }
202
+ const h = extractedHeritage[i];
203
+ if (h.kind === 'extends') {
204
+ const fileLanguage = getLanguageFromFilename(h.filePath);
205
+ if (!fileLanguage)
206
+ continue;
207
+ const { type: relType, idPrefix } = resolveExtendsType(h.parentName, h.filePath, ctx, fileLanguage);
208
+ const childId = resolveHeritageId(h.className, h.filePath, ctx, 'Class', `${h.filePath}:${h.className}`);
209
+ const parentId = resolveHeritageId(h.parentName, h.filePath, ctx, idPrefix);
210
+ if (childId && parentId && childId !== parentId) {
211
+ graph.addRelationship({
212
+ id: generateId(relType, `${childId}->${parentId}`),
213
+ sourceId: childId,
214
+ targetId: parentId,
215
+ type: relType,
216
+ confidence: 1.0,
217
+ reason: '',
218
+ });
219
+ }
220
+ }
221
+ else if (h.kind === 'implements') {
222
+ const classId = resolveHeritageId(h.className, h.filePath, ctx, 'Class', `${h.filePath}:${h.className}`);
223
+ const interfaceId = resolveHeritageId(h.parentName, h.filePath, ctx, 'Interface');
224
+ if (classId && interfaceId) {
225
+ graph.addRelationship({
226
+ id: generateId('IMPLEMENTS', `${classId}->${interfaceId}`),
227
+ sourceId: classId,
228
+ targetId: interfaceId,
229
+ type: 'IMPLEMENTS',
230
+ confidence: 1.0,
231
+ reason: '',
232
+ });
233
+ }
234
+ }
235
+ else if (h.kind === 'trait-impl' || h.kind === 'include' || h.kind === 'extend' || h.kind === 'prepend') {
236
+ const structId = resolveHeritageId(h.className, h.filePath, ctx, 'Struct', `${h.filePath}:${h.className}`);
237
+ const traitId = resolveHeritageId(h.parentName, h.filePath, ctx, 'Trait');
238
+ if (structId && traitId) {
239
+ graph.addRelationship({
240
+ id: generateId('IMPLEMENTS', `${structId}->${traitId}:${h.kind}`),
241
+ sourceId: structId,
242
+ targetId: traitId,
243
+ type: 'IMPLEMENTS',
244
+ confidence: 1.0,
245
+ reason: h.kind,
246
+ });
247
+ }
248
+ }
249
+ }
250
+ onProgress?.(total, total);
251
+ };
@@ -0,0 +1,34 @@
1
+ import { KnowledgeGraph } from '../graph/types.js';
2
+ import { ASTCache } from './ast-cache.js';
3
+ import type { ExtractedImport } from './workers/parse-worker.js';
4
+ import type { ResolutionContext } from './resolution-context.js';
5
+ import type { SuffixIndex } from './resolvers/index.js';
6
+ export type { SuffixIndex, TsconfigPaths, GoModuleConfig, CSharpProjectConfig, ComposerConfig } from './resolvers/index.js';
7
+ export type ImportMap = Map<string, Set<string>>;
8
+ export type PackageMap = Map<string, Set<string>>;
9
+ export interface NamedImportBinding {
10
+ sourcePath: string;
11
+ exportedName: string;
12
+ }
13
+ export type NamedImportMap = Map<string, Map<string, NamedImportBinding>>;
14
+ /**
15
+ * Check if a file path is directly inside a package directory identified by its suffix.
16
+ * Used by the symbol resolver for Go and C# directory-level import matching.
17
+ */
18
+ export declare function isFileInPackageDir(filePath: string, dirSuffix: string): boolean;
19
+ /** Pre-built lookup structures for import resolution. Build once, reuse across chunks. */
20
+ export interface ImportResolutionContext {
21
+ allFilePaths: Set<string>;
22
+ allFileList: string[];
23
+ normalizedFileList: string[];
24
+ suffixIndex: SuffixIndex;
25
+ resolveCache: Map<string, string | null>;
26
+ }
27
+ export declare function buildImportResolutionContext(allPaths: string[]): ImportResolutionContext;
28
+ export declare const processImports: (graph: KnowledgeGraph, files: {
29
+ path: string;
30
+ content: string;
31
+ }[], astCache: ASTCache, ctx: ResolutionContext, onProgress?: (current: number, total: number) => void, repoRoot?: string, allPaths?: string[]) => Promise<void>;
32
+ export declare const processImportsFromExtracted: (graph: KnowledgeGraph, files: {
33
+ path: string;
34
+ }[], extractedImports: ExtractedImport[], ctx: ResolutionContext, onProgress?: (current: number, total: number) => void, repoRoot?: string, prebuiltCtx?: ImportResolutionContext) => Promise<void>;