GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(providers): register Atomic Chat as local OpenAI-compatible runti… · Twigpine/zero@79fa142

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • README.md
  • README_ZH.md
  • internal
    • cli
      • command_center.go
      • command_center_test.go
      • provider_adoption_test.go
      • provider_detect.go
      • provider_detect_test.go
      • provider_setup.go
      • provider_setup_test.go
      • setup_test.go
    • config
      • credentials_test.go
    • providercatalog
      • catalog.go
      • catalog_test.go
    • providermodelcatalog
      • catalog.go
    • provideronboarding
      • advice.go
      • advice_test.go
      • localruntime.go
      • localruntime_test.go
    • tui
      • provider_wizard.go
      • provider_wizard_atomic_test.go
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+7-3Lines changed: 7 additions & 3 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ zero exec --output-format stream-json < turns.jsonl
2626
## Why Zero
2727

2828
- **Use the model you want.** Bring OpenAI, Anthropic, Gemini, Groq, OpenRouter,
29-
DeepSeek, Mistral, xAI, Qwen, Kimi, GitHub Models, Ollama, LM Studio, or any
29+
DeepSeek, Mistral, xAI, Qwen, Kimi, GitHub Models, Ollama, LM Studio, Atomic Chat, or any
3030
OpenAI-/Anthropic-compatible endpoint.
3131
- **Stay in control.** File writes, shell commands, network access, and
3232
out-of-workspace writes go through Zero's permission and sandbox policy.
@@ -182,8 +182,12 @@ zero providers add custom-openai-compatible \
182182
--set-active
183183
```
184184

185-
For local models, run Ollama or LM Studio and then use `zero setup` or
186-
`zero providers detect`.
185+
For local models, run Ollama, LM Studio, or the [Atomic Chat](https://atomic.chat)
186+
desktop app, then use `zero setup` or `zero providers detect`. For Atomic Chat,
187+
load a model and enable its local OpenAI-compatible API (default
188+
`http://127.0.0.1:1337/v1`). Choose `atomic-chat-local`; detection includes the
189+
loaded model ID in the add command. If no usable ID is discovered, load a model
190+
and retry. Model IDs requiring shell-specific quoting use interactive setup.
187191

188192
## Daily Use
189193

Collapse file

‎README_ZH.md‎

Copy file name to clipboardExpand all lines: README_ZH.md
+6-2Lines changed: 6 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ zero exec --output-format stream-json < turns.jsonl
2323

2424
## 为什么选择 Zero
2525

26-
- **使用你想要的模型。** 支持 OpenAI、Anthropic、Gemini、Groq、OpenRouter、DeepSeek、Mistral、xAI、Qwen、Kimi、GitHub Models、Ollama、LM Studio,或任何 OpenAI/Anthropic 兼容端点。
26+
- **使用你想要的模型。** 支持 OpenAI、Anthropic、Gemini、Groq、OpenRouter、DeepSeek、Mistral、xAI、Qwen、Kimi、GitHub Models、Ollama、LM Studio、Atomic Chat,或任何 OpenAI/Anthropic 兼容端点。
2727
- **保持控制权。** 文件写入、Shell 命令、网络访问和工作区外写入都经过 Zero 的权限和沙箱策略。
2828
- **在终端中工作。** TUI 具有模型/提供商选择器、图片输入、斜杠命令、实时计划/工具渲染、回滚滚动、主题以及恢复/分叉支持。
2929
- **无 TUI 也能工作。** `zero exec` 可脚本化,支持文本/JSON/stream-JSON I/O、隔离的工作树、规范优先运行,以及用于 CI 的有意义的退出码。
@@ -114,7 +114,11 @@ export LONGCAT_API_KEY=...
114114
zero providers setup longcat --set-active
115115
```
116116

117-
对于本地模型,运行 Ollama 或 LM Studio,然后使用 `zero setup` 或 `zero providers detect`。
117+
对于本地模型,运行 Ollama、LM Studio 或 [Atomic Chat](https://atomic.chat) 桌面应用,
118+
然后使用 `zero setup` 或 `zero providers detect`。使用 Atomic Chat 时,请先加载模型并启用
119+
本地 OpenAI 兼容 API(默认地址为 `http://127.0.0.1:1337/v1`),再选择 `atomic-chat-local`。
120+
检测生成的添加命令会包含已加载的模型 ID;如果未发现可用的 ID,请加载模型后重试。
121+
对于需要特定 Shell 转义的模型 ID,请使用交互式设置。
118122

