feat: sync runtime search and schema quality updates from app repo

- port retrieval, validation, and eval improvements relevant to os
- align prompts and dimensions with the flat single-agent model
- replace the old eval suite with the focused core scenarios

Generated with Codex
This commit is contained in:
“BeeRad”
2026-03-15 14:55:45 +11:00
parent 053c163e31
commit 4c75df101f
57 changed files with 1809 additions and 534 deletions
+10 -36
View File
@@ -1,6 +1,5 @@
import { NextRequest, NextResponse } from 'next/server';
import { getSQLiteClient } from '@/services/database/sqlite-client';
import { eventBroadcaster } from '@/services/events';
export const runtime = 'nodejs';
@@ -35,13 +34,12 @@ async function getPopularDimensionsSQLite() {
)
SELECT ad.name AS dimension,
COALESCE(dc.count, 0) AS count,
COALESCE(dim.is_priority, 0) AS is_priority,
dim.description
FROM all_dimensions ad
LEFT JOIN dimension_counts dc ON dc.dimension = ad.name
LEFT JOIN dimensions dim ON dim.name = ad.name
WHERE ad.name IS NOT NULL
ORDER BY is_priority DESC, LOWER(ad.name) ASC
ORDER BY LOWER(ad.name) ASC
`);
return NextResponse.json({
@@ -50,7 +48,7 @@ async function getPopularDimensionsSQLite() {
data: result.rows.map((row: any) => ({
dimension: row.dimension,
count: Number(row.count),
isPriority: Boolean(row.is_priority),
isPriority: false,
description: row.description || null
}))
});
@@ -67,7 +65,14 @@ export async function POST(request: NextRequest) {
}, { status: 400 });
}
return togglePrioritySQLite(dimension);
return NextResponse.json({
success: true,
data: {
dimension,
is_priority: false
},
message: 'Priority dimensions are no longer part of the product model.'
});
} catch (error) {
console.error('Error toggling dimension priority:', error);
return NextResponse.json({
@@ -76,34 +81,3 @@ export async function POST(request: NextRequest) {
}, { status: 500 });
}
}
// PostgreSQL path removed in SQLite-only consolidation
async function togglePrioritySQLite(dimension: string) {
const sqlite = getSQLiteClient();
const result = sqlite.query(`
INSERT INTO dimensions(name, is_priority, updated_at)
VALUES (?, 1, CURRENT_TIMESTAMP)
ON CONFLICT(name) DO UPDATE SET
is_priority = CASE WHEN is_priority=1 THEN 0 ELSE 1 END,
updated_at = CURRENT_TIMESTAMP
RETURNING is_priority
`, [dimension]);
const isPriority = Boolean(result.rows[0].is_priority);
// Broadcast dimension update event
eventBroadcaster.broadcast({
type: 'DIMENSION_UPDATED',
data: { dimension, isPriority }
});
return NextResponse.json({
success: true,
data: {
dimension,
is_priority: isPriority
}
});
}