JSPM

  • Created
  • Published
  • Downloads 160
  • Score
    100M100P100Q133823F

Package Exports

  • kob-cli

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 CLI

A beautiful, fully agentic AI coding assistant for your terminal.

πŸ‡ΉπŸ‡­ Made in Thailand Β· v2.0.56 Β· MIT


Read your project, write your code, run your tests, fix your bugs β€” all without leaving the terminal. No editor plugin. No background daemon. Just kob.


npm node typescript license kob


✨ Why KOB CLI

Most AI chat tools are passive: you paste code, you get text back. KOB CLI is active β€” it understands your project, decides which tools to call, and shows you exactly what it changed, with diffs and undo support.

It is designed to feel like a disciplined pair programmer inside your terminal:

  • πŸ” Reads first β€” the engine injects your file tree into context, so the model knows what you have before suggesting changes.
  • πŸ›  Acts, not just answers β€” read_file, str_replace, write_file, and shell commands are first-class tool calls, not hidden magic.
  • 🎨 Colored diffs, visible progress β€” every read, replacement, file write, and command run is reported inline as it happens.
  • ⚑ Interactive slash commands β€” real-time autocomplete for commands like /models, /undo, and /config directly in the prompt.
  • ↩️ /undo is real undo β€” every file mutation in the last turn can be reverted, no Git ceremony required.
  • πŸ›‘ Safe by default β€” destructive shell commands are flagged in red and require explicit Y confirmation.
  • πŸ’Ύ Remembers your project β€” per-project session history means reopening kob in the same repo picks up where you left off.
  • 🌍 Bilingual β€” status banners, help text, and prompts in English and ΰΉ„ΰΈ—ΰΈ’.

πŸš€ Quick start

# 1. Install globally from npm
npm i -g kob-cli

# 2. Configure β€” the program creates a global config file for you
kob config
#   API key : kob_xxx:token         (paste from https://www.kob-ai.dev)
#   Model   : deepseek/deepseek-v4-flash   (or pick from /models)
#   Base URL: https://www.kob-ai.dev       (default, just press Enter)

# 3. Launch the REPL
kob

That's it. No git clone, no bun install, no manual config file editing.

Inside the REPL, type a plain request β€” the agent does the rest.

❯ add a healthcheck endpoint to src/server.ts and write a test

Press Tab to switch between Ask, Plan, and Code modes. Press R to retry if the network blips. Type ? to see all key bindings.


πŸ“¦ Installation

npm i -g kob-cli
kob --version            # smoke test β†’ e.g. 2.0.3

Works on macOS, Linux, and Windows. The kob binary is added to your PATH automatically.

From source (for contributors)

git clone https://github.com/thekaroe-thailand/kobcli.git
cd kobcli
bun install
bun run dev               # live REPL against the source

If you want the local checkout to be the global kob:

bun link                  # exposes this checkout as `kob` on your PATH
kob --version             # should match package.json

bun link creates a symlink in your global bin pointing at this checkout, so any edit here is immediately reflected when you run kob.

Sanity check (the same checks the CI runs):

bun run typecheck          # tsc --noEmit, no compile
bun run src/index.ts --version    # should print the version from package.json
bun run src/index.ts ask "hi"     # should hit the API and return text

If any of those three error out, the checkout is broken β€” open an issue.

Update

You can easily upgrade KOB CLI to the latest version directly using:

kob upgrade

The built-in upgrader shows a live progress bar and suppresses routine npm warning noise such as funding notices and cleanup warnings. If npm returns a real error, KOB still prints it.

Or manually via npm:

npm update -g kob-cli

Uninstall

npm uninstall -g kob-cli
rm -rf ~/.kob-cli            # wipes persisted sessions

βš™οΈ Configuration

You do not need to edit config by hand. Run kob config (or /config from inside the REPL) and the program creates a single global file for you at ~/.kob-cli/config.env, pre-filled with the values you entered.

kob config

  β”Œ  KOB CLI configuration
  β”‚
  β—‡  API key (kob_xxx:token) β€” leave blank to keep current
  β”‚  kob_xxxxxxxxxxxxxxxxxxxxxxxx
  β”‚
  β—‡  Default model id
  β”‚  deepseek/deepseek-v4-flash
  β”‚
  β—‡  API base URL
  β”‚  https://www.kob-ai.dev
  β”‚
  β””  βœ“ Configuration saved

The form writes one global config file shared across projects. It looks like this:

KOB_API_BASE_URL=https://www.kob-ai.dev
KOB_API_KEY=kob_your_api_key_here
KOB_MODEL_ID=deepseek/deepseek-v4-flash
KOB_MAX_TOKENS=16384
KOB_AUTO_APPROVE_READONLY=true

Config keys

Key Required Default Description
KOB_API_KEY βœ… β€” Format: kob_xxx or kob_xxx:token
KOB_API_BASE_URL ❌ https://www.kob-ai.dev OpenAI-compatible endpoint
KOB_MODEL_ID ❌ deepseek/deepseek-v4-flash provider/model form
KOB_MAX_TOKENS ❌ 16384 Output cap per response
KOB_AUTO_APPROVE_READONLY ❌ true Skip confirm on read-only shell commands

