]> git.giacomolli.uk - onechat/blob - subagent_names.go
Store shared private images by content hash
[onechat] / subagent_names.go
1 package main
2
3 import (
4 "math/rand/v2"
5 "strings"
6 )
7
8 var (
9 // subagentAdjectives and subagentNouns are the words of the names of
10 // the subagents. A name is an adjective and a noun, each capitalized,
11 // joined, such as GreenOtter: 16,384 names.
12 subagentAdjectives = strings.Fields(`
13 red blue green yellow orange purple pink brown black white gray silver golden
14 amber azure bronze copper jade lemon lime mint navy peach plum ruby violet
15 cherry honey big small tiny huge giant little tall short long round flat thick
16 thin deep soft hard smooth rough fuzzy fluffy shiny crunchy crispy leafy spiky
17 hot cold warm cool icy frosty snowy rainy sunny cloudy windy stormy foggy
18 misty sweet sour salty spicy juicy minty nutty creamy smoky tasty fresh bright
19 dark quiet loud happy jolly merry calm brave bold clever wise kind gentle
20 lucky proud quick swift fast slow eager busy sleepy silly funny shy neat noble
21 grand royal mighty strong steady nimble lively cozy old new young ancient
22 wooden stone paper iron magic cosmic lunar solar polar wild
23 `)
24 subagentNouns = strings.Fields(`
25 ant bat bear bee beetle bird bison camel cat cheetah chicken clam cobra cougar
26 cow crab crane crow deer dog dolphin donkey dove dragon duck eagle eel elk
27 falcon finch fish flamingo fox frog gazelle gecko giraffe goat goose gorilla
28 hamster hare hawk hedgehog heron hippo horse hyena iguana jaguar jay kangaroo
29 kitten koala lamb lemur leopard lion lizard llama lobster moose moth mouse
30 mule octopus orca otter owl ox oyster panda parrot pelican penguin pig pigeon
31 pony puffin puma rabbit raccoon raven rhino robin salmon seal shark sheep
32 shrimp skunk sloth snail snake sparrow spider squid squirrel swan tiger toad
33 toucan trout tuna turkey turtle walrus wasp whale wolf wombat yak zebra apple
34 banana bagel cookie mango melon muffin noodle pancake pepper potato pretzel
35 radish taco waffle
36 `)
37 )
38
39 // subagentNameRandom returns a random name of a subagent.
40 func subagentNameRandom() string {
41 adjective := subagentAdjectives[rand.IntN(len(subagentAdjectives))]
42 noun := subagentNouns[rand.IntN(len(subagentNouns))]
43
44 return subagentWord(adjective) + subagentWord(noun)
45 }
46
47 // subagentNameValid tells if name is an adjective and a noun of the word lists,
48 // each capitalized, joined. Only such a name can be a directory of a subagent.
49 func subagentNameValid(name string) bool {
50 for _, adjective := range subagentAdjectives {
51 noun, found := strings.CutPrefix(name, subagentWord(adjective))
52 if !found {
53 continue
54 }
55
56 for _, word := range subagentNouns {
57 if subagentWord(word) == noun {
58 return true
59 }
60 }
61 }
62
63 return false
64 }
65
66 // subagentWord returns word with its first letter in upper case.
67 func subagentWord(word string) string {
68 return strings.ToUpper(word[:1]) + word[1:]
69 }