Skip to content

refactor: rename class name from indexer to context #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI

on:
push:
branches: [ master, main, refactor_name ]
branches: [ master, main, refactor_class_name ]
pull_request:
branches: [ master, main, refactor_name ]
branches: [ master, main, refactor_class_name ]

jobs:
lint_and_build:
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ While MCP is the recommended way to use Code Context with AI assistants, you can
The `@zilliz/code-context-core` package provides the fundamental functionality for code indexing and semantic search.

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

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

// Create indexer instance
const indexer = new CodeIndexer({
// Create context instance
const context = new CodeContext({
embedding,
vectorDatabase
});

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

// Perform semantic search
const results = await indexer.semanticSearch('./your-project', 'vector database operations', 5);
const results = await context.semanticSearch('./your-project', 'vector database operations', 5);
results.forEach(result => {
console.log(`File: ${result.relativePath}:${result.startLine}-${result.endLine}`);
console.log(`Score: ${(result.score * 100).toFixed(2)}%`);
Expand Down
16 changes: 8 additions & 8 deletions examples/basic-usage/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CodeIndexer, MilvusVectorDatabase, MilvusRestfulVectorDatabase, AstCodeSplitter, LangChainCodeSplitter } from '@zilliz/code-context-core';
import { CodeContext, MilvusVectorDatabase, MilvusRestfulVectorDatabase, AstCodeSplitter, LangChainCodeSplitter } from '@zilliz/code-context-core';
import * as path from 'path';

// Try to load .env file
Expand All @@ -9,7 +9,7 @@ try {
}

async function main() {
console.log('🚀 CodeIndexer Real Usage Example');
console.log('🚀 CodeContext Real Usage Example');
console.log('===============================');

try {
Expand Down Expand Up @@ -39,14 +39,14 @@ async function main() {
});
}

// 2. Create CodeIndexer instance
// 2. Create CodeContext instance
let codeSplitter;
if (splitterType === 'langchain') {
codeSplitter = new LangChainCodeSplitter(1000, 200);
} else {
codeSplitter = new AstCodeSplitter(2500, 300);
}
const indexer = new CodeIndexer({
const context = new CodeContext({
vectorDatabase,
codeSplitter,
supportedExtensions: ['.ts', '.js', '.py', '.java', '.cpp', '.go', '.rs']
Expand All @@ -57,14 +57,14 @@ async function main() {
const codebasePath = path.join(__dirname, '../..'); // Index entire project

// Check if index already exists
const hasExistingIndex = await indexer.hasIndex(codebasePath);
const hasExistingIndex = await context.hasIndex(codebasePath);
if (hasExistingIndex) {
console.log('🗑️ Existing index found, clearing it first...');
await indexer.clearIndex(codebasePath);
await context.clearIndex(codebasePath);
}

// Index with progress tracking
const indexStats = await indexer.indexCodebase(codebasePath);
const indexStats = await context.indexCodebase(codebasePath);

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

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

if (results.length > 0) {
results.forEach((result, index) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-usage/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "code-context-basic-example",
"version": "0.0.6",
"version": "0.0.7",
"description": "Basic usage example for Code Context",
"main": "index.ts",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "code-context",
"version": "0.0.6",
"version": "0.0.7",
"description": "A powerful code indexing tool with multi-platform support",
"private": true,
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/chrome-extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zilliz/code-context-chrome-extension",
"version": "0.0.6",
"version": "0.0.7",
"description": "Code Context Chrome extension for web-based code indexing",
"private": true,
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pnpm dev:core

## Project Structure

- `src/indexer.ts` - Main CodeIndexer class
- `src/context.ts` - Main CodeContext class
- `src/embedding/` - Embedding providers (OpenAI, VoyageAI, Ollama)
- `src/vectordb/` - Vector database implementations (Milvus)
- `src/splitter/` - Code splitting logic
Expand Down
26 changes: 13 additions & 13 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ MILVUS_TOKEN=your-zilliz-cloud-api-key

```typescript
import {
CodeIndexer,
CodeContext,
OpenAIEmbedding,
MilvusVectorDatabase
} from '@zilliz/code-context-core';
Expand All @@ -62,21 +62,21 @@ const vectorDatabase = new MilvusVectorDatabase({
token: process.env.MILVUS_TOKEN || ''
});

// Create indexer instance
const indexer = new CodeIndexer({
// Create context instance
const context = new CodeContext({
embedding,
vectorDatabase
});

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

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

// Search the codebase
const results = await indexer.semanticSearch(
const results = await context.semanticSearch(
'./my-project',
'function that handles user authentication',
5
Expand Down Expand Up @@ -115,10 +115,10 @@ results.forEach(result => {

## Configuration

### CodeIndexerConfig
### CodeContextConfig

```typescript
interface CodeIndexerConfig {
interface CodeContextConfig {
embedding?: Embedding; // Embedding provider
vectorDatabase?: VectorDatabase; // Vector database instance (required)
codeSplitter?: Splitter; // Code splitting strategy
Expand Down Expand Up @@ -148,7 +148,7 @@ interface CodeIndexerConfig {

## API Reference

### CodeIndexer
### CodeContext

#### Methods

Expand Down Expand Up @@ -180,7 +180,7 @@ interface SemanticSearchResult {
### Using VoyageAI Embeddings

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

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

const indexer = new CodeIndexer({
const context = new CodeContext({
embedding,
vectorDatabase
});
Expand All @@ -202,7 +202,7 @@ const indexer = new CodeIndexer({
### Custom File Filtering

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

## Contributing

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

## Related Packages

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


Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zilliz/code-context-core",
"version": "0.0.6",
"version": "0.0.7",
"description": "Core indexing engine for Code Context",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/indexer.ts → packages/core/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,23 @@ const DEFAULT_IGNORE_PATTERNS = [
'*.map', // source map files
];

export interface CodeIndexerConfig {
export interface CodeContextConfig {
embedding?: Embedding;
vectorDatabase?: VectorDatabase;
codeSplitter?: Splitter;
supportedExtensions?: string[];
ignorePatterns?: string[];
}

export class CodeIndexer {
export class CodeContext {
private embedding: Embedding;
private vectorDatabase: VectorDatabase;
private codeSplitter: Splitter;
private supportedExtensions: string[];
private ignorePatterns: string[];
private synchronizers = new Map<string, FileSynchronizer>();

constructor(config: CodeIndexerConfig = {}) {
constructor(config: CodeContextConfig = {}) {
// Initialize services
this.embedding = config.embedding || new OpenAIEmbedding({
apiKey: process.env.OPENAI_API_KEY || 'your-openai-api-key',
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ export * from './splitter';
export * from './embedding';
export * from './vectordb';
export * from './types';
export * from './indexer';
export * from './context';
export * from './sync/synchronizer';
4 changes: 2 additions & 2 deletions packages/core/src/sync/synchronizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class FileSynchronizer {

private getSnapshotPath(codebasePath: string): string {
const homeDir = os.homedir();
const merkleDir = path.join(homeDir, '.codeindexer', 'merkle');
const merkleDir = path.join(homeDir, '.codecontext', 'merkle');

const normalizedPath = path.resolve(codebasePath);
const hash = crypto.createHash('md5').update(normalizedPath).digest('hex');
Expand Down Expand Up @@ -287,7 +287,7 @@ export class FileSynchronizer {
*/
static async deleteSnapshot(codebasePath: string): Promise<void> {
const homeDir = os.homedir();
const merkleDir = path.join(homeDir, '.codeindexer', 'merkle');
const merkleDir = path.join(homeDir, '.codecontext', 'merkle');
const normalizedPath = path.resolve(codebasePath);
const hash = crypto.createHash('md5').update(normalizedPath).digest('hex');
const snapshotPath = path.join(merkleDir, `${hash}.json`);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/vectordb/milvus-vectordb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class MilvusVectorDatabase implements VectorDatabase {

const createCollectionParams = {
collection_name: collectionName,
description: description || `Code indexer collection: ${collectionName}`,
description: description || `Code context collection: ${collectionName}`,
fields: schema,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/mcp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zilliz/code-context-mcp",
"version": "0.0.6",
"version": "0.0.7",
"description": "Model Context Protocol integration for Code Context",
"type": "module",
"main": "dist/index.js",
Expand Down
Loading
Loading