cmdTranscript implements `flow transcript `. It delegates to the task's harness for both path resolution and on-disk format decoding — each harness has its own transcript layout AND its own schema (claude jsonl, codex event log, gemini single-object json). The harness writes a normalized
(args []string)
| 13 | // schema (claude jsonl, codex event log, gemini single-object json). |
| 14 | // The harness writes a normalized human-readable form to stdout. |
| 15 | func cmdTranscript(args []string) int { |
| 16 | // Positional arg first, then flags (same pattern as cmdDo). |
| 17 | ref := "" |
| 18 | flagArgs := args |
| 19 | if len(args) > 0 && !strings.HasPrefix(args[0], "-") { |
| 20 | ref = args[0] |
| 21 | flagArgs = args[1:] |
| 22 | } |
| 23 | |
| 24 | fs := flagSet("transcript") |
| 25 | compact := fs.Bool("compact", false, "omit tool results and thinking blocks") |
| 26 | if err := fs.Parse(flagArgs); err != nil { |
| 27 | return 2 |
| 28 | } |
| 29 | |
| 30 | dbPath, err := flowDBPath() |
| 31 | if err != nil { |
| 32 | fmt.Fprintf(os.Stderr, "error: %v\n", err) |
| 33 | return 1 |
| 34 | } |
| 35 | db, err := flowdb.OpenDB(dbPath) |
| 36 | if err != nil { |
| 37 | fmt.Fprintf(os.Stderr, "error: open db: %v\n", err) |
| 38 | return 1 |
| 39 | } |
| 40 | defer db.Close() |
| 41 | |
| 42 | var task *flowdb.Task |
| 43 | if ref == "" { |
| 44 | bound, lookupErr := currentSessionTask(db) |
| 45 | if lookupErr != nil { |
| 46 | if isNoBindingErr(lookupErr) { |
| 47 | if currentSessionID() == "" { |
| 48 | fmt.Fprintln(os.Stderr, "error: no task ref given and not running inside a Claude session ($CLAUDE_CODE_SESSION_ID unset)") |
| 49 | } else { |
| 50 | fmt.Fprintln(os.Stderr, "error: no task ref given and this Claude session is not bound to a task") |
| 51 | } |
| 52 | return 2 |
| 53 | } |
| 54 | fmt.Fprintf(os.Stderr, "error: lookup task by session: %v\n", lookupErr) |
| 55 | return 1 |
| 56 | } |
| 57 | task = bound |
| 58 | } else { |
| 59 | task, err = resolveTaskRef(db, ref) |
| 60 | if err != nil { |
| 61 | fmt.Fprintf(os.Stderr, "error: %v\n", err) |
| 62 | return 1 |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | if !task.SessionID.Valid || task.SessionID.String == "" { |
| 67 | fmt.Fprintf(os.Stderr, "error: task %q has no session — run `flow do %s` first\n", task.Slug, task.Slug) |
| 68 | return 1 |
| 69 | } |
| 70 | |
| 71 | // Spawn cwd == work_dir is an invariant for any task with a |
| 72 | // session_id (enforced at bind time in cmdDo + cmdDoHere). So |