loadInjectionText resolves --with / --with-file into the text that will be injected as the session's first user message. For --with-file we don't embed the file's contents — we synthesize a "read instructions at " prompt and let the session use its Read tool. That keeps the shell-quoted bl
(fs *flag.FlagSet, withInstr, withFile string)
| 21 | // Read tool. That keeps the shell-quoted blob short regardless of file |
| 22 | // size and lets the receiving model reason about the file directly. |
| 23 | func loadInjectionText(fs *flag.FlagSet, withInstr, withFile string) (string, int) { |
| 24 | passedWith, passedWithFile := false, false |
| 25 | fs.Visit(func(f *flag.Flag) { |
| 26 | switch f.Name { |
| 27 | case "with": |
| 28 | passedWith = true |
| 29 | case "with-file": |
| 30 | passedWithFile = true |
| 31 | } |
| 32 | }) |
| 33 | if !passedWith && !passedWithFile { |
| 34 | return "", 0 |
| 35 | } |
| 36 | if passedWith && passedWithFile { |
| 37 | fmt.Fprintln(os.Stderr, "error: --with and --with-file are mutually exclusive") |
| 38 | return "", 2 |
| 39 | } |
| 40 | if passedWith { |
| 41 | text := strings.TrimSpace(withInstr) |
| 42 | if text == "" { |
| 43 | fmt.Fprintln(os.Stderr, "error: --with instruction is empty") |
| 44 | return "", 2 |
| 45 | } |
| 46 | return text, 0 |
| 47 | } |
| 48 | if _, err := os.Stat(withFile); err != nil { |
| 49 | fmt.Fprintf(os.Stderr, "error: --with-file: %v\n", err) |
| 50 | return "", 1 |
| 51 | } |
| 52 | abs, err := filepath.Abs(withFile) |
| 53 | if err != nil { |
| 54 | fmt.Fprintf(os.Stderr, "error: --with-file: %v\n", err) |
| 55 | return "", 1 |
| 56 | } |
| 57 | return "read instructions at " + abs, 0 |
| 58 | } |
| 59 | |
| 60 | // openConcurrentDB opens flow.db with a generous busy_timeout so that two |
| 61 | // concurrent `flow do` processes (or two goroutines in the tests) will |
no outgoing calls
no test coverage detected