@dzhi/ocpg 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/ocpg.ts +6 -2
  2. package/package.json +1 -1
package/ocpg.ts CHANGED
@@ -171,8 +171,12 @@ async function recall(
171
171
  ? sql``
172
172
  : sql`AND project = ${ctx.directory}`;
173
173
  const queryCond = args.query
174
- ? sql`AND search_vector @@ plainto_tsquery('english', ${args.query})`
174
+ ? sql`AND search_vector @@ websearch_to_tsquery('english', ${args.query})`
175
175
  : sql``;
176
+ // Relevance-ranked when searching; recency-ordered for a plain project browse.
177
+ const orderBy = args.query
178
+ ? sql`ORDER BY ts_rank(search_vector, websearch_to_tsquery('english', ${args.query})) DESC`
179
+ : sql`ORDER BY created_at DESC`;
176
180
 
177
181
  const rows = await sql`
178
182
  SELECT id, content, coalesce(tags, '{}') AS tags,
@@ -180,7 +184,7 @@ async function recall(
180
184
  project
181
185
  FROM memories
182
186
  WHERE 1=1 ${projectCond} ${queryCond}
183
- ORDER BY created_at DESC
187
+ ${orderBy}
184
188
  LIMIT ${limit}
185
189
  ` as MemoryRow[];
186
190
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dzhi/ocpg",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "description": "Postgres-backed persistent memory plugin for OpenCode",
6
6
  "main": "ocpg.ts",