mirror of
https://github.com/getcompanion-ai/alpha-hub.git
synced 2026-04-17 15:04:51 +00:00
Alpha Hub: Context Hub for research papers
CLI + MCP server for searching papers and building persistent knowledge. Powered by alphaXiv for semantic search, paper reports, and PDF Q&A. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
commit
9a708a1ab9
20 changed files with 2212 additions and 0 deletions
37
cli/src/commands/search.js
Normal file
37
cli/src/commands/search.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import chalk from 'chalk';
|
||||
import { searchByEmbedding, searchByKeyword, disconnect } from '../lib/alphaxiv.js';
|
||||
import { output, error } from '../lib/output.js';
|
||||
|
||||
function formatResults(data) {
|
||||
const text = typeof data === 'string' ? data : JSON.stringify(data, null, 2);
|
||||
console.log(text);
|
||||
}
|
||||
|
||||
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')
|
||||
.action(async (query, cmdOpts) => {
|
||||
const opts = { ...program.opts(), ...cmdOpts };
|
||||
try {
|
||||
let results;
|
||||
if (opts.mode === 'keyword') {
|
||||
results = await searchByKeyword(query);
|
||||
} else if (opts.mode === 'both') {
|
||||
const [semantic, keyword] = await Promise.all([
|
||||
searchByEmbedding(query),
|
||||
searchByKeyword(query),
|
||||
]);
|
||||
results = { semantic, keyword };
|
||||
} else {
|
||||
results = await searchByEmbedding(query);
|
||||
}
|
||||
output(results, formatResults, opts);
|
||||
} catch (err) {
|
||||
error(err.message, opts);
|
||||
} finally {
|
||||
await disconnect();
|
||||
}
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue