Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

1.2 KB
Raw Blame
import { cli, Strategy } from '@jackwener/opencli/registry';
import { fetchWebApi } from './utils.js';
cli({
    site: 'weread',
    name: 'ranking',
    access: 'read',
    description: 'WeRead book rankings by category',
    domain: 'weread.qq.com',
    strategy: Strategy.PUBLIC,
    browser: false,
    args: [
        { name: 'category', positional: true, default: 'all', help: 'Category: all (default), rising, or numeric category ID' },
        { name: 'limit', type: 'int', default: 20, help: 'Max results' },
    ],
    columns: ['rank', 'title', 'author', 'category', 'readingCount', 'bookId'],
    func: async (args) => {
        const cat = encodeURIComponent(args.category ?? 'all');
        const data = await fetchWebApi(`/bookListInCategory/${cat}`, { rank: '1' });
        const books = data?.books ?? [];
        return books.slice(0, Number(args.limit)).map((item, i) => ({
            rank: i + 1,
            title: item.bookInfo?.title ?? '',
            author: item.bookInfo?.author ?? '',
            category: item.bookInfo?.category ?? '',
            readingCount: item.readingCount ?? 0,
            bookId: item.bookInfo?.bookId ?? '',
        }));
    },
});