classify maps a tool_use block to a lookup kind. The bool is false when the block is not a lookup (or is an own-bootstrap read we skip).
(name string, in rawInput, ownPrefix string)
| 148 | // classify maps a tool_use block to a lookup kind. The bool is false when |
| 149 | // the block is not a lookup (or is an own-bootstrap read we skip). |
| 150 | func classify(name string, in rawInput, ownPrefix string) (LookupKind, bool) { |
| 151 | switch name { |
| 152 | case "Bash": |
| 153 | c := in.Command |
| 154 | switch { |
| 155 | case strings.Contains(c, "flow show task"): |
| 156 | return LookupResume, true |
| 157 | case strings.Contains(c, "flow show "): |
| 158 | return LookupReference, true |
| 159 | case strings.Contains(c, "flow transcript"): |
| 160 | return LookupCrossTask, true |
| 161 | } |
| 162 | case "Read": |
| 163 | p := in.FilePath |
| 164 | switch { |
| 165 | case strings.Contains(p, "/.flow/kb/"): |
| 166 | return LookupKB, true |
| 167 | case strings.Contains(p, ownPrefix): |
| 168 | return "", false // own bootstrap read; already counted |
| 169 | case strings.Contains(p, "/.flow/tasks/"), strings.Contains(p, "/.flow/projects/"): |
| 170 | return LookupCrossTask, true |
| 171 | } |
| 172 | } |
| 173 | return "", false |
| 174 | } |
| 175 | |
| 176 | func parseTS(s string) time.Time { |
| 177 | if s == "" { |