lance-context 0.1.0 → 1.0.1
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 +232 -23
- package/dist/__tests__/ast-chunker.test.d.ts +2 -0
- package/dist/__tests__/ast-chunker.test.d.ts.map +1 -0
- package/dist/__tests__/ast-chunker.test.js +307 -0
- package/dist/__tests__/ast-chunker.test.js.map +1 -0
- package/dist/__tests__/config.test.d.ts +2 -0
- package/dist/__tests__/config.test.d.ts.map +1 -0
- package/dist/__tests__/config.test.js +242 -0
- package/dist/__tests__/config.test.js.map +1 -0
- package/dist/__tests__/dashboard/beads.test.d.ts +2 -0
- package/dist/__tests__/dashboard/beads.test.d.ts.map +1 -0
- package/dist/__tests__/dashboard/beads.test.js +151 -0
- package/dist/__tests__/dashboard/beads.test.js.map +1 -0
- package/dist/__tests__/dashboard/index.test.d.ts +2 -0
- package/dist/__tests__/dashboard/index.test.d.ts.map +1 -0
- package/dist/__tests__/dashboard/index.test.js +116 -0
- package/dist/__tests__/dashboard/index.test.js.map +1 -0
- package/dist/__tests__/dashboard/routes.test.d.ts +2 -0
- package/dist/__tests__/dashboard/routes.test.d.ts.map +1 -0
- package/dist/__tests__/dashboard/routes.test.js +125 -0
- package/dist/__tests__/dashboard/routes.test.js.map +1 -0
- package/dist/__tests__/dashboard/server.test.d.ts +2 -0
- package/dist/__tests__/dashboard/server.test.d.ts.map +1 -0
- package/dist/__tests__/dashboard/server.test.js +75 -0
- package/dist/__tests__/dashboard/server.test.js.map +1 -0
- package/dist/__tests__/dashboard/state.test.d.ts +2 -0
- package/dist/__tests__/dashboard/state.test.d.ts.map +1 -0
- package/dist/__tests__/dashboard/state.test.js +124 -0
- package/dist/__tests__/dashboard/state.test.js.map +1 -0
- package/dist/__tests__/embeddings/factory.test.d.ts +2 -0
- package/dist/__tests__/embeddings/factory.test.d.ts.map +1 -0
- package/dist/__tests__/embeddings/factory.test.js +100 -0
- package/dist/__tests__/embeddings/factory.test.js.map +1 -0
- package/dist/__tests__/embeddings/jina.test.d.ts +2 -0
- package/dist/__tests__/embeddings/jina.test.d.ts.map +1 -0
- package/dist/__tests__/embeddings/jina.test.js +156 -0
- package/dist/__tests__/embeddings/jina.test.js.map +1 -0
- package/dist/__tests__/embeddings/ollama.test.d.ts +2 -0
- package/dist/__tests__/embeddings/ollama.test.d.ts.map +1 -0
- package/dist/__tests__/embeddings/ollama.test.js +172 -0
- package/dist/__tests__/embeddings/ollama.test.js.map +1 -0
- package/dist/__tests__/embeddings/rate-limiter.test.d.ts +2 -0
- package/dist/__tests__/embeddings/rate-limiter.test.d.ts.map +1 -0
- package/dist/__tests__/embeddings/rate-limiter.test.js +163 -0
- package/dist/__tests__/embeddings/rate-limiter.test.js.map +1 -0
- package/dist/__tests__/embeddings/retry.test.d.ts +2 -0
- package/dist/__tests__/embeddings/retry.test.d.ts.map +1 -0
- package/dist/__tests__/embeddings/retry.test.js +260 -0
- package/dist/__tests__/embeddings/retry.test.js.map +1 -0
- package/dist/__tests__/embeddings/types.test.d.ts +2 -0
- package/dist/__tests__/embeddings/types.test.d.ts.map +1 -0
- package/dist/__tests__/embeddings/types.test.js +31 -0
- package/dist/__tests__/embeddings/types.test.js.map +1 -0
- package/dist/__tests__/mocks/embedding-backend.mock.d.ts +10 -0
- package/dist/__tests__/mocks/embedding-backend.mock.d.ts.map +1 -0
- package/dist/__tests__/mocks/embedding-backend.mock.js +39 -0
- package/dist/__tests__/mocks/embedding-backend.mock.js.map +1 -0
- package/dist/__tests__/mocks/fetch.mock.d.ts +38 -0
- package/dist/__tests__/mocks/fetch.mock.d.ts.map +1 -0
- package/dist/__tests__/mocks/fetch.mock.js +74 -0
- package/dist/__tests__/mocks/fetch.mock.js.map +1 -0
- package/dist/__tests__/mocks/lancedb.mock.d.ts +38 -0
- package/dist/__tests__/mocks/lancedb.mock.d.ts.map +1 -0
- package/dist/__tests__/mocks/lancedb.mock.js +63 -0
- package/dist/__tests__/mocks/lancedb.mock.js.map +1 -0
- package/dist/__tests__/search/clustering.test.d.ts +2 -0
- package/dist/__tests__/search/clustering.test.d.ts.map +1 -0
- package/dist/__tests__/search/clustering.test.js +230 -0
- package/dist/__tests__/search/clustering.test.js.map +1 -0
- package/dist/__tests__/search/hybrid-search.test.d.ts +2 -0
- package/dist/__tests__/search/hybrid-search.test.d.ts.map +1 -0
- package/dist/__tests__/search/hybrid-search.test.js +186 -0
- package/dist/__tests__/search/hybrid-search.test.js.map +1 -0
- package/dist/__tests__/search/indexer.test.d.ts +2 -0
- package/dist/__tests__/search/indexer.test.d.ts.map +1 -0
- package/dist/__tests__/search/indexer.test.js +878 -0
- package/dist/__tests__/search/indexer.test.js.map +1 -0
- package/dist/__tests__/search/tree-sitter-chunker.test.d.ts +2 -0
- package/dist/__tests__/search/tree-sitter-chunker.test.d.ts.map +1 -0
- package/dist/__tests__/search/tree-sitter-chunker.test.js +228 -0
- package/dist/__tests__/search/tree-sitter-chunker.test.js.map +1 -0
- package/dist/__tests__/setup.d.ts +2 -0
- package/dist/__tests__/setup.d.ts.map +1 -0
- package/dist/__tests__/setup.js +11 -0
- package/dist/__tests__/setup.js.map +1 -0
- package/dist/__tests__/utils/concurrency.test.d.ts +2 -0
- package/dist/__tests__/utils/concurrency.test.d.ts.map +1 -0
- package/dist/__tests__/utils/concurrency.test.js +83 -0
- package/dist/__tests__/utils/concurrency.test.js.map +1 -0
- package/dist/__tests__/utils/errors.test.d.ts +2 -0
- package/dist/__tests__/utils/errors.test.d.ts.map +1 -0
- package/dist/__tests__/utils/errors.test.js +136 -0
- package/dist/__tests__/utils/errors.test.js.map +1 -0
- package/dist/__tests__/utils/type-guards.test.d.ts +2 -0
- package/dist/__tests__/utils/type-guards.test.d.ts.map +1 -0
- package/dist/__tests__/utils/type-guards.test.js +80 -0
- package/dist/__tests__/utils/type-guards.test.js.map +1 -0
- package/dist/__tests__/worktree/worktree-manager.test.d.ts +2 -0
- package/dist/__tests__/worktree/worktree-manager.test.d.ts.map +1 -0
- package/dist/__tests__/worktree/worktree-manager.test.js +403 -0
- package/dist/__tests__/worktree/worktree-manager.test.js.map +1 -0
- package/dist/config.d.ts +122 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +508 -0
- package/dist/config.js.map +1 -0
- package/dist/dashboard/beads.d.ts +35 -0
- package/dist/dashboard/beads.d.ts.map +1 -0
- package/dist/dashboard/beads.js +102 -0
- package/dist/dashboard/beads.js.map +1 -0
- package/dist/dashboard/events.d.ts +46 -0
- package/dist/dashboard/events.d.ts.map +1 -0
- package/dist/dashboard/events.js +141 -0
- package/dist/dashboard/events.js.map +1 -0
- package/dist/dashboard/index.d.ts +67 -0
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +90 -0
- package/dist/dashboard/index.js.map +1 -0
- package/dist/dashboard/routes.d.ts +6 -0
- package/dist/dashboard/routes.d.ts.map +1 -0
- package/dist/dashboard/routes.js +244 -0
- package/dist/dashboard/routes.js.map +1 -0
- package/dist/dashboard/server.d.ts +27 -0
- package/dist/dashboard/server.d.ts.map +1 -0
- package/dist/dashboard/server.js +72 -0
- package/dist/dashboard/server.js.map +1 -0
- package/dist/dashboard/state.d.ts +116 -0
- package/dist/dashboard/state.d.ts.map +1 -0
- package/dist/dashboard/state.js +251 -0
- package/dist/dashboard/state.js.map +1 -0
- package/dist/dashboard/ui.d.ts +6 -0
- package/dist/dashboard/ui.d.ts.map +1 -0
- package/dist/dashboard/ui.js +1407 -0
- package/dist/dashboard/ui.js.map +1 -0
- package/dist/embeddings/index.d.ts +20 -2
- package/dist/embeddings/index.d.ts.map +1 -1
- package/dist/embeddings/index.js +49 -6
- package/dist/embeddings/index.js.map +1 -1
- package/dist/embeddings/jina.d.ts +9 -0
- package/dist/embeddings/jina.d.ts.map +1 -1
- package/dist/embeddings/jina.js +42 -2
- package/dist/embeddings/jina.js.map +1 -1
- package/dist/embeddings/ollama.d.ts +2 -0
- package/dist/embeddings/ollama.d.ts.map +1 -1
- package/dist/embeddings/ollama.js +21 -5
- package/dist/embeddings/ollama.js.map +1 -1
- package/dist/embeddings/rate-limiter.d.ts +75 -0
- package/dist/embeddings/rate-limiter.d.ts.map +1 -0
- package/dist/embeddings/rate-limiter.js +145 -0
- package/dist/embeddings/rate-limiter.js.map +1 -0
- package/dist/embeddings/retry.d.ts +14 -0
- package/dist/embeddings/retry.d.ts.map +1 -0
- package/dist/embeddings/retry.js +89 -0
- package/dist/embeddings/retry.js.map +1 -0
- package/dist/embeddings/types.d.ts +56 -2
- package/dist/embeddings/types.d.ts.map +1 -1
- package/dist/embeddings/types.js +16 -0
- package/dist/embeddings/types.js.map +1 -1
- package/dist/index.js +1870 -44
- package/dist/index.js.map +1 -1
- package/dist/memory/index.d.ts +63 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +168 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/search/ast-chunker.d.ts +34 -0
- package/dist/search/ast-chunker.d.ts.map +1 -0
- package/dist/search/ast-chunker.js +261 -0
- package/dist/search/ast-chunker.js.map +1 -0
- package/dist/search/clustering.d.ts +77 -0
- package/dist/search/clustering.d.ts.map +1 -0
- package/dist/search/clustering.js +455 -0
- package/dist/search/clustering.js.map +1 -0
- package/dist/search/indexer.d.ts +239 -3
- package/dist/search/indexer.d.ts.map +1 -1
- package/dist/search/indexer.js +941 -45
- package/dist/search/indexer.js.map +1 -1
- package/dist/search/tree-sitter-chunker.d.ts +69 -0
- package/dist/search/tree-sitter-chunker.d.ts.map +1 -0
- package/dist/search/tree-sitter-chunker.js +436 -0
- package/dist/search/tree-sitter-chunker.js.map +1 -0
- package/dist/symbols/index.d.ts +14 -0
- package/dist/symbols/index.d.ts.map +1 -0
- package/dist/symbols/index.js +19 -0
- package/dist/symbols/index.js.map +1 -0
- package/dist/symbols/name-path.d.ts +113 -0
- package/dist/symbols/name-path.d.ts.map +1 -0
- package/dist/symbols/name-path.js +194 -0
- package/dist/symbols/name-path.js.map +1 -0
- package/dist/symbols/pattern-search.d.ts +14 -0
- package/dist/symbols/pattern-search.d.ts.map +1 -0
- package/dist/symbols/pattern-search.js +224 -0
- package/dist/symbols/pattern-search.js.map +1 -0
- package/dist/symbols/reference-finder.d.ts +38 -0
- package/dist/symbols/reference-finder.d.ts.map +1 -0
- package/dist/symbols/reference-finder.js +376 -0
- package/dist/symbols/reference-finder.js.map +1 -0
- package/dist/symbols/symbol-editor.d.ts +81 -0
- package/dist/symbols/symbol-editor.d.ts.map +1 -0
- package/dist/symbols/symbol-editor.js +257 -0
- package/dist/symbols/symbol-editor.js.map +1 -0
- package/dist/symbols/symbol-extractor.d.ts +49 -0
- package/dist/symbols/symbol-extractor.d.ts.map +1 -0
- package/dist/symbols/symbol-extractor.js +593 -0
- package/dist/symbols/symbol-extractor.js.map +1 -0
- package/dist/symbols/symbol-renamer.d.ts +81 -0
- package/dist/symbols/symbol-renamer.d.ts.map +1 -0
- package/dist/symbols/symbol-renamer.js +204 -0
- package/dist/symbols/symbol-renamer.js.map +1 -0
- package/dist/symbols/types.d.ts +234 -0
- package/dist/symbols/types.d.ts.map +1 -0
- package/dist/symbols/types.js +106 -0
- package/dist/symbols/types.js.map +1 -0
- package/dist/utils/concurrency.d.ts +32 -0
- package/dist/utils/concurrency.d.ts.map +1 -0
- package/dist/utils/concurrency.js +57 -0
- package/dist/utils/concurrency.js.map +1 -0
- package/dist/utils/errors.d.ts +36 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +91 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/type-guards.d.ts +17 -0
- package/dist/utils/type-guards.d.ts.map +1 -0
- package/dist/utils/type-guards.js +25 -0
- package/dist/utils/type-guards.js.map +1 -0
- package/dist/worktree/index.d.ts +6 -0
- package/dist/worktree/index.d.ts.map +1 -0
- package/dist/worktree/index.js +6 -0
- package/dist/worktree/index.js.map +1 -0
- package/dist/worktree/types.d.ts +101 -0
- package/dist/worktree/types.d.ts.map +1 -0
- package/dist/worktree/types.js +6 -0
- package/dist/worktree/types.js.map +1 -0
- package/dist/worktree/worktree-manager.d.ts +80 -0
- package/dist/worktree/worktree-manager.d.ts.map +1 -0
- package/dist/worktree/worktree-manager.js +407 -0
- package/dist/worktree/worktree-manager.js.map +1 -0
- package/package.json +39 -5
- package/scripts/postinstall.js +48 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Symbolic code analysis module.
|
|
3
|
+
* Provides Serena-like symbol navigation and analysis tools.
|
|
4
|
+
*/
|
|
5
|
+
// Types
|
|
6
|
+
export * from './types.js';
|
|
7
|
+
// Name path utilities
|
|
8
|
+
export * from './name-path.js';
|
|
9
|
+
// Symbol extraction
|
|
10
|
+
export { SymbolExtractor } from './symbol-extractor.js';
|
|
11
|
+
// Pattern search
|
|
12
|
+
export { searchForPattern, formatPatternSearchResults } from './pattern-search.js';
|
|
13
|
+
// Reference finding
|
|
14
|
+
export { ReferenceFinder, formatReferencesResult } from './reference-finder.js';
|
|
15
|
+
// Symbol editing
|
|
16
|
+
export { SymbolEditor } from './symbol-editor.js';
|
|
17
|
+
// Symbol renaming
|
|
18
|
+
export { SymbolRenamer, formatRenameResult } from './symbol-renamer.js';
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/symbols/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,QAAQ;AACR,cAAc,YAAY,CAAC;AAE3B,sBAAsB;AACtB,cAAc,gBAAgB,CAAC;AAE/B,oBAAoB;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,iBAAiB;AACjB,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAEnF,oBAAoB;AACpB,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAEhF,iBAAiB;AACjB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,kBAAkB;AAClB,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Name path utilities for parsing and matching hierarchical symbol paths.
|
|
3
|
+
*
|
|
4
|
+
* Name path format:
|
|
5
|
+
* - "/ClassName/methodName" - Absolute path (must match from root)
|
|
6
|
+
* - "ClassName/methodName" - Relative path (matches any suffix)
|
|
7
|
+
* - "methodName" - Simple name (matches any symbol with that name)
|
|
8
|
+
* - "Class/get*" - With glob pattern (substring matching on last element)
|
|
9
|
+
*
|
|
10
|
+
* Uses "/" as separator to match Serena's convention.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Parsed name path pattern for matching.
|
|
14
|
+
*/
|
|
15
|
+
export interface ParsedNamePath {
|
|
16
|
+
/** Whether the path is absolute (starts with /) */
|
|
17
|
+
isAbsolute: boolean;
|
|
18
|
+
/** Path segments */
|
|
19
|
+
segments: string[];
|
|
20
|
+
/** Whether to use substring matching on last segment */
|
|
21
|
+
substringMatch: boolean;
|
|
22
|
+
/** Optional overload index (e.g., [0], [1]) */
|
|
23
|
+
overloadIndex?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Parse a name path pattern into its components.
|
|
27
|
+
*
|
|
28
|
+
* @param pattern - The name path pattern to parse
|
|
29
|
+
* @returns Parsed pattern components
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* parseNamePath("/MyClass/myMethod") // absolute path
|
|
33
|
+
* parseNamePath("MyClass/myMethod") // relative path
|
|
34
|
+
* parseNamePath("myMethod") // simple name
|
|
35
|
+
* parseNamePath("MyClass/get*") // with glob
|
|
36
|
+
* parseNamePath("MyClass/method[0]") // with overload index
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseNamePath(pattern: string): ParsedNamePath;
|
|
39
|
+
/**
|
|
40
|
+
* Build a name path from parent path and name.
|
|
41
|
+
*
|
|
42
|
+
* @param parentPath - Parent symbol's name path (or undefined for top-level)
|
|
43
|
+
* @param name - Symbol's name
|
|
44
|
+
* @returns Complete name path
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* buildNamePath(undefined, "MyClass") // "/MyClass"
|
|
48
|
+
* buildNamePath("/MyClass", "myMethod") // "/MyClass/myMethod"
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildNamePath(parentPath: string | undefined, name: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Check if a name path matches a pattern.
|
|
53
|
+
*
|
|
54
|
+
* @param namePath - The full name path of a symbol (e.g., "/MyClass/myMethod")
|
|
55
|
+
* @param pattern - The parsed pattern to match against
|
|
56
|
+
* @param useSubstringMatching - Override substring matching for last segment
|
|
57
|
+
* @returns True if the name path matches the pattern
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* // Absolute match
|
|
61
|
+
* matchNamePath("/MyClass/myMethod", parseNamePath("/MyClass/myMethod")) // true
|
|
62
|
+
* matchNamePath("/MyClass/myMethod", parseNamePath("/OtherClass/myMethod")) // false
|
|
63
|
+
*
|
|
64
|
+
* // Relative match (suffix)
|
|
65
|
+
* matchNamePath("/MyClass/myMethod", parseNamePath("myMethod")) // true
|
|
66
|
+
* matchNamePath("/MyClass/myMethod", parseNamePath("MyClass/myMethod")) // true
|
|
67
|
+
*
|
|
68
|
+
* // Substring match
|
|
69
|
+
* matchNamePath("/MyClass/getValue", parseNamePath("get*")) // true
|
|
70
|
+
*/
|
|
71
|
+
export declare function matchNamePath(namePath: string, pattern: ParsedNamePath, useSubstringMatching?: boolean): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Extract the last segment (symbol name) from a name path.
|
|
74
|
+
*
|
|
75
|
+
* @param namePath - Full name path
|
|
76
|
+
* @returns The last segment (symbol name)
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* getSymbolName("/MyClass/myMethod") // "myMethod"
|
|
80
|
+
* getSymbolName("/topLevelFunc") // "topLevelFunc"
|
|
81
|
+
*/
|
|
82
|
+
export declare function getSymbolName(namePath: string): string;
|
|
83
|
+
/**
|
|
84
|
+
* Get the parent path from a name path.
|
|
85
|
+
*
|
|
86
|
+
* @param namePath - Full name path
|
|
87
|
+
* @returns Parent path, or undefined if top-level
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* getParentPath("/MyClass/myMethod") // "/MyClass"
|
|
91
|
+
* getParentPath("/topLevelFunc") // undefined
|
|
92
|
+
*/
|
|
93
|
+
export declare function getParentPath(namePath: string): string | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* Get the depth of a name path (number of segments - 1).
|
|
96
|
+
*
|
|
97
|
+
* @param namePath - Full name path
|
|
98
|
+
* @returns Depth (0 for top-level)
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* getNamePathDepth("/topLevel") // 0
|
|
102
|
+
* getNamePathDepth("/MyClass/myMethod") // 1
|
|
103
|
+
*/
|
|
104
|
+
export declare function getNamePathDepth(namePath: string): number;
|
|
105
|
+
/**
|
|
106
|
+
* Create a display-friendly version of a name path.
|
|
107
|
+
* Removes the leading slash for cleaner display.
|
|
108
|
+
*
|
|
109
|
+
* @param namePath - Full name path
|
|
110
|
+
* @returns Display string
|
|
111
|
+
*/
|
|
112
|
+
export declare function formatNamePath(namePath: string): string;
|
|
113
|
+
//# sourceMappingURL=name-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"name-path.d.ts","sourceRoot":"","sources":["../../src/symbols/name-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,mDAAmD;IACnD,UAAU,EAAE,OAAO,CAAC;IACpB,oBAAoB;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,wDAAwD;IACxD,cAAc,EAAE,OAAO,CAAC;IACxB,+CAA+C;IAC/C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,CAmC7D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAKlF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,cAAc,EACvB,oBAAoB,CAAC,EAAE,OAAO,GAC7B,OAAO,CA+CT;AAgBD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGtD;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMlE;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEvD"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Name path utilities for parsing and matching hierarchical symbol paths.
|
|
3
|
+
*
|
|
4
|
+
* Name path format:
|
|
5
|
+
* - "/ClassName/methodName" - Absolute path (must match from root)
|
|
6
|
+
* - "ClassName/methodName" - Relative path (matches any suffix)
|
|
7
|
+
* - "methodName" - Simple name (matches any symbol with that name)
|
|
8
|
+
* - "Class/get*" - With glob pattern (substring matching on last element)
|
|
9
|
+
*
|
|
10
|
+
* Uses "/" as separator to match Serena's convention.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Parse a name path pattern into its components.
|
|
14
|
+
*
|
|
15
|
+
* @param pattern - The name path pattern to parse
|
|
16
|
+
* @returns Parsed pattern components
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* parseNamePath("/MyClass/myMethod") // absolute path
|
|
20
|
+
* parseNamePath("MyClass/myMethod") // relative path
|
|
21
|
+
* parseNamePath("myMethod") // simple name
|
|
22
|
+
* parseNamePath("MyClass/get*") // with glob
|
|
23
|
+
* parseNamePath("MyClass/method[0]") // with overload index
|
|
24
|
+
*/
|
|
25
|
+
export function parseNamePath(pattern) {
|
|
26
|
+
let isAbsolute = false;
|
|
27
|
+
let workingPattern = pattern.trim();
|
|
28
|
+
// Check for absolute path
|
|
29
|
+
if (workingPattern.startsWith('/')) {
|
|
30
|
+
isAbsolute = true;
|
|
31
|
+
workingPattern = workingPattern.slice(1);
|
|
32
|
+
}
|
|
33
|
+
// Check for overload index at the end (e.g., "[0]", "[1]")
|
|
34
|
+
let overloadIndex;
|
|
35
|
+
const overloadMatch = workingPattern.match(/\[(\d+)\]$/);
|
|
36
|
+
if (overloadMatch) {
|
|
37
|
+
overloadIndex = parseInt(overloadMatch[1], 10);
|
|
38
|
+
workingPattern = workingPattern.slice(0, -overloadMatch[0].length);
|
|
39
|
+
}
|
|
40
|
+
// Split into segments
|
|
41
|
+
const segments = workingPattern.split('/').filter((s) => s.length > 0);
|
|
42
|
+
// Check if last segment has glob pattern (ends with *)
|
|
43
|
+
const substringMatch = segments.length > 0 && segments[segments.length - 1].endsWith('*');
|
|
44
|
+
// Remove the * from last segment if present
|
|
45
|
+
if (substringMatch && segments.length > 0) {
|
|
46
|
+
segments[segments.length - 1] = segments[segments.length - 1].slice(0, -1);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
isAbsolute,
|
|
50
|
+
segments,
|
|
51
|
+
substringMatch,
|
|
52
|
+
overloadIndex,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Build a name path from parent path and name.
|
|
57
|
+
*
|
|
58
|
+
* @param parentPath - Parent symbol's name path (or undefined for top-level)
|
|
59
|
+
* @param name - Symbol's name
|
|
60
|
+
* @returns Complete name path
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* buildNamePath(undefined, "MyClass") // "/MyClass"
|
|
64
|
+
* buildNamePath("/MyClass", "myMethod") // "/MyClass/myMethod"
|
|
65
|
+
*/
|
|
66
|
+
export function buildNamePath(parentPath, name) {
|
|
67
|
+
if (!parentPath) {
|
|
68
|
+
return `/${name}`;
|
|
69
|
+
}
|
|
70
|
+
return `${parentPath}/${name}`;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Check if a name path matches a pattern.
|
|
74
|
+
*
|
|
75
|
+
* @param namePath - The full name path of a symbol (e.g., "/MyClass/myMethod")
|
|
76
|
+
* @param pattern - The parsed pattern to match against
|
|
77
|
+
* @param useSubstringMatching - Override substring matching for last segment
|
|
78
|
+
* @returns True if the name path matches the pattern
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* // Absolute match
|
|
82
|
+
* matchNamePath("/MyClass/myMethod", parseNamePath("/MyClass/myMethod")) // true
|
|
83
|
+
* matchNamePath("/MyClass/myMethod", parseNamePath("/OtherClass/myMethod")) // false
|
|
84
|
+
*
|
|
85
|
+
* // Relative match (suffix)
|
|
86
|
+
* matchNamePath("/MyClass/myMethod", parseNamePath("myMethod")) // true
|
|
87
|
+
* matchNamePath("/MyClass/myMethod", parseNamePath("MyClass/myMethod")) // true
|
|
88
|
+
*
|
|
89
|
+
* // Substring match
|
|
90
|
+
* matchNamePath("/MyClass/getValue", parseNamePath("get*")) // true
|
|
91
|
+
*/
|
|
92
|
+
export function matchNamePath(namePath, pattern, useSubstringMatching) {
|
|
93
|
+
// Normalize the name path (ensure it starts with /)
|
|
94
|
+
const normalizedPath = namePath.startsWith('/') ? namePath : `/${namePath}`;
|
|
95
|
+
const pathSegments = normalizedPath.split('/').filter((s) => s.length > 0);
|
|
96
|
+
const { isAbsolute, segments: patternSegments, substringMatch } = pattern;
|
|
97
|
+
const shouldSubstring = useSubstringMatching ?? substringMatch;
|
|
98
|
+
if (patternSegments.length === 0) {
|
|
99
|
+
return true; // Empty pattern matches everything
|
|
100
|
+
}
|
|
101
|
+
if (isAbsolute) {
|
|
102
|
+
// Absolute path must match from the start
|
|
103
|
+
if (pathSegments.length !== patternSegments.length) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
for (let i = 0; i < patternSegments.length; i++) {
|
|
107
|
+
const isLastSegment = i === patternSegments.length - 1;
|
|
108
|
+
if (!segmentMatches(pathSegments[i], patternSegments[i], isLastSegment && shouldSubstring)) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
// Relative path - find suffix match
|
|
116
|
+
if (pathSegments.length < patternSegments.length) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
// Try to match from the end
|
|
120
|
+
const startIdx = pathSegments.length - patternSegments.length;
|
|
121
|
+
for (let i = 0; i < patternSegments.length; i++) {
|
|
122
|
+
const isLastSegment = i === patternSegments.length - 1;
|
|
123
|
+
if (!segmentMatches(pathSegments[startIdx + i], patternSegments[i], isLastSegment && shouldSubstring)) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Check if a path segment matches a pattern segment.
|
|
132
|
+
*/
|
|
133
|
+
function segmentMatches(pathSegment, patternSegment, useSubstring) {
|
|
134
|
+
if (useSubstring) {
|
|
135
|
+
return pathSegment.toLowerCase().startsWith(patternSegment.toLowerCase());
|
|
136
|
+
}
|
|
137
|
+
return pathSegment === patternSegment;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Extract the last segment (symbol name) from a name path.
|
|
141
|
+
*
|
|
142
|
+
* @param namePath - Full name path
|
|
143
|
+
* @returns The last segment (symbol name)
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* getSymbolName("/MyClass/myMethod") // "myMethod"
|
|
147
|
+
* getSymbolName("/topLevelFunc") // "topLevelFunc"
|
|
148
|
+
*/
|
|
149
|
+
export function getSymbolName(namePath) {
|
|
150
|
+
const segments = namePath.split('/').filter((s) => s.length > 0);
|
|
151
|
+
return segments[segments.length - 1] || '';
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Get the parent path from a name path.
|
|
155
|
+
*
|
|
156
|
+
* @param namePath - Full name path
|
|
157
|
+
* @returns Parent path, or undefined if top-level
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* getParentPath("/MyClass/myMethod") // "/MyClass"
|
|
161
|
+
* getParentPath("/topLevelFunc") // undefined
|
|
162
|
+
*/
|
|
163
|
+
export function getParentPath(namePath) {
|
|
164
|
+
const segments = namePath.split('/').filter((s) => s.length > 0);
|
|
165
|
+
if (segments.length <= 1) {
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
return '/' + segments.slice(0, -1).join('/');
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Get the depth of a name path (number of segments - 1).
|
|
172
|
+
*
|
|
173
|
+
* @param namePath - Full name path
|
|
174
|
+
* @returns Depth (0 for top-level)
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* getNamePathDepth("/topLevel") // 0
|
|
178
|
+
* getNamePathDepth("/MyClass/myMethod") // 1
|
|
179
|
+
*/
|
|
180
|
+
export function getNamePathDepth(namePath) {
|
|
181
|
+
const segments = namePath.split('/').filter((s) => s.length > 0);
|
|
182
|
+
return Math.max(0, segments.length - 1);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Create a display-friendly version of a name path.
|
|
186
|
+
* Removes the leading slash for cleaner display.
|
|
187
|
+
*
|
|
188
|
+
* @param namePath - Full name path
|
|
189
|
+
* @returns Display string
|
|
190
|
+
*/
|
|
191
|
+
export function formatNamePath(namePath) {
|
|
192
|
+
return namePath.startsWith('/') ? namePath.slice(1) : namePath;
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=name-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"name-path.js","sourceRoot":"","sources":["../../src/symbols/name-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAgBH;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,IAAI,UAAU,GAAG,KAAK,CAAC;IACvB,IAAI,cAAc,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAEpC,0BAA0B;IAC1B,IAAI,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,UAAU,GAAG,IAAI,CAAC;QAClB,cAAc,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC;IAED,2DAA2D;IAC3D,IAAI,aAAiC,CAAC;IACtC,MAAM,aAAa,GAAG,cAAc,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACzD,IAAI,aAAa,EAAE,CAAC;QAClB,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC/C,cAAc,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACrE,CAAC;IAED,sBAAsB;IACtB,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAEvE,uDAAuD;IACvD,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAE1F,4CAA4C;IAC5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UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pattern search for finding text patterns in the codebase.
|
|
3
|
+
* Supports regex patterns with context lines.
|
|
4
|
+
*/
|
|
5
|
+
import { PatternSearchResult, SearchPatternOptions } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Search for a pattern in the codebase.
|
|
8
|
+
*/
|
|
9
|
+
export declare function searchForPattern(projectPath: string, options: SearchPatternOptions): Promise<PatternSearchResult>;
|
|
10
|
+
/**
|
|
11
|
+
* Format pattern search results for display.
|
|
12
|
+
*/
|
|
13
|
+
export declare function formatPatternSearchResults(result: PatternSearchResult): string;
|
|
14
|
+
//# sourceMappingURL=pattern-search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern-search.d.ts","sourceRoot":"","sources":["../../src/symbols/pattern-search.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,mBAAmB,EAAgB,oBAAoB,EAAE,MAAM,YAAY,CAAC;AA0DrF;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,CA4G9B;AAyDD;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CA8B9E"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pattern search for finding text patterns in the codebase.
|
|
3
|
+
* Supports regex patterns with context lines.
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from 'fs/promises';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { glob } from 'glob';
|
|
8
|
+
import { minimatch } from 'minimatch';
|
|
9
|
+
/**
|
|
10
|
+
* Default extensions for code files
|
|
11
|
+
*/
|
|
12
|
+
const CODE_FILE_EXTENSIONS = [
|
|
13
|
+
'.ts',
|
|
14
|
+
'.tsx',
|
|
15
|
+
'.js',
|
|
16
|
+
'.jsx',
|
|
17
|
+
'.mts',
|
|
18
|
+
'.cts',
|
|
19
|
+
'.mjs',
|
|
20
|
+
'.cjs',
|
|
21
|
+
'.py',
|
|
22
|
+
'.pyi',
|
|
23
|
+
'.go',
|
|
24
|
+
'.rs',
|
|
25
|
+
'.java',
|
|
26
|
+
'.kt',
|
|
27
|
+
'.rb',
|
|
28
|
+
'.php',
|
|
29
|
+
'.c',
|
|
30
|
+
'.cpp',
|
|
31
|
+
'.h',
|
|
32
|
+
'.hpp',
|
|
33
|
+
'.cs',
|
|
34
|
+
'.swift',
|
|
35
|
+
'.scala',
|
|
36
|
+
'.lua',
|
|
37
|
+
'.r',
|
|
38
|
+
'.R',
|
|
39
|
+
'.sh',
|
|
40
|
+
'.bash',
|
|
41
|
+
'.zsh',
|
|
42
|
+
'.sql',
|
|
43
|
+
];
|
|
44
|
+
/**
|
|
45
|
+
* Default directories to exclude
|
|
46
|
+
*/
|
|
47
|
+
const DEFAULT_EXCLUDE_PATTERNS = [
|
|
48
|
+
'node_modules/**',
|
|
49
|
+
'.git/**',
|
|
50
|
+
'dist/**',
|
|
51
|
+
'build/**',
|
|
52
|
+
'coverage/**',
|
|
53
|
+
'__pycache__/**',
|
|
54
|
+
'.next/**',
|
|
55
|
+
'.cache/**',
|
|
56
|
+
'vendor/**',
|
|
57
|
+
];
|
|
58
|
+
/**
|
|
59
|
+
* Maximum default response size in characters
|
|
60
|
+
*/
|
|
61
|
+
const DEFAULT_MAX_ANSWER_CHARS = 50000;
|
|
62
|
+
/**
|
|
63
|
+
* Search for a pattern in the codebase.
|
|
64
|
+
*/
|
|
65
|
+
export async function searchForPattern(projectPath, options) {
|
|
66
|
+
const { substringPattern, relativePath = '', restrictSearchToCodeFiles = false, pathsIncludeGlob, pathsExcludeGlob, contextLinesBefore = 0, contextLinesAfter = 0, maxAnswerChars = DEFAULT_MAX_ANSWER_CHARS, } = options;
|
|
67
|
+
// Compile the pattern
|
|
68
|
+
let regex;
|
|
69
|
+
try {
|
|
70
|
+
regex = new RegExp(substringPattern, 'gm');
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
throw new Error(`Invalid regex pattern: ${substringPattern}. ${e instanceof Error ? e.message : ''}`);
|
|
74
|
+
}
|
|
75
|
+
// Determine the search path
|
|
76
|
+
const searchPath = relativePath ? path.join(projectPath, relativePath) : projectPath;
|
|
77
|
+
// Check if searchPath is a file or directory
|
|
78
|
+
let files;
|
|
79
|
+
try {
|
|
80
|
+
const stat = await fs.stat(searchPath);
|
|
81
|
+
if (stat.isFile()) {
|
|
82
|
+
files = [searchPath];
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
files = await findFiles(searchPath, {
|
|
86
|
+
codeFilesOnly: restrictSearchToCodeFiles,
|
|
87
|
+
includeGlob: pathsIncludeGlob,
|
|
88
|
+
excludeGlob: pathsExcludeGlob,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
throw new Error(`Path not found: ${relativePath || '.'}`);
|
|
94
|
+
}
|
|
95
|
+
const matches = {};
|
|
96
|
+
let totalMatches = 0;
|
|
97
|
+
let totalChars = 0;
|
|
98
|
+
for (const file of files) {
|
|
99
|
+
if (totalChars >= maxAnswerChars) {
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
const content = await fs.readFile(file, 'utf-8');
|
|
104
|
+
const lines = content.split('\n');
|
|
105
|
+
const fileMatches = [];
|
|
106
|
+
// Find all matches in the file
|
|
107
|
+
let match;
|
|
108
|
+
regex.lastIndex = 0; // Reset regex state
|
|
109
|
+
while ((match = regex.exec(content)) !== null) {
|
|
110
|
+
// Find the line number of the match
|
|
111
|
+
const beforeMatch = content.slice(0, match.index);
|
|
112
|
+
const lineNumber = beforeMatch.split('\n').length;
|
|
113
|
+
// Get context lines
|
|
114
|
+
const startLine = Math.max(0, lineNumber - 1 - contextLinesBefore);
|
|
115
|
+
const endLine = Math.min(lines.length, lineNumber + contextLinesAfter);
|
|
116
|
+
const contextContent = lines.slice(startLine, endLine).join('\n');
|
|
117
|
+
// Calculate match position within line
|
|
118
|
+
const lineStart = beforeMatch.lastIndexOf('\n') + 1;
|
|
119
|
+
const matchStart = match.index - lineStart;
|
|
120
|
+
fileMatches.push({
|
|
121
|
+
line: lineNumber,
|
|
122
|
+
content: contextContent,
|
|
123
|
+
matchStart,
|
|
124
|
+
matchLength: match[0].length,
|
|
125
|
+
});
|
|
126
|
+
totalMatches++;
|
|
127
|
+
totalChars += contextContent.length + 50; // Approximate overhead
|
|
128
|
+
if (totalChars >= maxAnswerChars) {
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
// Prevent infinite loops on zero-length matches
|
|
132
|
+
if (match[0].length === 0) {
|
|
133
|
+
regex.lastIndex++;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (fileMatches.length > 0) {
|
|
137
|
+
const relPath = path.relative(projectPath, file);
|
|
138
|
+
matches[relPath] = fileMatches;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
// Skip files that can't be read (binary, etc.)
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
matches,
|
|
148
|
+
totalMatches,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
async function findFiles(searchPath, options) {
|
|
152
|
+
const { codeFilesOnly, includeGlob, excludeGlob } = options;
|
|
153
|
+
// Build glob patterns
|
|
154
|
+
let patterns;
|
|
155
|
+
if (codeFilesOnly) {
|
|
156
|
+
patterns = CODE_FILE_EXTENSIONS.map((ext) => `**/*${ext}`);
|
|
157
|
+
}
|
|
158
|
+
else if (includeGlob) {
|
|
159
|
+
patterns = [includeGlob];
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
patterns = ['**/*'];
|
|
163
|
+
}
|
|
164
|
+
// Build exclude patterns
|
|
165
|
+
const excludePatterns = [...DEFAULT_EXCLUDE_PATTERNS];
|
|
166
|
+
if (excludeGlob) {
|
|
167
|
+
excludePatterns.push(excludeGlob);
|
|
168
|
+
}
|
|
169
|
+
const files = [];
|
|
170
|
+
for (const pattern of patterns) {
|
|
171
|
+
const matches = await glob(pattern, {
|
|
172
|
+
cwd: searchPath,
|
|
173
|
+
ignore: excludePatterns,
|
|
174
|
+
absolute: true,
|
|
175
|
+
nodir: true,
|
|
176
|
+
});
|
|
177
|
+
files.push(...matches);
|
|
178
|
+
}
|
|
179
|
+
// Apply additional filtering if both includeGlob and excludeGlob are specified
|
|
180
|
+
let filtered = files;
|
|
181
|
+
if (includeGlob && !codeFilesOnly) {
|
|
182
|
+
filtered = filtered.filter((f) => {
|
|
183
|
+
const rel = path.relative(searchPath, f);
|
|
184
|
+
return minimatch(rel, includeGlob);
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
if (excludeGlob) {
|
|
188
|
+
filtered = filtered.filter((f) => {
|
|
189
|
+
const rel = path.relative(searchPath, f);
|
|
190
|
+
return !minimatch(rel, excludeGlob);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
// Remove duplicates
|
|
194
|
+
return [...new Set(filtered)];
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Format pattern search results for display.
|
|
198
|
+
*/
|
|
199
|
+
export function formatPatternSearchResults(result) {
|
|
200
|
+
if (result.totalMatches === 0) {
|
|
201
|
+
return 'No matches found.';
|
|
202
|
+
}
|
|
203
|
+
const parts = [];
|
|
204
|
+
parts.push(`Found ${result.totalMatches} match${result.totalMatches === 1 ? '' : 'es'}:\n`);
|
|
205
|
+
for (const [filepath, fileMatches] of Object.entries(result.matches)) {
|
|
206
|
+
parts.push(`\n## ${filepath}\n`);
|
|
207
|
+
for (const match of fileMatches) {
|
|
208
|
+
// Format with line numbers
|
|
209
|
+
const lines = match.content.split('\n');
|
|
210
|
+
const startLine = match.line - Math.floor((lines.length - 1) / 2);
|
|
211
|
+
const formatted = lines
|
|
212
|
+
.map((line, idx) => {
|
|
213
|
+
const lineNum = startLine + idx;
|
|
214
|
+
const isMatchLine = lineNum === match.line;
|
|
215
|
+
const prefix = isMatchLine ? '>' : ' ';
|
|
216
|
+
return `${prefix} ${lineNum.toString().padStart(4)}: ${line}`;
|
|
217
|
+
})
|
|
218
|
+
.join('\n');
|
|
219
|
+
parts.push('```\n' + formatted + '\n```\n');
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return parts.join('');
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=pattern-search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern-search.js","sourceRoot":"","sources":["../../src/symbols/pattern-search.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC;;GAEG;AACH,MAAM,oBAAoB,GAAG;IAC3B,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,KAAK;IACL,MAAM;IACN,KAAK;IACL,KAAK;IACL,OAAO;IACP,KAAK;IACL,KAAK;IACL,MAAM;IACN,IAAI;IACJ,MAAM;IACN,IAAI;IACJ,MAAM;IACN,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,OAAO;IACP,MAAM;IACN,MAAM;CACP,CAAC;AAEF;;GAEG;AACH,MAAM,wBAAwB,GAAG;IAC/B,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AG,OAAO,KAAK,KAAK,CAAC,IAAI,CAAC;gBAC3C,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;gBACvC,OAAO,GAAG,MAAM,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YAChE,CAAC,CAAC;iBACD,IAAI,CAAC,IAAI,CAAC,CAAC;YAEd,KAAK,CAAC,IAAI,CAAC,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reference finder for locating all usages of a symbol.
|
|
3
|
+
* Uses Tree-sitter to find identifier references across the codebase.
|
|
4
|
+
*/
|
|
5
|
+
import { SymbolReference, FindReferencesOptions } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Find references to a symbol across the codebase.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ReferenceFinder {
|
|
10
|
+
private static parser;
|
|
11
|
+
private static loadedLanguages;
|
|
12
|
+
private static initPromise;
|
|
13
|
+
private static wasmBasePath;
|
|
14
|
+
private projectPath;
|
|
15
|
+
private symbolExtractor;
|
|
16
|
+
constructor(projectPath: string);
|
|
17
|
+
/**
|
|
18
|
+
* Initialize the tree-sitter parser.
|
|
19
|
+
*/
|
|
20
|
+
private static initialize;
|
|
21
|
+
private static findWasmBasePath;
|
|
22
|
+
private static getLanguageConfig;
|
|
23
|
+
private static loadLanguage;
|
|
24
|
+
/**
|
|
25
|
+
* Find all references to a symbol.
|
|
26
|
+
*/
|
|
27
|
+
findReferences(options: FindReferencesOptions): Promise<SymbolReference[]>;
|
|
28
|
+
private findSymbolByPattern;
|
|
29
|
+
private findFilesToSearch;
|
|
30
|
+
private findReferencesInFile;
|
|
31
|
+
private findReferencesWithTypeScript;
|
|
32
|
+
private findReferencesWithTreeSitter;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Format reference results for display.
|
|
36
|
+
*/
|
|
37
|
+
export declare function formatReferencesResult(references: SymbolReference[]): string;
|
|
38
|
+
//# sourceMappingURL=reference-finder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reference-finder.d.ts","sourceRoot":"","sources":["../../src/symbols/reference-finder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,eAAe,EAAsB,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAyExF;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,MAAM,CAA2B;IAChD,OAAO,CAAC,MAAM,CAAC,eAAe,CAAoC;IAClE,OAAO,CAAC,MAAM,CAAC,WAAW,CAA8B;IACxD,OAAO,CAAC,MAAM,CAAC,YAAY,CAAuB;IAElD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,eAAe,CAAkB;gBAE7B,WAAW,EAAE,MAAM;IAK/B;;OAEG;mBACkB,UAAU;mBAwBV,gBAAgB;IA4BrC,OAAO,CAAC,MAAM,CAAC,iBAAiB;mBAUX,YAAY;IAkBjC;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAoChF,OAAO,CAAC,mBAAmB;YAkBb,iBAAiB;YAkCjB,oBAAoB;IAiElC,OAAO,CAAC,4BAA4B;YA2EtB,4BAA4B;CA2E3C;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,eAAe,EAAE,GAAG,MAAM,CA6B5E"}
|