-// probeWriter writes readable made-up messages.
-type probeWriter struct {
- random *rand.Rand
-}
-
-func (g *probeWriter) message() (string, string) {
- roll := g.random.IntN(100)
- switch {
- case roll < 5:
- return "user", g.fill(g.userLine, 10+g.random.IntN(200))
- case roll < 10:
- return "reply", g.fill(g.replyLine, 100+g.random.IntN(1500))
- case roll < 12:
- return "note", g.fill(g.noteLine, 50+g.random.IntN(600))
- case roll < 13:
- return "work", "[" + g.pick(people) + "] report: " + g.fill(g.replyLine, 300+g.random.IntN(3000))
- case roll < 56:
- return "tool", g.toolCall(60 + g.random.IntN(400))
- case roll < 57:
- return "echo", g.fill(g.outputLine, 30000+g.random.IntN(30000))
- default:
- return "echo", g.fill(g.outputLine, 20+g.random.IntN(4000))
- }
-}
-
-// fill joins lines of write until the text has about size bytes.
-func (g *probeWriter) fill(write func() string, size int) string {
- var text strings.Builder
- for text.Len() < size {
- if text.Len() > 0 {
- text.WriteByte(' ')
- }
-
- text.WriteString(write())
- }
-
- return text.String()
-}
-
-func (g *probeWriter) userLine() string {
- return g.pick([]string{
- fmt.Sprintf("Please check why the %s %s.", g.pick(things), g.pick(problems)),
- fmt.Sprintf("Move the %s to %s before %s.", g.pick(things), g.pick(places), g.pick(days)),
- fmt.Sprintf("Thanks, that works. Next, %s.", g.pick(tasks)),
- fmt.Sprintf("No, keep the old %s. %s asked for it.", g.pick(things), g.pick(people)),
- fmt.Sprintf("How many %s orders came in on %s?", g.pick(breads), g.pick(days)),
- })
-}
-
-func (g *probeWriter) replyLine() string {
- return g.pick([]string{
- fmt.Sprintf("I looked at %s. The %s %s because %s.", g.pick(files), g.pick(things), g.pick(problems), g.pick(causes)),
- fmt.Sprintf("I changed %s, and the tests pass now.", g.pick(changes)),
- fmt.Sprintf("There were %d %s orders on %s, %d of them late.", 10+g.random.IntN(90), g.pick(breads), g.pick(days), g.random.IntN(10)),
- fmt.Sprintf("Open question: should %s get %s?", g.pick(people), g.pick(tasks)),
- })
-}
-
-func (g *probeWriter) noteLine() string {
- return g.pick([]string{
- fmt.Sprintf("%s prefers %s.", g.pick(people), g.pick(preferences)),
- fmt.Sprintf("The bakery opens at %d and closes at %d on %s.", 5+g.random.IntN(3), 17+g.random.IntN(4), g.pick(days)),
- })
-}
-
-func (g *probeWriter) outputLine() string {
- return g.pick([]string{
- fmt.Sprintf("%02d:%02d order %d for %d %s, packed by %s.", 6+g.random.IntN(12), g.random.IntN(60), 1000+g.random.IntN(9000), 1+g.random.IntN(24), g.pick(breads), g.pick(people)),
- fmt.Sprintf("%s:%d: %s %s.", g.pick(files), 1+g.random.IntN(400), g.pick(things), g.pick(problems)),
- fmt.Sprintf("ok bakery/%s %d.%03ds", g.pick(modules), g.random.IntN(3), g.random.IntN(1000)),
- })
-}
-
-// toolCall returns a tool name and its JSON input of about size bytes.
-func (g *probeWriter) toolCall(size int) string {
- name := g.pick([]string{"shell", "read", "write", "edit"})
- var input map[string]string
- switch name {
- case "shell":
- input = map[string]string{"command": "grep -n '" + g.pick(things) + "' " + g.pick(files)}
- case "read":
- input = map[string]string{"path": g.pick(files)}
- default:
- input = map[string]string{
- "path": g.pick(files),
- "text": g.fill(g.replyLine, max(0, size-80)),
- }