Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ PATH, collisions, and links, and says what to fix.
`<letter><digit>`: 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
Expand Down
5 changes: 4 additions & 1 deletion commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <letter>, <letter>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:
Expand Down
30 changes: 19 additions & 11 deletions commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ import (
"errors"
"os"
"path/filepath"
"reflect"
"runtime"
"strings"
"testing"
)

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)
}
Expand Down Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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"}}
Expand All @@ -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)
Expand Down Expand Up @@ -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 <token>" {
// 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 <token>" {
t.Errorf("unlinked footer = %q", got)
}

Expand All @@ -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 <token>" {
if got := footerLine(vc); got != "all 24 commands linked in "+contractHome(vc.dir)+" · 1 project-only · details: clau show <token>" {
t.Errorf("linked footer = %q", got)
}
}
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Binary file modified docs/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions docs/demo.tape
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
10 changes: 6 additions & 4 deletions link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
}

Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 4 additions & 1 deletion resolve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."},
Expand All @@ -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, ""},
Expand Down
Loading