@@ -82,24 +82,46 @@ func asPrinter(cmd *cobra.Command) standalone.StatusPrinter {
8282 return & commandPrinter {cmd : cmd }
8383}
8484
85- // stripDefaultsFromModelName removes the default "ai/" prefix and ":latest" tag for display.
85+ // stripDefaultsFromModelName removes the default "ai/" prefix, default registry, and ":latest" tag for display.
8686// Examples:
8787// - "ai/gemma3:latest" -> "gemma3"
8888// - "ai/gemma3:v1" -> "ai/gemma3:v1"
8989// - "myorg/gemma3:latest" -> "myorg/gemma3"
9090// - "gemma3:latest" -> "gemma3"
91+ // - "index.docker.io/ai/gemma3:latest" -> "gemma3"
92+ // - "docker.io/ai/gemma3:latest" -> "gemma3"
93+ // - "docker.io/myorg/gemma3:latest" -> "myorg/gemma3"
9194// - "hf.co/bartowski/model:latest" -> "hf.co/bartowski/model"
9295func stripDefaultsFromModelName (model string ) string {
93- // Check if model has ai/ prefix without tag (implicitly :latest) - strip just ai/
96+ // First, let's handle the default registry prefixes
97+ defaultRegistries := []string {"index.docker.io/" , "docker.io/" }
98+ for _ , reg := range defaultRegistries {
99+ if strings .HasPrefix (model , reg ) {
100+ // Remove the registry prefix
101+ model = strings .TrimPrefix (model , reg )
102+ break
103+ }
104+ }
105+
106+ // If model has default org prefix (without tag, or with :latest tag), strip the org
107+ // but preserve other tags
94108 if strings .HasPrefix (model , defaultOrg + "/" ) {
95- model = strings .TrimPrefix (model , defaultOrg + "/" )
109+ rest := strings .TrimPrefix (model , defaultOrg + "/" )
110+ // Check if the remaining part has :latest tag
111+ if strings .HasSuffix (rest , ":" + defaultTag ) {
112+ // Strip the :latest tag to get just the name
113+ nameWithoutTag := strings .TrimSuffix (rest , ":" + defaultTag )
114+ return nameWithoutTag
115+ }
116+ // If it doesn't have latest tag, keep the rest intact
117+ return rest
96118 }
97119
98- // Check if model has :latest but no slash (no org specified) - strip :latest
120+ // For models without the default org but with :latest tag, just strip the tag (keep the org part)
99121 if strings .HasSuffix (model , ":" + defaultTag ) {
100122 model = strings .TrimSuffix (model , ":" + defaultTag )
101123 }
102124
103- // For other cases (ai/ with custom tag, custom org with :latest, etc.), keep as- is
125+ // For other cases (custom org with :latest, etc.), return as is
104126 return model
105127}
0 commit comments