fix: add configSchema to openclaw.plugin.json, add search CLI command, fix total_docs stat

- Add required configSchema to openclaw.plugin.json for OpenClaw plugin discovery
- Add search command to CLI with --limit, --dir, --from-date, --to-date, --tags filters
- Fix get_stats() to properly count unique docs (was returning 0 for non-null values)
- Remove hardcoded max_results default of 5; search now returns all results by default
- Update INSTALL.md and design docs with correct OpenClaw extension path instructions
This commit is contained in:
2026-04-11 20:01:09 -04:00
parent de3b9c1c12
commit e15e4ff856
6 changed files with 137 additions and 22 deletions

View File

@@ -74,7 +74,7 @@ export async function searchVectorDb(
}
const whereClause = conditions.length > 0 ? conditions.join(" AND ") : undefined;
const limit = options.max_results ?? 5;
const limit = options.max_results;
// Try vector search first; if Ollama is down embedQuery throws → fallback to FTS
let rows: Record<string, unknown>[];
@@ -85,14 +85,20 @@ export async function searchVectorDb(
if (whereClause) {
queryBuilder = queryBuilder.filter(whereClause);
}
rows = await queryBuilder.limit(limit).toArray();
if (limit !== undefined) {
queryBuilder = queryBuilder.limit(limit);
}
rows = await queryBuilder.toArray();
} catch {
// Ollama unavailable — fallback to full-text search on chunk_text (BM25 scoring)
let ftsBuilder = table.query().fullTextSearch(query);
if (whereClause) {
ftsBuilder = ftsBuilder.filter(whereClause);
}
rows = await ftsBuilder.limit(limit).toArray();
if (limit !== undefined) {
ftsBuilder = ftsBuilder.limit(limit);
}
rows = await ftsBuilder.toArray();
}
return rows.map((r: Record<string, unknown>) => ({