modelfamily

package
v0.41.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package modelfamily maps a Claude model id to the family alias a pyry session follows, and reduces claude's published model list to one row per family.

The operator's rule (2026-09-15, 2026-09-24) is that a pyry session follows the latest model of its family, and that the model menu shows one row per family. A pinned id such as claude-opus-4-7 or claude-opus-5 holds a session on a model claude has since superseded, so every Claude model the daemon hands to claude, stores or offers goes through this package first.

Claude Code does not publish family names only. Since about 2.1.289 its list carries the family rows (default, opus, fable, sonnet, haiku) followed by pinned rows (claude-sonnet-5, claude-opus-5, claude-fable-5, claude-opus-4-8, claude-opus-4-7, and more). Reduce removes those pinned rows; Alias resolves any pinned id that still arrives, from a client, a saved setting or Claude Code's own settings file, to its family.

Only Claude ids are touched. A Codex model ("gpt-5.6-terra", or its family "terra") never has the claude- prefix, so both functions return it unchanged.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alias

func Alias(model string) string

Alias returns the family alias for an exact Claude model id, carrying any trailing variant group through unchanged: "claude-fable-5-1[1m]" becomes "fable[1m]", "claude-opus-5" becomes "opus". Everything else is returned byte for byte as it arrived, including a bare alias ("opus", "opus[1m]"), "default" and "".

The rule, deliberately narrow (#2447): after any trailing variant group is split off, the base must divide on "-" into "claude", a family segment of letters, and at least one further segment, with every remaining segment all digits. That covers an id with no minor version (claude-opus-5) and a dated one (claude-haiku-4-5-20251001). It refuses the legacy generation-first spelling (claude-3-5-sonnet-20241022), whose family sits in no fixed position, and a value with no version segment at all (claude-fable).

SECURITY. The output reaches an argv token and a live child's stdin, so it must not weaken what internal/relay's validModel guarantees for those sinks, and it must do so WITHOUT assuming validModel ran: a saved setting, the operator's own --model and Claude Code's settings file all reach here unvalidated. Both properties are structural:

  • Every output byte is an input byte. The rewrite returns a substring of the base joined to a suffix of the input, and the identity arm returns the input.
  • A REWRITTEN value is strictly narrower than what validModel accepts: the emitted base is non-empty and all ASCII letters, so it can never start with "-" and pose as a claude flag, and the group, when present, is balanced, non-empty, unnested and drawn from [A-Za-z0-9._-].

Length never grows. A non-empty input always yields a non-empty output. TestAlias_RewrittenOutputIsNarrowerThanItsInput walks all 256 byte values through three positions rather than leaving those claims as prose.

func Reduce

func Reduce[T any](rows []T, value func(T) string) []T

Reduce returns rows with Claude's list reduced to one row per family, in claude's own order. value reads a row's value, the argument passed to claude.

  • A pinned row (one Alias rewrites) is dropped when a row whose value is its family is also present: claude-opus-4-7 goes when opus is published.
  • When a family has only pinned rows, the newest one is kept. Newest compares the version segments numerically, and a longer version beats its own prefix, so claude-opus-5-5 is newer than claude-opus-5, which is newer than claude-opus-4-8.
  • Every other row is kept: default, the family rows, and any value whose shape Alias does not touch.

A family key includes the variant group, so claude-opus-5-5[1m] is dropped by an opus[1m] row and not by an opus row.

Reduce never empties a non-empty list, since every family keeps one row. It does not modify rows and returns a fresh slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL