================================================================================
  SindByte MCP Server -- OpenCode CLI User Guide
  For End Users
================================================================================
Version: 1.9.09  |  Date: 2026-04-19

--------------------------------------------------------------------------------
 1. WHAT IS OPENCODE CLI?
--------------------------------------------------------------------------------
OpenCode CLI (npm package: opencode-ai) is a terminal-based AI coding assistant.

  Website:   https://opencode.ai
  Install:   npm install -g opencode-ai
  Config:    %USERPROFILE%\.config\opencode\opencode.json

  IMPORTANT: OpenCode CLI is NOT OpenAI Codex.

--------------------------------------------------------------------------------
 2. WHAT IS SINDBYTE?
--------------------------------------------------------------------------------
SindByte is a local MCP Server that provides ~233 tools for AI assistants:
FileTools, SystemTools, Trading tools, WebTools, Clipboard, Memory, and more.

It connects to OpenCode in TWO ways:

  METHOD A -- API ENDPOINT (Port 8091)
    SindByte acts as your AI provider. It sends chat to LM Studio and can
    run an IQ pipeline (chain-of-thought, multi-vote, research) before
    answering. Tools are built into the endpoint.

  METHOD B -- NATIVE MCP SERVER (Port 5555)
    You use your own AI provider (OpenAI, Anthropic, LM Studio, etc.).
    SindByte only provides tools via the MCP protocol. OpenCode decides
    when to call them.

--------------------------------------------------------------------------------
 3. BEFORE YOU START
--------------------------------------------------------------------------------
    1. Make sure SindByte is running (system tray icon)
    2. Make sure OpenCode is installed
    3. Know which method you want (see comparison below)

    Comparison:
    | Feature            | Method A (Endpoint)    | Method B (MCP)          |
    |--------------------|------------------------|-------------------------|
    | AI Brain           | SindByte -> LM Studio  | Your own provider       |
    | Tools              | Built-in               | Via MCP (port 5555)     |
    | IQ Pipeline        | Yes                    | No                      |
    | Setup Complexity   | Easy                   | Slightly more config    |
    | Best For           | IQ/research users      | Preferred AI model users|

--------------------------------------------------------------------------------
 4. METHOD A: API ENDPOINT -- FULL SETUP
--------------------------------------------------------------------------------

 Step 1 -- Install OpenCode (if not done):
    npm install -g opencode-ai

 Step 2 -- Edit config file:
    Notepad "%USERPROFILE%\.config\opencode\opencode.json"

 Step 3 -- Add the SindByte provider block:

    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "sindbyte-mcp": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "SindByte MCP Server (local)",
          "options": {
            "baseURL": "http://127.0.0.1:8091/v1",
            "apiKey": "not-needed"
          },
          "models": {
            "LMDirect":         { "name": "SindByte LMDirect" },
            "LMDirect_Tools":   { "name": "SindByte LMDirect + Tools" },
            "IQTools_Full":     { "name": "SindByte IQTools Full" },
            "IQTools_Research": { "name": "SindByte IQTools Research" },
            "IQTools_Trading":  { "name": "SindByte IQTools Trading" },
            "iq/full":          { "name": "SindByte IQ Full" },
            "iq/research":      { "name": "SindByte IQ Research" },
            "iq/trading":       { "name": "SindByte IQ Trading" },
            "iq/minimal":       { "name": "SindByte IQ Minimal" },
            "iq/off":           { "name": "SindByte IQ Off" }
          }
        }
      },
      "model": "sindbyte-mcp/LMDirect"
    }

 Step 4 -- Save and start OpenCode:
    opencode

--------------------------------------------------------------------------------
 5. METHOD A: MODEL ALIASES
--------------------------------------------------------------------------------

    | Alias             | Description                                     |
    |-------------------|-------------------------------------------------|
    | LMDirect          | Direct chat, no IQ tools                        |
    | LMDirect_Tools    | Direct chat + tool calls                        |
    | IQTools_Full      | Full IQ: CoT + MultiVote + Validate             |
    | IQTools_Research  | Web research + chain-of-thought                 |
    | IQTools_Trading   | Scanner + trading advisor + market data         |
    | iq/full           | Compact alias for full IQ                       |
    | iq/research       | Compact alias for research                      |
    | iq/trading        | Compact alias for trading                       |
    | iq/minimal        | Auto-prompt improvement only                    |
    | iq/off            | Same as LMDirect                                |

 Switch anytime:
    opencode config set model sindbyte-mcp/IQTools_Full

