Skip to content

Add Atomic Chat as a first-class local provider.#10555

Merged
johnnyeric merged 19 commits into
Kilo-Org:mainfrom
yanalialiuk:feat/atomic-chat-local-provider
Jun 4, 2026
Merged

Add Atomic Chat as a first-class local provider.#10555
johnnyeric merged 19 commits into
Kilo-Org:mainfrom
yanalialiuk:feat/atomic-chat-local-provider

Conversation

@yanalialiuk

@yanalialiuk yanalialiuk commented May 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Ship the Atomic Chat plugin with auto-discovery on localhost:1337, register the provider in models.dev fixtures, and document setup for VS Code and CLI.

Context

Atomic Chat runs local models and exposes an OpenAI-compatible API at http://127.0.0.1:1337/v1 (alternate port 1338). Kilo Code already supports local backends like LM Studio via @ai-sdk/openai-compatible, but users had to configure baseURL and model IDs manually, and Atomic Chat did not appear as a first-class provider with discovery or loaded-model checks.

This PR adds Atomic Chat as a built-in local provider: default plugin, catalog entry, documentation, icon, and VS Code migration mapping—so users can pick Atomic Chat in the UI and get models populated automatically when the app is running.

Implementation

@kilocode/plugin-atomic-chat (new package)

  • Auto-discovery: If provider.atomic-chat.options.baseURL is unset or still the default origin (http://127.0.0.1:1337), probe ports 1337 and 1338 with a health check, then call GET /v1/models.
  • Config hooks: Merge discovered models into provider.atomic-chat, set options.baseURL, and show success/error toasts.
  • chat.params hook: Validate the selected model is loaded (with cache/retry) before sending a request; surface a clear error if not.
  • 12 Vitest tests covering discovery, config enhancement, and validation paths.

Default plugin registration

  • atomic-chat-feature.ts — resolve and dedupe @kilocode/plugin-atomic-chat.
  • KilocodeDefaultPlugins — append the plugin alongside the indexing plugin (same builtin-origin pattern).

Catalog, UI, migration

  • Add atomic-chat to packages/opencode/test/tool/fixtures/models-api.json (@ai-sdk/openai-compatible, env ATOMIC_CHAT_API_KEY, default API http://127.0.0.1:1337/v1).
  • Provider icon + sprite; legacy migration atomicChatatomic-chat.
  • Docs: pages/ai-providers/atomic-chat.md, nav, and local-models page (Atomic Chat listed first under self-hosted).

Notes for reviewers

  • models-snapshot.js remains gitignored; the fixture is the source of truth for tests (regenerate locally via packages/opencode/script/generate.ts if needed).
  • Fixture models are placeholders; runtime discovery from the live API is authoritative when the plugin runs.
  • Optional follow-up: upstream atomic-chat on models.dev for live catalog fetches outside the bundled snapshot path.

How to Test

Prerequisites

  1. Install Atomic Chat and enable the local API (default port 1337).
  2. Load a model in the app.
  3. Confirm the API responds:
curl http://127.0.0.1:1337/v1/models

Automated

cd packages/plugin-atomic-chat && bun test
cd packages/opencode && bun test test/kilocode/config/atomic-chat-default-plugin.test.ts

Manual — VS Code

-Build/run this branch of the Kilo Code extension.
-Open Settings → Providers → Atomic Chat.
-Confirm models appear (from discovery) and chat works with a loaded model id from /v1/models.
-Stop or unload the model in Atomic Chat and retry chat — expect a validation error or toast.

Manual — CLI

In ~/.config/kilo/kilo.jsonc (or ./kilo.jsonc):

{
  "provider": {
    "atomic-chat": {
      "options": {
        "baseURL": "http://127.0.0.1:1337/v1"
      }
    }
  },
  "model": "atomic-chat/<id-from-v1-models>"
}

Run the Kilo CLI; confirm the default plugin discovers the server without manually adding @kilocode/plugin-atomic-chat.

Edge cases

Custom baseURL (non-default host/port): auto-probe should not override user config.
Atomic Chat on port 1338: should be detected when 1337 is down.

Comment thread packages/plugin-atomic-chat/src/plugin/chat-params-hook.ts Outdated
Comment thread packages/plugin-atomic-chat/src/plugin/chat-params-hook.ts Outdated
Comment thread packages/plugin-atomic-chat/src/plugin/enhance-config.ts Outdated
Comment thread packages/plugin-atomic-chat/src/plugin/enhance-config.ts Outdated
Comment thread packages/plugin-atomic-chat/src/plugin/config-hook.ts Outdated
Comment thread packages/plugin-atomic-chat/src/plugin/config-hook.ts Outdated
Comment thread packages/plugin-atomic-chat/src/cache/model-status-cache.ts Outdated
Comment thread packages/plugin-atomic-chat/src/utils/atomic-chat-api.ts Outdated
Comment thread packages/plugin-atomic-chat/src/utils/index.ts
@kilo-code-bot

kilo-code-bot Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/plugin-atomic-chat/src/utils/validation/validate-config.ts 17 validateConfig silently mutates the config object (sets atomic.npm, atomic.name, atomic.options) — side-effectful validation is surprising; move defaults to enhanceConfig or document/rename
Resolved since last review
  • CRITICAL: Broken not_found branch in categorizeError — two nested ifs with no return and a bare labeled object expression — replaced with a single, correct multi-line condition and a proper return statement
  • WARNING: retryWithBackoff retrying against stale model status cache — fixed via validationAttempt counter + forceRefresh on retry
  • WARNING: Two separate ModelStatusCache singletons in chat-params-hook and enhance-config — fixed by introducing shared-model-status-cache.ts
  • WARNING: enhanceConfig / getModels making separate health + discovery calls — fixed by deduplicating into a single fetchModelsEndpoint call
  • WARNING: fetchModelsDirect silently returning [] on non-OK responses — now throws on non-success status
  • WARNING: Promise.race timeout in config-hook leaving dangling promises — replaced with AbortController + AbortSignal threaded through enhanceConfig
  • SUGGESTION: Hard-coded port 1337 probe — now probing both 1337 and 1338 from ATOMIC_CHAT_PROBE_PORTS
  • WARNING: kilocode_change annotations were too broad in dialog-provider.tsx — narrowed to inline markers
Files Reviewed (incremental — 1 file)
  • packages/plugin-atomic-chat/src/utils/index.ts — ✅ CRITICAL resolved (not_found branch now correctly structured with return)

Fix these issues in Kilo Cloud


Reviewed by claude-4.6-sonnet-20260217 · 292,328 tokens

Review guidance: REVIEW.md from base branch main

@yanalialiuk yanalialiuk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

@yanalialiuk yanalialiuk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

@yanalialiuk yanalialiuk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Comment thread packages/kilo-vscode/src/legacy-migration/provider-mapping.ts Outdated
Comment thread packages/plugin-atomic-chat/src/plugin/enhance-config.ts Outdated
Comment thread packages/plugin-atomic-chat/src/utils/should-probe-atomic-chat.ts Outdated
Comment thread packages/plugin-atomic-chat/src/utils/should-probe-atomic-chat.ts Outdated
@yanalialiuk yanalialiuk force-pushed the feat/atomic-chat-local-provider branch from 169fcf6 to 3858240 Compare June 3, 2026 10:44
Comment thread packages/kilo-docs/pages/automate/extending/local-models.md
Comment thread packages/opencode/src/cli/cmd/tui/component/dialog-provider.tsx Outdated
@yanalialiuk yanalialiuk force-pushed the feat/atomic-chat-local-provider branch from f18a700 to 1844b8b Compare June 4, 2026 10:35
Comment thread packages/plugin-atomic-chat/src/plugin/enhance-config.ts Outdated
Comment thread packages/plugin-atomic-chat/src/plugin/enhance-config.ts Outdated
Comment thread packages/kilo-vscode/webview-ui/src/components/settings/ProviderConnectDialog.tsx Outdated
try {
const { ok } = await fetchModelsEndpoint(baseURL)
return ok
} catch {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Empty catch block silently swallows errors — violates style guide

The style guide requires that catch blocks never be empty. At minimum, bind the error and log it so failures are visible:

} catch (err) {
  // network/timeout error — treat as unhealthy
  return false
}

Same applies to the analogous blocks in discoverAtomicChatModels (line 61) and autoDetectAtomicChat (line 82).

Comment thread packages/plugin-atomic-chat/src/plugin/enhance-config.ts
@yanalialiuk yanalialiuk force-pushed the feat/atomic-chat-local-provider branch from 2fcc7fe to 4d79233 Compare June 4, 2026 10:56
Comment thread packages/plugin-atomic-chat/src/plugin/chat-params-hook.ts
Comment thread packages/plugin-atomic-chat/src/utils/validation/validate-config.ts
yanalialiuk and others added 12 commits June 4, 2026 14:22
Ship the atomic-chat plugin with auto-discovery on localhost:1337, register the provider in models.dev fixtures, and document setup for VS Code and CLI.

Co-authored-by: Cursor <cursoragent@cursor.com>
Removed atomicChat provider mapping from legacy migration.
Replace the embedded raster icon with a currentColor SVG symbol so it matches provider icon styling and inherits UI color consistently.

Co-authored-by: Cursor <cursoragent@cursor.com>
Load the atomic-chat plugin despite named constant exports, register local-server auth in the plugin, and let CLI and VS Code connect with an empty key on localhost.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: kilo-code-bot[bot] <240665456+kilo-code-bot[bot]@users.noreply.github.com>
Drop the modelID check (never equals provider key) and the duplicate providerID branch.

Co-authored-by: Cursor <cursoragent@cursor.com>
Restore atomic-chat in default-plugins after main merge, add missing sidebar locale keys, and annotate shared upstream diffs.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Reorder local-models providers per maintainer feedback; use inline kilocode_change markers in dialog-provider. Share ModelStatusCache, fix config discovery abort/timeout, throw on fetch failure, and resolve bot review warnings.

Co-authored-by: Cursor <cursoragent@cursor.com>
Restore useBindings instead of useKeyboard so shared-file diff stays minimal and passes annotation checks.

Co-authored-by: Cursor <cursoragent@cursor.com>
…erConnectDialog.tsx

Co-authored-by: kilo-code-bot[bot] <240665456+kilo-code-bot[bot]@users.noreply.github.com>
yanalialiuk and others added 4 commits June 4, 2026 14:22
Use a single shared models endpoint request in enhanceConfig instead of separate health and discovery calls.

Co-authored-by: Cursor <cursoragent@cursor.com>
Export ATOMIC_CHAT_PROVIDER_KEY from local-providers for the webview, log cache warm failures, and throw on network errors in fetchModelsEndpoint.

Co-authored-by: Cursor <cursoragent@cursor.com>
Reuse auto-detect model list to avoid duplicate /v1/models calls, wire AbortSignal into fetch, replace silent catches with logging, and only surface validation errors in chat.params.

Co-authored-by: Cursor <cursoragent@cursor.com>
Bypass the 15s model list cache after the first failed attempt so retryWithBackoff can observe newly loaded models.

Co-authored-by: Cursor <cursoragent@cursor.com>
@yanalialiuk yanalialiuk force-pushed the feat/atomic-chat-local-provider branch from 31eef5f to bc29b1e Compare June 4, 2026 11:22
Comment thread packages/plugin-atomic-chat/src/utils/index.ts
Co-authored-by: kilo-code-bot[bot] <240665456+kilo-code-bot[bot]@users.noreply.github.com>
Comment thread packages/plugin-atomic-chat/src/utils/index.ts Outdated
Restore return statement and map "not loaded" validation errors to not_found after bot commit broke the if block.

Co-authored-by: Cursor <cursoragent@cursor.com>
@johnnyeric johnnyeric merged commit 2d10946 into Kilo-Org:main Jun 4, 2026
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants