Lobe CLI Toolbox

repository·master·Indexed 19 days ago

https://github.com/lobehub/lobe-cli-toolbox

A suite of AI-enhanced command-line tools to improve developer productivity. It includes lobe-i18n for automating internationalization workflows and Markdown translation, lobe-seo for automating SEO Matter generation, lobe-commit for generating Gitmoji-based commit messages, and lobe-label for syncing issue labels from template repositories.

Tokens
39.9K
Snippets
133
Records
175
Agent score
64%

What's inside lobe-cli-toolbox

  1. Overview of Lobe i18n capabilities

    master

    Lobe i18n is a tool designed to automate internationalization (i18n) workflows using ChatGPT. Key features include:

    • Automated Translation: Leverages ChatGPT to automate the translation process.
    • Large File Support: Automatically splits large files to avoid ChatGPT token limits.
    • Incremental Updates: Supports incremental i18n updates by automatically extracting new content based on an entry file.
    • Flexible File Structures: Supports both single-file mode (e.g., en.json) and folder mode (e.g., en/common.json), making it compatible with i18next.
    • Locale Formats: Supports both flat and tree locale file structures.
    • Customizable AI Configuration: Allows users to specify custom OpenAI models, API proxies, and temperature settings.
  2. Lobe i18n: Automate internationalization workflows

    master

    Lobe i18n is an automation tool for the i18n translation process powered by ChatGPT. Key features include:

    • Automatic splitting of large translation files.
    • Incremental updates.
    • Customization of OpenAI models, API proxies, and temperature settings.
  3. Choose between `string` and `mdast` translation modes

    master

    The mode configuration determines how Markdown content is processed for translation:

    • string: The entire Markdown content is treated as a single string and sent for translation. This preserves the full structure but may use more tokens.
    • mdast: Uses mdast (Markdown Abstract Syntax Tree) to parse the structure and only translates the text value nodes.
      • Pros: Significantly reduces token consumption by stripping most Markdown syntax and links.
      • Cons: May lead to less accurate translations due to the reduced context.
      • Note: If using mdast and you need to translate code blocks, you must set translateCode: true.
  4. Lobe i18n: Automated internationalization translation

    master

    An automation tool for the internationalization translation process, powered by ChatGPT. Key features include:

    • Automatic splitting of large files.
    • Incremental updates.
    • Customization options for OpenAI models, API proxies, and temperature settings.
  5. Configure Lobe SEO via files

    master

    Lobe SEO supports configuration using the cosmiconfig format. You can define settings in the following ways:

    • The seo property in package.json.
    • A .seorc file in JSON or YAML format.
    • Specific files: .seorc.json, .seorc.yaml, .seorc.yml, .seorc.js, or .seorc.cjs.

    For type safety, you can import defineConfig from @lobehub/seo-cli when using .js configuration files.

    const { defineConfig } = require('@lobehub/seo-cli');
    
    module.exports = defineConfig({
      entry: './docs/**/*.mdx',
      modelName: 'gpt-3.5-turbo-1106',
      experimental: {
        jsonMode: true,
      },
    });
  6. Choose between Single-file and Folder-based Locale structures

    master

    Lobe i18n supports two primary ways of organizing translation files:

    1. Single-file structure

    All languages are stored in individual JSON files within a directory.

    - locales/
      - en_US.json
      - zh_CN.json

    Config: Set entry to the specific source JSON file.

    2. Folder structure

    Each language has its own directory containing multiple JSON files (compatible with i18next).

    - locales/
      - en_US/
        - common.json
      - zh_CN/
        - common.json

    Config: Set entry to the source language directory.

    // Single-file config example
    {
      "entry": "locales/en.json",
      "entryLocale": "en_US",
      "output": "locales",
      "outputLocales": ["zh_CN", "ja_JP"]
    }
    
    // Folder-structure config example
    {
      "entry": "locales/en_US",
      "entryLocale": "en_US",
      "output": "locales",
      "outputLocales": ["zh_CN", "ja_JP"]
    }
  7. Understand the output of update-models.ts

    master

    The script generates a formatted packages/common/models.ts file containing three main exports:

    1. LanguageModel: An enum containing all available models. The script automatically converts kebab-case model names to UPPER_SNAKE_CASE for the enum members.
    2. ModelTokens: A Record<LanguageModel, number> that maps each model to its context window token count (formatted with underscores for readability).
    3. defaultModel: A constant representing the recommended default model (prioritizing recent 'mini' models like o4-mini).
    export enum LanguageModel {
      /**
       * o3
       */
      O3 = 'o3',
      // ... more models
    }
    
    export const ModelTokens: Record<LanguageModel, number> = {
      [LanguageModel.O3]: 200_000,
      // ... more mappings
    };
    
    export const defaultModel = LanguageModel.O4_MINI;