--------------------------------------------------------------------------------
 6. METHOD B: MCP SERVER -- FULL SETUP
--------------------------------------------------------------------------------

 Step 1 -- Install OpenCode (if not done):
    npm install -g opencode-ai

 Step 2 -- Configure your AI provider (example: LM Studio):

    Add to your opencode.json:

      "provider": {
        "lmstudio": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "LM Studio (local)",
          "options": {
            "baseURL": "http://127.0.0.1:1234/v1",
            "apiKey": "lm-studio"
          },
          "models": {
            "qwen3.6-35b-a3b": { "name": "Qwen3.6-35b (local)" }
          }
        }
      },
      "model": "lmstudio/qwen3.6-35b-a3b"

    NOTE: Replace "lm-studio" with your actual LM Studio API key if you
    have authentication enabled.

 Step 3 -- Add SindByte as MCP server:

    In the SAME opencode.json, add:

      "mcp": {
        "sindbyte": {
          "type": "remote",
          "url": "http://127.0.0.1:5555/mcp",
          "enabled": true
        }
      }

 Step 4 -- Save and start OpenCode:
    opencode

 Step 5 -- Verify:
    Inside OpenCode, run:
      opencode mcp list
    You should see "sindbyte" listed as connected.

--------------------------------------------------------------------------------
 7. METHOD B: MANAGING TOOLS
--------------------------------------------------------------------------------

 Disable SindByte tools globally:
    opencode config set tools.sindbyte false

 Disable by pattern:
    opencode config set tools.sindbyte* false

 Re-enable:
    opencode config set tools.sindbyte true

 Per-agent control (disable global, enable for one agent):
    In opencode.json:
    {
      "tools": { "sindbyte*": false },
      "agent": {
        "my-trading-agent": {
          "tools": { "sindbyte*": true }
        }
      }
    }

--------------------------------------------------------------------------------
 8. HOW IQ TOOLS WORK (METHOD A ONLY)
--------------------------------------------------------------------------------
When you use an IQ model (e.g. IQTools_Full), SindByte runs your prompt
through an intelligence pipeline:

    - betterprompt    -- Improves your prompt automatically
    - chainofthought  -- Step-by-step reasoning
    - multivote       -- Asks multiple times, picks best answer
    - validate        -- Fact-checks the result
    - web_research    -- Searches the web for current info
    - scanner         -- Includes live market data

Default timeout: 3,600 seconds (1 hour). You can change this in the
SindByte configuration or per-request.

--------------------------------------------------------------------------------
 9. SWITCHING BETWEEN METHODS
--------------------------------------------------------------------------------

 To Method A (Endpoint / IQ Pipeline):
    opencode config set provider sindbyte-mcp
    opencode config set model sindbyte-mcp/LMDirect

 To Method B (MCP Server / Own AI):
    opencode config set provider lmstudio
    opencode config set model lmstudio/qwen3.6-35b-a3b

--------------------------------------------------------------------------------
 10. TROUBLESHOOTING
--------------------------------------------------------------------------------

  "Cannot connect" or "Connection refused"
    --> SindByte is not running. Start it before OpenCode.

  "Model not found" (Method A)
    --> Use exact aliases from Section 5. Check MCP_Server.log.

  Tools don't appear (Method B)
    --> Run: opencode mcp list
    --> Check that "sindbyte" is connected
    --> Verify tools are not disabled in config

  Answers take very long (Method A)
    --> IQ Tools are running. Switch to faster model:
        opencode config set model sindbyte-mcp/LMDirect
    --> Or reduce timeout in SindByte config.

  "Process has not exited"
    --> No default model set. Run one of the "Switch" commands above.

--------------------------------------------------------------------------------
 11. OTHER AI ASSISTANTS
--------------------------------------------------------------------------------

  KIMI CLI:
    set KIMI_BASE_URL=http://127.0.0.1:8091/v1
    set KIMI_API_KEY=sk-sindbyte-local
    kimi

  CLINE (VS Code):
    Provider: "OpenAI Compatible"
    Base URL: http://127.0.0.1:8091/v1
    API Key:  sk-sindbyte-local

  CONTINUE.DEV (VS Code):
    {
      "title": "SindByte Local",
      "provider": "openai",
      "model": "qwen2.5-coder-14b-instruct",
      "apiBase": "http://127.0.0.1:8091/v1",
      "apiKey": "sk-sindbyte-local"
    }

================================================================================
  END OF USER GUIDE
================================================================================
