@imagile-dev/toil-ui 0.1.0-beta.1 → 0.1.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // toil-ui-build {"version":"0.1.0-beta.1","commit":"2bb247a57f71f431f7bdf756d34752e704e81cb9"}
2
+ // toil-ui-build {"version":"0.1.0-beta.3","commit":"a8ca2c90f7942fbcd4cf98e643a97c83742330c4"}
3
3
  import { contractVersion, execute, mapOwi, registry, version } from "@imagile-dev/toil/api";
4
4
  import { fileURLToPath, pathToFileURL } from "node:url";
5
5
  import { chmodSync, closeSync, cpSync, existsSync, linkSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
@@ -35,6 +35,7 @@ var CONFIG_CHANGES = [
35
35
  "dossiers field",
36
36
  "dossiers person",
37
37
  "dossiers wip-limit",
38
+ "dossiers analyze set",
38
39
  "dossiers onboard",
39
40
  "dossiers describe",
40
41
  "theme set"
@@ -45,300 +46,7 @@ var CONFIG_COMMANDS = /* @__PURE__ */ new Set([...CONFIG_READS, ...CONFIG_CHANGE
45
46
  var DEFAULT_TIMEOUT_MS = 12e4;
46
47
  //#endregion
47
48
  //#region src/fixtures/config-areas.json
48
- var config_areas_default = [
49
- {
50
- "name": "ado",
51
- "description": "Azure DevOps Server: work items, repositories, pull requests and pipelines",
52
- "connection": [
53
- {
54
- "name": "baseUrl",
55
- "description": "Azure DevOps Server root, e.g. https://ado.imagile.dev (keep any /tfs prefix)",
56
- "secret": false,
57
- "password": false,
58
- "default": null,
59
- "required": true
60
- },
61
- {
62
- "name": "collection",
63
- "description": "Default collection, when --collection isn't given",
64
- "secret": false,
65
- "password": false,
66
- "default": null,
67
- "required": false
68
- },
69
- {
70
- "name": "project",
71
- "description": "Default team project, when --project isn't given",
72
- "secret": false,
73
- "password": false,
74
- "default": null,
75
- "required": false
76
- },
77
- {
78
- "name": "repo",
79
- "description": "Default git repository, when --repo isn't given",
80
- "secret": false,
81
- "password": false,
82
- "default": null,
83
- "required": false
84
- },
85
- {
86
- "name": "fieldAliases",
87
- "description": "Work item field aliases, friendly name to reference name (e.g. {\"storypoints\": \"Microsoft.VSTS.Scheduling.StoryPoints\"})",
88
- "secret": false,
89
- "password": false,
90
- "default": null,
91
- "required": false
92
- },
93
- {
94
- "name": "discoveredFields",
95
- "description": "Work item fields recorded by an earlier discovery; kept, not read",
96
- "secret": false,
97
- "password": false,
98
- "default": null,
99
- "required": false
100
- },
101
- {
102
- "name": "discoveredTypes",
103
- "description": "Work item types recorded by an earlier discovery; kept, not read",
104
- "secret": false,
105
- "password": false,
106
- "default": null,
107
- "required": false
108
- },
109
- {
110
- "name": "pat",
111
- "description": "Personal access token",
112
- "secret": true,
113
- "password": false,
114
- "default": null,
115
- "required": true
116
- }
117
- ]
118
- },
119
- {
120
- "name": "bitbucket",
121
- "description": "Bitbucket Data Center: repositories, pull requests, comments, reviewers and build statuses",
122
- "connection": [
123
- {
124
- "name": "baseUrl",
125
- "description": "Bitbucket server root, e.g. https://bitbucket.imagile.dev",
126
- "secret": false,
127
- "password": false,
128
- "default": null,
129
- "required": true
130
- },
131
- {
132
- "name": "project",
133
- "description": "Default project key",
134
- "secret": false,
135
- "password": false,
136
- "default": null,
137
- "required": false
138
- },
139
- {
140
- "name": "repo",
141
- "description": "Default repository slug",
142
- "secret": false,
143
- "password": false,
144
- "default": null,
145
- "required": false
146
- },
147
- {
148
- "name": "targetBranch",
149
- "description": "Default target branch for pr create (main when unset)",
150
- "secret": false,
151
- "password": false,
152
- "default": null,
153
- "required": false
154
- },
155
- {
156
- "name": "pat",
157
- "description": "HTTP access token",
158
- "secret": true,
159
- "password": false,
160
- "default": null,
161
- "required": true
162
- }
163
- ]
164
- },
165
- {
166
- "name": "github",
167
- "description": "GitHub and GitHub Enterprise Server: pull requests, reviews, comments, checks, labels, assignees, issues and projects",
168
- "connection": [
169
- {
170
- "name": "baseUrl",
171
- "description": "REST API root: https://api.github.com, or https://ghe.imagile.dev/api/v3 for Enterprise Server",
172
- "secret": false,
173
- "password": false,
174
- "default": null,
175
- "required": true
176
- },
177
- {
178
- "name": "owner",
179
- "description": "Default owner (user or org)",
180
- "secret": false,
181
- "password": false,
182
- "default": null,
183
- "required": false
184
- },
185
- {
186
- "name": "repo",
187
- "description": "Default repository name",
188
- "secret": false,
189
- "password": false,
190
- "default": null,
191
- "required": false
192
- },
193
- {
194
- "name": "targetBranch",
195
- "description": "Default base branch for pr create (main when unset)",
196
- "secret": false,
197
- "password": false,
198
- "default": null,
199
- "required": false
200
- },
201
- {
202
- "name": "token",
203
- "description": "Fine-grained personal access token",
204
- "secret": true,
205
- "password": false,
206
- "default": null,
207
- "required": true
208
- }
209
- ]
210
- },
211
- {
212
- "name": "jenkins",
213
- "description": "Jenkins: jobs, builds, console logs and the build queue",
214
- "connection": [
215
- {
216
- "name": "baseUrl",
217
- "description": "Jenkins server root, e.g. https://jenkins.imagile.dev",
218
- "secret": false,
219
- "password": false,
220
- "default": null,
221
- "required": true
222
- },
223
- {
224
- "name": "username",
225
- "description": "Jenkins user name the API token belongs to",
226
- "secret": false,
227
- "password": false,
228
- "default": null,
229
- "required": true
230
- },
231
- {
232
- "name": "instance",
233
- "description": "The name --instance selects this connection by, when it isn't the connection's own name",
234
- "secret": false,
235
- "password": false,
236
- "default": null,
237
- "required": false
238
- },
239
- {
240
- "name": "apiToken",
241
- "description": "Jenkins API token",
242
- "secret": true,
243
- "password": false,
244
- "default": null,
245
- "required": true
246
- }
247
- ]
248
- },
249
- {
250
- "name": "jira",
251
- "description": "Jira Data Center: issues, search, transitions, comments, worklogs, attachments, custom fields, boards and sprints",
252
- "connection": [
253
- {
254
- "name": "baseUrl",
255
- "description": "Jira server root, e.g. https://jira.imagile.dev",
256
- "secret": false,
257
- "password": false,
258
- "default": null,
259
- "required": true
260
- },
261
- {
262
- "name": "customFields",
263
- "description": "Custom fields addressable by friendly name",
264
- "secret": false,
265
- "password": false,
266
- "default": null,
267
- "required": false
268
- },
269
- {
270
- "name": "project",
271
- "description": "Default project key for issue create",
272
- "secret": false,
273
- "password": false,
274
- "default": null,
275
- "required": false
276
- },
277
- {
278
- "name": "issueType",
279
- "description": "Default issue type for issue create (Task when unset)",
280
- "secret": false,
281
- "password": false,
282
- "default": null,
283
- "required": false
284
- },
285
- {
286
- "name": "priority",
287
- "description": "Default priority for issue create",
288
- "secret": false,
289
- "password": false,
290
- "default": null,
291
- "required": false
292
- },
293
- {
294
- "name": "apiToken",
295
- "description": "Personal access token",
296
- "secret": true,
297
- "password": false,
298
- "default": null,
299
- "required": true
300
- }
301
- ]
302
- },
303
- {
304
- "name": "openshift",
305
- "description": "OpenShift and Kubernetes: pods, deployments, events, logs and resource usage",
306
- "connection": [
307
- {
308
- "name": "baseUrl",
309
- "description": "API server URL, e.g. https://openshift.imagile.dev",
310
- "secret": false,
311
- "password": false,
312
- "default": null,
313
- "required": false
314
- },
315
- {
316
- "name": "env",
317
- "description": "Environment name that --env selects this cluster by, e.g. prod",
318
- "secret": false,
319
- "password": false,
320
- "default": null,
321
- "required": false
322
- },
323
- {
324
- "name": "instance",
325
- "description": "Cluster instance name within the environment that --instance selects this cluster by, e.g. east",
326
- "secret": false,
327
- "password": false,
328
- "default": null,
329
- "required": false
330
- },
331
- {
332
- "name": "token",
333
- "description": "Bearer token, typically a service account token",
334
- "secret": true,
335
- "password": false,
336
- "default": null,
337
- "required": false
338
- }
339
- ]
340
- }
341
- ];
49
+ var config_areas_default = /*#__PURE__*/ JSON.parse("[{\"name\":\"ado\",\"description\":\"Azure DevOps Server and Azure DevOps Services: work items, boards, sprints, repositories, pull requests and pipelines\",\"connection\":[{\"name\":\"baseUrl\",\"description\":\"Server: the root, e.g. https://ado.imagile.dev (keep any /tfs prefix). Services: the organization URL, https://dev.azure.com/<organization> (or https://<organization>.visualstudio.com)\",\"secret\":false,\"password\":false,\"default\":null,\"required\":true},{\"name\":\"deployment\",\"description\":\"Which Azure DevOps this is: \\\"server\\\" for Azure DevOps Server (the default), or \\\"cloud\\\" for Azure DevOps Services\",\"secret\":false,\"password\":false,\"default\":\"server\",\"required\":false},{\"name\":\"collection\",\"description\":\"Server only: default collection, when --collection isn't given\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"project\",\"description\":\"Default team project, when --project isn't given\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"repo\",\"description\":\"Default git repository, when --repo isn't given\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"team\",\"description\":\"Services only: default team for the board, backlog and sprint commands, when --team isn't given (else the project's default team)\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"fieldAliases\",\"description\":\"Work item field aliases, friendly name to reference name (e.g. {\\\"storypoints\\\": \\\"Microsoft.VSTS.Scheduling.StoryPoints\\\"})\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"discoveredFields\",\"description\":\"Server only: work item fields recorded by an earlier discovery; kept, not read\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"discoveredTypes\",\"description\":\"Server only: work item types recorded by an earlier discovery; kept, not read\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"pat\",\"description\":\"Personal access token. Services: an organization-scoped one\",\"secret\":true,\"password\":false,\"default\":null,\"required\":true}]},{\"name\":\"bitbucket\",\"description\":\"Bitbucket Data Center and Bitbucket Cloud: repositories, branches, tags, commits, files, pull requests, comments, reviewers, build statuses and Pipelines\",\"connection\":[{\"name\":\"baseUrl\",\"description\":\"Bitbucket root: the Data Center server (https://bitbucket.imagile.dev), or the Cloud REST API root (https://api.bitbucket.org/2.0)\",\"secret\":false,\"password\":false,\"default\":null,\"required\":true},{\"name\":\"deployment\",\"description\":\"Which Bitbucket this is: \\\"server\\\" for Data Center (the default), or \\\"cloud\\\" for Bitbucket Cloud\",\"secret\":false,\"password\":false,\"default\":\"server\",\"required\":false},{\"name\":\"email\",\"description\":\"Bitbucket Cloud only: the email address of the Atlassian account an API token belongs to (with apiToken)\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"project\",\"description\":\"Data Center: default project key\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"workspace\",\"description\":\"Bitbucket Cloud: default workspace slug\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"repo\",\"description\":\"Default repository slug\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"targetBranch\",\"description\":\"Data Center: default target branch for pr create (main when unset)\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"pat\",\"description\":\"Data Center: an HTTP access token\",\"secret\":true,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"apiToken\",\"description\":\"Bitbucket Cloud only: an Atlassian API token with Bitbucket scopes, sent as Basic auth with email\",\"secret\":true,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"accessToken\",\"description\":\"Bitbucket Cloud only: a workspace, project or repository access token, sent as Bearer\",\"secret\":true,\"password\":false,\"default\":null,\"required\":false}]},{\"name\":\"github\",\"description\":\"GitHub and GitHub Enterprise Server: pull requests, reviews, comments, checks, labels, assignees, issues and projects\",\"connection\":[{\"name\":\"baseUrl\",\"description\":\"REST API root: https://api.github.com, or https://ghe.imagile.dev/api/v3 for Enterprise Server\",\"secret\":false,\"password\":false,\"default\":null,\"required\":true},{\"name\":\"owner\",\"description\":\"Default owner (user or org)\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"repo\",\"description\":\"Default repository name\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"targetBranch\",\"description\":\"Default base branch for pr create (main when unset)\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"token\",\"description\":\"Fine-grained personal access token\",\"secret\":true,\"password\":false,\"default\":null,\"required\":true}]},{\"name\":\"jenkins\",\"description\":\"Jenkins: jobs, builds, console logs and the build queue\",\"connection\":[{\"name\":\"baseUrl\",\"description\":\"Jenkins server root, e.g. https://jenkins.imagile.dev\",\"secret\":false,\"password\":false,\"default\":null,\"required\":true},{\"name\":\"username\",\"description\":\"Jenkins user name the API token belongs to\",\"secret\":false,\"password\":false,\"default\":null,\"required\":true},{\"name\":\"instance\",\"description\":\"The name --instance selects this connection by, when it isn't the connection's own name\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"apiToken\",\"description\":\"Jenkins API token\",\"secret\":true,\"password\":false,\"default\":null,\"required\":true}]},{\"name\":\"jira\",\"description\":\"Jira Data Center and Jira Cloud: issues, JQL search, transitions, comments, worklogs, attachments, custom fields, projects, users, boards and sprints\",\"connection\":[{\"name\":\"baseUrl\",\"description\":\"Jira root: the Data Center server (https://jira.imagile.dev), or the Cloud site (https://<your-site>.atlassian.net)\",\"secret\":false,\"password\":false,\"default\":null,\"required\":true},{\"name\":\"deployment\",\"description\":\"Which Jira this is: \\\"server\\\" for Data Center (the default), or \\\"cloud\\\" for Jira Cloud\",\"secret\":false,\"password\":false,\"default\":\"server\",\"required\":false},{\"name\":\"email\",\"description\":\"Jira Cloud only: the email address of the Atlassian account the API token belongs to\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"customFields\",\"description\":\"Custom fields addressable by friendly name\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"project\",\"description\":\"Default project key for issue create\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"issueType\",\"description\":\"Default issue type for issue create (Task when unset)\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"priority\",\"description\":\"Default priority for issue create\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"apiToken\",\"description\":\"Data Center: a personal access token. Cloud: an Atlassian account API token\",\"secret\":true,\"password\":false,\"default\":null,\"required\":true}]},{\"name\":\"openshift\",\"description\":\"OpenShift and Kubernetes: pods, deployments, events, logs and resource usage\",\"connection\":[{\"name\":\"baseUrl\",\"description\":\"API server URL, e.g. https://openshift.imagile.dev\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"env\",\"description\":\"Environment name that --env selects this cluster by, e.g. prod\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"instance\",\"description\":\"Cluster instance name within the environment that --instance selects this cluster by, e.g. east\",\"secret\":false,\"password\":false,\"default\":null,\"required\":false},{\"name\":\"token\",\"description\":\"Bearer token, typically a service account token\",\"secret\":true,\"password\":false,\"default\":null,\"required\":false}]}]");
342
50
  //#endregion
343
51
  //#region src/fixtures/dossiers.ts
344
52
  var DOSSIERS$1 = [
@@ -436,7 +144,7 @@ var DOSSIERS$1 = [
436
144
  ].join("\n")]
437
145
  }
438
146
  },
439
- "bitbucket-cloud": {
147
+ bitbucket: {
440
148
  connection: "bitbucket-cloud",
441
149
  workspace: "imagile",
442
150
  repo: "checkout-sdk"
@@ -456,7 +164,7 @@ var DOSSIERS$1 = [
456
164
  name: "Ada D.",
457
165
  ids: {
458
166
  github: "ada-dev",
459
- "bitbucket-cloud": "557058:abc12345-0000-0000-0000-000000000020"
167
+ bitbucket: "557058:abc12345-0000-0000-0000-000000000020"
460
168
  }
461
169
  },
462
170
  {
@@ -477,8 +185,11 @@ var fileOf = (name) => `${USER_DIR}/${name}.json`;
477
185
  /** Each area's context inputs, as `dossiers show` resolves them: the ones the registry declares, nothing else. */
478
186
  var CONTEXT = {
479
187
  jira: ["project"],
480
- bitbucket: ["project", "repo"],
481
- "bitbucket-cloud": ["workspace", "repo"],
188
+ bitbucket: [
189
+ "project",
190
+ "workspace",
191
+ "repo"
192
+ ],
482
193
  jenkins: ["instance"],
483
194
  ado: [
484
195
  "collection",
@@ -551,9 +262,95 @@ function listData() {
551
262
  };
552
263
  }
553
264
  //#endregion
265
+ //#region src/ado-revisions.ts
266
+ var isRec$6 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
267
+ var DAY$7 = 864e5;
268
+ /** The fields of a revision that `mapOwi` reads (adoHistory): the revision's `rev` is the feed's own, the rest are asked for by name. */
269
+ var ADO_FEED_FIELDS = "System.Rev,System.ChangedDate,System.ChangedBy,System.State,System.IterationPath";
270
+ /** `Name <email>`: the text form of an identity in the feed. */
271
+ var NAMED = /^.+<[^<>]+>$/;
272
+ /**
273
+ * The instant the feed is asked to start at: a day before the window opens, so
274
+ * it covers WIQL's `@Today - n`, which counts from the start of today.
275
+ */
276
+ var feedStart = (now, windowDays) => (/* @__PURE__ */ new Date(now.getTime() - (windowDays + 1) * DAY$7)).toISOString();
277
+ /** The revisions of one item as `work-item history` lists them, if the feed has exactly revisions 1 to `rev`. */
278
+ function wholeRevisions(revisions, rev) {
279
+ if (!revisions?.length || typeof rev !== "number" || !Number.isInteger(rev) || rev < 1 || revisions.length !== rev) return null;
280
+ const sorted = [...revisions].sort((a, b) => Number(a.rev) - Number(b.rev));
281
+ for (const [n, r] of sorted.entries()) {
282
+ if (r.rev !== n + 1 || !isRec$6(r.fields)) return null;
283
+ if (typeof r.fields["System.ChangedDate"] !== "string") return null;
284
+ const by = r.fields["System.ChangedBy"];
285
+ if (typeof by === "string" && !NAMED.test(by)) return null;
286
+ }
287
+ return sorted;
288
+ }
289
+ /**
290
+ * The feed split into what `mapOwi` has always been given. `items` are the
291
+ * work items `get-many` returned (each with its `id` and `rev`), `historyCommand`
292
+ * names the command the envelopes stand in for, and `iterationOverride` is the
293
+ * dossier's own iteration field, when it sets one: any such field sends every
294
+ * item to `work-item history`.
295
+ */
296
+ function splitRevisionFeed(feed, items, historyCommand, iterationOverride) {
297
+ const ids = items.map((i) => Number(i.id)).filter(Number.isFinite);
298
+ if (!feed || !feed.ok || !Array.isArray(feed.data) || iterationOverride !== void 0) return {
299
+ histories: [],
300
+ incomplete: ids
301
+ };
302
+ const byItem = /* @__PURE__ */ new Map();
303
+ for (const r of feed.data) {
304
+ if (!isRec$6(r) || typeof r.id !== "number") continue;
305
+ const list = byItem.get(r.id);
306
+ if (list) list.push(r);
307
+ else byItem.set(r.id, [r]);
308
+ }
309
+ const meta = {
310
+ ...feed.meta,
311
+ command: historyCommand
312
+ };
313
+ delete meta.page;
314
+ delete meta.warnings;
315
+ const histories = [];
316
+ const incomplete = [];
317
+ for (const item of items) {
318
+ const id = Number(item.id);
319
+ const whole = wholeRevisions(byItem.get(id), item.rev);
320
+ if (whole === null) incomplete.push(id);
321
+ else histories.push({
322
+ ok: true,
323
+ data: whole,
324
+ error: null,
325
+ meta
326
+ });
327
+ }
328
+ return {
329
+ histories,
330
+ incomplete
331
+ };
332
+ }
333
+ /** The key a revision is known by: an item's revision numbers never repeat. */
334
+ var revisionKey = (r) => `${r.id}@${r.rev}`;
335
+ /**
336
+ * The cached feed with a delta read from a watermark laid over it, by item and
337
+ * revision number (a revision read twice, as the watermark's margin makes
338
+ * likely, is kept once, the newer copy). `keep`, when given, drops the items
339
+ * the sync no longer lists, so the cached feed stays the size of the window.
340
+ * The merged feed is whole where `splitRevisionFeed` can tell: it sees the same
341
+ * run of 1 to `rev` or it reads the item with `work-item history`.
342
+ */
343
+ function mergeFeed(cached, fresh, keep) {
344
+ const byKey = /* @__PURE__ */ new Map();
345
+ for (const r of cached) byKey.set(revisionKey(r), r);
346
+ for (const r of fresh) byKey.set(revisionKey(r), r);
347
+ const all = [...byKey.values()];
348
+ return keep ? all.filter((r) => keep.has(Number(r.id))) : all;
349
+ }
350
+ //#endregion
554
351
  //#region src/model/delivery.ts
555
- var isRec$4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
556
- var recs$2 = (v) => Array.isArray(v) ? v.filter(isRec$4) : [];
352
+ var isRec$5 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
353
+ var recs$2 = (v) => Array.isArray(v) ? v.filter(isRec$5) : [];
557
354
  var str$2 = (v) => typeof v === "string" && v !== "" ? v : null;
558
355
  /** An instant as ISO 8601, or '' (shown as unknown) when it's missing or unparsable: one bad date stays on its own row. */
559
356
  var iso = (v) => {
@@ -561,8 +358,8 @@ var iso = (v) => {
561
358
  const t = new Date(v).getTime();
562
359
  return Number.isNaN(t) ? "" : new Date(t).toISOString();
563
360
  };
564
- /** A source's family, as the panels name it: `bitbucket-cloud` is Bitbucket, `ado-cloud` Azure DevOps. */
565
- var family$1 = (area) => area.split("-")[0];
361
+ /** A source's family, as the panels name it: an area's first word (`github`, `ado`). */
362
+ var family = (area) => area.split("-")[0];
566
363
  /**
567
364
  * A pull request's `ChangeRef`, made from its OWI change: the work items it
568
365
  * names that the dossier's own queries returned, its state, and the time the
@@ -574,7 +371,7 @@ function changeRef(c, byId) {
574
371
  return {
575
372
  id: c.id,
576
373
  kind: "pull-request",
577
- source: family$1(c.source.area),
374
+ source: family(c.source.area),
578
375
  command: c.source.command,
579
376
  items: c.workItems.filter((id) => byId.has(id)),
580
377
  title: c.title,
@@ -616,12 +413,12 @@ function jenkinsBuilds(data, connection, job, pr) {
616
413
  /** Azure Pipelines CI runs, each joined to its pull request by `triggerInfo["pr.number"]` or a `refs/pull/<id>/merge` branch. */
617
414
  function adoBuilds(data, connection, prs) {
618
415
  return recs$2(data).flatMap((run) => {
619
- const number = (isRec$4(run.triggerInfo) ? str$2(run.triggerInfo["pr.number"]) : null) ?? /^refs\/pull\/(\d+)\/merge$/.exec(str$2(run.sourceBranch) ?? "")?.[1];
416
+ const number = (isRec$5(run.triggerInfo) ? str$2(run.triggerInfo["pr.number"]) : null) ?? /^refs\/pull\/(\d+)\/merge$/.exec(str$2(run.sourceBranch) ?? "")?.[1];
620
417
  const pr = number ? prs.find((p) => p.id.endsWith(`#${number}`)) : void 0;
621
418
  if (!pr) return [];
622
419
  const status = str$2(run.status);
623
420
  const result = str$2(run.result);
624
- const definition = isRec$4(run.definition) ? str$2(run.definition.name) : null;
421
+ const definition = isRec$5(run.definition) ? str$2(run.definition.name) : null;
625
422
  return [{
626
423
  id: `${connection}:build#${run.id}`,
627
424
  kind: "build",
@@ -629,7 +426,7 @@ function adoBuilds(data, connection, prs) {
629
426
  command: "ado run list",
630
427
  items: pr.items,
631
428
  title: `${definition ?? "build"} ${run.buildNumber}`,
632
- url: isRec$4(run._links) && isRec$4(run._links.web) ? str$2(run._links.web.href) : null,
429
+ url: isRec$5(run._links) && isRec$5(run._links.web) ? str$2(run._links.web.href) : null,
633
430
  state: status === "completed" ? result ?? "completed" : status ?? "unknown",
634
431
  outcome: status !== "completed" ? "running" : result === "succeeded" ? "passed" : "failed",
635
432
  builds: pr.id,
@@ -687,7 +484,7 @@ function included$1(commit, prs) {
687
484
  var IMAGE_TAG = /:(?:(.+)-)?([0-9a-f]{7,40})$/;
688
485
  /** An OpenShift namespace's Deployments for the dossier's repositories, by the commit in each image tag. */
689
486
  function openshiftDeployments(data, environment, repos, prs) {
690
- const body = isRec$4(data) ? data : {};
487
+ const body = isRec$5(data) ? data : {};
691
488
  return recs$2(body.deployments).filter((d) => repos.includes(String(d.name))).map((d) => {
692
489
  const image = str$2(recs$2(d.images)[0]?.image) ?? "";
693
490
  const [, version, commit] = IMAGE_TAG.exec(image) ?? [];
@@ -710,7 +507,7 @@ function openshiftDeployments(data, environment, repos, prs) {
710
507
  }
711
508
  /** Azure Pipelines deploy runs: the newest successful run per `templateParameters.environment`. */
712
509
  function adoDeployments(data, connection, prs) {
713
- const runs = recs$2(data).filter((r) => r.status === "completed" && r.result === "succeeded" && isRec$4(r.templateParameters) && str$2(r.templateParameters.environment)).sort((a, b) => iso(a.finishTime) < iso(b.finishTime) ? 1 : -1);
510
+ const runs = recs$2(data).filter((r) => r.status === "completed" && r.result === "succeeded" && isRec$5(r.templateParameters) && str$2(r.templateParameters.environment)).sort((a, b) => iso(a.finishTime) < iso(b.finishTime) ? 1 : -1);
714
511
  const seen = /* @__PURE__ */ new Set();
715
512
  const out = [];
716
513
  for (const run of runs) {
@@ -723,12 +520,12 @@ function adoDeployments(data, connection, prs) {
723
520
  environment,
724
521
  source: "ado",
725
522
  command: "ado run list",
726
- name: `${isRec$4(run.definition) ? str$2(run.definition.name) : "deploy"} ${run.buildNumber}`,
523
+ name: `${isRec$5(run.definition) ? str$2(run.definition.name) : "deploy"} ${run.buildNumber}`,
727
524
  commit: commit.slice(0, 7),
728
525
  version: null,
729
526
  state: String(run.result),
730
527
  outcome: "passed",
731
- url: isRec$4(run._links) && isRec$4(run._links.web) ? str$2(run._links.web.href) : null,
528
+ url: isRec$5(run._links) && isRec$5(run._links.web) ? str$2(run._links.web.href) : null,
732
529
  ...included$1(commit, prs)
733
530
  });
734
531
  }
@@ -745,8 +542,76 @@ var byEnvironment = (a, b) => {
745
542
  return rank(a.environment) - rank(b.environment) || a.environment.localeCompare(b.environment);
746
543
  };
747
544
  //#endregion
545
+ //#region src/jira-changelog.ts
546
+ var isRec$4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
547
+ /** The entries of one issue's inline changelog, if Jira sent all of them. */
548
+ function wholeHistories(changelog) {
549
+ if (!isRec$4(changelog) || !Array.isArray(changelog.histories)) return null;
550
+ const histories = changelog.histories.filter(isRec$4);
551
+ if (typeof changelog.total !== "number" || changelog.total !== histories.length) return null;
552
+ if (typeof changelog.maxResults !== "number" || histories.length >= changelog.maxResults) return null;
553
+ return histories;
554
+ }
555
+ /**
556
+ * `issue history` lists entries oldest first, on both deployments. Cloud's
557
+ * search sends them newest first (Data Center's order is undocumented,
558
+ * docs/decisions/493-jira-changelog.md), so a list that runs newest first is
559
+ * turned round, which gives `mapOwi` the entries in the order
560
+ * `issue history` would have. A list already oldest first is left alone.
561
+ */
562
+ function oldestFirst(histories) {
563
+ const at = (h) => Date.parse(String(h?.created ?? "").replace(/([+-]\d{2})(\d{2})$/, "$1:$2"));
564
+ const first = at(histories[0]);
565
+ const last = at(histories[histories.length - 1]);
566
+ return Number.isFinite(first) && Number.isFinite(last) && first > last ? [...histories].reverse() : histories;
567
+ }
568
+ function splitChangelogs(search, historyCommand) {
569
+ const data = search.data;
570
+ if (!search.ok || !isRec$4(data) || !Array.isArray(data.issues)) return {
571
+ search,
572
+ histories: [],
573
+ incomplete: []
574
+ };
575
+ const histories = [];
576
+ const incomplete = [];
577
+ const meta = {
578
+ ...search.meta,
579
+ command: historyCommand
580
+ };
581
+ delete meta.page;
582
+ delete meta.warnings;
583
+ const issues = data.issues.map((issue) => {
584
+ if (!isRec$4(issue)) return issue;
585
+ const { changelog, ...rest } = issue;
586
+ const key = String(issue.key);
587
+ const whole = wholeHistories(changelog);
588
+ if (whole === null) incomplete.push(key);
589
+ else histories.push({
590
+ key,
591
+ history: {
592
+ ok: true,
593
+ data: oldestFirst(whole),
594
+ error: null,
595
+ meta
596
+ }
597
+ });
598
+ return rest;
599
+ });
600
+ return {
601
+ search: {
602
+ ...search,
603
+ data: {
604
+ ...data,
605
+ issues
606
+ }
607
+ },
608
+ histories,
609
+ incomplete
610
+ };
611
+ }
612
+ //#endregion
748
613
  //#region src/model/flow.ts
749
- var DAY$5 = 864e5;
614
+ var DAY$6 = 864e5;
750
615
  /**
751
616
  * Work that flows: not an epic, feature or other container. An item with no
752
617
  * type at all (a GitHub issue in a repository without issue types) is work,
@@ -763,7 +628,7 @@ function percentile(values, p) {
763
628
  function weekStart(iso) {
764
629
  const t = Date.parse(iso);
765
630
  const day = new Date(t).getUTCDay();
766
- const monday = Math.floor(t / DAY$5) * DAY$5 - (day + 6) % 7 * DAY$5;
631
+ const monday = Math.floor(t / DAY$6) * DAY$6 - (day + 6) % 7 * DAY$6;
767
632
  return new Date(monday).toISOString();
768
633
  }
769
634
  new Intl.DateTimeFormat("en-GB", {
@@ -782,9 +647,15 @@ new Intl.DateTimeFormat("en-GB", {
782
647
  timeZone: "UTC"
783
648
  });
784
649
  //#endregion
785
- //#region src/model/prs.ts
786
- var DAY$4 = 864e5;
787
- var WEEK = 7 * DAY$4;
650
+ //#region ../src/core/brief/time.ts
651
+ /**
652
+ * The clock arithmetic the briefing and Toil UI share. Time waiting on a
653
+ * review is counted in working days, Monday to Friday UTC, since nobody
654
+ * reviews at the weekend except the people who say they don't. Moved here
655
+ * from Toil UI (#494) so toil's briefing and Toil UI's pull request page
656
+ * count the same days.
657
+ */
658
+ var DAY$5 = 864e5;
788
659
  /** Working days between two instants, Monday to Friday UTC, to the fraction of a day. */
789
660
  function workingDays(from, to) {
790
661
  let a = Date.parse(from);
@@ -792,13 +663,92 @@ function workingDays(from, to) {
792
663
  if (!(b > a)) return 0;
793
664
  let n = 0;
794
665
  while (a < b) {
795
- const end = Math.min(b, (Math.floor(a / DAY$4) + 1) * DAY$4);
666
+ const end = Math.min(b, (Math.floor(a / DAY$5) + 1) * DAY$5);
796
667
  const d = new Date(a).getUTCDay();
797
- if (d !== 0 && d !== 6) n += (end - a) / DAY$4;
668
+ if (d !== 0 && d !== 6) n += (end - a) / DAY$5;
798
669
  a = end;
799
670
  }
800
671
  return n;
801
672
  }
673
+ var LENS = new Map([
674
+ {
675
+ id: "failing",
676
+ label: "Failing checks",
677
+ severity: "danger",
678
+ unit: "hours",
679
+ threshold: 24,
680
+ on: true,
681
+ test: (t) => `checks on an open pull request for an open item have failed for more than ${t} hours`
682
+ },
683
+ {
684
+ id: "blocked",
685
+ label: "Blocked",
686
+ severity: "danger",
687
+ unit: null,
688
+ threshold: null,
689
+ on: true,
690
+ test: () => "an open item waits on another open item"
691
+ },
692
+ {
693
+ id: "waiting",
694
+ label: "Waiting on review",
695
+ severity: "warn",
696
+ unit: "working days",
697
+ threshold: 2,
698
+ on: true,
699
+ test: (t) => `an open pull request has had no first review for more than ${t} working days`
700
+ },
701
+ {
702
+ id: "sprint",
703
+ label: "Sprint at risk",
704
+ severity: "warn",
705
+ unit: null,
706
+ threshold: null,
707
+ on: true,
708
+ test: () => "at the pace so far, the current sprint won't finish the points in it"
709
+ },
710
+ {
711
+ id: "stale",
712
+ label: "Stale",
713
+ severity: "warn",
714
+ unit: "days",
715
+ threshold: 5,
716
+ on: true,
717
+ test: (t) => `an item in progress has had no update for more than ${t} days`
718
+ },
719
+ {
720
+ id: "load",
721
+ label: "Over the WIP limit",
722
+ severity: "warn",
723
+ unit: null,
724
+ threshold: null,
725
+ on: true,
726
+ test: (_t, wip) => `someone has more than ${wip ?? "the dossier's WIP limit of"} items in progress (describe load, never rank people)`
727
+ },
728
+ {
729
+ id: "drift",
730
+ label: "Ticket and pull request disagree",
731
+ severity: "warn",
732
+ unit: null,
733
+ threshold: null,
734
+ on: true,
735
+ test: () => "an item is done while its pull request is open, or its pull request merged while the item is still open"
736
+ },
737
+ {
738
+ id: "ready",
739
+ label: "Not ready",
740
+ severity: "warn",
741
+ unit: null,
742
+ threshold: null,
743
+ on: false,
744
+ test: () => "the next item in line fails the readiness checks"
745
+ }
746
+ ].map((l) => [l.id, l]));
747
+ var lensDef = (id) => LENS.get(id);
748
+ //#endregion
749
+ //#region src/model/prs.ts
750
+ var DAY$4 = 864e5;
751
+ var WEEK = 7 * DAY$4;
802
752
  var isOpen$1 = (c) => c.state === "OPEN" || c.state === "DRAFT";
803
753
  var round1$2 = (n) => Math.round(n * 10) / 10;
804
754
  var daysText = (n) => `${round1$2(n)} working ${round1$2(n) === 1 ? "day" : "days"}`;
@@ -850,8 +800,12 @@ function sizeOf(c) {
850
800
  files: c.size?.files ?? null
851
801
  };
852
802
  }
803
+ /** Working days a pull request may wait for its first review before it is flagged. */
804
+ var PICKUP_DAYS = lensDef("waiting").threshold;
805
+ /** Hours checks may fail before it is flagged. */
806
+ var FAILING_HOURS = lensDef("failing").threshold;
853
807
  var PR_FLAG_LABEL = {
854
- "slow-pickup": `No first review in 2 working days`,
808
+ "slow-pickup": `No first review in ${PICKUP_DAYS} working days`,
855
809
  "failing-checks": "Checks failing for over a day",
856
810
  conflict: "Merge conflict",
857
811
  "no-work-item": "No linked work item",
@@ -865,13 +819,13 @@ function flagsOf(c, byId, now) {
865
819
  const items = linked(c, byId).map((id) => byId.get(id));
866
820
  if (c.state === "OPEN") {
867
821
  const waited = c.created ? workingDays(c.created, c.firstReviewAt ?? now) : null;
868
- if (!c.firstReviewAt && waited !== null && waited > 2) out.push({
822
+ if (!c.firstReviewAt && waited !== null && waited > PICKUP_DAYS) out.push({
869
823
  flag: "slow-pickup",
870
824
  text: `Open ${daysText(waited)} with no review yet.`
871
825
  });
872
826
  }
873
827
  if (isOpen$1(c)) {
874
- if (c.checks === "FAILING" && c.checksAt && Date.parse(now) - Date.parse(c.checksAt) > 864e5) out.push({
828
+ if (c.checks === "FAILING" && c.checksAt && Date.parse(now) - Date.parse(c.checksAt) > FAILING_HOURS * 36e5) out.push({
875
829
  flag: "failing-checks",
876
830
  text: `Failing since ${c.checksAt.slice(0, 16).replace("T", " ")} UTC, ${round1$2((Date.parse(now) - Date.parse(c.checksAt)) / DAY$4)} days.`
877
831
  });
@@ -1157,11 +1111,9 @@ function readPeople(dossier) {
1157
1111
  }
1158
1112
  var identityKey = (area, id) => `${area}\u0000${lower$1(id)}`;
1159
1113
  var keyOf$2 = (i) => identityKey(i.area, i.id);
1160
- /** `jira-cloud` is a Jira, `ado-cloud` an Azure DevOps: a person's `jira` identity applies to both unless the dossier names the variant. */
1161
- var family = (area) => area.replace(/-cloud$/, "");
1162
- /** The identity a person has in an area: the area's own entry, else its family's. */
1114
+ /** The identity a person has in an area: their entry for that area. */
1163
1115
  function idIn(person, area) {
1164
- return person.ids[area] ?? (family(area) !== area ? person.ids[family(area)] : void 0);
1116
+ return person.ids[area];
1165
1117
  }
1166
1118
  /** Whether a person is this account: their identity for its area is the account's id or its email. */
1167
1119
  function isPerson(person, who) {
@@ -1314,7 +1266,7 @@ function people(input) {
1314
1266
  const owner = (i) => entries.find((e) => isPerson(e, i));
1315
1267
  const peopleCards = entries.map((e) => {
1316
1268
  const found = [...seen.values()].filter((i) => isPerson(e, i));
1317
- const named = Object.entries(e.ids).filter(([area, id]) => !found.some((f) => family(f.area) === family(area) && (lower$1(f.id) === lower$1(id) || lower$1(f.email) === lower$1(id)))).map(([area, id]) => ({
1269
+ const named = Object.entries(e.ids).filter(([area, id]) => !found.some((f) => f.area === area && (lower$1(f.id) === lower$1(id) || lower$1(f.email) === lower$1(id)))).map(([area, id]) => ({
1318
1270
  area,
1319
1271
  id,
1320
1272
  name: null,
@@ -1723,31 +1675,27 @@ function tally(list) {
1723
1675
  //#endregion
1724
1676
  //#region ../src/core/owi/types.ts
1725
1677
  var PRS = ["pr list", "pr get"];
1726
- var JIRA$1 = {
1727
- family: "jira",
1728
- items: ["issue search", "issue get"],
1729
- history: ["issue history"],
1730
- context: [],
1731
- changes: []
1732
- };
1733
- var ADO$4 = {
1734
- family: "ado",
1735
- items: ["work-item get", "work-item get-many"],
1736
- history: ["work-item history"],
1737
- context: ["work-item iterations"],
1738
- changes: PRS
1739
- };
1740
1678
  /**
1741
1679
  * The areas toil maps to OWI. An area that sends one of these shapes is one
1742
- * line here: Data Center and Cloud variants share their family's mapper
1743
- * (`jira-cloud`, `ado-cloud`) where their shapes agree, and have their own
1744
- * where they don't (`bitbucket-cloud`).
1680
+ * line here: `jira` and `ado` serve both their deployments from one mapper, and
1681
+ * `bitbucket` has one per deployment (its connection's deployment picks, since
1682
+ * their shapes differ in almost every field).
1745
1683
  */
1746
1684
  var OWI_SOURCES = {
1747
- jira: JIRA$1,
1748
- "jira-cloud": JIRA$1,
1749
- ado: ADO$4,
1750
- "ado-cloud": ADO$4,
1685
+ jira: {
1686
+ family: "jira",
1687
+ items: ["issue search", "issue get"],
1688
+ history: ["issue history"],
1689
+ context: [],
1690
+ changes: []
1691
+ },
1692
+ ado: {
1693
+ family: "ado",
1694
+ items: ["work-item get", "work-item get-many"],
1695
+ history: ["work-item history"],
1696
+ context: ["work-item iterations"],
1697
+ changes: PRS
1698
+ },
1751
1699
  github: {
1752
1700
  family: "github",
1753
1701
  items: [
@@ -1766,13 +1714,6 @@ var OWI_SOURCES = {
1766
1714
  history: [],
1767
1715
  context: [],
1768
1716
  changes: PRS
1769
- },
1770
- "bitbucket-cloud": {
1771
- family: "bitbucket-cloud",
1772
- items: [],
1773
- history: [],
1774
- context: [],
1775
- changes: PRS
1776
1717
  }
1777
1718
  };
1778
1719
  var OWI_AREAS = Object.keys(OWI_SOURCES);
@@ -1839,12 +1780,12 @@ var num = (value) => typeof value === "number" && Number.isFinite(value) ? value
1839
1780
  * object by its value, name, displayName or title, a list by its first such
1840
1781
  * entry. Null when none of those hold.
1841
1782
  */
1842
- function text$1(value) {
1783
+ function text$2(value) {
1843
1784
  if (typeof value === "string") return value === "" ? null : value;
1844
1785
  if (typeof value === "number" && Number.isFinite(value)) return String(value);
1845
1786
  if (Array.isArray(value)) {
1846
1787
  for (const entry of value) {
1847
- const found = text$1(entry);
1788
+ const found = text$2(entry);
1848
1789
  if (found !== null) return found;
1849
1790
  }
1850
1791
  return null;
@@ -1905,7 +1846,8 @@ function blank$1(doc, key, title, native) {
1905
1846
  area: doc.area,
1906
1847
  connection: doc.connection,
1907
1848
  key,
1908
- command: doc.command
1849
+ command: doc.command,
1850
+ ...doc.deployment === void 0 ? {} : { deployment: doc.deployment }
1909
1851
  },
1910
1852
  url: null,
1911
1853
  type: "OTHER",
@@ -2008,7 +1950,7 @@ var ADO_HOURS_FIELD = "Microsoft.VSTS.Scheduling.OriginalEstimate";
2008
1950
  * the table had missed it, as tables do. Resolved behaves like In Progress on boards,
2009
1951
  * so it is IN_PROGRESS here; Removed is out of the work, so DONE, with the
2010
1952
  * reason as its resolution. A custom state isn't here and is UNKNOWN, with a
2011
- * warning: `ado work-item states` (or `ado-cloud work-item states`) shows its category.
1953
+ * warning: `ado work-item states` shows its category.
2012
1954
  */
2013
1955
  var ADO_STATES$1 = {
2014
1956
  New: "TODO",
@@ -2109,7 +2051,7 @@ function adoItem$1(doc, record, state, dates) {
2109
2051
  else if (apiUrl?.includes("/_apis/") && project) item.url = `${apiUrl.slice(0, apiUrl.indexOf("/_apis/"))}/${encodeURIComponent(project)}/_workitems/edit/${key}`;
2110
2052
  else unmapped(item, "url", "the record has no html link and no System.TeamProject to build one from");
2111
2053
  const typeField = state.fields.type ?? "System.WorkItemType";
2112
- item.typeName = text$1(f[typeField]);
2054
+ item.typeName = text$2(f[typeField]);
2113
2055
  item.type = typeOf(item.typeName, { issue: "STORY" });
2114
2056
  if (!(typeField in f)) unmapped(item, "type", missing$1(typeField, state.fields.type !== void 0 && "type"));
2115
2057
  if (typeof f["System.Description"] === "string") item.body = {
@@ -2123,11 +2065,11 @@ function adoItem$1(doc, record, state, dates) {
2123
2065
  item.assignee = adoPerson(f["System.AssignedTo"]);
2124
2066
  item.reporter = adoPerson(f["System.CreatedBy"]);
2125
2067
  const priorityField = state.fields.priority ?? "Microsoft.VSTS.Common.Priority";
2126
- item.priority = text$1(f[priorityField]);
2068
+ item.priority = text$2(f[priorityField]);
2127
2069
  if (state.fields.priority !== void 0 && f[priorityField] === void 0) unmapped(item, "priority", missing$1(priorityField, "priority"));
2128
2070
  item.labels = typeof f["System.Tags"] === "string" ? f["System.Tags"].split(";").map((t) => t.trim()).filter(Boolean) : [];
2129
2071
  if (state.fields.team !== void 0) {
2130
- item.team = text$1(f[state.fields.team]);
2072
+ item.team = text$2(f[state.fields.team]);
2131
2073
  if (f[state.fields.team] === void 0) unmapped(item, "team", missing$1(state.fields.team, "team"));
2132
2074
  }
2133
2075
  estimate$1(item, f, state);
@@ -2262,7 +2204,8 @@ function blankChange(doc, repo, number, title, native) {
2262
2204
  area: doc.area,
2263
2205
  connection: doc.connection,
2264
2206
  key,
2265
- command: doc.command
2207
+ command: doc.command,
2208
+ ...doc.deployment === void 0 ? {} : { deployment: doc.deployment }
2266
2209
  },
2267
2210
  url: null,
2268
2211
  repo,
@@ -3443,7 +3386,7 @@ function githubChange(doc, pr, state) {
3443
3386
  //#endregion
3444
3387
  //#region ../src/core/owi/jira.ts
3445
3388
  /**
3446
- * Jira Data Center (`jira`) and Jira Cloud (`jira-cloud`) to OWI: the issues
3389
+ * Jira Data Center and Jira Cloud (both `jira`, by the connection's deployment) to OWI: the issues
3447
3390
  * `issue search` and `issue get` return, one key or several, and the history
3448
3391
  * `issue history` returns. Both variants send the same issue shape; Cloud
3449
3392
  * identifies people by accountId and writes the description as ADF.
@@ -3526,7 +3469,7 @@ function jiraItem(doc, issue, state, categories) {
3526
3469
  if (self?.includes("/rest/")) item.url = `${self.slice(0, self.indexOf("/rest/"))}/browse/${encodeURIComponent(key)}`;
3527
3470
  else unmapped(item, "url", "the record has no self link to take the site from");
3528
3471
  const typeField = state.fields.type;
3529
- const typeName = typeField === void 0 ? isRecord(f.issuetype) ? str$1(f.issuetype.name) : null : text$1(f[typeField]);
3472
+ const typeName = typeField === void 0 ? isRecord(f.issuetype) ? str$1(f.issuetype.name) : null : text$2(f[typeField]);
3530
3473
  if (typeField !== void 0 && !(typeField in f)) unmapped(item, "type", `the record has no field "${typeField}" (fields type)`);
3531
3474
  item.typeName = typeName;
3532
3475
  item.type = typeField === void 0 && isRecord(f.issuetype) && f.issuetype.subtask === true ? "TASK" : typeOf(typeName);
@@ -3549,11 +3492,11 @@ function jiraItem(doc, issue, state, categories) {
3549
3492
  item.assignee = jiraPerson(f.assignee);
3550
3493
  item.reporter = jiraPerson(f.reporter);
3551
3494
  const priorityField = state.fields.priority ?? "priority";
3552
- item.priority = text$1(f[priorityField]);
3495
+ item.priority = text$2(f[priorityField]);
3553
3496
  if (state.fields.priority !== void 0 && !(priorityField in f)) unmapped(item, "priority", `the record has no field "${priorityField}" (fields priority)`);
3554
3497
  item.labels = Array.isArray(f.labels) ? f.labels.filter((l) => typeof l === "string") : [];
3555
3498
  if (state.fields.team !== void 0) {
3556
- if (state.fields.team in f) item.team = text$1(f[state.fields.team]);
3499
+ if (state.fields.team in f) item.team = text$2(f[state.fields.team]);
3557
3500
  else unmapped(item, "team", `the record has no field "${state.fields.team}" (fields team)`);
3558
3501
  }
3559
3502
  estimate(item, issue, state);
@@ -3756,6 +3699,7 @@ function documentsFrom(values, options = {}) {
3756
3699
  let command;
3757
3700
  let data;
3758
3701
  let connection;
3702
+ let deployment;
3759
3703
  const inputs = {};
3760
3704
  if (isEnvelope(value)) {
3761
3705
  command = value.meta.command;
@@ -3771,6 +3715,7 @@ function documentsFrom(values, options = {}) {
3771
3715
  data = value.data;
3772
3716
  const context = isRecord(value.meta.context) ? value.meta.context : {};
3773
3717
  connection = isRecord(context.connection) ? str$1(context.connection.value) ?? void 0 : void 0;
3718
+ deployment = isRecord(context.connection) ? str$1(context.connection.deployment) ?? void 0 : void 0;
3774
3719
  if (isRecord(context.inputs)) {
3775
3720
  for (const [name, input] of Object.entries(context.inputs)) if (isRecord(input) && typeof input.value === "string") inputs[name] = input.value;
3776
3721
  }
@@ -3806,6 +3751,7 @@ function documentsFrom(values, options = {}) {
3806
3751
  area,
3807
3752
  command,
3808
3753
  connection: connection ?? area,
3754
+ ...deployment === void 0 ? {} : { deployment },
3809
3755
  data,
3810
3756
  inputs,
3811
3757
  at,
@@ -4031,8 +3977,8 @@ function mapOwi$2(documents, options = {}) {
4031
3977
  function mapChanges(docs, state, skipped) {
4032
3978
  const out = /* @__PURE__ */ new Map();
4033
3979
  for (const doc of docs) {
4034
- const family = OWI_SOURCES[doc.area].family;
4035
- const prs = family === "github" ? githubPrs(doc.data) : family === "ado" ? adoPrs(doc.data) : bitbucketPrs(doc.data);
3980
+ const known = OWI_SOURCES[doc.area].family;
3981
+ const prs = known === "github" ? githubPrs(doc.data) : known === "ado" ? adoPrs(doc.data) : bitbucketPrs(doc.data);
4036
3982
  if (!prs) {
4037
3983
  skipped.push({
4038
3984
  at: doc.at,
@@ -4042,7 +3988,9 @@ function mapChanges(docs, state, skipped) {
4042
3988
  continue;
4043
3989
  }
4044
3990
  for (const pr of prs) {
3991
+ const family = known === "bitbucket" && (doc.deployment === "cloud" || doc.deployment === void 0 && isRecord(pr.destination)) ? "bitbucket-cloud" : known;
4045
3992
  const change = family === "github" ? githubChange(doc, pr, state) : family === "ado" ? adoChange(doc, pr, state) : family === "bitbucket-cloud" ? bitbucketCloudChange(doc, pr, state) : bitbucketChange(doc, pr, state);
3993
+ if (change && family === "bitbucket-cloud" && change.source.deployment === void 0) change.source.deployment = "cloud";
4046
3994
  if (!change) {
4047
3995
  skipped.push({
4048
3996
  at: doc.at,
@@ -4808,17 +4756,90 @@ var CALL_OPTIONS = {
4808
4756
  * shown on its panel with toil's own message and fix (principle 4), never
4809
4757
  * dropped.
4810
4758
  *
4759
+ * Jira and Azure DevOps are asked for open items and what changed within a
4760
+ * window of days (windowFor), not the whole project, and the per-item calls
4761
+ * (histories, pull request gets) run through one pool of PER_ITEM_CONCURRENCY
4762
+ * across the dossier.
4763
+ *
4811
4764
  * Work items and pull requests go through `mapOwi` (src/owi.ts), pull
4812
4765
  * requests as OWI 0.2 changes: each code host's `pr list`, then `pr get
4813
4766
  * --include reviews,checks,commits,files` for every open one and the newest
4814
4767
  * closed ones. Builds and deployments go through src/model/delivery.ts. One
4815
4768
  * loader, one dossier, no spreadsheet.
4816
4769
  */
4817
- /** The JQL and WIQL a dashboard sends: one query per tracker, the whole project. */
4818
- var JQL = (project) => `project = ${project} ORDER BY Rank ASC`;
4819
- /** The areas that read Azure DevOps work items: Server and Services. */
4820
- var ADO_AREAS = ["ado", "ado-cloud"];
4821
- var WIQL = "SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @project ORDER BY [System.Id]";
4770
+ /**
4771
+ * How many days back of its last change a closed Jira or Azure DevOps item is
4772
+ * still read: the cache's retention period, but at least LOOKBACK_DAYS so the
4773
+ * longest view (six weeks of throughput) stays whole. The cache prunes by when
4774
+ * a row was last synced, not by when an item changed, so the window is a
4775
+ * choice: a closed item older than it isn't read and leaves every view. The
4776
+ * sync passes windowFor(retentionDays); a browser that doesn't says
4777
+ * DEFAULT_WINDOW_DAYS, which is the same for the cache's default retention.
4778
+ */
4779
+ var windowFor = (retentionDays) => Math.max(retentionDays, 42);
4780
+ var DEFAULT_WINDOW_DAYS = windowFor(30);
4781
+ /**
4782
+ * The JQL a dashboard sends: the project's open items, and anything updated
4783
+ * within the window, so a project's closed history from years ago isn't read
4784
+ * only to be pruned.
4785
+ */
4786
+ var JQL = (project, windowDays = DEFAULT_WINDOW_DAYS) => `project = ${project} AND (statusCategory != Done OR updated >= -${windowDays}d) ORDER BY Rank ASC`;
4787
+ /** The areas that read Azure DevOps work items: one, whose connection is Server or Services, both sending the same work item shapes. */
4788
+ var ADO_AREAS = ["ado"];
4789
+ /** The areas that read Jira work items: one, whose connection is Data Center or Cloud, both sending the same issue shapes. */
4790
+ var JIRA_AREAS = ["jira"];
4791
+ /**
4792
+ * The WIQL a dashboard sends, bounded the same way as the JQL. WIQL has no
4793
+ * status category, so "open" is an item with no closed date (the Agile, Scrum
4794
+ * and CMMI processes set `ClosedDate` when an item reaches a closed state).
4795
+ * `toil ado work-item search --updated-since` ANDs onto the WHERE and
4796
+ * parenthesizes this one, so the two compose.
4797
+ */
4798
+ var wiqlFor = (windowDays = DEFAULT_WINDOW_DAYS) => `SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @project AND ([Microsoft.VSTS.Common.ClosedDate] = '' OR [System.ChangedDate] >= @Today - ${windowDays}) ORDER BY [System.Id]`;
4799
+ var WIQL = wiqlFor();
4800
+ /**
4801
+ * The input with its query's window set to `windowDays`, when the query is
4802
+ * the dashboard's own (JQL() or wiqlFor()); any other input comes back as it
4803
+ * was. The store asks the cache for the search the sync made, which names the
4804
+ * window the sync used, and only the window may differ from what a browser sent.
4805
+ */
4806
+ function withWindow(input, windowDays) {
4807
+ if (typeof input.jql === "string") {
4808
+ const jql = input.jql.replace(/^(project = \S+ AND \(statusCategory != Done OR updated >= -)\d+(d\) ORDER BY Rank ASC)$/, `$1${windowDays}$2`);
4809
+ return jql === input.jql ? input : {
4810
+ ...input,
4811
+ jql
4812
+ };
4813
+ }
4814
+ if (typeof input.wiql === "string") {
4815
+ const wiql = input.wiql.replace(/(\[System\.ChangedDate\] >= @Today - )\d+(\) ORDER BY \[System\.Id\])$/, `$1${windowDays}$2`);
4816
+ return wiql === input.wiql ? input : {
4817
+ ...input,
4818
+ wiql
4819
+ };
4820
+ }
4821
+ return input;
4822
+ }
4823
+ /**
4824
+ * A gate that lets `limit` calls through at once and queues the rest, first
4825
+ * come first served. The same number of counters is open for every area of a
4826
+ * dossier, which is how a queue at an airport stays fair.
4827
+ */
4828
+ function limiter(limit) {
4829
+ let active = 0;
4830
+ const waiting = [];
4831
+ return async function slot(fn) {
4832
+ if (active >= limit) await new Promise((resolve) => waiting.push(resolve));
4833
+ else active++;
4834
+ try {
4835
+ return await fn();
4836
+ } finally {
4837
+ const next = waiting.shift();
4838
+ if (next) next();
4839
+ else active--;
4840
+ }
4841
+ };
4842
+ }
4822
4843
  var isRec$1 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
4823
4844
  var recs$1 = (v) => Array.isArray(v) ? v.filter(isRec$1) : [];
4824
4845
  var strings$1 = (v) => Array.isArray(v) ? v.flatMap((x) => typeof x === "string" || typeof x === "number" ? [String(x)] : []) : [];
@@ -4878,21 +4899,11 @@ var PR_HOSTS = [
4878
4899
  all: "ALL",
4879
4900
  id: "id"
4880
4901
  },
4881
- {
4882
- area: "bitbucket-cloud",
4883
- all: "ALL",
4884
- id: "id"
4885
- },
4886
4902
  {
4887
4903
  area: "ado",
4888
4904
  all: "all",
4889
4905
  id: "id"
4890
4906
  },
4891
- {
4892
- area: "ado-cloud",
4893
- all: "all",
4894
- id: "id"
4895
- },
4896
4907
  {
4897
4908
  area: "github",
4898
4909
  all: "all",
@@ -4948,6 +4959,8 @@ function historyNumbers(issues) {
4948
4959
  return numbered.filter((i) => keep.has(i)).map((i) => i.number);
4949
4960
  }
4950
4961
  var connectionOf = (env, fallback) => env.ok ? env.meta.context?.connection?.value ?? fallback : fallback;
4962
+ /** The most ids one `get-many` call takes. */
4963
+ var GET_MANY_MAX = 1e3;
4951
4964
  async function loadDossier(execute, name, options = {}) {
4952
4965
  const calls = {
4953
4966
  dossier: [],
@@ -4957,8 +4970,8 @@ async function loadDossier(execute, name, options = {}) {
4957
4970
  builds: [],
4958
4971
  deployments: []
4959
4972
  };
4960
- /** One call, recorded on its panel. A failure is kept on the panel and comes back as null. */
4961
- const run = async (panel, command, input) => {
4973
+ /** One call and how it went, not yet recorded anywhere. */
4974
+ const send = async (command, input) => {
4962
4975
  const env = await execute(command, input, CALL_OPTIONS);
4963
4976
  const call = {
4964
4977
  command,
@@ -4966,64 +4979,96 @@ async function loadDossier(execute, name, options = {}) {
4966
4979
  ok: env.ok,
4967
4980
  error: env.ok ? null : `${env.error.message}${env.error.fix ? ` ${env.error.fix}` : ""}`
4968
4981
  };
4982
+ return {
4983
+ env: env.ok ? env : null,
4984
+ call
4985
+ };
4986
+ };
4987
+ /** One call, recorded on its panel. A failure is kept on the panel and comes back as null. */
4988
+ const run = async (panel, command, input) => {
4989
+ const { env, call } = await send(command, input);
4969
4990
  calls[panel].push(call);
4970
- if (!env.ok) {
4971
- if (panel === "dossier") throw new CallFailed(call);
4972
- return null;
4973
- }
4991
+ if (!env && panel === "dossier") throw new CallFailed(call);
4974
4992
  return env;
4975
4993
  };
4976
- const { summary, areas, dossier } = readShow((await run("dossier", "dossiers show", { dossier: name })).data);
4994
+ /**
4995
+ * One call per input, at most PER_ITEM_CONCURRENCY at a time across the
4996
+ * whole dossier. The answers come back, and the calls are recorded on the
4997
+ * panel, in the order of the inputs however they finished, so the same
4998
+ * dossier loads the same way twice.
4999
+ */
5000
+ const slot = limiter(4);
5001
+ const runEach = async (panel, command, inputs) => {
5002
+ const sent = await Promise.all(inputs.map((input) => slot(() => send(command, input))));
5003
+ calls[panel].push(...sent.map((s) => s.call));
5004
+ return sent.map((s) => s.env);
5005
+ };
5006
+ const show = await run("dossier", "dossiers show", { dossier: name });
5007
+ const { summary, areas, dossier } = readShow(show.data);
4977
5008
  const section = (area) => isRec$1(dossier[area]) ? dossier[area] : {};
4978
5009
  const repos = recs$1(dossier.repos).map((r) => String(r.name));
4979
5010
  const base = { dossier: name };
4980
5011
  const work = {
4981
5012
  jira: [],
4982
5013
  ado: [],
4983
- "ado-cloud": [],
4984
5014
  github: []
4985
5015
  };
4986
5016
  const tasks = [];
4987
- if (areas.jira?.inputs.project) tasks.push((async () => {
4988
- const search = await run("work", "jira issue search", {
5017
+ for (const jira of JIRA_AREAS.filter((a) => areas[a]?.inputs.project)) tasks.push((async () => {
5018
+ const asked = await run("work", `${jira} issue search`, {
4989
5019
  ...base,
4990
- jql: JQL(areas.jira.inputs.project)
5020
+ jql: JQL(areas[jira].inputs.project, options.windowDays),
5021
+ changelog: true
4991
5022
  });
4992
- if (!search) return;
4993
- work.jira.push(search);
4994
- const keys = recs$1(search.data.issues).map((i) => String(i.key));
4995
- for (const key of keys) {
4996
- const history = await run("work", "jira issue history", {
4997
- ...base,
4998
- key
4999
- });
5000
- if (history) work.jira.push({
5001
- key,
5023
+ if (!asked) return;
5024
+ const { search, histories: inline, incomplete } = splitChangelogs(asked, `${jira} issue history`);
5025
+ work[jira].push(search);
5026
+ for (const { key, history } of inline) work[jira].push({
5027
+ key,
5028
+ history
5029
+ });
5030
+ (await runEach("work", `${jira} issue history`, incomplete.map((key) => ({
5031
+ ...base,
5032
+ key
5033
+ })))).forEach((history, n) => {
5034
+ if (history) work[jira].push({
5035
+ key: incomplete[n],
5002
5036
  history
5003
5037
  });
5004
- }
5038
+ });
5005
5039
  })());
5006
5040
  for (const ado of ADO_AREAS.filter((a) => areas[a])) tasks.push((async () => {
5007
5041
  const iterations = await run("work", `${ado} work-item iterations`, base);
5008
5042
  if (iterations) work[ado].push(iterations);
5009
5043
  const search = await run("work", `${ado} work-item search`, {
5010
5044
  ...base,
5011
- wiql: WIQL
5045
+ wiql: wiqlFor(options.windowDays)
5012
5046
  });
5013
5047
  const ids = search ? recs$1(search.data.workItems).map((w) => Number(w.id)) : [];
5014
5048
  if (!ids.length) return;
5015
- const batch = await run("work", `${ado} work-item get-many`, {
5016
- ...base,
5017
- id: ids
5018
- });
5019
- if (batch) work[ado].push(batch);
5020
- for (const id of ids) {
5021
- const revisions = await run("work", `${ado} work-item history`, {
5049
+ const items = [];
5050
+ for (let from = 0; from < ids.length; from += GET_MANY_MAX) {
5051
+ const batch = await run("work", `${ado} work-item get-many`, {
5022
5052
  ...base,
5023
- id
5053
+ id: ids.slice(from, from + GET_MANY_MAX)
5024
5054
  });
5025
- if (revisions) work[ado].push(revisions);
5055
+ if (!batch) continue;
5056
+ work[ado].push(batch);
5057
+ items.push(...recs$1(batch.data.value));
5026
5058
  }
5059
+ const iteration = owiFields(section(ado).fields).iteration;
5060
+ const { histories: inline, incomplete } = splitRevisionFeed(items.length && iteration === void 0 ? await run("work", `${ado} work-item feed`, {
5061
+ ...base,
5062
+ updatedSince: feedStart((options.now ?? (() => /* @__PURE__ */ new Date()))(), options.windowDays ?? DEFAULT_WINDOW_DAYS),
5063
+ fields: ADO_FEED_FIELDS
5064
+ }) : null, items, `${ado} work-item history`, iteration);
5065
+ work[ado].push(...inline);
5066
+ const known = new Set(items.map((i) => Number(i.id)));
5067
+ const histories = await runEach("work", `${ado} work-item history`, [...incomplete, ...ids.filter((id) => !known.has(id))].map((id) => ({
5068
+ ...base,
5069
+ id
5070
+ })));
5071
+ for (const revisions of histories) if (revisions) work[ado].push(revisions);
5027
5072
  })());
5028
5073
  if (areas.github) tasks.push((async () => {
5029
5074
  const repo = `${areas.github.inputs.owner}/${areas.github.inputs.repo}`;
@@ -5036,16 +5081,16 @@ async function loadDossier(execute, name, options = {}) {
5036
5081
  });
5037
5082
  if (!issues) return;
5038
5083
  work.github.push(issues);
5039
- for (const number of historyNumbers(recs$1(issues.data))) {
5040
- const events = await run("work", "github issue history", {
5041
- ...base,
5042
- number
5043
- });
5084
+ const wanted = historyNumbers(recs$1(issues.data));
5085
+ (await runEach("work", "github issue history", wanted.map((number) => ({
5086
+ ...base,
5087
+ number
5088
+ })))).forEach((events, n) => {
5044
5089
  if (events) work.github.push({
5045
- key: String(number),
5090
+ key: String(wanted[n]),
5046
5091
  history: events
5047
5092
  });
5048
- }
5093
+ });
5049
5094
  return;
5050
5095
  }
5051
5096
  for (const project of projects) {
@@ -5067,16 +5112,16 @@ async function loadDossier(execute, name, options = {}) {
5067
5112
  subIssues: true
5068
5113
  });
5069
5114
  if (issues) work.github.push(issues);
5070
- for (const number of numbers) {
5071
- const events = await run("work", "github issue history", {
5072
- ...base,
5073
- number
5074
- });
5115
+ const wanted = [...numbers];
5116
+ (await runEach("work", "github issue history", wanted.map((number) => ({
5117
+ ...base,
5118
+ number
5119
+ })))).forEach((events, n) => {
5075
5120
  if (events) work.github.push({
5076
- key: String(number),
5121
+ key: String(wanted[n]),
5077
5122
  history: events
5078
5123
  });
5079
- }
5124
+ });
5080
5125
  })());
5081
5126
  await Promise.all(tasks);
5082
5127
  const mapper = options.mapOwi ?? mapOwi$1;
@@ -5119,18 +5164,17 @@ async function loadDossier(execute, name, options = {}) {
5119
5164
  }
5120
5165
  const listed = first.changes;
5121
5166
  const docs = [list];
5122
- for (const pr of checkedPrs(listed)) {
5123
- const number = Number(pr.id.slice(pr.id.lastIndexOf("#") + 1));
5124
- const got = await run("prs", `${host.area} pr get`, {
5125
- ...base,
5126
- [host.id]: number,
5127
- include: PR_INCLUDE
5128
- });
5129
- if (got) {
5130
- docs.push(got);
5131
- gets.set(pr.id, got);
5167
+ const checked = checkedPrs(listed);
5168
+ (await runEach("prs", `${host.area} pr get`, checked.map((pr) => ({
5169
+ ...base,
5170
+ [host.id]: Number(pr.id.slice(pr.id.lastIndexOf("#") + 1)),
5171
+ include: PR_INCLUDE
5172
+ })))).forEach((envelope, n) => {
5173
+ if (envelope) {
5174
+ docs.push(envelope);
5175
+ gets.set(checked[n].id, envelope);
5132
5176
  }
5133
- }
5177
+ });
5134
5178
  const prs = mapper(docs, {
5135
5179
  keyPatterns,
5136
5180
  authorKinds
@@ -5167,12 +5211,12 @@ async function loadDossier(execute, name, options = {}) {
5167
5211
  if (runs) changes.push(...jenkinsBuilds(runs.data, connectionOf(runs, "jenkins"), `${job}/PR-${id}`, pr));
5168
5212
  }
5169
5213
  }
5170
- if (areas["bitbucket-cloud"]) changes.push(...refs((await readPrs(PR_HOSTS[1])).prs));
5171
- if (areas.ado) {
5172
- const prs = refs((await readPrs(PR_HOSTS[2])).prs);
5214
+ const onServices = areas.ado?.connection?.deployment === "cloud";
5215
+ if (areas.ado && !(onServices && !areas.ado.inputs.repo)) {
5216
+ const prs = refs((await readPrs(PR_HOSTS[1])).prs);
5173
5217
  changes.push(...prs);
5174
5218
  const connection = prs[0]?.change?.source.connection ?? areas.ado.connection?.value ?? "ado";
5175
- for (const pipeline of strings$1(section("ado").builds)) {
5219
+ for (const pipeline of onServices ? [] : strings$1(section("ado").builds)) {
5176
5220
  const runs = await run("builds", "ado run list", {
5177
5221
  ...base,
5178
5222
  name: pipeline,
@@ -5180,7 +5224,7 @@ async function loadDossier(execute, name, options = {}) {
5180
5224
  });
5181
5225
  if (runs) changes.push(...adoBuilds(runs.data, connectionOf(runs, connection), prs));
5182
5226
  }
5183
- for (const pipeline of strings$1(section("ado").deployments)) {
5227
+ for (const pipeline of onServices ? [] : strings$1(section("ado").deployments)) {
5184
5228
  const runs = await run("deployments", "ado run list", {
5185
5229
  ...base,
5186
5230
  name: pipeline,
@@ -5189,9 +5233,8 @@ async function loadDossier(execute, name, options = {}) {
5189
5233
  if (runs) deployments.push(...adoDeployments(runs.data, connectionOf(runs, connection), prs));
5190
5234
  }
5191
5235
  }
5192
- if (areas["ado-cloud"]?.inputs.repo) changes.push(...refs((await readPrs(PR_HOSTS[3])).prs));
5193
5236
  if (areas.github) {
5194
- const { prs, gets } = await readPrs(PR_HOSTS[4]);
5237
+ const { prs, gets } = await readPrs(PR_HOSTS[2]);
5195
5238
  const github = refs(prs);
5196
5239
  changes.push(...github);
5197
5240
  calls.builds.push(...calls.prs.filter((c) => c.command === "github pr get"));
@@ -5221,6 +5264,13 @@ async function loadDossier(execute, name, options = {}) {
5221
5264
  }
5222
5265
  if (namespaces.length) deployments.push(...await onOpenShift(changes.filter((c) => c.kind === "pull-request")));
5223
5266
  const team = readPeople(dossier);
5267
+ const analyze = isRec$1(dossier.analyze) ? dossier.analyze : null;
5268
+ const shown = show.data;
5269
+ const origin = typeof shown.source === "string" && typeof shown.file === "string" ? {
5270
+ source: shown.source,
5271
+ file: shown.file,
5272
+ adopted: shown.adopted === true
5273
+ } : null;
5224
5274
  return {
5225
5275
  ...summary,
5226
5276
  items,
@@ -5231,6 +5281,8 @@ async function loadDossier(execute, name, options = {}) {
5231
5281
  deployments: deployments.sort(byEnvironment),
5232
5282
  people: team.people,
5233
5283
  wipLimit: team.wipLimit,
5284
+ analyze,
5285
+ origin,
5234
5286
  peopleNotes: team.notes,
5235
5287
  readiness: readReadiness(dossier),
5236
5288
  calls
@@ -5272,7 +5324,7 @@ async function loadDossier(execute, name, options = {}) {
5272
5324
  var VERSION$4 = "0.1.0-alpha.1";
5273
5325
  var sha$1 = (short) => short.padEnd(40, "0");
5274
5326
  var ms$1 = (iso) => Date.parse(iso);
5275
- var envelope$2 = (command, data, connection, inputs) => ({
5327
+ var envelope$2 = (command, data, connection, inputs, deployment) => ({
5276
5328
  ok: true,
5277
5329
  data,
5278
5330
  error: null,
@@ -5283,7 +5335,8 @@ var envelope$2 = (command, data, connection, inputs) => ({
5283
5335
  context: {
5284
5336
  connection: {
5285
5337
  value: connection,
5286
- source: "dossier"
5338
+ source: "dossier",
5339
+ ...deployment === void 0 ? {} : { deployment }
5287
5340
  },
5288
5341
  inputs: Object.fromEntries(Object.entries(inputs).map(([k, value]) => [k, {
5289
5342
  value,
@@ -6180,9 +6233,9 @@ var BBC_SPECS = [{
6180
6233
  removed: 0
6181
6234
  }]
6182
6235
  }];
6183
- /** `bitbucket-cloud pr list --state ALL` for checkout-web's SDK. */
6236
+ /** `bitbucket pr list --state ALL` on a Cloud connection for checkout-web's SDK. */
6184
6237
  var BITBUCKET_CLOUD_PRS = BBC_SPECS.map(bbcPr);
6185
- /** `bitbucket-cloud pr get <id> --include reviews,checks,commits,files`, by id. */
6238
+ /** `bitbucket pr get <id> --include reviews,checks,commits,files`, by id. */
6186
6239
  var BITBUCKET_CLOUD_PR_GETS = Object.fromEntries(BBC_SPECS.map((s) => [s.id, bbcGet(s)]));
6187
6240
  var BB_AT = {
6188
6241
  project: "PAY",
@@ -6202,14 +6255,14 @@ var BBC_AT = {
6202
6255
  repo: "checkout-sdk"
6203
6256
  };
6204
6257
  `${[
6205
- envelope$2("bitbucket pr list", BITBUCKET_PRS, "corp-bitbucket", BB_AT),
6206
- ...Object.values(BITBUCKET_PR_GETS).map((d) => envelope$2("bitbucket pr get", d, "corp-bitbucket", BB_AT)),
6258
+ envelope$2("bitbucket pr list", BITBUCKET_PRS, "corp-bitbucket", BB_AT, "server"),
6259
+ ...Object.values(BITBUCKET_PR_GETS).map((d) => envelope$2("bitbucket pr get", d, "corp-bitbucket", BB_AT, "server")),
6207
6260
  envelope$2("ado pr list", ADO_PRS, "corp-ado", ADO_AT),
6208
6261
  ...Object.values(ADO_PR_GETS).map((d) => envelope$2("ado pr get", d, "corp-ado", ADO_AT)),
6209
6262
  envelope$2("github pr list", GITHUB_PRS, "github", GH_AT),
6210
6263
  ...Object.values(GITHUB_PR_GETS).map((d) => envelope$2("github pr get", d, "github", GH_AT)),
6211
- envelope$2("bitbucket-cloud pr list", BITBUCKET_CLOUD_PRS, "bitbucket-cloud", BBC_AT),
6212
- ...Object.values(BITBUCKET_CLOUD_PR_GETS).map((d) => envelope$2("bitbucket-cloud pr get", d, "bitbucket-cloud", BBC_AT))
6264
+ envelope$2("bitbucket pr list", BITBUCKET_CLOUD_PRS, "bitbucket-cloud", BBC_AT, "cloud"),
6265
+ ...Object.values(BITBUCKET_CLOUD_PR_GETS).map((d) => envelope$2("bitbucket pr get", d, "bitbucket-cloud", BBC_AT, "cloud"))
6213
6266
  ].map((e) => JSON.stringify(e)).join("\n")}`;
6214
6267
  //#endregion
6215
6268
  //#region src/fixtures/delivery.ts
@@ -7465,8 +7518,8 @@ var moreChangelogs = { "PAY-106": [jiraStatus(40501, "2026-10-06T09:30:00.000+00
7465
7518
  /** Each issue's `jira issue history` data; an issue nothing changed on since it was created has an empty one. */
7466
7519
  var JIRA_CHANGELOGS = Object.fromEntries(JIRA_KEYS.map((key) => [key, historyOf$2("jira issue history").find((h) => h.key === key)?.history.data ?? moreChangelogs[key] ?? []]));
7467
7520
  var ADO_ITERATIONS = dataOf("ado work-item iterations");
7468
- var ADO_BATCH = dataOf("ado work-item get-many");
7469
- var ADO_IDS = ADO_BATCH.value.map((w) => w.id);
7521
+ var adoBatch = dataOf("ado work-item get-many");
7522
+ var ADO_IDS = adoBatch.value.map((w) => w.id);
7470
7523
  var ADO = "https://ado.imagile.dev/DefaultCollection";
7471
7524
  /** `ado work-item search`'s data: the WIQL answer, ids and urls only. */
7472
7525
  var ADO_WIQL = {
@@ -7522,6 +7575,40 @@ var moreRevisions = {
7522
7575
  };
7523
7576
  /** Each work item's `ado work-item history` data, oldest first. */
7524
7577
  var ADO_REVISIONS = Object.fromEntries(ADO_IDS.map((id) => [id, fixtureRevisions.get(id) ?? moreRevisions[id]]));
7578
+ /**
7579
+ * `ado work-item get-many`'s data. The OWI fixture gives every item the same
7580
+ * `rev`, which no item with a history of its own could have: a work item's
7581
+ * `rev` is the number of its latest revision, so each gets its history's length.
7582
+ */
7583
+ var ADO_BATCH = {
7584
+ ...adoBatch,
7585
+ value: adoBatch.value.map((w) => ({
7586
+ ...w,
7587
+ rev: ADO_REVISIONS[w.id].length
7588
+ }))
7589
+ };
7590
+ var FEED_FROM = Date.parse("2026-10-13T08:00:00.000Z") - 37152e5;
7591
+ /** A person as the feed sends one: `Name <unique name>`, where `work-item history` sends the identity object. */
7592
+ var asText = (who) => typeof who === "object" && who !== null ? `${who.displayName} <${who.uniqueName}>` : who;
7593
+ /**
7594
+ * `ado work-item feed`'s data for the sample: every revision after
7595
+ * the feed's start, in the order they were made, as the reporting feed sends
7596
+ * them ({ id, rev, fields } with people as text and no url). The sample's
7597
+ * items were created from late August, so one of them (2301, from the 24th) is
7598
+ * not held whole and is read with `work-item history`.
7599
+ */
7600
+ var ADO_FEED$1 = ADO_IDS.flatMap((id) => ADO_REVISIONS[id]).filter((r) => Date.parse(String(r.fields["System.ChangedDate"])) > FEED_FROM).map((r) => ({
7601
+ id: r.id,
7602
+ rev: r.rev,
7603
+ fields: {
7604
+ "System.Id": r.id,
7605
+ "System.Rev": r.rev,
7606
+ ...r.fields,
7607
+ "System.ChangedBy": asText(r.fields["System.ChangedBy"])
7608
+ }
7609
+ })).sort((a, b) => Date.parse(String(a.fields["System.ChangedDate"])) - Date.parse(String(b.fields["System.ChangedDate"])) || a.id - b.id);
7610
+ /** The items whose history the sample feed doesn't hold whole: the ones the sample still reads one by one. */
7611
+ var ADO_FEED_GAPS = ADO_IDS.filter((id) => ADO_FEED$1.filter((r) => r.id === id).length !== ADO_REVISIONS[id].length);
7525
7612
  var GITHUB_PROJECT_ITEMS = dataOf("github project items");
7526
7613
  var GITHUB_NUMBERS = GITHUB_PROJECT_ITEMS.map((i) => i.content.number);
7527
7614
  var GITHUB_ISSUES = dataOf("github issue get");
@@ -7613,6 +7700,30 @@ var ADO_STATES = {
7613
7700
  Bug: AGILE,
7614
7701
  Feature: AGILE
7615
7702
  };
7703
+ /** The issues whose inline changelog the sample cuts short: the only ones the dashboard reads with `issue history`. */
7704
+ var JIRA_CUT_SHORT = ["PAY-106"];
7705
+ /**
7706
+ * `jira issue search --changelog`'s data: the same answer with each issue's
7707
+ * history inline, as Jira sends it (`changelog: { startAt, maxResults, total,
7708
+ * histories }`). The entries are the ones `issue history` returns for the key.
7709
+ */
7710
+ var JIRA_SEARCH_WITH_CHANGELOGS = {
7711
+ ...JIRA_SEARCH,
7712
+ issues: JIRA_SEARCH.issues.map((i) => {
7713
+ const key = i.key;
7714
+ const histories = JIRA_CHANGELOGS[key];
7715
+ const sent = JIRA_CUT_SHORT.includes(key) ? histories.slice(0, 1) : histories;
7716
+ return {
7717
+ ...i,
7718
+ changelog: {
7719
+ startAt: 0,
7720
+ maxResults: 100,
7721
+ total: histories.length,
7722
+ histories: sent
7723
+ }
7724
+ };
7725
+ })
7726
+ };
7616
7727
  //#endregion
7617
7728
  //#region src/fixtures/execute.ts
7618
7729
  /**
@@ -7636,13 +7747,14 @@ var VERSION$2 = "0.1.0-alpha.1";
7636
7747
  var card = "card-payments";
7637
7748
  var settle = "settlement";
7638
7749
  var checkout = "checkout-web";
7639
- var at$2 = (dossier, area, env) => ({
7750
+ var at$2 = (dossier, area, env, deployment) => ({
7640
7751
  dossier,
7641
7752
  area,
7642
- ...env ? { env } : {}
7753
+ ...env ? { env } : {},
7754
+ ...deployment ? { deployment } : {}
7643
7755
  });
7644
7756
  /** `pr get <n> --include …` for each pull request a host's fixture holds. */
7645
- var gets = (dossier, area, field, byNumber) => Object.entries(byNumber).map(([n, data]) => ({
7757
+ var gets = (dossier, area, field, byNumber, deployment) => Object.entries(byNumber).map(([n, data]) => ({
7646
7758
  command: `${area} pr get`,
7647
7759
  input: {
7648
7760
  dossier,
@@ -7650,7 +7762,7 @@ var gets = (dossier, area, field, byNumber) => Object.entries(byNumber).map(([n,
7650
7762
  include: PR_INCLUDE
7651
7763
  },
7652
7764
  data,
7653
- ...at$2(dossier, area)
7765
+ ...at$2(dossier, area, void 0, deployment)
7654
7766
  }));
7655
7767
  var CANNED = [
7656
7768
  {
@@ -7667,12 +7779,13 @@ var CANNED = [
7667
7779
  command: "jira issue search",
7668
7780
  input: {
7669
7781
  dossier: card,
7670
- jql: JQL("PAY")
7782
+ jql: JQL("PAY"),
7783
+ changelog: true
7671
7784
  },
7672
- data: JIRA_SEARCH,
7785
+ data: JIRA_SEARCH_WITH_CHANGELOGS,
7673
7786
  ...at$2(card, "jira")
7674
7787
  },
7675
- ...JIRA_KEYS.map((key) => ({
7788
+ ...JIRA_CUT_SHORT.map((key) => ({
7676
7789
  command: "jira issue history",
7677
7790
  input: {
7678
7791
  dossier: card,
@@ -7754,7 +7867,16 @@ var CANNED = [
7754
7867
  data: ADO_BATCH,
7755
7868
  ...at$2(settle, "ado")
7756
7869
  },
7757
- ...ADO_IDS.map((id) => ({
7870
+ {
7871
+ command: "ado work-item feed",
7872
+ input: {
7873
+ dossier: settle,
7874
+ fields: ADO_FEED_FIELDS
7875
+ },
7876
+ data: ADO_FEED$1,
7877
+ ...at$2(settle, "ado")
7878
+ },
7879
+ ...ADO_FEED_GAPS.map((id) => ({
7758
7880
  command: "ado work-item history",
7759
7881
  input: {
7760
7882
  dossier: settle,
@@ -7850,15 +7972,15 @@ var CANNED = [
7850
7972
  ...at$2(checkout, "github")
7851
7973
  },
7852
7974
  {
7853
- command: "bitbucket-cloud pr list",
7975
+ command: "bitbucket pr list",
7854
7976
  input: {
7855
7977
  dossier: checkout,
7856
7978
  state: "ALL"
7857
7979
  },
7858
7980
  data: BITBUCKET_CLOUD_PRS,
7859
- ...at$2(checkout, "bitbucket-cloud")
7981
+ ...at$2(checkout, "bitbucket", void 0, "cloud")
7860
7982
  },
7861
- ...gets(checkout, "bitbucket-cloud", "id", BITBUCKET_CLOUD_PR_GETS),
7983
+ ...gets(checkout, "bitbucket", "id", BITBUCKET_CLOUD_PR_GETS, "cloud"),
7862
7984
  {
7863
7985
  command: "openshift deployment list",
7864
7986
  input: {
@@ -7882,6 +8004,7 @@ var CANNED = [
7882
8004
  ];
7883
8005
  /** One string per command and input, whatever order the input's keys came in. */
7884
8006
  function callKey(command, input) {
8007
+ if (command === "ado work-item feed") input = Object.fromEntries(Object.entries(input).filter(([k]) => k !== "updatedSince"));
7885
8008
  const sort = (v) => Array.isArray(v) ? v.map(sort) : v && typeof v === "object" ? Object.fromEntries(Object.entries(v).sort(([a], [b]) => a.localeCompare(b)).map(([k, x]) => [k, sort(x)])) : v;
7886
8009
  return `${command} ${JSON.stringify(sort(input))}`;
7887
8010
  }
@@ -7900,7 +8023,8 @@ function contextOf(c) {
7900
8023
  },
7901
8024
  connection: {
7902
8025
  value: String(section.connection),
7903
- source: "dossier"
8026
+ source: "dossier",
8027
+ ...c.deployment ? { deployment: c.deployment } : {}
7904
8028
  },
7905
8029
  ...Object.keys(inputs).length ? { inputs: Object.fromEntries(Object.entries(inputs).map(([k, value]) => [k, {
7906
8030
  value,
@@ -7986,7 +8110,7 @@ var FIXES = {
7986
8110
  CREDENTIAL_STORE: "Check the OS credential store is available, or set the secret's env var instead.",
7987
8111
  UNSUPPORTED_NODE: "Install Node 24.22.1 or later on 24.x, or 26.12.1 or later (CVE-2026-111497).",
7988
8112
  GIT_NOT_FOUND: "Install git 2.24 or later and put it on PATH.",
7989
- UNSUPPORTED: "The server's release doesn't have the API the command needs; check the area's supported versions.",
8113
+ UNSUPPORTED: "The server's release, or the connection's deployment, doesn't have what the command needs; check the area's supported versions, or use a connection of the deployment that does.",
7990
8114
  INTERNAL: "This is a bug in toil. Report it with toil feedback bug, naming the command."
7991
8115
  };
7992
8116
  var fixFor = (code) => Object.hasOwn(FIXES, code) ? FIXES[code] : null;
@@ -9149,48 +9273,128 @@ var ANALYZE_PARTS = [
9149
9273
  "review"
9150
9274
  ];
9151
9275
  /**
9152
- * Analyze's top in the preview (#395): the recommendation and its issues,
9153
- * written top-down as the prompt asks, before the evidence above. Each line
9154
- * restates facts the evidence already holds, so it can't drift from the data.
9276
+ * Analyze's briefing in the preview (#494): what the scripted agent answers
9277
+ * with, a ```briefing block as the prompt asks, before the evidence above as
9278
+ * plain text. Each line restates facts the evidence already holds, so it can't
9279
+ * drift from the data; ids are written bare in the block's fields and as
9280
+ * [[citations]] in its sentences, as a real agent's are.
9155
9281
  */
9156
- var ANALYZE_TOP = {
9282
+ var id = (citation) => citation.slice(2, -2);
9283
+ var ANALYZE_BRIEFING = {
9157
9284
  "card-payments": {
9158
- recommendation: `Fix ${J$2(101)}'s failing build first: ${J$2(102)} and ${J$2(103)} are blocked behind it, holding 11 points back.`,
9159
- issues: [
9160
- `Build failing: ${J$2(101)}'s latest build failed, and it blocks ${J$2(102)}: fixing that build unblocks the chain.`,
9161
- `Blocked chain: ${J$2(102)} is blocked by ${J$2(101)} and holds up ${J$2(103)}, and nothing has changed on it for 8 days.`,
9162
- `Aging carry-over: ${J$2(104)} has been in progress for 13.9 days and came over from Sprint 41; its pull request ${BB(305)} has waited 3.9 working days for a first review.`
9163
- ]
9285
+ recommendation: `Fix ${J$2(101)}'s failing checks first: ${J$2(102)} and ${J$2(103)} wait behind it, 11 of the 18 points left, and the sprint ends in 3 days.`,
9286
+ reasons: [
9287
+ {
9288
+ lens: "failing",
9289
+ label: "Failing checks",
9290
+ line: "holds up 2 items, 11 points",
9291
+ items: [[
9292
+ J$2(101),
9293
+ `Its pull request ${BB(311)} fails the tokeniser's tests, and ${J$2(102)} and ${J$2(103)} wait behind it.`,
9294
+ "Fix the failing test in the tokeniser before anything else in the chain."
9295
+ ]]
9296
+ },
9297
+ {
9298
+ lens: "blocked",
9299
+ label: "Blocked",
9300
+ line: "2 items, 11 points, both behind PAY-101",
9301
+ items: [[
9302
+ J$2(102),
9303
+ `Blocked by ${J$2(101)} and unchanged for 8 days.`,
9304
+ `Nothing to do until ${J$2(101)}'s checks pass; its assignee can review ${BB(305)} meanwhile.`
9305
+ ], [
9306
+ J$2(103),
9307
+ `Second in the chain behind ${J$2(102)}, 8 points, and nobody owns it.`,
9308
+ "Give it an owner now, so it starts the day the chain clears."
9309
+ ]]
9310
+ },
9311
+ {
9312
+ lens: "waiting",
9313
+ label: "Waiting on review",
9314
+ line: "1 pull request past 2 working days",
9315
+ items: [[
9316
+ J$2(104),
9317
+ `Its pull request ${BB(305)} has waited 3.9 working days for a first review, and it came over from Sprint 41.`,
9318
+ `Ask for a first review of ${BB(305)} today.`
9319
+ ]]
9320
+ }
9321
+ ],
9322
+ onTrack: "",
9323
+ changed: []
9164
9324
  },
9165
9325
  settlement: {
9166
- recommendation: `Get ${A(2302)} done first: ${A(2303)} can't start until it is, and its pull request #87 is still building.`,
9167
- issues: [
9168
- `Blocked: ${A(2303)} is blocked by ${A(2302)}, and nothing has changed on it for 7.9 days.`,
9169
- `Aging carry-over: ${A(2304)} has been in progress for 15 days, longer than 85% of this dossier's finished items took (8.3 days).`,
9170
- `Review waiting on its author: ${AZ(87)} waits on D. Okafor: J. Park asked for changes 0.8 working days ago.`
9171
- ]
9326
+ recommendation: `Get ${A(2302)} done first: ${A(2303)} can't start until it is, and its pull request ${AZ(87)} is still building.`,
9327
+ reasons: [{
9328
+ lens: "blocked",
9329
+ label: "Blocked",
9330
+ line: "1 item, 3 points",
9331
+ items: [[
9332
+ A(2303),
9333
+ `Blocked by ${A(2302)}, and nothing has changed on it for 7.9 days.`,
9334
+ `Finish ${A(2302)} first; ${AZ(87)} needs its build to pass.`
9335
+ ]]
9336
+ }, {
9337
+ lens: "stale",
9338
+ label: "Stale",
9339
+ line: "1 item past 5 days",
9340
+ items: [[
9341
+ A(2304),
9342
+ "In progress for 15 days, longer than 85% of this dossier's finished items took, and carried over from Sprint 41.",
9343
+ "Ask whether it should be split or moved out of the sprint."
9344
+ ]]
9345
+ }],
9346
+ onTrack: "",
9347
+ changed: []
9172
9348
  },
9173
9349
  "checkout-web": {
9174
9350
  recommendation: `Fix ${GH(51)}'s failing checks first: it has waited on them for 2 working days, with no reviewer asked.`,
9175
- issues: [
9176
- `Failing build: ${G(43)}'s latest build failed on e2e-safari, and nothing has changed on it for 6 days.`,
9177
- `Reviews waiting: ${SDK(12)} and ${GH(52)} each wait 1.3 working days for review from Ada D.`,
9178
- `No estimate: ${G(45)} has no estimate and hasn't been updated for 7.9 days.`
9179
- ]
9351
+ reasons: [{
9352
+ lens: "failing",
9353
+ label: "Failing checks",
9354
+ line: "1 item",
9355
+ items: [[
9356
+ G(43),
9357
+ `Its latest build failed on e2e-safari, and nothing has changed on it for 6 days.`,
9358
+ "Rerun e2e-safari, then fix or quarantine the failing spec."
9359
+ ]]
9360
+ }, {
9361
+ lens: "waiting",
9362
+ label: "Waiting on review",
9363
+ line: "2 pull requests, 1.3 working days each",
9364
+ items: [[
9365
+ G(42),
9366
+ `${GH(52)} and ${SDK(12)} each wait 1.3 working days for a review.`,
9367
+ "Ask Ada D. for the two reviews together."
9368
+ ]]
9369
+ }],
9370
+ onTrack: "",
9371
+ changed: []
9180
9372
  }
9181
9373
  };
9182
- /** The scripted Analyze answer's paragraphs, top-down: Recommendation, Issues, then Evidence. */
9374
+ /** The scripted Analyze answer: the briefing block, then the evidence as plain text. */
9183
9375
  function analyzeParts(dossier) {
9184
9376
  const script = SCRIPTS[dossier] ?? {};
9185
- const top = ANALYZE_TOP[dossier];
9186
- const evidence = ANALYZE_PARTS.flatMap((id) => script[id]?.parts ?? []);
9377
+ const top = ANALYZE_BRIEFING[dossier];
9378
+ const evidence = ANALYZE_PARTS.flatMap((part) => script[part]?.parts ?? []);
9187
9379
  if (!top) return evidence;
9188
- return [
9189
- `Recommendation: ${top.recommendation}`,
9190
- ["Issues:", ...top.issues.map((t, i) => `${i + 1}. ${t}`)].join("\n"),
9191
- "Evidence:",
9192
- ...evidence
9193
- ];
9380
+ const briefing = {
9381
+ recommendation: top.recommendation,
9382
+ reasons: top.reasons.map((r) => ({
9383
+ lens: r.lens,
9384
+ label: r.label,
9385
+ line: r.line,
9386
+ text: r.text ?? null,
9387
+ items: r.items.map(([cited, why, next]) => ({
9388
+ id: id(cited),
9389
+ why,
9390
+ next
9391
+ }))
9392
+ })),
9393
+ onTrack: top.onTrack,
9394
+ changed: top.changed,
9395
+ leftOut: []
9396
+ };
9397
+ return [`\`\`\`briefing\n${JSON.stringify(briefing)}\n\`\`\``, ...evidence];
9194
9398
  }
9195
9399
  function scriptedAgent({ delay = 0 } = {}) {
9196
9400
  const answer = (dossier, prompt, style, chat) => {
@@ -9478,7 +9682,7 @@ var keyOf = (item) => item.source.key.replace(/^[^/]+\//, "");
9478
9682
  var prLabel = (id) => {
9479
9683
  return id.slice(id.indexOf(":") + 1).replace(/^[^/]*\//, "");
9480
9684
  };
9481
- var valid = (iso) => typeof iso === "string" && !Number.isNaN(Date.parse(iso));
9685
+ var valid$1 = (iso) => typeof iso === "string" && !Number.isNaN(Date.parse(iso));
9482
9686
  var isoOf = (iso) => new Date(iso).toISOString();
9483
9687
  var names = (list) => list.join(", ");
9484
9688
  var unfinished = (item) => item !== void 0 && item.statusCategory !== "DONE";
@@ -9524,14 +9728,14 @@ function eventsFrom(input, known = []) {
9524
9728
  const out = [];
9525
9729
  for (const item of input.items) {
9526
9730
  for (const t of item.history?.transitions ?? []) {
9527
- if (!valid(t.at)) continue;
9731
+ if (!valid$1(t.at)) continue;
9528
9732
  out.push({
9529
9733
  ...itemEvent(item, "status", t.at, `${t.from ?? "Created"} → ${t.to}`, t.by, `${t.from ?? ""}>${t.to}`),
9530
9734
  toCategory: t.toCategory
9531
9735
  });
9532
9736
  }
9533
9737
  for (const c of item.history?.iterations ?? []) {
9534
- if (!valid(c.at)) continue;
9738
+ if (!valid$1(c.at)) continue;
9535
9739
  const text = !c.from.length ? `added to ${names(c.to)}` : !c.to.length ? `dropped from ${names(c.from)}` : `moved from ${names(c.from)} to ${names(c.to)}`;
9536
9740
  out.push(itemEvent(item, "sprint", c.at, text, c.by, `${names(c.from)}>${names(c.to)}`));
9537
9741
  }
@@ -9563,15 +9767,15 @@ function eventsFrom(input, known = []) {
9563
9767
  observed: null,
9564
9768
  who
9565
9769
  });
9566
- if (valid(c.created)) out.push(base("pr-opened", c.created, c.state === "DRAFT" ? "opened as a draft" : "opened", c.author));
9567
- for (const r of c.reviews ?? []) if (valid(r.at)) out.push(base("pr-review", r.at, REVIEW_TEXT[r.state], r.by, `:${r.by.id}:${r.state}`));
9568
- if (c.state === "MERGED" && valid(c.mergedAt)) out.push(base("pr-merged", c.mergedAt, c.branch.target ? `merged into ${c.branch.target}` : "merged", null, "", c.author));
9569
- if (c.state === "DECLINED" && valid(c.closedAt ?? null)) out.push(base("pr-declined", c.closedAt, "closed without merging", null, "", c.author));
9770
+ if (valid$1(c.created)) out.push(base("pr-opened", c.created, c.state === "DRAFT" ? "opened as a draft" : "opened", c.author));
9771
+ for (const r of c.reviews ?? []) if (valid$1(r.at)) out.push(base("pr-review", r.at, REVIEW_TEXT[r.state], r.by, `:${r.by.id}:${r.state}`));
9772
+ if (c.state === "MERGED" && valid$1(c.mergedAt)) out.push(base("pr-merged", c.mergedAt, c.branch.target ? `merged into ${c.branch.target}` : "merged", null, "", c.author));
9773
+ if (c.state === "DECLINED" && valid$1(c.closedAt ?? null)) out.push(base("pr-declined", c.closedAt, "closed without merging", null, "", c.author));
9570
9774
  }
9571
9775
  const groups = /* @__PURE__ */ new Map();
9572
9776
  const groupOf = (b) => `${b.command}|${b.builds ?? b.id}|${b.kind === "build" && b.command === "ado run list" ? b.title.replace(/\s+\S+$/, "") : ""}`;
9573
9777
  for (const b of builds) {
9574
- if (b.outcome !== "failed" && b.outcome !== "passed" || !valid(b.at)) continue;
9778
+ if (b.outcome !== "failed" && b.outcome !== "passed" || !valid$1(b.at)) continue;
9575
9779
  const g = groupOf(b);
9576
9780
  if (!groups.has(g)) groups.set(g, []);
9577
9781
  groups.get(g).push({
@@ -10220,10 +10424,94 @@ function capStop(c) {
10220
10424
  fix: `${c.scope === "chat" ? "Start a new chat, or raise" : "Wait for the next day (UTC), or raise"} the cap or turn it off under Settings, Agent usage. The cap counts only what the SDK reports; ${VENDOR[c.adapter]} own bill is the authority.`
10221
10425
  };
10222
10426
  }
10223
- /** The share of a cap at which the chat says so. */
10224
- var WARN_AT = .8;
10225
- /** A chat id the server takes: letters, digits and hyphens, as a UUID is. */
10226
- var CHAT_ID = /^[A-Za-z0-9-]{8,64}$/;
10427
+ /** The share of a cap at which the chat says so. */
10428
+ var WARN_AT = .8;
10429
+ /** A chat id the server takes: letters, digits and hyphens, as a UUID is. */
10430
+ var CHAT_ID = /^[A-Za-z0-9-]{8,64}$/;
10431
+ var BLOCK = /```briefing[ \t]*\r?\n([\s\S]*?)\r?\n?```/;
10432
+ var text$1 = (v) => typeof v === "string" && v.trim() !== "" ? v.trim() : null;
10433
+ var texts = (v) => Array.isArray(v) ? v.map(text$1).filter((t) => t !== null) : [];
10434
+ /** The briefing block in an answer, read and checked. */
10435
+ function readBriefing(answer) {
10436
+ const m = BLOCK.exec(answer);
10437
+ if (!m) return {
10438
+ briefing: null,
10439
+ problems: ["The answer has no ```briefing block."],
10440
+ rest: answer.trim()
10441
+ };
10442
+ const rest = (answer.slice(0, m.index) + answer.slice(m.index + m[0].length)).replace(/(\r?\n\s*){3,}/g, "\n\n").trim();
10443
+ const problems = [];
10444
+ let raw;
10445
+ try {
10446
+ raw = JSON.parse(m[1]);
10447
+ } catch (err) {
10448
+ return {
10449
+ briefing: null,
10450
+ problems: [`The briefing block isn't JSON: ${err.message}.`],
10451
+ rest
10452
+ };
10453
+ }
10454
+ if (!isRecord(raw)) return {
10455
+ briefing: null,
10456
+ problems: ["The briefing block holds no object."],
10457
+ rest
10458
+ };
10459
+ const recommendation = text$1(raw.recommendation);
10460
+ if (!recommendation) return {
10461
+ briefing: null,
10462
+ problems: ["The briefing has no recommendation."],
10463
+ rest
10464
+ };
10465
+ const reasons = [];
10466
+ (Array.isArray(raw.reasons) ? raw.reasons : []).forEach((r, i) => {
10467
+ if (!isRecord(r)) return void problems.push(`Reason ${i + 1} isn't an object, so it was left out.`);
10468
+ const items = [];
10469
+ (Array.isArray(r.items) ? r.items : []).forEach((it, j) => {
10470
+ const id = isRecord(it) ? text$1(it.id) : null;
10471
+ const why = isRecord(it) ? text$1(it.why) : null;
10472
+ if (!id || !why) return void problems.push(`Item ${j + 1} of reason ${i + 1} has no ${id ? "why" : "id"}, so it was left out.`);
10473
+ items.push({
10474
+ id,
10475
+ why,
10476
+ next: text$1(it.next)
10477
+ });
10478
+ });
10479
+ const label = text$1(r.label) ?? text$1(r.lens);
10480
+ const reasonText = text$1(r.text);
10481
+ if (!label || !items.length && !reasonText) return void problems.push(`Reason ${i + 1} has no ${label ? "items and no text" : "label"}, so it was left out.`);
10482
+ reasons.push({
10483
+ lens: text$1(r.lens) ?? "other",
10484
+ label,
10485
+ line: text$1(r.line) ?? "",
10486
+ text: reasonText,
10487
+ items
10488
+ });
10489
+ });
10490
+ if (reasons.length > 5) problems.push(`The briefing has ${reasons.length} reasons; the first 5 are shown.`);
10491
+ const seen = /* @__PURE__ */ new Set();
10492
+ for (const r of reasons) for (const it of r.items) {
10493
+ if (seen.has(it.id)) problems.push(`${it.id} is under more than one reason.`);
10494
+ seen.add(it.id);
10495
+ }
10496
+ const leftOut = (Array.isArray(raw.leftOut) ? raw.leftOut : []).flatMap((l) => {
10497
+ const id = isRecord(l) ? text$1(l.id) : null;
10498
+ return id ? [{
10499
+ id,
10500
+ why: isRecord(l) && text$1(l.why) || ""
10501
+ }] : [];
10502
+ });
10503
+ return {
10504
+ briefing: {
10505
+ recommendation,
10506
+ reasons: reasons.slice(0, 5),
10507
+ onTrack: text$1(raw.onTrack),
10508
+ changed: texts(raw.changed),
10509
+ leftOut
10510
+ },
10511
+ problems,
10512
+ rest
10513
+ };
10514
+ }
10227
10515
  //#endregion
10228
10516
  //#region src/proposal.ts
10229
10517
  /** One positional list for several commands, as [command, fields] entries. */
@@ -10241,34 +10529,34 @@ var POSITIONAL_FIELDS = new Map([
10241
10529
  ...positional(["app"], "contrast app findings", "contrast app libraries"),
10242
10530
  ...positional(["buildId"], "saucelabs build get", "saucelabs build jobs"),
10243
10531
  ...positional(["commentId"], "github pr delete-comment", "github pr delete-review-comment"),
10244
- ...positional(["commit"], "ado commit status", "bitbucket commit status", "bitbucket-cloud commit get", "bitbucket-cloud commit status"),
10532
+ ...positional(["commit"], "ado commit status", "bitbucket commit get", "bitbucket commit status"),
10245
10533
  ...positional(["deviceId"], "saucelabs device get"),
10246
10534
  ...positional(["fileKeyOrUrl"], "figma file comments", "figma file get", "figma file versions"),
10247
10535
  ...positional(["flag"], "splitio flag archive", "splitio flag get", "splitio flag kill", "splitio flag restore", "splitio flag set-default", "splitio flag set-rule", "splitio flag toggle", "splitio flag update"),
10248
10536
  ...positional(["id", "attachmentId"], "ado work-item download"),
10249
- ...positional(["id", "commentId"], "bitbucket pr delete-comment", "bitbucket pr reply", "bitbucket pr resolve", "bitbucket-cloud pr delete-comment", "bitbucket-cloud pr reply", "bitbucket-cloud pr resolve"),
10537
+ ...positional(["id", "commentId"], "bitbucket pr delete-comment", "bitbucket pr reply", "bitbucket pr resolve"),
10250
10538
  ...positional([
10251
10539
  "id",
10252
10540
  "threadId",
10253
10541
  "commentId"
10254
10542
  ], "ado pr delete-comment"),
10255
- ...positional(["id", "threadId"], "ado pr reply", "ado pr resolve", "ado-cloud pr reply", "ado-cloud pr resolve"),
10256
- ...positional(["id"], "ado pipeline get", "ado pipeline run", "ado pr abandon", "ado pr approve", "ado pr builds", "ado pr comment", "ado pr comment-inline", "ado pr comments", "ado pr diff", "ado pr files", "ado pr get", "ado pr merge", "ado pr reviewers", "ado pr unapprove", "ado pr update", "ado pr wait-for-author", "ado run cancel", "ado run get", "ado run logs", "ado work-item assign", "ado work-item attach", "ado work-item attachments", "ado work-item comment", "ado work-item comments", "ado work-item get", "ado work-item get-many", "ado work-item history", "ado work-item link", "ado work-item tag", "ado work-item transition", "ado work-item untag", "ado work-item update", "ado-cloud backlog items", "ado-cloud board get", "ado-cloud pr abandon", "ado-cloud pr approve", "ado-cloud pr comment", "ado-cloud pr comment-inline", "ado-cloud pr comments", "ado-cloud pr get", "ado-cloud pr merge", "ado-cloud pr reviewers", "ado-cloud pr threads", "ado-cloud pr unapprove", "ado-cloud pr update", "ado-cloud pr wait-for-author", "ado-cloud sprint items", "ado-cloud work-item comment", "ado-cloud work-item comments", "ado-cloud work-item get", "ado-cloud work-item get-many", "ado-cloud work-item history", "ado-cloud work-item transition", "ado-cloud work-item update", "alation column get", "alation datasource get", "alation document get", "alation document update", "alation folder get", "alation job get", "alation schema get", "alation table get", "bitbucket pr add-reviewer", "bitbucket pr approve", "bitbucket pr builds", "bitbucket pr comment", "bitbucket pr comment-inline", "bitbucket pr comments", "bitbucket pr decline", "bitbucket pr diff", "bitbucket pr files", "bitbucket pr get", "bitbucket pr merge", "bitbucket pr needs-work", "bitbucket pr reviewers", "bitbucket pr unapprove", "bitbucket pr update", "bitbucket-cloud pr approve", "bitbucket-cloud pr builds", "bitbucket-cloud pr comment", "bitbucket-cloud pr comment-inline", "bitbucket-cloud pr comments", "bitbucket-cloud pr decline", "bitbucket-cloud pr diff", "bitbucket-cloud pr files", "bitbucket-cloud pr get", "bitbucket-cloud pr merge", "bitbucket-cloud pr request-changes", "bitbucket-cloud pr reviewers", "bitbucket-cloud pr unapprove", "bitbucket-cloud pr update", "checkmarx project get", "checkmarx scan get", "checkmarx scan stats", "confluence attachment delete", "confluence attachment download", "confluence page attach", "confluence page attachments", "confluence page children", "confluence page comment", "confluence page comments", "confluence page delete", "confluence page get", "confluence page history", "confluence page label", "confluence page labels", "confluence page unlabel", "confluence page update", "confluence-cloud attachment delete", "confluence-cloud attachment download", "confluence-cloud page attach", "confluence-cloud page attachments", "confluence-cloud page children", "confluence-cloud page comment", "confluence-cloud page comments", "confluence-cloud page delete", "confluence-cloud page get", "confluence-cloud page history", "confluence-cloud page label", "confluence-cloud page labels", "confluence-cloud page unlabel", "confluence-cloud page update", "dynatrace entity get", "dynatrace problem get", "dynatrace trace get", "kibana dashboard export", "kibana rule get", "sde project get", "splitio change-request get"),
10543
+ ...positional(["id", "threadId"], "ado pr reply", "ado pr resolve"),
10544
+ ...positional(["id"], "ado backlog items", "ado board get", "ado pipeline get", "ado pipeline run", "ado pr abandon", "ado pr approve", "ado pr builds", "ado pr comment", "ado pr comment-inline", "ado pr comments", "ado pr diff", "ado pr files", "ado pr get", "ado pr merge", "ado pr reviewers", "ado pr threads", "ado pr unapprove", "ado pr update", "ado pr wait-for-author", "ado run cancel", "ado run get", "ado run logs", "ado sprint items", "ado work-item assign", "ado work-item attach", "ado work-item attachments", "ado work-item comment", "ado work-item comments", "ado work-item get", "ado work-item get-many", "ado work-item history", "ado work-item link", "ado work-item tag", "ado work-item transition", "ado work-item untag", "ado work-item update", "alation column get", "alation datasource get", "alation document get", "alation document update", "alation folder get", "alation job get", "alation schema get", "alation table get", "bitbucket pr add-reviewer", "bitbucket pr approve", "bitbucket pr builds", "bitbucket pr comment", "bitbucket pr comment-inline", "bitbucket pr comments", "bitbucket pr decline", "bitbucket pr diff", "bitbucket pr files", "bitbucket pr get", "bitbucket pr merge", "bitbucket pr needs-work", "bitbucket pr reviewers", "bitbucket pr unapprove", "bitbucket pr update", "checkmarx project get", "checkmarx scan get", "checkmarx scan stats", "confluence attachment delete", "confluence attachment download", "confluence page attach", "confluence page attachments", "confluence page children", "confluence page comment", "confluence page comments", "confluence page delete", "confluence page get", "confluence page history", "confluence page label", "confluence page labels", "confluence page unlabel", "confluence page update", "dynatrace entity get", "dynatrace problem get", "dynatrace trace get", "kibana dashboard export", "kibana rule get", "sde project get", "splitio change-request get"),
10257
10545
  ...positional(["index"], "elasticsearch index count", "elasticsearch index search"),
10258
10546
  ...positional(["jobId"], "saucelabs job assets", "saucelabs job build", "saucelabs job delete", "saucelabs job get", "saucelabs job stop", "saucelabs job update", "saucelabs rdc-job delete", "saucelabs rdc-job get", "saucelabs rdc-job stop", "saucelabs rdc-job update"),
10259
- ...positional(["key", "attachmentId"], "jira issue download", "jira-cloud issue download"),
10260
- ...positional(["key"], "confluence space get", "confluence-cloud space get", "jira issue assign", "jira issue attach", "jira issue attachments", "jira issue comment", "jira issue comments", "jira issue get", "jira issue history", "jira issue label", "jira issue link", "jira issue log-work", "jira issue set-sprint", "jira issue transition", "jira issue transitions", "jira issue unlabel", "jira issue update", "jira-cloud issue assign", "jira-cloud issue attach", "jira-cloud issue attachments", "jira-cloud issue comment", "jira-cloud issue comments", "jira-cloud issue get", "jira-cloud issue history", "jira-cloud issue label", "jira-cloud issue link", "jira-cloud issue log-work", "jira-cloud issue set-sprint", "jira-cloud issue transition", "jira-cloud issue transitions", "jira-cloud issue unlabel", "jira-cloud issue update"),
10261
- ...positional(["method", "path"], "ado-cloud api", "bitbucket-cloud api", "jira api"),
10547
+ ...positional(["key", "attachmentId"], "jira issue download"),
10548
+ ...positional(["key"], "confluence space get", "jira issue assign", "jira issue attach", "jira issue attachments", "jira issue comment", "jira issue comments", "jira issue get", "jira issue history", "jira issue label", "jira issue link", "jira issue log-work", "jira issue set-sprint", "jira issue transition", "jira issue transitions", "jira issue unlabel", "jira issue update"),
10549
+ ...positional(["method", "path"], "ado api", "bitbucket api", "jira api"),
10262
10550
  ...positional(["name", "number"], "artifactory build get", "jenkins run get", "jenkins run logs"),
10263
- ...positional(["name"], "ado project get", "ado-cloud project get", "artifactory build runs", "jenkins pipeline get", "jenkins pipeline run", "jenkins pipeline runs"),
10551
+ ...positional(["name"], "ado project get", "artifactory build runs", "jenkins pipeline get", "jenkins pipeline run", "jenkins pipeline runs"),
10264
10552
  ...positional(["number", "commentId"], "github pr reply"),
10265
10553
  ...positional(["number"], "github issue assign", "github issue get", "github issue history", "github issue label", "github issue unassign", "github issue unlabel", "github pr add-reviewers", "github pr approve", "github pr close", "github pr comment", "github pr comment-inline", "github pr comments", "github pr diff", "github pr disable-auto-merge", "github pr draft", "github pr enable-auto-merge", "github pr enqueue", "github pr files", "github pr get", "github pr merge", "github pr ready", "github pr remove-reviewers", "github pr reopen", "github pr request-changes", "github pr review-comments", "github pr reviewers", "github pr reviews", "github pr status", "github pr threads", "github pr update"),
10266
- ...positional(["path"], "bitbucket-cloud file get", "bitbucket-cloud file list", "github repo file"),
10267
- ...positional(["pipeline", "step"], "bitbucket-cloud pipeline logs"),
10268
- ...positional(["pipeline"], "bitbucket-cloud pipeline get", "bitbucket-cloud pipeline steps"),
10554
+ ...positional(["path"], "bitbucket file get", "bitbucket file list", "github repo file"),
10555
+ ...positional(["pipeline", "step"], "bitbucket pipeline logs"),
10556
+ ...positional(["pipeline"], "bitbucket pipeline get", "bitbucket pipeline steps"),
10269
10557
  ...positional(["plugin"], "skills marketplace disable", "skills marketplace enable", "skills marketplace sync"),
10270
10558
  ...positional(["pod"], "openshift pod logs"),
10271
- ...positional(["project"], "github project fields", "github project items", "jira-cloud project get"),
10559
+ ...positional(["project"], "github project fields", "github project items", "jira project get"),
10272
10560
  ...positional(["projectId"], "figma project files"),
10273
10561
  ...positional(["publicId"], "sonatypeiq application get"),
10274
10562
  ...positional(["query"], "alation search"),
@@ -10406,7 +10694,9 @@ function named(text, connections) {
10406
10694
  /** The finished answer: parts, citations, proposals, and what the checks flagged. */
10407
10695
  function finish(raw, f) {
10408
10696
  const blocks = [...raw.matchAll(FENCE)].map((m) => m[1]);
10409
- const parts = partsOf(raw.replace(FENCE, "").replace(OPEN_FENCE, ""));
10697
+ const stripped = raw.replace(FENCE, "").replace(OPEN_FENCE, "");
10698
+ const read = stripped.includes("```briefing") ? readBriefing(stripped) : null;
10699
+ const parts = partsOf(read ? read.rest : stripped);
10410
10700
  const warnings = [];
10411
10701
  const proposals = [];
10412
10702
  for (const [i, block] of blocks.entries()) {
@@ -10422,7 +10712,27 @@ function finish(raw, f) {
10422
10712
  const connections = new Set([...ledgerIds].map((id) => id.slice(0, id.indexOf(":"))));
10423
10713
  const keyOf = new Set([...ledgerIds].map((id) => id.slice(id.indexOf(":") + 1)));
10424
10714
  const unverified = /* @__PURE__ */ new Set();
10425
- const { cited, bare, keys } = named([...parts.map((p) => p.text), ...proposals.map((p) => p.reason)].join("\n\n"), connections);
10715
+ const b = read?.briefing;
10716
+ const briefed = b ? [
10717
+ b.recommendation,
10718
+ b.onTrack ?? "",
10719
+ ...b.changed,
10720
+ ...b.reasons.flatMap((r) => [
10721
+ r.line,
10722
+ r.text ?? "",
10723
+ ...r.items.flatMap((i) => [
10724
+ i.id,
10725
+ i.why,
10726
+ i.next ?? ""
10727
+ ])
10728
+ ]),
10729
+ ...b.leftOut.flatMap((l) => [l.id, l.why])
10730
+ ] : [];
10731
+ const { cited, bare, keys } = named([
10732
+ ...parts.map((p) => p.text),
10733
+ ...proposals.map((p) => p.reason),
10734
+ ...briefed
10735
+ ].join("\n\n"), connections);
10426
10736
  for (const id of [
10427
10737
  ...cited,
10428
10738
  ...bare,
@@ -10430,9 +10740,10 @@ function finish(raw, f) {
10430
10740
  ]) if (!ledgerIds.has(id)) unverified.add(id);
10431
10741
  const projects = new Set([...keyOf].map((k) => /^([A-Z][A-Z0-9]{1,9})-\d+$/.exec(k)?.[1]).filter(Boolean));
10432
10742
  for (const key of keys) if (projects.has(key.split("-")[0]) && !keyOf.has(key) && ![...unverified].some((id) => id.endsWith(`:${key}`))) unverified.add(key);
10433
- const citations = citationsOf(parts);
10743
+ const citations = [.../* @__PURE__ */ new Set([...citationsOf(parts), ...b ? [...b.reasons.flatMap((r) => r.items.map((i) => i.id)), ...citationsOf(briefed.map((text) => ({ text })))] : []])];
10434
10744
  if (unverified.size) warnings.unshift(`This answer names ${unverified.size === 1 ? "an item" : `${unverified.size} items`} its tools never returned: ${[...unverified].join(", ")}. Treat ${unverified.size === 1 ? "it" : "them"} as unverified.`);
10435
- if (parts.length && !citations.length && ledgerIds.size) warnings.push("This answer cites none of the items its tools read, so nothing in it is traced to a source.");
10745
+ if (read?.problems.length) warnings.push(...read.problems.map((p) => `The briefing: ${p}`));
10746
+ if (parts.length && !citations.length && !read?.briefing && ledgerIds.size) warnings.push("This answer cites none of the items its tools read, so nothing in it is traced to a source.");
10436
10747
  if (parts.length && !ledgerIds.size) warnings.push("The agent's tools returned no work items, so this answer rests on none.");
10437
10748
  return {
10438
10749
  prompt: f.prompt,
@@ -10441,7 +10752,11 @@ function finish(raw, f) {
10441
10752
  citations,
10442
10753
  proposals,
10443
10754
  unverified: [...unverified],
10444
- warnings
10755
+ warnings,
10756
+ ...read ? {
10757
+ briefing: read.briefing,
10758
+ briefingProblems: read.problems
10759
+ } : {}
10445
10760
  };
10446
10761
  }
10447
10762
  //#endregion
@@ -11165,6 +11480,36 @@ function withHistory(text, history) {
11165
11480
  var STANDUP = /^\s*write\s+up\s+the\s+stand-?up\s+for\s+(\d{4}-\d{2}-\d{2})(?:\s+to\s+(\d{4}-\d{2}-\d{2}))?\s*[.?!]?\s*$/i;
11166
11481
  /** The instructions behind it: the report's facts only, in its order, each sentence naming its fact numbers. */
11167
11482
  var standupPrompt = (dossier, from, to) => `Write up the stand-up for the dossier "${dossier}" from ${from} to ${to} (UTC days). Call standup_report with from "${from}" and to "${to}" and use only what it returns. Write it as a few short paragraphs a team can read aloud in a minute: first the team lines, then each person with anything in their lists, in the report's order, saying what they got done, what is in progress, what is blocked and what is next. Keep every fact as the report gives it: add nothing it doesn't say, and leave out nothing that is blocked. End each sentence with the fact numbers it rests on in parentheses, such as (F3, F7), and cite every work item and pull request by its id. If the report's gaps say the worklog can't vouch for part of the range, say so in one sentence first. Describe the work, never the people: no praise, no blame and no comparison.`;
11483
+ /**
11484
+ * Analyze's question, from toil (#494): `dossiers analyze prompt --host toil-ui`
11485
+ * composes the standard method with the dossier's own lenses and focus, the
11486
+ * focus labelled with where it came from, and asks for a briefing block the
11487
+ * page lays out. A toil without that command (Toil UI ahead of its release)
11488
+ * gets the question this file kept before, which the page still reads, and the
11489
+ * answer says so in a warning.
11490
+ */
11491
+ async function analyzeQuestion(execute, dossier) {
11492
+ const e = await execute("dossiers analyze prompt", {
11493
+ dossier,
11494
+ host: "toil-ui"
11495
+ }, {
11496
+ readOnly: true,
11497
+ caller: "toil-ui"
11498
+ });
11499
+ const prompt = e.ok && typeof e.data === "object" && e.data !== null ? e.data.prompt : void 0;
11500
+ if (typeof prompt === "string") return {
11501
+ label: ANALYZE_LABEL,
11502
+ text: prompt,
11503
+ warning: null
11504
+ };
11505
+ const why = e.ok ? "it returned no prompt" : e.error.message;
11506
+ const fix = !e.ok && /unknown command|isn't a command|no command/i.test(e.error.message) ? "Upgrade toil to use the dossier's Analyze settings." : e.ok ? "Upgrade toil, or report it: a toil with the command returns a prompt." : e.error.fix ?? "";
11507
+ return {
11508
+ label: ANALYZE_LABEL,
11509
+ text: analyzePrompt(dossier),
11510
+ warning: `Analyze used Toil UI's own question, not the dossier's: toil dossiers analyze prompt failed (${why}).${fix ? ` ${fix}` : ""}`
11511
+ };
11512
+ }
11168
11513
  /** The question for a starter id or Analyze (#343), or the typed text as it is; "Prepare my 1:1 notes for <person>" typed out gets the 1:1 instructions, and "Write up the stand-up for <from> to <to>" the stand-up's. */
11169
11514
  function promptFor(dossier, prompt) {
11170
11515
  if (prompt === "analyze") return {
@@ -11401,38 +11746,19 @@ function fixtureFeedbackEnvelope(fields, send) {
11401
11746
  }
11402
11747
  }
11403
11748
  //#endregion
11404
- //#region server/store.ts
11749
+ //#region server/reads.ts
11405
11750
  /**
11406
- * The Store: where the server gets what a view shows (#206, Hosting-ready by
11407
- * design). The SPA reads through one seam, toil's own `execute()` signature
11408
- * (src/toil.ts), so a Store answers toil calls. Three ship beside each other
11409
- * and one is chosen at startup:
11410
- *
11411
- * - `sqliteStore`: the SQLite cache (#250), answering the views' calls from
11412
- * what a sync stored (server/sync.ts). `toil-ui` picks it.
11413
- * - `toilStore`: toil itself, in-process through `@imagile-dev/toil/api`, with
11414
- * the user's own connections and dossiers, every call live. Every call is
11415
- * `caller: 'toil-ui'` in the audit log.
11416
- * - `fixtureStore`: the preview's fixture `execute()` and its sample data, for
11417
- * `toil-ui --sample`, the site preview and the tests.
11418
- *
11419
- * The server, not the Store, decides what a call may do: a read
11420
- * from `READ_COMMANDS` always goes `readOnly`, a config change only for a
11421
- * command in the server's config allowlist (#253), and anything else is
11422
- * refused before a Store sees it. Two locks on one door, and both keys stay
11423
- * with the tenant.
11751
+ * The commands the views read: data only, kept apart from the Store that runs
11752
+ * them (ui/server/store.ts holds the read-only lock) so that adding a read is a
11753
+ * change to a list and nothing else. Triage may edit this file
11754
+ * (scripts/triage/changes.mjs); it may not edit the Store.
11424
11755
  */
11425
11756
  /**
11426
11757
  * The readiness gate's live reads (#307): an item's workflow, read on a
11427
11758
  * person's press from its page. A sync never stores them, so the cache passes
11428
11759
  * them to toil, read-only, like the dossiers.
11429
11760
  */
11430
- var WORKFLOW_READS = [
11431
- "jira issue transitions",
11432
- "jira-cloud issue transitions",
11433
- "ado work-item states",
11434
- "ado-cloud work-item states"
11435
- ];
11761
+ var WORKFLOW_READS = ["jira issue transitions", "ado work-item states"];
11436
11762
  /**
11437
11763
  * The commands the views read, and the only ones `/api/execute` runs. They are
11438
11764
  * the calls src/load.ts makes; test/server.test.ts holds this list to every
@@ -11447,15 +11773,10 @@ var READ_COMMANDS = /* @__PURE__ */ new Set([
11447
11773
  "ado work-item search",
11448
11774
  "ado work-item get-many",
11449
11775
  "ado work-item history",
11776
+ "ado work-item feed",
11450
11777
  "ado pr list",
11451
11778
  "ado pr get",
11452
11779
  "ado run list",
11453
- "ado-cloud work-item iterations",
11454
- "ado-cloud work-item search",
11455
- "ado-cloud work-item get-many",
11456
- "ado-cloud work-item history",
11457
- "ado-cloud pr list",
11458
- "ado-cloud pr get",
11459
11780
  "github project items",
11460
11781
  "github issue get",
11461
11782
  "github issue list",
@@ -11465,12 +11786,32 @@ var READ_COMMANDS = /* @__PURE__ */ new Set([
11465
11786
  "github repo file",
11466
11787
  "bitbucket pr list",
11467
11788
  "bitbucket pr get",
11468
- "bitbucket-cloud pr list",
11469
- "bitbucket-cloud pr get",
11470
11789
  "jenkins pipeline runs",
11471
11790
  "openshift deployment list",
11472
11791
  ...WORKFLOW_READS
11473
11792
  ]);
11793
+ //#endregion
11794
+ //#region server/store.ts
11795
+ /**
11796
+ * The Store: where the server gets what a view shows (#206, Hosting-ready by
11797
+ * design). The SPA reads through one seam, toil's own `execute()` signature
11798
+ * (src/toil.ts), so a Store answers toil calls. Three ship beside each other
11799
+ * and one is chosen at startup:
11800
+ *
11801
+ * - `sqliteStore`: the SQLite cache (#250), answering the views' calls from
11802
+ * what a sync stored (server/sync.ts). `toil-ui` picks it.
11803
+ * - `toilStore`: toil itself, in-process through `@imagile-dev/toil/api`, with
11804
+ * the user's own connections and dossiers, every call live. Every call is
11805
+ * `caller: 'toil-ui'` in the audit log.
11806
+ * - `fixtureStore`: the preview's fixture `execute()` and its sample data, for
11807
+ * `toil-ui --sample`, the site preview and the tests.
11808
+ *
11809
+ * The server, not the Store, decides what a call may do: a read
11810
+ * from `READ_COMMANDS` always goes `readOnly`, a config change only for a
11811
+ * command in the server's config allowlist (#253), and anything else is
11812
+ * refused before a Store sees it. Two locks on one door, and both keys stay
11813
+ * with the tenant.
11814
+ */
11474
11815
  /** Every Toil UI call names itself, so the audit log says which lines were the UI's. */
11475
11816
  var CALLER = "toil-ui";
11476
11817
  /**
@@ -11514,7 +11855,7 @@ function sqliteStore(cache, execute, toil) {
11514
11855
  contractVersion: toil.contractVersion
11515
11856
  };
11516
11857
  const dossier = typeof input.dossier === "string" ? input.dossier : null;
11517
- const stored = dossier ? cache().response(dossier, command, input) : null;
11858
+ const stored = dossier ? cache().response(dossier, command, withWindow(input, windowFor(cache().retentionDays))) : null;
11518
11859
  if (!stored) return {
11519
11860
  ok: false,
11520
11861
  data: null,
@@ -11529,7 +11870,7 @@ function sqliteStore(cache, execute, toil) {
11529
11870
  if (source?.status !== "failed") return stored.envelope;
11530
11871
  const warning = {
11531
11872
  code: "STALE",
11532
- message: `The latest sync of ${stored.area} failed (${source.error ?? "no message"}), so this is the copy synced ${stored.syncedAt}.`
11873
+ message: `The latest sync of ${stored.area} failed (${source.error ?? "no message"}), so this is the copy synced ${source.lastSuccessAt ?? stored.syncedAt}.`
11533
11874
  };
11534
11875
  return {
11535
11876
  ...stored.envelope,
@@ -11790,7 +12131,7 @@ function buildStandup(input) {
11790
12131
  for (const c of input.pullRequests) {
11791
12132
  if (c.state !== "OPEN") continue;
11792
12133
  const wait = waitOf(c, asOf);
11793
- if (wait.on !== "review" || wait.days === null || wait.days < 2) continue;
12134
+ if (wait.on !== "review" || wait.days === null || wait.days < PICKUP_DAYS) continue;
11794
12135
  const days = Math.round(wait.days * 10) / 10;
11795
12136
  const label = c.id.slice(c.id.indexOf(":") + 1).replace(/^[^/]*\//, "");
11796
12137
  put(prGroup(c.id, c.source.area, c.author).group, "blocked", {
@@ -11976,7 +12317,7 @@ function cacheData(cache, dossier) {
11976
12317
  items: () => cache.items(dossier),
11977
12318
  transitions: (id) => cache.transitions(dossier, id),
11978
12319
  changes: () => cache.changes(dossier),
11979
- syncedAt: () => state.lastSyncAt
12320
+ syncedAt: () => state.lastSavedAt
11980
12321
  };
11981
12322
  }
11982
12323
  /** `dossiers show` through toil, read-only and labelled as Toil UI: the people tools' `ReadDossier`. */
@@ -12014,13 +12355,6 @@ var LIVE_COMMANDS = [
12014
12355
  "ado pr list",
12015
12356
  "ado pr get",
12016
12357
  "ado run list",
12017
- "ado-cloud work-item search",
12018
- "ado-cloud work-item get",
12019
- "ado-cloud work-item get-many",
12020
- "ado-cloud work-item history",
12021
- "ado-cloud work-item iterations",
12022
- "ado-cloud pr list",
12023
- "ado-cloud pr get",
12024
12358
  "github issue get",
12025
12359
  "github issue history",
12026
12360
  "github project items",
@@ -12029,8 +12363,6 @@ var LIVE_COMMANDS = [
12029
12363
  "github commit checks",
12030
12364
  "bitbucket pr list",
12031
12365
  "bitbucket pr get",
12032
- "bitbucket-cloud pr list",
12033
- "bitbucket-cloud pr get",
12034
12366
  "jenkins pipeline runs",
12035
12367
  "openshift deployment list"
12036
12368
  ];
@@ -13646,8 +13978,8 @@ function packageUrl(specifier, from) {
13646
13978
  }
13647
13979
  //#endregion
13648
13980
  //#region server/agents/env.ts
13649
- /** What every CLI needs to run at all. */
13650
- var BASE = /^(PATH|PATHEXT|HOME|USERPROFILE|HOMEDRIVE|HOMEPATH|APPDATA|LOCALAPPDATA|TMP|TEMP|TMPDIR|SYSTEMROOT|WINDIR|COMSPEC|LANG|LC_[A-Z_]+|TZ|XDG_CONFIG_HOME|XDG_DATA_HOME|XDG_STATE_HOME|XDG_CACHE_HOME)$/i;
13981
+ /** OS identity includes USER: Claude needs it to find its macOS sign-in (#489). */
13982
+ var BASE = /^(PATH|PATHEXT|HOME|USER|USERPROFILE|HOMEDRIVE|HOMEPATH|APPDATA|LOCALAPPDATA|TMP|TEMP|TMPDIR|SYSTEMROOT|WINDIR|COMSPEC|LANG|LC_[A-Z_]+|TZ|XDG_CONFIG_HOME|XDG_DATA_HOME|XDG_STATE_HOME|XDG_CACHE_HOME)$/i;
13651
13983
  /** The proxy and the certificate authorities the machine names (principle 9). */
13652
13984
  var NETWORK = /^(HTTPS_PROXY|HTTP_PROXY|ALL_PROXY|NO_PROXY|NODE_EXTRA_CA_CERTS|SSL_CERT_FILE|SSL_CERT_DIR)$/i;
13653
13985
  /**
@@ -13901,7 +14233,7 @@ var FIELDS = /* @__PURE__ */ new Set([
13901
14233
  "models",
13902
14234
  "cliPaths"
13903
14235
  ]);
13904
- var NAMES = [
14236
+ var NAMES$1 = [
13905
14237
  "claude",
13906
14238
  "copilot",
13907
14239
  "codex"
@@ -13976,7 +14308,7 @@ function perAdapter(value, field, check) {
13976
14308
  if (typeof value !== "object" || Array.isArray(value)) throw new AgentError(`${field} must be an object of adapter to value.`, `Send { "claude": …, "copilot": …, "codex": … }, or leave ${field} out.`);
13977
14309
  const out = {};
13978
14310
  for (const [k, v] of Object.entries(value)) {
13979
- if (!NAMES.includes(k)) throw new AgentError(`${field} has no adapter ${JSON.stringify(k)}.`, `Its keys are ${NAMES.join(", ")}.`);
14311
+ if (!NAMES$1.includes(k)) throw new AgentError(`${field} has no adapter ${JSON.stringify(k)}.`, `Its keys are ${NAMES$1.join(", ")}.`);
13980
14312
  const checked = check(v, k);
13981
14313
  if (checked !== null) out[k] = checked;
13982
14314
  }
@@ -14041,7 +14373,7 @@ var THEME_VOICES = new Map([
14041
14373
  {
14042
14374
  name: "plain",
14043
14375
  label: "Plain",
14044
- description: "Light and quiet, with a dark variant: toil's rounded brand face, Fredoka, on headings and figures, and IBM Plex Sans to read. The accessibility baseline every other theme is held to.",
14376
+ description: "Light and quiet: toil's rounded brand face, Fredoka, on headings and figures, and IBM Plex Sans to read. The accessibility baseline every other theme is held to.",
14045
14377
  schemes: {
14046
14378
  "light": {
14047
14379
  "bg": "#ffffff",
@@ -14094,24 +14426,43 @@ var THEME_VOICES = new Map([
14094
14426
  {
14095
14427
  name: "crate",
14096
14428
  label: "Crate",
14097
- description: "The toil site's look: its near-black, the drafting grid and the blue glow, the blue accent gradient, dust drifting in the glow, and the crate in its hard hat when there's nothing to show yet.",
14098
- schemes: { "dark": {
14099
- "bg": "#0f1115",
14100
- "surface": "#171a21",
14101
- "raised": "#1e222b",
14102
- "ink": "#e8eaed",
14103
- "muted": "#a7afba",
14104
- "line": "#3a414d",
14105
- "accent": "#8cc4ff",
14106
- "accentInk": "#0b1220",
14107
- "link": "#c2e0ff",
14108
- "focus": "#8cc4ff",
14109
- "ok": "#6fd394",
14110
- "warn": "#f0b849",
14111
- "danger": "#ff8a80",
14112
- "bannerBg": "#1e222b",
14113
- "bannerInk": "#c2e0ff"
14114
- } },
14429
+ description: "The toil site's look: its near-black, or warm drafting paper in light, the drafting grid and the blue glow, the blue accent gradient, dust drifting in the glow, and the crate in its hard hat when there's nothing to show yet.",
14430
+ schemes: {
14431
+ "dark": {
14432
+ "bg": "#0f1115",
14433
+ "surface": "#171a21",
14434
+ "raised": "#1e222b",
14435
+ "ink": "#e8eaed",
14436
+ "muted": "#a7afba",
14437
+ "line": "#3a414d",
14438
+ "accent": "#8cc4ff",
14439
+ "accentInk": "#0b1220",
14440
+ "link": "#c2e0ff",
14441
+ "focus": "#8cc4ff",
14442
+ "ok": "#6fd394",
14443
+ "warn": "#f0b849",
14444
+ "danger": "#ff8a80",
14445
+ "bannerBg": "#1e222b",
14446
+ "bannerInk": "#c2e0ff"
14447
+ },
14448
+ "light": {
14449
+ "bg": "#f4f2ed",
14450
+ "surface": "#faf9f5",
14451
+ "raised": "#ffffff",
14452
+ "ink": "#1a1e26",
14453
+ "muted": "#505865",
14454
+ "line": "#cfcac0",
14455
+ "accent": "#1b66c4",
14456
+ "accentInk": "#ffffff",
14457
+ "link": "#0e4a96",
14458
+ "focus": "#1b66c4",
14459
+ "ok": "#146c2e",
14460
+ "warn": "#7a4a00",
14461
+ "danger": "#b42318",
14462
+ "bannerBg": "#fdf0c4",
14463
+ "bannerInk": "#3d2c00"
14464
+ }
14465
+ },
14115
14466
  fonts: {
14116
14467
  "body": "'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif",
14117
14468
  "display": "'Source Serif 4', Georgia, 'Times New Roman', serif",
@@ -14252,24 +14603,43 @@ var THEME_VOICES = new Map([
14252
14603
  {
14253
14604
  name: "harvest",
14254
14605
  label: "Harvest",
14255
- description: "A 16-bit farm: a pixel font, wooden sign panels, a sky that runs from dawn on the sprint's first day to dusk on its last, and crops that grow a stage with each column an item moves.",
14256
- schemes: { "light": {
14257
- "bg": "#efe3c2",
14258
- "surface": "#f6ecd2",
14259
- "raised": "#fdf6e3",
14260
- "ink": "#2b1a0e",
14261
- "muted": "#5c3f24",
14262
- "line": "#b08a5a",
14263
- "accent": "#2f6b1f",
14264
- "accentInk": "#ffffff",
14265
- "link": "#8a3410",
14266
- "focus": "#1f55a8",
14267
- "ok": "#2c6a1c",
14268
- "warn": "#7a4800",
14269
- "danger": "#a3200f",
14270
- "bannerBg": "#3b2614",
14271
- "bannerInk": "#fbe7b5"
14272
- } },
14606
+ description: "A 16-bit farm, by day or by lantern light: a pixel font, wooden sign panels, a sky that runs from dawn on the sprint's first day to dusk on its last, and crops that grow a stage with each column an item moves.",
14607
+ schemes: {
14608
+ "light": {
14609
+ "bg": "#efe3c2",
14610
+ "surface": "#f6ecd2",
14611
+ "raised": "#fdf6e3",
14612
+ "ink": "#2b1a0e",
14613
+ "muted": "#5c3f24",
14614
+ "line": "#b08a5a",
14615
+ "accent": "#2f6b1f",
14616
+ "accentInk": "#ffffff",
14617
+ "link": "#8a3410",
14618
+ "focus": "#1f55a8",
14619
+ "ok": "#2c6a1c",
14620
+ "warn": "#7a4800",
14621
+ "danger": "#a3200f",
14622
+ "bannerBg": "#3b2614",
14623
+ "bannerInk": "#fbe7b5"
14624
+ },
14625
+ "dark": {
14626
+ "bg": "#151d17",
14627
+ "surface": "#1e2a20",
14628
+ "raised": "#283628",
14629
+ "ink": "#f3e4bf",
14630
+ "muted": "#cdb58a",
14631
+ "line": "#80613c",
14632
+ "accent": "#8fd46a",
14633
+ "accentInk": "#10200c",
14634
+ "link": "#f0b060",
14635
+ "focus": "#7db4f2",
14636
+ "ok": "#8fd46a",
14637
+ "warn": "#f2c04a",
14638
+ "danger": "#ff8f7a",
14639
+ "bannerBg": "#2a1a0c",
14640
+ "bannerInk": "#fbe7b5"
14641
+ }
14642
+ },
14273
14643
  fonts: {
14274
14644
  "body": "'Pixelify Sans', system-ui, -apple-system, 'Segoe UI', sans-serif",
14275
14645
  "display": "'Pixelify Sans', system-ui, -apple-system, 'Segoe UI', sans-serif",
@@ -14426,23 +14796,42 @@ var THEME_VOICES = new Map([
14426
14796
  name: "starship",
14427
14797
  label: "Starship",
14428
14798
  description: "A starship's bridge console: HUD frames, scanlines and a slow starfield over a nebula, holo panels with a glow, sprint health as ship's readouts, and the dependency graph as a star chart.",
14429
- schemes: { "dark": {
14430
- "bg": "#05070f",
14431
- "surface": "#0a1222",
14432
- "raised": "#101b31",
14433
- "ink": "#e6f1ff",
14434
- "muted": "#9fb4cd",
14435
- "line": "#2a4262",
14436
- "accent": "#36d6ff",
14437
- "accentInk": "#00121c",
14438
- "link": "#7fe3ff",
14439
- "focus": "#ffcf4a",
14440
- "ok": "#5df2a6",
14441
- "warn": "#ffc857",
14442
- "danger": "#ff7a8e",
14443
- "bannerBg": "#0a1222",
14444
- "bannerInk": "#7fe3ff"
14445
- } },
14799
+ schemes: {
14800
+ "dark": {
14801
+ "bg": "#05070f",
14802
+ "surface": "#0a1222",
14803
+ "raised": "#101b31",
14804
+ "ink": "#e6f1ff",
14805
+ "muted": "#9fb4cd",
14806
+ "line": "#2a4262",
14807
+ "accent": "#36d6ff",
14808
+ "accentInk": "#00121c",
14809
+ "link": "#7fe3ff",
14810
+ "focus": "#ffcf4a",
14811
+ "ok": "#5df2a6",
14812
+ "warn": "#ffc857",
14813
+ "danger": "#ff7a8e",
14814
+ "bannerBg": "#0a1222",
14815
+ "bannerInk": "#7fe3ff"
14816
+ },
14817
+ "light": {
14818
+ "bg": "#eaf1f9",
14819
+ "surface": "#f6f9fd",
14820
+ "raised": "#ffffff",
14821
+ "ink": "#0a1a2e",
14822
+ "muted": "#3d566f",
14823
+ "line": "#7f9bb9",
14824
+ "accent": "#00708f",
14825
+ "accentInk": "#ffffff",
14826
+ "link": "#00607f",
14827
+ "focus": "#8a5a00",
14828
+ "ok": "#0b7a46",
14829
+ "warn": "#8a5a00",
14830
+ "danger": "#b3213d",
14831
+ "bannerBg": "#dbe8f5",
14832
+ "bannerInk": "#00506b"
14833
+ }
14834
+ },
14446
14835
  fonts: {
14447
14836
  "body": "'Exo 2', system-ui, -apple-system, 'Segoe UI', sans-serif",
14448
14837
  "display": "'Orbitron', 'Exo 2', system-ui, sans-serif",
@@ -14596,23 +14985,42 @@ var THEME_VOICES = new Map([
14596
14985
  name: "realm",
14597
14986
  label: "Realm",
14598
14987
  description: "A grimdark house ledger kept as a tabletop campaign: soot and iron around aged vellum, leather-bound folios with wax-sealed headings, a dungeon map at the foot of every page, a d20 rolling while a view loads, the dependency graph as an engraved war-table map, an item's fields as a character sheet, and the agent as the dungeon master.",
14599
- schemes: { "light": {
14600
- "bg": "#cbbd9e",
14601
- "surface": "#e2d7bf",
14602
- "raised": "#ece4d2",
14603
- "ink": "#1a1410",
14604
- "muted": "#46392c",
14605
- "line": "#8a7558",
14606
- "accent": "#6e1c18",
14607
- "accentInk": "#f1e8d4",
14608
- "link": "#2b3f52",
14609
- "focus": "#24405e",
14610
- "ok": "#2b4a22",
14611
- "warn": "#663f00",
14612
- "danger": "#7f1a12",
14613
- "bannerBg": "#1a1715",
14614
- "bannerInk": "#e6dcc6"
14615
- } },
14988
+ schemes: {
14989
+ "light": {
14990
+ "bg": "#cbbd9e",
14991
+ "surface": "#e2d7bf",
14992
+ "raised": "#ece4d2",
14993
+ "ink": "#1a1410",
14994
+ "muted": "#46392c",
14995
+ "line": "#8a7558",
14996
+ "accent": "#6e1c18",
14997
+ "accentInk": "#f1e8d4",
14998
+ "link": "#2b3f52",
14999
+ "focus": "#24405e",
15000
+ "ok": "#2b4a22",
15001
+ "warn": "#663f00",
15002
+ "danger": "#7f1a12",
15003
+ "bannerBg": "#1a1715",
15004
+ "bannerInk": "#e6dcc6"
15005
+ },
15006
+ "dark": {
15007
+ "bg": "#1c1712",
15008
+ "surface": "#2a231b",
15009
+ "raised": "#342b21",
15010
+ "ink": "#ece1c8",
15011
+ "muted": "#bdae92",
15012
+ "line": "#8f7d62",
15013
+ "accent": "#d4705a",
15014
+ "accentInk": "#1a1410",
15015
+ "link": "#8fb4d4",
15016
+ "focus": "#8fb9e8",
15017
+ "ok": "#8fc47a",
15018
+ "warn": "#e0a64a",
15019
+ "danger": "#f08a78",
15020
+ "bannerBg": "#0f0c0a",
15021
+ "bannerInk": "#e6dcc6"
15022
+ }
15023
+ },
14616
15024
  fonts: {
14617
15025
  "body": "'EB Garamond', Georgia, 'Times New Roman', serif",
14618
15026
  "display": "'Grenze Gotisch', Georgia, 'Times New Roman', serif",
@@ -14791,24 +15199,43 @@ var THEME_VOICES = new Map([
14791
15199
  {
14792
15200
  name: "sprawl",
14793
15201
  label: "Sprawl",
14794
- description: "A terminal at heart in a rain-soaked megacity: monospace type and a block cursor, faint scanlines and a CRT edge glow, neon magenta and cyan on deep blue-black, the skyline at the foot of the page, rain on the glass, the dependency graph as a net map, and the agent as a netrunner.",
14795
- schemes: { "dark": {
14796
- "bg": "#07060f",
14797
- "surface": "#0e0c1d",
14798
- "raised": "#17142c",
14799
- "ink": "#eaf6ff",
14800
- "muted": "#a8a3cf",
14801
- "line": "#3b2f6b",
14802
- "accent": "#ff2e88",
14803
- "accentInk": "#12020a",
14804
- "link": "#3ff0ff",
14805
- "focus": "#f2ff4a",
14806
- "ok": "#39ff9c",
14807
- "warn": "#ffd23f",
14808
- "danger": "#ff6470",
14809
- "bannerBg": "#0e0c1d",
14810
- "bannerInk": "#3ff0ff"
14811
- } },
15202
+ description: "A terminal at heart in a rain-soaked megacity: monospace type and a block cursor, faint scanlines and a CRT edge glow, neon magenta and cyan on deep blue-black, or the city at dawn in light, the skyline at the foot of the page, rain on the glass, the dependency graph as a net map, and the agent as a netrunner.",
15203
+ schemes: {
15204
+ "dark": {
15205
+ "bg": "#07060f",
15206
+ "surface": "#0e0c1d",
15207
+ "raised": "#17142c",
15208
+ "ink": "#eaf6ff",
15209
+ "muted": "#a8a3cf",
15210
+ "line": "#3b2f6b",
15211
+ "accent": "#ff2e88",
15212
+ "accentInk": "#12020a",
15213
+ "link": "#3ff0ff",
15214
+ "focus": "#f2ff4a",
15215
+ "ok": "#39ff9c",
15216
+ "warn": "#ffd23f",
15217
+ "danger": "#ff6470",
15218
+ "bannerBg": "#0e0c1d",
15219
+ "bannerInk": "#3ff0ff"
15220
+ },
15221
+ "light": {
15222
+ "bg": "#e9e7f2",
15223
+ "surface": "#f4f2fa",
15224
+ "raised": "#ffffff",
15225
+ "ink": "#14102a",
15226
+ "muted": "#4a4570",
15227
+ "line": "#8f88bd",
15228
+ "accent": "#b80f62",
15229
+ "accentInk": "#ffffff",
15230
+ "link": "#00667a",
15231
+ "focus": "#5b21c9",
15232
+ "ok": "#0a6e3e",
15233
+ "warn": "#80530a",
15234
+ "danger": "#bd1530",
15235
+ "bannerBg": "#d5f1f5",
15236
+ "bannerInk": "#00424f"
15237
+ }
15238
+ },
14812
15239
  fonts: {
14813
15240
  "body": "'Fira Code', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace",
14814
15241
  "display": "'Chakra Petch', 'Fira Code', ui-monospace, monospace",
@@ -14821,6 +15248,7 @@ var THEME_VOICES = new Map([
14821
15248
  assets: {
14822
15249
  "skyline": "assets/skyline.webp",
14823
15250
  "netMap": "assets/net-map.svg",
15251
+ "netMapLight": "assets/net-map-light.svg",
14824
15252
  "netrunner": "assets/netrunner.svg",
14825
15253
  "blackIce": "assets/black-ice.svg",
14826
15254
  "loading": "assets/jack-in.webp",
@@ -14965,23 +15393,42 @@ var THEME_VOICES = new Map([
14965
15393
  name: "frontier",
14966
15394
  label: "Frontier",
14967
15395
  description: "Steampunk on the wild west frontier: brass, copper and riveted iron over sun-bleached desert wood, panels framed in riveted brass plate, pressure gauges on the tallies, the dependency graph as a railroad survey map, dust and drifting steam, and the agent as a dry telegraph operator.",
14968
- schemes: { "light": {
14969
- "bg": "#d6c4a0",
14970
- "surface": "#efe3c8",
14971
- "raised": "#f6eedb",
14972
- "ink": "#22170d",
14973
- "muted": "#4b3925",
14974
- "line": "#97794f",
14975
- "accent": "#8a3812",
14976
- "accentInk": "#fbf1de",
14977
- "link": "#1f4859",
14978
- "focus": "#1e4e85",
14979
- "ok": "#2e5a1c",
14980
- "warn": "#683f00",
14981
- "danger": "#8c1c10",
14982
- "bannerBg": "#1f1b17",
14983
- "bannerInk": "#ecd9ad"
14984
- } },
15396
+ schemes: {
15397
+ "light": {
15398
+ "bg": "#d6c4a0",
15399
+ "surface": "#efe3c8",
15400
+ "raised": "#f6eedb",
15401
+ "ink": "#22170d",
15402
+ "muted": "#4b3925",
15403
+ "line": "#97794f",
15404
+ "accent": "#8a3812",
15405
+ "accentInk": "#fbf1de",
15406
+ "link": "#1f4859",
15407
+ "focus": "#1e4e85",
15408
+ "ok": "#2e5a1c",
15409
+ "warn": "#683f00",
15410
+ "danger": "#8c1c10",
15411
+ "bannerBg": "#1f1b17",
15412
+ "bannerInk": "#ecd9ad"
15413
+ },
15414
+ "dark": {
15415
+ "bg": "#15181f",
15416
+ "surface": "#241f1a",
15417
+ "raised": "#2e2820",
15418
+ "ink": "#f1e4c6",
15419
+ "muted": "#cdb998",
15420
+ "line": "#7c6646",
15421
+ "accent": "#e2a23f",
15422
+ "accentInk": "#1c1209",
15423
+ "link": "#8ec3d6",
15424
+ "focus": "#9bbdf2",
15425
+ "ok": "#8cc46a",
15426
+ "warn": "#e6b552",
15427
+ "danger": "#f08a72",
15428
+ "bannerBg": "#0f0d0b",
15429
+ "bannerInk": "#ecd9ad"
15430
+ }
15431
+ },
14985
15432
  fonts: {
14986
15433
  "body": "'Bitter', Georgia, 'Times New Roman', serif",
14987
15434
  "display": "'Rye', 'Bitter', Georgia, serif",
@@ -15140,23 +15587,42 @@ var THEME_VOICES = new Map([
15140
15587
  name: "overworld",
15141
15588
  label: "Overworld",
15142
15589
  description: "A top-down 16-bit adventure: an overworld map at the page's edges, panels as dungeon rooms walled in stone, a heart meter for the days left in the sprint and a gem counter for its points, chests that open as quests are done, and the agent as an old sage in a cave.",
15143
- schemes: { "dark": {
15144
- "bg": "#111c16",
15145
- "surface": "#1a2620",
15146
- "raised": "#223129",
15147
- "ink": "#f3efdc",
15148
- "muted": "#bcc7b4",
15149
- "line": "#4d6355",
15150
- "accent": "#5cc46e",
15151
- "accentInk": "#0b120e",
15152
- "link": "#f2c94c",
15153
- "focus": "#ffd75e",
15154
- "ok": "#7ed98f",
15155
- "warn": "#f2b84b",
15156
- "danger": "#ff8a7a",
15157
- "bannerBg": "#0b120e",
15158
- "bannerInk": "#f3efdc"
15159
- } },
15590
+ schemes: {
15591
+ "dark": {
15592
+ "bg": "#111c16",
15593
+ "surface": "#1a2620",
15594
+ "raised": "#223129",
15595
+ "ink": "#f3efdc",
15596
+ "muted": "#bcc7b4",
15597
+ "line": "#4d6355",
15598
+ "accent": "#5cc46e",
15599
+ "accentInk": "#0b120e",
15600
+ "link": "#f2c94c",
15601
+ "focus": "#ffd75e",
15602
+ "ok": "#7ed98f",
15603
+ "warn": "#f2b84b",
15604
+ "danger": "#ff8a7a",
15605
+ "bannerBg": "#0b120e",
15606
+ "bannerInk": "#f3efdc"
15607
+ },
15608
+ "light": {
15609
+ "bg": "#e9efd6",
15610
+ "surface": "#f7f4e2",
15611
+ "raised": "#fffbe9",
15612
+ "ink": "#241c14",
15613
+ "muted": "#46564a",
15614
+ "line": "#7d8d76",
15615
+ "accent": "#1a7a4a",
15616
+ "accentInk": "#ffffff",
15617
+ "link": "#7a5000",
15618
+ "focus": "#8a5a00",
15619
+ "ok": "#1d6a31",
15620
+ "warn": "#8a5500",
15621
+ "danger": "#b0231a",
15622
+ "bannerBg": "#1f3a2a",
15623
+ "bannerInk": "#f7f4e2"
15624
+ }
15625
+ },
15160
15626
  fonts: {
15161
15627
  "body": "'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif",
15162
15628
  "display": "'Press Start 2P', 'IBM Plex Sans', system-ui, sans-serif",
@@ -15487,7 +15953,11 @@ var AgentHost = class {
15487
15953
  const data = this.o.data(dossier);
15488
15954
  if (!data) throw new AgentError(`Toil UI hasn't synced ${dossier} yet, so the agent has nothing to read.`, "Press Sync now in the Sync panel, then ask again.");
15489
15955
  const ledger = new Ledger();
15490
- const { label, text: question } = promptFor(dossier, prompt);
15956
+ const asking = prompt === "analyze" ? await analyzeQuestion(this.o.execute, dossier) : {
15957
+ ...promptFor(dossier, prompt),
15958
+ warning: null
15959
+ };
15960
+ const { label, text: question } = asking;
15491
15961
  const { text, carried } = withHistory(question, extra.history);
15492
15962
  const by = this.byOf(runtime);
15493
15963
  const who = {
@@ -15535,14 +16005,16 @@ var AgentHost = class {
15535
16005
  }
15536
16006
  }).then(async ({ text: final, usage }) => {
15537
16007
  const session = held ? await this.checked(held).catch(() => null) : null;
16008
+ const done = finish(final, {
16009
+ dossier,
16010
+ prompt: label,
16011
+ by,
16012
+ ledger,
16013
+ writes: this.writes
16014
+ });
16015
+ if (asking.warning) done.warnings = [...done.warnings ?? [], asking.warning];
15538
16016
  out.push({
15539
- ...finish(final, {
15540
- dossier,
15541
- prompt: label,
15542
- by,
15543
- ledger,
15544
- writes: this.writes
15545
- }),
16017
+ ...done,
15546
16018
  ...who,
15547
16019
  usage,
15548
16020
  ...session ? { session } : {}
@@ -16060,7 +16532,13 @@ function snapshotOf(items, now) {
16060
16532
  }
16061
16533
  /** An Analyze answer, finished, as a record for the history. */
16062
16534
  function recordOf(answer, o) {
16063
- const s = structureOf(textOfParts(answer.parts));
16535
+ const text = textOfParts(answer.parts);
16536
+ const read = answer.briefing !== void 0 ? {
16537
+ briefing: answer.briefing,
16538
+ problems: answer.briefingProblems ?? []
16539
+ } : text.includes("```briefing") ? readBriefing(text) : null;
16540
+ const b = read?.briefing ?? null;
16541
+ const s = b ? null : structureOf(text);
16064
16542
  return {
16065
16543
  id: o.id,
16066
16544
  dossier: o.dossier,
@@ -16070,8 +16548,13 @@ function recordOf(answer, o) {
16070
16548
  model: answer.model ?? null,
16071
16549
  by: answer.by,
16072
16550
  usage: answer.usage ?? null,
16073
- recommendation: s?.recommendation ?? null,
16074
- issues: s?.issues ?? [],
16551
+ recommendation: b?.recommendation ?? s?.recommendation ?? null,
16552
+ issues: b ? b.reasons.slice(0, 3).map((r) => ({
16553
+ title: r.label,
16554
+ text: r.text ?? r.line
16555
+ })) : s?.issues ?? [],
16556
+ briefing: b,
16557
+ briefingProblems: read?.problems ?? [],
16075
16558
  parts: answer.parts,
16076
16559
  citations: answer.citations.length ? answer.citations : citationsOf(answer.parts),
16077
16560
  unverified: answer.unverified ?? [],
@@ -16141,7 +16624,10 @@ function historyOf$1(records) {
16141
16624
  issues: r.issues,
16142
16625
  citations: r.citations,
16143
16626
  unverified: r.unverified.length,
16144
- changes: changesBetween(oldest[i - 1] ?? null, r)
16627
+ changes: changesBetween(oldest[i - 1] ?? null, r),
16628
+ briefing: r.briefing ?? null,
16629
+ briefingProblems: r.briefingProblems ?? [],
16630
+ proposals: r.proposals
16145
16631
  })).reverse();
16146
16632
  }
16147
16633
  /** One record opened, with what changed since the one before it. */
@@ -16382,6 +16868,16 @@ var MIGRATIONS = [
16382
16868
  PRIMARY KEY (dossier, id)
16383
16869
  );
16384
16870
  CREATE INDEX analyses_at ON analyses (dossier, at);
16871
+ `
16872
+ },
16873
+ {
16874
+ version: 5,
16875
+ description: "a stored response's digest, so a sync rewrites only what changed, when each source was last read whole, and when a dossier's data was last saved (#493)",
16876
+ sql: `
16877
+ ALTER TABLE responses ADD COLUMN digest TEXT;
16878
+ ALTER TABLE sources ADD COLUMN full_read_at TEXT;
16879
+ ALTER TABLE dossiers ADD COLUMN last_saved_at TEXT;
16880
+ UPDATE dossiers SET last_saved_at = last_sync_at;
16385
16881
  `
16386
16882
  }
16387
16883
  ];
@@ -16393,8 +16889,16 @@ var CacheError = class extends Error {
16393
16889
  this.fix = fix;
16394
16890
  }
16395
16891
  };
16396
- /** One string per command and input, whatever order the input's keys came in. */
16397
- function inputKey(input) {
16892
+ /** The command whose `updatedSince` is a clock reading, not a question: the revision feed's start date moves with the day. */
16893
+ var FEED_COMMAND = "ado work-item feed";
16894
+ /**
16895
+ * One string per command and input, whatever order the input's keys came in.
16896
+ * For the revision feed alone, `updatedSince` is left out (it says when the
16897
+ * call was made, and the sync adds its own to a delta read without ever
16898
+ * recording it); on any other command it still tells one answer from another.
16899
+ */
16900
+ function inputKey(input, command) {
16901
+ if (command === FEED_COMMAND) input = Object.fromEntries(Object.entries(input).filter(([k]) => k !== "updatedSince"));
16398
16902
  const sort = (v) => Array.isArray(v) ? v.map(sort) : v && typeof v === "object" ? Object.fromEntries(Object.entries(v).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, x]) => [k, sort(x)])) : v;
16399
16903
  return JSON.stringify(sort(input));
16400
16904
  }
@@ -16410,6 +16914,17 @@ var WORKLOG_TABLES = [
16410
16914
  ];
16411
16915
  /** How far before the last good sync a newly listed fact may be and still count as news: the clocks may disagree (#419). */
16412
16916
  var NEWS_SKEW_MS = 3e5;
16917
+ /** What makes two envelopes the same answer: everything but how long the call took and the requests it made. */
16918
+ function digestOf(env) {
16919
+ return createHash("sha256").update(JSON.stringify([
16920
+ env.ok,
16921
+ env.data,
16922
+ env.error,
16923
+ env.meta.warnings ?? null,
16924
+ env.meta.context ?? null
16925
+ ])).digest("hex");
16926
+ }
16927
+ var byId = (a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
16413
16928
  /** The tables kept per dossier that a sync never rewrites: the worklog's, and the analyses (#395). */
16414
16929
  var KEPT_TABLES = [...WORKLOG_TABLES, "analyses"];
16415
16930
  /** The one message every OS gives for a wipe while Toil UI runs. */
@@ -16593,7 +17108,7 @@ var Cache = class Cache {
16593
17108
  }
16594
17109
  /** The envelope a call got on its last good sync. */
16595
17110
  response(dossier, command, input) {
16596
- const row = this.db.prepare("SELECT envelope, area, synced_at FROM responses WHERE dossier = ? AND command = ? AND input_key = ?").get(dossier, command, inputKey(input));
17111
+ const row = this.db.prepare("SELECT envelope, area, synced_at FROM responses WHERE dossier = ? AND command = ? AND input_key = ?").get(dossier, command, inputKey(input, command));
16597
17112
  return row ? {
16598
17113
  envelope: JSON.parse(row.envelope),
16599
17114
  area: row.area,
@@ -16609,6 +17124,14 @@ var Cache = class Cache {
16609
17124
  syncedAt: row.synced_at
16610
17125
  } : null;
16611
17126
  }
17127
+ /** Every stored envelope for a command in a dossier, whatever its input. */
17128
+ all(dossier, command) {
17129
+ return this.db.prepare("SELECT envelope, area, synced_at FROM responses WHERE dossier = ? AND command = ? ORDER BY synced_at DESC").all(dossier, command).map((row) => ({
17130
+ envelope: JSON.parse(row.envelope),
17131
+ area: row.area,
17132
+ syncedAt: row.synced_at
17133
+ }));
17134
+ }
16612
17135
  source(dossier, area) {
16613
17136
  const row = this.db.prepare("SELECT * FROM sources WHERE dossier = ? AND area = ?").get(dossier, area);
16614
17137
  return row ? sourceOf(row) : null;
@@ -16620,6 +17143,7 @@ var Cache = class Cache {
16620
17143
  return dossiers.map((d) => ({
16621
17144
  name: d.name,
16622
17145
  lastSyncAt: d.last_sync_at,
17146
+ lastSavedAt: d.last_saved_at ?? null,
16623
17147
  status: d.status,
16624
17148
  error: d.error,
16625
17149
  sources: sources.filter((s) => s.dossier === d.name).map(sourceOf)
@@ -16696,7 +17220,7 @@ var Cache = class Cache {
16696
17220
  if (input.dossier === from) input.dossier = to;
16697
17221
  const envelope = JSON.parse(r.envelope);
16698
17222
  if (envelope.meta?.context?.dossier?.name === from) envelope.meta.context.dossier.name = to;
16699
- moved += Number(move.run(to, inputKey(input), JSON.stringify(envelope), from, r.command, r.input_key).changes);
17223
+ moved += Number(move.run(to, inputKey(input, r.command), JSON.stringify(envelope), from, r.command, r.input_key).changes);
16700
17224
  }
16701
17225
  for (const table of [
16702
17226
  "items",
@@ -16729,7 +17253,7 @@ var Cache = class Cache {
16729
17253
  dossierNames() {
16730
17254
  return this.db.prepare("SELECT name FROM dossiers UNION SELECT DISTINCT dossier FROM responses ORDER BY 1").all().map((r) => r.name);
16731
17255
  }
16732
- /** A dossier whose `dossiers show` failed: its last sync time and error, and nothing else touched. */
17256
+ /** A dossier whose `dossiers show` failed: its last attempt and error, and nothing else touched. `last_saved_at` stays, so a failing sync keeps no data alive. */
16733
17257
  saveFailure(dossier, at, error) {
16734
17258
  this.db.prepare("INSERT INTO dossiers (name, last_sync_at, status, error) VALUES (?, ?, ?, ?) ON CONFLICT (name) DO UPDATE SET last_sync_at = excluded.last_sync_at, status = excluded.status, error = excluded.error").run(dossier, at, "failed", error);
16735
17259
  }
@@ -16751,9 +17275,12 @@ var Cache = class Cache {
16751
17275
  this.transaction(() => {
16752
17276
  const previous = this.db.prepare("SELECT name FROM dossiers WHERE name = ?").get(save.dossier);
16753
17277
  const lastGood = this.db.prepare("SELECT MAX(at) AS at FROM sync_runs WHERE dossier = ? AND ok = 1").get(save.dossier).at;
17278
+ const refresh = (/* @__PURE__ */ new Date(Date.parse(at) - this.retentionDays * DAY / 4)).toISOString();
17279
+ const itemRows = this.db.prepare("SELECT id, item FROM items WHERE dossier = ? ORDER BY id").all(save.dossier);
17280
+ const refRows = this.db.prepare("SELECT kind, id, ref FROM change_refs WHERE dossier = ?").all(save.dossier);
16754
17281
  const before = previous ? {
16755
- items: this.items(save.dossier),
16756
- deployments: this.changes(save.dossier).filter((c) => c.kind === "deployment").map((c) => c.ref)
17282
+ items: itemRows.map((r) => JSON.parse(r.item)),
17283
+ deployments: refRows.filter((c) => c.kind === "deployment").sort(byId).map((c) => JSON.parse(c.ref))
16757
17284
  } : null;
16758
17285
  const builds = this.db.prepare("SELECT event FROM worklog_events WHERE dossier = ? AND kind LIKE 'build-%'").all(save.dossier).map((r) => JSON.parse(r.event));
16759
17286
  const facts = [...eventsFrom({
@@ -16765,35 +17292,95 @@ var Cache = class Cache {
16765
17292
  }, at, lastGood)];
16766
17293
  const fact = this.db.prepare(`INSERT INTO worklog_events (dossier, key, day, at, kind, event, synced_at) VALUES (?, ?, ?, ?, ?, ?, ?)
16767
17294
  ON CONFLICT (dossier, key) DO UPDATE SET day = excluded.day, at = excluded.at, kind = excluded.kind, event = excluded.event, synced_at = excluded.synced_at`);
16768
- const known = new Set(this.db.prepare("SELECT key FROM worklog_events WHERE dossier = ?").all(save.dossier).map((r) => r.key));
17295
+ const known = new Map(this.db.prepare("SELECT key, event, synced_at FROM worklog_events WHERE dossier = ?").all(save.dossier).map((r) => [r.key, r]));
16769
17296
  const since = lastGood ? Date.parse(lastGood) - NEWS_SKEW_MS : null;
16770
17297
  news = previous && since !== null ? facts.filter((e) => !known.has(e.key) && (e.observed !== null || Date.parse(e.at) >= since)) : [];
16771
- for (const e of facts) fact.run(save.dossier, e.key, dayOf(e.at), e.at, e.kind, JSON.stringify(e), at);
17298
+ for (const e of facts) {
17299
+ const text = JSON.stringify(e);
17300
+ const old = known.get(e.key);
17301
+ if (old && old.event === text && old.synced_at >= refresh) continue;
17302
+ fact.run(save.dossier, e.key, dayOf(e.at), e.at, e.kind, text, at);
17303
+ }
16772
17304
  const run = this.db.prepare("INSERT OR REPLACE INTO sync_runs (dossier, area, at, ok, error) VALUES (?, ?, ?, ?, ?)");
16773
17305
  for (const s of save.sources) run.run(save.dossier, s.area, at, s.ok ? 1 : 0, s.error);
16774
- const put = this.db.prepare("INSERT INTO responses (dossier, command, input_key, area, envelope, synced_at) VALUES (?, ?, ?, ?, ?, ?) ON CONFLICT (dossier, command, input_key) DO UPDATE SET area = excluded.area, envelope = excluded.envelope, synced_at = excluded.synced_at");
16775
- for (const r of save.responses) put.run(save.dossier, r.command, inputKey(r.input), areaOf(r.command), JSON.stringify(r.envelope), at);
16776
- const drop = this.db.prepare("DELETE FROM responses WHERE dossier = ? AND area = ? AND synced_at < ?");
16777
- for (const s of save.sources) if (s.ok) drop.run(save.dossier, s.area, at);
16778
- for (const table of [
16779
- "items",
16780
- "transitions",
16781
- "change_refs"
16782
- ]) this.db.prepare(`DELETE FROM ${table} WHERE dossier = ?`).run(save.dossier);
17306
+ const stored = new Map(this.db.prepare("SELECT command, input_key, area, digest FROM responses WHERE dossier = ?").all(save.dossier).map((r) => [`${r.command}\n${r.input_key}`, r]));
17307
+ const okAreas = save.sources.filter((s) => s.ok).map((s) => s.area);
17308
+ const put = this.db.prepare("INSERT INTO responses (dossier, command, input_key, area, envelope, synced_at, digest) VALUES (?, ?, ?, ?, ?, ?, ?) ON CONFLICT (dossier, command, input_key) DO UPDATE SET area = excluded.area, envelope = excluded.envelope, synced_at = excluded.synced_at, digest = excluded.digest");
17309
+ const touch = this.db.prepare("UPDATE responses SET synced_at = ? WHERE dossier = ? AND command = ? AND input_key = ? AND synced_at < ?");
17310
+ const wanted = /* @__PURE__ */ new Set();
17311
+ for (const r of save.responses) {
17312
+ const key = inputKey(r.input, r.command);
17313
+ const id = `${r.command}\n${key}`;
17314
+ wanted.add(id);
17315
+ const old = stored.get(id);
17316
+ const digest = r.unchanged && old?.digest ? old.digest : digestOf(r.envelope);
17317
+ if (old && old.digest === digest) {
17318
+ if (!okAreas.includes(old.area)) touch.run(at, save.dossier, r.command, key, refresh);
17319
+ continue;
17320
+ }
17321
+ put.run(save.dossier, r.command, key, areaOf(r.command), JSON.stringify(r.envelope), at, digest);
17322
+ }
17323
+ const drop = this.db.prepare("DELETE FROM responses WHERE dossier = ? AND command = ? AND input_key = ?");
17324
+ for (const [id, r] of stored) if (!wanted.has(id) && okAreas.includes(r.area)) drop.run(save.dossier, id.slice(0, id.indexOf("\n")), id.slice(id.indexOf("\n") + 1));
17325
+ if (okAreas.length) this.db.prepare(`UPDATE responses SET synced_at = ? WHERE dossier = ? AND synced_at < ? AND area IN (${okAreas.map(() => "?").join(", ")})`).run(at, save.dossier, refresh, ...okAreas);
17326
+ const oldItems = new Map(itemRows.map((r) => [r.id, r.item]));
17327
+ const nowItems = new Map(save.items.map((i) => [i.id, i]));
16783
17328
  const item = this.db.prepare("INSERT OR REPLACE INTO items (dossier, id, area, connection, native_key, type, status_category, updated, item, synced_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
17329
+ const dropTransitions = this.db.prepare("DELETE FROM transitions WHERE dossier = ? AND item_id = ?");
16784
17330
  const transition = this.db.prepare("INSERT OR REPLACE INTO transitions (dossier, item_id, seq, from_status, to_status, from_category, to_category, at, by_name, synced_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
16785
- for (const i of save.items) {
16786
- item.run(save.dossier, i.id, i.source.area, i.source.connection, i.source.key, i.type, i.statusCategory, i.updated, JSON.stringify(i), at);
17331
+ for (const [id, i] of nowItems) {
17332
+ const text = JSON.stringify(i);
17333
+ if (oldItems.get(id) === text) continue;
17334
+ item.run(save.dossier, i.id, i.source.area, i.source.connection, i.source.key, i.type, i.statusCategory, i.updated, text, at);
17335
+ dropTransitions.run(save.dossier, id);
16787
17336
  (i.history?.transitions ?? []).forEach((t, seq) => transition.run(save.dossier, i.id, seq, t.from, t.to, t.fromCategory, t.toCategory, t.at, t.by?.name ?? null, at));
16788
17337
  }
17338
+ const dropItem = this.db.prepare("DELETE FROM items WHERE dossier = ? AND id = ?");
17339
+ for (const id of oldItems.keys()) if (!nowItems.has(id)) dropItem.run(save.dossier, id);
17340
+ this.db.prepare("DELETE FROM transitions WHERE dossier = ? AND item_id NOT IN (SELECT id FROM items WHERE dossier = ?)").run(save.dossier, save.dossier);
17341
+ const nowRefs = /* @__PURE__ */ new Map();
17342
+ for (const c of save.changes) nowRefs.set(`${c.kind}\n${c.id}`, {
17343
+ kind: c.kind,
17344
+ id: c.id,
17345
+ text: JSON.stringify(c),
17346
+ values: [
17347
+ c.source,
17348
+ c.command,
17349
+ c.state,
17350
+ c.outcome,
17351
+ c.at || null,
17352
+ JSON.stringify(c.items)
17353
+ ]
17354
+ });
17355
+ for (const d of save.deployments) nowRefs.set(`deployment\n${d.id}`, {
17356
+ kind: "deployment",
17357
+ id: d.id,
17358
+ text: JSON.stringify(d),
17359
+ values: [
17360
+ d.source,
17361
+ d.command,
17362
+ d.state,
17363
+ d.outcome,
17364
+ null,
17365
+ JSON.stringify(d.items)
17366
+ ]
17367
+ });
17368
+ const oldRefs = new Map(refRows.map((r) => [`${r.kind}\n${r.id}`, r.ref]));
16789
17369
  const change = this.db.prepare("INSERT OR REPLACE INTO change_refs (dossier, id, kind, area, command, state, outcome, at, items, ref, synced_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
16790
- for (const c of save.changes) change.run(save.dossier, c.id, c.kind, c.source, c.command, c.state, c.outcome, c.at || null, JSON.stringify(c.items), JSON.stringify(c), at);
16791
- for (const d of save.deployments) change.run(save.dossier, d.id, "deployment", d.source, d.command, d.state, d.outcome, null, JSON.stringify(d.items), JSON.stringify(d), at);
16792
- const source = this.db.prepare(`INSERT INTO sources (dossier, area, status, last_attempt_at, last_success_at, watermark, error, fix, calls) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
17370
+ for (const [key, c] of nowRefs) if (oldRefs.get(key) !== c.text) change.run(save.dossier, c.id, c.kind, ...c.values, c.text, at);
17371
+ const dropRef = this.db.prepare("DELETE FROM change_refs WHERE dossier = ? AND kind = ? AND id = ?");
17372
+ for (const key of oldRefs.keys()) if (!nowRefs.has(key)) dropRef.run(save.dossier, key.slice(0, key.indexOf("\n")), key.slice(key.indexOf("\n") + 1));
17373
+ for (const table of [
17374
+ "items",
17375
+ "transitions",
17376
+ "change_refs"
17377
+ ]) this.db.prepare(`UPDATE ${table} SET synced_at = ? WHERE dossier = ? AND synced_at < ?`).run(at, save.dossier, refresh);
17378
+ const source = this.db.prepare(`INSERT INTO sources (dossier, area, status, last_attempt_at, last_success_at, watermark, full_read_at, error, fix, calls) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
16793
17379
  ON CONFLICT (dossier, area) DO UPDATE SET status = excluded.status, last_attempt_at = excluded.last_attempt_at,
16794
17380
  last_success_at = COALESCE(excluded.last_success_at, sources.last_success_at), watermark = COALESCE(excluded.watermark, sources.watermark),
17381
+ full_read_at = COALESCE(excluded.full_read_at, sources.full_read_at),
16795
17382
  error = excluded.error, fix = excluded.fix, calls = excluded.calls`);
16796
- for (const s of save.sources) source.run(save.dossier, s.area, s.ok ? "ok" : "failed", at, s.ok ? at : null, s.ok ? s.watermark : null, s.error, s.fix, s.calls);
17383
+ for (const s of save.sources) source.run(save.dossier, s.area, s.ok ? "ok" : "failed", at, s.ok ? at : null, s.ok ? s.watermark : null, s.ok ? s.fullReadAt ?? null : null, s.error, s.fix, s.calls);
16797
17384
  const areas = save.sources.map((s) => s.area);
16798
17385
  for (const old of this.db.prepare("SELECT area FROM sources WHERE dossier = ?").all(save.dossier)) if (!areas.includes(old.area)) {
16799
17386
  this.db.prepare("DELETE FROM sources WHERE dossier = ? AND area = ?").run(save.dossier, old.area);
@@ -16802,7 +17389,7 @@ var Cache = class Cache {
16802
17389
  const failed = save.sources.filter((s) => !s.ok);
16803
17390
  const status = failed.length === 0 ? "ok" : failed.length === save.sources.length ? "failed" : "partial";
16804
17391
  const error = failed.length ? failed.map((s) => `${s.area}: ${s.error ?? "failed"}`).join(" ") : null;
16805
- this.db.prepare("INSERT INTO dossiers (name, last_sync_at, status, error) VALUES (?, ?, ?, ?) ON CONFLICT (name) DO UPDATE SET last_sync_at = excluded.last_sync_at, status = excluded.status, error = excluded.error").run(save.dossier, at, status, error);
17392
+ this.db.prepare("INSERT INTO dossiers (name, last_sync_at, last_saved_at, status, error) VALUES (?, ?, ?, ?, ?) ON CONFLICT (name) DO UPDATE SET last_sync_at = excluded.last_sync_at, last_saved_at = excluded.last_saved_at, status = excluded.status, error = excluded.error").run(save.dossier, at, at, status, error);
16806
17393
  });
16807
17394
  this.prune();
16808
17395
  return news;
@@ -16848,21 +17435,40 @@ var Cache = class Cache {
16848
17435
  analyses(dossier) {
16849
17436
  return this.db.prepare("SELECT record FROM analyses WHERE dossier = ? ORDER BY at, id").all(dossier).map((r) => JSON.parse(r.record));
16850
17437
  }
16851
- /** Deletes every row last synced before the retention period. Returns how many went. */
17438
+ /**
17439
+ * Deletes what is older than the retention period. Returns how many went.
17440
+ * Everything a sync writes goes per dossier, together, by one date: `dossiers.last_saved_at`, the last time a sync
17441
+ * saved data (a failed `dossiers show` moves `last_sync_at`, the last attempt, and leaves this alone, so a failing sync
17442
+ * keeps nothing alive). A dossier is kept while last_saved_at >= now - retention. A dossier that is not kept loses its
17443
+ * responses, items, transitions, change refs, worklog facts and sources, and then its row, in this one transaction, so
17444
+ * a dossier is never half there. (One that only ever failed has no last_saved_at; its row goes by last_sync_at.) The
17445
+ * rows' own synced_at values differ by up to a quarter of the period (saveDossier refreshes only the unchanged rows it
17446
+ * finds old), so they can't decide on their own. The rest goes by its own date.
17447
+ *
17448
+ * Worklog facts also go by their own date, 1.25 x retention. saveDossier only upserts a fact, so one that no sync produces
17449
+ * any more (its item left the sync) would otherwise live as long as the dossier keeps saving. A fact a sync still
17450
+ * produces is refreshed at a save whenever it is more than retention/4 old. While the dossier is kept its last save was
17451
+ * at or after now - retention, and at that save the fact's synced_at became at least save - retention/4, so it is at or
17452
+ * after now - 1.25 x retention and this rule never touches it. A fact nothing produces goes about 1.25 x retention after
17453
+ * it was last seen. Once saves stop, the whole dossier goes at retention, before this rule matters.
17454
+ */
16852
17455
  prune() {
16853
17456
  const cutoff = (/* @__PURE__ */ new Date(this.now().getTime() - this.retentionDays * DAY)).toISOString();
16854
17457
  let removed = 0;
16855
17458
  this.transaction(() => {
17459
+ const kept = "SELECT name FROM dossiers WHERE last_saved_at >= ?";
16856
17460
  for (const table of [
16857
17461
  "responses",
16858
17462
  "items",
16859
17463
  "transitions",
16860
- "change_refs"
16861
- ]) removed += Number(this.db.prepare(`DELETE FROM ${table} WHERE synced_at < ?`).run(cutoff).changes);
16862
- removed += Number(this.db.prepare("DELETE FROM sources WHERE last_attempt_at < ?").run(cutoff).changes);
16863
- removed += Number(this.db.prepare("DELETE FROM dossiers WHERE last_sync_at < ?").run(cutoff).changes);
17464
+ "change_refs",
17465
+ "worklog_events",
17466
+ "sources"
17467
+ ]) removed += Number(this.db.prepare(`DELETE FROM ${table} WHERE dossier NOT IN (${kept})`).run(cutoff).changes);
17468
+ const stale = (/* @__PURE__ */ new Date(this.now().getTime() - this.retentionDays * 1.25 * DAY)).toISOString();
17469
+ removed += Number(this.db.prepare("DELETE FROM worklog_events WHERE synced_at < ?").run(stale).changes);
17470
+ removed += Number(this.db.prepare("DELETE FROM dossiers WHERE last_saved_at < ? OR (last_saved_at IS NULL AND last_sync_at < ?)").run(cutoff, cutoff).changes);
16864
17471
  if (this.db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'usage'").get()) removed += Number(this.db.prepare("DELETE FROM usage WHERE at < ?").run(cutoff).changes);
16865
- removed += Number(this.db.prepare("DELETE FROM worklog_events WHERE synced_at < ?").run(cutoff).changes);
16866
17472
  removed += Number(this.db.prepare("DELETE FROM sync_runs WHERE at < ?").run(cutoff).changes);
16867
17473
  removed += Number(this.db.prepare("DELETE FROM agent_runs WHERE started_at < ?").run(cutoff).changes);
16868
17474
  removed += Number(this.db.prepare("DELETE FROM notes WHERE at < ?").run(cutoff).changes);
@@ -16929,6 +17535,7 @@ function sourceOf(r) {
16929
17535
  lastAttemptAt: r.last_attempt_at,
16930
17536
  lastSuccessAt: r.last_success_at,
16931
17537
  watermark: r.watermark,
17538
+ fullReadAt: r.full_read_at ?? null,
16932
17539
  error: r.error,
16933
17540
  fix: r.fix,
16934
17541
  calls: Number(r.calls),
@@ -17041,8 +17648,8 @@ function memoryAnalyses(seed = []) {
17041
17648
  * page only reads: nothing it sends can write a record. Minutes taken by
17042
17649
  * the clerk, never by the people being minuted.
17043
17650
  */
17044
- /** An answer that is whole: not a partial still streaming, and with something in it. */
17045
- var isWhole = (a) => !!a && !a.activity && a.parts.length > 0;
17651
+ /** An answer that is whole: not a partial still streaming, and with something in it, prose or a briefing (#494). */
17652
+ var isWhole = (a) => !!a && !a.activity && (a.parts.length > 0 || Boolean(a.briefing));
17046
17653
  /** The cache's history: what a real Toil UI keeps. `cache` is a getter, since a wipe swaps the file underneath. */
17047
17654
  function cacheAnalyses(cache, now = () => (/* @__PURE__ */ new Date()).toISOString()) {
17048
17655
  return {
@@ -17220,23 +17827,18 @@ var recs = (v) => Array.isArray(v) ? v.filter(isRec) : [];
17220
17827
  var SEARCHES = {
17221
17828
  "jira issue search": {
17222
17829
  list: "issues",
17223
- id: (r) => String(r.key)
17224
- },
17225
- "jira-cloud issue search": {
17226
- list: "issues",
17227
- id: (r) => String(r.key)
17830
+ id: (r) => String(r.key),
17831
+ reconcile: true
17228
17832
  },
17229
17833
  "ado work-item search": {
17230
17834
  list: "workItems",
17231
- id: (r) => String(r.id)
17232
- },
17233
- "ado-cloud work-item search": {
17234
- list: "workItems",
17235
- id: (r) => String(r.id)
17835
+ id: (r) => String(r.id),
17836
+ reconcile: true
17236
17837
  },
17237
17838
  "github issue list": {
17238
17839
  list: null,
17239
- id: (r) => String(r.number)
17840
+ id: (r) => String(r.number),
17841
+ reconcile: false
17240
17842
  }
17241
17843
  };
17242
17844
  /** A batch get by ids: the input field holding them, and where the answer lists the items. */
@@ -17246,11 +17848,6 @@ var BATCHES = {
17246
17848
  list: "value",
17247
17849
  id: (r) => String(r.id)
17248
17850
  },
17249
- "ado-cloud work-item get-many": {
17250
- field: "id",
17251
- list: "value",
17252
- id: (r) => String(r.id)
17253
- },
17254
17851
  "github issue get": {
17255
17852
  field: "number",
17256
17853
  list: "issues",
@@ -17260,29 +17857,26 @@ var BATCHES = {
17260
17857
  /** One item's history: the input field naming the item. */
17261
17858
  var HISTORIES = {
17262
17859
  "jira issue history": "key",
17263
- "jira-cloud issue history": "key",
17264
17860
  "ado work-item history": "id",
17265
- "ado-cloud work-item history": "id",
17266
17861
  "github issue history": "number"
17267
17862
  };
17268
17863
  var BOARD = "github project items";
17864
+ /** Azure DevOps' feed of every revision since a date, which stands in for each item's history (src/ado-revisions.ts). */
17865
+ var ADO_FEED = "ado work-item feed";
17866
+ var ADO_SEARCH = "ado work-item search";
17269
17867
  /** Commands whose NOT_FOUND says the thing isn't there, which is worth knowing: the loader looks for CODEOWNERS where GitHub would. */
17270
17868
  var ABSENT_IS_AN_ANSWER = /* @__PURE__ */ new Set(["github repo file"]);
17271
17869
  /** Each host's pull request list, which `updatedSince` narrows, and how a pull request in it is named. */
17272
17870
  var PR_LISTS = {
17273
17871
  "github pr list": (r) => String(r.number),
17274
17872
  "bitbucket pr list": (r) => String(r.id),
17275
- "bitbucket-cloud pr list": (r) => String(r.id),
17276
- "ado pr list": (r) => String(r.pullRequestId),
17277
- "ado-cloud pr list": (r) => String(r.pullRequestId)
17873
+ "ado pr list": (r) => String(r.pullRequestId)
17278
17874
  };
17279
17875
  /** Each host's pull request get, and the input field naming the pull request. */
17280
17876
  var PR_GETS = {
17281
17877
  "github pr get": "number",
17282
17878
  "bitbucket pr get": "id",
17283
- "bitbucket-cloud pr get": "id",
17284
- "ado pr get": "id",
17285
- "ado-cloud pr get": "id"
17879
+ "ado pr get": "id"
17286
17880
  };
17287
17881
  /** A pull request record that is merged, declined or abandoned, by whichever host's words it uses. */
17288
17882
  var closedPr = (data) => isRec(data) && (data.state === "closed" || [
@@ -17290,6 +17884,17 @@ var closedPr = (data) => isRec(data) && (data.state === "closed" || [
17290
17884
  "DECLINED",
17291
17885
  "SUPERSEDED"
17292
17886
  ].includes(String(data.state)) || data.status === "completed" || data.status === "abandoned");
17887
+ /** Envelopes the sync handed back as the last copy, untouched: the cache needn't compare them with what it holds. */
17888
+ var reusedEnvelopes = /* @__PURE__ */ new WeakSet();
17889
+ var reuse = (env) => (reusedEnvelopes.add(env), env);
17890
+ /** The same search asking for ids only, where the command can: a listing to reconcile with, not to read. */
17891
+ var idsOnly = (command, input) => {
17892
+ if (!command.endsWith("issue search")) return input;
17893
+ return {
17894
+ ...Object.fromEntries(Object.entries(input).filter(([k]) => k !== "changelog")),
17895
+ fields: "key"
17896
+ };
17897
+ };
17293
17898
  /** Two pages of one listing as one answer: lists concatenated, the rest from the newer page. */
17294
17899
  function joinPages(a, b) {
17295
17900
  if (Array.isArray(a) && Array.isArray(b)) return [...a, ...b];
@@ -17318,6 +17923,7 @@ var SyncService = class {
17318
17923
  now;
17319
17924
  maxPages;
17320
17925
  onFinished;
17926
+ onForget;
17321
17927
  job = idle();
17322
17928
  current = null;
17323
17929
  controller = null;
@@ -17328,6 +17934,7 @@ var SyncService = class {
17328
17934
  this.now = options.now ?? (() => /* @__PURE__ */ new Date());
17329
17935
  this.maxPages = options.maxPages ?? 200;
17330
17936
  this.onFinished = options.onFinished;
17937
+ this.onForget = options.onForget;
17331
17938
  }
17332
17939
  status() {
17333
17940
  return {
@@ -17395,7 +18002,14 @@ var SyncService = class {
17395
18002
  const names = recs(list.data.dossiers).filter((d) => d.shadowedBy === null || d.shadowedBy === void 0).map((d) => String(d.name));
17396
18003
  if (only !== void 0 && !names.includes(only)) throw new Error(`toil has no dossier named ${JSON.stringify(only)}. Run toil dossiers list to see them.`);
17397
18004
  if (only === void 0) {
17398
- for (const old of this.cache.dossierNames()) if (!names.includes(old)) this.cache.forget(old);
18005
+ for (const old of this.cache.dossierNames()) if (!names.includes(old)) {
18006
+ this.cache.forget(old);
18007
+ try {
18008
+ this.onForget?.(old);
18009
+ } catch (e) {
18010
+ this.say(`${old}: couldn't forget its other records: ${e instanceof Error ? e.message : String(e)}`);
18011
+ }
18012
+ }
17399
18013
  }
17400
18014
  const targets = only === void 0 ? names : [only];
17401
18015
  job.dossiersTotal = targets.length;
@@ -17485,7 +18099,11 @@ var SyncService = class {
17485
18099
  const syncing = (command, input = {}) => this.answer(run, command, input, signal);
17486
18100
  let loaded;
17487
18101
  try {
17488
- loaded = await loadDossier(syncing, name, { mapOwi: this.mapOwi });
18102
+ loaded = await loadDossier(syncing, name, {
18103
+ mapOwi: this.mapOwi,
18104
+ windowDays: windowFor(this.cache.retentionDays),
18105
+ now: this.now
18106
+ });
17489
18107
  } catch (e) {
17490
18108
  const message = e instanceof Error ? e.message : String(e);
17491
18109
  this.cache.saveFailure(name, this.now().toISOString(), message);
@@ -17498,6 +18116,7 @@ var SyncService = class {
17498
18116
  error: s.error?.message ?? null,
17499
18117
  fix: s.error?.fix ?? null,
17500
18118
  watermark: s.error === null ? (/* @__PURE__ */ new Date(Date.parse(run.startedAt) - SKEW_MS)).toISOString() : null,
18119
+ fullReadAt: s.error === null && s.searches > 0 && s.fullSearches === s.searches ? run.startedAt : null,
17501
18120
  calls: s.calls
17502
18121
  }));
17503
18122
  const news = this.cache.saveDossier({
@@ -17525,7 +18144,9 @@ var SyncService = class {
17525
18144
  calls: 0,
17526
18145
  error: null,
17527
18146
  changed: null,
17528
- changedPrs: null
18147
+ changedPrs: null,
18148
+ searches: 0,
18149
+ fullSearches: 0
17529
18150
  };
17530
18151
  run.sources.set(area, s);
17531
18152
  }
@@ -17545,7 +18166,8 @@ var SyncService = class {
17545
18166
  run.responses.push({
17546
18167
  command,
17547
18168
  input,
17548
- envelope: env
18169
+ envelope: env,
18170
+ ...reusedEnvelopes.has(env) ? { unchanged: true } : {}
17549
18171
  });
17550
18172
  return env;
17551
18173
  }
@@ -17559,11 +18181,17 @@ var SyncService = class {
17559
18181
  }
17560
18182
  async fetch(run, source, command, input, signal) {
17561
18183
  const { dossier } = run;
17562
- const watermark = this.cache.source(dossier, source.area)?.watermark ?? null;
18184
+ const state = this.cache.source(dossier, source.area);
18185
+ const watermark = state?.watermark ?? null;
17563
18186
  const search = SEARCHES[command];
17564
18187
  if (search) {
18188
+ source.searches++;
17565
18189
  const last = this.cache.response(dossier, command, input);
17566
- if (!watermark || !last?.envelope.ok) return this.call(command, input, signal);
18190
+ if (!watermark || !last?.envelope.ok) {
18191
+ const whole = await this.call(command, input, signal);
18192
+ if (whole.ok) source.fullSearches++;
18193
+ return whole;
18194
+ }
17567
18195
  const delta = await this.call(command, {
17568
18196
  ...input,
17569
18197
  updatedSince: watermark
@@ -17573,7 +18201,21 @@ var SyncService = class {
17573
18201
  const fresh = listOf(delta.data);
17574
18202
  source.changed = /* @__PURE__ */ new Set([...source.changed ?? [], ...fresh.map(search.id)]);
17575
18203
  this.say(`${dossier}: ${command} since ${watermark}: ${fresh.length} changed`);
17576
- const merged = mergeById(listOf(last.envelope.data), fresh, search.id);
18204
+ let merged = mergeById(listOf(last.envelope.data), fresh, search.id);
18205
+ let removed = 0;
18206
+ const fullReadAt = state?.fullReadAt ?? null;
18207
+ if (search.reconcile && (fullReadAt === null || Date.parse(run.startedAt) - Date.parse(fullReadAt) >= 864e5)) {
18208
+ const whole = await this.call(command, idsOnly(command, input), signal);
18209
+ if (whole.ok) {
18210
+ const present = new Set(listOf(whole.data).map(search.id));
18211
+ const kept = merged.filter((r) => present.has(search.id(r)));
18212
+ removed = merged.length - kept.length;
18213
+ merged = kept;
18214
+ source.fullSearches++;
18215
+ if (removed) this.say(`${dossier}: ${command} listed whole: ${removed} no longer there`);
18216
+ } else this.say(`${dossier}: ${command} listed whole failed, ${whole.error.message}; keeping the changes since ${watermark}, trying again next sync`);
18217
+ }
18218
+ if (!fresh.length && !removed) return reuse(last.envelope);
17577
18219
  if (search.list === null) return {
17578
18220
  ...delta,
17579
18221
  data: merged
@@ -17589,6 +18231,33 @@ var SyncService = class {
17589
18231
  data
17590
18232
  };
17591
18233
  }
18234
+ if (command === ADO_FEED) {
18235
+ const last = this.cache.response(dossier, command, input);
18236
+ if (!watermark || !last?.envelope.ok || !Array.isArray(last.envelope.data)) return this.call(command, input, signal);
18237
+ const fullReadAt = state?.fullReadAt ?? null;
18238
+ if (fullReadAt === null || Date.parse(run.startedAt) - Date.parse(fullReadAt) >= 864e5) {
18239
+ const whole = await this.call(command, input, signal);
18240
+ if (whole.ok && Array.isArray(whole.data)) {
18241
+ this.say(`${dossier}: ${command} read whole: ${whole.data.length} revisions`);
18242
+ return whole;
18243
+ }
18244
+ this.say(`${dossier}: ${command} read whole failed${whole.ok ? "" : `, ${whole.error.message}`}; keeping the changes since ${watermark}, trying again next sync`);
18245
+ }
18246
+ const delta = await this.call(command, {
18247
+ ...input,
18248
+ updatedSince: watermark
18249
+ }, signal);
18250
+ if (!delta.ok || !Array.isArray(delta.data)) return delta;
18251
+ this.say(`${dossier}: ${command} since ${watermark}: ${delta.data.length} revisions`);
18252
+ const search = run.responses.find((r) => r.command === ADO_SEARCH && r.envelope.ok);
18253
+ const keep = search ? new Set(recs(search.envelope.data.workItems).map((w) => Number(w.id))) : void 0;
18254
+ const merged = mergeFeed(recs(last.envelope.data), recs(delta.data), keep);
18255
+ if (!delta.data.length && merged.length === last.envelope.data.length) return reuse(last.envelope);
18256
+ return {
18257
+ ...delta,
18258
+ data: merged
18259
+ };
18260
+ }
17592
18261
  const prId = PR_LISTS[command];
17593
18262
  if (prId) {
17594
18263
  const last = this.cache.response(dossier, command, input);
@@ -17611,7 +18280,7 @@ var SyncService = class {
17611
18280
  const last = this.cache.response(dossier, command, input);
17612
18281
  if (last?.envelope.ok && closedPr(last.envelope.data)) {
17613
18282
  this.job.reused++;
17614
- return last.envelope;
18283
+ return reuse(last.envelope);
17615
18284
  }
17616
18285
  }
17617
18286
  if (command === BOARD) {
@@ -17629,13 +18298,17 @@ var SyncService = class {
17629
18298
  const batch = BATCHES[command];
17630
18299
  if (batch && Array.isArray(input[batch.field]) && input[batch.field].length > 1) {
17631
18300
  const wanted = input[batch.field].map(String);
17632
- const last = this.cache.latest(dossier, command);
18301
+ const stored = this.cache.all(dossier, command).filter((r) => r.envelope.ok);
18302
+ const last = stored[0];
17633
18303
  const changed = source.changed;
17634
- if (changed === null || !last?.envelope.ok) return this.call(command, input, signal);
17635
- const cached = new Map(recs(last.envelope.data[batch.list]).map((r) => [batch.id(r), r]));
18304
+ if (changed === null || !last) return this.call(command, input, signal);
18305
+ const cached = /* @__PURE__ */ new Map();
18306
+ for (const row of stored) for (const r of recs(row.envelope.data[batch.list])) if (!cached.has(batch.id(r))) cached.set(batch.id(r), r);
17636
18307
  const toFetch = wanted.filter((id) => changed.has(id) || !cached.has(id));
17637
18308
  if (!toFetch.length) {
17638
18309
  this.job.reused++;
18310
+ const all = recs(last.envelope.data[batch.list]);
18311
+ if (stored.length === 1 && all.length === wanted.length && all.every((r, n) => batch.id(r) === wanted[n])) return reuse(last.envelope);
17639
18312
  return {
17640
18313
  ...last.envelope,
17641
18314
  data: {
@@ -17669,7 +18342,7 @@ var SyncService = class {
17669
18342
  const last = this.cache.response(dossier, command, input);
17670
18343
  if (last?.envelope.ok) {
17671
18344
  this.job.reused++;
17672
- return last.envelope;
18345
+ return reuse(last.envelope);
17673
18346
  }
17674
18347
  }
17675
18348
  return this.call(command, input, signal);
@@ -17730,7 +18403,7 @@ function publishProposals(dossier, what, path, areas) {
17730
18403
  const out = [];
17731
18404
  const reason = `The ${thing} exported to ${path}, as it stands. Check it reads as you want before it's posted: it is the cache's record, facts only.`;
17732
18405
  const space = areas.confluence?.inputs.space;
17733
- if (space) out.push({
18406
+ if (space && areas.confluence?.connection?.deployment !== "cloud") out.push({
17734
18407
  id: `${thing}:${dossier}:${span}:confluence`,
17735
18408
  from: "worklog",
17736
18409
  item: `${dossier}:${span}`,
@@ -18617,11 +19290,17 @@ DIRECTIVES.filter((d) => !d.startsWith("frame-ancestors")).join("; ");
18617
19290
  *
18618
19291
  * - **The launch token.** Each start makes a random token and prints one URL
18619
19292
  * that carries it, as Jupyter does. The page trades it (`POST api/session`)
18620
- * for a session id it keeps in memory and sends as `X-Toil-UI-Session` on
18621
- * every API call; the API answers nothing without one. No cookie is ever
18622
- * set: browsers send cookies to every port on a host, so one would reach any
18623
- * other server on 127.0.0.1. The static files hold no data and need no
18624
- * session. A reload forgets the id, so it takes the launch URL again.
19293
+ * for a session id and sends it as `X-Toil-UI-Session` on every API call; the
19294
+ * API answers nothing without one. No cookie is ever set: browsers send
19295
+ * cookies to every port on a host, so one would reach any other server on
19296
+ * 127.0.0.1. The page keeps the id in `sessionStorage` instead (#485), which
19297
+ * is scoped to this exact origin and never sent by the browser, so a reload
19298
+ * resumes through `GET api/session`; a new tab takes the launch URL again
19299
+ * (a duplicated or browser-restored tab can carry the id), and a restart of
19300
+ * this server (sessions are in memory) always ends it. The token stays: it
19301
+ * is what keeps other local processes and users out of an API that runs toil
19302
+ * with the person's connections. The static files hold no data and need no
19303
+ * session.
18625
19304
  * - **The Host header.** Only the exact `127.0.0.1:<port>` (or `[::1]:<port>`)
18626
19305
  * the server printed is answered, so a page using DNS rebinding to reach the
18627
19306
  * port is refused before anything else is read.
@@ -18693,6 +19372,30 @@ function kept(keeper, dossier, startedAt) {
18693
19372
  stream
18694
19373
  };
18695
19374
  }
19375
+ /**
19376
+ * Remembers the adapter for a dossier (#494) once its Analyze answer is whole, and only then: a stopped
19377
+ * or failed run says nothing about what the person prefers. A memory that can't be written never fails the answer.
19378
+ */
19379
+ function rememberer(store, dossier, adapter) {
19380
+ const one = (answer) => {
19381
+ if (!isWhole(answer)) return;
19382
+ try {
19383
+ store.set(dossier, adapter);
19384
+ } catch {}
19385
+ };
19386
+ async function* stream(answers, signal) {
19387
+ let last;
19388
+ for await (const a of answers) {
19389
+ last = a;
19390
+ yield a;
19391
+ }
19392
+ if (!signal.aborted && last) one(last);
19393
+ }
19394
+ return {
19395
+ one,
19396
+ stream
19397
+ };
19398
+ }
18696
19399
  /** The session id the page got for the launch token, on every API call. Never a cookie. */
18697
19400
  var SESSION_HEADER = "x-toil-ui-session";
18698
19401
  var TYPES = {
@@ -19009,7 +19712,7 @@ function createUiServer(options) {
19009
19712
  const csrf = req.headers[CSRF_HEADER];
19010
19713
  if (typeof csrf !== "string" || !same(csrf, session.csrf)) throw new HttpError(403, "The request didn't carry this session's CSRF token.", `Send the csrf value ${base}api/session gave in the ${CSRF_HEADER} header.`);
19011
19714
  };
19012
- /** `POST api/session`: the launch token for a new session id, which the page keeps in memory. */
19715
+ /** `POST api/session`: the launch token for a new session id, which the page keeps in its tab's `sessionStorage` (#485). */
19013
19716
  const signIn = async (req, res) => {
19014
19717
  checkOrigin(req);
19015
19718
  const body = await readJson(req);
@@ -19106,7 +19809,7 @@ function createUiServer(options) {
19106
19809
  if (key === "POST session") return signIn(req, res);
19107
19810
  if (key === "POST agent/mcp") return mcpCall(req, res, ctx);
19108
19811
  const signedIn = sessionOf(req);
19109
- if (!signedIn) throw new HttpError(401, `The API answers only a page signed in to this launch, with its session id in ${SESSION_HEADER}.`, "Open the URL toil-ui printed when it started; a reloaded page needs it again.");
19812
+ if (!signedIn) throw new HttpError(401, `The API answers only a page signed in to this launch, with its session id in ${SESSION_HEADER}.`, "Open the URL toil-ui printed when it started; a tab keeps its session across a reload, but not across a restart of toil-ui.");
19110
19813
  if (req.method === "POST") {
19111
19814
  checkOrigin(req);
19112
19815
  checkCsrf(req, signedIn.session);
@@ -19143,12 +19846,15 @@ function createUiServer(options) {
19143
19846
  const chat = chatOf(body.chat);
19144
19847
  const extra = extraOf(body);
19145
19848
  const keep = body.prompt === "analyze" && options.analyses ? kept(options.analyses, body.dossier, (/* @__PURE__ */ new Date()).toISOString()) : null;
19849
+ const remember = body.prompt === "analyze" && extra.adapter && options.dossierAgents ? rememberer(options.dossierAgents, body.dossier, extra.adapter) : null;
19146
19850
  if (body.stream === true && agent.stream) {
19147
19851
  const answers = agent.stream(ctx, body.dossier, body.prompt, style, chat, extra);
19148
- return streamAnswer(res, keep ? keep.stream(answers, ctx.signal) : answers);
19852
+ const remembered = remember ? remember.stream(answers, ctx.signal) : answers;
19853
+ return streamAnswer(res, keep ? keep.stream(remembered, ctx.signal) : remembered);
19149
19854
  }
19150
19855
  try {
19151
19856
  const answer = await agent.ask(ctx, body.dossier, body.prompt, style, chat, extra);
19857
+ if (remember && !ctx.signal.aborted) remember.one(answer);
19152
19858
  json(res, 200, keep && !ctx.signal.aborted ? await keep.one(answer) : answer);
19153
19859
  } catch (e) {
19154
19860
  json(res, 502, { error: agentFailure(e) });
@@ -19208,10 +19914,18 @@ function createUiServer(options) {
19208
19914
  json(res, 200, control().status());
19209
19915
  return;
19210
19916
  case "GET agent/adapters":
19211
- json(res, 200, agent.adapterOptions?.() ?? {
19212
- chosen: null,
19213
- options: []
19214
- });
19917
+ {
19918
+ const list = agent.adapterOptions?.() ?? {
19919
+ chosen: null,
19920
+ options: []
19921
+ };
19922
+ const dossier = url.searchParams.get("dossier");
19923
+ const remembered = dossier && options.dossierAgents ? options.dossierAgents.get(dossier) : null;
19924
+ json(res, 200, remembered ? {
19925
+ ...list,
19926
+ remembered
19927
+ } : list);
19928
+ }
19215
19929
  return;
19216
19930
  case "GET agent/install":
19217
19931
  json(res, 200, control().installPlan(installAdapter(url.searchParams.get("adapter"))));
@@ -19404,6 +20118,89 @@ function createUiServer(options) {
19404
20118
  }
19405
20119
  };
19406
20120
  }
20121
+ //#endregion
20122
+ //#region server/agents/dossier-agents.ts
20123
+ /**
20124
+ * The agent last used for each dossier's Analyze (#494). Toil UI's own state,
20125
+ * so it lives in its data folder (`~/.toil-ui/dossier-agents.json`) beside the
20126
+ * global default in `agent.json`, never in toil's dossier file and never in
20127
+ * the browser: a second browser, or a restart, sees the same memory. The file
20128
+ * holds an adapter's name per dossier name and nothing else, so it has no
20129
+ * room for a key. A stale entry (a dossier renamed or removed behind Toil
20130
+ * UI's back) is only ever a name nobody asks for. A seating chart for
20131
+ * software that was told to sit wherever it sat last time.
20132
+ */
20133
+ var NAMES = [
20134
+ "claude",
20135
+ "copilot",
20136
+ "codex"
20137
+ ];
20138
+ /** toil's dossier names (the same rule the server checks a rename with). */
20139
+ var DOSSIER$2 = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
20140
+ var MAX_DOSSIER = 200;
20141
+ var dossierAgentsFile = (dataDir) => nodePath.join(dataDir, "dossier-agents.json");
20142
+ var DossierAgents = class {
20143
+ dataDir;
20144
+ agents;
20145
+ constructor(dataDir) {
20146
+ this.dataDir = dataDir;
20147
+ this.agents = readAgents(dossierAgentsFile(dataDir));
20148
+ }
20149
+ /** The adapter last used for the dossier, or null. */
20150
+ get(dossier) {
20151
+ return this.agents.get(dossier) ?? null;
20152
+ }
20153
+ /** Remembers an adapter for a dossier; a name that is not an adapter or a dossier is ignored. */
20154
+ set(dossier, adapter) {
20155
+ if (!valid(dossier) || !NAMES.includes(adapter)) return false;
20156
+ if (this.agents.get(dossier) === adapter) return true;
20157
+ this.agents.set(dossier, adapter);
20158
+ this.save();
20159
+ return true;
20160
+ }
20161
+ /** A dossier toil renamed: its memory moves to the new name, replacing any left under it. */
20162
+ rename(from, to) {
20163
+ if (from === to || !valid(to)) return;
20164
+ const adapter = this.agents.get(from);
20165
+ const had = this.agents.delete(to);
20166
+ if (adapter === void 0) {
20167
+ if (had) this.save();
20168
+ return;
20169
+ }
20170
+ this.agents.delete(from);
20171
+ this.agents.set(to, adapter);
20172
+ this.save();
20173
+ }
20174
+ /** A dossier toil no longer has. */
20175
+ forget(dossier) {
20176
+ if (this.agents.delete(dossier)) this.save();
20177
+ }
20178
+ /** Writes owner-only through a temporary file, so a crash never leaves half of one. */
20179
+ save() {
20180
+ mkdirSync(this.dataDir, {
20181
+ recursive: true,
20182
+ mode: 448
20183
+ });
20184
+ const file = dossierAgentsFile(this.dataDir);
20185
+ const temp = `${file}.${process.pid}.tmp`;
20186
+ writeFileSync(temp, `${JSON.stringify({
20187
+ version: 1,
20188
+ agents: Object.fromEntries(this.agents)
20189
+ }, null, 2)}\n`, { mode: 384 });
20190
+ renameSync(temp, file);
20191
+ }
20192
+ };
20193
+ var valid = (dossier) => dossier.length <= MAX_DOSSIER && DOSSIER$2.test(dossier);
20194
+ /** What the file holds, entry by entry; a missing or broken file is no memory, never a failed start. */
20195
+ function readAgents(file) {
20196
+ const out = /* @__PURE__ */ new Map();
20197
+ try {
20198
+ const parsed = JSON.parse(readFileSync(file, "utf8"));
20199
+ if (typeof parsed.agents !== "object" || parsed.agents === null || Array.isArray(parsed.agents)) return out;
20200
+ for (const [dossier, adapter] of Object.entries(parsed.agents)) if (valid(dossier) && typeof adapter === "string" && NAMES.includes(adapter)) out.set(dossier, adapter);
20201
+ } catch {}
20202
+ return out;
20203
+ }
19407
20204
  var MAX_RETENTION_DAYS = 3650;
19408
20205
  /** v1 binds loopback only (#206, Local first). */
19409
20206
  var LOOPBACK = /* @__PURE__ */ new Set(["127.0.0.1", "::1"]);
@@ -19429,7 +20226,7 @@ Options:
19429
20226
  --port <n> Port; 0 (default) lets the OS pick a free one. Env: TOIL_UI_PORT
19430
20227
  --base-path <path> Path the app is served under (default /). Env: TOIL_UI_BASE_PATH
19431
20228
  --data-dir <dir> Toil UI's own folder (default ~/.toil-ui). Env: TOIL_UI_DATA_DIR
19432
- --retention-days <n> Days the cache keeps synced data (default 30). Env: TOIL_UI_RETENTION_DAYS
20229
+ --retention-days <n> Days the cache keeps synced data, and how far back closed Jira and Azure DevOps items are read (at least 42) (default 30). Env: TOIL_UI_RETENTION_DAYS
19433
20230
  --sample Serve sample data and the scripted agent, not toil.
19434
20231
  --version Print the version.
19435
20232
  --help Print this help.
@@ -20838,7 +21635,7 @@ var common = (dossier, mode, now) => [
20838
21635
  "3. Cite every work item you mention by its OWI id in double square brackets, such as [[jira:PAY-101]], and every pull request by its change id, exactly as your tools returned it. The server checks every id against your tool results and flags any it never saw.",
20839
21636
  "4. Your tools only read. When the work calls for a change to the tracker, write it as a proposal for a person to apply, in a fenced block like this, one block per change:",
20840
21637
  "```proposal",
20841
- "{\"item\": \"<owi id>\", \"title\": \"<one line>\", \"reason\": \"<why, citing [[ids]]>\", \"command\": \"<the toil write command, such as ado-cloud work-item update, or null if toil has none>\", \"input\": {\"<field>\": \"<value>\"}, \"note\": \"<anything to check first, or null>\"}",
21638
+ "{\"item\": \"<owi id>\", \"title\": \"<one line>\", \"reason\": \"<why, citing [[ids]]>\", \"command\": \"<the toil write command, such as ado work-item update, or null if toil has none>\", \"input\": {\"<field>\": \"<value>\"}, \"note\": \"<anything to check first, or null>\"}",
20842
21639
  "```",
20843
21640
  " The input is the toil command's MCP input, without the dossier and without allowWrite: call proposal_fields with the command first and use only its fields. Never say a change was made: it is only proposed.",
20844
21641
  "5. Anything you need a person to answer goes on a line of its own that starts QUESTION: followed by the question.",
@@ -20990,13 +21787,6 @@ var workFolder = (dataDir, id) => join(dataDir, "cache", "work", id);
20990
21787
  var cloneOf = (folder) => join(folder, "repo");
20991
21788
  /** The tracker command that posts a comment on an item, by area, where toil has one; its input from the item and the text. */
20992
21789
  var COMMENT = {
20993
- "ado-cloud": (key, body) => ({
20994
- command: "ado-cloud work-item comment",
20995
- input: {
20996
- id: Number(key),
20997
- body
20998
- }
20999
- }),
21000
21790
  github: (key, body) => {
21001
21791
  const m = /^([^/]+)\/([^#]+)#(\d+)$/.exec(key);
21002
21792
  return {
@@ -21025,13 +21815,6 @@ var COMMENT = {
21025
21815
  key,
21026
21816
  body
21027
21817
  }
21028
- }),
21029
- "jira-cloud": (key, body) => ({
21030
- command: "jira-cloud issue comment",
21031
- input: {
21032
- key,
21033
- body
21034
- }
21035
21818
  })
21036
21819
  };
21037
21820
  /** A report as one comment: its paragraphs, citations written as the ids they name. */
@@ -21548,7 +22331,7 @@ async function main() {
21548
22331
  return 0;
21549
22332
  }
21550
22333
  if (parsed.version) {
21551
- process.stdout.write(`0.1.0-beta.1 (toil ${version})\n`);
22334
+ process.stdout.write(`0.1.0-beta.3 (toil ${version})\n`);
21552
22335
  return 0;
21553
22336
  }
21554
22337
  const { settings } = parsed;
@@ -21566,6 +22349,7 @@ async function main() {
21566
22349
  let cache;
21567
22350
  let sync;
21568
22351
  let worklog;
22352
+ const dossierAgents = settings.sample ? void 0 : new DossierAgents(settings.dataDir);
21569
22353
  if (!settings.sample) {
21570
22354
  try {
21571
22355
  cache = await Cache.open(settings.dataDir, { retentionDays: settings.retentionDays });
@@ -21585,7 +22369,8 @@ async function main() {
21585
22369
  cache,
21586
22370
  execute,
21587
22371
  mapOwi,
21588
- onFinished: () => pages.reconcileAll()
22372
+ onFinished: () => pages.reconcileAll(),
22373
+ onForget: (dossier) => dossierAgents?.forget(dossier)
21589
22374
  });
21590
22375
  await worklog.reconcileAll().catch((e) => process.stderr.write(`toil-ui: couldn't fold the worklog pages again: ${e instanceof Error ? e.message : String(e)}\n`));
21591
22376
  }
@@ -21607,8 +22392,8 @@ async function main() {
21607
22392
  commit: typeof toilCommit === "string" ? toilCommit : null
21608
22393
  },
21609
22394
  toilUi: {
21610
- version: "0.1.0-beta.1",
21611
- commit: "2bb247a57f71f431f7bdf756d34752e704e81cb9"
22395
+ version: "0.1.0-beta.3",
22396
+ commit: "a8ca2c90f7942fbcd4cf98e643a97c83742330c4"
21612
22397
  }
21613
22398
  },
21614
22399
  toilBundle: toilBundle(),
@@ -21643,7 +22428,7 @@ async function main() {
21643
22428
  };
21644
22429
  const host = cache ? new AgentHost({
21645
22430
  dataDir: settings.dataDir,
21646
- version: "0.1.0-beta.1",
22431
+ version: "0.1.0-beta.3",
21647
22432
  data: (dossier) => {
21648
22433
  const data = cacheData(cache, dossier);
21649
22434
  return data && worklog ? {
@@ -21678,7 +22463,7 @@ async function main() {
21678
22463
  execute,
21679
22464
  mapIds,
21680
22465
  data,
21681
- version: "0.1.0-beta.1",
22466
+ version: "0.1.0-beta.3",
21682
22467
  toilVersion: version,
21683
22468
  ...fingerprints ? { fingerprints } : {}
21684
22469
  }),
@@ -21737,12 +22522,14 @@ async function main() {
21737
22522
  };
21738
22523
  step("its cache", () => cache.rename(from, to));
21739
22524
  step("its assignments", () => assignments.queue.renameDossier(from, to));
22525
+ step("its Analyze agent", () => dossierAgents?.rename(from, to));
21740
22526
  await worklog.reconcileAll().catch((e) => problems.push(`Toil UI couldn't fold the worklog again under ${to}: ${e instanceof Error ? e.message : String(e)}`));
21741
22527
  return problems;
21742
22528
  }
21743
22529
  } : void 0;
21744
22530
  const ui = createUiServer({
21745
22531
  ...renames ? { renames } : {},
22532
+ ...dossierAgents ? { dossierAgents } : {},
21746
22533
  settings,
21747
22534
  store: cache ? sqliteStore(() => cache, execute, toil) : fixtureStore(),
21748
22535
  agent: host ?? fixtureAgent(),
@@ -21754,7 +22541,7 @@ async function main() {
21754
22541
  assignments,
21755
22542
  ...fingerprints ? { serverStatus: () => fingerprints.server() } : {},
21756
22543
  appDir: fileURLToPath(new URL("../app/", import.meta.url)),
21757
- version: "0.1.0-beta.1",
22544
+ version: "0.1.0-beta.3",
21758
22545
  toil,
21759
22546
  config: settings.sample ? {
21760
22547
  areas: FIXTURE_AREAS,
@@ -21775,7 +22562,7 @@ async function main() {
21775
22562
  return 1;
21776
22563
  }
21777
22564
  process.stdout.write([
21778
- `Toil UI 0.1.0-beta.1 (beta, local only), on toil ${version}`,
22565
+ `Toil UI 0.1.0-beta.3 (beta, local only), on toil ${version}`,
21779
22566
  settings.sample ? "Serving sample data and the scripted agent; nothing connects to a tracker." : "Syncing through toil, read-only, with your own connections and dossiers. Only its Settings pages, and a dossier's name and description edited in place, change anything: toil's own connections and dossiers, when you ask. The worklog keeps its pages and your notes in its data folder, and writes anywhere else only when you export one. Feedback goes to Imagile only when you send it.",
21780
22567
  ...cache ? [`The cache is ${cache.paths.db}, kept ${settings.retentionDays} days after each sync; toil-ui wipe deletes it.`] : [],
21781
22568
  "",