]> git.giacomolli.uk - onechat/blobdiff - stop.go
Check the width of comment lines
[onechat] / stop.go
diff --git a/stop.go b/stop.go
index 640464f9fb1c0ce47bde9ea8638512ea1276dd0e..6df8dd32c4de5208353b81992524654b9d6f8552 100644 (file)
--- a/stop.go
+++ b/stop.go
@@ -1,4 +1,21 @@
 package main
 
 package main
 
-// stopCommand is the input line that interrupts the running turn.
+import (
+       "strings"
+)
+
+// stopCommand is the input line that interrupts the running turn. The line
+// "/stop NAME" stops the subagent NAME.
 const stopCommand = "/stop"
 const stopCommand = "/stop"
+
+// stopSubagentName returns NAME of a line "/stop NAME", or false for any other
+// line.
+func stopSubagentName(line string) (string, bool) {
+       name, found := strings.CutPrefix(strings.TrimSpace(line), stopCommand+" ")
+       name = strings.TrimSpace(name)
+       if !found || name == "" {
+               return "", false
+       }
+
+       return name, true
+}