mirror of
https://github.com/proffesor-for-testing/agentic-qe.git
synced 2026-09-19 08:45:47 +08:00
2253d05618
Remove the nested v3/ subdirectory by moving all active source code, tests, configs, and assets directly to the project root. Archive v2/ (dead code, 847MB) to v2-archive.tar.gz. Key changes: - Move v3/src/ → src/, v3/tests/ → tests/, v3/packages/ → packages/ - Move v3/tsconfig.json, v3/vitest.config.ts to root - Merge v3/package.json into root package.json (ESM, scripts, deps, exports) - Merge v3/scripts/ into scripts/, v3/implementation/ into docs/implementation/ - Update all CI workflows to remove "cd v3 &&" and v3/ path prefixes - Fix all init installer path resolution (3-level-up → 2-level-up) - Fix hooks to use "node ./dist/cli/bundle.js" instead of bare "aqe" - Update settings.json ADR/DDD directories to docs/implementation/ - Fix helper scripts (statusline, adr-compliance, ddd-tracker, guidance-hooks) - Update 58 agent definitions: aqe/v3/ → aqe/ memory namespaces - Update 15 guidance shards: v3/src/ → src/ path references - Fix sync interfaces: remove v3/ and v2/ path references - Fix test path calculations (process.cwd() + '..' no longer needed) - Fix flaky perf test threshold (500ms → 1000ms for CI environments) - Fix complexity-analyzer test to match ADR-051 keyword-based eligibility Build passes, 17,901 tests pass, CLI and MCP bundles verified. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
103 lines
3.3 KiB
TypeScript
103 lines
3.3 KiB
TypeScript
/**
|
|
* Generate embeddings for migrated V2 patterns
|
|
* This script generates embeddings for all patterns in the database
|
|
* and stores them in the qe_pattern_embeddings table for HNSW search
|
|
*/
|
|
|
|
import { createSQLitePatternStore } from '../src/learning/sqlite-persistence.js';
|
|
import { computeRealEmbedding } from '../src/learning/real-embeddings.js';
|
|
import type { QEPattern } from '../src/learning/qe-patterns.js';
|
|
|
|
async function main() {
|
|
console.log('=== Generating Embeddings for Migrated Patterns ===\n');
|
|
|
|
// Initialize SQLite Pattern Store
|
|
console.log('1. Initializing Pattern Store...');
|
|
const patternStore = createSQLitePatternStore({
|
|
dbPath: '.agentic-qe/memory.db',
|
|
});
|
|
await patternStore.initialize();
|
|
console.log(' Initialized');
|
|
|
|
// Get all patterns
|
|
console.log('\n2. Loading all patterns...');
|
|
const allPatterns = patternStore.getPatterns({ limit: 10000 });
|
|
console.log(' Loaded', allPatterns.length, 'patterns');
|
|
|
|
// Check existing embeddings
|
|
const existingEmbeddings = patternStore.getAllEmbeddings();
|
|
console.log(' Existing embeddings:', existingEmbeddings.length);
|
|
|
|
const patternsToEmbed = allPatterns.filter(p =>
|
|
!existingEmbeddings.some(e => e.patternId === p.id)
|
|
);
|
|
console.log(' Patterns needing embeddings:', patternsToEmbed.length);
|
|
|
|
if (patternsToEmbed.length === 0) {
|
|
console.log('\n All patterns already have embeddings!');
|
|
await patternStore.close();
|
|
return;
|
|
}
|
|
|
|
// Generate embeddings in batches
|
|
console.log('\n3. Generating embeddings...');
|
|
console.log(' Loading embedding model...');
|
|
|
|
let successCount = 0;
|
|
let errorCount = 0;
|
|
const batchSize = 10;
|
|
|
|
for (let i = 0; i < patternsToEmbed.length; i += batchSize) {
|
|
const batch = patternsToEmbed.slice(i, i + batchSize);
|
|
const batchNum = Math.floor(i / batchSize) + 1;
|
|
const totalBatches = Math.ceil(patternsToEmbed.length / batchSize);
|
|
|
|
console.log(` Batch ${batchNum}/${totalBatches} (${batch.length} patterns)...`);
|
|
|
|
for (const pattern of batch) {
|
|
try {
|
|
// Generate embedding from pattern name + description
|
|
const textToEmbed = [
|
|
pattern.name,
|
|
pattern.description || '',
|
|
pattern.domain || '',
|
|
].filter(Boolean).join('. ');
|
|
|
|
const embedding = await computeRealEmbedding(textToEmbed, {
|
|
model: 'Xenova/all-MiniLM-L6-v2',
|
|
});
|
|
|
|
// Store embedding
|
|
patternStore.storePatternEmbedding(pattern.id, embedding);
|
|
|
|
successCount++;
|
|
|
|
// Show progress every 25 patterns
|
|
if (successCount % 25 === 0) {
|
|
console.log(` Progress: ${successCount}/${patternsToEmbed.length} (${((successCount / patternsToEmbed.length) * 100).toFixed(1)}%)`);
|
|
}
|
|
} catch (error) {
|
|
errorCount++;
|
|
console.warn(` Failed to embed pattern ${pattern.id}:`, error);
|
|
}
|
|
}
|
|
}
|
|
|
|
console.log('\n4. Results:');
|
|
console.log(' Successful embeddings:', successCount);
|
|
console.log(' Failed embeddings:', errorCount);
|
|
|
|
// Verify embeddings
|
|
console.log('\n5. Verifying embeddings...');
|
|
const finalEmbeddings = patternStore.getAllEmbeddings();
|
|
console.log(' Total embeddings in database:', finalEmbeddings.length);
|
|
|
|
await patternStore.close();
|
|
console.log('\n=== Embedding Generation Complete ===');
|
|
}
|
|
|
|
main().catch(error => {
|
|
console.error('Script failed:', error);
|
|
process.exit(1);
|
|
});
|