code-graph-context 2.0.1 → 2.3.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.
- package/README.md +221 -2
- package/dist/constants.js +167 -0
- package/dist/core/config/fairsquare-framework-schema.js +9 -7
- package/dist/core/config/schema.js +41 -2
- package/dist/core/embeddings/natural-language-to-cypher.service.js +166 -110
- package/dist/core/parsers/typescript-parser.js +1039 -742
- package/dist/core/parsers/workspace-parser.js +175 -193
- package/dist/core/utils/code-normalizer.js +299 -0
- package/dist/core/utils/file-change-detection.js +17 -2
- package/dist/core/utils/file-utils.js +40 -5
- package/dist/core/utils/graph-factory.js +161 -0
- package/dist/core/utils/shared-utils.js +79 -0
- package/dist/core/workspace/workspace-detector.js +59 -5
- package/dist/mcp/constants.js +261 -8
- package/dist/mcp/handlers/graph-generator.handler.js +1 -0
- package/dist/mcp/handlers/incremental-parse.handler.js +22 -6
- package/dist/mcp/handlers/parallel-import.handler.js +136 -0
- package/dist/mcp/handlers/streaming-import.handler.js +14 -59
- package/dist/mcp/mcp.server.js +77 -2
- package/dist/mcp/services/job-manager.js +5 -8
- package/dist/mcp/services/watch-manager.js +64 -25
- package/dist/mcp/tools/detect-dead-code.tool.js +413 -0
- package/dist/mcp/tools/detect-duplicate-code.tool.js +450 -0
- package/dist/mcp/tools/hello.tool.js +16 -2
- package/dist/mcp/tools/impact-analysis.tool.js +20 -4
- package/dist/mcp/tools/index.js +37 -0
- package/dist/mcp/tools/parse-typescript-project.tool.js +15 -14
- package/dist/mcp/tools/swarm-cleanup.tool.js +157 -0
- package/dist/mcp/tools/swarm-constants.js +35 -0
- package/dist/mcp/tools/swarm-pheromone.tool.js +196 -0
- package/dist/mcp/tools/swarm-sense.tool.js +212 -0
- package/dist/mcp/workers/chunk-worker-pool.js +196 -0
- package/dist/mcp/workers/chunk-worker.types.js +4 -0
- package/dist/mcp/workers/chunk.worker.js +89 -0
- package/dist/mcp/workers/parse-coordinator.js +183 -0
- package/dist/mcp/workers/worker.pool.js +54 -0
- package/dist/storage/neo4j/neo4j.service.js +198 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,12 +20,17 @@ A Model Context Protocol (MCP) server that builds rich code graphs to provide de
|
|
|
20
20
|
- **Natural Language Querying**: Convert natural language questions into Cypher queries using OpenAI assistants API
|
|
21
21
|
- **Framework-Aware & Customizable**: Built-in NestJS schema with ability to define custom framework patterns via configuration
|
|
22
22
|
- **Weighted Graph Traversal**: Intelligent traversal that scores paths based on relationship importance, query relevance, and depth
|
|
23
|
-
- **Workspace & Monorepo Support**: Auto-detects Turborepo, pnpm, Yarn, and npm workspaces
|
|
23
|
+
- **Workspace & Monorepo Support**: Auto-detects Nx, Turborepo, pnpm, Yarn, and npm workspaces
|
|
24
|
+
- **Parallel Parsing**: Multi-threaded parsing with configurable worker pool for maximum CPU utilization
|
|
24
25
|
- **Async Parsing**: Background parsing with Worker threads for large codebases without blocking the MCP server
|
|
25
26
|
- **Streaming Import**: Chunked processing for projects with 100+ files to prevent memory issues
|
|
27
|
+
- **TypeAlias Support**: Full parsing of TypeScript type aliases into graph nodes
|
|
26
28
|
- **Incremental Parsing**: Only reparse changed files for faster updates
|
|
27
29
|
- **File Watching**: Real-time monitoring with automatic incremental graph updates on file changes
|
|
28
30
|
- **Impact Analysis**: Assess refactoring risk with dependency analysis (LOW/MEDIUM/HIGH/CRITICAL scoring)
|
|
31
|
+
- **Dead Code Detection**: Find unreferenced exports, uncalled private methods, unused interfaces with confidence scoring
|
|
32
|
+
- **Duplicate Code Detection**: Identify structural duplicates (identical AST) and semantic duplicates (similar logic via embeddings)
|
|
33
|
+
- **Swarm Coordination**: Multi-agent stigmergic coordination through pheromone markers with exponential decay
|
|
29
34
|
- **High Performance**: Optimized Neo4j storage with vector indexing for fast retrieval
|
|
30
35
|
- **MCP Integration**: Seamless integration with Claude Code and other MCP-compatible tools
|
|
31
36
|
|
|
@@ -249,6 +254,11 @@ npm run build
|
|
|
249
254
|
| `stop_watch_project` | Stop file watching for a project | **Resource management** - stop monitoring |
|
|
250
255
|
| `list_watchers` | List all active file watchers | **Monitoring** - see what's being watched |
|
|
251
256
|
| `natural_language_to_cypher` | Convert natural language to Cypher | **Advanced queries** - complex graph queries |
|
|
257
|
+
| `detect_dead_code` | Find unreferenced exports, uncalled methods, unused interfaces | **Code cleanup** - identify potentially removable code |
|
|
258
|
+
| `detect_duplicate_code` | Find structural and semantic code duplicates | **Refactoring** - identify DRY violations |
|
|
259
|
+
| `swarm_pheromone` | Leave pheromone markers on code nodes | **Multi-agent** - stigmergic coordination |
|
|
260
|
+
| `swarm_sense` | Query pheromones in the code graph | **Multi-agent** - sense what other agents are doing |
|
|
261
|
+
| `swarm_cleanup` | Bulk delete pheromones | **Multi-agent** - cleanup after swarm completion |
|
|
252
262
|
| `test_neo4j_connection` | Verify database connectivity | **Health check** - troubleshooting |
|
|
253
263
|
|
|
254
264
|
> **Note**: All query tools (`search_codebase`, `traverse_from_node`, `impact_analysis`, `natural_language_to_cypher`) require a `projectId` parameter. Use `list_projects` to discover available projects.
|
|
@@ -562,7 +572,155 @@ await mcp.call('test_neo4j_connection');
|
|
|
562
572
|
APOC plugin available with 438 functions"
|
|
563
573
|
```
|
|
564
574
|
|
|
565
|
-
#### 5.
|
|
575
|
+
#### 5. `detect_dead_code` - Code Cleanup Analysis
|
|
576
|
+
**Purpose**: Identify potentially dead code including unreferenced exports, uncalled private methods, and unused interfaces.
|
|
577
|
+
|
|
578
|
+
**Parameters:**
|
|
579
|
+
| Parameter | Type | Default | Description |
|
|
580
|
+
|-----------|------|---------|-------------|
|
|
581
|
+
| `projectId` | string | required | Project ID, name, or path |
|
|
582
|
+
| `excludePatterns` | string[] | [] | Additional file patterns to exclude (e.g., `["*.config.ts"]`) |
|
|
583
|
+
| `excludeSemanticTypes` | string[] | [] | Additional semantic types to exclude (e.g., `["EntityClass"]`) |
|
|
584
|
+
| `minConfidence` | enum | "LOW" | Minimum confidence: "LOW", "MEDIUM", "HIGH" |
|
|
585
|
+
| `summaryOnly` | boolean | false | Return only statistics, not full list |
|
|
586
|
+
| `limit` | number | 100 | Maximum items to return |
|
|
587
|
+
| `offset` | number | 0 | Pagination offset |
|
|
588
|
+
|
|
589
|
+
**Response Structure:**
|
|
590
|
+
```json
|
|
591
|
+
{
|
|
592
|
+
"summary": "Found 15 potentially dead code items",
|
|
593
|
+
"riskLevel": "MEDIUM",
|
|
594
|
+
"statistics": {
|
|
595
|
+
"total": 15,
|
|
596
|
+
"byConfidence": { "HIGH": 5, "MEDIUM": 7, "LOW": 3 },
|
|
597
|
+
"byCategory": { "internal-unused": 10, "library-export": 3, "ui-component": 2 },
|
|
598
|
+
"byType": { "FunctionDeclaration": 8, "InterfaceDeclaration": 4, "MethodDeclaration": 3 }
|
|
599
|
+
},
|
|
600
|
+
"deadCode": [
|
|
601
|
+
{
|
|
602
|
+
"nodeId": "proj_xxx:FunctionDeclaration:abc123",
|
|
603
|
+
"name": "unusedHelper",
|
|
604
|
+
"type": "FunctionDeclaration",
|
|
605
|
+
"filePath": "/src/utils/helpers.ts",
|
|
606
|
+
"lineNumber": 42,
|
|
607
|
+
"confidence": "HIGH",
|
|
608
|
+
"confidenceReason": "Exported but never imported anywhere",
|
|
609
|
+
"category": "internal-unused",
|
|
610
|
+
"reason": "Exported but never imported or referenced"
|
|
611
|
+
}
|
|
612
|
+
]
|
|
613
|
+
}
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
**Framework-Aware Exclusions:**
|
|
617
|
+
- Automatically excludes NestJS entry points (controllers, modules, guards, etc.)
|
|
618
|
+
- Excludes common entry point files (`main.ts`, `*.module.ts`, `*.controller.ts`)
|
|
619
|
+
- Excludes Next.js/React patterns (`page.tsx`, `layout.tsx`, `route.tsx`)
|
|
620
|
+
|
|
621
|
+
```typescript
|
|
622
|
+
// Basic usage
|
|
623
|
+
await mcp.call('detect_dead_code', {
|
|
624
|
+
projectId: 'my-backend'
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
// High confidence only with custom exclusions
|
|
628
|
+
await mcp.call('detect_dead_code', {
|
|
629
|
+
projectId: 'my-backend',
|
|
630
|
+
minConfidence: 'HIGH',
|
|
631
|
+
excludePatterns: ['*.seed.ts', '*.fixture.ts'],
|
|
632
|
+
excludeSemanticTypes: ['EntityClass', 'DTOClass']
|
|
633
|
+
});
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
#### 6. `detect_duplicate_code` - DRY Violation Detection
|
|
637
|
+
**Purpose**: Identify duplicate code using structural (identical AST) and semantic (similar embeddings) analysis.
|
|
638
|
+
|
|
639
|
+
**Parameters:**
|
|
640
|
+
| Parameter | Type | Default | Description |
|
|
641
|
+
|-----------|------|---------|-------------|
|
|
642
|
+
| `projectId` | string | required | Project ID, name, or path |
|
|
643
|
+
| `type` | enum | "all" | Detection type: "structural", "semantic", "all" |
|
|
644
|
+
| `scope` | enum | "all" | Scope: "methods", "functions", "classes", "all" |
|
|
645
|
+
| `minSimilarity` | number | 0.8 | Minimum similarity threshold (0.5-1.0) |
|
|
646
|
+
| `maxResults` | number | 50 | Maximum duplicate groups to return |
|
|
647
|
+
| `includeCode` | boolean | true | Include source code snippets |
|
|
648
|
+
| `summaryOnly` | boolean | false | Return only statistics |
|
|
649
|
+
|
|
650
|
+
**Response Structure:**
|
|
651
|
+
```json
|
|
652
|
+
{
|
|
653
|
+
"summary": "Found 8 duplicate code groups across 12 files",
|
|
654
|
+
"statistics": {
|
|
655
|
+
"totalGroups": 8,
|
|
656
|
+
"totalDuplicates": 24,
|
|
657
|
+
"byType": {
|
|
658
|
+
"structural": { "groups": 3, "items": 9 },
|
|
659
|
+
"semantic": { "groups": 5, "items": 15 }
|
|
660
|
+
},
|
|
661
|
+
"byConfidence": { "HIGH": 4, "MEDIUM": 3, "LOW": 1 }
|
|
662
|
+
},
|
|
663
|
+
"duplicates": [
|
|
664
|
+
{
|
|
665
|
+
"groupId": "dup_1",
|
|
666
|
+
"type": "structural",
|
|
667
|
+
"similarity": 1.0,
|
|
668
|
+
"confidence": "HIGH",
|
|
669
|
+
"category": "cross-file",
|
|
670
|
+
"recommendation": "Extract to shared utility",
|
|
671
|
+
"items": [
|
|
672
|
+
{
|
|
673
|
+
"nodeId": "proj_xxx:MethodDeclaration:abc",
|
|
674
|
+
"name": "formatDate",
|
|
675
|
+
"filePath": "/src/utils/date.ts",
|
|
676
|
+
"lineNumber": 15,
|
|
677
|
+
"sourceCode": "formatDate(date: Date): string { ... }"
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
"nodeId": "proj_xxx:MethodDeclaration:def",
|
|
681
|
+
"name": "formatDate",
|
|
682
|
+
"filePath": "/src/helpers/formatting.ts",
|
|
683
|
+
"lineNumber": 42,
|
|
684
|
+
"sourceCode": "formatDate(date: Date): string { ... }"
|
|
685
|
+
}
|
|
686
|
+
]
|
|
687
|
+
}
|
|
688
|
+
]
|
|
689
|
+
}
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
**Detection Types:**
|
|
693
|
+
- **Structural**: Identical normalized code (same AST after removing comments, normalizing names)
|
|
694
|
+
- **Semantic**: Similar logic via vector embeddings (requires embeddings enabled during parse)
|
|
695
|
+
|
|
696
|
+
**Categories:**
|
|
697
|
+
- `ui-component`: Duplicates in UI component directories
|
|
698
|
+
- `cross-app`: Duplicates across monorepo apps
|
|
699
|
+
- `same-file`: Duplicates within the same file
|
|
700
|
+
- `cross-file`: Duplicates across different files
|
|
701
|
+
|
|
702
|
+
```typescript
|
|
703
|
+
// Find all duplicates
|
|
704
|
+
await mcp.call('detect_duplicate_code', {
|
|
705
|
+
projectId: 'my-backend'
|
|
706
|
+
});
|
|
707
|
+
|
|
708
|
+
// Only structural duplicates in methods
|
|
709
|
+
await mcp.call('detect_duplicate_code', {
|
|
710
|
+
projectId: 'my-backend',
|
|
711
|
+
type: 'structural',
|
|
712
|
+
scope: 'methods'
|
|
713
|
+
});
|
|
714
|
+
|
|
715
|
+
// High similarity semantic duplicates
|
|
716
|
+
await mcp.call('detect_duplicate_code', {
|
|
717
|
+
projectId: 'my-backend',
|
|
718
|
+
type: 'semantic',
|
|
719
|
+
minSimilarity: 0.9
|
|
720
|
+
});
|
|
721
|
+
```
|
|
722
|
+
|
|
723
|
+
#### 7. File Watching Tools
|
|
566
724
|
**Purpose**: Monitor file changes and automatically update the graph.
|
|
567
725
|
|
|
568
726
|
```typescript
|
|
@@ -601,6 +759,67 @@ await mcp.call('stop_watch_project', {
|
|
|
601
759
|
- 1000 pending events per watcher
|
|
602
760
|
- Graceful cleanup on server shutdown
|
|
603
761
|
|
|
762
|
+
#### 8. Swarm Coordination Tools
|
|
763
|
+
**Purpose**: Enable multiple parallel agents to coordinate work through stigmergic pheromone markers in the code graph—no direct messaging needed.
|
|
764
|
+
|
|
765
|
+
**Core Concepts:**
|
|
766
|
+
- **Pheromones**: Markers attached to graph nodes that decay over time
|
|
767
|
+
- **swarmId**: Groups related agents for bulk cleanup when done
|
|
768
|
+
- **Workflow States**: `exploring`, `claiming`, `modifying`, `completed`, `blocked` (mutually exclusive per agent+node)
|
|
769
|
+
- **Flags**: `warning`, `proposal`, `needs_review` (can coexist with workflow states)
|
|
770
|
+
|
|
771
|
+
**Pheromone Types & Decay:**
|
|
772
|
+
| Type | Half-Life | Use |
|
|
773
|
+
|------|-----------|-----|
|
|
774
|
+
| `exploring` | 2 min | Browsing/reading |
|
|
775
|
+
| `modifying` | 10 min | Active work |
|
|
776
|
+
| `claiming` | 1 hour | Ownership |
|
|
777
|
+
| `completed` | 24 hours | Done |
|
|
778
|
+
| `warning` | Never | Danger |
|
|
779
|
+
| `blocked` | 5 min | Stuck |
|
|
780
|
+
| `proposal` | 1 hour | Awaiting approval |
|
|
781
|
+
| `needs_review` | 30 min | Review requested |
|
|
782
|
+
|
|
783
|
+
```typescript
|
|
784
|
+
// Orchestrator: Generate swarm ID and spawn agents
|
|
785
|
+
const swarmId = `swarm_${Date.now()}`;
|
|
786
|
+
|
|
787
|
+
// Agent: Check what's claimed before working
|
|
788
|
+
await mcp.call('swarm_sense', {
|
|
789
|
+
projectId: 'my-backend',
|
|
790
|
+
swarmId,
|
|
791
|
+
types: ['claiming', 'modifying']
|
|
792
|
+
});
|
|
793
|
+
|
|
794
|
+
// Agent: Claim a node before working
|
|
795
|
+
await mcp.call('swarm_pheromone', {
|
|
796
|
+
projectId: 'my-backend',
|
|
797
|
+
nodeId: 'proj_xxx:ClassDeclaration:abc123', // From search_codebase or traverse_from_node
|
|
798
|
+
type: 'claiming',
|
|
799
|
+
agentId: 'agent_1',
|
|
800
|
+
swarmId
|
|
801
|
+
});
|
|
802
|
+
|
|
803
|
+
// Agent: Mark complete when done
|
|
804
|
+
await mcp.call('swarm_pheromone', {
|
|
805
|
+
projectId: 'my-backend',
|
|
806
|
+
nodeId: 'proj_xxx:ClassDeclaration:abc123',
|
|
807
|
+
type: 'completed',
|
|
808
|
+
agentId: 'agent_1',
|
|
809
|
+
swarmId,
|
|
810
|
+
data: { summary: 'Added soft delete support' }
|
|
811
|
+
});
|
|
812
|
+
|
|
813
|
+
// Orchestrator: Clean up when swarm is done
|
|
814
|
+
await mcp.call('swarm_cleanup', {
|
|
815
|
+
projectId: 'my-backend',
|
|
816
|
+
swarmId,
|
|
817
|
+
keepTypes: ['warning'] // Preserve warnings
|
|
818
|
+
});
|
|
819
|
+
```
|
|
820
|
+
|
|
821
|
+
**Important**: Node IDs must come from graph tool responses (`search_codebase`, `traverse_from_node`). Never fabricate node IDs—they are hash-based strings like `proj_xxx:ClassDeclaration:abc123`.
|
|
822
|
+
|
|
604
823
|
### Workflow Examples
|
|
605
824
|
|
|
606
825
|
#### Example 1: Understanding Authentication Flow
|
package/dist/constants.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
export const MAX_TRAVERSAL_DEPTH = 5;
|
|
2
|
+
// Logging Configuration (shared between core and mcp)
|
|
3
|
+
export const LOG_CONFIG = {
|
|
4
|
+
debugLogFile: 'debug-search.log',
|
|
5
|
+
separator: '---',
|
|
6
|
+
jsonIndent: 2,
|
|
7
|
+
// Alias for backwards compatibility with mcp code
|
|
8
|
+
jsonIndentation: 2,
|
|
9
|
+
};
|
|
2
10
|
// Shared exclude patterns for file parsing and change detection
|
|
3
11
|
// Regex patterns (escaped dots, anchored to end)
|
|
4
12
|
export const EXCLUDE_PATTERNS_REGEX = [
|
|
@@ -9,6 +17,12 @@ export const EXCLUDE_PATTERNS_REGEX = [
|
|
|
9
17
|
'\\.d\\.ts$',
|
|
10
18
|
'\\.spec\\.ts$',
|
|
11
19
|
'\\.test\\.ts$',
|
|
20
|
+
// Common config and test infrastructure files
|
|
21
|
+
'jest\\.config\\.ts$',
|
|
22
|
+
'-e2e/',
|
|
23
|
+
'test-setup\\.ts$',
|
|
24
|
+
'global-setup\\.ts$',
|
|
25
|
+
'global-teardown\\.ts$',
|
|
12
26
|
];
|
|
13
27
|
// Glob patterns for use with glob library
|
|
14
28
|
export const EXCLUDE_PATTERNS_GLOB = [
|
|
@@ -19,4 +33,157 @@ export const EXCLUDE_PATTERNS_GLOB = [
|
|
|
19
33
|
'**/*.d.ts',
|
|
20
34
|
'**/*.spec.ts',
|
|
21
35
|
'**/*.test.ts',
|
|
36
|
+
// Common config and test infrastructure files
|
|
37
|
+
'**/jest.config.ts',
|
|
38
|
+
'**/*-e2e/**',
|
|
39
|
+
'**/test-setup.ts',
|
|
40
|
+
'**/global-setup.ts',
|
|
41
|
+
'**/global-teardown.ts',
|
|
22
42
|
];
|
|
43
|
+
// ============================================
|
|
44
|
+
// CALLS Edge Detection - Built-in Identifiers
|
|
45
|
+
// Skip these when extracting CALLS edges to reduce noise
|
|
46
|
+
// ============================================
|
|
47
|
+
/** Built-in function names to skip when extracting CALLS edges */
|
|
48
|
+
export const BUILT_IN_FUNCTIONS = new Set([
|
|
49
|
+
'console',
|
|
50
|
+
'setTimeout',
|
|
51
|
+
'setInterval',
|
|
52
|
+
'clearTimeout',
|
|
53
|
+
'clearInterval',
|
|
54
|
+
'parseInt',
|
|
55
|
+
'parseFloat',
|
|
56
|
+
'isNaN',
|
|
57
|
+
'isFinite',
|
|
58
|
+
'encodeURI',
|
|
59
|
+
'decodeURI',
|
|
60
|
+
'encodeURIComponent',
|
|
61
|
+
'decodeURIComponent',
|
|
62
|
+
'JSON',
|
|
63
|
+
'Math',
|
|
64
|
+
'Date',
|
|
65
|
+
'Object',
|
|
66
|
+
'Array',
|
|
67
|
+
'String',
|
|
68
|
+
'Number',
|
|
69
|
+
'Boolean',
|
|
70
|
+
'Symbol',
|
|
71
|
+
'BigInt',
|
|
72
|
+
'Promise',
|
|
73
|
+
'require',
|
|
74
|
+
'eval',
|
|
75
|
+
]);
|
|
76
|
+
/** Built-in method names to skip when extracting CALLS edges */
|
|
77
|
+
export const BUILT_IN_METHODS = new Set([
|
|
78
|
+
// Array methods
|
|
79
|
+
'push',
|
|
80
|
+
'pop',
|
|
81
|
+
'shift',
|
|
82
|
+
'unshift',
|
|
83
|
+
'slice',
|
|
84
|
+
'splice',
|
|
85
|
+
'concat',
|
|
86
|
+
'join',
|
|
87
|
+
'reverse',
|
|
88
|
+
'sort',
|
|
89
|
+
'indexOf',
|
|
90
|
+
'lastIndexOf',
|
|
91
|
+
'includes',
|
|
92
|
+
'find',
|
|
93
|
+
'findIndex',
|
|
94
|
+
'filter',
|
|
95
|
+
'map',
|
|
96
|
+
'reduce',
|
|
97
|
+
'reduceRight',
|
|
98
|
+
'every',
|
|
99
|
+
'some',
|
|
100
|
+
'forEach',
|
|
101
|
+
'flat',
|
|
102
|
+
'flatMap',
|
|
103
|
+
'fill',
|
|
104
|
+
'entries',
|
|
105
|
+
'keys',
|
|
106
|
+
'values',
|
|
107
|
+
// String methods
|
|
108
|
+
'charAt',
|
|
109
|
+
'charCodeAt',
|
|
110
|
+
'substring',
|
|
111
|
+
'substr',
|
|
112
|
+
'split',
|
|
113
|
+
'trim',
|
|
114
|
+
'trimStart',
|
|
115
|
+
'trimEnd',
|
|
116
|
+
'toLowerCase',
|
|
117
|
+
'toUpperCase',
|
|
118
|
+
'replace',
|
|
119
|
+
'replaceAll',
|
|
120
|
+
'match',
|
|
121
|
+
'search',
|
|
122
|
+
'startsWith',
|
|
123
|
+
'endsWith',
|
|
124
|
+
'padStart',
|
|
125
|
+
'padEnd',
|
|
126
|
+
'repeat',
|
|
127
|
+
// Object methods
|
|
128
|
+
'hasOwnProperty',
|
|
129
|
+
'toString',
|
|
130
|
+
'valueOf',
|
|
131
|
+
'toJSON',
|
|
132
|
+
// Promise methods
|
|
133
|
+
'then',
|
|
134
|
+
'catch',
|
|
135
|
+
'finally',
|
|
136
|
+
// Console methods
|
|
137
|
+
'log',
|
|
138
|
+
'error',
|
|
139
|
+
'warn',
|
|
140
|
+
'info',
|
|
141
|
+
'debug',
|
|
142
|
+
'trace',
|
|
143
|
+
'dir',
|
|
144
|
+
'table',
|
|
145
|
+
// Common utilities
|
|
146
|
+
'bind',
|
|
147
|
+
'call',
|
|
148
|
+
'apply',
|
|
149
|
+
]);
|
|
150
|
+
/** Built-in class names to skip when extracting constructor calls */
|
|
151
|
+
export const BUILT_IN_CLASSES = new Set([
|
|
152
|
+
'Array',
|
|
153
|
+
'Object',
|
|
154
|
+
'String',
|
|
155
|
+
'Number',
|
|
156
|
+
'Boolean',
|
|
157
|
+
'Date',
|
|
158
|
+
'RegExp',
|
|
159
|
+
'Error',
|
|
160
|
+
'TypeError',
|
|
161
|
+
'RangeError',
|
|
162
|
+
'SyntaxError',
|
|
163
|
+
'ReferenceError',
|
|
164
|
+
'Map',
|
|
165
|
+
'Set',
|
|
166
|
+
'WeakMap',
|
|
167
|
+
'WeakSet',
|
|
168
|
+
'Promise',
|
|
169
|
+
'Proxy',
|
|
170
|
+
'Reflect',
|
|
171
|
+
'Symbol',
|
|
172
|
+
'BigInt',
|
|
173
|
+
'ArrayBuffer',
|
|
174
|
+
'DataView',
|
|
175
|
+
'Int8Array',
|
|
176
|
+
'Uint8Array',
|
|
177
|
+
'Int16Array',
|
|
178
|
+
'Uint16Array',
|
|
179
|
+
'Int32Array',
|
|
180
|
+
'Uint32Array',
|
|
181
|
+
'Float32Array',
|
|
182
|
+
'Float64Array',
|
|
183
|
+
'URL',
|
|
184
|
+
'URLSearchParams',
|
|
185
|
+
'TextEncoder',
|
|
186
|
+
'TextDecoder',
|
|
187
|
+
'Buffer',
|
|
188
|
+
'EventEmitter',
|
|
189
|
+
]);
|
|
@@ -311,11 +311,12 @@ export const FAIRSQUARE_FRAMEWORK_SCHEMA = {
|
|
|
311
311
|
}
|
|
312
312
|
if (vendorName) {
|
|
313
313
|
// Initialize map if not exists
|
|
314
|
+
// Store nodeId (string) for serialization support in parallel parsing
|
|
314
315
|
if (!sharedContext?.has('vendorControllers')) {
|
|
315
316
|
sharedContext?.set('vendorControllers', new Map());
|
|
316
317
|
}
|
|
317
318
|
const vendorControllerMap = sharedContext?.get('vendorControllers');
|
|
318
|
-
vendorControllerMap.set(vendorName, parsedNode);
|
|
319
|
+
vendorControllerMap.set(vendorName, parsedNode.id);
|
|
319
320
|
}
|
|
320
321
|
}
|
|
321
322
|
return {};
|
|
@@ -747,14 +748,14 @@ export const FAIRSQUARE_FRAMEWORK_SCHEMA = {
|
|
|
747
748
|
const isTargetController = parsedTargetNode.semanticType === FairSquareSemanticNodeType.FS_CONTROLLER;
|
|
748
749
|
if (!isSourceService || !isTargetController)
|
|
749
750
|
return false;
|
|
750
|
-
// Get vendor controller map
|
|
751
|
+
// Get vendor controller map (stores vendorName → nodeId for serialization)
|
|
751
752
|
const vendorControllerMap = sharedContext?.get('vendorControllers');
|
|
752
753
|
if (!vendorControllerMap)
|
|
753
754
|
return false;
|
|
754
|
-
// Check if target is a vendor controller
|
|
755
|
+
// Check if target is a vendor controller by matching nodeId
|
|
755
756
|
let vendorName = '';
|
|
756
|
-
for (const [name,
|
|
757
|
-
if (
|
|
757
|
+
for (const [name, nodeId] of vendorControllerMap) {
|
|
758
|
+
if (nodeId === parsedTargetNode.id) {
|
|
758
759
|
vendorName = name;
|
|
759
760
|
break;
|
|
760
761
|
}
|
|
@@ -768,10 +769,11 @@ export const FAIRSQUARE_FRAMEWORK_SCHEMA = {
|
|
|
768
769
|
return propertyTypes.includes(expectedClientName);
|
|
769
770
|
},
|
|
770
771
|
contextExtractor: (parsedSourceNode, parsedTargetNode, allParsedNodes, sharedContext) => {
|
|
772
|
+
// Map stores vendorName → nodeId
|
|
771
773
|
const vendorControllerMap = sharedContext?.get('vendorControllers');
|
|
772
774
|
let vendorName = '';
|
|
773
|
-
for (const [name,
|
|
774
|
-
if (
|
|
775
|
+
for (const [name, nodeId] of vendorControllerMap) {
|
|
776
|
+
if (nodeId === parsedTargetNode.id) {
|
|
775
777
|
vendorName = name;
|
|
776
778
|
break;
|
|
777
779
|
}
|
|
@@ -17,6 +17,7 @@ export var CoreNodeType;
|
|
|
17
17
|
CoreNodeType["ENUM_DECLARATION"] = "EnumDeclaration";
|
|
18
18
|
CoreNodeType["FUNCTION_DECLARATION"] = "FunctionDeclaration";
|
|
19
19
|
CoreNodeType["VARIABLE_DECLARATION"] = "VariableDeclaration";
|
|
20
|
+
CoreNodeType["TYPE_ALIAS"] = "TypeAlias";
|
|
20
21
|
// Class Members
|
|
21
22
|
CoreNodeType["METHOD_DECLARATION"] = "MethodDeclaration";
|
|
22
23
|
CoreNodeType["PROPERTY_DECLARATION"] = "PropertyDeclaration";
|
|
@@ -118,6 +119,7 @@ export const CORE_TYPESCRIPT_SCHEMA = {
|
|
|
118
119
|
[CoreNodeType.FUNCTION_DECLARATION]: 'getFunctions',
|
|
119
120
|
[CoreNodeType.IMPORT_DECLARATION]: 'getImportDeclarations',
|
|
120
121
|
[CoreNodeType.VARIABLE_DECLARATION]: 'getDeclarations', // Called on VariableStatement
|
|
122
|
+
[CoreNodeType.TYPE_ALIAS]: 'getTypeAliases',
|
|
121
123
|
[CoreNodeType.ENUM_DECLARATION]: 'getEnums',
|
|
122
124
|
[CoreNodeType.CONSTRUCTOR_DECLARATION]: 'getConstructors',
|
|
123
125
|
[CoreNodeType.EXPORT_DECLARATION]: 'getExportDeclarations',
|
|
@@ -154,6 +156,8 @@ export const CORE_TYPESCRIPT_SCHEMA = {
|
|
|
154
156
|
[CoreNodeType.FUNCTION_DECLARATION]: CoreEdgeType.CONTAINS,
|
|
155
157
|
[CoreNodeType.IMPORT_DECLARATION]: CoreEdgeType.CONTAINS,
|
|
156
158
|
[CoreNodeType.ENUM_DECLARATION]: CoreEdgeType.CONTAINS,
|
|
159
|
+
[CoreNodeType.VARIABLE_DECLARATION]: CoreEdgeType.CONTAINS,
|
|
160
|
+
[CoreNodeType.TYPE_ALIAS]: CoreEdgeType.CONTAINS,
|
|
157
161
|
},
|
|
158
162
|
neo4j: {
|
|
159
163
|
labels: ['SourceFile', 'TypeScript'],
|
|
@@ -470,6 +474,12 @@ export const CORE_TYPESCRIPT_SCHEMA = {
|
|
|
470
474
|
extraction: { method: 'ast', source: 'getName' },
|
|
471
475
|
neo4j: { indexed: true, unique: false, required: true },
|
|
472
476
|
},
|
|
477
|
+
{
|
|
478
|
+
name: 'isExported',
|
|
479
|
+
type: 'boolean',
|
|
480
|
+
extraction: { method: 'static', defaultValue: false }, // We'll set this manually
|
|
481
|
+
neo4j: { indexed: true, unique: false, required: true },
|
|
482
|
+
},
|
|
473
483
|
],
|
|
474
484
|
relationships: [],
|
|
475
485
|
children: {},
|
|
@@ -480,6 +490,27 @@ export const CORE_TYPESCRIPT_SCHEMA = {
|
|
|
480
490
|
skipEmbedding: true,
|
|
481
491
|
},
|
|
482
492
|
},
|
|
493
|
+
[CoreNodeType.TYPE_ALIAS]: {
|
|
494
|
+
coreType: CoreNodeType.TYPE_ALIAS,
|
|
495
|
+
astNodeKind: 265,
|
|
496
|
+
astGetter: 'getTypeAliases',
|
|
497
|
+
properties: [
|
|
498
|
+
{
|
|
499
|
+
name: 'name',
|
|
500
|
+
type: 'string',
|
|
501
|
+
extraction: { method: 'ast', source: 'getName' },
|
|
502
|
+
neo4j: { indexed: true, unique: false, required: true },
|
|
503
|
+
},
|
|
504
|
+
],
|
|
505
|
+
relationships: [],
|
|
506
|
+
children: {},
|
|
507
|
+
neo4j: {
|
|
508
|
+
labels: ['TypeAlias', 'TypeScript'],
|
|
509
|
+
primaryLabel: 'TypeAlias',
|
|
510
|
+
indexed: ['name'],
|
|
511
|
+
skipEmbedding: true,
|
|
512
|
+
},
|
|
513
|
+
},
|
|
483
514
|
[CoreNodeType.CONSTRUCTOR_DECLARATION]: {
|
|
484
515
|
coreType: CoreNodeType.CONSTRUCTOR_DECLARATION,
|
|
485
516
|
astNodeKind: 175,
|
|
@@ -767,8 +798,16 @@ export const CORE_TYPESCRIPT_SCHEMA = {
|
|
|
767
798
|
},
|
|
768
799
|
[CoreEdgeType.CALLS]: {
|
|
769
800
|
coreType: CoreEdgeType.CALLS,
|
|
770
|
-
sourceTypes: [
|
|
771
|
-
|
|
801
|
+
sourceTypes: [
|
|
802
|
+
CoreNodeType.METHOD_DECLARATION,
|
|
803
|
+
CoreNodeType.FUNCTION_DECLARATION,
|
|
804
|
+
CoreNodeType.CONSTRUCTOR_DECLARATION,
|
|
805
|
+
],
|
|
806
|
+
targetTypes: [
|
|
807
|
+
CoreNodeType.METHOD_DECLARATION,
|
|
808
|
+
CoreNodeType.FUNCTION_DECLARATION,
|
|
809
|
+
CoreNodeType.CONSTRUCTOR_DECLARATION,
|
|
810
|
+
],
|
|
772
811
|
properties: [
|
|
773
812
|
{
|
|
774
813
|
name: 'confidence',
|