MCPcopy Create free account
hub / github.com/Facets-cloud/flow / cmdTranscript

Function cmdTranscript

internal/app/transcript.go:15–94  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 5

TestE2EFullRoundtripFunction · 0.85
RunFunction · 0.85

Calls 9

OpenDBFunction · 0.92
flagSetFunction · 0.85
flowDBPathFunction · 0.85
currentSessionTaskFunction · 0.85
isNoBindingErrFunction · 0.85
currentSessionIDFunction · 0.85
resolveTaskRefFunction · 0.85
harnessForTaskFunction · 0.85
RenderTranscriptMethod · 0.65