Improve alphaXiv client outputs and exports

This commit is contained in:
Advait Paliwal 2026-03-20 12:03:27 -07:00
parent 9a708a1ab9
commit 270eaa1dc5
11 changed files with 417 additions and 11 deletions

View file

@ -1,5 +1,5 @@
import chalk from 'chalk';
import { searchByEmbedding, searchByKeyword, disconnect } from '../lib/alphaxiv.js';
import { searchByEmbedding, searchByKeyword, agenticSearch, disconnect } from '../lib/alphaxiv.js';
import { output, error } from '../lib/output.js';
function formatResults(data) {
@ -10,20 +10,29 @@ function formatResults(data) {
export function registerSearchCommand(program) {
program
.command('search <query>')
.description('Search papers via alphaXiv (semantic + keyword)')
.option('-m, --mode <mode>', 'Search mode: semantic, keyword, both', 'semantic')
.description('Search papers via alphaXiv (semantic, keyword, both, agentic, or all)')
.option('-m, --mode <mode>', 'Search mode: semantic, keyword, both, agentic, all', 'semantic')
.action(async (query, cmdOpts) => {
const opts = { ...program.opts(), ...cmdOpts };
try {
let results;
if (opts.mode === 'keyword') {
results = await searchByKeyword(query);
} else if (opts.mode === 'agentic') {
results = await agenticSearch(query);
} else if (opts.mode === 'both') {
const [semantic, keyword] = await Promise.all([
searchByEmbedding(query),
searchByKeyword(query),
]);
results = { semantic, keyword };
} else if (opts.mode === 'all') {
const [semantic, keyword, agentic] = await Promise.all([
searchByEmbedding(query),
searchByKeyword(query),
agenticSearch(query),
]);
results = { semantic, keyword, agentic };
} else {
results = await searchByEmbedding(query);
}