JSPM

  • Created
  • Published
  • Downloads 160
  • Score
    100M100P100Q133823F
  • License SEE LICENSE IN LICENSE

KOB CLI โ€” AI-powered code generation tool. Built by Kob AI, made in Thailand.

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (kob-cli) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    ๐Ÿค– KOB AI CLI

    Command-line interface for interacting with KOB AI API. Built with Bun and TypeScript.

    Developed by Kob AI โ€” www.kob-ai.dev | Developer in Thailand ๐Ÿ‡น๐Ÿ‡ญ

    โœจ Features

    • ๐Ÿ” Authentication - Verify credentials and check balance
    • ๐Ÿ’ฌ AI Chat - Send messages and get AI responses
    • ๐ŸŒŠ Streaming - Real-time streaming AI responses
    • ๐Ÿค– Models - Browse available AI models and pricing
    • ๐Ÿ“ Projects - Create, update, list, and delete projects
    • ๐Ÿ“œ Rules - Manage project rules (forbidden, required, custom)
    • ๐Ÿ’ฐ Credits - View credit history and transactions
    • ๐ŸŽจ Rich Output - Beautiful terminal output with colors and formatting

    ๐Ÿš€ Quick Start

    Prerequisites

    • Bun runtime installed (Install Bun)
    • KOB AI API credentials (API Key)
    npm install -g kob-cli

    Installation from source

    1. Clone or navigate to the kob-cli directory:
    cd kob-cli
    1. Install dependencies:
    bun install
    1. Set up environment variables:
    # Copy the example env file
    cp .env.example .env
    
    # Edit .env and add your credentials
    # KOB_API_BASE_URL=https://www.kob-ai.dev
    # KOB_API_KEY=kob_your_api_key

    Or export them directly:

    export KOB_API_KEY=kob_your_api_key

    Usage

    Run the CLI directly with Bun:

    bun run src/index.ts <command>

    Or use the npm script:

    bun dev <command>

    ๐Ÿ“– Commands

    Authentication

    Verify credentials:

    bun dev auth:verify

    Shows user information, package details, and credit balance.

    Check balance:

    bun dev balance

    Quick check of your current credit balance.

    AI Chat

    Send a message:

    bun dev chat "Explain quantum computing" \
      --provider DeepSeek \
      --model deepseek-chat \
      --temperature 0.7

    Interactive chat mode:

    bun dev chat:interactive \
      --provider OpenRouter \
      --model openai/gpt-4o

    Interactive commands:

    • /clear - Clear conversation history
    • /stats - Show conversation statistics
    • /help - Show available commands
    • /exit - Exit chat mode

    Streaming

    Stream AI response:

    bun dev stream "Write a poem about coding" \
      --provider OpenRouter \
      --model google/gemini-flash-1.5

    Real-time token-by-token display as AI generates response.

    Models

    List all models:

    bun dev models

    Filter by provider:

    bun dev models --provider DeepSeek

    JSON output:

    bun dev models --format json

    Projects

    List projects:

    bun dev projects:list

    Create project:

    bun dev projects:create "My Chatbot" \
      --description "AI chatbot for customer support"

    Update project:

    bun dev projects:update <project-id> \
      --name "Updated Name" \
      --description "New description"

    Delete project:

    bun dev projects:delete <project-id>

    Rules

    List rules:

    bun dev rules:list --project-id <project-id>

    Create rule:

    bun dev rules:create \
      --project-id <project-id> \
      --text "Must respond in Thai only" \
      --type required

    Rule types:

    • forbidden - ๐Ÿšซ Things AI must not do
    • required - โœ… Things AI must do
    • custom - ๐Ÿ“Œ Custom rules

    Update rule:

    bun dev rules:update <rule-id> \
      --project-id <project-id> \
      --text "Updated rule text" \
      --active false

    Delete rule:

    bun dev rules:delete <rule-id> --project-id <project-id>

    Credits

    View credit history:

    bun dev credits:history

    With pagination:

    bun dev credits:history --limit 50 --offset 0

    ๐Ÿ”ง Options

    Chat & Stream Options

    Option Description Default
    -p, --provider AI provider (DeepSeek, OpenRouter, DeepInfra) DeepSeek
    -m, --model Model ID deepseek-chat
    -t, --temperature Temperature (0.0-2.0) 0.7
    --max-tokens Maximum tokens 4096
    --project-id Project ID for rules -
    --system-prompt System prompt -

    Common Providers and Models

    DeepSeek:

    • deepseek-chat (DeepSeek V3)
    • deepseek-reasoner (DeepSeek R1)
    • deepseek-v4-pro
    • deepseek-v4-flash

    OpenRouter:

    • openai/gpt-4o
    • openai/gpt-4o-mini
    • anthropic/claude-3.5-sonnet
    • google/gemini-1.5-pro

    DeepInfra:

    • meta-llama/Meta-Llama-3.1-8B-Instruct
    • meta-llama/Meta-Llama-3.1-70B-Instruct
    • Qwen/Qwen2.5-72B-Instruct

    ๐Ÿ’ก Examples

    Complete Workflow

    # 1. Verify connection
    bun dev auth:verify
    
    # 2. Check available models
    bun dev models --provider DeepSeek
    
    # 3. Create a project
    bun dev projects:create "Customer Support Bot"
    
    # 4. Add rules to project
    bun dev rules:create \
      --project-id <id> \
      --text "Always respond in Thai" \
      --type required
    
    # 5. Chat with AI using project rules
    bun dev chat "เธชเธงเธฑเธชเธ”เธต เธŠเนˆเธงเธขเนเธ™เธฐเธ™เธณเธชเธดเธ™เธ„เน‰เธฒเธซเธ™เนˆเธญเธข" \
      --project-id <id>
    
    # 6. Stream response for longer content
    bun dev stream "Write a detailed guide about AI" \
      --model openai/gpt-4o
    
    # 7. Check credit usage
    bun dev balance
    bun dev credits:history

    ๐Ÿ›  Development

    Project Structure

    kob-cli/
    โ”œโ”€โ”€ src/
    โ”‚   โ”œโ”€โ”€ index.ts              # CLI entry point
    โ”‚   โ”œโ”€โ”€ commands/             # Command implementations
    โ”‚   โ”‚   โ”œโ”€โ”€ auth.ts          # Authentication commands
    โ”‚   โ”‚   โ”œโ”€โ”€ chat.ts          # Chat commands
    โ”‚   โ”‚   โ”œโ”€โ”€ stream.ts        # Streaming command
    โ”‚   โ”‚   โ”œโ”€โ”€ models.ts        # Models command
    โ”‚   โ”‚   โ”œโ”€โ”€ projects.ts      # Project CRUD
    โ”‚   โ”‚   โ”œโ”€โ”€ rules.ts         # Rules CRUD
    โ”‚   โ”‚   โ””โ”€โ”€ credits.ts       # Credit history
    โ”‚   โ”œโ”€โ”€ utils/               # Utility modules
    โ”‚   โ”‚   โ”œโ”€โ”€ api.ts           # API client
    โ”‚   โ”‚   โ”œโ”€โ”€ config.ts        # Configuration
    โ”‚   โ”‚   โ”œโ”€โ”€ format.ts        # Output formatting
    โ”‚   โ”‚   โ””โ”€โ”€ errors.ts        # Error handling
    โ”‚   โ””โ”€โ”€ types/               # TypeScript types
    โ”‚       โ””โ”€โ”€ index.ts
    โ”œโ”€โ”€ .env.example             # Environment variables template
    โ”œโ”€โ”€ package.json
    โ””โ”€โ”€ README.md

    Adding New Commands

    1. Create command file in src/commands/
    2. Export the command
    3. Import and add to src/index.ts

    Build for Distribution

    bun run build

    This creates a compiled binary kob-cli.exe.

    โ“ Troubleshooting

    Error: KOB_API_KEY environment variable is required

    • Make sure you've set your environment variables
    • Check that they're exported correctly or in .env file

    Authentication failed

    • Verify your API key is correct
    • Check that your key is active on the Kob AI dashboard

    Insufficient credits

    Model not available

    • List available models with bun dev models
    • Verify the model ID is correct

    ๐Ÿ“ API Documentation

    For detailed API documentation, see the official KOB AI API docs in the parent directory:

    • /my-app/docs/api-token-verify.md
    • /my-app/docs/api-ai-chat.md
    • /my-app/docs/api-ai-stream.md
    • /my-app/docs/api-models.md
    • /my-app/docs/api-projects.md
    • /my-app/docs/api-project-rules.md
    • /my-app/docs/api-credit-history.md

    ๐Ÿ“„ License

    KOB AI CLI - Non-Commercial Open Source License

    Copyright (c) 2025 KOB AI Project Owner

    This software is open source and free to use, modify, and distribute for non-commercial purposes only.

    Commercial use is strictly prohibited without prior written permission from the owner.

    For commercial licensing inquiries, please contact the project owner.

    See the LICENSE file for full terms.

    ๐Ÿค Support

    For issues or questions, please visit https://www.kob-ai.dev or contact the Kob AI development team.