119123
## 日常使用
120124

Collapse file

‎internal/cli/command_center.go‎

Copy file name to clipboardExpand all lines: internal/cli/command_center.go
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,11 @@ func formatProviderCatalogLine(provider providerCatalogSummary) string {
407407
provider.RuntimeSupported,
408408
))
409409
if provider.RuntimeSupported {
410-
lines = append(lines, " setup: zero providers setup "+displayCLIValue(provider.ID, "unknown")+" --set-active")
410+
setup := " setup: zero providers setup " + displayCLIValue(provider.ID, "unknown") + " --set-active"
411+
if provider.ID == "atomic-chat-local" {
412+
setup = " setup: run zero setup to select a loaded model, or zero providers detect to get an add command"
413+
}
414+
lines = append(lines, setup)
411415
} else {
412416
lines = append(lines, " unsupported: "+displayCLIValue(provider.RuntimeUnsupportedReason, "unknown"))
413417
}
@@ -502,7 +506,7 @@ func writeProvidersHelp(w io.Writer) error {
502506
zero providers models [name] [flags]
503507
504508
Inspects resolved provider profiles and provider catalog descriptors without printing secrets.
505-
Detect probes for running local runtimes (Ollama, LM Studio) and prints adopt commands plus per-provider next steps.
509+
Detect probes for running local runtimes (Ollama, LM Studio, Atomic Chat) and prints adopt commands plus per-provider next steps.
506510
Models probes a provider's live model-listing endpoint (e.g. an OpenAI-compatible /v1/models) and lists the models it serves — including custom OpenAI-/Anthropic-compatible endpoints — so a self-hosted provider needs no per-model config.
507511
508512
Flags:
Collapse file

‎internal/cli/command_center_test.go‎

Copy file name to clipboardExpand all lines: internal/cli/command_center_test.go
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,3 +967,10 @@ func TestProvidersListMarksOAuthLoginProviders(t *testing.T) {
967967
t.Fatalf("list should render the oauth login state, got:\n%s", rendered)
968968
}
969969
}
970+
971+
func TestAtomicCatalogSetupRequiresLoadedModel(t *testing.T) {
972+
out := formatProviderCatalogLine(providerCatalogSummary{ID: "atomic-chat-local", RuntimeSupported: true})
973+
if strings.Contains(out, "zero providers setup atomic-chat-local --set-active") || !strings.Contains(out, "zero setup") {
974+
t.Fatalf("catalog advertises a failing setup command: %s", out)
975+
}
976+
}
Collapse file

‎internal/cli/provider_adoption_test.go‎

