Add comprehensive tests for schema cleanup migration and search comparison

- Implement tests for migration 005 to verify removal of deprecated fields in the database schema.
- Ensure that new databases are created with a clean schema.
- Validate that keywords are correctly extracted from the normalized file_keywords table.
- Test symbol insertion without deprecated fields and subdir operations without direct_files.
- Create a detailed search comparison test to evaluate vector search vs hybrid search performance.
- Add a script for reindexing projects to extract code relationships and verify GraphAnalyzer functionality.
- Include a test script to check TreeSitter parser availability and relationship extraction from sample files.
This commit is contained in:
catlog22
2025-12-16 19:27:05 +08:00
parent 3da0ef2adb
commit df23975a0b
61 changed files with 13114 additions and 366 deletions

View File

@@ -235,6 +235,35 @@ async function loadHookConfig() {
}
}
async function loadAvailableSkills() {
try {
const response = await fetch('/api/skills?path=' + encodeURIComponent(projectPath));
if (!response.ok) throw new Error('Failed to load skills');
const data = await response.json();
// Combine project and user skills
const projectSkills = (data.projectSkills || []).map(s => ({
name: s.name,
path: s.path,
scope: 'project'
}));
const userSkills = (data.userSkills || []).map(s => ({
name: s.name,
path: s.path,
scope: 'user'
}));
// Store in window for access by wizard
window.availableSkills = [...projectSkills, ...userSkills];
return window.availableSkills;
} catch (err) {
console.error('Failed to load available skills:', err);
window.availableSkills = [];
return [];
}
}
/**
* Convert internal hook format to Claude Code format
* Internal: { command, args, matcher, timeout }
@@ -510,7 +539,7 @@ function getHookEventIconLucide(event) {
let currentWizardTemplate = null;
let wizardConfig = {};
function openHookWizardModal(wizardId) {
async function openHookWizardModal(wizardId) {
const wizard = WIZARD_TEMPLATES[wizardId];
if (!wizard) {
showRefreshToast('Wizard template not found', 'error');
@@ -530,6 +559,11 @@ function openHookWizardModal(wizardId) {
wizardConfig.selectedOptions = [];
}
// Ensure available skills are loaded for SKILL context wizard
if (wizardId === 'skill-context' && typeof window.availableSkills === 'undefined') {
await loadAvailableSkills();
}
const modal = document.getElementById('hookWizardModal');
if (modal) {
renderWizardModalContent();
@@ -792,9 +826,19 @@ function renderSkillContextConfig() {
const availableSkills = window.availableSkills || [];
if (selectedOption === 'auto') {
const skillBadges = availableSkills.map(function(s) {
return '<span class="px-1.5 py-0.5 bg-emerald-500/10 text-emerald-500 rounded text-xs">' + escapeHtml(s.name) + '</span>';
}).join(' ');
let skillBadges = '';
if (typeof window.availableSkills === 'undefined') {
// Still loading
skillBadges = '<span class="px-1.5 py-0.5 bg-muted text-muted-foreground rounded text-xs">' + t('common.loading') + '...</span>';
} else if (availableSkills.length === 0) {
// No skills found
skillBadges = '<span class="px-1.5 py-0.5 bg-warning/10 text-warning rounded text-xs">' + t('hook.wizard.noSkillsFound') + '</span>';
} else {
// Skills found
skillBadges = availableSkills.map(function(s) {
return '<span class="px-1.5 py-0.5 bg-emerald-500/10 text-emerald-500 rounded text-xs">' + escapeHtml(s.name) + '</span>';
}).join(' ');
}
return '<div class="bg-muted/30 rounded-lg p-4 text-sm text-muted-foreground">' +
'<div class="flex items-center gap-2 mb-2">' +
'<i data-lucide="info" class="w-4 h-4"></i>' +
@@ -814,10 +858,15 @@ function renderSkillContextConfig() {
'</div>';
} else {
configListHtml = skillConfigs.map(function(config, idx) {
var skillOptions = availableSkills.map(function(s) {
var selected = config.skill === s.id ? 'selected' : '';
return '<option value="' + s.id + '" ' + selected + '>' + escapeHtml(s.name) + '</option>';
}).join('');
var skillOptions = '';
if (availableSkills.length === 0) {
skillOptions = '<option value="" disabled>' + t('hook.wizard.noSkillsFound') + '</option>';
} else {
skillOptions = availableSkills.map(function(s) {
var selected = config.skill === s.name ? 'selected' : '';
return '<option value="' + escapeHtml(s.name) + '" ' + selected + '>' + escapeHtml(s.name) + '</option>';
}).join('');
}
return '<div class="border border-border rounded-lg p-3 bg-card">' +
'<div class="flex items-center justify-between mb-2">' +
'<select onchange="updateSkillConfig(' + idx + ', \'skill\', this.value)" ' +