oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package equipo
2
3import (
4 "fmt"
5 "strings"
6
7 "amadan.net/oficina/equipo/internal/equipo/activity"
8 "amadan.net/oficina/equipo/internal/wire"
9)
10
11// The team panel says what a specialist is doing the way a person would:
12// "Reading NavigationStack.swift", not the command the runner saw. A
13// step's activity lines (wire.ActivityLine, the step_activity stream)
14// arrive sorted by kind for Claude's own tools; a shell command arrives
15// as kind "run" with the command's first line, wrapped or not (Codex
16// sends `/bin/bash -lc "cat ios/..."`). Package activity unwraps the
17// command, takes its first meaningful part and maps the common tools to
18// a verb and, for a file, its path; humaneActivity words it with the
19// base name. Anything unknown is "Working on the project": raw shell never
20// shows. The command itself stays behind a disclosure on the panel.
21
22// humaneActivity is one activity line in plain words.
23func humaneActivity(a wire.ActivityLine) string {
24 key, subject := activity.Meaning(a)
25 return activityWords(key, subject)
26}
27
28// activityWords renders a verb and subject with the reviewed copy. A
29// subject that is not plain (a variable, a glob, a substitution) is
30// dropped rather than shown.
31func activityWords(key, subject string) string {
32 file := activity.Name(subject)
33 switch key {
34 case "read", "edit":
35 if file == "" {
36 return copyText("team.activity." + key + "_files")
37 }
38 return fmt.Sprintf(copyText("work.activity."+key), file)
39 case "search":
40 if !activity.Word(subject) {
41 return copyText("team.activity.search_code")
42 }
43 return fmt.Sprintf(copyText("work.activity.search"), subject)
44 case "list":
45 if file == "" || file == "." {
46 return copyText("team.activity.list_files")
47 }
48 return fmt.Sprintf(copyText("team.activity.list"), file)
49 case "script":
50 if file == "" {
51 return copyText("team.activity.command")
52 }
53 return fmt.Sprintf(copyText("team.activity.script"), file)
54 case "working":
55 return copyText("work.activity.working")
56 }
57 if text := copyText("team.activity." + key); text != "" {
58 return text
59 }
60 return copyText("team.activity.command")
61}
62
63// teamFile is one file a step's lines touched.
64type teamFile struct {
65 Name, Path string
66 Edited bool
67}
68
69// activityFiles are the files a step's lines read or edited, newest
70// first, once each; an edit wins over a read.
71func activityFiles(lines []wire.ActivityLine) []teamFile {
72 var out []teamFile
73 seen := map[string]int{}
74 for i := len(lines) - 1; i >= 0; i-- {
75 key, subject := activity.Meaning(lines[i])
76 if key != "read" && key != "edit" {
77 continue
78 }
79 name := activity.Name(subject)
80 if name == "" {
81 continue
82 }
83 p := strings.TrimPrefix(strings.TrimSpace(subject), "./")
84 if j, ok := seen[p]; ok {
85 out[j].Edited = out[j].Edited || key == "edit"
86 continue
87 }
88 seen[p] = len(out)
89 out = append(out, teamFile{Name: name, Path: p, Edited: key == "edit"})
90 }
91 return out
92}
93