Copy file name to clipboard
+117Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
package cli
2+
3+
import (
4+
"context"
5+
"encoding/json"
6+
"fmt"
7+
"net/http"
8+
"net/http/httptest"
9+
"os"
10+
"os/exec"
11+
"path/filepath"
12+
"strings"
13+
"testing"
14+
"time"
15+
16+
"github.com/Gitlawb/zero/internal/provideronboarding"
17+
"mvdan.cc/sh/v3/shell"
18+
)
19+
20+
func TestLocalAdoptionSavesAndReloadsEligibleModel(t *testing.T) {
21+
const wantModel = "-loaded chat model"
22+
requests := make(chan string, 4)
23+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
24+
switch r.URL.Path {
25+
case "/v1/models":
26+
w.Header().Set("Content-Type", "application/json")
27+
_, _ = fmt.Fprintf(w, `{"data":[{"id":"text-embedding-local"},{"id":%q}]}`, wantModel)
28+
case "/v1/chat/completions":
29+
var body struct {
30+
Model string `json:"model"`
31+
}
32+
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
33+
t.Errorf("decode completion request: %v", err)
34+
w.WriteHeader(http.StatusBadRequest)
35+
return
36+
}
37+
if r.Header.Get("Authorization") != "" {
38+
t.Error("local adoption unexpectedly sent authorization")
39+
}
40+
select {
41+
case requests <- body.Model:
42+
default:
43+
t.Error("unexpected extra completion requests")
44+
}
45+
w.Header().Set("Content-Type", "text/event-stream")
46+
_, _ = fmt.Fprint(w, "data: {\"choices\":[{\"delta\":{\"content\":\"adoption ok\"},\"finish_reason\":\"stop\"}]}\n\ndata: [DONE]\n\n")
47+
default:
48+
w.WriteHeader(http.StatusNotFound)
49+
}
50+
}))
51+
defer server.Close()
52+
detected := provideronboarding.DetectLocalRuntimes(context.Background(), provideronboarding.LocalDetectOptions{
53+
HTTPClient: server.Client(),
54+
Candidates: []provideronboarding.LocalRuntime{{CatalogID: "atomic-chat-local", Name: "Atomic Chat Local", DefaultModel: "local-model", BaseURL: server.URL + "/v1"}},
55+
})
56+
if len(detected) != 1 {
57+
t.Fatalf("expected one detected runtime: %+v", detected)
58+
}
59+
args, err := shell.Fields(detected[0].SetupAction().Command, func(string) string { return "" })
60+
if err != nil || len(args) < 4 {
61+
t.Fatalf("invalid adoption command: args=%q err=%v", args, err)
62+
}
63+
root := t.TempDir()
64+
run := func(args ...string) string {
65+
t.Helper()
66+
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
67+
defer cancel()
68+
childArgs := append([]string{"-test.run=^TestLocalAdoptionCLIProcess$", "--"}, args...)
69+
cmd := exec.CommandContext(ctx, os.Args[0], childArgs...)
70+
cmd.Dir = root
71+
cmd.Env = []string{
72+
"ZERO_TEST_LOCAL_ADOPTION=1", "ZERO_CRED_STORAGE=encrypted-file",
73+
"HOME=" + root, "USERPROFILE=" + root,
74+
"XDG_CONFIG_HOME=" + filepath.Join(root, "config"),
75+
"XDG_CACHE_HOME=" + filepath.Join(root, "cache"),
76+
"XDG_STATE_HOME=" + filepath.Join(root, "state"),
77+
"APPDATA=" + filepath.Join(root, "config"),
78+
"LOCALAPPDATA=" + filepath.Join(root, "cache"),
79+
}
80+
for _, key := range []string{"PATH", "SystemRoot", "WINDIR", "TMPDIR", "TEMP", "TMP"} {
81+
if value, ok := os.LookupEnv(key); ok {
82+
cmd.Env = append(cmd.Env, key+"="+value)
83+
}
84+
}
85+
output, err := cmd.CombinedOutput()
86+
if err != nil {
87+
t.Fatalf("CLI %q failed: %v\n%s", args, err, output)
88+
}
89+
return string(output)
90+
}
91+
// The mock uses a random port; only override the endpoint, retaining all
92+
// generated arguments for the real add parser and persistence path.
93+
run(append(args[1:], "--base-url", server.URL+"/v1")...)
94+
if output := run("exec", "--cwd", root, "Reply with adoption ok"); !strings.Contains(output, "adoption ok") {
95+
t.Fatalf("completion output = %q", output)
96+
}
97+
select {
98+
case model := <-requests:
99+
if model != wantModel {
100+
t.Fatalf("fresh process sent model %q, want eligible model %q", model, wantModel)
101+
}
102+
default:
103+
t.Fatal("fresh process did not send a completion request")
104+
}
105+
}
106+
107+
func TestLocalAdoptionCLIProcess(t *testing.T) {
108+
if os.Getenv("ZERO_TEST_LOCAL_ADOPTION") != "1" {
109+
return
110+
}
111+
for i, arg := range os.Args {
112+
if arg == "--" {
113+
os.Exit(Run(os.Args[i+1:], os.Stdout, os.Stderr))
114+
}
115+
}
116+
t.Fatal("missing helper argument separator")
117+
}
Collapse file

‎internal/cli/provider_detect.go‎

Copy file name to clipboardExpand all lines: internal/cli/provider_detect.go
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type providerDetectReport struct {
4040
}
4141

