### Install and Run Codemogger CLI Source: https://github.com/glommer/codemogger/blob/main/README.md Commands to install the Codemogger CLI globally and perform basic indexing and search operations on a project directory. ```bash npm install -g codemogger codemogger index ./my-project codemogger search "authentication middleware" ``` -------------------------------- ### Initialize and Use Codemogger SDK Source: https://github.com/glommer/codemogger/blob/main/README.md Example of how to use the Codemogger library programmatically, including setting up a local embedding model and performing searches. ```typescript import { CodeIndex } from "codemogger" import { pipeline } from "@huggingface/transformers" const extractor = await pipeline("feature-extraction", "Xenova/all-MiniLM-L6-v2", { dtype: "q8" }) const embedder = async (texts: string[]): Promise => { const output = await extractor(texts, { pooling: "mean", normalize: true }) return output.tolist() as number[][] } const db = new CodeIndex({ dbPath: "./my-project.db", embedder, embeddingModel: "all-MiniLM-L6-v2", }) await db.index("/path/to/project") const results = await db.search("authentication middleware", { mode: "semantic" }) await db.close() ``` -------------------------------- ### Initialize and Use CodeIndex SDK Source: https://context7.com/glommer/codemogger/llms.txt Example of initializing the CodeIndex class with a custom embedding function and indexing a project directory using the TypeScript SDK. ```typescript import { CodeIndex, projectDbPath } from "codemogger" import { pipeline } from "@huggingface/transformers" const extractor = await pipeline( "feature-extraction", "Xenova/all-MiniLM-L6-v2", { dtype: "q8" } ) const embedder = async (texts: string[]): Promise => { const output = await extractor(texts, { pooling: "mean", normalize: true }) return output.tolist() as number[][] } const db = new CodeIndex({ dbPath: "./my-project.db", embedder, embeddingModel: "all-MiniLM-L6-v2", }) const result = await db.index("/path/to/project", { languages: ["typescript", "rust"], verbose: true, onProgress: (progress) => { console.log(`${progress.phase}: ${progress.current}/${progress.total}`) }, }) console.log(`Indexed ${result.files} files, ${result.chunks} chunks in ${result.duration}ms`) await db.close() ``` -------------------------------- ### GET /files Source: https://context7.com/glommer/codemogger/llms.txt Lists all indexed files within the database. ```APIDOC ## GET /files ### Description Lists all indexed files with their associated hashes and chunk counts. ### Method GET ### Endpoint CodeIndex.listFiles() ### Response #### Success Response (200) - **files** (Array) - List of file metadata objects. #### Response Example [{ "filePath": "/src/index.ts", "chunkCount": 8, "fileHash": "a1b2c3d4e5f6" }] ``` -------------------------------- ### GET /codebases Source: https://context7.com/glommer/codemogger/llms.txt Lists all indexed codebases within the database. ```APIDOC ## GET /codebases ### Description Retrieves a list of all indexed codebases, including metadata like file counts and chunk counts. ### Method GET ### Endpoint CodeIndex.listCodebases() ### Response #### Success Response (200) - **codebases** (Array) - List of codebase metadata objects. #### Response Example [{ "id": 1, "name": "my-project", "fileCount": 42, "chunkCount": 256 }] ``` -------------------------------- ### Create Bun Server with Routes and WebSockets Source: https://github.com/glommer/codemogger/blob/main/CLAUDE.md Shows how to initialize a server using Bun.serve, including route handling and WebSocket configuration. ```typescript import index from "./index.html" Bun.serve({ routes: { "/": index, "/api/users/:id": { GET: (req) => { return new Response(JSON.stringify({ id: req.params.id })); }, }, }, websocket: { open: (ws) => { ws.send("Hello, world!"); }, message: (ws, message) => { ws.send(message); }, close: (ws) => {} }, development: { hmr: true, console: true, } }) ``` -------------------------------- ### Run Bun Tests Source: https://github.com/glommer/codemogger/blob/main/CLAUDE.md Demonstrates how to write and execute tests using the built-in bun:test framework. ```typescript import { test, expect } from "bun:test"; test("hello world", () => { expect(1).toBe(1); }); ``` -------------------------------- ### Implement React Frontend Component Source: https://github.com/glommer/codemogger/blob/main/CLAUDE.md Shows how to create a React component that imports CSS files directly, which Bun handles automatically. ```tsx import React from "react"; import './index.css'; import { createRoot } from "react-dom/client"; const root = createRoot(document.body); export default function Frontend() { return

