qiaomu-opencli-skills

repository·main·Indexed 21 days ago

https://github.com/joeseesun/qiaomu-opencli-skills

A collection of Claude Code Skills for OpenCLI providing CLI interfaces for 79+ websites and desktop applications. It enables AI agents to automate tasks such as searching, posting, and downloading content from platforms like Bilibili, Twitter/X, and YouTube, as well as controlling Electron-based apps like Cursor, ChatGPT, and Notion. Includes specialized skills for adapter repair (qiaomu-opencli-autofix) and browser automation.

Tokens
27.8K
Snippets
82
Records
107
Agent score
76%

What's inside qiaomu-opencli-skills

  1. Overview of Qiaomu OpenCLI Skills

    main
    Qiaomu OpenCLI Skills is a collection of Claude Code Skills built on top of jackwener/opencli. It transforms over 79 websites and various desktop applications into CLI interfaces, enabling AI Agents to perform tasks like searching, posting, downloading videos, and controlling browsers or Electron apps (e.g., Cursor, Notion, ChatGPT).
  2. Explore related Qiaomu OpenCLI Skills

    main

    The following specialized skills are available to extend the capabilities of OpenCLI:

    • opencli-browser: Provides browser automation for AI agents, enabling them to navigate, click, type, and extract data via Chrome.
    • opencli-explorer: A comprehensive guide and toolset for creating new adapters, covering API discovery, authentication strategies, and TypeScript implementation.
    • opencli-oneshot: A streamlined 4-step template designed for quickly adding a single command from a specific URL.
    • opencli-autofix: A utility to automatically repair broken adapters when command executions fail.
  3. Use the qiaomu-smart-search skill for intelligent routing

    main

    The qiaomu-smart-search skill acts as an intelligent router that directs queries to the best available opencli search sources based on the topic and scenario. It is designed for searching, querying, or researching information across websites, social media, technical documentation, news, shopping, travel, finance, or Chinese-language content.

    Core Workflow:

    1. Identify Data Sources: Instead of relying on hardcoded commands, use opencli to discover real-time capabilities.
    2. Route Queries:
      • If a user specifies a site/platform, use that site directly.
      • If no site is specified, select exactly one AI source (grok, doubao, or gemini).
      • If the AI response is insufficient or requires authoritative/vertical data, supplement with 1-2 specialized sources.
    3. Report Results: Every query must end with a "Search Summary" (搜索摘要) detailing the sites used, queries performed, and counts.
    搜索摘要
    - 网站:<site1> | 查询词:<term1> | 次数:<n>
    - 网站:<site2> | 查询词:<term2>;<term3> | 次数:<n>
    - 已跳过:<site3>,原因:达到频率上限
  4. Use shopping skills for product search and price comparison

    main

    The shopping skills in Qiaomu OpenCLI allow you to search for products, compare prices, find deals, check reviews, and retrieve results from regional e-commerce platforms.

    Available platforms include:

    • amazon: Global product search, price references, and English-language e-commerce.
    • smzdm: Domestic (China) deals, discounts, shopping guides, and product discussions.
    • coupang: South Korean e-commerce product search.
    • douban: Supplementary reviews for books, movies, and music to aid consumer decision-making.
  5. Select the appropriate AI source

    main

    When no specific website is requested, choose exactly one of the following AI sources based on the context:

    • grok: Best for real-time discussions, English-language internet discourse, Twitter/X context, and trending topics.
    • doubao: Best for Chinese-language contexts, ByteDance/Douyin ecosystem, lifestyle content, and Chinese trending topics/Q&A.
    • gemini: Best for global web content, English-language documentation, general information retrieval, and background summaries.

    Constraint: Once an AI source has been queried for a specific problem, do not re-query it with different keywords. If the answer is insufficient, supplement with specialized sources instead.

  6. Heuristics for Advanced API Discovery

    main

    If automated exploration fails, use these high-priority heuristics to find APIs:

    1. Suffix Probing (.json): Try adding .json to the URL (e.g., /r/all.json on Reddit) to access clean REST data.
    2. Global State Extraction (__INITIAL_STATE__): For SSR sites (e.g., Xiaohongshu, Bilibili), use page.evaluate('() => window.__INITIAL_STATE__') to grab the full data tree from the window object.
    3. Active Interaction: Manually click buttons (e.g., "Expand All", "CC") via evaluate to trigger hidden Network Fetches.
    4. Framework Store Interception: For Vue + Pinia sites, call Store Actions directly to bypass complex authentication/signing.
    5. XHR/Fetch Interception: As a last resort, use TypeScript adapters for non-intrusive request capturing.
  7. Understand OpenCLI Authentication Levels

    main

    OpenCLI uses a 5-level authentication system to access different types of data and services:

    1. public: Public APIs that require no authentication.
    2. cookie: Reuses existing browser cookies (the most common method for web scraping/automation).
    3. header: Requires an API Token passed in the request header.
    4. intercept: Intercepts requests to capture necessary tokens.
    5. ui: Uses Chrome DevTools Protocol (CDP) to control desktop applications directly.
  8. Choose the right Strategy for adapters

    main

    When writing an adapter in ~/.opencli/clis/, select the appropriate Strategy based on how you access data:

    StrategyWhen to usebrowser: setting
    Strategy.PUBLICUsing a public API, no auth requiredfalse
    Strategy.COOKIENeeds existing login cookies/sessiontrue
    Strategy.UIDirect DOM interaction/scrapingtrue

    Note: Always prefer Strategy.PUBLIC (API) over Strategy.UI (DOM) if an API is available.

    // Example Strategy.PUBLIC implementation
    import { cli, Strategy } from '@jackwener/opencli/registry';
    
    cli({
      site: 'hn',
      name: 'top',
      strategy: Strategy.PUBLIC,
      browser: false,
      // ...
    });
  9. Use the Intercept Strategy for complex sites (Pinia/XHR)

    main

    For sites that use complex JavaScript logic, XHR signatures, or state management like Pinia (e.g., Xiaohongshu), use Strategy.INTERCEPT.

    Instead of trying to replicate complex request signatures, you can use page.installInterceptor(pattern) to hijack the site's own XMLHttpRequest or fetch calls.

    Workflow:

    1. Set strategy: Strategy.INTERCEPT and browser: true.
    2. Navigate to the target page and wait for loading.
    3. Call await page.installInterceptor('url_pattern') to start listening for specific requests.
    4. Trigger the request by interacting with the page (e.g., page.autoScroll() or calling a Pinia store action via page.evaluate()).
    5. Retrieve the captured data using await page.getInterceptedRequests().
    import { cli, Strategy } from '@jackwener/opencli/registry';
    
    cli({
      site: 'xiaohongshu',
      name: 'notifications',
      description: '小红书通知',
      domain: 'www.xiaohongshu.com',
      strategy: Strategy.INTERCEPT,
      browser: true,
      args: [
        { name: 'type', type: 'str', default: 'mentions' },
        { name: 'limit', type: 'int', default: 20 },
      ],
      columns: ['rank', 'user', 'action', 'content', 'note', 'time'],
      func: async (page, kwargs) => {
        await page.goto('https://www.xiaohongshu.com/notification');
        await page.wait(3);
    
        // Install interceptor for specific URL pattern
        await page.installInterceptor('/you/');
    
        // Trigger API via Pinia store action
        await page.evaluate(`(async () => {
          const app = document.querySelector('#app')?.__vue_app__;
          const pinia = app?.config?.globalProperties?.$pinia;
          const store = pinia?._s?.get('notification');
          if (store?.getNotification) {
            await store.getNotification('${kwargs.type}');
          }
        })()`);
    
        const requests = await page.getInterceptedRequests();
        if (!requests?.length) return [];
    
        let results: any[] = [];
        for (const req of requests) {
          const items = req.data?.data?.message_list || [];
          results.push(...items);
        }
    
        return results.slice(0, kwargs.limit).map((item, i) => ({
          rank: i + 1,
          user: item.user_info?.nickname || '',
          action: item.title || '',
          content: item.comment_info?.content || '',
        }));
      },
    });
  10. Routing logic for technical search queries

    main

    When using the OpenCLI skills, you can optimize your results by selecting the appropriate source based on the user's intent. Use the following routing logic to decide which skill to invoke:

    • Research/Papers: If the query mentions "papers" (论文) or "research" (研究), prioritize arxiv.
    • Code/Errors: If the query mentions "errors" (报错) or "API usage" (API 怎么用), prioritize stackoverflow.
    • Community/Opinions: If the query seeks "community discussion" (社区讨论) or "developer opinions" (开发者观点), prioritize hackernews or reddit.
    • General/Fallback: If no specific site is mentioned, start with general models like gemini or grok. If the information provided by those models is insufficient, supplement the results using the specialized technical sources listed above.
  11. Determine the correct authentication strategy

    main

    Choose your Strategy based on how easily the API can be called via a fetch request in the browser console:

    Result of fetch(url)StrategyImplementation Detail
    Works directlyStrategy.PUBLICUse browser: false
    Works with {credentials: 'include'}Strategy.COOKIEUse func() pattern
    Works with Bearer/CSRF headersStrategy.HEADERUse TS func()
    Fails via fetch but works on pageStrategy.INTERCEPTUse installInterceptor