4242
// runProvidersDetect probes the machine for running local, OpenAI-compatible
43-
// model runtimes (Ollama, LM Studio) and prints a no-key adopt command for each
43+
// model runtimes (Ollama, LM Studio, Atomic Chat) and prints a no-key adopt command for each
4444
// one it finds, followed by the next-step actions for every already-configured
4545
// provider. It is the onboarding-advice surface — "what can I do right now?" —
4646
// and never errors on a machine with nothing running locally (it just reports an
@@ -146,6 +146,8 @@ func formatProviderDetectReport(report providerDetectReport) string {
146146
}
147147
if command := strings.TrimSpace(runtime.Action.Command); command != "" {
148148
lines = append(lines, " "+runtime.Action.Label+": "+command)
149+
} else if detail := strings.TrimSpace(runtime.Action.Detail); detail != "" {
150+
lines = append(lines, " "+runtime.Action.Label+": "+detail)
149151
}
150152
}
151153

Collapse file

‎internal/cli/provider_detect_test.go‎

Copy file name to clipboardExpand all lines: internal/cli/provider_detect_test.go
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,13 @@ func TestRunProvidersDetectJSONNoRuntimesActiveProvider(t *testing.T) {
105105
t.Fatalf("expected only a Check action for an active keyed provider, got %#v", payload.Providers[0].Actions)
106106
}
107107
}
108+
109+
func TestProviderDetectShowsGuidanceWithoutCommand(t *testing.T) {
110+
for _, models := range [][]string{nil, {"local-model"}, {"x&calc"}} {
111+
runtime := provideronboarding.DetectedLocalRuntime{LocalRuntime: provideronboarding.LocalRuntime{CatalogID: "atomic-chat-local", Name: "Atomic Chat Local", DefaultModel: "local-model"}, Models: models}
112+
out := formatProviderDetectReport(buildProviderDetectReport(config.ResolvedConfig{}, []provideronboarding.DetectedLocalRuntime{runtime}))
113+
if strings.Contains(out, "providers add") || !strings.Contains(out, runtime.SetupAction().Detail) {
114+
t.Fatalf("missing actionable guidance: %s", out)
115+
}
116+
}
117+
}
Collapse file

‎internal/cli/provider_setup.go‎

