Skip to content

Commit 486f4c3

Browse files
committed
refactor: rename class name from indexer to context
Signed-off-by: ChengZi <chen.zhang@zilliz.com>
1 parent be04eaf commit 486f4c3

File tree

21 files changed

+228
-200
lines changed

21 files changed

+228
-200
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: CI
22

33
on:
44
push:
5-
branches: [ master, main, refactor_name ]
5+
branches: [ master, main, refactor_class_name ]
66
pull_request:
7-
branches: [ master, main, refactor_name ]
7+
branches: [ master, main, refactor_class_name ]
88

99
jobs:
1010
lint_and_build:

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ While MCP is the recommended way to use Code Context with AI assistants, you can
374374
The `@zilliz/code-context-core` package provides the fundamental functionality for code indexing and semantic search.
375375

376376
```typescript
377-
import { CodeIndexer, MilvusVectorDatabase, OpenAIEmbedding } from '@zilliz/code-context-core';
377+
import { CodeContext, MilvusVectorDatabase, OpenAIEmbedding } from '@zilliz/code-context-core';
378378

379379
// Initialize embedding provider
380380
const embedding = new OpenAIEmbedding({
@@ -388,20 +388,20 @@ const vectorDatabase = new MilvusVectorDatabase({
388388
token: process.env.MILVUS_TOKEN || 'your-zilliz-cloud-api-key'
389389
});
390390

391-
// Create indexer instance
392-
const indexer = new CodeIndexer({
391+
// Create context instance
392+
const context = new CodeContext({
393393
embedding,
394394
vectorDatabase
395395
});
396396

397397
// Index your codebase with progress tracking
398-
const stats = await indexer.indexCodebase('./your-project', (progress) => {
398+
const stats = await context.indexCodebase('./your-project', (progress) => {
399399
console.log(`${progress.phase} - ${progress.percentage}%`);
400400
});
401401
console.log(`Indexed ${stats.indexedFiles} files, ${stats.totalChunks} chunks`);
402402

403403
// Perform semantic search
404-
const results = await indexer.semanticSearch('./your-project', 'vector database operations', 5);
404+
const results = await context.semanticSearch('./your-project', 'vector database operations', 5);
405405
results.forEach(result => {
406406
console.log(`File: ${result.relativePath}:${result.startLine}-${result.endLine}`);
407407
console.log(`Score: ${(result.score * 100).toFixed(2)}%`);

examples/basic-usage/index.ts

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

44
// Try to load .env file
@@ -9,7 +9,7 @@ try {
99
}
1010

1111
async function main() {
12-
console.log('🚀 CodeIndexer Real Usage Example');
12+
console.log('🚀 CodeContext Real Usage Example');
1313
console.log('===============================');
1414

1515
try {
@@ -39,14 +39,14 @@ async function main() {
3939
});
4040
}
4141

42-
// 2. Create CodeIndexer instance
42+
// 2. Create CodeContext instance
4343
let codeSplitter;
4444
if (splitterType === 'langchain') {
4545
codeSplitter = new LangChainCodeSplitter(1000, 200);
4646
} else {
4747
codeSplitter = new AstCodeSplitter(2500, 300);
4848
}
49-
const indexer = new CodeIndexer({
49+
const context = new CodeContext({
5050
vectorDatabase,
5151
codeSplitter,
5252
supportedExtensions: ['.ts', '.js', '.py', '.java', '.cpp', '.go', '.rs']
@@ -57,14 +57,14 @@ async function main() {
5757
const codebasePath = path.join(__dirname, '../..'); // Index entire project
5858

5959
// Check if index already exists
60-
const hasExistingIndex = await indexer.hasIndex(codebasePath);
60+
const hasExistingIndex = await context.hasIndex(codebasePath);
6161
if (hasExistingIndex) {
6262
console.log('🗑️ Existing index found, clearing it first...');
63-
await indexer.clearIndex(codebasePath);
63+
await context.clearIndex(codebasePath);
6464
}
6565

6666
// Index with progress tracking
67-
const indexStats = await indexer.indexCodebase(codebasePath);
67+
const indexStats = await context.indexCodebase(codebasePath);
6868

6969
// 4. Show indexing statistics
7070
console.log(`\n📊 Indexing stats: ${indexStats.indexedFiles} files, ${indexStats.totalChunks} code chunks`);
@@ -81,7 +81,7 @@ async function main() {
8181

8282
for (const query of queries) {
8383
console.log(`\n🔎 Search: "${query}"`);
84-
const results = await indexer.semanticSearch(codebasePath, query, 3, 0.3);
84+
const results = await context.semanticSearch(codebasePath, query, 3, 0.3);
8585

8686
if (results.length > 0) {
8787
results.forEach((result, index) => {

packages/core/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pnpm dev:core
2727

2828
## Project Structure
2929

30-
- `src/indexer.ts` - Main CodeIndexer class
30+
- `src/context.ts` - Main CodeContext class
3131
- `src/embedding/` - Embedding providers (OpenAI, VoyageAI, Ollama)
3232
- `src/vectordb/` - Vector database implementations (Milvus)
3333
- `src/splitter/` - Code splitting logic

packages/core/README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ MILVUS_TOKEN=your-zilliz-cloud-api-key
4545

4646
```typescript
4747
import {
48-
CodeIndexer,
48+
CodeContext,
4949
OpenAIEmbedding,
5050
MilvusVectorDatabase
5151
} from '@zilliz/code-context-core';
@@ -62,21 +62,21 @@ const vectorDatabase = new MilvusVectorDatabase({
6262
token: process.env.MILVUS_TOKEN || ''
6363
});
6464

