diff --git a/README.md b/README.md index f55ad15..7eff38c 100644 --- a/README.md +++ b/README.md @@ -41,17 +41,17 @@ PATH, collisions, and links, and says what to fix. ``: the letter picks a model from `[models]` in your config, the digit 1–5 picks effort low/medium/high/xhigh/max. Letter alone = model only. Built-in letters: `o` opus, `s` sonnet, `f` fable, -`h` haiku (haiku takes no effort digit — the CLI would silently -downgrade it, so clau errors instead). The digit ladder is itself -config: an `[efforts]` table remaps digits `1`–`9` to `--effort` -values, replacing the default five. +`h` haiku. The digit ladder is itself config: an `[efforts]` table +remaps digits `1`–`9` to `--effort` values, replacing the default +five. Add a model in one line — `g = "glm-5.2"` — and `g`, `g1`…`g5` all resolve (re-run `clau link` and the commands `cg`, `cg1`…`cg5` exist -too). A model that shouldn't take effort digits opts out with the -table form — `k = { model = "kimi", efforts = false }` — and gets -haiku's guard. One line is enough when your backend serves the -model; to aim a shortcut at a different backend, use a profile — see +too). A model without effort support opts out with the table form — +`k = { model = "kimi", efforts = false }` — and clau rejects its +digits instead of letting Claude Code drop the effort silently. One +line is enough when your backend serves the model; to aim a shortcut +at a different backend, use a profile — see [Other backends](#other-backends). ## Profiles diff --git a/commands.go b/commands.go index 3d722af..be690e4 100644 --- a/commands.go +++ b/commands.go @@ -496,11 +496,14 @@ const starterConfig = `# clau configuration — https://github.com/usmanbashir/c o = "opus" s = "sonnet" f = "fable" -h = { model = "haiku", efforts = false } +h = "haiku" # Add your own — one line yields , 1..5 and, after # "clau link", their commands. The model must be one your backend # serves; for another backend use a profile (see below). #g = "glm-5.2" +# A model without effort support opts out of the digits — clau then +# rejects k1..k5 rather than let claude drop the effort silently: +#k = { model = "kimi", efforts = false } # The digit ladder is configurable too — a non-empty [efforts] table # maps digits 1..9 to --effort values and replaces the default five: diff --git a/commands_test.go b/commands_test.go index 5cc819e..4ac76fb 100644 --- a/commands_test.go +++ b/commands_test.go @@ -4,6 +4,7 @@ import ( "errors" "os" "path/filepath" + "reflect" "runtime" "strings" "testing" @@ -11,9 +12,10 @@ import ( func TestTokensOf(t *testing.T) { cfg := defaultConfig() + cfg.Models["k"] = ModelSpec{Model: "kimi"} // efforts=false: no k1..k5 cfg.Profiles["rev"] = Profile{Model: "opus"} got := strings.Join(tokensOf(cfg), " ") - want := "f f1 f2 f3 f4 f5 h o o1 o2 o3 o4 o5 rev s s1 s2 s3 s4 s5" + want := "f f1 f2 f3 f4 f5 h h1 h2 h3 h4 h5 k o o1 o2 o3 o4 o5 rev s s1 s2 s3 s4 s5" if got != want { t.Errorf("tokens = %q\nwant %q", got, want) } @@ -94,8 +96,8 @@ func TestStarterConfigIsValidAndInert(t *testing.T) { if len(cfg.Bases) != 0 { t.Errorf("starter config defines active bases: %v (examples must be commented out)", cfg.Bases) } - if cfg.Models["o"].Model != "opus" { - t.Errorf("starter config changed defaults: %+v", cfg.Models) + if !reflect.DeepEqual(cfg.Models, defaultConfig().Models) { + t.Errorf("starter config changed default models: %+v", cfg.Models) } } @@ -332,6 +334,7 @@ func TestRenderSectionAlignment(t *testing.T) { func TestListViewSectionsAndOrder(t *testing.T) { cfg := defaultConfig() + cfg.Models["k"] = ModelSpec{Model: "kimi"} // opted out of effort digits cfg.Bases["ollama"] = Profile{Flags: []string{"--bare"}} cfg.Profiles["gem"] = Profile{Model: "gemma4:12b", Extends: "ollama"} cfg.Profiles["work"] = Profile{Env: map[string]string{"A": "1"}} @@ -348,8 +351,11 @@ func TestListViewSectionsAndOrder(t *testing.T) { if !strings.Contains(lines[models], "letter alone = model, +digit 1-5 = effort low..max") { t.Errorf("MODELS header missing legend: %q", lines[models]) } - if l := lineWith(t, lines, "haiku"); !strings.Contains(l, "no effort digits") { - t.Errorf("h row missing efforts note: %q", l) + if l := lineWith(t, lines, "kimi"); !strings.Contains(l, "no effort digits") { + t.Errorf("k row missing efforts note: %q", l) + } + if l := lineWith(t, lines, "haiku"); strings.Contains(l, "no effort digits") { + t.Errorf("h row has an efforts note: %q", l) } if l := lineWith(t, lines, "gem"); !strings.Contains(l, "gemma4:12b") { t.Errorf("gem row = %q", l) @@ -398,8 +404,8 @@ func TestFooterLine(t *testing.T) { vc := plainListVC(t, cfg) delete(vc.globalTokens, "gma") - // 19 global grammar tokens, none linked. - if got := footerLine(vc); got != "0 of 19 commands linked in "+contractHome(vc.dir)+" — run clau link · 1 project-only · details: clau show " { + // 24 global grammar tokens, none linked. + if got := footerLine(vc); got != "0 of 24 commands linked in "+contractHome(vc.dir)+" — run clau link · 1 project-only · details: clau show " { t.Errorf("unlinked footer = %q", got) } @@ -408,7 +414,7 @@ func TestFooterLine(t *testing.T) { t.Fatal(err) } } - if got := footerLine(vc); got != "all 19 commands linked in "+contractHome(vc.dir)+" · 1 project-only · details: clau show " { + if got := footerLine(vc); got != "all 24 commands linked in "+contractHome(vc.dir)+" · 1 project-only · details: clau show " { t.Errorf("linked footer = %q", got) } } @@ -448,6 +454,7 @@ func TestMaskedEnvName(t *testing.T) { func showVC(t *testing.T) viewContext { t.Helper() cfg := defaultConfig() + cfg.Models["k"] = ModelSpec{Model: "kimi"} // opted out of effort digits cfg.Bases["ollama"] = Profile{Flags: []string{"--bare"}} cfg.Profiles["gem"] = Profile{ Model: "gemma4:12b", Extends: "ollama", @@ -488,7 +495,8 @@ func TestShowViewKinds(t *testing.T) { vc := showVC(t) cases := map[string]string{ "o": "model letter: opus · effort digits 1-5", - "h": "model letter: haiku · no effort digits", + "h": "model letter: haiku · effort digits 1-5", + "k": "model letter: kimi · no effort digits", "o3": "grammar: o (opus) + 3 (effort high)", } for token, want := range cases { @@ -524,8 +532,8 @@ func TestShowViewFallbacksAndErrors(t *testing.T) { t.Errorf("did-you-mean missing: %v", err) } - if _, err := showView(vc, "h3"); err == nil || - !strings.Contains(err.Error(), "supports no effort levels") { + if _, err := showView(vc, "k3"); err == nil || + !strings.Contains(err.Error(), `efforts = false is set for "k" in [models]`) { t.Errorf("resolver error must surface: %v", err) } } diff --git a/config.go b/config.go index 0e58082..345929c 100644 --- a/config.go +++ b/config.go @@ -42,7 +42,7 @@ func defaultConfig() Config { "o": {Model: "opus", Efforts: true}, "s": {Model: "sonnet", Efforts: true}, "f": {Model: "fable", Efforts: true}, - "h": {Model: "haiku", Efforts: false}, + "h": {Model: "haiku", Efforts: true}, }, Efforts: map[string]string{ "1": "low", "2": "medium", "3": "high", "4": "xhigh", "5": "max", diff --git a/config_test.go b/config_test.go index a0c7ea7..1fcaf3d 100644 --- a/config_test.go +++ b/config_test.go @@ -24,8 +24,8 @@ func TestDefaultConfig(t *testing.T) { if got := cfg.Models["o"]; got.Model != "opus" || !got.Efforts { t.Errorf("o = %+v, want opus/efforts", got) } - if got := cfg.Models["h"]; got.Model != "haiku" || got.Efforts { - t.Errorf("h = %+v, want haiku/no-efforts", got) + if got := cfg.Models["h"]; got.Model != "haiku" || !got.Efforts { + t.Errorf("h = %+v, want haiku/efforts", got) } if cfg.Efforts["5"] != "max" || cfg.Efforts["1"] != "low" { t.Errorf("ladder = %v", cfg.Efforts) diff --git a/docs/demo.gif b/docs/demo.gif index 9694f10..f612ead 100644 Binary files a/docs/demo.gif and b/docs/demo.gif differ diff --git a/docs/demo.tape b/docs/demo.tape index af49127..6aa857e 100644 --- a/docs/demo.tape +++ b/docs/demo.tape @@ -3,7 +3,7 @@ Output docs/demo.gif Set Shell "fish" Set FontSize 20 Set Width 1200 -Set Height 1200 +Set Height 1260 Set Framerate 25 Set TypingSpeed 75ms @@ -29,10 +29,12 @@ Sleep 6s Ctrl+C Sleep 300ms Ctrl+C +# Hide before claude's exit reaches the shell: the terminal's focus-in +# report gets echoed as a stray ^[[I there. +Hide Sleep 1.5s # The freeze-frame: breadth, grouped (fresh screen so the whole list fits) -Hide Type "clear" Enter Show diff --git a/link_test.go b/link_test.go index b016426..07c46ab 100644 --- a/link_test.go +++ b/link_test.go @@ -11,12 +11,14 @@ import ( func TestLinkNames(t *testing.T) { cfg := defaultConfig() + cfg.Models["k"] = ModelSpec{Model: "kimi"} cfg.Profiles["rev"] = Profile{Model: "opus"} got := linkNames(cfg) want := []string{ "c", "cf", "cf1", "cf2", "cf3", "cf4", "cf5", - "ch", // efforts=false: no ch1..ch5 + "ch", "ch1", "ch2", "ch3", "ch4", "ch5", + "ck", // efforts=false: no ck1..ck5 "co", "co1", "co2", "co3", "co4", "co5", "crev", "cs", "cs1", "cs2", "cs3", "cs4", "cs5", @@ -62,7 +64,7 @@ func TestSyncLinksCreatesAndPrunes(t *testing.T) { if err != nil { t.Fatal(err) } - if len(rep.Created) != 21 || len(rep.Pruned) != 0 { + if len(rep.Created) != 26 || len(rep.Pruned) != 0 { t.Fatalf("report = %+v", rep) } if target, err := os.Readlink(filepath.Join(dir, "co5")); err != nil || target != clauPath { @@ -74,7 +76,7 @@ func TestSyncLinksCreatesAndPrunes(t *testing.T) { if err != nil { t.Fatal(err) } - if len(rep.Created) != 0 || len(rep.Kept) != 21 { + if len(rep.Created) != 0 || len(rep.Kept) != 26 { t.Fatalf("resync report = %+v", rep) } @@ -208,7 +210,7 @@ func TestRemoveOwned(t *testing.T) { if err != nil { t.Fatal(err) } - if len(removed) != 20 { // linkNames(defaultConfig()) yields 20 names, all owned + if len(removed) != 25 { // linkNames(defaultConfig()) yields 25 names, all owned t.Errorf("removed %d: %v", len(removed), removed) } if _, err := os.Stat(filepath.Join(dir, "unrelated")); err != nil { diff --git a/resolve.go b/resolve.go index 5357359..cef74d0 100644 --- a/resolve.go +++ b/resolve.go @@ -38,7 +38,8 @@ func resolveToken(cfg Config, token string) (TokenResolution, bool, error) { if inLadder && isModel { if !spec.Efforts { return TokenResolution{}, true, - fmt.Errorf("model %q (%s) supports no effort levels", rest, spec.Model) + fmt.Errorf("model %q (%s) takes no effort digits: efforts = false is set for %q in [models]", + rest, spec.Model, rest) } return TokenResolution{Flags: []string{"--model", spec.Model, "--effort", level}}, true, nil } diff --git a/resolve_test.go b/resolve_test.go index a24a274..e728fb8 100644 --- a/resolve_test.go +++ b/resolve_test.go @@ -8,6 +8,7 @@ import ( func testConfig() Config { cfg := defaultConfig() + cfg.Models["k"] = ModelSpec{Model: "kimi"} // opted out of effort digits cfg.Profiles["rev"] = Profile{ Model: "opus", Effort: "high", Flags: []string{"--append-system-prompt", "Review code."}, @@ -32,7 +33,9 @@ func TestResolveToken(t *testing.T) { {"s3", []string{"--model", "sonnet", "--effort", "high"}, true, ""}, {"f5", []string{"--model", "fable", "--effort", "max"}, true, ""}, {"h", []string{"--model", "haiku"}, true, ""}, - {"h3", nil, true, "no effort levels"}, + {"h3", []string{"--model", "haiku", "--effort", "high"}, true, ""}, + {"k", []string{"--model", "kimi"}, true, ""}, + {"k3", nil, true, `efforts = false is set for "k" in [models]`}, {"o5", []string{"--model", "shadow"}, true, ""}, // profile wins {"rev", []string{"--model", "opus", "--effort", "high", "--append-system-prompt", "Review code."}, true, ""}, {"x", nil, false, ""},