Copy file name to clipboardExpand all lines: internal/cli/provider_setup.go
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,14 @@ func providerProfileForAdd(options providerAddOptions) (config.ProviderProfile,
434434
catalogHeaders = aimlapi.WithResolvedPartnerHeader(catalogHeaders)
435435
}
436436
}
437+
// Discovery fallback can pass the nonempty catalog placeholder through
438+
// either CLI setup path. Never persist it as an Atomic Chat model.
439+
if descriptor.ID == "atomic-chat-local" {
440+
model := strings.TrimSpace(options.model)
441+
if model == "" || model == "local-model" {
442+
return config.ProviderProfile{}, fmt.Errorf("provider %q serves a locally loaded model; pass --model <id> (run `zero providers detect` to see the served model)", descriptor.ID)
443+
}
444+
}
437445
profile := config.ProviderProfile{
438446
Name: name,
439447
ProviderKind: providerKindForDescriptor(descriptor),
Collapse file

‎internal/cli/provider_setup_test.go‎

Copy file name to clipboardExpand all lines: internal/cli/provider_setup_test.go
+58Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package cli
22

33
import (
4+
"strings"
45
"testing"
56

67
"github.com/Gitlawb/zero/internal/config"
8+
"github.com/Gitlawb/zero/internal/provideronboarding"
9+
"mvdan.cc/sh/v3/shell"
710
)
811

912
// Regression for issue #555's follow-up: `zero providers check` must not
@@ -66,3 +69,58 @@ func TestValidateProviderRuntimeReadyCustomEndpoint(t *testing.T) {
6669
})
6770
}
6871
}
72+
73+
// atomic-chat-local without --model would persist the catalog placeholder
74+
// "local-model", which the Atomic Chat server never serves, so the first
75+
// completion fails. Adding it must require a real model instead.
76+
func TestProviderProfileForAddRequiresModelForAtomicChatLocal(t *testing.T) {
77+
if _, err := providerProfileForAdd(providerAddOptions{catalogID: "atomic-chat-local"}); err == nil {
78+
t.Fatalf("providerProfileForAdd(atomic-chat-local, no --model) = nil error, want a require-model error")
79+
} else if !strings.Contains(err.Error(), "--model") {
80+
t.Fatalf("error should tell the user to pass --model, got %v", err)
81+
}
82+
83+
// The interactive wizards and the no-id detect fallback resolve the model to
84+
// the catalog DefaultModel and pass it through as a non-empty value, so the
85+
// placeholder itself must be rejected, not just an empty --model.
86+
if _, err := providerProfileForAdd(providerAddOptions{catalogID: "atomic-chat-local", model: "local-model"}); err == nil {
87+
t.Fatalf("providerProfileForAdd(atomic-chat-local, --model local-model) = nil error, want reject of the catalog placeholder")
88+
}
89+
90+
profile, err := providerProfileForAdd(providerAddOptions{catalogID: "atomic-chat-local", model: "unsloth/gemma-4-E2B-it-GGUF"})
91+
if err != nil {
92+
t.Fatalf("providerProfileForAdd(atomic-chat-local, --model) returned error: %v", err)
93+
}
94+
if profile.Model != "unsloth/gemma-4-E2B-it-GGUF" {
95+
t.Fatalf("profile.Model = %q, want the explicit model", profile.Model)
96+
}
97+
if profile.Model == "local-model" {
98+
t.Fatalf("profile persisted the catalog placeholder")
99+
}
100+
}
101+
102+
func TestDetectedModelActionSurvivesAddParser(t *testing.T) {
103+
for _, catalogID := range []string{"atomic-chat-local", "lmstudio", "ollama"} {
104+
for _, modelID := range []string{"-loaded-model", "--set-active", "--model", "-loaded model", "ordinary/model", "model with spaces"} {
105+
t.Run(catalogID+"/"+modelID, func(t *testing.T) {
106+
detected := provideronboarding.DetectedLocalRuntime{
107+
LocalRuntime: provideronboarding.LocalRuntime{CatalogID: catalogID, Name: "Local Runtime", DefaultModel: "local-model"},
108+
Models: []string{modelID},
109+
}
110+
command := detected.SetupAction().Command
111+
args, err := shell.Fields(command, func(string) string { return "" })
112+
if err != nil || len(args) < 4 {
113+
t.Fatalf("invalid adoption command %q: %v", command, err)
114+
}
115+
options, help, err := parseProviderAddArgs(args[3:])
116+
if err != nil || help {
117+
t.Fatalf("generated adoption command rejected by add parser: %q: %v", command, err)
118+
}
119+
profile, err := providerProfileForAdd(options)
120+
if err != nil || profile.Model != modelID || !options.setActive || profile.Name != "Local Runtime" {
121+
t.Fatalf("adoption changed model or options: model=%q name=%q active=%v err=%v", profile.Model, profile.Name, options.setActive, err)
122+
}
123+
})
124+
}
125+
}
126+
}
Collapse file

‎internal/cli/setup_test.go‎

Copy file name to clipboardExpand all lines: internal/cli/setup_test.go
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,3 +367,14 @@ func TestVerifySetupProviderDistinguishesMissingFromRejectedKey(t *testing.T) {
367367
t.Fatal("a keyless local provider should still be probed")
368368
}
369369
}
370+
371+
func TestSaveSetupProviderRejectsAtomicPlaceholderBeforeConfigAccess(t *testing.T) {
372+
for _, model := range []string{"", "local-model", " local-model "} {
373+
accessed := false
374+
deps := appDeps{userConfigPath: func() (string, error) { accessed = true; return filepath.Join(t.TempDir(), "config.json"), nil }}
375+
_, err := saveSetupProvider(deps, tui.SetupSelection{CatalogID: "atomic-chat-local", Model: model}, setupSaveOptions{})
376+
if err == nil || !strings.Contains(err.Error(), "--model") || accessed {
377+
t.Fatalf("invalid model %q reached config access: accessed=%v err=%v", model, accessed, err)
378+
}
379+
}
380+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.