65-
// Create indexer instance
66-
const indexer = new CodeIndexer({
65+
// Create context instance
66+
const context = new CodeContext({
6767
embedding,
6868
vectorDatabase
6969
});
7070

7171
// Index a codebase
72-
const stats = await indexer.indexCodebase('./my-project', (progress) => {
72+
const stats = await context.indexCodebase('./my-project', (progress) => {
7373
console.log(`${progress.phase} - ${progress.percentage}%`);
7474
});
7575

7676
console.log(`Indexed ${stats.indexedFiles} files with ${stats.totalChunks} chunks`);
7777

7878
// Search the codebase
79-
const results = await indexer.semanticSearch(
79+
const results = await context.semanticSearch(
8080
'./my-project',
8181
'function that handles user authentication',
8282
5
@@ -115,10 +115,10 @@ results.forEach(result => {
115115

116116
## Configuration
117117

118-
### CodeIndexerConfig
118+
### CodeContextConfig
119119

120120
```typescript
121-
interface CodeIndexerConfig {
121+
interface CodeContextConfig {
122122
embedding?: Embedding; // Embedding provider
123123
vectorDatabase?: VectorDatabase; // Vector database instance (required)
124124
codeSplitter?: Splitter; // Code splitting strategy
@@ -148,7 +148,7 @@ interface CodeIndexerConfig {
148148

149149
## API Reference
150150

151-
### CodeIndexer
151+
### CodeContext
152152

153153
#### Methods
154154

@@ -180,7 +180,7 @@ interface SemanticSearchResult {
180180
### Using VoyageAI Embeddings
181181

182182
```typescript
183-
import { CodeIndexer, MilvusVectorDatabase, VoyageAIEmbedding } from '@zilliz/code-context-core';
183+
import { CodeContext, MilvusVectorDatabase, VoyageAIEmbedding } from '@zilliz/code-context-core';
184184

185185
// Initialize with VoyageAI embedding provider
186186
const embedding = new VoyageAIEmbedding({
@@ -193,7 +193,7 @@ const vectorDatabase = new MilvusVectorDatabase({
193193
token: process.env.MILVUS_TOKEN || ''
194194
});
195195

196-
const indexer = new CodeIndexer({
196+
const context = new CodeContext({
197197
embedding,
198198
vectorDatabase
199199
});
@@ -202,7 +202,7 @@ const indexer = new CodeIndexer({
202202
### Custom File Filtering
203203

204204
```typescript
205-
const indexer = new CodeIndexer({
205+
const context = new CodeContext({
206206
embedding,
207207
vectorDatabase,
208208
supportedExtensions: ['.ts', '.js', '.py', '.java'],
@@ -257,13 +257,13 @@ The file synchronization system uses a **Merkle tree-based approach** combined w
257257

258258
## Contributing
259259

260-
This package is part of the CodeIndexer monorepo. Please see:
260+
This package is part of the CodeContext monorepo. Please see:
261261
- [Main Contributing Guide](../../CONTRIBUTING.md) - General contribution guidelines
262262
- [Core Package Contributing](CONTRIBUTING.md) - Specific development guide for this package
263263

264264
## Related Packages
265265

266-
- **[@code-indexer/mcp](../mcp)** - MCP server that uses this core engine
266+
- **[@code-context/mcp](../mcp)** - MCP server that uses this core engine
267267
- **[VSCode Extension](../vscode-extension)** - VSCode extension built on this core
268268

269269

packages/core/src/indexer.ts renamed to packages/core/src/context.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,23 @@ const DEFAULT_IGNORE_PATTERNS = [
7979
'*.map', // source map files
8080
];
8181

82-
export interface CodeIndexerConfig {
82+
export interface CodeContextConfig {
8383
embedding?: Embedding;
8484
vectorDatabase?: VectorDatabase;
8585
codeSplitter?: Splitter;
8686
supportedExtensions?: string[];
8787
ignorePatterns?: string[];
8888
}
8989

90-
export class CodeIndexer {
90+
export class CodeContext {
9191
private embedding: Embedding;
9292
private vectorDatabase: VectorDatabase;
9393
private codeSplitter: Splitter;
9494
private supportedExtensions: string[];
9595
private ignorePatterns: string[];
9696
private synchronizers = new Map<string, FileSynchronizer>();
9797

98-
constructor(config: CodeIndexerConfig = {}) {
98+
constructor(config: CodeContextConfig = {}) {
9999
// Initialize services
100100
this.embedding = config.embedding || new OpenAIEmbedding({
101101
apiKey: process.env.OPENAI_API_KEY || 'your-openai-api-key',

packages/core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ export * from './splitter';
22
export * from './embedding';
33
export * from './vectordb';
44
export * from './types';
5-
export * from './indexer';
5+
export * from './context';
66
export * from './sync/synchronizer';

packages/core/src/sync/synchronizer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class FileSynchronizer {
2121

2222
private getSnapshotPath(codebasePath: string): string {
2323
const homeDir = os.homedir();
24-
const merkleDir = path.join(homeDir, '.codeindexer', 'merkle');
24+
const merkleDir = path.join(homeDir, '.codecontext', 'merkle');
2525

2626
const normalizedPath = path.resolve(codebasePath);
2727
const hash = crypto.createHash('md5').update(normalizedPath).digest('hex');
@@ -287,7 +287,7 @@ export class FileSynchronizer {
287287
*/
288288
static async deleteSnapshot(codebasePath: string): Promise<void> {
289289
const homeDir = os.homedir();
290-
const merkleDir = path.join(homeDir, '.codeindexer', 'merkle');
290+
const merkleDir = path.join(homeDir, '.codecontext', 'merkle');
291291
const normalizedPath = path.resolve(codebasePath);
292292
const hash = crypto.createHash('md5').update(normalizedPath).digest('hex');
293293
const snapshotPath = path.join(merkleDir, `${hash}.json`);

packages/core/src/vectordb/milvus-vectordb.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class MilvusVectorDatabase implements VectorDatabase {
8686

8787
const createCollectionParams = {
8888
collection_name: collectionName,
89-
description: description || `Code indexer collection: ${collectionName}`,
89+
description: description || `Code context collection: ${collectionName}`,
9090
fields: schema,
9191
};
9292

0 commit comments

Comments
 (0)