### Ollama Setup Commands Source: https://github.com/anrgct/autodev-codebase/blob/master/CONFIG.md Commands to install Ollama, pull models, configure Autodev for Ollama, and start indexing. ```bash # Install and start Ollama brew install ollama ollama serve # Pull embedding model ollama pull nomic-embed-text # Configure codebase config --set embedderProvider=ollama,embedderModelId=nomic-embed-text codebase config --set qdrantUrl=http://localhost:6333 # Start indexing codebase index --log-level=debug --force ``` -------------------------------- ### Quick Start: MCP Server Demo Source: https://github.com/anrgct/autodev-codebase/blob/master/README.md Demonstrates running the MCP server in demo mode. This command starts the server with demo data for testing. ```bash # MCP server codebase index --serve --demo ``` -------------------------------- ### Basic Node.js Usage Example Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/project-outline.md Demonstrates fundamental usage patterns for the autodev library in a Node.js environment. No specific setup is required beyond having the library installed. ```typescript function basicUsageExample() { // ... implementation details ... } ``` -------------------------------- ### Project Configuration Example Source: https://github.com/anrgct/autodev-codebase/blob/master/CONFIG.md Example of a project-specific configuration file (`./autodev-config.json`). This file allows you to define settings for a particular project. ```json { "embedderProvider": "ollama", "embedderModelId": "nomic-embed-text", "qdrantUrl": "http://localhost:6333" } ``` -------------------------------- ### Global Configuration Example Source: https://github.com/anrgct/autodev-codebase/blob/master/CONFIG.md Example of a global user-specific configuration file (`~/.autodev-cache/autodev-config.json`). These settings apply across all projects. ```json { "embedderProvider": "openai", "embedderModelId": "text-embedding-3-small", "embedderOpenAiApiKey": "sk-your-key", "qdrantUrl": "http://localhost:6333", "vectorSearchMinScore": 0.3, "vectorSearchMaxResults": 20 } ``` -------------------------------- ### Call Command Framework Setup Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/plans/260117-dependency-cli.md This snippet shows the initial setup for the 'call' command, including file creation, function implementation, and command registration within the CLI. ```typescript // src/commands/call.ts // 实现 createCallCommand() 函数 // 在 src/cli.ts 中注册新命令 ``` -------------------------------- ### Install CLI and Configure Embedding Backend Source: https://context7.com/anrgct/autodev-codebase/llms.txt Install the CLI globally and configure an embedding backend. For privacy, Ollama is recommended for local operation. Ensure Qdrant is running. ```bash # Option A: Fully local with Ollama (recommended for privacy) brew install ollama ripgrep ollama serve ollama pull nomic-embed-text # Start Qdrant vector database docker run -d -p 6333:6333 -p 6334:6334 --name qdrant qdrant/qdrant # Install CLI npm install -g @autodev/codebase # Configure for Ollama codebase config --set embedderProvider=ollama,embedderModelId=nomic-embed-text codebase config --set qdrantUrl=http://localhost:6333 # Option B: OpenAI export OPENAI_API_KEY="sk-your-key" codebase config --set embedderProvider=openai,embedderModelId=text-embedding-3-small codebase config --set qdrantUrl=http://localhost:6333 ``` -------------------------------- ### User Guide: Dependency Analysis Capabilities Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/plans/260121-top-level-calls-not-tracked.md This user guide update outlines the supported dependency types, including the new 'module-level calls', and provides an example of how top-level code in files like `app.js` is now tracked. ```markdown ## 依赖分析功能 ### 支持的依赖类型 1. **函数间调用** - `functionA → functionB` 2. **类间调用** - `ClassA → ClassB` 3. **方法间调用** - `ClassA.methodX → ClassB.methodY` 4. **模块级调用** - `module → function/class` (新增) ### 顶层代码支持 依赖分析器会自动追踪文件顶层代码的函数调用: ```javascript // 入口文件 app.js const service = new UserService(); // ✅ 会追踪 service.initialize(); // ✅ 会追踪 console.log('Ready'); // ❌ 自动过滤(内置函数) ``` 这对以下场景特别有用: - 入口文件的初始化逻辑 - 脚本文件的执行流程 - 测试文件的顶层 describe/it 调用 ``` -------------------------------- ### CLI Example for Autodev Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/project-outline.md Demonstrates how to interact with the autodev tools via the command-line interface. This example is useful for understanding command-line arguments and output. ```typescript function cliExample() { // ... implementation details ... } ``` -------------------------------- ### Start Qdrant Vector Database Source: https://github.com/anrgct/autodev-codebase/blob/master/README.md Run a Qdrant instance using Docker for vector storage. This command starts a container named 'qdrant' and maps the default ports. ```bash docker run -d -p 6333:6333 -p 6334:6334 --name qdrant qdrant/qdrant ``` -------------------------------- ### Summarizer Language Examples Source: https://github.com/anrgct/autodev-codebase/blob/master/CONFIG.md Examples of configuring the summarizer for English and Chinese output. ```json { "summarizerProvider": "ollama", "summarizerLanguage": "English" } ``` ```json { "summarizerProvider": "ollama", "summarizerLanguage": "Chinese" } ``` -------------------------------- ### Start Stdio MCP Adapter Source: https://context7.com/anrgct/autodev-codebase/llms.txt Starts the stdio adapter, connecting it to the running HTTP MCP server via its URL. This allows IDEs using stdio transport to communicate with the HTTP server. ```bash codebase stdio --server-url=http://localhost:3001/mcp ``` -------------------------------- ### Test Development Mode Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/plans/260122-unify-wasm-path-resolution.md Start the development server and manually verify that WASM files are loaded correctly in development mode. ```bash npm run dev ``` -------------------------------- ### MCP Server Status Output Source: https://context7.com/anrgct/autodev-codebase/llms.txt Example output when starting the MCP server, showing the running address, workspace path, MCP endpoint, and health check URL. ```text 🔍 Codebase MCP Server running at http://localhost:3001 📁 Workspace: /my/project 🌐 MCP endpoint: http://localhost:3001/mcp ❤️ Health check: http://localhost:3001/health ``` -------------------------------- ### Start Stdio MCP Adapter with Custom Timeout Source: https://context7.com/anrgct/autodev-codebase/llms.txt Starts the stdio adapter with a custom timeout value (in milliseconds) for communication with the HTTP MCP server. ```bash codebase stdio --server-url=http://localhost:3001/mcp --timeout=60000 ``` -------------------------------- ### Quick Start: Index and Search Demo Source: https://github.com/anrgct/autodev-codebase/blob/master/README.md Demonstrates the core indexing and search functionality in demo mode. This is recommended for first-time users to test the tool without a real project. ```bash # Index & search codebase index --demo codebase search "user greet" --demo ``` -------------------------------- ### Autodev Codebase Configuration Examples (JSON) Source: https://github.com/anrgct/autodev-codebase/blob/master/README.md Illustrative JSON configurations for different embedder providers (Ollama, OpenAI, OpenAI-compatible). These examples show how to set provider, model ID, API keys, and base URLs. ```json { "embedderProvider": "ollama", "embedderModelId": "nomic-embed-text", "qdrantUrl": "http://localhost:6333" } ``` ```json { "embedderProvider": "openai", "embedderModelId": "text-embedding-3-small", "embedderOpenAiApiKey": "sk-your-key", "qdrantUrl": "http://localhost:6333" } ``` ```json { "embedderProvider": "openai-compatible", "embedderModelId": "text-embedding-3-small", "embedderOpenAiCompatibleApiKey": "sk-your-key", "embedderOpenAiCompatibleBaseUrl": "https://api.openai.com/v1" } ``` -------------------------------- ### Start MCP HTTP Server Source: https://github.com/anrgct/autodev-codebase/blob/master/README.md Starts the MCP server in HTTP streamable mode, recommended for IDE integration. Specify the port using `--port`. ```bash codebase index --serve --port=3001 ``` -------------------------------- ### Quick Start: Call Graph Analysis Demo Source: https://github.com/anrgct/autodev-codebase/blob/master/README.md Demonstrates call graph analysis in demo mode. This command shows the relationships between 'app' and 'addUser' functions. ```bash # Call graph analysis codebase call --demo --query="app,addUser" ``` -------------------------------- ### CLI Usage Examples: Summary, Query, and Visualization Modes Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/plans/260117-dependency-cli.md Illustrates various ways to use the dependency CLI, covering summary output (plain text and JSON), query mode for specific functions, and exporting/opening visualization data. ```bash ✅ codebase call # 显示统计概览(tree 格式) ✅ codebase call --json # 显示统计概览(JSON 格式,包含示例节点) ✅ codebase call --viz graph.json # 导出完整可视化数据(Cytoscape.js 格式) ✅ codebase call --open # 打开可视化查看器 ✅ codebase call --viz graph.json --open # 导出并打开 ``` ```bash ✅ codebase call --query "getUser" # 显示依赖树(tree 格式) ✅ codebase call --query "getUser" --json # 显示依赖树(JSON 格式) ✅ codebase call --query "getUser,validateUser" # 多函数连接分析 ``` -------------------------------- ### Start HTTP MCP Server (Default Port) Source: https://context7.com/anrgct/autodev-codebase/llms.txt Starts the Model Context Protocol (MCP) server on the default port, indexing the specified project path. The server exposes search and outline tools for AI IDEs. ```bash codebase index --serve --path=/my/project ``` -------------------------------- ### Migration Example: Scanner Before and After API Redesign Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/plans/260119-list-files-api-redesign.md Illustrates the refactoring of a scanner component's file listing logic. The 'Before' example uses the older `listFiles` (likely ripgrep-based) and requires manual filtering. The 'After' examples show how to use the new `listOnlyFiles` convenience method or the structured `listFiles` API for type-safe and cleaner code. ```typescript const [allPaths, _] = await listFiles(directoryPath, true, 10000, { pathUtils: this.deps.pathUtils, ripgrepPath: 'rg' // 🔴 需要 ripgrep }) // 🔴 需要手动过滤 const filePaths = allPaths.filter((p) => !p.endsWith("/")) ``` ```typescript // 方式 1: 使用便捷方法 const [files, _] = await listOnlyFiles(directoryPath, true, 10000, { pathUtils: this.deps.pathUtils, workspace: this.deps.workspace, // ✅ 通过 workspace 获取 ignoreService fileSystem: this.deps.fileSystem }) // 方式 2: 使用结构化 API const result = await listFiles(directoryPath, { recursive: true, limit: 10000, includeDirectories: false, // 🔥 明确声明只要文件 deps: { pathUtils: this.deps.pathUtils, workspace: this.deps.workspace, fileSystem: this.deps.fileSystem } }) const files = result.files // ✅ 类型安全,无需过滤 ``` -------------------------------- ### Install @autodev/codebase CLI Source: https://github.com/anrgct/autodev-codebase/blob/master/README.md Install the @autodev/codebase CLI globally and configure it to use Ollama for embeddings. This sets up the default embedder provider and model. ```bash npm install -g @autodev/codebase codebase config --set embedderProvider=ollama,embedderModelId=nomic-embed-text ``` -------------------------------- ### Complete Autodev Configuration Source: https://github.com/anrgct/autodev-codebase/blob/master/CONFIG.md A comprehensive configuration example including Ollama for embedding and reranking, and summarization with specified batch sizes and retries. ```json { "embedderProvider": "ollama", "embedderModelId": "nomic-embed-text", "embedderOllamaBaseUrl": "http://localhost:11434", "qdrantUrl": "http://localhost:6333", "vectorSearchMinScore": 0.3, "vectorSearchMaxResults": 20, "rerankerEnabled": true, "rerankerProvider": "ollama", "rerankerOllamaModelId": "qwen3-vl:4b-instruct", "rerankerOllamaBaseUrl": "http://localhost:11434", "rerankerMinScore": 0.5, "rerankerBatchSize": 10, "rerankerConcurrency": 3, "rerankerMaxRetries": 3, "rerankerRetryDelayMs": 1000, "summarizerProvider": "ollama", "summarizerOllamaBaseUrl": "http://localhost:11434", "summarizerOllamaModelId": "qwen3-vl:4b-instruct", "summarizerLanguage": "English", "summarizerBatchSize": 2, "summarizerConcurrency": 2, "summarizerMaxRetries": 3, "summarizerRetryDelayMs": 1000 } ``` -------------------------------- ### Start HTTP MCP Server (Custom Port) Source: https://context7.com/anrgct/autodev-codebase/llms.txt Starts the MCP server on a custom port (e.g., 3001) for the specified project path. This allows running multiple servers or avoiding port conflicts. ```bash codebase index --serve --port=3001 --path=/my/project ``` -------------------------------- ### Code Outline with AI Summaries CLI Example Source: https://github.com/anrgct/autodev-codebase/blob/master/README.md Generate a structured outline of code files with AI-generated summaries. This command processes 'hello.js' and provides summaries for functions and classes. ```bash # Code outline with AI summaries - Understand code structure at a glance ╭─ ~/workspace/autodev-codebase ╰─❯ codebase outline 'hello.js' --demo --summarize # hello.js (23 lines) └─ Defines a greeting function that logs a personalized hello message and returns a welcome string. Implements a UserManager class managing an array of users with methods to add users and retrieve the current user list. Exports both components for external use. 2--5 | function greetUser └─ Implements user greeting logic by logging a personalized hello message and returning a welcome message 7--20 | class UserManager └─ Manages user data with methods to add users to a list and retrieve all stored users 12--15 | method addUser └─ Adds a user to the users array and logs a confirmation message with the user's name. ``` -------------------------------- ### Start Stdio Adapter for MCP Source: https://github.com/anrgct/autodev-codebase/blob/master/README.md Connects to a running MCP server using the stdio adapter, typically for IDEs that require stdio communication. ```bash # First start the MCP server in one terminal codebase index --serve --port=3001 # Then connect via stdio adapter in another terminal (for IDEs that require stdio) codebase stdio --server-url=http://localhost:3001/mcp ``` -------------------------------- ### Install Ollama and Nomic Embed Text Source: https://github.com/anrgct/autodev-codebase/blob/master/README.md Install necessary dependencies for local embedding and reranking using Ollama. Ensure Ollama is running before pulling models. ```bash brew install ollama ripgrep ollama serve ollama pull nomic-embed-text ``` -------------------------------- ### OpenAI Setup Command Source: https://github.com/anrgct/autodev-codebase/blob/master/CONFIG.md Command to set the OpenAI API key and configure Autodev to use OpenAI for embeddings. ```bash export OPENAI_API_KEY="sk-your-key" codebase config --set embedderProvider=openai,embedderModelId=text-embedding-3-small ``` -------------------------------- ### Initialize and Index Codebase Source: https://github.com/anrgct/autodev-codebase/blob/master/CLAUDE.md Use CodeIndexManager for initializing the system and starting the code indexing process. Ensure dependencies are correctly created for Node.js environments. ```typescript import { CodeIndexManager, createNodeDependencies } from './src/index.ts'; const deps = createNodeDependencies(); const manager = CodeIndexManager.getInstance(deps); await manager.initialize(); await manager.startIndexing(); const results = await manager.searchIndex(query, { limit: 20 }); ``` -------------------------------- ### Codebase Index Serve Source: https://context7.com/anrgct/autodev-codebase/llms.txt Starts an HTTP Model Context Protocol (MCP) server that exposes `search_codebase` and `outline_codebase` tools to AI IDEs. ```APIDOC ## `codebase index --serve` — HTTP MCP Server Starts an HTTP Model Context Protocol server that exposes `search_codebase` and `outline_codebase` tools to AI IDEs (Cursor, Windsurf, Claude, etc.). The server uses the Streamable HTTP transport with session management and supports Server-Sent Events. It begins indexing the workspace as soon as it starts and keeps the index up to date via the file watcher. ```bash # Start the MCP server on the default port codebase index --serve --path=/my/project # Custom port codebase index --serve --port=3001 --path=/my/project # Output: # 🔍 Codebase MCP Server running at http://localhost:3001 # 📁 Workspace: /my/project # 🌐 MCP endpoint: http://localhost:3001/mcp # ❤️ Health check: http://localhost:3001/health # Health check curl http://localhost:3001/health # {"status":"healthy","timestamp":"2025-01-22T10:00:00.000Z","workspace":"/my/project"} # IDE configuration (HTTP Streamable — recommended) # Add to your IDE's MCP config file: cat << 'EOF' { "mcpServers": { "codebase": { "url": "http://localhost:3001/mcp" } } } EOF # Call search_codebase tool via MCP JSON-RPC curl -X POST http://localhost:3001/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "search_codebase", "arguments": { "query": "How does user authentication work?", "limit": 10, "filters": { "pathFilters": ["src/**/*.ts", "!**/*.test.ts"], "minScore": 0.6 } } } }' # Call outline_codebase tool curl -X POST http://localhost:3001/mcp \ -H "Content-Type: application/json" \ -H "MCP-Session-ID: " \ -d '{ "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "outline_codebase", "arguments": { "path": "src/auth/service.ts", "summarize": true, "title": false } } }' ``` ``` -------------------------------- ### Get Configuration as JSON Source: https://github.com/anrgct/autodev-codebase/blob/master/CONFIG.md Obtain the complete configuration hierarchy in JSON format. This is ideal for scripting and programmatic access to configuration settings. ```bash codebase config --get --json ``` -------------------------------- ### Example of Concise Path Handling in `call.ts` Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/plans/260122-unify-wasm-path-resolution.md Illustrates an effective approach to path resolution by using only two paths based on the development environment. This method is clear, efficient, and aligns with project structure. ```typescript const isDevelopment = currentFilePath.endsWith('.ts'); const viewerPath = isDevelopment ? path.join(currentDir, '../../static/graph_viewer.html') // src/commands -> static : path.join(currentDir, 'static/graph_viewer.html'); // dist -> dist/static ``` -------------------------------- ### OpenAI-Compatible Summarizer Configuration JSON Source: https://github.com/anrgct/autodev-codebase/blob/master/CONFIG.md Example JSON configuration for an OpenAI-compatible summarizer, specifying API base URL, model ID, and API key. ```json { "summarizerProvider": "openai-compatible", "summarizerOpenAiCompatibleBaseUrl": "https://api.deepseek.com/v1", "summarizerOpenAiCompatibleModelId": "deepseek-chat", "summarizerOpenAiCompatibleApiKey": "sk-your-deepseek-key", "summarizerLanguage": "English", "summarizerBatchSize": 2, "summarizerConcurrency": 2, "summarizerMaxRetries": 3, "summarizerRetryDelayMs": 1000 } ``` -------------------------------- ### Serve MCP Server with Autodev Codebase CLI Source: https://github.com/anrgct/autodev-codebase/blob/master/README.md Start an MCP server for code intelligence. Supports HTTP mode on a specified port or a stdio adapter for communication. ```bash # HTTP mode (recommended) codebase index --serve --port=3001 --path=/my/project # Stdio adapter codebase stdio --server-url=http://localhost:3001/mcp ``` -------------------------------- ### Configuration Management CLI Source: https://github.com/anrgct/autodev-codebase/blob/master/CLAUDE.md Manage Autodev configurations, including getting all settings, specific items, and setting project or global configurations. ```bash # 配置管理 codebase config --get # 查看所有配置层 codebase config --get embedderProvider # 查看特定配置项 codebase config --set embedderProvider=ollama # 设置项目配置 codebase config --set key=value --global # 设置全局配置 ``` -------------------------------- ### Ollama Summarizer Configuration JSON Source: https://github.com/anrgct/autodev-codebase/blob/master/CONFIG.md Example JSON configuration for the Ollama summarizer provider, including base URL, model ID, and other settings. ```json { "summarizerProvider": "ollama", "summarizerOllamaBaseUrl": "http://localhost:11434", "summarizerOllamaModelId": "qwen3-vl:4b-instruct", "summarizerLanguage": "English", "summarizerBatchSize": 2, "summarizerConcurrency": 2, "summarizerMaxRetries": 3, "summarizerRetryDelayMs": 1000 } ``` -------------------------------- ### Call Graph Analysis CLI Example Source: https://github.com/anrgct/autodev-codebase/blob/master/README.md Analyze function call relationships and execution paths. This command traces calls related to 'app' and 'addUser'. ```bash # Call graph analysis - Trace function call relationships and execution paths ╭─ ~/workspace/autodev-codebase ╰─❯ codebase call --demo --query="app,addUser" Connections between app, addUser: Found 2 matching node(s): - demo/app:L1-29 - demo/hello.UserManager.addUser:L12-15 Direct connections: - demo/app:L1-29 → demo/hello.UserManager.addUser:L12-15 Chains found: - demo/app:L1-29 → demo/hello.UserManager.addUser:L12-15 ``` -------------------------------- ### Code Index Manager Example Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/project-outline.md Shows how to use the Code Index Manager for indexing and retrieving code-related information. This is useful for projects requiring code navigation or analysis. ```typescript function codeIndexManagerExample() { // ... implementation details ... } ``` -------------------------------- ### Inefficient Dual Querying Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/plans/260119-list-files-api-redesign.md This example illustrates the current implementation's inefficiency, which involves two separate I/O operations: one using ripgrep and another using fs.readdir. This leads to higher overhead and complexity. ```typescript // 当前实现(ripgrep 时代) const files = await listFilesWithRipgrep(...) // 查询 1: ripgrep 子进程 const directories = await listFilteredDirectories(...) // 查询 2: fs.readdir return formatAndCombineResults(files, directories, limit) ``` -------------------------------- ### Semantic Code Search CLI Example Source: https://github.com/anrgct/autodev-codebase/blob/master/README.md Perform semantic code search using natural language queries. This command finds code snippets related to 'user manage'. ```bash # Semantic code search - Find code by meaning, not just keywords ╭─ ~/workspace/autodev-codebase ╰─❯ codebase search "user manage" --demo Found 20 results in 5 files for: "user manage" ================================================== File: "hello.js" ================================================== < class UserManager > (L7-20) class UserManager { constructor() { this.users = []; } addUser(user) { this.users.push(user); console.log('User added:', user.name); } getUsers() { return this.users; } } …… ``` -------------------------------- ### Get Language Configuration Function Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/project-outline.md Retrieves the configuration object for a specific programming language. This configuration is used to guide the parsing process. ```typescript function getLanguageConfig(language: string): LanguageConfig | undefined { // ... implementation details ... } ``` -------------------------------- ### Install @rollup/plugin-replace Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/plans/260122-unify-wasm-path-resolution.md Install the necessary plugin for replacing code during the Rollup build process. ```bash npm install --save-dev @rollup/plugin-replace ``` -------------------------------- ### Invalid Score Range Example Source: https://github.com/anrgct/autodev-codebase/blob/master/CONFIG.md Example of an invalid command attempting to set the vector search minimum score outside the allowed range (0.0 to 1.0). ```bash # Invalid score range codebase config --set vectorSearchMinScore=1.5 # Error: Search minimum score must be between 0 and 1 ``` -------------------------------- ### Demonstrate File System Interaction Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/project-outline.md Illustrates how the project interacts with the file system, potentially for reading, writing, or traversing files and directories. ```typescript function demonstrateFileSystem() { // ... implementation details ... } ``` -------------------------------- ### Reranker Prompt Example Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/07-search.md Example prompt for evaluating code snippet relevance against a user query. It specifies the desired output format as a JSON array of scores. ```plaintext 请评估以下代码片段与用户查询的相关性。 查询: {用户查询} 候选代码片段: 1. {代码内容1} 2. {代码内容2} ... 请为每个候选片段打分(0-10分),10分表示完全相关。 以 JSON 数组格式返回分数: [8, 5, 9, ...] ``` -------------------------------- ### View Configuration Source: https://github.com/anrgct/autodev-codebase/blob/master/README.md Use these commands to view the current configuration settings. The `--json` flag provides output in JSON format. ```bash codebase config --get ``` ```bash codebase config --get --json ``` -------------------------------- ### Use Custom Config File Path Source: https://context7.com/anrgct/autodev-codebase/llms.txt Demonstrates how to specify a custom configuration file path when running codebase commands for configuration retrieval and indexing. ```bash codebase --config=/custom/path/config.json config --get ``` ```bash codebase --config=/custom/path/config.json index ``` -------------------------------- ### Advanced Node.js Usage Example Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/project-outline.md Illustrates more complex scenarios and advanced features of the autodev library. This example may involve multiple configurations or intricate data flows. ```typescript function advancedUsageExample() { // ... implementation details ... } ``` -------------------------------- ### Use Custom Configuration File Source: https://github.com/anrgct/autodev-codebase/blob/master/README.md Specify a custom configuration file using the `--config` flag. This allows for project-specific settings. ```bash codebase --config=/path/to/config.json config --get ``` ```bash codebase --config=/path/to/config.json config --set embedderProvider=ollama ``` -------------------------------- ### Build and Run Commands Source: https://github.com/anrgct/autodev-codebase/blob/master/AGENTS.md Standard npm scripts for building, type checking, development mode, running the MCP server, and executing tests. ```bash npm run build npm run type-check npm run dev npm run mcp-server npm run test npm run test:e2e ``` -------------------------------- ### Build and Run Commands Source: https://github.com/anrgct/autodev-codebase/blob/master/CLAUDE.md Standard npm scripts for building, type checking, development mode, running the MCP server, and executing tests. ```bash npm run build # 构建 npm run type-check # 类型检查 npm run dev # 用 demo 目录的开发模式 npm run mcp-server # 启动 MCP 服务器(端口 3001) npm run test # vitest 单元测试 npm run test:e2e # e2e 测试 ``` -------------------------------- ### View Configuration Hierarchy Source: https://github.com/anrgct/autodev-codebase/blob/master/CONFIG.md Use this command to view the complete configuration hierarchy. It helps in understanding how different configuration sources are layered and prioritized. ```bash codebase config --get ``` -------------------------------- ### Get Language Configs Function Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/project-outline.md Retrieves configurations for all supported languages. ```typescript function getLanguageConfigs(): LanguageConfig[] { // ... implementation details ... } ``` -------------------------------- ### Get Supported Languages Function Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/project-outline.md Returns a list of programming languages that the parser supports. ```typescript function getSupportedLanguages(): string[] { // ... implementation details ... } ``` -------------------------------- ### Test Case for analyzeConnections Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/plans/260117-dependency-cli.md Example test case in `call.test.ts` demonstrating the addition of the `depth` parameter to `analyzeConnections` calls. ```typescript // src/commands/__tests__/call.test.ts // 所有 analyzeConnections 调用都添加 depth 参数 analyzeConnections(result.nodes, 'functionA,functionB', 10) ``` -------------------------------- ### NodeWorkspace Get Glob Ignore Patterns Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/04-ignore.md Retrieves glob patterns used for ignore filtering within the NodeWorkspace context. ```typescript // NodeWorkspace.getGlobIgnorePatterns:54 // getGlobIgnorePatterns() (NodeWorkspace.getGlobIgnorePatterns:54) ``` -------------------------------- ### Use Custom Configuration File Source: https://github.com/anrgct/autodev-codebase/blob/master/CONFIG.md Specify a custom path for the configuration file when running commands. This allows for flexible configuration management. ```bash codebase --config=/path/to/config.json config --get ``` -------------------------------- ### Configure Ollama Summarizer Source: https://github.com/anrgct/autodev-codebase/blob/master/CONFIG.md Set up the CLI to use Ollama for code summarization, specifying the model and other parameters. ```bash codebase config --set summarizerProvider=ollama,summarizerOllamaModelId=qwen3-vl:4b-instruct ``` -------------------------------- ### View Specific Configuration Item Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/05-config.md Use this command to retrieve the value of a particular configuration setting. Ensure you specify the exact configuration key. ```bash codebase config --get embedderProvider vectorSearchMinScore ``` -------------------------------- ### Configuration Priority Levels Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/architecture.md Details the four-tiered configuration priority system, from CLI arguments to built-in defaults, showing how settings are overridden. ```text-chart [配置优先级] (从高到低) 1. CLI参数 ─── 运行时覆盖 └── --path, --log-level, --force等 2. 项目配置 ─── ./autodev-config.json └── 项目级持久化设置 3. 全局配置 ─── ~/.autodev-cache/autodev-config.json └── 用户级默认设置 4. 内置默认值 ─── 代码中的默认配置 ``` -------------------------------- ### IDE Configuration for Stdio Adapter Source: https://github.com/anrgct/autodev-codebase/blob/master/README.md JSON configuration for IDEs to use the codebase command with stdio arguments to connect to an MCP server. ```json { "mcpServers": { "codebase": { "command": "codebase", "args": ["stdio", "--server-url=http://localhost:3001/mcp"] } } } ``` -------------------------------- ### Create Module Node on Analysis Start Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/plans/260121-top-level-calls-not-tracked.md This modification adds a call to `createModuleNode` at the beginning of the `analyze` method to establish a node representing the module itself. ```typescript public async analyze(): Promise { // 创建 module 节点 this.createModuleNode() const tree = this.parser.parse(this.content) // ... 现有逻辑 } ``` ```typescript private createModuleNode(): void { const moduleId = this.getModulePath() // 复用现有方法,保持 ID 格式一致 const moduleNode: DependencyNode = { id: moduleId, name: path.basename(this.filePath), componentType: 'module', filePath: this.filePath, relativePath: this.getRelativePath(), startLine: 1, endLine: this.lines.length, dependsOn: new Set(), language: this.nodeTypes.extensions.values().next().value, } this.nodes.set(moduleId, moduleNode) } ``` ```typescript private getModuleNodeId(): string { return this.getModulePath() // 直接使用现有的 getModulePath() 方法 } ``` -------------------------------- ### Codebase Index Initialization Flow Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/01-index.md The initialization process involves creating Node.js platform dependencies and instantiating the CodeIndexManager. ```text-chart [Initialization Flow] (Creating and configuring CodeIndexManager) indexHandler:232 ↓ initializeManager:118 ↓ createDependencies:77 → createNodeDependencies:29 ↓ CodeIndexManager.getInstance:42 ↓ CodeIndexManager.initialize:124 ``` -------------------------------- ### Manage configuration settings Source: https://context7.com/anrgct/autodev-codebase/llms.txt Use `codebase config` to read and write configuration. Supports viewing all or specific keys, setting project-level or global values, and JSON output. Project-level settings are saved to `./autodev-config.json`. ```bash # View all configuration layers codebase config --get ``` ```bash # View specific keys codebase config --get embedderProvider qdrantUrl ``` ```bash # JSON output for scripting codebase config --get --json ``` ```bash # Set project-level config (writes to ./autodev-config.json) codebase config --set embedderProvider=ollama,embedderModelId=nomic-embed-text ``` ```bash # Set global config codebase config --set --global qdrantUrl=http://localhost:6333 ``` -------------------------------- ### Get Type Label Source: https://github.com/anrgct/autodev-codebase/blob/master/static/graph_viewer.html Returns a localized or abbreviated label for a given node type. Used for displaying type information in a user-friendly format. ```javascript function getTypeLabel(type) { const labels = { 'class': currentLang === 'en' ? 'Class' : '类', 'function': currentLang === 'en' ? 'Func' : '函数', 'module': currentLang === 'en' ? 'Mod' : '模块' }; return labels[type] || type.substring(0, 1).toUpperCase(); } ``` -------------------------------- ### Get Leaf Nodes Function Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/project-outline.md Identifies and returns the leaf nodes of the dependency graph. Leaf nodes are typically modules that do not have any outgoing dependencies. ```typescript function getLeafNodes(graph: Map): string[] { // ... implementation details ... } ``` -------------------------------- ### Set Project Configuration Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/05-config.md This command allows you to set multiple configuration options for the current project. Values are comma-separated. ```bash codebase config --set embedderProvider=ollama,qdrantUrl=http://localhost:6333 ``` -------------------------------- ### Test Full Parsing Functionality Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/project-outline.md This test function verifies the complete parsing pipeline of the project. It ensures that files are parsed accurately from start to finish. ```typescript function testFullParsing() { // ... implementation details ... } ``` -------------------------------- ### Generate Code Outline with Summaries Source: https://github.com/anrgct/autodev-codebase/blob/master/CONFIG.md Use the 'codebase outline' command with the --summarize flag to generate an intelligent code outline with AI-generated summaries. ```bash # Generate intelligent code outline with AI summaries codebase outline "src/**/*.ts" --summarize ``` -------------------------------- ### Remove Pre-creation of Module Nodes Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/plans/260121-top-level-calls-not-tracked.md Delete the logic that pre-creates module nodes at the start of analysis to avoid redundant nodes for files without dependencies. ```typescript // ❌ 删除:在 analyze() 开始时创建 module 节点 async analyze(): Promise { // this.createModuleNode() // ← 删除这一行 const tree = this.parser.parse(this.content) // ... } ``` -------------------------------- ### Set API Keys via Environment Variables Source: https://github.com/anrgct/autodev-codebase/blob/master/CONFIG.md Configure API keys for services like OpenAI, Qdrant, and Gemini using environment variables. This is a common practice for managing sensitive credentials. ```bash export OPENAI_API_KEY="sk-your-key" export QDRANT_API_KEY="your-qdrant-key" export GEMINI_API_KEY="your-gemini-key" ``` -------------------------------- ### Start Indexing in CodeIndexManager Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/01-index.md The `startIndexing` method in `CodeIndexManager` checks the current status, attempts recovery if in an error state, and then delegates the indexing process to the `CodeIndexOrchestrator`. ```typescript public async startIndexing(force?: boolean): Promise { // Check for error status and attempt recovery const currentStatus = this.getCurrentStatus() if (currentStatus.systemStatus === "Error") { await this.recoverFromError() return } this.assertInitialized() await this._orchestrator!.startIndexing(force) } ``` -------------------------------- ### Demonstrate Search Functionality Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/project-outline.md Illustrates how to perform searches using the autodev system. This function is useful for understanding the search capabilities and how to query the indexed data. ```typescript function demonstrateSearch() { // ... implementation details ... } ``` -------------------------------- ### Indexing Data Flow Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/architecture.md Visualizes the end-to-end data flow for indexing, starting from the file system and progressing through scanning, parsing, embedding, and storing vectors. ```text-chart [索引数据流] (从文件到向量的完整流程) 文件系统 ↓ DirectoryScanner ──→ 扫描文件列表 ↓ IgnoreService ──→ 应用忽略规则 ↓ FileWatcher ──→ 监听文件变化 ↓ CodeParser ──→ 解析代码结构 ↓ 代码块提取 ──→ 函数、类、方法 ↓ Embedder ──→ 生成向量嵌入 ↓ QdrantVectorStore ──→ 存储向量 ``` -------------------------------- ### API Documentation: DependencyNode componentType Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/plans/260121-top-level-calls-not-tracked.md This documentation update introduces the 'module' componentType for DependencyNode, explaining its purpose in tracking top-level call dependencies and providing an example. ```markdown ## DependencyNode ### componentType 节点类型: - `function` - 函数定义 - `class` - 类定义 - `method` - 方法定义 - `module` - 模块/文件本身(用于追踪顶层调用) #### module 节点说明 每个分析的文件都会自动创建一个 `module` 节点,用于追踪文件顶层代码的依赖关系。 **示例:** ```javascript // app.js const { greetUser } = require('./hello'); greetUser('Alice'); // 顶层调用 // 依赖图: // app (module) → hello.greetUser ``` **注意:** 内置函数调用(如 `console.log`)会被自动过滤。 ``` -------------------------------- ### Run Unit Tests Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/plans/260122-unify-wasm-path-resolution.md Execute the project's unit tests to verify the changes. Use the `--silent=false` flag for detailed output. ```bash npm run test -- --silent=false ``` -------------------------------- ### Orchestrator.startIndexing Decision Flow Source: https://github.com/anrgct/autodev-codebase/blob/master/docs/01-index.md The orchestrator decides between incremental or full scanning based on the existence of data in the vector store, initializing the vector store and starting a watcher. ```text-chart [orchestrator.startIndexing:142 Decision Flow] (Incremental vs. Full Scan) orchestrator.startIndexing:142 ↓ vectorStore.initialize() ↓ Check hasExistingData ├── Yes → Incremental Scan │ ├── Mark indexing incomplete │ ├── scanner.scanDirectory:119 (Incremental) │ ├── _startWatcher:86 (Start watching) │ └── Mark indexing complete └── No → Full Scan ├── Mark indexing incomplete ├── scanner.scanDirectory:119 (Full) ├── _startWatcher:86 (Start watching) └── Mark indexing complete ``` -------------------------------- ### Codebase CLI: Configuration Management Source: https://github.com/anrgct/autodev-codebase/blob/master/AGENTS.md Manage Autodev configuration settings. View all configuration layers, get specific settings, and set project-level or global configurations. ```bash # Configuration management codebase config --get # View all configuration layers codebase config --get embedderProvider # View a specific configuration item codebase config --set embedderProvider=ollama # Set project configuration codebase config --set key=value --global # Set global configuration ``` -------------------------------- ### Set Qdrant Docker Environment Source: https://github.com/anrgct/autodev-codebase/blob/master/CONFIG.md Run Qdrant using Docker. This command maps the necessary ports for Qdrant to be accessible. ```bash docker run -p 6333:6333 -p 6334:6334 qdrant/qdrant ``` -------------------------------- ### MCP Tool: Semantic Code Search Payload Source: https://github.com/anrgct/autodev-codebase/blob/master/AGENTS.md Example JSON payload for the `search_codebase` MCP tool, specifying the search query, result limit, and filtering criteria. ```json { "query": "user authentication logic", "limit": 20, "filters": { "pathFilters": ["src/**/*.ts"], "minScore": 0.3 } } ```