npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@liendev/core

v0.24.0

Published

Core indexing and analysis engine for Lien

Downloads

764

Readme

@liendev/core

Core indexing and analysis engine for Lien. This package provides the low-level APIs for semantic code search, complexity analysis, and framework detection.

Installation

npm install @liendev/core

Usage

import {
  indexCodebase,
  VectorDB,
  ComplexityAnalyzer,
} from '@liendev/core';

// Index a codebase
await indexCodebase({
  rootDir: '/path/to/project',
});

// Load the vector database
const db = await VectorDB.load('/path/to/project');

// Run semantic search
const results = await db.search('authentication logic', { limit: 10 });

// Analyze complexity
const analyzer = new ComplexityAnalyzer(db);
const report = await analyzer.analyze();

console.log(`Found ${report.summary.totalViolations} complexity violations`);

API Reference

Indexing

indexCodebase(options: IndexingOptions): Promise<IndexingResult>

Index a codebase for semantic search.

interface IndexingOptions {
  rootDir?: string;           // Root directory (default: cwd)
  force?: boolean;            // Force full reindex (default: false)
  verbose?: boolean;          // Verbose output (default: false)
  embeddings?: EmbeddingService;  // Pre-initialized embeddings
  config?: LienConfig;        // Pre-loaded config
  onProgress?: (progress: IndexingProgress) => void;  // Progress callback
}

interface IndexingResult {
  filesIndexed: number;
  chunksCreated: number;
  timeMs: number;
}

Example:

const result = await indexCodebase({
  rootDir: './my-project',
  force: true,
  onProgress: (progress) => {
    console.log(`Indexed ${progress.filesCompleted}/${progress.totalFiles} files`);
  },
});

console.log(`Indexed ${result.filesIndexed} files in ${result.timeMs}ms`);

Vector Database

VectorDB.load(rootDir: string): Promise<VectorDB>

Load an existing vector database.

const db = await VectorDB.load('./my-project');

db.search(query: string, options?: SearchOptions): Promise<SearchResult[]>

Perform semantic search.

interface SearchOptions {
  limit?: number;              // Max results (default: 5)
  minScore?: number;          // Min similarity score (default: 0.5)
  fileFilter?: string[];      // Filter by file paths
}

const results = await db.search('error handling', {
  limit: 10,
  minScore: 0.7,
  fileFilter: ['src/utils/**'],
});

Complexity Analysis

new ComplexityAnalyzer(db: VectorDBInterface)

Create a complexity analyzer. Uses default thresholds (no config needed).

const analyzer = new ComplexityAnalyzer(db);

analyzer.analyze(files?: string[]): Promise<ComplexityReport>

Analyze code complexity. Optionally filter to specific files.

// Analyze all files
const report = await analyzer.analyze();

// Analyze specific files
const report = await analyzer.analyze(['src/utils.ts', 'src/parser.ts']);

console.log(`${report.summary.totalViolations} violations found`);
console.log(`Average complexity: ${report.summary.avgComplexity}`);

Complexity Report Structure

interface ComplexityReport {
  summary: {
    filesAnalyzed: number;
    totalViolations: number;
    bySeverity: { error: number; warning: number };
    avgComplexity: number;
    maxComplexity: number;
  };
  files: Record<string, FileComplexityData>;
}

interface FileComplexityData {
  violations: ComplexityViolation[];
  dependents: string[];        // Files that import this file
  testAssociations: string[];  // Test files covering this file
  riskLevel: 'low' | 'medium' | 'high' | 'critical';
}

interface ComplexityViolation {
  filepath: string;
  startLine: number;
  endLine: number;
  symbolName: string;
  symbolType: 'function' | 'method' | 'class' | 'file';
  language: string;
  complexity: number;
  threshold: number;
  severity: 'warning' | 'error';
  metricType: 'cyclomatic' | 'cognitive' | 'halstead_effort' | 'halstead_bugs';
  halsteadDetails?: HalsteadDetails;
}

Configuration

Lien no longer requires per-project configuration files. It uses:

  • Global config at ~/.lien/config.json (optional, for backend selection)
  • Environment variables (LIEN_BACKEND, LIEN_QDRANT_URL, etc.)
  • Auto-detected frameworks
  • Sensible defaults for all settings

For more details, see the Configuration Guide. }, }, });


#### `createDefaultConfig(): LienConfig`

Create a default configuration.

```typescript
const config = createDefaultConfig();

Framework Detection

detectAllFrameworks(rootDir: string): Promise<FrameworkInstance[]>

Detect frameworks in a project.

import { detectAllFrameworks } from '@liendev/core';

const frameworks = await detectAllFrameworks('./my-project');

for (const fw of frameworks) {
  console.log(`Found ${fw.name} at ${fw.path}`);
}

Git Utilities

import {
  isGitRepo,
  getCurrentBranch,
  getCurrentCommit,
  getChangedFiles,
} from '@liendev/core';

const isGit = await isGitRepo('./my-project');
const branch = await getCurrentBranch('./my-project');
const commit = await getCurrentCommit('./my-project');
const changed = await getChangedFiles('./my-project');

Advanced Usage

Warm Workers (Cloud/Action Use)

Keep embeddings loaded between requests for better performance:

import { LocalEmbeddings, indexCodebase } from '@liendev/core';

// Initialize once
const embeddings = new LocalEmbeddings();
await embeddings.initialize();

// Reuse across multiple indexing operations
for (const project of projects) {
  await indexCodebase({
    rootDir: project.path,
    embeddings,  // Reuse warm embeddings
  });
}

Custom Embedding Service

Implement EmbeddingService interface for custom embeddings:

interface EmbeddingService {
  initialize(): Promise<void>;
  embed(texts: string[]): Promise<number[][]>;
  getDimension(): number;
}

class CustomEmbeddings implements EmbeddingService {
  async initialize() { /* ... */ }
  async embed(texts: string[]) { /* ... */ }
  getDimension() { return 768; }
}

await indexCodebase({
  embeddings: new CustomEmbeddings(),
});

Progress Tracking

Monitor indexing progress in real-time:

await indexCodebase({
  rootDir: './large-project',
  onProgress: (progress) => {
    const pct = (progress.filesCompleted / progress.totalFiles * 100).toFixed(1);
    console.log(`[${pct}%] ${progress.filesCompleted}/${progress.totalFiles} files`);
  },
});

Supported Languages

  • TypeScript / JavaScript
  • Python
  • PHP

More languages coming soon!

Performance

  • Embeddings: Local transformer model (~50ms per chunk)
  • Vector DB: LanceDB (Apache Arrow, SIMD-optimized)
  • Chunking: AST-based with fallback to line-based
  • Indexing: ~1000 LOC/sec on typical hardware

Architecture

@liendev/core
├── indexer/         # Code scanning, chunking, AST parsing
├── embeddings/      # Local embeddings (transformers.js)
├── vectordb/        # LanceDB wrapper
├── insights/        # Complexity analysis
├── config/          # Configuration management
├── frameworks/      # Framework detection
└── git/             # Git utilities

Who Uses This?

  • @liendev/cli - CLI and MCP server
  • @liendev/action - GitHub Action
  • @liendev/cloud - Cloud backend (private)
  • Third-party integrations - Your custom tools!

License

MIT

Links