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.

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