Hello, world!

; } root.render(); ``` -------------------------------- ### Manage Indexed Files and MCP Server Source: https://context7.com/glommer/codemogger/llms.txt Commands to list indexed files or launch the Model Context Protocol server for AI assistant integration. ```bash codemogger list codemogger list --format json codemogger mcp ``` -------------------------------- ### Define Frontend HTML Entry Source: https://github.com/glommer/codemogger/blob/main/CLAUDE.md Demonstrates using HTML imports in Bun to reference JavaScript modules. ```html

Hello, world!

``` -------------------------------- ### Execute Bun Server with Hot Reloading Source: https://github.com/glommer/codemogger/blob/main/CLAUDE.md Command to run the server file with hot module replacement enabled. ```bash bun --hot ./index.ts ``` -------------------------------- ### Index Codebase via CLI Source: https://context7.com/glommer/codemogger/llms.txt Commands to scan and index a directory into a SQLite database. Supports filtering by language and custom database paths. ```bash codemogger index ./my-project codemogger index ./my-project --verbose codemogger index ./my-project --language rust codemogger --db /path/to/custom.db index ./my-project ``` -------------------------------- ### CLI Indexing API Source: https://context7.com/glommer/codemogger/llms.txt The index command scans a project directory, parses code using tree-sitter, and stores embeddings in a local SQLite database. ```APIDOC ## CLI: Index a Codebase ### Description Scans a directory, parses files with tree-sitter, computes embeddings, and stores chunks in SQLite. Only changed files are re-processed on subsequent runs. ### Method CLI Command ### Parameters - **path** (string) - Required - The project directory to index. - **--verbose** (flag) - Optional - Enable verbose output. - **--language** (string) - Optional - Filter by specific programming language. - **--db** (string) - Optional - Path to a custom database file. ### Request Example `codemogger index ./my-project --verbose` ``` -------------------------------- ### POST /codemogger_index Source: https://github.com/glommer/codemogger/blob/main/README.md Indexes a codebase for the first time by scanning files, chunking code using tree-sitter, and generating local embeddings. ```APIDOC ## POST /codemogger_index ### Description Indexes a directory to create a local SQLite database containing semantic and keyword search indices. ### Method POST ### Endpoint codemogger_index ### Parameters #### Request Body - **path** (string) - Required - The local file system path to the codebase directory. ### Request Example { "path": "./my-project" } ### Response #### Success Response (200) - **status** (string) - Confirmation message of indexing completion. #### Response Example { "status": "success", "indexed_files": 150 } ``` -------------------------------- ### Manage Database Paths Source: https://context7.com/glommer/codemogger/llms.txt Helper function to resolve the default database location for a project. It ensures the .codemogger directory exists. ```typescript import { projectDbPath } from "codemogger" const dbPath = projectDbPath("/path/to/my-project") ``` -------------------------------- ### List Indexed Codebases and Files Source: https://context7.com/glommer/codemogger/llms.txt Retrieve metadata about indexed codebases and individual files. Useful for auditing the state of the database and verifying indexing progress. ```typescript const codebases = await db.listCodebases() for (const codebase of codebases) { console.log(`ID: ${codebase.id}`) console.log(` Path: ${codebase.rootPath}`) } const files = await db.listFiles() for (const file of files) { console.log(`${file.filePath} (${file.chunkCount} chunks)`) } ``` -------------------------------- ### Ignore Codemogger Database Files Source: https://github.com/glommer/codemogger/blob/main/README.md Recommended configuration for .gitignore to exclude the local Codemogger database directory. ```gitignore .codemogger/ ``` -------------------------------- ### CLI Search API Source: https://context7.com/glommer/codemogger/llms.txt The search command allows querying the indexed codebase using semantic, keyword, or hybrid search modes. ```APIDOC ## CLI: Search Indexed Code ### Description Search using semantic (natural language), keyword (exact identifiers), or hybrid mode. Returns matching code chunks. ### Method CLI Command ### Parameters - **query** (string) - Required - The search term or natural language query. - **--mode** (string) - Optional - Search mode: 'semantic', 'keyword', or 'hybrid'. - **--snippet** (flag) - Optional - Include code snippets in results. - **--limit** (number) - Optional - Maximum number of results. - **--threshold** (number) - Optional - Minimum score threshold. ### Request Example `codemogger search "authentication middleware" --limit 10` ``` -------------------------------- ### Configure Embedding Functions Source: https://context7.com/glommer/codemogger/llms.txt Demonstrates how to use the built-in local embedder or provide a custom embedding function using external libraries like HuggingFace Transformers. ```typescript import { localEmbed, LOCAL_MODEL_NAME } from "codemogger/embed/local" const db = new CodeIndex({ dbPath: "./my-project.db", embedder: localEmbed, embeddingModel: LOCAL_MODEL_NAME, }) ``` -------------------------------- ### Configure Codemogger as an MCP Server Source: https://github.com/glommer/codemogger/blob/main/README.md Configuration snippet to integrate Codemogger into an AI coding agent's MCP server settings. ```json { "mcpServers": { "codemogger": { "command": "npx", "args": ["-y", "codemogger", "mcp"] } } } ``` -------------------------------- ### Search Indexed Code via CLI Source: https://context7.com/glommer/codemogger/llms.txt Perform semantic, keyword, or hybrid searches across an indexed codebase. Results can be filtered by limit and score threshold. ```bash codemogger search "authentication middleware" codemogger search "BTreeCursor" --mode keyword codemogger search "HTTP request handling" --mode hybrid codemogger search "database connection" --snippet codemogger search "error handling" --limit 10 --threshold 0.5 codemogger search "user authentication" --format text ``` -------------------------------- ### Supported Languages Mapping Source: https://context7.com/glommer/codemogger/llms.txt A mapping of supported programming languages to their corresponding file extensions, used by codemogger for parsing and chunking. ```typescript const supportedLanguages = { rust: [".rs"], javascript: [".js", ".jsx", ".mjs", ".cjs"], typescript: [".ts", ".mts", ".cts"], tsx: [".tsx"], c: [".c", ".h"], cpp: [".cpp", ".cc", ".cxx", ".hpp", ".hh", ".hxx"], c_sharp: [".cs"], python: [".py", ".pyi"], go: [".go"], zig: [".zig"], java: [".java"], scala: [".scala", ".sc"], php: [".php"], ruby: [".rb"], } ``` -------------------------------- ### POST /search Source: https://context7.com/glommer/codemogger/llms.txt Performs a search across the indexed codebase using semantic, keyword, or hybrid search modes. ```APIDOC ## POST /search ### Description Search for code chunks using semantic, keyword, or hybrid mode. Semantic search uses vector embeddings, while keyword search uses FTS for identifier lookup. ### Method POST ### Endpoint CodeIndex.search(query, options) ### Parameters #### Query Parameters - **query** (string) - Required - The search string or natural language question. - **options.mode** (string) - Required - Search mode: 'semantic', 'keyword', or 'hybrid'. - **options.limit** (number) - Optional - Maximum number of results to return. - **options.includeSnippet** (boolean) - Optional - Whether to include the code snippet in the response. - **options.threshold** (number) - Optional - Minimum relevance score for results. ### Request Example await db.search("how does authentication work?", { mode: "semantic", limit: 5, includeSnippet: true }) ### Response #### Success Response (200) - **results** (Array) - A list of code chunks matching the query. #### Response Example { "chunkKey": "src/auth.ts:10:20", "filePath": "/path/to/src/auth.ts", "name": "authenticate", "kind": "function", "score": 0.95 } ``` -------------------------------- ### TypeScript SDK: CodeIndex Source: https://context7.com/glommer/codemogger/llms.txt The CodeIndex class provides a programmatic interface for indexing and searching codebases within a Node.js environment. ```APIDOC ## SDK: CodeIndex Class ### Description The main SDK class for indexing and searching codebases. It is model-agnostic and requires a custom embedding function. ### Method Class Constructor & Methods ### Parameters - **dbPath** (string) - Required - Path to the SQLite database file. - **embedder** (function) - Required - Async function that takes string[] and returns number[][]. - **embeddingModel** (string) - Required - Name of the embedding model used. ### Request Example const db = new CodeIndex({ dbPath: "./my-project.db", embedder, embeddingModel: "all-MiniLM-L6-v2" }); await db.index("/path/to/project"); ``` -------------------------------- ### Supported Languages Source: https://context7.com/glommer/codemogger/llms.txt Lists the programming languages supported by Codemogger for parsing and chunking, along with their associated file extensions. ```APIDOC ## Supported Languages codemogger supports parsing and chunking for the following languages with their file extensions: - **rust**: [.rs] - **javascript**: [.js, .jsx, .mjs, .cjs] - **typescript**: [.ts, .mts, .cts] - **tsx**: [.tsx] - **c**: [.c, .h] - **cpp**: [.cpp, .cc, .cxx, .hpp, .hh, .hxx] - **c_sharp**: [.cs] - **python**: [.py, .pyi] - **go**: [.go] - **zig**: [.zig] - **java**: [.java] - **scala**: [.scala, .sc] - **php**: [.php] - **ruby**: [.rb] ``` -------------------------------- ### POST /codemogger_reindex Source: https://github.com/glommer/codemogger/blob/main/README.md Updates the existing index by processing only the files that have changed since the last indexing operation. ```APIDOC ## POST /codemogger_reindex ### Description Incremental update of the codebase index. Only files modified since the last run are re-parsed and re-embedded. ### Method POST ### Endpoint codemogger_reindex ### Parameters #### Request Body - **path** (string) - Required - The path to the codebase to re-index. ### Request Example { "path": "./my-project" } ### Response #### Success Response (200) - **updated_files** (integer) - Number of files processed during the incremental update. ``` -------------------------------- ### SearchResult Interface Source: https://context7.com/glommer/codemogger/llms.txt The TypeScript interface defining the structure of objects returned by search operations. ```typescript interface SearchResult { chunkKey: string filePath: string name: string kind: string signature: string snippet: string startLine: number endLine: number score: number } ``` -------------------------------- ### Search Code Chunks Source: https://context7.com/glommer/codemogger/llms.txt Perform semantic, keyword, or hybrid searches across indexed codebases. This method returns a list of search results containing code snippets and metadata based on the specified mode. ```typescript import { CodeIndex } from "codemogger" const db = new CodeIndex({ dbPath: "./my-project.db", embedder, embeddingModel: "all-MiniLM-L6-v2", }) const semanticResults = await db.search("how does authentication work?", { mode: "semantic", limit: 5, includeSnippet: true, }) const keywordResults = await db.search("handleRequest", { mode: "keyword", limit: 10, threshold: 0.3, }) const hybridResults = await db.search("database connection pool", { mode: "hybrid", limit: 5, includeSnippet: true, }) for (const result of semanticResults) { console.log(`${result.filePath}:${result.startLine}-${result.endLine}`) console.log(` [${result.kind}] ${result.name}`) console.log(` ${result.signature}`) console.log(` Score: ${result.score.toFixed(3)}`) if (result.snippet) { console.log(`\n${result.snippet}\n`) } } await db.close() ``` -------------------------------- ### POST /codemogger_search Source: https://github.com/glommer/codemogger/blob/main/README.md Performs a search query over the indexed codebase using either semantic (vector) or keyword (FTS) search modes. ```APIDOC ## POST /codemogger_search ### Description Queries the indexed codebase for relevant code chunks based on natural language or specific identifiers. ### Method POST ### Endpoint codemogger_search ### Parameters #### Request Body - **query** (string) - Required - The search term or natural language query. - **mode** (string) - Optional - Search mode: 'semantic' (default) or 'keyword'. ### Request Example { "query": "authentication middleware", "mode": "semantic" } ### Response #### Success Response (200) - **results** (array) - List of matching code chunks with file paths and snippet content. #### Response Example { "results": [ { "file": "src/auth.ts", "snippet": "function authenticate(req, res) { ... }", "score": 0.92 } ] } ``` -------------------------------- ### CodeChunk Interface Definition Source: https://context7.com/glommer/codemogger/llms.txt Represents the internal structure of a code chunk, containing metadata such as file path, language, kind, name, and the code snippet itself. ```typescript interface CodeChunk { chunkKey: string // Unique key: "file_path:startLine:endLine" filePath: string // Absolute path to source file language: string // Language name (e.g., "typescript", "rust") kind: string // Node type: "function", "struct", "class", etc. name: string // Extracted name of the definition signature: string // First line (function signature) snippet: string // Full source code startLine: number // 1-based start line endLine: number // 1-based end line fileHash: string // SHA-256 hash of source file } ``` -------------------------------- ### Data Structures Source: https://context7.com/glommer/codemogger/llms.txt Defines the data structures used by Codemogger for representing index results and code chunks. ```APIDOC ## IndexResult The result type returned by index operations. ### Fields - **files** (number) - Number of files processed - **chunks** (number) - Number of chunks created - **embedded** (number) - Number of chunks embedded - **skipped** (number) - Number of unchanged files skipped - **removed** (number) - Number of stale files removed - **errors** (string[]) - Any errors encountered - **duration** (number) - Total time in milliseconds ## CodeChunk The internal representation of a code chunk. ### Fields - **chunkKey** (string) - Unique key: "file_path:startLine:endLine" - **filePath** (string) - Absolute path to source file - **language** (string) - Language name (e.g., "typescript", "rust") - **kind** (string) - Node type: "function", "struct", "class", etc. - **name** (string) - Extracted name of the definition - **signature** (string) - First line (function signature) - **snippet** (string) - Full source code - **startLine** (number) - 1-based start line - **endLine** (number) - 1-based end line - **fileHash** (string) - SHA-256 hash of source file ``` -------------------------------- ### IndexResult Interface Definition Source: https://context7.com/glommer/codemogger/llms.txt Defines the structure of the result returned by index operations, including counts of files, chunks, and errors encountered. ```typescript interface IndexResult { files: number // Number of files processed chunks: number // Number of chunks created embedded: number // Number of chunks embedded skipped: number // Number of unchanged files skipped removed: number // Number of stale files removed errors: string[] // Any errors encountered duration: number // Total time in milliseconds } ``` -------------------------------- ### Embedder Type Source: https://context7.com/glommer/codemogger/llms.txt Defines the type signature for custom embedding functions used by Codemogger. ```APIDOC ## Embedder Type The function signature for custom embedding functions. ### Type Definition - **Embedder** (function) - Takes an array of strings (texts) and returns a Promise resolving to a 2D array of numbers (embeddings). ``` -------------------------------- ### Embedder Type Definition Source: https://context7.com/glommer/codemogger/llms.txt Defines the type for custom embedding functions, which take an array of strings and return a promise resolving to a 2D array of numbers representing embeddings. ```typescript type Embedder = (texts: string[]) => Promise ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.