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.

191 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 /// Commits agent sessions pushed outside any pull request in the week
62 /// (to the default branch, most of all), each once.
63 pub agent_commits: u32,
64}
65
66/// One repository's UTC day. Days with nothing in them are left out.
67#[derive(Clone, Default, Deserialize, Serialize)]
68#[serde(default, rename_all(serialize = "camelCase"))]
69pub struct SignalDay {
70 pub repo_id: String,
71 pub day: String,
72 pub opened: u32,
73 pub merged: u32,
74 /// Of `merged`, an agent's.
75 pub agent_merged: u32,
76 /// A person's requests for changes.
77 pub reworked: u32,
78 /// Reviews and comments by people other than the pull request's owner.
79 pub reviews: u32,
80 /// Harness sessions started.
81 pub sessions: u32,
82 /// Commits agent sessions pushed outside any pull request.
83 pub agent_commits: u32,
84}
85
86/// An open pull request no one has reviewed yet, oldest first.
87#[derive(Clone, Default, Deserialize, Serialize)]
88#[serde(default, rename_all(serialize = "camelCase"))]
89pub struct WaitingPull {
90 pub repo_id: String,
91 pub number: u32,
92 pub title: String,
93 pub created_at: String,
94 pub agent: bool,
95 /// For an agent's: seconds from its first session's start to opening.
96 pub draft_seconds: Option<f64>,
97 /// The work item it is for, and the open work items blocked by that one.
98 pub item: Option<u32>,
99 pub blocks: Vec<u32>,
100}
101
102/// A pull request opened or merged since `since`.
103#[derive(Clone, Default, Deserialize, Serialize)]
104#[serde(default, rename_all(serialize = "camelCase"))]
105pub struct SignalPull {
106 pub repo_id: String,
107 pub number: u32,
108 pub title: String,
109 /// draft, open, merged or closed.
110 pub status: String,
111 pub agent: bool,
112 pub owner_id: String,
113 pub owner_name: String,
114 pub created_at: String,
115 pub merged_at: Option<String>,
116 /// The work item it is for, and that item's milestone.
117 pub item: Option<u32>,
118 pub milestone: Option<u32>,
119 /// Its share of what the harness sessions tied to it cost: each
120 /// session's cost split evenly among the pull requests it is tied to
121 /// (a subagent tied to none counts with its root session's). Unknown
122 /// costs count as nothing.
123 pub session_cost_usd: f64,
124}
125
126/// One person's use of one harness in one repository: when they first
127/// started a session with it there, and how many they have started.
128#[derive(Clone, Default, Deserialize, Serialize)]
129#[serde(default, rename_all(serialize = "camelCase"))]
130pub struct SignalHarness {
131 pub repo_id: String,
132 pub owner_id: String,
133 pub owner_name: String,
134 /// claude_code, codex, cursor, copilot or other.
135 pub harness: String,
136 pub first_at: String,
137 pub sessions: u32,
138}
139
140/// One person's merged pull requests in one repository, over its whole history.
141#[derive(Clone, Default, Deserialize, Serialize)]
142#[serde(default, rename_all(serialize = "camelCase"))]
143pub struct SignalAuthor {
144 pub repo_id: String,
145 pub owner_id: String,
146 pub owner_name: String,
147 pub first_merged_at: String,
148 pub last_merged_at: String,
149 pub merged: u32,
150 /// Of `merged`, the ones in the 90 days ending with `until`.
151 pub recent: u32,
152}
153
154/// A work item `pulls` or `waiting` names.
155#[derive(Clone, Default, Deserialize, Serialize)]
156#[serde(default, rename_all(serialize = "camelCase"))]
157pub struct SignalItem {
158 pub number: u32,
159 pub title: String,
160 pub state: String,
161 pub milestone: Option<u32>,
162}
163
164/// One of the workspace's milestones.
165#[derive(Clone, Default, Deserialize, Serialize)]
166#[serde(default, rename_all(serialize = "camelCase"))]
167pub struct SignalMilestone {
168 pub number: u32,
169 pub title: String,
170 pub state: String,
171 pub due_on: Option<String>,
172 pub created_at: String,
173 pub closed_at: Option<String>,
174}
175
176#[derive(Default, Serialize)]
177#[serde(rename_all = "camelCase")]
178pub struct WorkspaceSignals {
179 pub weeks: Vec<SignalWeek>,
180 pub days: Vec<SignalDay>,
181 /// At most 50.
182 pub waiting: Vec<WaitingPull>,
183 /// At most 3,000, newest first; `pulls_capped` when there were more.
184 pub pulls: Vec<SignalPull>,
185 pub pulls_capped: bool,
186 pub authors: Vec<SignalAuthor>,
187 /// People's harnesses, root sessions only (a subagent is its parent's).
188 pub harnesses: Vec<SignalHarness>,
189 pub items: Vec<SignalItem>,
190 pub milestones: Vec<SignalMilestone>,
191}