Switching config later

The same form is available at any time β€” inside the REPL just type /config:

❯ /config

Edit one field, press Enter, the file is rewritten and the REPL reloads. Your session and history are preserved.


πŸ§‘β€πŸ’» Usage

CLI commands

kob                       # launch interactive REPL (default)
kob chat                  # same as above, explicit
kob ask "…"               # one-shot question, no REPL
kob ask "…" -m gpt-4o     # override model for one request
kob models                # list available models from backend
kob config                # edit global KOB settings
kob --version             # show version
kob --help                # full CLI help

Modes

Press Tab to cycle, or 1/2/3 to jump:

Key Mode Color Purpose
1 Ask 🩡 blue Read-only Q&A about your code
2 Plan 🩷 pink Design a solution, no file changes
3 Code 🟒 green Build / edit autonomously β€” the only mode that mutates your project

The mode colours the system prompt, the rail around the conversation, and the prompt icon. Code is the default.

Slash commands

Type / to open the autocomplete menu, or type the command directly:

Command What it does
/ask Switch to Ask mode
/plan Switch to Plan mode
/code Switch to Code mode
/models Pick a model from the live backend catalog
/config Edit global KOB settings
/git Branch + dirty file count + first 30 lines of git status
/diff Show the file changes from the last turn
/undo Revert every file mutation from the last turn
/init Scaffold an AGENTS.md (file tree + commands)
/tokens Show session input/output token totals
/find <text> Search text across the project, scoped to the current directory
/replace <a> <b> Replace <a> with <b> in one or all files
/open Open a file and read it with line numbers
/project:create Create a new project bookmark (prompts for name and path)
/project:list List saved projects and switch to one (changes cwd)
/project:delete Remove a project bookmark from the list
/clear Clear the in-memory session
/reset Clear + reload model from config
/help Show all slash commands
/exit Quit (/quit works too)

Direct shell commands

Any input starting with $ or > is run as a shell command in your project root:

❯ $ npm test
βœ“ $ npm test
    > my-project@1.0.0 test
    > jest
    PASS  src/sum.test.ts
  exit 0 Β· 4.1s

Read-only commands (ls, cat, git status, …) run with auto-approval when KOB_AUTO_APPROVE_READONLY=true. Mutating ones ask once. Dangerous ones (rm -rf, git reset --hard, curl … | sh, …) are flagged in red and always require explicit Y.

Special keys

Key Action
Tab Cycle mode (Ask β†’ Plan β†’ Code)
1/2/3 Jump to mode
↑ / ↓ Walk through your last 100 prompts
Esc Abort the current generation (during streaming)
Ctrl+C Quit
Ctrl+V Paste an image (vision-capable models only)
y Copy the last assistant response to your clipboard
R When shown "Press R to retry" β€” re-send the last request

🧠 How the agent works

The runtime is a small, explicit pipeline β€” no hidden orchestration, no opaque plugin system.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  USER INPUT                                                 β”‚
β”‚  "add a healthcheck endpoint to src/server.ts"             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  ENGINE  (src/core/engine.ts)                               β”‚
β”‚  β€’ load session history (scoped to cwd)                     β”‚
β”‚  β€’ inject file tree into the system prompt                  β”‚
β”‚  β€’ send to KOB AI /api/v2/chat/completions (streaming)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  PARSER  (src/tools/parser.ts)                              β”‚
β”‚  β€’ extract ```ts:path fenced blocks β†’ write_file            β”‚
β”‚  β€’ extract ```bash fenced blocks   β†’ run_shell              β”‚
β”‚  β€’ extract tool_call JSON          β†’ str_replace / read_fileβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  EXECUTOR                                                   β”‚
β”‚  β€’ sandbox path: must be inside project root                β”‚
β”‚  β€’ show inline: read Β· str_replace Β· write Β· command output β”‚
β”‚  β€’ destructive commands β†’ red confirmation banner           β”‚
β”‚  β€’ every mutation pushed to the undo stack                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  RENDER  (src/ui/render.ts)                                 β”‚
β”‚  β€’ colored diffs of changed files                           β”‚
β”‚  β€’ command output (first 8 lines + exit code + duration)    β”‚
β”‚  β€’ markdown assistant reply with syntax tint                β”‚
β”‚  β€’ "βœ“ Done" round close                                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

A single user request can produce multiple rounds: the model reads a file, decides to edit, applies a str_replace, runs a test, sees the failure, and fixes it β€” all inside one turn.

Network resilience

  • Up to 5 automatic retries on transient failures (DNS, TCP, TLS, fetch aborted) with exponential backoff + jitter (0.5s β†’ 1s β†’ 2s β†’ 4s, capped at 5s).
  • HTTP 4xx/5xx are not retried β€” they bubble up immediately with the server's message.
  • User aborts (Esc) are not retried β€” they propagate instantly.
  • On final failure the REPL prints Press R to retry, any other key to continue. β€” one keypress, no retyping.

