mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-29 06:32:28 +00:00
fixed: S-queries modified to support arrow functions
This commit is contained in:
parent
27e656e203
commit
efc784915e
5 changed files with 82 additions and 23 deletions
|
|
@ -5,23 +5,23 @@ import { useAppState } from '../hooks/useAppState';
|
|||
const EXAMPLE_QUERIES = [
|
||||
{
|
||||
label: 'All Functions',
|
||||
query: `MATCH (n:CodeNode) WHERE n.label = 'Function' RETURN n.id AS id, n.name AS name, n.filePath AS path`,
|
||||
query: `MATCH (n:Function) RETURN n.id AS id, n.name AS name, n.filePath AS path LIMIT 50`,
|
||||
},
|
||||
{
|
||||
label: 'All Classes',
|
||||
query: `MATCH (n:CodeNode) WHERE n.label = 'Class' RETURN n.id AS id, n.name AS name, n.filePath AS path`,
|
||||
query: `MATCH (n:Class) RETURN n.id AS id, n.name AS name, n.filePath AS path LIMIT 50`,
|
||||
},
|
||||
{
|
||||
label: 'All Interfaces',
|
||||
query: `MATCH (n:CodeNode) WHERE n.label = 'Interface' RETURN n.id AS id, n.name AS name, n.filePath AS path`,
|
||||
query: `MATCH (n:Interface) RETURN n.id AS id, n.name AS name, n.filePath AS path LIMIT 50`,
|
||||
},
|
||||
{
|
||||
label: 'Function Calls',
|
||||
query: `MATCH (a:CodeNode)-[r:CodeRelation]->(b:CodeNode) WHERE r.type = 'CALLS' RETURN a.id AS id, a.name AS caller, b.name AS callee LIMIT 50`,
|
||||
query: `MATCH (a:File)-[r:CodeRelation {type: 'CALLS'}]->(b:Function) RETURN a.id AS id, a.name AS caller, b.name AS callee LIMIT 50`,
|
||||
},
|
||||
{
|
||||
label: 'Import Dependencies',
|
||||
query: `MATCH (a:CodeNode)-[r:CodeRelation]->(b:CodeNode) WHERE r.type = 'IMPORTS' RETURN a.id AS id, a.name AS from, b.name AS imports LIMIT 50`,
|
||||
query: `MATCH (a:File)-[r:CodeRelation {type: 'IMPORTS'}]->(b:File) RETURN a.id AS id, a.name AS from, b.name AS imports LIMIT 50`,
|
||||
},
|
||||
];
|
||||
|
||||
|
|
@ -203,7 +203,7 @@ export const QueryFAB = () => {
|
|||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
onKeyDown={handleKeyDown}
|
||||
placeholder="MATCH (n:CodeNode) WHERE n.label = 'Function' RETURN n"
|
||||
placeholder="MATCH (n:Function) RETURN n.name, n.filePath LIMIT 10"
|
||||
rows={3}
|
||||
className="
|
||||
w-full px-3 py-2.5
|
||||
|
|
|
|||
|
|
@ -161,9 +161,12 @@ export const ToolCallCard = ({ toolCall, defaultExpanded = false }: ToolCallCard
|
|||
return (
|
||||
<div className={`rounded-lg border ${status.borderColor} ${status.bgColor} overflow-hidden transition-all`}>
|
||||
{/* Header - always visible */}
|
||||
<button
|
||||
<div
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
onClick={() => setIsExpanded(!isExpanded)}
|
||||
className="w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-white/5 transition-colors"
|
||||
onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); setIsExpanded(!isExpanded); } }}
|
||||
className="w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-white/5 transition-colors cursor-pointer select-none"
|
||||
>
|
||||
{/* Expand/collapse icon */}
|
||||
<span className="text-text-muted">
|
||||
|
|
@ -204,7 +207,7 @@ export const ToolCallCard = ({ toolCall, defaultExpanded = false }: ToolCallCard
|
|||
{status.icon}
|
||||
<span className="capitalize">{toolCall.status}</span>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Expanded content */}
|
||||
{isExpanded && (
|
||||
|
|
|
|||
|
|
@ -22,6 +22,28 @@ export const TYPESCRIPT_QUERIES = `
|
|||
(method_definition
|
||||
name: (property_identifier) @name) @definition.method
|
||||
|
||||
(lexical_declaration
|
||||
(variable_declarator
|
||||
name: (identifier) @name
|
||||
value: (arrow_function))) @definition.function
|
||||
|
||||
(lexical_declaration
|
||||
(variable_declarator
|
||||
name: (identifier) @name
|
||||
value: (function_expression))) @definition.function
|
||||
|
||||
(export_statement
|
||||
declaration: (lexical_declaration
|
||||
(variable_declarator
|
||||
name: (identifier) @name
|
||||
value: (arrow_function)))) @definition.function
|
||||
|
||||
(export_statement
|
||||
declaration: (lexical_declaration
|
||||
(variable_declarator
|
||||
name: (identifier) @name
|
||||
value: (function_expression)))) @definition.function
|
||||
|
||||
(import_statement
|
||||
source: (string) @import.source) @import
|
||||
|
||||
|
|
@ -44,6 +66,28 @@ export const JAVASCRIPT_QUERIES = `
|
|||
(method_definition
|
||||
name: (property_identifier) @name) @definition.method
|
||||
|
||||
(lexical_declaration
|
||||
(variable_declarator
|
||||
name: (identifier) @name
|
||||
value: (arrow_function))) @definition.function
|
||||
|
||||
(lexical_declaration
|
||||
(variable_declarator
|
||||
name: (identifier) @name
|
||||
value: (function_expression))) @definition.function
|
||||
|
||||
(export_statement
|
||||
declaration: (lexical_declaration
|
||||
(variable_declarator
|
||||
name: (identifier) @name
|
||||
value: (arrow_function)))) @definition.function
|
||||
|
||||
(export_statement
|
||||
declaration: (lexical_declaration
|
||||
(variable_declarator
|
||||
name: (identifier) @name
|
||||
value: (function_expression)))) @definition.function
|
||||
|
||||
(import_statement
|
||||
source: (string) @import.source) @import
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
import { tool } from '@langchain/core/tools';
|
||||
import { z } from 'zod';
|
||||
import { GRAPH_SCHEMA_DESCRIPTION } from './types';
|
||||
// Note: GRAPH_SCHEMA_DESCRIPTION from './types' is available if needed for additional context
|
||||
import { WebGPUNotAvailableError, embedText, embeddingToArray, initEmbedder, isEmbedderReady } from '../embeddings/embedder';
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -258,11 +258,15 @@ NODE TABLES:
|
|||
- nodeId: STRING (primary key)
|
||||
- embedding: FLOAT[384]
|
||||
|
||||
RELATIONSHIP TABLES:
|
||||
1. CONTAINS (Folder->Folder, Folder->File)
|
||||
2. DEFINES (File->Function, File->Class, File->Interface, File->Method, File->CodeElement)
|
||||
3. IMPORTS (File->File)
|
||||
4. CALLS (File->Function, File->Method)
|
||||
RELATIONSHIP TABLE:
|
||||
CodeRelation - Single table with 'type' property connecting all node tables
|
||||
- type: STRING (values: CONTAINS, DEFINES, IMPORTS, CALLS)
|
||||
|
||||
Connection patterns:
|
||||
- CONTAINS: Folder->Folder, Folder->File
|
||||
- DEFINES: File->Function, File->Class, File->Interface, File->Method, File->CodeElement
|
||||
- IMPORTS: File->File
|
||||
- CALLS: File->Function, File->Method, Function->Function, Function->Method
|
||||
|
||||
QUERY PATTERNS:
|
||||
|
||||
|
|
@ -270,19 +274,23 @@ QUERY PATTERNS:
|
|||
MATCH (f:Function) RETURN f.name, f.filePath LIMIT 10
|
||||
|
||||
2. Find what a file defines:
|
||||
MATCH (f:File)-[:DEFINES]->(fn:Function)
|
||||
MATCH (f:File)-[:CodeRelation {type: 'DEFINES'}]->(fn:Function)
|
||||
WHERE f.name = 'utils.ts'
|
||||
RETURN fn.name
|
||||
|
||||
3. Find function callers:
|
||||
MATCH (caller:File)-[:CALLS]->(fn:Function {name: 'myFunction'})
|
||||
MATCH (caller:File)-[:CodeRelation {type: 'CALLS'}]->(fn:Function {name: 'myFunction'})
|
||||
RETURN caller.name, caller.filePath
|
||||
|
||||
4. Find imports:
|
||||
MATCH (f:File {name: 'main.ts'})-[:IMPORTS]->(imported:File)
|
||||
MATCH (f:File {name: 'main.ts'})-[:CodeRelation {type: 'IMPORTS'}]->(imported:File)
|
||||
RETURN imported.name
|
||||
|
||||
5. SEMANTIC SEARCH (embeddings in separate table - MUST JOIN):
|
||||
5. Find files that import a specific file:
|
||||
MATCH (f:File)-[:CodeRelation {type: 'IMPORTS'}]->(target:File {name: 'utils.ts'})
|
||||
RETURN f.name, f.filePath
|
||||
|
||||
6. SEMANTIC SEARCH (embeddings in separate table - MUST JOIN):
|
||||
CALL QUERY_VECTOR_INDEX('CodeEmbedding', 'code_embedding_idx', $queryVector, 10)
|
||||
YIELD node AS emb, distance
|
||||
WITH emb, distance
|
||||
|
|
@ -291,23 +299,27 @@ QUERY PATTERNS:
|
|||
RETURN n.name, n.filePath, distance
|
||||
ORDER BY distance
|
||||
|
||||
6. Search across all code types (use UNION or separate queries):
|
||||
7. Search across all code types (use UNION or separate queries):
|
||||
MATCH (f:Function) WHERE f.name CONTAINS 'auth' RETURN f.id, f.name, 'Function' AS type
|
||||
UNION ALL
|
||||
MATCH (c:Class) WHERE c.name CONTAINS 'auth' RETURN c.id, c.name, 'Class' AS type
|
||||
|
||||
7. Folder structure:
|
||||
MATCH (parent:Folder)-[:CONTAINS]->(child)
|
||||
8. Folder structure:
|
||||
MATCH (parent:Folder)-[:CodeRelation {type: 'CONTAINS'}]->(child)
|
||||
WHERE parent.name = 'src'
|
||||
RETURN child.name, labels(child)[0] AS type
|
||||
|
||||
9. Get all connections for a node:
|
||||
MATCH (f:File {name: 'index.ts'})-[r:CodeRelation]-(m)
|
||||
RETURN m.name, r.type
|
||||
|
||||
TOOLING NOTE (for execute_vector_cypher):
|
||||
- Write Cypher containing {{QUERY_VECTOR}} where the vector should go.
|
||||
- The tool will replace {{QUERY_VECTOR}} with CAST([..] AS FLOAT[384]).
|
||||
|
||||
NOTES:
|
||||
- Use proper table names: File, Folder, Function, Class, Interface, Method, CodeElement
|
||||
- Relationship labels are: CONTAINS, DEFINES, IMPORTS, CALLS
|
||||
- Use CodeRelation with type property: [:CodeRelation {type: 'DEFINES'}]
|
||||
- For vector search, join CodeEmbedding.nodeId to the appropriate table's id
|
||||
- Use LIMIT to avoid returning too many results
|
||||
`;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue