Skip to content

Commit d81b9ba

Browse files
committed
refactor import path to code-context
Signed-off-by: ChengZi <chen.zhang@zilliz.com>
1 parent a253eb3 commit d81b9ba

File tree

10 files changed

+37
-37
lines changed

10 files changed

+37
-37
lines changed

examples/basic-usage/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CodeIndexer, MilvusVectorDatabase, MilvusRestfulVectorDatabase, AstCodeSplitter, LangChainCodeSplitter } from '@code-indexer/core';
1+
import { CodeIndexer, MilvusVectorDatabase, MilvusRestfulVectorDatabase, AstCodeSplitter, LangChainCodeSplitter } from '@zilliz/code-context-core';
22
import * as path from 'path';
33

44
// Try to load .env file

packages/mcp/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import {
2121
ListToolsRequestSchema,
2222
CallToolRequestSchema
2323
} from "@modelcontextprotocol/sdk/types.js";
24-
import { CodeIndexer, SemanticSearchResult } from "@code-indexer/core";
25-
import { OpenAIEmbedding, VoyageAIEmbedding, GeminiEmbedding, OllamaEmbedding } from "@code-indexer/core";
26-
import { MilvusVectorDatabase } from "@code-indexer/core";
24+
import { CodeIndexer, SemanticSearchResult } from "@zilliz/code-context-core";
25+
import { OpenAIEmbedding, VoyageAIEmbedding, GeminiEmbedding, OllamaEmbedding } from "@zilliz/code-context-core";
26+
import { MilvusVectorDatabase } from "@zilliz/code-context-core";
2727
import * as path from "path";
2828
import * as fs from "fs";
2929
import * as os from "os";
@@ -430,7 +430,7 @@ class CodeIndexerMcpServer {
430430
}
431431

432432
// Initialize file synchronizer with proper ignore patterns
433-
const { FileSynchronizer } = await import("@code-indexer/core");
433+
const { FileSynchronizer } = await import("@zilliz/code-context-core");
434434
const ignorePatterns = this.codeIndexer['ignorePatterns'] || [];
435435
console.log(`[INDEX] Using ignore patterns: ${ignorePatterns.join(', ')}`);
436436
const synchronizer = new FileSynchronizer(absolutePath, ignorePatterns);

packages/vscode-extension/src/commands/indexCommand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as vscode from 'vscode';
2-
import { CodeIndexer } from '@code-indexer/core';
2+
import { CodeIndexer } from '@zilliz/code-context-core';
33
import * as path from 'path';
44
import * as fs from 'fs';
55
import * as crypto from 'crypto';
@@ -118,7 +118,7 @@ export class IndexCommand {
118118

119119
// Initialize file synchronizer
120120
progress.report({ increment: 0, message: 'Initializing file synchronizer...' });
121-
const { FileSynchronizer } = await import("@code-indexer/core");
121+
const { FileSynchronizer } = await import("@zilliz/code-context-core");
122122
const synchronizer = new FileSynchronizer(selectedFolder.uri.fsPath, this.codeIndexer['ignorePatterns'] || []);
123123
await synchronizer.initialize();
124124
// Store synchronizer in the indexer's internal map using the same collection name generation logic

packages/vscode-extension/src/commands/searchCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as vscode from 'vscode';
2-
import { CodeIndexer, SearchQuery, SemanticSearchResult } from '@code-indexer/core';
2+
import { CodeIndexer, SearchQuery, SemanticSearchResult } from '@zilliz/code-context-core';
33
import * as path from 'path';
44

55
export class SearchCommand {

packages/vscode-extension/src/commands/syncCommand.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as vscode from 'vscode';
2-
import { CodeIndexer } from '@code-indexer/core';
2+
import { CodeIndexer } from '@zilliz/code-context-core';
33
import * as fs from 'fs';
44

55
export class SyncCommand {
@@ -43,7 +43,7 @@ export class SyncCommand {
4343
}
4444

4545
console.log(`[SYNC] Starting sync for current workspace: ${codebasePath}`);
46-
46+
4747
this.isSyncing = true;
4848

4949
try {
@@ -75,7 +75,7 @@ export class SyncCommand {
7575

7676
if (syncStats) {
7777
const totalChanges = syncStats.added + syncStats.removed + syncStats.modified;
78-
78+
7979
if (totalChanges > 0) {
8080
vscode.window.showInformationMessage(
8181
`✅ Sync complete!\n\nAdded: ${syncStats.added}, Removed: ${syncStats.removed}, Modified: ${syncStats.modified} files.`
@@ -101,9 +101,9 @@ export class SyncCommand {
101101
*/
102102
async startAutoSync(intervalMinutes: number = 5): Promise<vscode.Disposable> {
103103
console.log(`[AUTO-SYNC] Starting auto-sync with ${intervalMinutes} minute interval`);
104-
104+
105105
const intervalMs = intervalMinutes * 60 * 1000;
106-
106+
107107
const interval = setInterval(async () => {
108108
try {
109109
console.log('[AUTO-SYNC] Running periodic sync...');
@@ -144,17 +144,17 @@ export class SyncCommand {
144144
}
145145

146146
console.log(`[AUTO-SYNC] Starting silent sync for: ${codebasePath}`);
147-
147+
148148
this.isSyncing = true;
149149

150150
try {
151151
const syncStats = await this.codeIndexer.reindexByChange(codebasePath);
152-
152+
153153
const totalChanges = syncStats.added + syncStats.removed + syncStats.modified;
154-
154+
155155
if (totalChanges > 0) {
156156
console.log(`[AUTO-SYNC] Silent sync complete for '${codebasePath}'. Added: ${syncStats.added}, Removed: ${syncStats.removed}, Modified: ${syncStats.modified}`);
157-
157+
158158
// Show a subtle notification for auto-sync changes
159159
vscode.window.showInformationMessage(
160160
`🔄 Index auto-updated: ${totalChanges} file changes detected`,

packages/vscode-extension/src/config/configManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as vscode from 'vscode';
2-
import { OpenAIEmbedding, OpenAIEmbeddingConfig, VoyageAIEmbedding, VoyageAIEmbeddingConfig, OllamaEmbedding, OllamaEmbeddingConfig, GeminiEmbedding, GeminiEmbeddingConfig, MilvusConfig, SplitterType, SplitterConfig, AstCodeSplitter, LangChainCodeSplitter } from '@code-indexer/core';
2+
import { OpenAIEmbedding, OpenAIEmbeddingConfig, VoyageAIEmbedding, VoyageAIEmbeddingConfig, OllamaEmbedding, OllamaEmbeddingConfig, GeminiEmbedding, GeminiEmbeddingConfig, MilvusConfig, SplitterType, SplitterConfig, AstCodeSplitter, LangChainCodeSplitter } from '@zilliz/code-context-core';
33

44
// Simplified Milvus configuration interface for frontend
55
export interface MilvusWebConfig {

packages/vscode-extension/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { SearchCommand } from './commands/searchCommand';
55
import { IndexCommand } from './commands/indexCommand';
66
import { SyncCommand } from './commands/syncCommand';
77
import { ConfigManager } from './config/configManager';
8-
import { CodeIndexer, OpenAIEmbedding, VoyageAIEmbedding, GeminiEmbedding, MilvusRestfulVectorDatabase, AstCodeSplitter, LangChainCodeSplitter, SplitterType } from '@code-indexer/core';
8+
import { CodeIndexer, OpenAIEmbedding, VoyageAIEmbedding, GeminiEmbedding, MilvusRestfulVectorDatabase, AstCodeSplitter, LangChainCodeSplitter, SplitterType } from '@zilliz/code-context-core';
99

1010
let semanticSearchProvider: SemanticSearchViewProvider;
1111
let searchCommand: SearchCommand;

packages/vscode-extension/src/stubs/ast-splitter-stub.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class AstCodeSplitterStub {
4848
this.loadedLanguages = new Map();
4949
// Import LangChain splitter as fallback
5050
try {
51-
const { LangChainCodeSplitter } = require('@code-indexer/core');
51+
const { LangChainCodeSplitter } = require('@zilliz/code-context-core');
5252
this.fallbackSplitter = new LangChainCodeSplitter(chunkSize, chunkOverlap);
5353
} catch (error) {
5454
console.error('Failed to initialize LangChain fallback splitter:', error);
@@ -142,7 +142,7 @@ class AstCodeSplitterStub {
142142
normalizeLanguage(language) {
143143
const langMap = {
144144
'js': 'javascript',
145-
'ts': 'typescript',
145+
'ts': 'typescript',
146146
'py': 'python',
147147
'c++': 'cpp',
148148
'c': 'cpp',
@@ -158,7 +158,7 @@ class AstCodeSplitterStub {
158158
console.log('[AST Splitter] web-tree-sitter not available, using LangChain fallback');
159159
return this.fallbackSplitter.split(code, language, filePath);
160160
}
161-
161+
162162
const languageParser = await this.loadLanguage(language);
163163
if (!languageParser) {
164164
console.log(`[AST Splitter] Language ${language} not supported by web AST, using LangChain fallback for: ${filePath || 'unknown'}`);
@@ -180,13 +180,13 @@ class AstCodeSplitterStub {
180180
}
181181

182182
console.log(`🌳 [AST Splitter] Using web-tree-sitter for ${language} file: ${filePath || 'unknown'}`);
183-
183+
184184
const normalizedLang = this.normalizeLanguage(language);
185185
const nodeTypes = SPLITTABLE_NODE_TYPES[normalizedLang] || [];
186-
186+
187187
// Extract chunks based on AST nodes
188188
const chunks = this.extractChunks(tree.rootNode, code, nodeTypes, language, filePath);
189-
189+
190190
// If chunks are too large, split them further
191191
const refinedChunks = await this.refineChunks(chunks, code);
192192

@@ -203,7 +203,7 @@ class AstCodeSplitterStub {
203203

204204
// Find all splittable nodes
205205
const splittableNodes = this.findSplittableNodes(node, nodeTypes);
206-
206+
207207
if (splittableNodes.length === 0) {
208208
// No splittable nodes found, treat as single chunk
209209
return [{
@@ -222,7 +222,7 @@ class AstCodeSplitterStub {
222222
for (const astNode of splittableNodes) {
223223
const startLine = astNode.startPosition.row + 1;
224224
const endLine = astNode.endPosition.row + 1;
225-
225+
226226
// Add any content between previous node and current node
227227
if (startLine > lastEndLine + 1) {
228228
const betweenContent = lines.slice(lastEndLine, startLine - 1).join('\n');
@@ -276,7 +276,7 @@ class AstCodeSplitterStub {
276276

277277
findSplittableNodes(node, nodeTypes) {
278278
const nodes = [];
279-
279+
280280
// Check if current node is splittable
281281
if (nodeTypes.includes(node.type)) {
282282
nodes.push(node);
@@ -303,11 +303,11 @@ class AstCodeSplitterStub {
303303
// Chunk is too large, split it using LangChain splitter
304304
console.log(`📏 [AST Splitter] Chunk too large (${chunk.content.length} chars), using LangChain for refinement`);
305305
const subChunks = await this.fallbackSplitter.split(
306-
chunk.content,
307-
chunk.metadata.language,
306+
chunk.content,
307+
chunk.metadata.language,
308308
chunk.metadata.filePath
309309
);
310-
310+
311311
// Adjust line numbers for sub-chunks
312312
let currentStartLine = chunk.metadata.startLine;
313313
for (const subChunk of subChunks) {

packages/vscode-extension/webpack.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ module.exports = {
2525
// support reading TypeScript and JavaScript files
2626
extensions: ['.ts', '.js'],
2727
alias: {
28-
'@code-indexer/core': path.resolve(__dirname, '../core/dist/index.js'),
29-
'@code-indexer/core/dist/splitter': path.resolve(__dirname, '../core/dist/splitter'),
30-
'@code-indexer/core/dist/embedding': path.resolve(__dirname, '../core/dist/embedding'),
31-
'@code-indexer/core/dist/vectordb': path.resolve(__dirname, '../core/dist/vectordb')
28+
'@zilliz/code-context-core': path.resolve(__dirname, '../core/dist/index.js'),
29+
'@zilliz/code-context-core/dist/splitter': path.resolve(__dirname, '../core/dist/splitter'),
30+
'@zilliz/code-context-core/dist/embedding': path.resolve(__dirname, '../core/dist/embedding'),
31+
'@zilliz/code-context-core/dist/vectordb': path.resolve(__dirname, '../core/dist/vectordb')
3232
}
3333
},
3434
module: {

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
"allowSyntheticDefaultImports": true,
1919
"baseUrl": ".",
2020
"paths": {
21-
"@code-indexer/core": [
21+
"@zilliz/code-context-core": [
2222
"./packages/core/src"
2323
],
24-
"@code-indexer/core/*": [
24+
"@zilliz/code-context-core/*": [
2525
"./packages/core/src/*"
2626
]
2727
}

0 commit comments

Comments
 (0)