Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

186 linesCodeBlameRaw
1//! What a workspace's work says over the last weeks: the reads behind
2//! Home's daily signal and the Workspace overview. Each row is one
3//! repository's, so a caller that asks in batches adds them up.
4//!
5//! A pull request is an agent's when g1t's agent opened it, it was opened
6//! as an agent's, or a harness session is tied to it (by a link, by saying
7//! so when it started, or by pushing its branch). Whose it is (`owner`) is
8//! the person it was requested by, else its author: the one who
9//! understood it.
10use crate::Viewer;
11use serde::{Deserialize, Serialize};
12
13#[derive(Deserialize, Serialize)]
14#[serde(rename_all = "camelCase")]
15pub struct WorkspaceSignalsArgs {
16 /// The workspace the repositories belong to: its work items and milestones.
17 pub workspace: String,
18 /// Up to 100 repositories; the ones the viewer cannot read are left out.
19 pub repo_ids: Vec<String>,
20 pub viewer: Viewer,
21 /// The last UTC day covered, `YYYY-MM-DD`: the last week ends with it.
22 pub until: String,
23 /// How many weeks of seven UTC days end with `until`: 1 through 13.
24 pub weeks: u32,
25 /// How many UTC days end with `until` for `days`: 1 through 28.
26 pub days: u32,
27 /// The first UTC day `pulls` reaches back to, `YYYY-MM-DD`: at most 400 days before `until`.
28 pub since: String,
29}
30
31/// One repository's week, starting on UTC day `start`. Weeks with nothing
32/// in them are left out.
33#[derive(Clone, Default, Deserialize, Serialize)]
34#[serde(default, rename_all(serialize = "camelCase"))]
35pub struct SignalWeek {
36 pub repo_id: String,
37 pub start: String,
38 pub merged: u32,
39 /// Of `merged`, an agent's.
40 pub agent_merged: u32,
41 /// Of `agent_merged`, the ones a person asked for changes on before they merged.
42 pub agent_reworked: u32,
43 /// Agent pull requests opened in the week whose session started first,
44 /// and the seconds from each session's start to its pull request opening.
45 pub agent_drafted: u32,
46 pub agent_draft_seconds: f64,
47 /// First reviews given in the week (a person's approval or request for
48 /// changes, as Insights counts them), and the seconds each waited.
49 pub reviewed: u32,
50 pub review_seconds: f64,
51 /// Pull requests open when the week ended (now, for the current week),
52 /// opened at least three days before, with no activity in the three
53 /// days before it ended: no comment, review or timeline event, no push
54 /// (only its latest is known), no check or status on its head commit
55 /// (only its current head is known) or acceptance check, no session
56 /// entry, and no tied session (or its subagent) running.
57 pub stalled: u32,
58 /// What the harness sessions started in the week cost, as they
59 /// reported it (estimated at list price from their token usage).
60 pub session_cost_usd: f64,
61}
62
63/// One repository's UTC day. Days with nothing in them are left out.
64#[derive(Clone, Default, Deserialize, Serialize)]
65#[serde(default, rename_all(serialize = "camelCase"))]
66pub struct SignalDay {
67 pub repo_id: String,
68 pub day: String,
69 pub opened: u32,
70 pub merged: u32,
71 /// Of `merged`, an agent's.
72 pub agent_merged: u32,
73 /// A person's requests for changes.
74 pub reworked: u32,
75 /// Reviews and comments by people other than the pull request's owner.
76 pub reviews: u32,
77 /// Harness sessions started.
78 pub sessions: u32,
79}
80
81/// An open pull request no one has reviewed yet, oldest first.
82#[derive(Clone, Default, Deserialize, Serialize)]
83#[serde(default, rename_all(serialize = "camelCase"))]
84pub struct WaitingPull {
85 pub repo_id: String,
86 pub number: u32,
87 pub title: String,
88 pub created_at: String,
89 pub agent: bool,
90 /// For an agent's: seconds from its first session's start to opening.
91 pub draft_seconds: Option<f64>,
92 /// The work item it is for, and the open work items blocked by that one.
93 pub item: Option<u32>,
94 pub blocks: Vec<u32>,
95}
96
97/// A pull request opened or merged since `since`.
98#[derive(Clone, Default, Deserialize, Serialize)]
99#[serde(default, rename_all(serialize = "camelCase"))]
100pub struct SignalPull {
101 pub repo_id: String,
102 pub number: u32,
103 pub title: String,
104 /// draft, open, merged or closed.
105 pub status: String,
106 pub agent: bool,
107 pub owner_id: String,
108 pub owner_name: String,
109 pub created_at: String,
110 pub merged_at: Option<String>,
111 /// The work item it is for, and that item's milestone.
112 pub item: Option<u32>,
113 pub milestone: Option<u32>,
114 /// Its share of what the harness sessions tied to it cost: each
115 /// session's cost split evenly among the pull requests it is tied to
116 /// (a subagent tied to none counts with its root session's). Unknown
117 /// costs count as nothing.
118 pub session_cost_usd: f64,
119}
120
121/// One person's use of one harness in one repository: when they first
122/// started a session with it there, and how many they have started.
123#[derive(Clone, Default, Deserialize, Serialize)]
124#[serde(default, rename_all(serialize = "camelCase"))]
125pub struct SignalHarness {
126 pub repo_id: String,
127 pub owner_id: String,
128 pub owner_name: String,
129 /// claude_code, codex, cursor, copilot or other.
130 pub harness: String,
131 pub first_at: String,
132 pub sessions: u32,
133}
134
135/// One person's merged pull requests in one repository, over its whole history.
136#[derive(Clone, Default, Deserialize, Serialize)]
137#[serde(default, rename_all(serialize = "camelCase"))]
138pub struct SignalAuthor {
139 pub repo_id: String,
140 pub owner_id: String,
141 pub owner_name: String,
142 pub first_merged_at: String,
143 pub last_merged_at: String,
144 pub merged: u32,
145 /// Of `merged`, the ones in the 90 days ending with `until`.
146 pub recent: u32,
147}
148
149/// A work item `pulls` or `waiting` names.
150#[derive(Clone, Default, Deserialize, Serialize)]
151#[serde(default, rename_all(serialize = "camelCase"))]
152pub struct SignalItem {
153 pub number: u32,
154 pub title: String,
155 pub state: String,
156 pub milestone: Option<u32>,
157}
158
159/// One of the workspace's milestones.
160#[derive(Clone, Default, Deserialize, Serialize)]
161#[serde(default, rename_all(serialize = "camelCase"))]
162pub struct SignalMilestone {
163 pub number: u32,
164 pub title: String,
165 pub state: String,
166 pub due_on: Option<String>,
167 pub created_at: String,
168 pub closed_at: Option<String>,
169}
170
171#[derive(Default, Serialize)]
172#[serde(rename_all = "camelCase")]
173pub struct WorkspaceSignals {
174 pub weeks: Vec<SignalWeek>,
175 pub days: Vec<SignalDay>,
176 /// At most 50.
177 pub waiting: Vec<WaitingPull>,
178 /// At most 3,000, newest first; `pulls_capped` when there were more.
179 pub pulls: Vec<SignalPull>,
180 pub pulls_capped: bool,
181 pub authors: Vec<SignalAuthor>,
182 /// People's harnesses, root sessions only (a subagent is its parent's).
183 pub harnesses: Vec<SignalHarness>,
184 pub items: Vec<SignalItem>,
185 pub milestones: Vec<SignalMilestone>,
186}