Files
wehub-resource-sync 9b395f5cc3
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:39:48 +08:00

47 lines
1.7 KiB
JavaScript

/**
* OpenReview full-text search.
*/
import { cli, Strategy } from '@jackwener/opencli/registry';
import { ArgumentError, EmptyResultError } from '@jackwener/opencli/errors';
import { noteToRow, openreviewFetch, requireBoundedInt } from './utils.js';
cli({
site: 'openreview',
name: 'search',
access: 'read',
description: 'Search OpenReview papers by free-text query',
domain: 'openreview.net',
strategy: Strategy.PUBLIC,
browser: false,
args: [
{ name: 'query', positional: true, required: true, help: 'Search keyword (e.g. "diffusion model")' },
{ name: 'limit', type: 'int', default: 25, help: 'Max results (max 50)' },
],
columns: ['rank', 'id', 'title', 'authors', 'venue', 'pdate', 'url'],
func: async (args) => {
const term = String(args.query ?? '').trim();
if (!term) {
throw new ArgumentError('openreview search query cannot be empty');
}
const limit = requireBoundedInt(args.limit, 25, 50);
const path = `/notes/search?term=${encodeURIComponent(term)}&type=terms&limit=${limit}`;
const json = await openreviewFetch(path, 'openreview search');
const notes = Array.isArray(json?.notes) ? json.notes : [];
if (!notes.length) {
throw new EmptyResultError('openreview', `No papers found for "${term}". Try a different keyword.`);
}
return notes.slice(0, limit).map((note, i) => {
const row = noteToRow(note);
return {
rank: i + 1,
id: row.id,
title: row.title,
authors: row.authors,
venue: row.venue,
pdate: row.pdate,
url: row.url,
};
});
},
});