### Install Ceregrep Client Dependencies Source: https://github.com/swarm-code/ceregrep-client/blob/master/CEREBRAS_QUICKSTART.md Installs the necessary Node.js dependencies for the ceregrep-client project. This command navigates to the project directory and then runs `npm install`. ```bash cd ceregrep-client npm install ``` -------------------------------- ### Ceregrep Client CLI Query Example Source: https://github.com/swarm-code/ceregrep-client/blob/master/CEREBRAS_QUICKSTART.md Demonstrates how to use the Ceregrep client via the command-line interface to perform a simple query. It specifies the action 'query' and the query string. ```bash ./dist/cli/index.js query "List all TypeScript files in the src directory" ``` -------------------------------- ### Setup and Installation (Bash) Source: https://github.com/swarm-code/ceregrep-client/blob/master/COMMANDS.md Provides commands for setting up the ceregrep-client project, including a one-command setup script or step-by-step instructions involving package installation, configuration copying, and building. ```bash # One-command setup ./GET_STARTED.sh # Or step-by-step: npm install cp .ceregrep.example.json .ceregrep.json npm run build node dist/test-cerebras.js ``` -------------------------------- ### Use Ceregrep CLI for Queries Source: https://github.com/swarm-code/ceregrep-client/blob/master/SETUP.md These examples demonstrate how to use the Ceregrep client's command-line interface (CLI) to interact with the LLM. They cover querying, listing available tools, and checking the configuration. ```bash ./dist/cli/index.js query "List all TypeScript files" ./dist/cli/index.js list-tools ./dist/cli/index.js config ``` -------------------------------- ### Install Dependencies using npm Source: https://github.com/swarm-code/ceregrep-client/blob/master/SETUP.md This command installs the necessary dependencies for the Ceregrep client project using npm. It assumes you are in the project's root directory. ```bash cd /home/alejandro/Swarm/ceregrep/ceregrep-client npm install ``` -------------------------------- ### Ceregrep Client CLI Verbose Query Example Source: https://github.com/swarm-code/ceregrep-client/blob/master/CEREBRAS_QUICKSTART.md Shows how to execute a query using the Ceregrep CLI with verbose output enabled. This is useful for debugging and understanding the agent's process. ```bash ./dist/cli/index.js query "Search for TODO comments in the codebase" --verbose ``` -------------------------------- ### Untitled No description -------------------------------- ### Ceregrep Client CLI Configuration Check Source: https://github.com/swarm-code/ceregrep-client/blob/master/CEREBRAS_QUICKSTART.md Uses the Ceregrep client CLI to display the current configuration settings. This command helps verify that the client is set up correctly. ```bash ./dist/cli/index.js config ``` -------------------------------- ### Untitled No description -------------------------------- ### Enable Debugging via CLI Source: https://github.com/swarm-code/ceregrep-client/blob/master/SETUP.md This command demonstrates how to enable verbose and debug modes directly from the Ceregrep client's CLI when making a query. ```bash ./dist/cli/index.js query "test" --verbose --debug ``` -------------------------------- ### Untitled No description -------------------------------- ### Troubleshooting Build Errors Source: https://github.com/swarm-code/ceregrep-client/blob/master/SETUP.md This sequence of commands can be used to resolve build errors by cleaning the 'node_modules' and 'dist' directories, reinstalling dependencies, and rebuilding the project. ```bash rm -rf node_modules dist npm install npm run build ``` -------------------------------- ### Interact with Ceregrep Client SDK in TypeScript Source: https://github.com/swarm-code/ceregrep-client/blob/master/SETUP.md This TypeScript code snippet shows how to initialize and use the Ceregrep client's SDK to send a query to the LLM. It demonstrates programmatic access to the client's functionality. ```typescript import { CeregrepClient } from './dist/sdk/typescript/index.js'; const client = new CeregrepClient(); await client.initialize(); const result = await client.query('Explain this codebase'); console.log(result); ``` -------------------------------- ### Install Ceregrep Client from Source Source: https://github.com/swarm-code/ceregrep-client/blob/master/README.md Installs the Ceregrep client from its source code repository. This involves cloning the repository, installing dependencies, building the project, and linking it globally for development. ```bash git clone https://github.com/swarmcode/ceregrep-client.git cd ceregrep-client npm install npm run build npm link ``` -------------------------------- ### Test Ceregrep Client with Node.js Source: https://github.com/swarm-code/ceregrep-client/blob/master/SETUP.md This command executes the test script for the Ceregrep client. It assumes the project has been built and the test script is located in the 'dist' directory. ```bash node dist/test-cerebras.js ``` -------------------------------- ### Build Ceregrep Client Project Source: https://github.com/swarm-code/ceregrep-client/blob/master/CEREBRAS_QUICKSTART.md Compiles the TypeScript code for the ceregrep-client project. This command is typically run after making code changes or before deploying. ```bash npm run build ``` -------------------------------- ### Configuration Management (Bash) Source: https://github.com/swarm-code/ceregrep-client/blob/master/COMMANDS.md Commands for viewing, editing, and setting up the project's configuration file. It also shows how to use the example configuration as a template. ```bash # View current config cat .ceregrep.json # Edit config nano .ceregrep.json # Use example as template cp .ceregrep.example.json .ceregrep.json ``` -------------------------------- ### Anthropic Configuration Options Source: https://github.com/swarm-code/ceregrep-client/blob/master/SETUP.md This JSON object illustrates the configuration for the Anthropic provider, specifying the model, provider type, and API key. ```json { "model": "claude-sonnet-4-20250514", "provider": { "type": "anthropic" }, "apiKey": "sk-ant-..." } ``` -------------------------------- ### Configure Ceregrep Client with JSON Source: https://github.com/swarm-code/ceregrep-client/blob/master/CEREBRAS_QUICKSTART.md Sets up the Ceregrep client by creating a `.ceregrep.json` file in the project root. This file specifies the model, provider details (type, API key, base URL), and other parameters like temperature and verbosity. ```json { "model": "qwen-3-coder-480b", "provider": { "type": "cerebras", "apiKey": "your-cerebras-api-key-here", "baseURL": "https://api.cerebras.ai/v1", "temperature": 0.7, "top_p": 0.8 }, "verbose": true, "debug": false } ``` -------------------------------- ### Example CLI Queries (Bash) Source: https://github.com/swarm-code/ceregrep-client/blob/master/COMMANDS.md Illustrative examples of using the ceregrep CLI for common code analysis tasks, such as finding functions, listing files, searching for comments, and explaining codebase structure. ```bash # Code analysis ./dist/cli/index.js query "Find all async functions" # File operations ./dist/cli/index.js query "List all .ts files in src/" # Search patterns ./dist/cli/index.js query "Search for TODO comments" # Architecture questions ./dist/cli/index.js query "Explain the structure of this codebase" ``` -------------------------------- ### Ceregrep Client TypeScript SDK Basic Query Source: https://github.com/swarm-code/ceregrep-client/blob/master/CEREBRAS_QUICKSTART.md Initializes the Ceregrep client using the TypeScript SDK and performs a query. It automatically uses the configuration from `.ceregrep.json` and prints the assistant's response content and total cost. ```typescript import { CeregrepClient } from '@ceregrep/client'; // Initialize client (automatically uses config from .ceregrep.json) const client = new CeregrepClient({ verbose: true, }); // Query the agent const result = await client.query( 'Find all functions that use async/await in this codebase' ); // Print results for (const msg of result.messages) { if (msg.type === 'assistant') { const textContent = msg.message.content .filter((c: any) => c.type === 'text') .map((c: any) => c.text) .join('\n'); console.log(textContent); } } console.log(`\nTotal cost: $${result.totalCost.toFixed(4)}`); ``` -------------------------------- ### Install Ceregrep MCP Server from Source (Development) Source: https://github.com/swarm-code/ceregrep-client/blob/master/mcp-server/README.md Installs the ceregrep-mcp package from its source code for development purposes. Requires navigating to the 'mcp-server' directory and using pip for an editable installation. ```bash cd mcp-server pip install -e . ``` -------------------------------- ### Enable Debugging in Configuration Source: https://github.com/swarm-code/ceregrep-client/blob/master/SETUP.md This JSON snippet shows how to enable verbose logging and debugging for the Ceregrep client by setting 'verbose' and 'debug' flags in the configuration file. ```json { "verbose": true, "debug": true } ``` -------------------------------- ### Untitled No description -------------------------------- ### Ceregrep Client TypeScript SDK Programmatic Configuration Source: https://github.com/swarm-code/ceregrep-client/blob/master/CEREBRAS_QUICKSTART.md Initializes the Ceregrep client using the TypeScript SDK with programmatic configuration, overriding settings from `.ceregrep.json`. It allows direct specification of the model, API key, and verbosity. ```typescript import { CeregrepClient } from '@ceregrep/client'; const client = new CeregrepClient({ model: 'qwen-3-coder-480b', apiKey: 'csk-your-api-key', verbose: true, }); const result = await client.query('Explain the architecture of this codebase'); ``` -------------------------------- ### Cerebras Configuration Options Source: https://github.com/swarm-code/ceregrep-client/blob/master/SETUP.md This JSON object details the configuration parameters specific to the Cerebras provider, including the model name, API key, base URL, and generation settings. ```json { "model": "qwen-3-coder-480b", "provider": { "type": "cerebras", "apiKey": "csk-...", "baseURL": "https://api.cerebras.ai/v1", "temperature": 0.7, "top_p": 0.8 } } ``` -------------------------------- ### Configure Ceregrep Client with Environment Variable Source: https://github.com/swarm-code/ceregrep-client/blob/master/CEREBRAS_QUICKSTART.md Configures the Ceregrep client by setting the Cerebras API key as an environment variable. This is an alternative to specifying the API key in the `.ceregrep.json` file. ```bash export CEREBRAS_API_KEY=your-cerebras-api-key-here ``` -------------------------------- ### Untitled No description -------------------------------- ### Ceregrep Client CLI Commands Source: https://github.com/swarm-code/ceregrep-client/blob/master/README.md Provides examples of common commands for interacting with the Ceregrep client via its command-line interface. This includes querying, listing tools, and showing configuration. ```bash ceregrep query "List all TypeScript files" ceregrep list-tools ceregrep config ``` -------------------------------- ### Install Dependencies and Build Project (Bash) Source: https://github.com/swarm-code/ceregrep-client/blob/master/README.md Commands to install project dependencies using npm and then build the project. These are standard commands for Node.js projects. ```bash # Install dependencies npm install # Build npm run build ``` -------------------------------- ### Untitled No description -------------------------------- ### Ceregrep CLI Query Example Source: https://context7.com/swarm-code/ceregrep-client/llms.txt Provides an example of how to use the ceregrep command-line interface to query an agent with a natural language prompt. This demonstrates scripted usage of the tool. ```bash # Query the agent ceregrep query "Find all async functions and explain how they handle errors" ``` -------------------------------- ### Install Ceregrep Client via npm Source: https://github.com/swarm-code/ceregrep-client/blob/master/README.md Installs the Ceregrep client package from npm. This can be done for local project use or globally for CLI access. ```bash npm install ceregrep ``` ```bash npm install -g ceregrep ``` -------------------------------- ### Install Ceregrep MCP Server via pip Source: https://github.com/swarm-code/ceregrep-client/blob/master/mcp-server/README.md Installs the ceregrep-mcp package using pip, the Python package installer. This is an alternative installation method. ```bash pip install ceregrep-mcp ``` -------------------------------- ### Run Ceregrep MCP Server with uvx (Recommended) Source: https://github.com/swarm-code/ceregrep-client/blob/master/mcp-server/README.md Executes the ceregrep-mcp package without requiring a formal installation, using the 'uvx' command. This is the recommended method for ease of use. ```bash uvx ceregrep-mcp ``` -------------------------------- ### Install Ceregrep CLI Globally Source: https://github.com/swarm-code/ceregrep-client/blob/master/mcp-server/README.md Installs the ceregrep command-line interface globally using npm. This is a prerequisite for running the MCP server. ```bash npm install -g ceregrep ``` -------------------------------- ### Install Ceregrep CLI (Bash) Source: https://github.com/swarm-code/ceregrep-client/blob/master/README.md Installs the Ceregrep command-line interface globally using npm. This is a prerequisite for using the MCP server via the Claude MCP CLI. ```bash # Install ceregrep CLI first npm install -g ceregrep ``` -------------------------------- ### Configure tsconfig.json for Module Resolution Source: https://github.com/swarm-code/ceregrep-client/blob/master/SETUP.md This JSON configuration snippet specifies module and moduleResolution options for TypeScript projects. It is essential for resolving modules correctly in Node.js environments, preventing common module resolution errors. ```json { "compilerOptions": { "module": "ES2022", "moduleResolution": "node" } } ``` -------------------------------- ### Verify uv Installation Source: https://github.com/swarm-code/ceregrep-client/blob/master/mcp-server/README.md Checks if 'uv', a fast Python package installer and tool, is installed. 'uv' is recommended for running ceregrep-mcp without installation and for general Python environment management. ```bash uv --version ``` -------------------------------- ### Ceregrep Configuration for Cerebras (Global) Source: https://github.com/swarm-code/ceregrep-client/blob/master/README.md Example bash script to set up a global Ceregrep configuration file for the Cerebras provider. It defines the model, provider details, and logging preferences. ```bash cat > ~/.ceregrep.json << 'EOF' { "model": "qwen-3-coder-480b", "provider": { "type": "cerebras", "apiKey": "csk-your-cerebras-api-key", "baseURL": "https://api.cerebras.ai/v1", "temperature": 0.7, "top_p": 0.8 }, "verbose": true, "debug": false } EOF ``` -------------------------------- ### Package Management with npm (Bash) Source: https://github.com/swarm-code/ceregrep-client/blob/master/COMMANDS.md Essential npm commands for managing project dependencies, including installing all packages, adding new ones, and updating existing ones. ```bash # Install all dependencies npm install # Add a new dependency npm install package-name # Update dependencies npm update ``` -------------------------------- ### Ceregrep Configuration for Cerebras (Project) Source: https://github.com/swarm-code/ceregrep-client/blob/master/README.md Example JSON configuration for using the Ceregrep client with the Cerebras provider on a project-specific basis. It includes model, provider details, and logging settings. ```json { "model": "qwen-3-coder-480b", "provider": { "type": "cerebras", "apiKey": "csk-your-cerebras-api-key", "baseURL": "https://api.cerebras.ai/v1", "temperature": 0.7, "top_p": 0.8 }, "verbose": false, "debug": false } ``` -------------------------------- ### Ceregrep MCP Server Configuration Source: https://github.com/swarm-code/ceregrep-client/blob/master/README.md Example JSON configuration for setting up MCP servers within Ceregrep. This allows the client to connect to external services for extended functionality, specifying server type, command, and arguments. ```json { "mcpServers": { "server-name": { "type": "stdio", "command": "node", "args": ["path/to/server.js"] } } } ``` -------------------------------- ### Quick Task Execution (Bash) Source: https://github.com/swarm-code/ceregrep-client/blob/master/COMMANDS.md Common quick tasks for project maintenance and information retrieval, including a fresh install, running all tests, displaying help, and checking the version. ```bash # Fresh install rm -rf node_modules dist && npm install && npm run build # Test everything npm run build && node dist/test-cerebras.js # Show all available commands ./dist/cli/index.js --help # Get version ./dist/cli/index.js --version ``` -------------------------------- ### Troubleshoot Ceregrep CLI Not Found Source: https://github.com/swarm-code/ceregrep-client/blob/master/mcp-server/README.md Provides a command to resolve the 'ceregrep command not found' error by linking the globally installed CLI. This is necessary if the npm install command did not add it to the system's PATH. ```bash npm link ``` -------------------------------- ### Ceregrep Configuration for Anthropic Claude Source: https://github.com/swarm-code/ceregrep-client/blob/master/README.md Example JSON configuration for using the Ceregrep client with Anthropic Claude. It specifies the model, API key, MCP servers, and verbosity settings. ```json { "model": "claude-sonnet-4-20250514", "apiKey": "your-anthropic-api-key", "mcpServers": { "filesystem": { "type": "stdio", "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/directory"] } }, "verbose": false, "debug": false } ``` -------------------------------- ### Core Agent Query Loop with Customization (TypeScript) Source: https://context7.com/swarm-code/ceregrep-client/llms.txt Provides a low-level example of the Ceregrep agent's query loop, allowing direct control over system prompts, tool contexts, and permission checking. This is for advanced use cases requiring detailed customization of agent behavior. ```typescript import { query } from 'ceregrep'; import { createUserMessage } from 'ceregrep'; import { getTools } from 'ceregrep'; import { querySonnet, formatSystemPromptWithContext } from 'ceregrep'; const tools = await getTools(true); // true = include MCP tools const messages = [createUserMessage('List all API endpoints in this codebase')]; const systemPrompt = [ 'You are a helpful AI assistant with access to bash and file search tools.', 'Use the tools available to help the user accomplish their tasks.', ]; const context = { cwd: process.cwd(), date: new Date().toISOString(), }; const canUseTool = async (toolName: string, input: any) => { // Permission checker - return true to auto-approve console.log(`Tool requested: ${toolName}`); return true; }; const toolContext = { options: { tools, verbose: true, debug: false, slowAndCapableModel: 'claude-sonnet-4-20250514', maxThinkingTokens: 0, enableThinking: false, ultrathinkMode: false, dangerouslySkipPermissions: false, commands: [], forkNumber: 0, messageLogName: 'custom-query', }, abortController: new AbortController(), readFileTimestamps: {}, }; // Execute query loop - yields messages as they're generated for await (const message of query( messages, systemPrompt, context, canUseTool, toolContext, querySonnet, formatSystemPromptWithContext, )) { console.log('Message received:', message.type); messages.push(message); } ``` -------------------------------- ### Verify Python Version Source: https://github.com/swarm-code/ceregrep-client/blob/master/mcp-server/README.md Checks the installed Python version to ensure it meets the minimum requirement of Python 3.10 for the ceregrep-mcp package. ```bash python --version ``` -------------------------------- ### Configure Ceregrep MCP Server in Claude Desktop (Manual - pip) Source: https://github.com/swarm-code/ceregrep-client/blob/master/mcp-server/README.md Manually configures the Ceregrep MCP server in Claude Desktop's settings when installed via pip. Involves editing a JSON configuration file. ```json { "mcpServers": { "ceregrep": { "command": "ceregrep-mcp" } } } ``` -------------------------------- ### Integrate Custom Tool with Ceregrep Client in TypeScript Source: https://context7.com/swarm-code/ceregrep-client/llms.txt This TypeScript code demonstrates how to integrate the custom 'DatabaseQuery' tool with the Ceregrep client. It fetches standard tools, adds the custom tool to the list, and then sets these tools on a new CeregrepClient instance. Finally, it shows an example of using the client to query data. ```typescript // Use custom tool with client import { CeregrepClient } from 'ceregrep'; import { getTools } from 'ceregrep'; const client = new CeregrepClient(); const standardTools = await getTools(false); client.setTools([...standardTools, customTool]); const result = await client.query('Query the users table for admin accounts'); ``` -------------------------------- ### CLI Query and Management (Bash) Source: https://github.com/swarm-code/ceregrep-client/blob/master/COMMANDS.md Demonstrates how to interact with the ceregrep CLI for querying the agent, listing available tools, and viewing configuration. Supports optional verbose and debug flags. ```bash # Query the agent ./dist/cli/index.js query "Your question here" # List available tools ./dist/cli/index.js list-tools # Show configuration ./dist/cli/index.js config # With options ./dist/cli/index.js query "test" --verbose --debug ``` -------------------------------- ### Testing Integration and SDK (Node.js/Bash) Source: https://github.com/swarm-code/ceregrep-client/blob/master/COMMANDS.md Includes commands for running Cerebras integration tests and executing tests directly from TypeScript using the SDK, demonstrating client instantiation and query execution. ```bash # Test Cerebras integration node dist/test-cerebras.js # Test from TypeScript node -e "import('./dist/sdk/typescript/index.js').then(async m => { const client = new m.CeregrepClient(); const result = await client.query('Hello'); console.log(result); })" ``` -------------------------------- ### Untitled No description -------------------------------- ### Initialize and Query Ceregrep Client (TypeScript) Source: https://context7.com/swarm-code/ceregrep-client/llms.txt Demonstrates how to instantiate the CeregrepClient, initialize its tools, and send a query. It also shows how to access response messages and manage conversation history, including manual compaction and clearing. ```typescript import { CeregrepClient } from 'ceregrep'; const client = new CeregrepClient({ model: 'claude-sonnet-4-20250514', apiKey: process.env.ANTHROPIC_API_KEY, verbose: true, compactionThreshold: 100000, // Auto-compact at 100k tokens enableThinking: false, // Extended thinking mode }); // Initialize tools (loads Bash, Grep, and MCP tools) await client.initialize(); // Query the agent const result = await client.query('Find all TypeScript files with async functions'); // Access response messages result.messages.forEach(msg => { if (msg.type === 'assistant') { console.log(msg.message.content); } }); // Get conversation history const history = client.getHistory(); console.log(`Total messages: ${history.length}`); // Manual compaction (keeps last 10 messages, summarizes rest) await client.compact(10); // Clear history for fresh start client.clearHistory(); ``` -------------------------------- ### Build Commands (Bash) Source: https://github.com/swarm-code/ceregrep-client/blob/master/COMMANDS.md Commands for building the project, including a standard build, a development watch mode for continuous rebuilding, and a clean build process. ```bash # Build project npm run build # Watch mode (rebuild on changes) npm run dev # Clean build npm run clean && npm run build ``` -------------------------------- ### CeregrepClient SDK Source: https://github.com/swarm-code/ceregrep-client/blob/master/README.md Documentation for the CeregrepClient class, its constructor, and methods for querying the agent, managing conversation history, and setting tools or models. ```APIDOC ## CeregrepClient API ### Class: `CeregrepClient` Initializes a new instance of the CeregrepClient. #### Constructor ```typescript constructor(options?: QueryOptions); ``` - **options** (`QueryOptions`, optional) - Configuration options for the client. ### Methods #### `query(prompt: string, options?: QueryOptions): Promise` Sends a query to the Ceregrep agent. - **prompt** (`string`) - The user's query to the agent. - **options** (`QueryOptions`, optional) - Additional options for this specific query. - **Returns** (`Promise`) - A promise that resolves with the agent's response. #### `getHistory(): Message[]` Retrieves the current conversation history. - **Returns** (`Message[]`) - An array of message objects representing the history. #### `clearHistory(): void` Clears the entire conversation history. #### `compact(): Promise` Compacts the conversation history by summarizing older messages using the LLM. - **Returns** (`Promise`) #### `setTools(tools: Tool[]): void` Sets custom tools for the agent to use. - **tools** (`Tool[]`) - An array of tool definitions. #### `setModel(model: string): void` Sets the LLM model to be used by the agent. - **model** (`string`) - The identifier of the model to use. ``` -------------------------------- ### Ceregrep Client TypeScript SDK Usage Source: https://github.com/swarm-code/ceregrep-client/blob/master/README.md Demonstrates how to use the Ceregrep client with the TypeScript SDK. It shows initializing the client with model and API key, querying the agent, and logging the response. ```typescript import { CeregrepClient } from 'ceregrep'; const client = new CeregrepClient({ model: 'claude-sonnet-4-20250514', apiKey: process.env.ANTHROPIC_API_KEY, }); // Query the agent const result = await client.query('List all TypeScript files in the current directory'); console.log('Agent response:', result.messages); ``` -------------------------------- ### Provider Configuration (JSON) Source: https://github.com/swarm-code/ceregrep-client/blob/master/COMMANDS.md Configuration snippets in JSON format for switching between different AI providers, specifically Cerebras and Anthropic. Includes model selection and API key details. ```json { "model": "qwen-3-coder-480b", "provider": { "type": "cerebras", "apiKey": "csk-..." } } { "model": "claude-sonnet-4-20250514", "provider": { "type": "anthropic" }, "apiKey": "sk-ant-..." } ``` -------------------------------- ### Environment Variable Configuration (Bash) Source: https://github.com/swarm-code/ceregrep-client/blob/master/COMMANDS.md Instructions for setting environment variables for API keys for Cerebras and Anthropic, and how to use these variables when executing CLI commands. ```bash # Set Cerebras API key export CEREBRAS_API_KEY=csk-your-key # Set Anthropic API key export ANTHROPIC_API_KEY=sk-ant-your-key # Use in command CEREBRAS_API_KEY=csk-... ./dist/cli/index.js query "test" ``` -------------------------------- ### Ceregrep CLI Commands for Querying and Management Source: https://context7.com/swarm-code/ceregrep-client/llms.txt This section demonstrates various command-line interface (CLI) commands for the ceregrep client. It includes commands for performing advanced queries with different thinking modes, listing tools, managing configurations, running diagnostics, updating the client, and managing MCP servers. ```bash ceregrep query "Analyze the security of this authentication system" --thinking ceregrep query "Design a complete refactoring plan for this module" --ultrathink ceregrep query "List all API endpoints" --model claude-sonnet-4-20250514 --verbose ceregrep list-tools ceregrep config ceregrep doctor ceregrep update ceregrep mcp list ceregrep mcp add filesystem --type stdio --command npx --args "-y @modelcontextprotocol/server-filesystem /path/to/dir" ceregrep mcp test filesystem ceregrep mcp disable filesystem ceregrep mcp enable filesystem ceregrep mcp remove filesystem ``` -------------------------------- ### Untitled No description -------------------------------- ### Configure Ceregrep MCP Server for Other MCP Clients Source: https://github.com/swarm-code/ceregrep-client/blob/master/mcp-server/README.md Adds the Ceregrep MCP server configuration to a generic 'mcp.json' or equivalent file for use with any MCP-compatible client. Specifies 'uvx' execution with arguments. ```json { "mcpServers": { "ceregrep": { "command": "uvx", "args": ["ceregrep-mcp"], "env": {} } } } ``` -------------------------------- ### File Structure Navigation (Bash) Source: https://github.com/swarm-code/ceregrep-client/blob/master/COMMANDS.md Bash commands for inspecting the project's file structure, including finding TypeScript files, counting specific file types, and listing directory contents. ```bash # Show project structure find . -type f -name "*.ts" | head -20 # Count files find . -type f ( -name "*.ts" -o -name "*.json" ) ! -path "./node_modules/*" | wc -l # List tools ls -la tools/ ``` -------------------------------- ### Configure Ceregrep MCP Server in Claude Desktop (Manual - uvx) Source: https://github.com/swarm-code/ceregrep-client/blob/master/mcp-server/README.md Manually configures the Ceregrep MCP server in Claude Desktop's settings when using 'uvx' for execution. Involves editing a JSON configuration file. ```json { "mcpServers": { "ceregrep": { "command": "uvx", "args": ["ceregrep-mcp"] } } } ``` -------------------------------- ### Untitled No description -------------------------------- ### Debugging CLI Output (Bash) Source: https://github.com/swarm-code/ceregrep-client/blob/master/COMMANDS.md Commands to enable verbose and debug output for the ceregrep CLI queries, along with a command to follow log files for real-time debugging information. ```bash # Enable verbose output ./dist/cli/index.js query "test" --verbose # Enable debug mode ./dist/cli/index.js query "test" --debug # Check logs tail -f debug-*.log ``` -------------------------------- ### Manage Configuration with Ceregrep Source: https://context7.com/swarm-code/ceregrep-client/llms.txt Illustrates hierarchical configuration management using functions like getConfig, getGlobalConfig, getProjectConfig, and saveCurrentProjectConfig from the 'ceregrep' library. Supports project-specific overrides and saving configurations. ```typescript import { getConfig, getGlobalConfig, getProjectConfig, saveCurrentProjectConfig } from 'ceregrep'; // Get merged configuration (project overrides global) const config = getConfig(); console.log('Model:', config.model); console.log('Provider:', config.provider?.type); console.log('MCP Servers:', Object.keys(config.mcpServers || {})); // Get only global config const globalConfig = getGlobalConfig(); console.log('Global config from ~/.ceregrep.json:', globalConfig); // Get only project config const projectConfig = getProjectConfig(); console.log('Project config from ./.ceregrep.json:', projectConfig); // Save project configuration saveCurrentProjectConfig({ model: 'claude-sonnet-4-20250514', verbose: true, mcpServers: { filesystem: { type: 'stdio', command: 'npx', args: ['-y', '@modelcontextprotocol/server-filesystem', process.cwd()], disabled: false, disabledTools: [], }, }, }); // Configuration schema example const exampleConfig = { model: 'claude-sonnet-4-20250514', apiKey: process.env.ANTHROPIC_API_KEY, provider: { type: 'cerebras', apiKey: process.env.CEREBRAS_API_KEY, baseURL: 'https://api.cerebras.ai/v1', temperature: 0.7, top_p: 0.8, }, verbose: false, debug: false, enableThinking: false, ultrathinkMode: false, maxThinkingTokens: 0, compactionThreshold: 100000, compactionKeepRecentCount: 10, }; ``` -------------------------------- ### Execute Bash Commands with Ceregrep BashTool Source: https://context7.com/swarm-code/ceregrep-client/llms.txt Demonstrates how to use the BashTool to execute shell commands in a persistent session. Includes input validation for security and command execution with timeout. Dependencies include the 'ceregrep' library. ```typescript import { BashTool } from 'ceregrep'; const toolContext = { abortController: new AbortController(), options: { verbose: true, debug: false, tools: [], dangerouslySkipPermissions: false }, readFileTimestamps: {}, }; // Validate command before execution const validation = await BashTool.validateInput({ command: 'ls -la' }); if (!validation.success) { console.error('Command blocked:', validation.message); process.exit(1); } // Execute command with 30-second timeout for await (const result of BashTool.call( { command: 'find . -name "*.ts" | head -10', timeout: 30000 }, toolContext )) { if (result.type === 'result') { console.log('STDOUT:', result.data.stdout); console.log('STDERR:', result.data.stderr); console.log('Interrupted:', result.data.interrupted); } } // Banned commands (will fail validation) const bannedCommands = ['rm', 'shutdown', 'reboot', 'halt', 'poweroff', 'mkfs', 'dd', 'fdisk', 'parted']; ``` -------------------------------- ### Integrate MCP Client with Ceregrep Source: https://context7.com/swarm-code/ceregrep-client/llms.txt Demonstrates how to connect to, disconnect from, and test Messagepassing Communication Protocol (MCP) servers using functions like connectToAllServers, disconnectAllServers, and testMCPServer from the 'ceregrep' library. Also shows how to load and use MCP tools. ```typescript import { getMCPTools, connectToAllServers, disconnectAllServers, testMCPServer } from 'ceregrep'; // Connect to all configured MCP servers const clients = await connectToAllServers(); for (const client of clients) { if (client.type === 'connected') { console.log(`✓ Connected to ${client.name}`); } else { console.error(`✗ Failed to connect to ${client.name}: ${client.error}`); } } // Get all MCP tools (automatically prefixed with mcp__servername__) const mcpTools = await getMCPTools(); console.log(`Loaded ${mcpTools.length} MCP tools`); // Use MCP tools like regular tools for (const tool of mcpTools) { console.log(`Tool: ${tool.name}`); console.log(`Description: ${await tool.description()}`); } // Test connection to a specific server const testResult = await testMCPServer('filesystem', { type: 'stdio', command: 'npx', args: ['-y', '@modelcontextprotocol/server-filesystem', '/tmp'], disabled: false, disabledTools: [], }); if (testResult.success) { console.log(`✓ ${testResult.message}`); console.log(`Tools available: ${testResult.toolCount}`); } else { console.error(`✗ Connection failed: ${testResult.message}`); } // Cleanup: disconnect all servers await disconnectAllServers(); ``` -------------------------------- ### Untitled No description -------------------------------- ### Search Files with Ceregrep GrepTool Source: https://context7.com/swarm-code/ceregrep-client/llms.txt Shows how to use the GrepTool for searching files using regular expressions and glob patterns. It supports specifying search paths and include/exclude filters. Requires the 'ceregrep' library. ```typescript import { GrepTool } from 'ceregrep'; const toolContext = { abortController: new AbortController(), options: { verbose: true }, readFileTimestamps: {}, }; // Search for pattern in all files for await (const result of GrepTool.call( { pattern: 'async\s+function', path: './src', include: '*.{ts,js}' }, toolContext )) { if (result.type === 'result') { console.log(`Found ${result.data.numFiles} files`); console.log('Files:', result.data.filenames.slice(0, 10)); console.log(`Duration: ${result.data.durationMs}ms`); } } // Search current directory (path is optional) for await (const result of GrepTool.call( { pattern: 'TODO|FIXME' }, toolContext )) { console.log(result.resultForAssistant); // Formatted output } ``` -------------------------------- ### Add Ceregrep MCP to Claude Desktop via CLI Source: https://github.com/swarm-code/ceregrep-client/blob/master/mcp-server/README.md Adds the ceregrep MCP server to Claude Desktop's configuration using the Claude MCP CLI. This is the simplest method for integrating ceregrep with Claude. ```bash claude mcp add ceregrep uvx ceregrep-mcp ``` -------------------------------- ### QueryOptions Interface Source: https://github.com/swarm-code/ceregrep-client/blob/master/README.md Defines the available options for querying the Ceregrep agent. ```APIDOC ### Interface: `QueryOptions` Options for configuring queries and the Ceregrep client. #### Properties - **model** (`string`, optional) - The LLM model to use (e.g., 'claude-sonnet-4-20250514', 'qwen-3-coder-480b'). - **apiKey** (`string`, optional) - API key for the LLM provider. - **tools** (`Tool[]`, optional) - An array of custom tools to enable for the query. - **maxThinkingTokens** (`number`, optional) - The maximum number of tokens the agent can use for thinking. - **verbose** (`boolean`, optional) - Enables verbose logging. - **debug** (`boolean`, optional) - Enables debug logging. ``` -------------------------------- ### QueryOptions Interface for CeregrepClient Source: https://github.com/swarm-code/ceregrep-client/blob/master/README.md TypeScript interface defining the options that can be passed to the CeregrepClient's query method or constructor. This includes model, API key, tools, and other operational parameters. ```typescript interface QueryOptions { model?: string; apiKey?: string; tools?: Tool[]; maxThinkingTokens?: number; verbose?: boolean; debug?: boolean; dangerouslySkipPermissions?: boolean; } ``` -------------------------------- ### CeregrepClient Class Definition Source: https://github.com/swarm-code/ceregrep-client/blob/master/README.md TypeScript definition for the CeregrepClient class. It outlines the constructor and methods for interacting with the agent, including querying, managing history, and setting tools or models. ```typescript class CeregrepClient { constructor(options?: QueryOptions); // Query the agent async query(prompt: string, options?: QueryOptions): Promise; // Get conversation history getHistory(): Message[]; // Clear history clearHistory(): void; // Compact history (summarize with LLM) async compact(): Promise; // Set custom tools setTools(tools: Tool[]): void; // Set model setModel(model: string): void; } ``` -------------------------------- ### Untitled No description -------------------------------- ### Ceregrep API Key Environment Variables Source: https://github.com/swarm-code/ceregrep-client/blob/master/README.md Shows how to set API keys for Anthropic and Cerebras providers using environment variables. These variables are used by the Ceregrep client to authenticate with the respective services. ```bash # For Anthropic export ANTHROPIC_API_KEY=your-key-here # For Cerebras export CEREBRAS_API_KEY=your-key-here ``` -------------------------------- ### Context Compaction with Ceregrep Client Source: https://context7.com/swarm-code/ceregrep-client/llms.txt This TypeScript code demonstrates the context compaction feature of the ceregrep client, which summarizes older messages to stay within token limits. It shows how to check if compaction is needed, perform the compaction, and then use the summarized conversation history for subsequent queries. ```typescript import { compact } from 'ceregrep'; import { createUserMessage, createAssistantMessage } from 'ceregrep'; import { getTools } from 'ceregrep'; import { querySonnet } from 'ceregrep'; import { getTokenStats, shouldCompact } from 'ceregrep'; const tools = await getTools(false); const messages = [ createUserMessage('Find all TypeScript files'), createAssistantMessage('I found 42 TypeScript files...'), // ... many more messages ]; // Check if compaction is needed const stats = getTokenStats(messages); console.log('Total tokens:', stats.total); console.log('User tokens:', stats.user); console.log('Assistant tokens:', stats.assistant); const threshold = 100000; if (shouldCompact(messages, threshold)) { console.log('Compaction needed!'); // Compact: keep last 10 messages, summarize the rest const result = await compact( messages, tools, querySonnet, // Function to use for summarization 'claude-sonnet-4-20250514', // Model to use for summarization new AbortController().signal, 10 // keepRecentCount ); console.log('Summary:', result.summary.message.content); console.log('Cleared messages:', result.clearedMessages.length); console.log('Recent messages:', result.recentMessages.length); // Replace message history with compacted version const newMessages = [result.summary, ...result.recentMessages]; console.log('New message count:', newMessages.length); } ``` -------------------------------- ### Stream Query Results from Ceregrep Client (TypeScript) Source: https://context7.com/swarm-code/ceregrep-client/llms.txt Illustrates how to use the streaming query interface of the CeregrepClient for real-time message delivery. This is useful for applications requiring immediate feedback as the agent processes a query. ```typescript import { CeregrepClient } from 'ceregrep'; const client = new CeregrepClient(); await client.initialize(); // Stream messages as they arrive for await (const message of client.queryStream('Analyze the authentication flow')) { if (message.type === 'assistant') { const content = Array.isArray(message.message.content) ? message.message.content : [message.message.content]; for (const block of content) { if (block.type === 'text') { console.log(block.text); } else if (block.type === 'tool_use') { console.log(`Using tool: ${block.name}`); } } } else if (message.type === 'user') { // Tool results console.log('Tool execution completed'); } } ```