@veewo/gitnexus 1.3.11 → 1.4.6-rc

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 (181) hide show
  1. package/README.md +37 -80
  2. package/dist/benchmark/agent-context/tool-runner.js +2 -2
  3. package/dist/benchmark/neonspark-candidates.js +3 -3
  4. package/dist/benchmark/tool-runner.js +2 -2
  5. package/dist/cli/ai-context.d.ts +2 -1
  6. package/dist/cli/ai-context.js +16 -12
  7. package/dist/cli/analyze.d.ts +2 -0
  8. package/dist/cli/analyze.js +68 -48
  9. package/dist/cli/augment.js +1 -1
  10. package/dist/cli/eval-server.d.ts +8 -1
  11. package/dist/cli/eval-server.js +30 -13
  12. package/dist/cli/index.js +28 -82
  13. package/dist/cli/lazy-action.d.ts +6 -0
  14. package/dist/cli/lazy-action.js +18 -0
  15. package/dist/cli/mcp.js +3 -1
  16. package/dist/cli/setup.js +87 -48
  17. package/dist/cli/setup.test.js +18 -13
  18. package/dist/cli/skill-gen.d.ts +26 -0
  19. package/dist/cli/skill-gen.js +549 -0
  20. package/dist/cli/status.js +13 -4
  21. package/dist/cli/tool.d.ts +3 -2
  22. package/dist/cli/tool.js +50 -16
  23. package/dist/cli/wiki.js +8 -4
  24. package/dist/config/ignore-service.d.ts +25 -0
  25. package/dist/config/ignore-service.js +76 -0
  26. package/dist/config/supported-languages.d.ts +4 -1
  27. package/dist/config/supported-languages.js +3 -2
  28. package/dist/core/augmentation/engine.js +94 -67
  29. package/dist/core/embeddings/embedder.d.ts +1 -1
  30. package/dist/core/embeddings/embedder.js +1 -1
  31. package/dist/core/embeddings/embedding-pipeline.d.ts +3 -3
  32. package/dist/core/embeddings/embedding-pipeline.js +52 -25
  33. package/dist/core/embeddings/types.d.ts +1 -1
  34. package/dist/core/graph/types.d.ts +7 -2
  35. package/dist/core/ingestion/ast-cache.js +3 -2
  36. package/dist/core/ingestion/call-processor.d.ts +8 -6
  37. package/dist/core/ingestion/call-processor.js +468 -206
  38. package/dist/core/ingestion/call-routing.d.ts +53 -0
  39. package/dist/core/ingestion/call-routing.js +108 -0
  40. package/dist/core/ingestion/constants.d.ts +16 -0
  41. package/dist/core/ingestion/constants.js +16 -0
  42. package/dist/core/ingestion/entry-point-scoring.d.ts +2 -1
  43. package/dist/core/ingestion/entry-point-scoring.js +116 -23
  44. package/dist/core/ingestion/export-detection.d.ts +18 -0
  45. package/dist/core/ingestion/export-detection.js +231 -0
  46. package/dist/core/ingestion/filesystem-walker.js +4 -3
  47. package/dist/core/ingestion/framework-detection.d.ts +19 -4
  48. package/dist/core/ingestion/framework-detection.js +182 -6
  49. package/dist/core/ingestion/heritage-processor.d.ts +13 -5
  50. package/dist/core/ingestion/heritage-processor.js +109 -55
  51. package/dist/core/ingestion/import-processor.d.ts +16 -20
  52. package/dist/core/ingestion/import-processor.js +199 -579
  53. package/dist/core/ingestion/language-config.d.ts +46 -0
  54. package/dist/core/ingestion/language-config.js +167 -0
  55. package/dist/core/ingestion/mro-processor.d.ts +45 -0
  56. package/dist/core/ingestion/mro-processor.js +369 -0
  57. package/dist/core/ingestion/named-binding-extraction.d.ts +61 -0
  58. package/dist/core/ingestion/named-binding-extraction.js +363 -0
  59. package/dist/core/ingestion/parsing-processor.d.ts +4 -1
  60. package/dist/core/ingestion/parsing-processor.js +107 -109
  61. package/dist/core/ingestion/pipeline.d.ts +6 -3
  62. package/dist/core/ingestion/pipeline.js +208 -114
  63. package/dist/core/ingestion/process-processor.js +8 -2
  64. package/dist/core/ingestion/resolution-context.d.ts +53 -0
  65. package/dist/core/ingestion/resolution-context.js +132 -0
  66. package/dist/core/ingestion/resolvers/csharp.d.ts +22 -0
  67. package/dist/core/ingestion/resolvers/csharp.js +109 -0
  68. package/dist/core/ingestion/resolvers/go.d.ts +19 -0
  69. package/dist/core/ingestion/resolvers/go.js +42 -0
  70. package/dist/core/ingestion/resolvers/index.d.ts +18 -0
  71. package/dist/core/ingestion/resolvers/index.js +13 -0
  72. package/dist/core/ingestion/resolvers/jvm.d.ts +23 -0
  73. package/dist/core/ingestion/resolvers/jvm.js +87 -0
  74. package/dist/core/ingestion/resolvers/php.d.ts +15 -0
  75. package/dist/core/ingestion/resolvers/php.js +35 -0
  76. package/dist/core/ingestion/resolvers/python.d.ts +19 -0
  77. package/dist/core/ingestion/resolvers/python.js +52 -0
  78. package/dist/core/ingestion/resolvers/ruby.d.ts +12 -0
  79. package/dist/core/ingestion/resolvers/ruby.js +15 -0
  80. package/dist/core/ingestion/resolvers/rust.d.ts +15 -0
  81. package/dist/core/ingestion/resolvers/rust.js +73 -0
  82. package/dist/core/ingestion/resolvers/standard.d.ts +28 -0
  83. package/dist/core/ingestion/resolvers/standard.js +123 -0
  84. package/dist/core/ingestion/resolvers/utils.d.ts +33 -0
  85. package/dist/core/ingestion/resolvers/utils.js +122 -0
  86. package/dist/core/ingestion/symbol-table.d.ts +21 -1
  87. package/dist/core/ingestion/symbol-table.js +40 -12
  88. package/dist/core/ingestion/tree-sitter-queries.d.ts +13 -10
  89. package/dist/core/ingestion/tree-sitter-queries.js +297 -7
  90. package/dist/core/ingestion/type-env.d.ts +49 -0
  91. package/dist/core/ingestion/type-env.js +611 -0
  92. package/dist/core/ingestion/type-extractors/c-cpp.d.ts +2 -0
  93. package/dist/core/ingestion/type-extractors/c-cpp.js +385 -0
  94. package/dist/core/ingestion/type-extractors/csharp.d.ts +2 -0
  95. package/dist/core/ingestion/type-extractors/csharp.js +383 -0
  96. package/dist/core/ingestion/type-extractors/go.d.ts +2 -0
  97. package/dist/core/ingestion/type-extractors/go.js +467 -0
  98. package/dist/core/ingestion/type-extractors/index.d.ts +22 -0
  99. package/dist/core/ingestion/type-extractors/index.js +31 -0
  100. package/dist/core/ingestion/type-extractors/jvm.d.ts +3 -0
  101. package/dist/core/ingestion/type-extractors/jvm.js +681 -0
  102. package/dist/core/ingestion/type-extractors/php.d.ts +2 -0
  103. package/dist/core/ingestion/type-extractors/php.js +549 -0
  104. package/dist/core/ingestion/type-extractors/python.d.ts +2 -0
  105. package/dist/core/ingestion/type-extractors/python.js +406 -0
  106. package/dist/core/ingestion/type-extractors/ruby.d.ts +2 -0
  107. package/dist/core/ingestion/type-extractors/ruby.js +389 -0
  108. package/dist/core/ingestion/type-extractors/rust.d.ts +2 -0
  109. package/dist/core/ingestion/type-extractors/rust.js +449 -0
  110. package/dist/core/ingestion/type-extractors/shared.d.ts +133 -0
  111. package/dist/core/ingestion/type-extractors/shared.js +703 -0
  112. package/dist/core/ingestion/type-extractors/swift.d.ts +2 -0
  113. package/dist/core/ingestion/type-extractors/swift.js +137 -0
  114. package/dist/core/ingestion/type-extractors/types.d.ts +127 -0
  115. package/dist/core/ingestion/type-extractors/typescript.d.ts +2 -0
  116. package/dist/core/ingestion/type-extractors/typescript.js +494 -0
  117. package/dist/core/ingestion/utils.d.ts +103 -0
  118. package/dist/core/ingestion/utils.js +1085 -4
  119. package/dist/core/ingestion/workers/parse-worker.d.ts +51 -4
  120. package/dist/core/ingestion/workers/parse-worker.js +634 -222
  121. package/dist/core/ingestion/workers/worker-pool.js +8 -0
  122. package/dist/core/{kuzu → lbug}/csv-generator.d.ts +12 -10
  123. package/dist/core/{kuzu → lbug}/csv-generator.js +82 -101
  124. package/dist/core/{kuzu/kuzu-adapter.d.ts → lbug/lbug-adapter.d.ts} +20 -25
  125. package/dist/core/{kuzu/kuzu-adapter.js → lbug/lbug-adapter.js} +150 -122
  126. package/dist/core/{kuzu → lbug}/schema.d.ts +4 -4
  127. package/dist/core/{kuzu → lbug}/schema.js +23 -22
  128. package/dist/core/lbug/schema.test.d.ts +1 -0
  129. package/dist/core/search/bm25-index.d.ts +4 -4
  130. package/dist/core/search/bm25-index.js +12 -11
  131. package/dist/core/search/hybrid-search.d.ts +2 -2
  132. package/dist/core/search/hybrid-search.js +6 -6
  133. package/dist/core/tree-sitter/parser-loader.d.ts +1 -0
  134. package/dist/core/tree-sitter/parser-loader.js +19 -0
  135. package/dist/core/wiki/generator.d.ts +2 -2
  136. package/dist/core/wiki/generator.js +6 -6
  137. package/dist/core/wiki/graph-queries.d.ts +4 -4
  138. package/dist/core/wiki/graph-queries.js +7 -7
  139. package/dist/mcp/compatible-stdio-transport.d.ts +25 -0
  140. package/dist/mcp/compatible-stdio-transport.js +200 -0
  141. package/dist/mcp/core/{kuzu-adapter.d.ts → lbug-adapter.d.ts} +11 -10
  142. package/dist/mcp/core/lbug-adapter.js +327 -0
  143. package/dist/mcp/local/local-backend.d.ts +21 -16
  144. package/dist/mcp/local/local-backend.js +306 -706
  145. package/dist/mcp/local/unity-parity-seed-loader.d.ts +6 -1
  146. package/dist/mcp/local/unity-parity-seed-loader.js +119 -9
  147. package/dist/mcp/local/unity-parity-seed-loader.test.js +95 -7
  148. package/dist/mcp/resources.js +2 -2
  149. package/dist/mcp/server.js +28 -13
  150. package/dist/mcp/staleness.js +2 -2
  151. package/dist/mcp/tools.js +12 -3
  152. package/dist/server/api.js +12 -12
  153. package/dist/server/mcp-http.d.ts +1 -1
  154. package/dist/server/mcp-http.js +1 -1
  155. package/dist/storage/git.js +4 -1
  156. package/dist/storage/repo-manager.d.ts +20 -2
  157. package/dist/storage/repo-manager.js +74 -4
  158. package/dist/types/pipeline.d.ts +1 -1
  159. package/hooks/claude/gitnexus-hook.cjs +149 -46
  160. package/hooks/claude/pre-tool-use.sh +2 -1
  161. package/hooks/claude/session-start.sh +0 -0
  162. package/package.json +20 -4
  163. package/scripts/patch-tree-sitter-swift.cjs +74 -0
  164. package/skills/gitnexus-cli.md +8 -8
  165. package/skills/gitnexus-debugging.md +1 -1
  166. package/skills/gitnexus-exploring.md +1 -1
  167. package/skills/gitnexus-guide.md +1 -1
  168. package/skills/gitnexus-impact-analysis.md +1 -1
  169. package/skills/gitnexus-pr-review.md +163 -0
  170. package/skills/gitnexus-refactoring.md +1 -1
  171. package/dist/cli/claude-hooks.d.ts +0 -22
  172. package/dist/cli/claude-hooks.js +0 -97
  173. package/dist/mcp/core/kuzu-adapter.js +0 -231
  174. /package/dist/core/{kuzu/csv-generator.test.d.ts → ingestion/type-extractors/types.js} +0 -0
  175. /package/dist/core/{kuzu/relationship-pair-buckets.test.d.ts → lbug/csv-generator.test.d.ts} +0 -0
  176. /package/dist/core/{kuzu → lbug}/csv-generator.test.js +0 -0
  177. /package/dist/core/{kuzu → lbug}/relationship-pair-buckets.d.ts +0 -0
  178. /package/dist/core/{kuzu → lbug}/relationship-pair-buckets.js +0 -0
  179. /package/dist/core/{kuzu/schema.test.d.ts → lbug/relationship-pair-buckets.test.d.ts} +0 -0
  180. /package/dist/core/{kuzu → lbug}/relationship-pair-buckets.test.js +0 -0
  181. /package/dist/core/{kuzu → lbug}/schema.test.js +0 -0
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Shared Ruby call routing logic.
3
+ *
4
+ * Ruby expresses imports, heritage (mixins), and property definitions as
5
+ * method calls rather than syntax-level constructs. This module provides a
6
+ * routing function used by the CLI call-processor, CLI parse-worker, and
7
+ * the web call-processor so that the classification logic lives in one place.
8
+ *
9
+ * NOTE: This file is intentionally duplicated in gitnexus-web/ because the
10
+ * two packages have separate build targets (Node native vs WASM/browser).
11
+ * Keep both copies in sync until a shared package is introduced.
12
+ */
13
+ import { SupportedLanguages } from '../../config/supported-languages.js';
14
+ /** null = this call was not routed; fall through to default call handling */
15
+ export type CallRoutingResult = RubyCallRouting | null;
16
+ export type CallRouter = (calledName: string, callNode: any) => CallRoutingResult;
17
+ /** Per-language call routing. noRouting = no special routing (normal call processing) */
18
+ export declare const callRouters: Record<SupportedLanguages, CallRouter>;
19
+ export type RubyCallRouting = {
20
+ kind: 'import';
21
+ importPath: string;
22
+ isRelative: boolean;
23
+ } | {
24
+ kind: 'heritage';
25
+ items: RubyHeritageItem[];
26
+ } | {
27
+ kind: 'properties';
28
+ items: RubyPropertyItem[];
29
+ } | {
30
+ kind: 'call';
31
+ } | {
32
+ kind: 'skip';
33
+ };
34
+ export interface RubyHeritageItem {
35
+ enclosingClass: string;
36
+ mixinName: string;
37
+ heritageKind: 'include' | 'extend' | 'prepend';
38
+ }
39
+ export type RubyAccessorType = 'attr_accessor' | 'attr_reader' | 'attr_writer';
40
+ export interface RubyPropertyItem {
41
+ propName: string;
42
+ accessorType: RubyAccessorType;
43
+ startLine: number;
44
+ endLine: number;
45
+ }
46
+ /**
47
+ * Classify a Ruby call node and extract its semantic payload.
48
+ *
49
+ * @param calledName - The method name (e.g. 'require', 'include', 'attr_accessor')
50
+ * @param callNode - The tree-sitter `call` AST node
51
+ * @returns A discriminated union describing the call's semantic role
52
+ */
53
+ export declare function routeRubyCall(calledName: string, callNode: any): RubyCallRouting;
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Shared Ruby call routing logic.
3
+ *
4
+ * Ruby expresses imports, heritage (mixins), and property definitions as
5
+ * method calls rather than syntax-level constructs. This module provides a
6
+ * routing function used by the CLI call-processor, CLI parse-worker, and
7
+ * the web call-processor so that the classification logic lives in one place.
8
+ *
9
+ * NOTE: This file is intentionally duplicated in gitnexus-web/ because the
10
+ * two packages have separate build targets (Node native vs WASM/browser).
11
+ * Keep both copies in sync until a shared package is introduced.
12
+ */
13
+ import { SupportedLanguages } from '../../config/supported-languages.js';
14
+ /** No-op router: returns null for every call (passthrough to normal processing) */
15
+ const noRouting = () => null;
16
+ /** Per-language call routing. noRouting = no special routing (normal call processing) */
17
+ export const callRouters = {
18
+ [SupportedLanguages.JavaScript]: noRouting,
19
+ [SupportedLanguages.TypeScript]: noRouting,
20
+ [SupportedLanguages.Python]: noRouting,
21
+ [SupportedLanguages.Java]: noRouting,
22
+ [SupportedLanguages.Kotlin]: noRouting,
23
+ [SupportedLanguages.Go]: noRouting,
24
+ [SupportedLanguages.Rust]: noRouting,
25
+ [SupportedLanguages.CSharp]: noRouting,
26
+ [SupportedLanguages.PHP]: noRouting,
27
+ [SupportedLanguages.Swift]: noRouting,
28
+ [SupportedLanguages.CPlusPlus]: noRouting,
29
+ [SupportedLanguages.C]: noRouting,
30
+ [SupportedLanguages.Ruby]: routeRubyCall,
31
+ };
32
+ // ── Pre-allocated singletons for common return values ────────────────────────
33
+ const CALL_RESULT = { kind: 'call' };
34
+ const SKIP_RESULT = { kind: 'skip' };
35
+ /** Max depth for parent-walking loops to prevent pathological AST traversals */
36
+ const MAX_PARENT_DEPTH = 50;
37
+ // ── Routing function ────────────────────────────────────────────────────────
38
+ /**
39
+ * Classify a Ruby call node and extract its semantic payload.
40
+ *
41
+ * @param calledName - The method name (e.g. 'require', 'include', 'attr_accessor')
42
+ * @param callNode - The tree-sitter `call` AST node
43
+ * @returns A discriminated union describing the call's semantic role
44
+ */
45
+ export function routeRubyCall(calledName, callNode) {
46
+ // ── require / require_relative → import ─────────────────────────────────
47
+ if (calledName === 'require' || calledName === 'require_relative') {
48
+ const argList = callNode.childForFieldName?.('arguments');
49
+ const stringNode = argList?.children?.find((c) => c.type === 'string');
50
+ const contentNode = stringNode?.children?.find((c) => c.type === 'string_content');
51
+ if (!contentNode)
52
+ return SKIP_RESULT;
53
+ let importPath = contentNode.text;
54
+ // Validate: reject null bytes, control chars, excessively long paths
55
+ if (!importPath || importPath.length > 1024 || /[\x00-\x1f]/.test(importPath)) {
56
+ return SKIP_RESULT;
57
+ }
58
+ const isRelative = calledName === 'require_relative';
59
+ if (isRelative && !importPath.startsWith('.')) {
60
+ importPath = './' + importPath;
61
+ }
62
+ return { kind: 'import', importPath, isRelative };
63
+ }
64
+ // ── include / extend / prepend → heritage (mixin) ──────────────────────
65
+ if (calledName === 'include' || calledName === 'extend' || calledName === 'prepend') {
66
+ let enclosingClass = null;
67
+ let current = callNode.parent;
68
+ let depth = 0;
69
+ while (current && ++depth <= MAX_PARENT_DEPTH) {
70
+ if (current.type === 'class' || current.type === 'module') {
71
+ const nameNode = current.childForFieldName?.('name');
72
+ if (nameNode) {
73
+ enclosingClass = nameNode.text;
74
+ break;
75
+ }
76
+ }
77
+ current = current.parent;
78
+ }
79
+ if (!enclosingClass)
80
+ return SKIP_RESULT;
81
+ const items = [];
82
+ const argList = callNode.childForFieldName?.('arguments');
83
+ for (const arg of (argList?.children ?? [])) {
84
+ if (arg.type === 'constant' || arg.type === 'scope_resolution') {
85
+ items.push({ enclosingClass, mixinName: arg.text, heritageKind: calledName });
86
+ }
87
+ }
88
+ return items.length > 0 ? { kind: 'heritage', items } : SKIP_RESULT;
89
+ }
90
+ // ── attr_accessor / attr_reader / attr_writer → property definitions ───
91
+ if (calledName === 'attr_accessor' || calledName === 'attr_reader' || calledName === 'attr_writer') {
92
+ const items = [];
93
+ const argList = callNode.childForFieldName?.('arguments');
94
+ for (const arg of (argList?.children ?? [])) {
95
+ if (arg.type === 'simple_symbol') {
96
+ items.push({
97
+ propName: arg.text.startsWith(':') ? arg.text.slice(1) : arg.text,
98
+ accessorType: calledName,
99
+ startLine: arg.startPosition.row,
100
+ endLine: arg.endPosition.row,
101
+ });
102
+ }
103
+ }
104
+ return items.length > 0 ? { kind: 'properties', items } : SKIP_RESULT;
105
+ }
106
+ // ── Everything else → regular call ─────────────────────────────────────
107
+ return CALL_RESULT;
108
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Default minimum buffer size for tree-sitter parsing (512 KB).
3
+ * tree-sitter requires bufferSize >= file size in bytes.
4
+ */
5
+ export declare const TREE_SITTER_BUFFER_SIZE: number;
6
+ /**
7
+ * Maximum buffer size cap (32 MB) to prevent OOM on huge files.
8
+ * Also used as the file-size skip threshold — files larger than this are not parsed.
9
+ */
10
+ export declare const TREE_SITTER_MAX_BUFFER: number;
11
+ /**
12
+ * Compute adaptive buffer size for tree-sitter parsing.
13
+ * Uses 2× file size, clamped between 512 KB and 32 MB.
14
+ * Previous 256 KB fixed limit silently skipped files > ~200 KB (e.g., imgui.h at 411 KB).
15
+ */
16
+ export declare const getTreeSitterBufferSize: (contentLength: number) => number;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Default minimum buffer size for tree-sitter parsing (512 KB).
3
+ * tree-sitter requires bufferSize >= file size in bytes.
4
+ */
5
+ export const TREE_SITTER_BUFFER_SIZE = 512 * 1024;
6
+ /**
7
+ * Maximum buffer size cap (32 MB) to prevent OOM on huge files.
8
+ * Also used as the file-size skip threshold — files larger than this are not parsed.
9
+ */
10
+ export const TREE_SITTER_MAX_BUFFER = 32 * 1024 * 1024;
11
+ /**
12
+ * Compute adaptive buffer size for tree-sitter parsing.
13
+ * Uses 2× file size, clamped between 512 KB and 32 MB.
14
+ * Previous 256 KB fixed limit silently skipped files > ~200 KB (e.g., imgui.h at 411 KB).
15
+ */
16
+ export const getTreeSitterBufferSize = (contentLength) => Math.min(Math.max(contentLength * 2, TREE_SITTER_BUFFER_SIZE), TREE_SITTER_MAX_BUFFER);
@@ -9,6 +9,7 @@
9
9
  *
10
10
  * This module is language-agnostic - language-specific patterns are defined per language.
11
11
  */
12
+ import { SupportedLanguages } from '../../config/supported-languages.js';
12
13
  export interface EntryPointScoreResult {
13
14
  score: number;
14
15
  reasons: string[];
@@ -26,7 +27,7 @@ export interface EntryPointScoreResult {
26
27
  * @param calleeCount - Number of functions this function calls
27
28
  * @returns Score and array of reasons explaining the score
28
29
  */
29
- export declare function calculateEntryPointScore(name: string, language: string, isExported: boolean, callerCount: number, calleeCount: number, filePath?: string): EntryPointScoreResult;
30
+ export declare function calculateEntryPointScore(name: string, language: SupportedLanguages, isExported: boolean, callerCount: number, calleeCount: number, filePath?: string): EntryPointScoreResult;
30
31
  /**
31
32
  * Check if a file path is a test file (should be excluded from entry points)
32
33
  * Covers common test file patterns across all supported languages
@@ -10,8 +10,9 @@
10
10
  * This module is language-agnostic - language-specific patterns are defined per language.
11
11
  */
12
12
  import { detectFrameworkFromPath } from './framework-detection.js';
13
+ import { SupportedLanguages } from '../../config/supported-languages.js';
13
14
  // ============================================================================
14
- // NAME PATTERNS - All 9 supported languages
15
+ // NAME PATTERNS - All 11 supported languages
15
16
  // ============================================================================
16
17
  /**
17
18
  * Common entry point naming patterns by language
@@ -34,65 +35,131 @@ const ENTRY_POINT_PATTERNS = {
34
35
  /^emit[A-Z]/, // emitEvent
35
36
  ],
36
37
  // JavaScript/TypeScript
37
- 'javascript': [
38
+ [SupportedLanguages.JavaScript]: [
38
39
  /^use[A-Z]/, // React hooks (useEffect, etc.)
39
40
  ],
40
- 'typescript': [
41
+ [SupportedLanguages.TypeScript]: [
41
42
  /^use[A-Z]/, // React hooks
42
43
  ],
43
44
  // Python
44
- 'python': [
45
+ [SupportedLanguages.Python]: [
45
46
  /^app$/, // Flask/FastAPI app
46
47
  /^(get|post|put|delete|patch)_/i, // REST conventions
47
48
  /^api_/, // API functions
48
49
  /^view_/, // Django views
49
50
  ],
50
51
  // Java
51
- 'java': [
52
+ [SupportedLanguages.Java]: [
52
53
  /^do[A-Z]/, // doGet, doPost (Servlets)
53
54
  /^create[A-Z]/, // Factory patterns
54
55
  /^build[A-Z]/, // Builder patterns
55
56
  /Service$/, // UserService
56
57
  ],
57
58
  // C#
58
- 'csharp': [
59
- /^(Get|Post|Put|Delete)/, // ASP.NET conventions
59
+ [SupportedLanguages.CSharp]: [
60
+ /^(Get|Post|Put|Delete|Patch)/, // ASP.NET action methods
60
61
  /Action$/, // MVC actions
61
- /^On[A-Z]/, // Event handlers
62
+ /^On[A-Z]/, // Event handlers / Blazor lifecycle
62
63
  /Async$/, // Async entry points
64
+ /^Configure$/, // Startup.Configure
65
+ /^ConfigureServices$/, // Startup.ConfigureServices
66
+ /^Handle$/, // MediatR / generic handler
67
+ /^Execute$/, // Command pattern
68
+ /^Invoke$/, // Middleware Invoke
69
+ /^Map[A-Z]/, // Minimal API MapGet, MapPost
70
+ /Service$/, // Service classes
71
+ /^Seed/, // Database seeding
63
72
  ],
64
73
  // Go
65
- 'go': [
74
+ [SupportedLanguages.Go]: [
66
75
  /Handler$/, // http.Handler pattern
67
76
  /^Serve/, // ServeHTTP
68
77
  /^New[A-Z]/, // Constructor pattern (returns new instance)
69
78
  /^Make[A-Z]/, // Make functions
70
79
  ],
71
80
  // Rust
72
- 'rust': [
81
+ [SupportedLanguages.Rust]: [
73
82
  /^(get|post|put|delete)_handler$/i,
74
83
  /^handle_/, // handle_request
75
84
  /^new$/, // Constructor pattern
76
85
  /^run$/, // run entry point
77
86
  /^spawn/, // Async spawn
78
87
  ],
79
- // C - explicit main() boost (critical for C programs)
80
- 'c': [
88
+ // C - explicit main() boost plus common C entry point conventions
89
+ [SupportedLanguages.C]: [
81
90
  /^main$/, // THE entry point
82
- /^init_/, // Initialization functions
83
- /^start_/, // Start functions
84
- /^run_/, // Run functions
91
+ /^init_/, // init_server, init_client
92
+ /_init$/, // module_init, server_init
93
+ /^start_/, // start_server
94
+ /_start$/, // thread_start
95
+ /^run_/, // run_loop
96
+ /_run$/, // event_run
97
+ /^stop_/, // stop_server
98
+ /_stop$/, // service_stop
99
+ /^open_/, // open_connection
100
+ /_open$/, // file_open
101
+ /^close_/, // close_connection
102
+ /_close$/, // socket_close
103
+ /^create_/, // create_session
104
+ /_create$/, // object_create
105
+ /^destroy_/, // destroy_session
106
+ /_destroy$/, // object_destroy
107
+ /^handle_/, // handle_request
108
+ /_handler$/, // signal_handler
109
+ /_callback$/, // event_callback
110
+ /^cmd_/, // tmux: cmd_new_window, cmd_attach_session
111
+ /^server_/, // server_start, server_loop
112
+ /^client_/, // client_connect
113
+ /^session_/, // session_create
114
+ /^window_/, // window_resize (tmux)
115
+ /^key_/, // key_press
116
+ /^input_/, // input_parse
117
+ /^output_/, // output_write
118
+ /^notify_/, // notify_client
119
+ /^control_/, // control_start
85
120
  ],
86
- // C++ - same as C plus class patterns
87
- 'cpp': [
121
+ // C++ - same as C plus OOP/template patterns
122
+ [SupportedLanguages.CPlusPlus]: [
88
123
  /^main$/, // THE entry point
89
124
  /^init_/,
125
+ /_init$/,
90
126
  /^Create[A-Z]/, // Factory patterns
127
+ /^create_/,
91
128
  /^Run$/, // Run methods
129
+ /^run$/,
92
130
  /^Start$/, // Start methods
131
+ /^start$/,
132
+ /^handle_/,
133
+ /_handler$/,
134
+ /_callback$/,
135
+ /^OnEvent/, // Event callbacks
136
+ /^on_/,
137
+ /::Run$/, // Class::Run
138
+ /::Start$/, // Class::Start
139
+ /::Init$/, // Class::Init
140
+ /::Execute$/, // Class::Execute
141
+ ],
142
+ // Swift / iOS
143
+ [SupportedLanguages.Swift]: [
144
+ /^viewDidLoad$/, // UIKit lifecycle
145
+ /^viewWillAppear$/, // UIKit lifecycle
146
+ /^viewDidAppear$/, // UIKit lifecycle
147
+ /^viewWillDisappear$/, // UIKit lifecycle
148
+ /^viewDidDisappear$/, // UIKit lifecycle
149
+ /^application\(/, // AppDelegate methods
150
+ /^scene\(/, // SceneDelegate methods
151
+ /^body$/, // SwiftUI View.body
152
+ /Coordinator$/, // Coordinator pattern
153
+ /^sceneDidBecomeActive$/, // SceneDelegate lifecycle
154
+ /^sceneWillResignActive$/, // SceneDelegate lifecycle
155
+ /^didFinishLaunchingWithOptions$/, // AppDelegate
156
+ /ViewController$/, // ViewController classes
157
+ /^configure[A-Z]/, // Configuration methods
158
+ /^setup[A-Z]/, // Setup methods
159
+ /^makeBody$/, // SwiftUI ViewModifier
93
160
  ],
94
161
  // PHP / Laravel
95
- 'php': [
162
+ [SupportedLanguages.PHP]: [
96
163
  /Controller$/, // UserController (class name convention)
97
164
  /^handle$/, // Job::handle(), Listener::handle()
98
165
  /^execute$/, // Command::execute()
@@ -111,7 +178,21 @@ const ENTRY_POINT_PATTERNS = {
111
178
  /^save$/, // Repository::save()
112
179
  /^delete$/, // Repository::delete()
113
180
  ],
181
+ // Ruby
182
+ [SupportedLanguages.Ruby]: [
183
+ /^call$/, // Service objects (MyService.call)
184
+ /^perform$/, // Background jobs (Sidekiq, ActiveJob)
185
+ /^execute$/, // Command pattern
186
+ ],
114
187
  };
188
+ /** Pre-computed merged patterns (universal + language-specific) to avoid per-call array allocation. */
189
+ const MERGED_ENTRY_POINT_PATTERNS = {};
190
+ const UNIVERSAL_PATTERNS = ENTRY_POINT_PATTERNS['*'] || [];
191
+ for (const [lang, patterns] of Object.entries(ENTRY_POINT_PATTERNS)) {
192
+ if (lang === '*')
193
+ continue;
194
+ MERGED_ENTRY_POINT_PATTERNS[lang] = [...UNIVERSAL_PATTERNS, ...patterns];
195
+ }
115
196
  // ============================================================================
116
197
  // UTILITY PATTERNS - Functions that should be penalized
117
198
  // ============================================================================
@@ -177,9 +258,7 @@ export function calculateEntryPointScore(name, language, isExported, callerCount
177
258
  }
178
259
  else {
179
260
  // Check positive patterns
180
- const universalPatterns = ENTRY_POINT_PATTERNS['*'] || [];
181
- const langPatterns = ENTRY_POINT_PATTERNS[language] || [];
182
- const allPatterns = [...universalPatterns, ...langPatterns];
261
+ const allPatterns = MERGED_ENTRY_POINT_PATTERNS[language] || UNIVERSAL_PATTERNS;
183
262
  if (allPatterns.some(p => p.test(name))) {
184
263
  nameMultiplier = 1.5; // Bonus for matching entry point pattern
185
264
  reasons.push('entry-pattern');
@@ -229,14 +308,28 @@ export function isTestFile(filePath) {
229
308
  p.includes('/src/test/') ||
230
309
  // Rust test patterns (inline tests are different, but test files)
231
310
  p.includes('/tests/') ||
311
+ // Swift/iOS test patterns
312
+ p.endsWith('tests.swift') ||
313
+ p.endsWith('test.swift') ||
314
+ p.includes('uitests/') ||
232
315
  // C# test patterns
316
+ p.endsWith('tests.cs') ||
317
+ p.endsWith('test.cs') ||
233
318
  p.includes('.tests/') ||
234
- p.includes('tests.cs') ||
319
+ p.includes('.test/') ||
320
+ p.includes('.integrationtests/') ||
321
+ p.includes('.unittests/') ||
322
+ p.includes('/testproject/') ||
235
323
  // PHP/Laravel test patterns
236
324
  p.endsWith('test.php') ||
237
325
  p.endsWith('spec.php') ||
238
326
  p.includes('/tests/feature/') ||
239
- p.includes('/tests/unit/'));
327
+ p.includes('/tests/unit/') ||
328
+ // Ruby test patterns
329
+ p.endsWith('_spec.rb') ||
330
+ p.endsWith('_test.rb') ||
331
+ p.includes('/spec/') ||
332
+ p.includes('/test/fixtures/'));
240
333
  }
241
334
  /**
242
335
  * Check if a file path is likely a utility/helper file
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Export Detection
3
+ *
4
+ * Determines whether a symbol (function, class, etc.) is exported/public
5
+ * in its language. This is a pure function — safe for use in worker threads.
6
+ *
7
+ * Shared between parse-worker.ts (worker pool) and parsing-processor.ts (sequential fallback).
8
+ */
9
+ import { SyntaxNode } from './utils.js';
10
+ import { SupportedLanguages } from '../../config/supported-languages.js';
11
+ /**
12
+ * Check if a tree-sitter node is exported/public in its language.
13
+ * @param node - The tree-sitter AST node
14
+ * @param name - The symbol name
15
+ * @param language - The programming language
16
+ * @returns true if the symbol is exported/public
17
+ */
18
+ export declare const isNodeExported: (node: SyntaxNode, name: string, language: SupportedLanguages) => boolean;