Files
proffesor-for-testing__agen…/scripts/query-codebase.ts
Profa c42c88b9d6 feat(release): v2.6.0 - Code Intelligence System & MCP Configuration
## Major Features

### Code Intelligence System v2.0
- Tree-sitter multi-language parser (TypeScript, Python, Go, Rust, JavaScript)
- Hybrid search engine (BM25 + semantic vector search with RRF fusion)
- Knowledge graph with relationship extraction
- RAG context builder with 70-80% token reduction
- CodeIntelligenceAgent for intelligent code queries
- Auto-injection into all QE agents via FleetManager

### MCP Configuration Fix
- Added `generateMcpJson()` to create `.claude/mcp.json` during `aqe init`
- Fixed learning persistence via `capture-task-learning.js` hook
- Added `agentic-qe` to `enabledMcpjsonServers`

## CLI Commands
- `aqe kg index <directory>` - Index codebase
- `aqe kg search <query>` - Semantic code search
- `aqe kg visualize <entity>` - Generate Mermaid diagrams
- `aqe code-intel setup/enable/status` - Configuration commands

## Bug Fixes
- Fixed TypeScript build errors in Code Intelligence files
- Fixed FormattedContext type mismatch in CodeIntelligenceAgent
- Fixed Mermaid direction type (TD → TB)
- Fixed autoIndex property type in code-intelligence-init

## Issues Closed
- #158 Code Intelligence System v2.0 (Epic)
- #161 Wave 3: AST-Based Chunking & Embeddings
- #162 Wave 4: Incremental Indexing Pipeline
- #163 Wave 5: Hybrid Search & LlamaIndex RAG
- #164 Wave 6: Agent Integration & CLI Commands

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-22 15:06:25 +00:00

70 lines
2.1 KiB
TypeScript

#!/usr/bin/env npx tsx
/**
* Query Codebase Script
*
* Search the indexed codebase using semantic search.
* Usage: npx tsx scripts/query-codebase.ts "your search query"
*/
import chalk from 'chalk';
import { CodeIntelligenceOrchestrator } from '../src/code-intelligence/orchestrator/CodeIntelligenceOrchestrator.js';
async function queryCodebase(query: string): Promise<void> {
console.log(chalk.cyan(`\n🔍 Searching: "${query}"\n`));
const orchestrator = new CodeIntelligenceOrchestrator({
rootDir: process.cwd(),
watchEnabled: false,
gitEnabled: false,
database: {
enabled: true,
host: 'localhost',
port: 5432,
database: 'ruvector_db',
user: 'ruvector',
password: 'ruvector',
},
});
try {
await orchestrator.initialize();
const result = await orchestrator.query({
query,
topK: 10,
includeGraphContext: true,
graphDepth: 2,
});
if (result.results.length === 0) {
console.log(chalk.yellow('No results found.\n'));
} else {
console.log(chalk.green(`Found ${result.results.length} results (${result.metadata?.searchTimeMs || 0}ms):\n`));
for (let i = 0; i < result.results.length; i++) {
const r = result.results[i];
const file = r.filePath.replace(process.cwd(), '').replace(/^\//, '');
console.log(chalk.white.bold(`${i + 1}. ${r.entityName || file}`));
console.log(chalk.gray(` File: ${file}:${r.startLine}-${r.endLine}`));
console.log(chalk.gray(` Type: ${r.entityType || 'chunk'} | Score: ${r.score.toFixed(4)}`));
// Show preview
const preview = r.content.substring(0, 150).replace(/\n/g, ' ').trim();
console.log(chalk.dim(` ${preview}...`));
console.log();
}
}
await orchestrator.shutdown();
} catch (error) {
console.error(chalk.red(`Error: ${(error as Error).message}`));
await orchestrator.shutdown();
process.exit(1);
}
}
// Get query from command line
const query = process.argv.slice(2).join(' ') || 'BaseAgent initialization';
queryCodebase(query);