@duytransipher/gitnexus 1.4.6-sipher.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +73 -0
- package/README.md +261 -0
- package/dist/cli/ai-context.d.ts +23 -0
- package/dist/cli/ai-context.js +265 -0
- package/dist/cli/analyze.d.ts +12 -0
- package/dist/cli/analyze.js +345 -0
- package/dist/cli/augment.d.ts +13 -0
- package/dist/cli/augment.js +33 -0
- package/dist/cli/clean.d.ts +10 -0
- package/dist/cli/clean.js +60 -0
- package/dist/cli/eval-server.d.ts +37 -0
- package/dist/cli/eval-server.js +389 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +137 -0
- package/dist/cli/lazy-action.d.ts +6 -0
- package/dist/cli/lazy-action.js +18 -0
- package/dist/cli/list.d.ts +6 -0
- package/dist/cli/list.js +30 -0
- package/dist/cli/mcp.d.ts +8 -0
- package/dist/cli/mcp.js +36 -0
- package/dist/cli/serve.d.ts +4 -0
- package/dist/cli/serve.js +6 -0
- package/dist/cli/setup.d.ts +8 -0
- package/dist/cli/setup.js +367 -0
- package/dist/cli/sipher-patched.d.ts +2 -0
- package/dist/cli/sipher-patched.js +77 -0
- package/dist/cli/skill-gen.d.ts +26 -0
- package/dist/cli/skill-gen.js +549 -0
- package/dist/cli/status.d.ts +6 -0
- package/dist/cli/status.js +36 -0
- package/dist/cli/tool.d.ts +60 -0
- package/dist/cli/tool.js +180 -0
- package/dist/cli/wiki.d.ts +15 -0
- package/dist/cli/wiki.js +365 -0
- package/dist/config/ignore-service.d.ts +26 -0
- package/dist/config/ignore-service.js +284 -0
- package/dist/config/supported-languages.d.ts +15 -0
- package/dist/config/supported-languages.js +16 -0
- package/dist/core/augmentation/engine.d.ts +26 -0
- package/dist/core/augmentation/engine.js +240 -0
- package/dist/core/embeddings/embedder.d.ts +60 -0
- package/dist/core/embeddings/embedder.js +251 -0
- package/dist/core/embeddings/embedding-pipeline.d.ts +51 -0
- package/dist/core/embeddings/embedding-pipeline.js +356 -0
- package/dist/core/embeddings/index.d.ts +9 -0
- package/dist/core/embeddings/index.js +9 -0
- package/dist/core/embeddings/text-generator.d.ts +24 -0
- package/dist/core/embeddings/text-generator.js +182 -0
- package/dist/core/embeddings/types.d.ts +87 -0
- package/dist/core/embeddings/types.js +32 -0
- package/dist/core/graph/graph.d.ts +2 -0
- package/dist/core/graph/graph.js +66 -0
- package/dist/core/graph/types.d.ts +66 -0
- package/dist/core/graph/types.js +1 -0
- package/dist/core/ingestion/ast-cache.d.ts +11 -0
- package/dist/core/ingestion/ast-cache.js +35 -0
- package/dist/core/ingestion/call-processor.d.ts +23 -0
- package/dist/core/ingestion/call-processor.js +793 -0
- package/dist/core/ingestion/call-routing.d.ts +68 -0
- package/dist/core/ingestion/call-routing.js +129 -0
- package/dist/core/ingestion/cluster-enricher.d.ts +38 -0
- package/dist/core/ingestion/cluster-enricher.js +170 -0
- package/dist/core/ingestion/community-processor.d.ts +39 -0
- package/dist/core/ingestion/community-processor.js +312 -0
- package/dist/core/ingestion/constants.d.ts +16 -0
- package/dist/core/ingestion/constants.js +16 -0
- package/dist/core/ingestion/entry-point-scoring.d.ts +40 -0
- package/dist/core/ingestion/entry-point-scoring.js +353 -0
- package/dist/core/ingestion/export-detection.d.ts +18 -0
- package/dist/core/ingestion/export-detection.js +231 -0
- package/dist/core/ingestion/filesystem-walker.d.ts +28 -0
- package/dist/core/ingestion/filesystem-walker.js +81 -0
- package/dist/core/ingestion/framework-detection.d.ts +54 -0
- package/dist/core/ingestion/framework-detection.js +411 -0
- package/dist/core/ingestion/heritage-processor.d.ts +28 -0
- package/dist/core/ingestion/heritage-processor.js +251 -0
- package/dist/core/ingestion/import-processor.d.ts +34 -0
- package/dist/core/ingestion/import-processor.js +398 -0
- package/dist/core/ingestion/language-config.d.ts +46 -0
- package/dist/core/ingestion/language-config.js +167 -0
- package/dist/core/ingestion/mro-processor.d.ts +45 -0
- package/dist/core/ingestion/mro-processor.js +369 -0
- package/dist/core/ingestion/named-binding-extraction.d.ts +61 -0
- package/dist/core/ingestion/named-binding-extraction.js +363 -0
- package/dist/core/ingestion/parsing-processor.d.ts +19 -0
- package/dist/core/ingestion/parsing-processor.js +315 -0
- package/dist/core/ingestion/pipeline.d.ts +6 -0
- package/dist/core/ingestion/pipeline.js +401 -0
- package/dist/core/ingestion/process-processor.d.ts +51 -0
- package/dist/core/ingestion/process-processor.js +315 -0
- package/dist/core/ingestion/resolution-context.d.ts +53 -0
- package/dist/core/ingestion/resolution-context.js +132 -0
- package/dist/core/ingestion/resolvers/csharp.d.ts +22 -0
- package/dist/core/ingestion/resolvers/csharp.js +109 -0
- package/dist/core/ingestion/resolvers/go.d.ts +19 -0
- package/dist/core/ingestion/resolvers/go.js +42 -0
- package/dist/core/ingestion/resolvers/index.d.ts +18 -0
- package/dist/core/ingestion/resolvers/index.js +13 -0
- package/dist/core/ingestion/resolvers/jvm.d.ts +23 -0
- package/dist/core/ingestion/resolvers/jvm.js +87 -0
- package/dist/core/ingestion/resolvers/php.d.ts +15 -0
- package/dist/core/ingestion/resolvers/php.js +35 -0
- package/dist/core/ingestion/resolvers/python.d.ts +19 -0
- package/dist/core/ingestion/resolvers/python.js +52 -0
- package/dist/core/ingestion/resolvers/ruby.d.ts +12 -0
- package/dist/core/ingestion/resolvers/ruby.js +15 -0
- package/dist/core/ingestion/resolvers/rust.d.ts +15 -0
- package/dist/core/ingestion/resolvers/rust.js +73 -0
- package/dist/core/ingestion/resolvers/standard.d.ts +28 -0
- package/dist/core/ingestion/resolvers/standard.js +123 -0
- package/dist/core/ingestion/resolvers/utils.d.ts +33 -0
- package/dist/core/ingestion/resolvers/utils.js +122 -0
- package/dist/core/ingestion/structure-processor.d.ts +2 -0
- package/dist/core/ingestion/structure-processor.js +36 -0
- package/dist/core/ingestion/symbol-table.d.ts +63 -0
- package/dist/core/ingestion/symbol-table.js +85 -0
- package/dist/core/ingestion/tree-sitter-queries.d.ts +15 -0
- package/dist/core/ingestion/tree-sitter-queries.js +888 -0
- package/dist/core/ingestion/type-env.d.ts +49 -0
- package/dist/core/ingestion/type-env.js +613 -0
- package/dist/core/ingestion/type-extractors/c-cpp.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/c-cpp.js +385 -0
- package/dist/core/ingestion/type-extractors/csharp.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/csharp.js +383 -0
- package/dist/core/ingestion/type-extractors/go.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/go.js +467 -0
- package/dist/core/ingestion/type-extractors/index.d.ts +22 -0
- package/dist/core/ingestion/type-extractors/index.js +31 -0
- package/dist/core/ingestion/type-extractors/jvm.d.ts +3 -0
- package/dist/core/ingestion/type-extractors/jvm.js +681 -0
- package/dist/core/ingestion/type-extractors/php.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/php.js +549 -0
- package/dist/core/ingestion/type-extractors/python.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/python.js +455 -0
- package/dist/core/ingestion/type-extractors/ruby.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/ruby.js +389 -0
- package/dist/core/ingestion/type-extractors/rust.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/rust.js +456 -0
- package/dist/core/ingestion/type-extractors/shared.d.ts +145 -0
- package/dist/core/ingestion/type-extractors/shared.js +810 -0
- package/dist/core/ingestion/type-extractors/swift.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/swift.js +137 -0
- package/dist/core/ingestion/type-extractors/types.d.ts +127 -0
- package/dist/core/ingestion/type-extractors/types.js +1 -0
- package/dist/core/ingestion/type-extractors/typescript.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/typescript.js +494 -0
- package/dist/core/ingestion/utils.d.ts +138 -0
- package/dist/core/ingestion/utils.js +1290 -0
- package/dist/core/ingestion/workers/parse-worker.d.ts +122 -0
- package/dist/core/ingestion/workers/parse-worker.js +1126 -0
- package/dist/core/ingestion/workers/worker-pool.d.ts +16 -0
- package/dist/core/ingestion/workers/worker-pool.js +128 -0
- package/dist/core/lbug/csv-generator.d.ts +33 -0
- package/dist/core/lbug/csv-generator.js +366 -0
- package/dist/core/lbug/lbug-adapter.d.ts +103 -0
- package/dist/core/lbug/lbug-adapter.js +769 -0
- package/dist/core/lbug/schema.d.ts +53 -0
- package/dist/core/lbug/schema.js +430 -0
- package/dist/core/search/bm25-index.d.ts +23 -0
- package/dist/core/search/bm25-index.js +96 -0
- package/dist/core/search/hybrid-search.d.ts +49 -0
- package/dist/core/search/hybrid-search.js +118 -0
- package/dist/core/tree-sitter/parser-loader.d.ts +5 -0
- package/dist/core/tree-sitter/parser-loader.js +63 -0
- package/dist/core/wiki/generator.d.ts +120 -0
- package/dist/core/wiki/generator.js +939 -0
- package/dist/core/wiki/graph-queries.d.ts +80 -0
- package/dist/core/wiki/graph-queries.js +238 -0
- package/dist/core/wiki/html-viewer.d.ts +10 -0
- package/dist/core/wiki/html-viewer.js +297 -0
- package/dist/core/wiki/llm-client.d.ts +43 -0
- package/dist/core/wiki/llm-client.js +186 -0
- package/dist/core/wiki/prompts.d.ts +53 -0
- package/dist/core/wiki/prompts.js +174 -0
- package/dist/lib/utils.d.ts +1 -0
- package/dist/lib/utils.js +3 -0
- package/dist/mcp/compatible-stdio-transport.d.ts +25 -0
- package/dist/mcp/compatible-stdio-transport.js +200 -0
- package/dist/mcp/core/embedder.d.ts +27 -0
- package/dist/mcp/core/embedder.js +108 -0
- package/dist/mcp/core/lbug-adapter.d.ts +57 -0
- package/dist/mcp/core/lbug-adapter.js +455 -0
- package/dist/mcp/local/local-backend.d.ts +181 -0
- package/dist/mcp/local/local-backend.js +1722 -0
- package/dist/mcp/resources.d.ts +31 -0
- package/dist/mcp/resources.js +411 -0
- package/dist/mcp/server.d.ts +23 -0
- package/dist/mcp/server.js +296 -0
- package/dist/mcp/staleness.d.ts +15 -0
- package/dist/mcp/staleness.js +29 -0
- package/dist/mcp/tools.d.ts +24 -0
- package/dist/mcp/tools.js +292 -0
- package/dist/server/api.d.ts +10 -0
- package/dist/server/api.js +344 -0
- package/dist/server/mcp-http.d.ts +13 -0
- package/dist/server/mcp-http.js +100 -0
- package/dist/storage/git.d.ts +6 -0
- package/dist/storage/git.js +35 -0
- package/dist/storage/repo-manager.d.ts +138 -0
- package/dist/storage/repo-manager.js +299 -0
- package/dist/types/pipeline.d.ts +32 -0
- package/dist/types/pipeline.js +18 -0
- package/dist/unreal/bridge.d.ts +4 -0
- package/dist/unreal/bridge.js +113 -0
- package/dist/unreal/config.d.ts +6 -0
- package/dist/unreal/config.js +55 -0
- package/dist/unreal/types.d.ts +105 -0
- package/dist/unreal/types.js +1 -0
- package/hooks/claude/gitnexus-hook.cjs +238 -0
- package/hooks/claude/pre-tool-use.sh +79 -0
- package/hooks/claude/session-start.sh +42 -0
- package/package.json +100 -0
- package/scripts/ensure-cli-executable.cjs +21 -0
- package/scripts/patch-tree-sitter-swift.cjs +74 -0
- package/scripts/setup-unreal-gitnexus.ps1 +191 -0
- package/skills/gitnexus-cli.md +82 -0
- package/skills/gitnexus-debugging.md +89 -0
- package/skills/gitnexus-exploring.md +78 -0
- package/skills/gitnexus-guide.md +64 -0
- package/skills/gitnexus-impact-analysis.md +97 -0
- package/skills/gitnexus-pr-review.md +163 -0
- package/skills/gitnexus-refactoring.md +121 -0
- package/vendor/leiden/index.cjs +355 -0
- package/vendor/leiden/utils.cjs +392 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import ignore from 'ignore';
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
import nodePath from 'path';
|
|
4
|
+
const DEFAULT_IGNORE_LIST = new Set([
|
|
5
|
+
// Version Control
|
|
6
|
+
'.git',
|
|
7
|
+
'.svn',
|
|
8
|
+
'.hg',
|
|
9
|
+
'.bzr',
|
|
10
|
+
// IDEs & Editors
|
|
11
|
+
'.idea',
|
|
12
|
+
'.vscode',
|
|
13
|
+
'.vs',
|
|
14
|
+
'.eclipse',
|
|
15
|
+
'.settings',
|
|
16
|
+
'.DS_Store',
|
|
17
|
+
'Thumbs.db',
|
|
18
|
+
// Dependencies
|
|
19
|
+
'node_modules',
|
|
20
|
+
'bower_components',
|
|
21
|
+
'jspm_packages',
|
|
22
|
+
'vendor', // PHP/Go
|
|
23
|
+
// 'packages' removed - commonly used for monorepo source code (lerna, pnpm, yarn workspaces)
|
|
24
|
+
'venv',
|
|
25
|
+
'.venv',
|
|
26
|
+
'env',
|
|
27
|
+
'.env',
|
|
28
|
+
'__pycache__',
|
|
29
|
+
'.pytest_cache',
|
|
30
|
+
'.mypy_cache',
|
|
31
|
+
'site-packages',
|
|
32
|
+
'.tox',
|
|
33
|
+
'eggs',
|
|
34
|
+
'.eggs',
|
|
35
|
+
'lib64',
|
|
36
|
+
'parts',
|
|
37
|
+
'sdist',
|
|
38
|
+
'wheels',
|
|
39
|
+
// Build Outputs
|
|
40
|
+
'dist',
|
|
41
|
+
'build',
|
|
42
|
+
'out',
|
|
43
|
+
'output',
|
|
44
|
+
'bin',
|
|
45
|
+
'obj',
|
|
46
|
+
'target', // Java/Rust
|
|
47
|
+
'.next',
|
|
48
|
+
'.nuxt',
|
|
49
|
+
'.output',
|
|
50
|
+
'.vercel',
|
|
51
|
+
'.netlify',
|
|
52
|
+
'.serverless',
|
|
53
|
+
'_build',
|
|
54
|
+
'public/build',
|
|
55
|
+
'.parcel-cache',
|
|
56
|
+
'.turbo',
|
|
57
|
+
'.svelte-kit',
|
|
58
|
+
// Test & Coverage
|
|
59
|
+
'coverage',
|
|
60
|
+
'.nyc_output',
|
|
61
|
+
'htmlcov',
|
|
62
|
+
'.coverage',
|
|
63
|
+
'__tests__', // Often just test files
|
|
64
|
+
'__mocks__',
|
|
65
|
+
'.jest',
|
|
66
|
+
// Logs & Temp
|
|
67
|
+
'logs',
|
|
68
|
+
'log',
|
|
69
|
+
'tmp',
|
|
70
|
+
'temp',
|
|
71
|
+
'cache',
|
|
72
|
+
'.cache',
|
|
73
|
+
'.tmp',
|
|
74
|
+
'.temp',
|
|
75
|
+
// Generated/Compiled
|
|
76
|
+
'.generated',
|
|
77
|
+
'generated',
|
|
78
|
+
'auto-generated',
|
|
79
|
+
'.terraform',
|
|
80
|
+
'.serverless',
|
|
81
|
+
// Documentation (optional - might want to keep)
|
|
82
|
+
// 'docs',
|
|
83
|
+
// 'documentation',
|
|
84
|
+
// Misc
|
|
85
|
+
'.husky',
|
|
86
|
+
'.github', // GitHub config, not code
|
|
87
|
+
'.circleci',
|
|
88
|
+
'.gitlab',
|
|
89
|
+
'fixtures', // Test fixtures
|
|
90
|
+
'snapshots', // Jest snapshots
|
|
91
|
+
'__snapshots__',
|
|
92
|
+
]);
|
|
93
|
+
const IGNORED_EXTENSIONS = new Set([
|
|
94
|
+
// Images
|
|
95
|
+
'.png', '.jpg', '.jpeg', '.gif', '.svg', '.ico', '.webp', '.bmp', '.tiff', '.tif',
|
|
96
|
+
'.psd', '.ai', '.sketch', '.fig', '.xd',
|
|
97
|
+
// Archives
|
|
98
|
+
'.zip', '.tar', '.gz', '.rar', '.7z', '.bz2', '.xz', '.tgz',
|
|
99
|
+
// Binary/Compiled
|
|
100
|
+
'.exe', '.dll', '.so', '.dylib', '.a', '.lib', '.o', '.obj',
|
|
101
|
+
'.class', '.jar', '.war', '.ear',
|
|
102
|
+
'.pyc', '.pyo', '.pyd',
|
|
103
|
+
'.beam', // Erlang
|
|
104
|
+
'.wasm', // WebAssembly - important!
|
|
105
|
+
'.node', // Native Node addons
|
|
106
|
+
// Documents
|
|
107
|
+
'.pdf', '.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx',
|
|
108
|
+
'.odt', '.ods', '.odp',
|
|
109
|
+
// Media
|
|
110
|
+
'.mp4', '.mp3', '.wav', '.mov', '.avi', '.mkv', '.flv', '.wmv',
|
|
111
|
+
'.ogg', '.webm', '.flac', '.aac', '.m4a',
|
|
112
|
+
// Fonts
|
|
113
|
+
'.woff', '.woff2', '.ttf', '.eot', '.otf',
|
|
114
|
+
// Databases
|
|
115
|
+
'.db', '.sqlite', '.sqlite3', '.mdb', '.accdb',
|
|
116
|
+
// Minified/Bundled files
|
|
117
|
+
'.min.js', '.min.css', '.bundle.js', '.chunk.js',
|
|
118
|
+
// Source maps (debug files, not source)
|
|
119
|
+
'.map',
|
|
120
|
+
// Lock files (handled separately, but also here)
|
|
121
|
+
'.lock',
|
|
122
|
+
// Certificates & Keys (security - don't index!)
|
|
123
|
+
'.pem', '.key', '.crt', '.cer', '.p12', '.pfx',
|
|
124
|
+
// Data files (often large/binary)
|
|
125
|
+
'.csv', '.tsv', '.parquet', '.avro', '.feather',
|
|
126
|
+
'.npy', '.npz', '.pkl', '.pickle', '.h5', '.hdf5',
|
|
127
|
+
// Misc binary
|
|
128
|
+
'.bin', '.dat', '.data', '.raw',
|
|
129
|
+
'.iso', '.img', '.dmg',
|
|
130
|
+
]);
|
|
131
|
+
// Files to ignore by exact name
|
|
132
|
+
const IGNORED_FILES = new Set([
|
|
133
|
+
'package-lock.json',
|
|
134
|
+
'yarn.lock',
|
|
135
|
+
'pnpm-lock.yaml',
|
|
136
|
+
'composer.lock',
|
|
137
|
+
'Gemfile.lock',
|
|
138
|
+
'poetry.lock',
|
|
139
|
+
'Cargo.lock',
|
|
140
|
+
'go.sum',
|
|
141
|
+
'.gitignore',
|
|
142
|
+
'.gitattributes',
|
|
143
|
+
'.npmrc',
|
|
144
|
+
'.yarnrc',
|
|
145
|
+
'.editorconfig',
|
|
146
|
+
'.prettierrc',
|
|
147
|
+
'.prettierignore',
|
|
148
|
+
'.eslintignore',
|
|
149
|
+
'.dockerignore',
|
|
150
|
+
'Thumbs.db',
|
|
151
|
+
'.DS_Store',
|
|
152
|
+
'LICENSE',
|
|
153
|
+
'LICENSE.md',
|
|
154
|
+
'LICENSE.txt',
|
|
155
|
+
'CHANGELOG.md',
|
|
156
|
+
'CHANGELOG',
|
|
157
|
+
'CONTRIBUTING.md',
|
|
158
|
+
'CODE_OF_CONDUCT.md',
|
|
159
|
+
'SECURITY.md',
|
|
160
|
+
'.env',
|
|
161
|
+
'.env.local',
|
|
162
|
+
'.env.development',
|
|
163
|
+
'.env.production',
|
|
164
|
+
'.env.test',
|
|
165
|
+
'.env.example',
|
|
166
|
+
]);
|
|
167
|
+
// NOTE: Negation patterns in .gitnexusignore (e.g. `!vendor/`) cannot override
|
|
168
|
+
// entries in DEFAULT_IGNORE_LIST — this is intentional. The hardcoded list protects
|
|
169
|
+
// against indexing directories that are almost never source code (node_modules, .git, etc.).
|
|
170
|
+
// Users who need to include such directories should remove them from the hardcoded list.
|
|
171
|
+
export const shouldIgnorePath = (filePath) => {
|
|
172
|
+
const normalizedPath = filePath.replace(/\\/g, '/');
|
|
173
|
+
const parts = normalizedPath.split('/');
|
|
174
|
+
const fileName = parts[parts.length - 1];
|
|
175
|
+
const fileNameLower = fileName.toLowerCase();
|
|
176
|
+
// Check if any path segment is in ignore list
|
|
177
|
+
for (const part of parts) {
|
|
178
|
+
if (DEFAULT_IGNORE_LIST.has(part)) {
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// Check exact filename matches
|
|
183
|
+
if (IGNORED_FILES.has(fileName) || IGNORED_FILES.has(fileNameLower)) {
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
// Check extension
|
|
187
|
+
const lastDotIndex = fileNameLower.lastIndexOf('.');
|
|
188
|
+
if (lastDotIndex !== -1) {
|
|
189
|
+
const ext = fileNameLower.substring(lastDotIndex);
|
|
190
|
+
if (IGNORED_EXTENSIONS.has(ext))
|
|
191
|
+
return true;
|
|
192
|
+
// Handle compound extensions like .min.js, .bundle.js
|
|
193
|
+
const secondLastDot = fileNameLower.lastIndexOf('.', lastDotIndex - 1);
|
|
194
|
+
if (secondLastDot !== -1) {
|
|
195
|
+
const compoundExt = fileNameLower.substring(secondLastDot);
|
|
196
|
+
if (IGNORED_EXTENSIONS.has(compoundExt))
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
// Ignore hidden files (starting with .)
|
|
201
|
+
if (fileName.startsWith('.') && fileName !== '.') {
|
|
202
|
+
// But allow some important config files
|
|
203
|
+
const allowedDotFiles = ['.env', '.gitignore']; // Already in IGNORED_FILES, so this is redundant
|
|
204
|
+
// Actually, let's NOT ignore all dot files - many are important configs
|
|
205
|
+
// Just rely on the explicit lists above
|
|
206
|
+
}
|
|
207
|
+
// Ignore files that look like generated/bundled code
|
|
208
|
+
if (fileNameLower.includes('.bundle.') ||
|
|
209
|
+
fileNameLower.includes('.chunk.') ||
|
|
210
|
+
fileNameLower.includes('.generated.') ||
|
|
211
|
+
fileNameLower.endsWith('.d.ts')) { // TypeScript declaration files
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
return false;
|
|
215
|
+
};
|
|
216
|
+
/** Check if a directory name is in the hardcoded ignore list */
|
|
217
|
+
export const isHardcodedIgnoredDirectory = (name) => {
|
|
218
|
+
return DEFAULT_IGNORE_LIST.has(name);
|
|
219
|
+
};
|
|
220
|
+
export const loadIgnoreRules = async (repoPath, options) => {
|
|
221
|
+
const ig = ignore();
|
|
222
|
+
let hasRules = false;
|
|
223
|
+
// Allow users to bypass .gitignore parsing (e.g. when .gitignore accidentally excludes source files)
|
|
224
|
+
const skipGitignore = options?.noGitignore ?? !!process.env.GITNEXUS_NO_GITIGNORE;
|
|
225
|
+
const filenames = skipGitignore
|
|
226
|
+
? ['.gitnexusignore']
|
|
227
|
+
: ['.gitignore', '.gitnexusignore'];
|
|
228
|
+
for (const filename of filenames) {
|
|
229
|
+
try {
|
|
230
|
+
const content = await fs.readFile(nodePath.join(repoPath, filename), 'utf-8');
|
|
231
|
+
ig.add(content);
|
|
232
|
+
hasRules = true;
|
|
233
|
+
}
|
|
234
|
+
catch (err) {
|
|
235
|
+
const code = err.code;
|
|
236
|
+
if (code !== 'ENOENT') {
|
|
237
|
+
console.warn(` Warning: could not read ${filename}: ${err.message}`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return hasRules ? ig : null;
|
|
242
|
+
};
|
|
243
|
+
/**
|
|
244
|
+
* Create a glob-compatible ignore filter combining:
|
|
245
|
+
* - .gitignore / .gitnexusignore patterns (via `ignore` package)
|
|
246
|
+
* - Hardcoded DEFAULT_IGNORE_LIST, IGNORED_EXTENSIONS, IGNORED_FILES
|
|
247
|
+
*
|
|
248
|
+
* Returns an IgnoreLike object for glob's `ignore` option,
|
|
249
|
+
* enabling directory-level pruning during traversal.
|
|
250
|
+
*/
|
|
251
|
+
export const createIgnoreFilter = async (repoPath, options) => {
|
|
252
|
+
const ig = await loadIgnoreRules(repoPath, options);
|
|
253
|
+
return {
|
|
254
|
+
ignored(p) {
|
|
255
|
+
// path-scurry's Path.relative() returns POSIX paths on all platforms,
|
|
256
|
+
// which is what the `ignore` package expects. No explicit normalization needed.
|
|
257
|
+
const rel = p.relative();
|
|
258
|
+
if (!rel)
|
|
259
|
+
return false;
|
|
260
|
+
// Check .gitignore / .gitnexusignore patterns
|
|
261
|
+
if (ig && ig.ignores(rel))
|
|
262
|
+
return true;
|
|
263
|
+
// Fall back to hardcoded rules
|
|
264
|
+
return shouldIgnorePath(rel);
|
|
265
|
+
},
|
|
266
|
+
childrenIgnored(p) {
|
|
267
|
+
// Fast path: check directory name against hardcoded list.
|
|
268
|
+
// Note: dot-directories (.git, .vscode, etc.) are primarily excluded by
|
|
269
|
+
// glob's `dot: false` option in filesystem-walker.ts. This check is
|
|
270
|
+
// defense-in-depth — do not remove `dot: false` assuming this covers it.
|
|
271
|
+
if (DEFAULT_IGNORE_LIST.has(p.name))
|
|
272
|
+
return true;
|
|
273
|
+
// Check against .gitignore / .gitnexusignore patterns.
|
|
274
|
+
// Test both bare path and path with trailing slash to handle
|
|
275
|
+
// bare-name patterns (e.g. `local`) and dir-only patterns (e.g. `local/`).
|
|
276
|
+
if (ig) {
|
|
277
|
+
const rel = p.relative();
|
|
278
|
+
if (rel && (ig.ignores(rel) || ig.ignores(rel + '/')))
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
return false;
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare enum SupportedLanguages {
|
|
2
|
+
JavaScript = "javascript",
|
|
3
|
+
TypeScript = "typescript",
|
|
4
|
+
Python = "python",
|
|
5
|
+
Java = "java",
|
|
6
|
+
C = "c",
|
|
7
|
+
CPlusPlus = "cpp",
|
|
8
|
+
CSharp = "csharp",
|
|
9
|
+
Go = "go",
|
|
10
|
+
Ruby = "ruby",
|
|
11
|
+
Rust = "rust",
|
|
12
|
+
PHP = "php",
|
|
13
|
+
Kotlin = "kotlin",
|
|
14
|
+
Swift = "swift"
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export var SupportedLanguages;
|
|
2
|
+
(function (SupportedLanguages) {
|
|
3
|
+
SupportedLanguages["JavaScript"] = "javascript";
|
|
4
|
+
SupportedLanguages["TypeScript"] = "typescript";
|
|
5
|
+
SupportedLanguages["Python"] = "python";
|
|
6
|
+
SupportedLanguages["Java"] = "java";
|
|
7
|
+
SupportedLanguages["C"] = "c";
|
|
8
|
+
SupportedLanguages["CPlusPlus"] = "cpp";
|
|
9
|
+
SupportedLanguages["CSharp"] = "csharp";
|
|
10
|
+
SupportedLanguages["Go"] = "go";
|
|
11
|
+
SupportedLanguages["Ruby"] = "ruby";
|
|
12
|
+
SupportedLanguages["Rust"] = "rust";
|
|
13
|
+
SupportedLanguages["PHP"] = "php";
|
|
14
|
+
SupportedLanguages["Kotlin"] = "kotlin";
|
|
15
|
+
SupportedLanguages["Swift"] = "swift";
|
|
16
|
+
})(SupportedLanguages || (SupportedLanguages = {}));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Augmentation Engine
|
|
3
|
+
*
|
|
4
|
+
* Lightweight, fast-path enrichment of search patterns with knowledge graph context.
|
|
5
|
+
* Designed to be called from platform hooks (Claude Code PreToolUse, Cursor beforeShellExecution)
|
|
6
|
+
* when an agent runs grep/glob/search.
|
|
7
|
+
*
|
|
8
|
+
* Performance target: <500ms cold start, <200ms warm.
|
|
9
|
+
*
|
|
10
|
+
* Design decisions:
|
|
11
|
+
* - Uses only BM25 search (no semantic/embedding) for speed
|
|
12
|
+
* - Clusters used internally for ranking, NEVER in output
|
|
13
|
+
* - Output is pure relationships: callers, callees, process participation
|
|
14
|
+
* - Graceful failure: any error → return empty string
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Augment a search pattern with knowledge graph context.
|
|
18
|
+
*
|
|
19
|
+
* 1. BM25 search for the pattern
|
|
20
|
+
* 2. For top matches, fetch callers/callees/processes
|
|
21
|
+
* 3. Rank by internal cluster cohesion (not exposed)
|
|
22
|
+
* 4. Format as structured text block
|
|
23
|
+
*
|
|
24
|
+
* Returns empty string on any error (graceful failure).
|
|
25
|
+
*/
|
|
26
|
+
export declare function augment(pattern: string, cwd?: string): Promise<string>;
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Augmentation Engine
|
|
3
|
+
*
|
|
4
|
+
* Lightweight, fast-path enrichment of search patterns with knowledge graph context.
|
|
5
|
+
* Designed to be called from platform hooks (Claude Code PreToolUse, Cursor beforeShellExecution)
|
|
6
|
+
* when an agent runs grep/glob/search.
|
|
7
|
+
*
|
|
8
|
+
* Performance target: <500ms cold start, <200ms warm.
|
|
9
|
+
*
|
|
10
|
+
* Design decisions:
|
|
11
|
+
* - Uses only BM25 search (no semantic/embedding) for speed
|
|
12
|
+
* - Clusters used internally for ranking, NEVER in output
|
|
13
|
+
* - Output is pure relationships: callers, callees, process participation
|
|
14
|
+
* - Graceful failure: any error → return empty string
|
|
15
|
+
*/
|
|
16
|
+
import path from 'path';
|
|
17
|
+
import { listRegisteredRepos } from '../../storage/repo-manager.js';
|
|
18
|
+
/**
|
|
19
|
+
* Find the best matching repo for a given working directory.
|
|
20
|
+
* Matches by checking if cwd is within the repo's path.
|
|
21
|
+
*/
|
|
22
|
+
async function findRepoForCwd(cwd) {
|
|
23
|
+
try {
|
|
24
|
+
const entries = await listRegisteredRepos({ validate: true });
|
|
25
|
+
const resolved = path.resolve(cwd);
|
|
26
|
+
// Normalize to lowercase on Windows (drive letters can differ: D: vs d:)
|
|
27
|
+
const isWindows = process.platform === 'win32';
|
|
28
|
+
const normalizedCwd = isWindows ? resolved.toLowerCase() : resolved;
|
|
29
|
+
const sep = path.sep;
|
|
30
|
+
// Find the LONGEST matching repo path (most specific match wins)
|
|
31
|
+
let bestMatch = null;
|
|
32
|
+
let bestLen = 0;
|
|
33
|
+
for (const entry of entries) {
|
|
34
|
+
const repoResolved = path.resolve(entry.path);
|
|
35
|
+
const normalizedRepo = isWindows ? repoResolved.toLowerCase() : repoResolved;
|
|
36
|
+
// Check if cwd is inside repo OR repo is inside cwd
|
|
37
|
+
// Must match at a path separator boundary to avoid false positives
|
|
38
|
+
// (e.g. /projects/gitnexusv2 should NOT match /projects/gitnexus)
|
|
39
|
+
let matched = false;
|
|
40
|
+
if (normalizedCwd === normalizedRepo) {
|
|
41
|
+
matched = true;
|
|
42
|
+
}
|
|
43
|
+
else if (normalizedCwd.startsWith(normalizedRepo + sep)) {
|
|
44
|
+
matched = true;
|
|
45
|
+
}
|
|
46
|
+
else if (normalizedRepo.startsWith(normalizedCwd + sep)) {
|
|
47
|
+
matched = true;
|
|
48
|
+
}
|
|
49
|
+
if (matched && normalizedRepo.length > bestLen) {
|
|
50
|
+
bestMatch = entry;
|
|
51
|
+
bestLen = normalizedRepo.length;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (!bestMatch)
|
|
55
|
+
return null;
|
|
56
|
+
return {
|
|
57
|
+
name: bestMatch.name,
|
|
58
|
+
storagePath: bestMatch.storagePath,
|
|
59
|
+
lbugPath: path.join(bestMatch.storagePath, 'lbug'),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Augment a search pattern with knowledge graph context.
|
|
68
|
+
*
|
|
69
|
+
* 1. BM25 search for the pattern
|
|
70
|
+
* 2. For top matches, fetch callers/callees/processes
|
|
71
|
+
* 3. Rank by internal cluster cohesion (not exposed)
|
|
72
|
+
* 4. Format as structured text block
|
|
73
|
+
*
|
|
74
|
+
* Returns empty string on any error (graceful failure).
|
|
75
|
+
*/
|
|
76
|
+
export async function augment(pattern, cwd) {
|
|
77
|
+
if (!pattern || pattern.length < 3)
|
|
78
|
+
return '';
|
|
79
|
+
const workDir = cwd || process.cwd();
|
|
80
|
+
try {
|
|
81
|
+
const repo = await findRepoForCwd(workDir);
|
|
82
|
+
if (!repo)
|
|
83
|
+
return '';
|
|
84
|
+
// Lazy-load lbug adapter (skip unnecessary init)
|
|
85
|
+
const { initLbug, executeQuery, isLbugReady } = await import('../../mcp/core/lbug-adapter.js');
|
|
86
|
+
const { searchFTSFromLbug } = await import('../search/bm25-index.js');
|
|
87
|
+
const repoId = repo.name.toLowerCase();
|
|
88
|
+
// Init LadybugDB if not already
|
|
89
|
+
if (!isLbugReady(repoId)) {
|
|
90
|
+
await initLbug(repoId, repo.lbugPath);
|
|
91
|
+
}
|
|
92
|
+
// Step 1: BM25 search (fast, no embeddings)
|
|
93
|
+
const bm25Results = await searchFTSFromLbug(pattern, 10, repoId);
|
|
94
|
+
if (bm25Results.length === 0)
|
|
95
|
+
return '';
|
|
96
|
+
// Step 2: Map BM25 file results to symbols
|
|
97
|
+
const symbolMatches = [];
|
|
98
|
+
for (const result of bm25Results.slice(0, 5)) {
|
|
99
|
+
const escaped = result.filePath.replace(/'/g, "''");
|
|
100
|
+
try {
|
|
101
|
+
const symbols = await executeQuery(repoId, `
|
|
102
|
+
MATCH (n) WHERE n.filePath = '${escaped}'
|
|
103
|
+
AND n.name CONTAINS '${pattern.replace(/'/g, "''").split(/\s+/)[0]}'
|
|
104
|
+
RETURN n.id AS id, n.name AS name, labels(n)[0] AS type, n.filePath AS filePath
|
|
105
|
+
LIMIT 3
|
|
106
|
+
`);
|
|
107
|
+
for (const sym of symbols) {
|
|
108
|
+
symbolMatches.push({
|
|
109
|
+
nodeId: sym.id || sym[0],
|
|
110
|
+
name: sym.name || sym[1],
|
|
111
|
+
type: sym.type || sym[2],
|
|
112
|
+
filePath: sym.filePath || sym[3],
|
|
113
|
+
score: result.score,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch { /* skip */ }
|
|
118
|
+
}
|
|
119
|
+
if (symbolMatches.length === 0)
|
|
120
|
+
return '';
|
|
121
|
+
// Step 3: Batch-fetch callers/callees/processes/cohesion for top matches
|
|
122
|
+
// Uses batched WHERE n.id IN [...] queries instead of per-symbol queries
|
|
123
|
+
const uniqueSymbols = symbolMatches.slice(0, 5).filter((sym, i, arr) => arr.findIndex(s => s.nodeId === sym.nodeId) === i);
|
|
124
|
+
if (uniqueSymbols.length === 0)
|
|
125
|
+
return '';
|
|
126
|
+
const idList = uniqueSymbols.map(s => `'${s.nodeId.replace(/'/g, "''")}'`).join(', ');
|
|
127
|
+
// Batch fetch callers
|
|
128
|
+
const callersMap = new Map();
|
|
129
|
+
try {
|
|
130
|
+
const rows = await executeQuery(repoId, `
|
|
131
|
+
MATCH (caller)-[:CodeRelation {type: 'CALLS'}]->(n)
|
|
132
|
+
WHERE n.id IN [${idList}]
|
|
133
|
+
RETURN n.id AS targetId, caller.name AS name
|
|
134
|
+
LIMIT 15
|
|
135
|
+
`);
|
|
136
|
+
for (const r of rows) {
|
|
137
|
+
const tid = r.targetId || r[0];
|
|
138
|
+
const name = r.name || r[1];
|
|
139
|
+
if (tid && name) {
|
|
140
|
+
if (!callersMap.has(tid))
|
|
141
|
+
callersMap.set(tid, []);
|
|
142
|
+
callersMap.get(tid).push(name);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch { /* skip */ }
|
|
147
|
+
// Batch fetch callees
|
|
148
|
+
const calleesMap = new Map();
|
|
149
|
+
try {
|
|
150
|
+
const rows = await executeQuery(repoId, `
|
|
151
|
+
MATCH (n)-[:CodeRelation {type: 'CALLS'}]->(callee)
|
|
152
|
+
WHERE n.id IN [${idList}]
|
|
153
|
+
RETURN n.id AS sourceId, callee.name AS name
|
|
154
|
+
LIMIT 15
|
|
155
|
+
`);
|
|
156
|
+
for (const r of rows) {
|
|
157
|
+
const sid = r.sourceId || r[0];
|
|
158
|
+
const name = r.name || r[1];
|
|
159
|
+
if (sid && name) {
|
|
160
|
+
if (!calleesMap.has(sid))
|
|
161
|
+
calleesMap.set(sid, []);
|
|
162
|
+
calleesMap.get(sid).push(name);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
catch { /* skip */ }
|
|
167
|
+
// Batch fetch processes
|
|
168
|
+
const processesMap = new Map();
|
|
169
|
+
try {
|
|
170
|
+
const rows = await executeQuery(repoId, `
|
|
171
|
+
MATCH (n)-[r:CodeRelation {type: 'STEP_IN_PROCESS'}]->(p:Process)
|
|
172
|
+
WHERE n.id IN [${idList}]
|
|
173
|
+
RETURN n.id AS nodeId, p.heuristicLabel AS label, r.step AS step, p.stepCount AS stepCount
|
|
174
|
+
`);
|
|
175
|
+
for (const r of rows) {
|
|
176
|
+
const nid = r.nodeId || r[0];
|
|
177
|
+
const label = r.label || r[1];
|
|
178
|
+
const step = r.step || r[2];
|
|
179
|
+
const stepCount = r.stepCount || r[3];
|
|
180
|
+
if (nid && label) {
|
|
181
|
+
if (!processesMap.has(nid))
|
|
182
|
+
processesMap.set(nid, []);
|
|
183
|
+
processesMap.get(nid).push(`${label} (step ${step}/${stepCount})`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
catch { /* skip */ }
|
|
188
|
+
// Batch fetch cohesion
|
|
189
|
+
const cohesionMap = new Map();
|
|
190
|
+
try {
|
|
191
|
+
const rows = await executeQuery(repoId, `
|
|
192
|
+
MATCH (n)-[:CodeRelation {type: 'MEMBER_OF'}]->(c:Community)
|
|
193
|
+
WHERE n.id IN [${idList}]
|
|
194
|
+
RETURN n.id AS nodeId, c.cohesion AS cohesion
|
|
195
|
+
`);
|
|
196
|
+
for (const r of rows) {
|
|
197
|
+
const nid = r.nodeId || r[0];
|
|
198
|
+
const coh = r.cohesion ?? r[1] ?? 0;
|
|
199
|
+
if (nid)
|
|
200
|
+
cohesionMap.set(nid, coh);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
catch { /* skip */ }
|
|
204
|
+
// Assemble enriched results
|
|
205
|
+
const enriched = [];
|
|
206
|
+
for (const sym of uniqueSymbols) {
|
|
207
|
+
enriched.push({
|
|
208
|
+
name: sym.name,
|
|
209
|
+
filePath: sym.filePath,
|
|
210
|
+
callers: (callersMap.get(sym.nodeId) || []).slice(0, 3),
|
|
211
|
+
callees: (calleesMap.get(sym.nodeId) || []).slice(0, 3),
|
|
212
|
+
processes: processesMap.get(sym.nodeId) || [],
|
|
213
|
+
cohesion: cohesionMap.get(sym.nodeId) || 0,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
if (enriched.length === 0)
|
|
217
|
+
return '';
|
|
218
|
+
// Step 4: Rank by cohesion (internal signal) and format
|
|
219
|
+
enriched.sort((a, b) => b.cohesion - a.cohesion);
|
|
220
|
+
const lines = [`[GitNexus] ${enriched.length} related symbols found:`, ''];
|
|
221
|
+
for (const item of enriched) {
|
|
222
|
+
lines.push(`${item.name} (${item.filePath})`);
|
|
223
|
+
if (item.callers.length > 0) {
|
|
224
|
+
lines.push(` Called by: ${item.callers.join(', ')}`);
|
|
225
|
+
}
|
|
226
|
+
if (item.callees.length > 0) {
|
|
227
|
+
lines.push(` Calls: ${item.callees.join(', ')}`);
|
|
228
|
+
}
|
|
229
|
+
if (item.processes.length > 0) {
|
|
230
|
+
lines.push(` Flows: ${item.processes.join(', ')}`);
|
|
231
|
+
}
|
|
232
|
+
lines.push('');
|
|
233
|
+
}
|
|
234
|
+
return lines.join('\n').trim();
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
// Graceful failure — never break the original tool
|
|
238
|
+
return '';
|
|
239
|
+
}
|
|
240
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embedder Module
|
|
3
|
+
*
|
|
4
|
+
* Singleton factory for transformers.js embedding pipeline.
|
|
5
|
+
* Handles model loading, caching, and both single and batch embedding operations.
|
|
6
|
+
*
|
|
7
|
+
* Uses snowflake-arctic-embed-xs by default (22M params, 384 dims, ~90MB)
|
|
8
|
+
*/
|
|
9
|
+
import { type FeatureExtractionPipeline } from '@huggingface/transformers';
|
|
10
|
+
import { type EmbeddingConfig, type ModelProgress } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Progress callback type for model loading
|
|
13
|
+
*/
|
|
14
|
+
export type ModelProgressCallback = (progress: ModelProgress) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Get the current device being used for inference
|
|
17
|
+
*/
|
|
18
|
+
export declare const getCurrentDevice: () => "dml" | "cuda" | "cpu" | "wasm" | null;
|
|
19
|
+
/**
|
|
20
|
+
* Initialize the embedding model
|
|
21
|
+
* Uses singleton pattern - only loads once, subsequent calls return cached instance
|
|
22
|
+
*
|
|
23
|
+
* @param onProgress - Optional callback for model download progress
|
|
24
|
+
* @param config - Optional configuration override
|
|
25
|
+
* @param forceDevice - Force a specific device
|
|
26
|
+
* @returns Promise resolving to the embedder pipeline
|
|
27
|
+
*/
|
|
28
|
+
export declare const initEmbedder: (onProgress?: ModelProgressCallback, config?: Partial<EmbeddingConfig>, forceDevice?: "dml" | "cuda" | "cpu" | "wasm") => Promise<FeatureExtractionPipeline>;
|
|
29
|
+
/**
|
|
30
|
+
* Check if the embedder is initialized and ready
|
|
31
|
+
*/
|
|
32
|
+
export declare const isEmbedderReady: () => boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Get the embedder instance (throws if not initialized)
|
|
35
|
+
*/
|
|
36
|
+
export declare const getEmbedder: () => FeatureExtractionPipeline;
|
|
37
|
+
/**
|
|
38
|
+
* Embed a single text string
|
|
39
|
+
*
|
|
40
|
+
* @param text - Text to embed
|
|
41
|
+
* @returns Float32Array of embedding vector (384 dimensions)
|
|
42
|
+
*/
|
|
43
|
+
export declare const embedText: (text: string) => Promise<Float32Array>;
|
|
44
|
+
/**
|
|
45
|
+
* Embed multiple texts in a single batch
|
|
46
|
+
* More efficient than calling embedText multiple times
|
|
47
|
+
*
|
|
48
|
+
* @param texts - Array of texts to embed
|
|
49
|
+
* @returns Array of Float32Array embedding vectors
|
|
50
|
+
*/
|
|
51
|
+
export declare const embedBatch: (texts: string[]) => Promise<Float32Array[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Convert Float32Array to regular number array (for LadybugDB storage)
|
|
54
|
+
*/
|
|
55
|
+
export declare const embeddingToArray: (embedding: Float32Array) => number[];
|
|
56
|
+
/**
|
|
57
|
+
* Cleanup the embedder (free memory)
|
|
58
|
+
* Call this when done with embeddings
|
|
59
|
+
*/
|
|
60
|
+
export declare const disposeEmbedder: () => Promise<void>;
|