πŸ—‚ Project layout

src/
β”œβ”€β”€ index.ts              CLI entry + non-interactive subcommands
β”œβ”€β”€ repl.ts               interactive REPL loop, command routing, Esc interrupt
β”œβ”€β”€ core/
β”‚   β”œβ”€β”€ api.ts            streaming OpenAI-compatible client + retry logic
β”‚   β”œβ”€β”€ engine.ts         agentic multi-round loop
β”‚   β”œβ”€β”€ modes.ts          chat / ask / plan / code prompts
β”‚   β”œβ”€β”€ config.ts         env loading + validation
β”‚   β”œβ”€β”€ env-file.ts       read/write ~/.kob-cli/config.env (comment-preserving)
β”‚   β”œβ”€β”€ history.ts        per-project session persistence
β”‚   └── types.ts
β”œβ”€β”€ tools/
β”‚   β”œβ”€β”€ parser.ts         extract file blocks, tool calls, shell commands
β”‚   β”œβ”€β”€ files.ts          sandboxed read/write/str_replace + file tree
β”‚   β”œβ”€β”€ shell.ts          run commands, read-only & danger classifiers
β”‚   β”œβ”€β”€ git.ts            branch / dirty / ahead-behind
β”‚   β”œβ”€β”€ diff.ts           LCS line diff + compact hunks
β”‚   └── clipboard.ts
β”œβ”€β”€ ui/
β”‚   β”œβ”€β”€ banner.ts         the KOB header
β”‚   β”œβ”€β”€ gradient.ts       dependency-free hex gradient
β”‚   β”œβ”€β”€ markdown.ts       Markdown β†’ ANSI with syntax tint
β”‚   β”œβ”€β”€ render.ts         status bar, diffs, help, results
β”‚   β”œβ”€β”€ spinner.ts        interleaving single-line spinner
β”‚   β”œβ”€β”€ prompts.ts        model picker, config form, approvals
β”‚   └── theme.ts          palette + helpers
└── scripts/
    └── release.ts        bump + build + publish + push + tag

πŸ›  Development

bun run dev          # bun run src/index.ts β€” live REPL
bun run typecheck    # tsc --noEmit, no compile
bun run build        # compile to a single native binary
bun run build:only   # bun build src/index.ts --compile --outfile kob-cli

Releasing a new version

The release script (src/scripts/release.ts) bumps package.json, runs the typecheck, rebuilds the binary, and commits in one step:

bun run release:patch    # 2.0.0 β†’ 2.0.1
bun run release:minor    # 2.0.0 β†’ 2.1.0
bun run release:major    # 2.0.0 β†’ 3.0.0

Style

  • TypeScript, strict, ESM modules
  • async/await everywhere β€” no .then chains
  • single responsibility per file under src/tools/, src/ui/
  • prefer editing existing files; only create new ones when there is no good host
  • run bun run typecheck before opening a PR

πŸ”Œ Backend contract

KOB CLI speaks the OpenAI streaming protocol to KOB_API_BASE_URL. Minimum the backend must support:

Endpoint Method Purpose
/api/v2/chat/completions POST streaming chat (SSE)
/api/ai/models POST model catalog (primary)
/api/models POST model catalog (fallback)
/api/v2/models GET model catalog (fallback)

Authentication is a Bearer token. The KobApiClient (see src/core/api.ts) tries the catalog endpoints in order, so older backends stay compatible.


πŸ—Ί Roadmap

In priority order, not promised:

  • Conversation export to Markdown / JSON
  • Multi-profile .env switching
  • Plugin hooks (pre/post tool execution)
  • Background "watch this file" agents
  • In-terminal Markdown preview pane
  • Built-in token cost estimator

Out of scope, intentionally: editor plugin, GUI client, global cross-project memory store.


πŸ› Troubleshooting

Connection failed. Please check your network and try again. The backend was unreachable for 5 retries. Check KOB_API_BASE_URL, your network, or just press R to retry.

This model does not support the requested operation. You tried to paste an image into a text-only model, or called a vision tool on a model that has no vl in its id. Run /models to switch.

No API key configured. Exiting. Run kob config and paste your kob_xxx:token key.

βœ— Permission denied on shell commands Mutating shell commands require an explicit Y at the prompt. Destructive ones are flagged in red β€” type Y only if you mean it.


🀝 Contributing

Issues and PRs are welcome. Please read the design log under docs/ first β€” most architectural questions are answered there. The codebase is small enough that you can read it in an afternoon.


πŸ“„ License

MIT Β· Β© Kob AI Β· www.kob-ai.dev


ΰΈ–ΰΉ‰ΰΈ²ΰΈŠΰΈ­ΰΈš ฝากกด ⭐ ΰΈ—ΰΈ΅ΰΉˆ GitHub ΰΉƒΰΈ«ΰΉ‰ΰΈ”ΰΉ‰ΰΈ§ΰΈ’ΰΈ™ΰΈ°ΰΈ„ΰΈ£ΰΈ±ΰΈš πŸ‡ΉπŸ‡­

If you like it, drop a ⭐ on GitHub.