@warlock.js/grimoire 5.58.0 → 5.59.0
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.
- package/CHANGELOG.md +24 -0
- package/esm/apps/check-apps.mjs +11 -5
- package/esm/apps/check-apps.mjs.map +1 -1
- package/esm/book/build.d.mts.map +1 -1
- package/esm/book/build.mjs.map +1 -1
- package/esm/bookmap/build.d.mts.map +1 -1
- package/esm/bookmap/build.mjs +5 -3
- package/esm/bookmap/build.mjs.map +1 -1
- package/esm/bookmap/steps.mjs +34 -3
- package/esm/bookmap/steps.mjs.map +1 -1
- package/esm/contracts/adapter.d.mts +22 -1
- package/esm/contracts/adapter.d.mts.map +1 -1
- package/esm/contracts/scry.d.mts +26 -6
- package/esm/contracts/scry.d.mts.map +1 -1
- package/esm/contracts/snapshot.d.mts +3 -1
- package/esm/contracts/snapshot.d.mts.map +1 -1
- package/esm/devtools/data.mjs +23 -3
- package/esm/devtools/data.mjs.map +1 -1
- package/esm/devtools/feature-map.mjs +149 -0
- package/esm/devtools/feature-map.mjs.map +1 -0
- package/esm/devtools/index.d.mts +2 -2
- package/esm/devtools/index.mjs +30 -9
- package/esm/devtools/index.mjs.map +1 -1
- package/esm/devtools/product-map.d.mts.map +1 -1
- package/esm/devtools/product-map.mjs +82 -7
- package/esm/devtools/product-map.mjs.map +1 -1
- package/esm/devtools/site.d.mts +43 -1
- package/esm/devtools/site.d.mts.map +1 -1
- package/esm/devtools/site.mjs +111 -15
- package/esm/devtools/site.mjs.map +1 -1
- package/esm/devtools/snapshot-source.mjs +15 -2
- package/esm/devtools/snapshot-source.mjs.map +1 -1
- package/esm/index.d.mts +3 -3
- package/esm/ownership/index.d.mts.map +1 -1
- package/esm/ownership/index.mjs +60 -1
- package/esm/ownership/index.mjs.map +1 -1
- package/esm/scry/compact.mjs +2 -1
- package/esm/scry/compact.mjs.map +1 -1
- package/esm/scry/format.d.mts.map +1 -1
- package/esm/scry/format.mjs +12 -1
- package/esm/scry/format.mjs.map +1 -1
- package/esm/scry/query.d.mts.map +1 -1
- package/esm/scry/query.mjs +147 -23
- package/esm/scry/query.mjs.map +1 -1
- package/esm/test-results/index.d.mts.map +1 -1
- package/esm/test-results/index.mjs.map +1 -1
- package/esm/warlock/actions.mjs +15 -7
- package/esm/warlock/actions.mjs.map +1 -1
- package/esm/warlock/adapter.d.mts.map +1 -1
- package/esm/warlock/adapter.mjs +36 -2
- package/esm/warlock/adapter.mjs.map +1 -1
- package/esm/warlock/commands.mjs +7 -2
- package/esm/warlock/commands.mjs.map +1 -1
- package/esm/warlock/logo.mjs +12 -0
- package/esm/warlock/logo.mjs.map +1 -0
- package/esm/warlock/mcp-tools.mjs +6 -6
- package/esm/warlock/mcp-tools.mjs.map +1 -1
- package/esm/workspace/cache.mjs +194 -0
- package/esm/workspace/cache.mjs.map +1 -0
- package/esm/workspace/index.d.mts.map +1 -1
- package/esm/workspace/index.mjs +3 -1
- package/esm/workspace/index.mjs.map +1 -1
- package/llms-full.txt +32 -9
- package/package.json +3 -3
- package/skills/record-a-change/SKILL.md +2 -0
- package/skills/use-the-grimoire/SKILL.md +30 -9
- package/ui/grimoire-static.js +57 -6
- package/ui/grimoire-view.js +1289 -310
- package/ui/grimoire.css +583 -2
- package/ui/product-map.css +157 -8
- package/ui/product-map.js +507 -59
package/ui/product-map.js
CHANGED
|
@@ -99,17 +99,24 @@ function productDate(value) {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
function productStatusChip(kit, status) {
|
|
102
|
-
return kit.el("span", {
|
|
102
|
+
return kit.el("span", {
|
|
103
|
+
class: `pm-chip pm-status pm-status--${status}`,
|
|
104
|
+
text: PRODUCT_STATUS[status] ?? status,
|
|
105
|
+
});
|
|
103
106
|
}
|
|
104
107
|
|
|
105
108
|
/** A traffic light: a shape and words as well as a colour. */
|
|
106
109
|
function productLight(kit, level, label) {
|
|
107
110
|
const light = PRODUCT_LIGHT[level] ?? PRODUCT_LIGHT.unknown;
|
|
108
111
|
|
|
109
|
-
return kit.el(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
return kit.el(
|
|
113
|
+
"span",
|
|
114
|
+
{ class: `pm-light pm-light--${PRODUCT_LIGHT[level] ? level : "unknown"}` },
|
|
115
|
+
[
|
|
116
|
+
kit.el("span", { class: "pm-light-glyph", "aria-hidden": "true", text: light.glyph }),
|
|
117
|
+
kit.el("span", { text: label ?? light.label }),
|
|
118
|
+
],
|
|
119
|
+
);
|
|
113
120
|
}
|
|
114
121
|
|
|
115
122
|
function productHealth(kit, health) {
|
|
@@ -119,12 +126,100 @@ function productHealth(kit, health) {
|
|
|
119
126
|
]);
|
|
120
127
|
}
|
|
121
128
|
|
|
129
|
+
/**
|
|
130
|
+
* The health strip of a feature card: four thin segments (flows written,
|
|
131
|
+
* criteria proven by tests, screenshots present, open findings) and a legend
|
|
132
|
+
* that says each number in words. Criteria with no recorded results are grey and
|
|
133
|
+
* read "not measured": that is a missing measurement, not a problem.
|
|
134
|
+
*/
|
|
135
|
+
function productStrip(kit, strip) {
|
|
136
|
+
if (!strip) return null;
|
|
137
|
+
|
|
138
|
+
const share = (part, whole) =>
|
|
139
|
+
whole > 0 ? Math.max(0, Math.min(100, Math.round((part / whole) * 100))) : 0;
|
|
140
|
+
const findings = strip.findings.errors + strip.findings.warnings;
|
|
141
|
+
const criteria = strip.criteria;
|
|
142
|
+
const parts = [
|
|
143
|
+
{
|
|
144
|
+
key: "flows",
|
|
145
|
+
fill: share(strip.flows.shipped, strip.flows.total),
|
|
146
|
+
tone: strip.flows.total ? "info" : "none",
|
|
147
|
+
text: `${productPlural(strip.flows.total, "flow")} written, ${strip.flows.shipped} shipped`,
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
key: "proof",
|
|
151
|
+
fill: criteria.measured ? share(criteria.proven, criteria.total) : 0,
|
|
152
|
+
tone:
|
|
153
|
+
!criteria.total || !criteria.measured
|
|
154
|
+
? "none"
|
|
155
|
+
: criteria.failing
|
|
156
|
+
? "bad"
|
|
157
|
+
: criteria.proven === criteria.total
|
|
158
|
+
? "good"
|
|
159
|
+
: "warn",
|
|
160
|
+
text: !criteria.total
|
|
161
|
+
? "No criteria written"
|
|
162
|
+
: criteria.measured
|
|
163
|
+
? `${criteria.proven} of ${criteria.total} criteria proven by tests`
|
|
164
|
+
: `${criteria.total} criteria, test results not measured`,
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
key: "shots",
|
|
168
|
+
fill: share(strip.screenshots.present, strip.screenshots.places),
|
|
169
|
+
tone: !strip.screenshots.places
|
|
170
|
+
? "none"
|
|
171
|
+
: strip.screenshots.present === strip.screenshots.places
|
|
172
|
+
? "good"
|
|
173
|
+
: "warn",
|
|
174
|
+
text: strip.screenshots.places
|
|
175
|
+
? `${strip.screenshots.present} of ${productPlural(strip.screenshots.places, "place")} with a screenshot`
|
|
176
|
+
: "No pages show it yet",
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
key: "findings",
|
|
180
|
+
fill: 100,
|
|
181
|
+
tone: strip.findings.errors ? "bad" : findings ? "warn" : "good",
|
|
182
|
+
text: findings ? `${productPlural(findings, "open finding")}` : "No open findings",
|
|
183
|
+
},
|
|
184
|
+
];
|
|
185
|
+
const summary = parts.map((part) => part.text).join("; ");
|
|
186
|
+
|
|
187
|
+
return kit.el(
|
|
188
|
+
"div",
|
|
189
|
+
{ class: "pm-strip", role: "group", "aria-label": "Health", title: summary },
|
|
190
|
+
[
|
|
191
|
+
kit.el(
|
|
192
|
+
"div",
|
|
193
|
+
{ class: "pm-strip-bar", "aria-hidden": "true" },
|
|
194
|
+
parts.map((part) =>
|
|
195
|
+
kit.el("span", { class: `pm-strip-seg is-${part.tone}` }, [
|
|
196
|
+
kit.el("span", { class: "pm-strip-fill", style: `width: ${part.fill}%` }),
|
|
197
|
+
]),
|
|
198
|
+
),
|
|
199
|
+
),
|
|
200
|
+
kit.el(
|
|
201
|
+
"ul",
|
|
202
|
+
{ class: "pm-strip-legend" },
|
|
203
|
+
parts.map((part) =>
|
|
204
|
+
kit.el("li", { class: `pm-strip-item is-${part.tone}` }, [
|
|
205
|
+
kit.el("span", { class: "pm-strip-dot", "aria-hidden": "true" }),
|
|
206
|
+
part.text,
|
|
207
|
+
]),
|
|
208
|
+
),
|
|
209
|
+
),
|
|
210
|
+
],
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
122
214
|
function productChips(kit, items, kind) {
|
|
123
215
|
if (!items || items.length === 0) return null;
|
|
124
216
|
|
|
125
217
|
return kit.el(
|
|
126
218
|
"ul",
|
|
127
|
-
{
|
|
219
|
+
{
|
|
220
|
+
class: `pm-chips pm-chips--${kind}`,
|
|
221
|
+
"aria-label": kind === "audience" ? "Who it is for" : "Where it lives",
|
|
222
|
+
},
|
|
128
223
|
items.map((item) => kit.el("li", { class: `pm-chip pm-chip--${kind}`, text: item })),
|
|
129
224
|
);
|
|
130
225
|
}
|
|
@@ -202,11 +297,15 @@ const PRODUCT_SHOT_EXTENSION = /\.(png|jpe?g|webp|gif)$/i;
|
|
|
202
297
|
* `ctx.file()` can never point an image outside the folder.
|
|
203
298
|
*/
|
|
204
299
|
function productShotPath(src) {
|
|
205
|
-
if (typeof src !== "string" || src === "" || src.startsWith("/") || /[\\:\0?#]/.test(src))
|
|
300
|
+
if (typeof src !== "string" || src === "" || src.startsWith("/") || /[\\:\0?#]/.test(src))
|
|
301
|
+
return false;
|
|
206
302
|
|
|
207
303
|
const segments = src.split("/");
|
|
208
304
|
|
|
209
|
-
return
|
|
305
|
+
return (
|
|
306
|
+
segments.every((segment) => segment !== "" && segment !== "." && segment !== "..") &&
|
|
307
|
+
PRODUCT_SHOT_EXTENSION.test(src)
|
|
308
|
+
);
|
|
210
309
|
}
|
|
211
310
|
|
|
212
311
|
function productShots(ctx, kit, list, lightbox) {
|
|
@@ -262,7 +361,11 @@ function productAppearances(ctx, kit, appearances, lightbox, withFlowLinks) {
|
|
|
262
361
|
kit.el("strong", { text: item.title ?? item.id }),
|
|
263
362
|
item.route ? kit.el("span", { class: "pm-place-route", text: item.route }) : null,
|
|
264
363
|
withFlowLinks && item.flow
|
|
265
|
-
? kit.link(
|
|
364
|
+
? kit.link(
|
|
365
|
+
`product/flow/${item.flow.split("/").map(productEncode).join("/")}`,
|
|
366
|
+
"See the story",
|
|
367
|
+
{ class: "pm-place-flow" },
|
|
368
|
+
)
|
|
266
369
|
: null,
|
|
267
370
|
]),
|
|
268
371
|
productShots(ctx, kit, item.screenshots, lightbox),
|
|
@@ -292,7 +395,11 @@ function productDeveloperToggle(kit, body) {
|
|
|
292
395
|
"aria-pressed": String(on),
|
|
293
396
|
text: "For developers",
|
|
294
397
|
});
|
|
295
|
-
const panel = kit.el(
|
|
398
|
+
const panel = kit.el(
|
|
399
|
+
"section",
|
|
400
|
+
{ class: "pm-developer", "aria-label": "For developers" },
|
|
401
|
+
on ? body() : [],
|
|
402
|
+
);
|
|
296
403
|
|
|
297
404
|
if (!on) panel.setAttribute("hidden", "");
|
|
298
405
|
|
|
@@ -342,6 +449,106 @@ function productLoadError(ctx, kit, what, error) {
|
|
|
342
449
|
]);
|
|
343
450
|
}
|
|
344
451
|
|
|
452
|
+
/** The sorts of the feature cards. `id` is the written order and the default. */
|
|
453
|
+
const PRODUCT_SORTS = [
|
|
454
|
+
{ value: "id", label: "Feature id" },
|
|
455
|
+
{ value: "name", label: "Name" },
|
|
456
|
+
{ value: "changed", label: "Recently changed" },
|
|
457
|
+
{ value: "health", label: "Health (worst first)" },
|
|
458
|
+
];
|
|
459
|
+
|
|
460
|
+
const PRODUCT_HEALTH_ORDER = { problem: 0, attention: 1, unknown: 2, good: 3 };
|
|
461
|
+
|
|
462
|
+
const productCompareText = (left, right) => (left < right ? -1 : left > right ? 1 : 0);
|
|
463
|
+
|
|
464
|
+
/** The cards in the order `sort` names; the sort is stable, so equal cards keep their written order. */
|
|
465
|
+
export function productSortFeatures(features, sort) {
|
|
466
|
+
const list = features.map((feature, index) => ({ feature, index }));
|
|
467
|
+
const by = {
|
|
468
|
+
id: (a, b) => productCompareText(a.feature.id, b.feature.id),
|
|
469
|
+
name: (a, b) => a.feature.title.localeCompare(b.feature.title),
|
|
470
|
+
changed: (a, b) => productCompareText(b.feature.changedAt ?? "", a.feature.changedAt ?? ""),
|
|
471
|
+
health: (a, b) =>
|
|
472
|
+
(PRODUCT_HEALTH_ORDER[a.feature.health.level] ?? 2) -
|
|
473
|
+
(PRODUCT_HEALTH_ORDER[b.feature.health.level] ?? 2),
|
|
474
|
+
}[sort];
|
|
475
|
+
|
|
476
|
+
if (!by) return features;
|
|
477
|
+
|
|
478
|
+
return list.sort((a, b) => by(a, b) || a.index - b.index).map((item) => item.feature);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/** The flow cards in the order `sort` names (`written`, `name`, `health`); the sort is stable. */
|
|
482
|
+
export function productSortFlows(flows, sort) {
|
|
483
|
+
const list = flows.map((flow, index) => ({ flow, index }));
|
|
484
|
+
const by = {
|
|
485
|
+
name: (a, b) => (a.flow.title ?? "").localeCompare(b.flow.title ?? ""),
|
|
486
|
+
health: (a, b) =>
|
|
487
|
+
(PRODUCT_HEALTH_ORDER[a.flow.health?.level] ?? 2) -
|
|
488
|
+
(PRODUCT_HEALTH_ORDER[b.flow.health?.level] ?? 2),
|
|
489
|
+
}[sort];
|
|
490
|
+
|
|
491
|
+
if (!by) return flows;
|
|
492
|
+
|
|
493
|
+
return list.sort((a, b) => by(a, b) || a.index - b.index).map((item) => item.flow);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* The features that changed since a day (`yyyy-mm-dd`) or since a release (the release's own
|
|
498
|
+
* changes included, and anything not yet released). An empty `since` keeps every feature.
|
|
499
|
+
*/
|
|
500
|
+
export function productChangedSince(features, since, releases = []) {
|
|
501
|
+
if (!since) return features;
|
|
502
|
+
|
|
503
|
+
if (since.startsWith("release:")) {
|
|
504
|
+
const name = since.slice("release:".length);
|
|
505
|
+
const position = releases.findIndex((item) => item.release === name);
|
|
506
|
+
|
|
507
|
+
if (position < 0) return features;
|
|
508
|
+
|
|
509
|
+
const later = new Set(releases.slice(position).map((item) => item.release));
|
|
510
|
+
|
|
511
|
+
return features.filter(
|
|
512
|
+
(feature) =>
|
|
513
|
+
feature.unreleased === true ||
|
|
514
|
+
(feature.changedIn ?? []).some((release) => later.has(release)),
|
|
515
|
+
);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
return features.filter((feature) => (feature.changedAt ?? "") >= since);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/** The "changed since" choices: the last week and month before the newest change, and each written release. */
|
|
522
|
+
function productSinceChoices(features, releases) {
|
|
523
|
+
const validDay = (value) =>
|
|
524
|
+
typeof value === "string" &&
|
|
525
|
+
/^\d{4}-\d{2}-\d{2}$/.test(value) &&
|
|
526
|
+
!Number.isNaN(new Date(`${value}T00:00:00Z`).getTime());
|
|
527
|
+
const newest = features.reduce(
|
|
528
|
+
(max, feature) =>
|
|
529
|
+
validDay(feature.changedAt) && feature.changedAt > max ? feature.changedAt : max,
|
|
530
|
+
"",
|
|
531
|
+
);
|
|
532
|
+
const choices = [];
|
|
533
|
+
|
|
534
|
+
if (newest !== "") {
|
|
535
|
+
for (const [days, label] of [
|
|
536
|
+
[7, "Last 7 days"],
|
|
537
|
+
[30, "Last 30 days"],
|
|
538
|
+
]) {
|
|
539
|
+
const day = new Date(`${newest}T00:00:00Z`);
|
|
540
|
+
|
|
541
|
+
day.setUTCDate(day.getUTCDate() - days);
|
|
542
|
+
choices.push({ value: day.toISOString().slice(0, 10), label: `${label} of activity` });
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
for (const item of [...releases].reverse())
|
|
547
|
+
choices.push({ value: `release:${item.release}`, label: `Release ${item.release} and later` });
|
|
548
|
+
|
|
549
|
+
return choices;
|
|
550
|
+
}
|
|
551
|
+
|
|
345
552
|
function productMapPage(ctx, kit, answer) {
|
|
346
553
|
const features = answer.features ?? [];
|
|
347
554
|
const live = features.filter((feature) => feature.status === "shipped").length;
|
|
@@ -359,7 +566,11 @@ function productMapPage(ctx, kit, answer) {
|
|
|
359
566
|
}),
|
|
360
567
|
]),
|
|
361
568
|
share
|
|
362
|
-
? kit.el("a", {
|
|
569
|
+
? kit.el("a", {
|
|
570
|
+
class: "pm-button pm-button--primary",
|
|
571
|
+
href: share.manageHref,
|
|
572
|
+
text: "Share this map",
|
|
573
|
+
})
|
|
363
574
|
: null,
|
|
364
575
|
]);
|
|
365
576
|
|
|
@@ -377,10 +588,14 @@ function productMapPage(ctx, kit, answer) {
|
|
|
377
588
|
|
|
378
589
|
const apps = [...new Set(features.flatMap((feature) => feature.apps))].sort();
|
|
379
590
|
const audiences = [...new Set(features.flatMap((feature) => feature.audience))].sort();
|
|
380
|
-
const
|
|
591
|
+
const releases = answer.releases ?? [];
|
|
592
|
+
const state = { text: "", app: "", audience: "", sort: "id", since: "" };
|
|
381
593
|
const grid = kit.el("ul", { class: "pm-grid" });
|
|
382
594
|
const count = kit.el("p", { class: "pm-count", role: "status", "aria-live": "polite" });
|
|
383
|
-
const none = kit.el("p", {
|
|
595
|
+
const none = kit.el("p", {
|
|
596
|
+
class: "pm-empty pm-empty--inline",
|
|
597
|
+
text: "No feature matches. Clear the search or a filter.",
|
|
598
|
+
});
|
|
384
599
|
|
|
385
600
|
const card = (feature) =>
|
|
386
601
|
kit.el("li", { class: "pm-card" }, [
|
|
@@ -389,7 +604,9 @@ function productMapPage(ctx, kit, answer) {
|
|
|
389
604
|
kit.el("span", { class: "pm-muted", text: productPlural(feature.flows, "flow") }),
|
|
390
605
|
]),
|
|
391
606
|
kit.el("h3", { class: "pm-card-title" }, [
|
|
392
|
-
kit.link(`product/feature/${productEncode(feature.id)}`, feature.title, {
|
|
607
|
+
kit.link(`product/feature/${productEncode(feature.id)}`, feature.title, {
|
|
608
|
+
class: "pm-card-link",
|
|
609
|
+
}),
|
|
393
610
|
]),
|
|
394
611
|
kit.el("p", {
|
|
395
612
|
class: "pm-card-summary",
|
|
@@ -397,12 +614,16 @@ function productMapPage(ctx, kit, answer) {
|
|
|
397
614
|
}),
|
|
398
615
|
productChips(kit, feature.audience, "audience"),
|
|
399
616
|
productChips(kit, feature.apps, "app"),
|
|
617
|
+
productStrip(kit, feature.strip),
|
|
400
618
|
productHealth(kit, feature.health),
|
|
401
619
|
]);
|
|
402
620
|
|
|
403
621
|
const show = () => {
|
|
404
622
|
const needle = state.text.trim().toLowerCase();
|
|
405
|
-
const matches =
|
|
623
|
+
const matches = productSortFeatures(
|
|
624
|
+
productChangedSince(features, state.since, releases),
|
|
625
|
+
state.sort,
|
|
626
|
+
).filter(
|
|
406
627
|
(feature) =>
|
|
407
628
|
(state.app === "" || feature.apps.includes(state.app)) &&
|
|
408
629
|
(state.audience === "" || feature.audience.includes(state.audience)) &&
|
|
@@ -448,6 +669,39 @@ function productMapPage(ctx, kit, answer) {
|
|
|
448
669
|
]),
|
|
449
670
|
apps.length > 1 ? select("App", apps, "app") : null,
|
|
450
671
|
audiences.length > 0 ? select("Audience", audiences, "audience") : null,
|
|
672
|
+
kit.el("label", { class: "pm-field" }, [
|
|
673
|
+
kit.el("span", { text: "Sort by" }),
|
|
674
|
+
kit.el(
|
|
675
|
+
"select",
|
|
676
|
+
{
|
|
677
|
+
"data-pm": "sort",
|
|
678
|
+
onchange: (event) => {
|
|
679
|
+
state.sort = event?.target?.value ?? "id";
|
|
680
|
+
show();
|
|
681
|
+
},
|
|
682
|
+
},
|
|
683
|
+
PRODUCT_SORTS.map((item) => kit.el("option", { value: item.value, text: item.label })),
|
|
684
|
+
),
|
|
685
|
+
]),
|
|
686
|
+
kit.el("label", { class: "pm-field" }, [
|
|
687
|
+
kit.el("span", { text: "Changed since" }),
|
|
688
|
+
kit.el(
|
|
689
|
+
"select",
|
|
690
|
+
{
|
|
691
|
+
"data-pm": "since",
|
|
692
|
+
onchange: (event) => {
|
|
693
|
+
state.since = event?.target?.value ?? "";
|
|
694
|
+
show();
|
|
695
|
+
},
|
|
696
|
+
},
|
|
697
|
+
[
|
|
698
|
+
kit.el("option", { value: "", text: "Any time" }),
|
|
699
|
+
...productSinceChoices(features, releases).map((item) =>
|
|
700
|
+
kit.el("option", { value: item.value, text: item.label }),
|
|
701
|
+
),
|
|
702
|
+
],
|
|
703
|
+
),
|
|
704
|
+
]),
|
|
451
705
|
]);
|
|
452
706
|
|
|
453
707
|
show();
|
|
@@ -455,8 +709,14 @@ function productMapPage(ctx, kit, answer) {
|
|
|
455
709
|
return kit.el("div", { class: "pm-page" }, [
|
|
456
710
|
header,
|
|
457
711
|
kit.el("ul", { class: "pm-stats", "aria-label": "At a glance" }, [
|
|
458
|
-
kit.el("li", {}, [
|
|
459
|
-
|
|
712
|
+
kit.el("li", {}, [
|
|
713
|
+
kit.el("strong", { text: String(features.length) }),
|
|
714
|
+
kit.el("span", { text: "features" }),
|
|
715
|
+
]),
|
|
716
|
+
kit.el("li", {}, [
|
|
717
|
+
kit.el("strong", { text: String(live) }),
|
|
718
|
+
kit.el("span", { text: "live" }),
|
|
719
|
+
]),
|
|
460
720
|
kit.el("li", {}, [
|
|
461
721
|
kit.el("strong", { text: String(attention) }),
|
|
462
722
|
kit.el("span", { text: attention === 1 ? "needs attention" : "need attention" }),
|
|
@@ -475,13 +735,50 @@ function productFlowCard(kit, flow) {
|
|
|
475
735
|
kit.el("span", { class: "pm-muted", text: flow.who }),
|
|
476
736
|
]),
|
|
477
737
|
kit.el("h4", { class: "pm-card-title" }, [
|
|
478
|
-
kit.link(`product/flow/${flow.ref.split("/").map(productEncode).join("/")}`, flow.title, {
|
|
738
|
+
kit.link(`product/flow/${flow.ref.split("/").map(productEncode).join("/")}`, flow.title, {
|
|
739
|
+
class: "pm-card-link",
|
|
740
|
+
}),
|
|
479
741
|
]),
|
|
480
742
|
kit.el("p", { class: "pm-card-summary", text: flow.summary ?? "No summary yet." }),
|
|
481
743
|
productHealth(kit, flow.health),
|
|
482
744
|
]);
|
|
483
745
|
}
|
|
484
746
|
|
|
747
|
+
/** A reference id: `AC-6`, `T-089`, `QA 1.5.6`. */
|
|
748
|
+
const PRODUCT_REF = /^(?:[A-Z]{1,5}-\d+|QA\s+\d[\w.-]*)$/;
|
|
749
|
+
/** A trailing parenthesised group (optionally followed by one end mark) at the end of a sentence. */
|
|
750
|
+
const PRODUCT_TRAILING_GROUP = /\s*\(([^()]*)\)\s*([.!?]?)\s*$/;
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Split the reference ids off the end of a change sentence: `"Fixed the total (AC-6, T-089)."` gives
|
|
754
|
+
* `{ text: "Fixed the total.", refs: ["AC-6", "T-089"] }`. Only a trailing parenthesised group whose items are
|
|
755
|
+
* all reference ids is taken, so ordinary parentheses in the text stay.
|
|
756
|
+
*/
|
|
757
|
+
export function productSplitRefs(sentence) {
|
|
758
|
+
let text = String(sentence ?? "");
|
|
759
|
+
const refs = [];
|
|
760
|
+
|
|
761
|
+
for (;;) {
|
|
762
|
+
const match = PRODUCT_TRAILING_GROUP.exec(text);
|
|
763
|
+
|
|
764
|
+
if (!match) break;
|
|
765
|
+
|
|
766
|
+
const parts = match[1]
|
|
767
|
+
.split(/[,;]/)
|
|
768
|
+
.map((part) => part.trim())
|
|
769
|
+
.filter(Boolean);
|
|
770
|
+
|
|
771
|
+
if (parts.length === 0 || !parts.every((part) => PRODUCT_REF.test(part))) break;
|
|
772
|
+
|
|
773
|
+
refs.unshift(...parts);
|
|
774
|
+
text = `${text.slice(0, match.index)}${match[2]}`;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
return { text: text.trim(), refs };
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
const PRODUCT_CHANGE_ORDER = ["added", "changed", "fixed", "removed"];
|
|
781
|
+
|
|
485
782
|
function productTimeline(kit, releases) {
|
|
486
783
|
const ordered = [...releases].sort(
|
|
487
784
|
(left, right) => Number(right.release === null) - Number(left.release === null),
|
|
@@ -491,38 +788,105 @@ function productTimeline(kit, releases) {
|
|
|
491
788
|
"ol",
|
|
492
789
|
{ class: "pm-timeline" },
|
|
493
790
|
ordered.map((item) => {
|
|
494
|
-
const
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
791
|
+
const groups = new Map();
|
|
792
|
+
|
|
793
|
+
for (const change of item.changes)
|
|
794
|
+
groups.set(change.word, [...(groups.get(change.word) ?? []), change]);
|
|
498
795
|
|
|
499
|
-
|
|
796
|
+
const words = [
|
|
797
|
+
...PRODUCT_CHANGE_ORDER.filter((word) => groups.has(word)),
|
|
798
|
+
...[...groups.keys()].filter((word) => !PRODUCT_CHANGE_ORDER.includes(word)),
|
|
799
|
+
];
|
|
800
|
+
const date = productDate(item.date);
|
|
801
|
+
|
|
802
|
+
return kit.el("li", { class: `pm-release${item.release === null ? " is-unreleased" : ""}` }, [
|
|
500
803
|
kit.el("div", { class: "pm-release-head" }, [
|
|
501
|
-
kit.el("strong", { text: `Version ${item.version}` }),
|
|
502
|
-
|
|
804
|
+
kit.el("strong", { class: "pm-release-version", text: `Version ${item.version}` }),
|
|
805
|
+
item.release === null
|
|
806
|
+
? kit.el("span", {
|
|
807
|
+
class: "pm-chip pm-chip--soft pm-release-state",
|
|
808
|
+
text: "Unreleased",
|
|
809
|
+
})
|
|
810
|
+
: kit.el("span", {
|
|
811
|
+
class: "pm-muted pm-release-state",
|
|
812
|
+
text: [`Release ${item.release}`, date].filter(Boolean).join(" · "),
|
|
813
|
+
}),
|
|
503
814
|
]),
|
|
504
|
-
|
|
505
|
-
"
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
815
|
+
words.length === 0
|
|
816
|
+
? kit.el("p", { class: "pm-muted", text: "No changes are listed for this version." })
|
|
817
|
+
: kit.el(
|
|
818
|
+
"div",
|
|
819
|
+
{ class: "pm-change-groups" },
|
|
820
|
+
words.map((word) =>
|
|
821
|
+
kit.el("section", { class: "pm-change-group" }, [
|
|
822
|
+
kit.el("h4", {
|
|
823
|
+
class: `pm-change-type pm-change--${word}`,
|
|
824
|
+
text: PRODUCT_CHANGE[word] ?? word,
|
|
825
|
+
}),
|
|
826
|
+
kit.el(
|
|
827
|
+
"ul",
|
|
828
|
+
{ class: "pm-changes" },
|
|
829
|
+
groups.get(word).map((change) => {
|
|
830
|
+
const { text, refs } = productSplitRefs(change.text);
|
|
831
|
+
|
|
832
|
+
return kit.el("li", {}, [
|
|
833
|
+
kit.el("span", { class: "pm-change-text", text }),
|
|
834
|
+
!kit.shared && refs.length > 0
|
|
835
|
+
? kit.el(
|
|
836
|
+
"span",
|
|
837
|
+
{ class: "pm-refs" },
|
|
838
|
+
refs.map((ref) => kit.el("code", { class: "pm-ref", text: ref })),
|
|
839
|
+
)
|
|
840
|
+
: null,
|
|
841
|
+
]);
|
|
842
|
+
}),
|
|
843
|
+
),
|
|
844
|
+
]),
|
|
845
|
+
),
|
|
846
|
+
),
|
|
514
847
|
]);
|
|
515
848
|
}),
|
|
516
849
|
);
|
|
517
850
|
}
|
|
518
851
|
|
|
852
|
+
/** The host the adapter reported, or `null` when there is none. */
|
|
853
|
+
function productHost(host) {
|
|
854
|
+
return host && typeof host === "object" ? host : null;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
/** "Warlock.js v5.58.0" with the logo, for the footer of the shared page. */
|
|
858
|
+
function productBrandLine(kit, host) {
|
|
859
|
+
return kit.el("span", { class: "pm-brand" }, [
|
|
860
|
+
host.logo
|
|
861
|
+
? kit.el("img", {
|
|
862
|
+
class: "pm-brand-logo",
|
|
863
|
+
src: host.logo,
|
|
864
|
+
alt: "",
|
|
865
|
+
width: "16",
|
|
866
|
+
height: "16",
|
|
867
|
+
})
|
|
868
|
+
: null,
|
|
869
|
+
kit.el("span", { text: host.version ? `${host.name} v${host.version}` : host.name }),
|
|
870
|
+
]);
|
|
871
|
+
}
|
|
872
|
+
|
|
519
873
|
function productPlanned(kit, planned) {
|
|
520
874
|
return kit.el(
|
|
521
875
|
"ul",
|
|
522
876
|
{ class: "pm-list" },
|
|
523
877
|
planned.map((item) =>
|
|
524
878
|
kit.el("li", {}, [
|
|
525
|
-
kit.el("span", {
|
|
879
|
+
kit.el("span", {
|
|
880
|
+
class: "pm-chip",
|
|
881
|
+
text:
|
|
882
|
+
item.type === "bug"
|
|
883
|
+
? "Fix"
|
|
884
|
+
: item.type === "feature"
|
|
885
|
+
? "New"
|
|
886
|
+
: item.type === "decision"
|
|
887
|
+
? "Decision"
|
|
888
|
+
: "Upkeep",
|
|
889
|
+
}),
|
|
526
890
|
kit.el("span", { text: item.title }),
|
|
527
891
|
kit.el("span", { class: "pm-muted", text: item.status }),
|
|
528
892
|
]),
|
|
@@ -560,16 +924,42 @@ function productFeaturePage(ctx, kit, answer, lightbox) {
|
|
|
560
924
|
]),
|
|
561
925
|
);
|
|
562
926
|
|
|
563
|
-
if (feature.why)
|
|
927
|
+
if (feature.why)
|
|
928
|
+
sections.push(
|
|
929
|
+
productSection(kit, "Why it exists", kit.el("p", { class: "pm-prose", text: feature.why })),
|
|
930
|
+
);
|
|
564
931
|
|
|
565
|
-
if (answer.flows.length > 0)
|
|
932
|
+
if (answer.flows.length > 0) {
|
|
933
|
+
const list = kit.el("ul", { class: "pm-grid pm-grid--flows" });
|
|
934
|
+
const showFlows = (sort) =>
|
|
935
|
+
list.replaceChildren(
|
|
936
|
+
...productSortFlows(answer.flows, sort).map((flow) => productFlowCard(kit, flow)),
|
|
937
|
+
);
|
|
938
|
+
|
|
939
|
+
showFlows("written");
|
|
566
940
|
sections.push(
|
|
567
|
-
productSection(
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
941
|
+
productSection(kit, "What people can do", [
|
|
942
|
+
answer.flows.length > 1
|
|
943
|
+
? kit.el("label", { class: "pm-field" }, [
|
|
944
|
+
kit.el("span", { text: "Sort by" }),
|
|
945
|
+
kit.el(
|
|
946
|
+
"select",
|
|
947
|
+
{
|
|
948
|
+
"data-pm": "flow-sort",
|
|
949
|
+
onchange: (event) => showFlows(event?.target?.value ?? "written"),
|
|
950
|
+
},
|
|
951
|
+
[
|
|
952
|
+
kit.el("option", { value: "written", text: "As written" }),
|
|
953
|
+
kit.el("option", { value: "name", text: "Name" }),
|
|
954
|
+
kit.el("option", { value: "health", text: "Health (worst first)" }),
|
|
955
|
+
],
|
|
956
|
+
),
|
|
957
|
+
])
|
|
958
|
+
: null,
|
|
959
|
+
list,
|
|
960
|
+
]),
|
|
572
961
|
);
|
|
962
|
+
}
|
|
573
963
|
|
|
574
964
|
sections.push(productAppearances(ctx, kit, answer.appearances, lightbox, true));
|
|
575
965
|
|
|
@@ -610,7 +1000,9 @@ function productFeatureDeveloper(kit, developer) {
|
|
|
610
1000
|
: kit.el(
|
|
611
1001
|
"ul",
|
|
612
1002
|
{ class: "pm-mono pm-plain-list" },
|
|
613
|
-
developer.routes.map((route) =>
|
|
1003
|
+
developer.routes.map((route) =>
|
|
1004
|
+
kit.el("li", { text: `${route.method} ${route.path}` }),
|
|
1005
|
+
),
|
|
614
1006
|
),
|
|
615
1007
|
),
|
|
616
1008
|
]),
|
|
@@ -627,7 +1019,9 @@ function productStory(ctx, kit, story, lightbox) {
|
|
|
627
1019
|
story.map((step) =>
|
|
628
1020
|
kit.el("li", { class: "pm-step" }, [
|
|
629
1021
|
kit.el("p", { text: step.text }),
|
|
630
|
-
step.derived
|
|
1022
|
+
step.derived
|
|
1023
|
+
? kit.el("span", { class: "pm-chip pm-chip--soft", text: "from the technical steps" })
|
|
1024
|
+
: null,
|
|
631
1025
|
productShots(ctx, kit, step.screenshots, lightbox),
|
|
632
1026
|
]),
|
|
633
1027
|
),
|
|
@@ -640,9 +1034,14 @@ function productCases(kit, cases) {
|
|
|
640
1034
|
const item = (entry) =>
|
|
641
1035
|
kit.el("li", {}, [
|
|
642
1036
|
kit.el("strong", { text: entry.question }),
|
|
643
|
-
kit.el("p", {
|
|
1037
|
+
kit.el("p", {
|
|
1038
|
+
text: entry.handled ? entry.answer : entry.answer.replace(/^does not apply\b[:\s—-]*/i, ""),
|
|
1039
|
+
}),
|
|
644
1040
|
entry.criteria.length > 0
|
|
645
|
-
? kit.el("span", {
|
|
1041
|
+
? kit.el("span", {
|
|
1042
|
+
class: "pm-chip pm-chip--soft",
|
|
1043
|
+
text: `Checked by ${entry.criteria.join(", ")}`,
|
|
1044
|
+
})
|
|
646
1045
|
: null,
|
|
647
1046
|
]);
|
|
648
1047
|
|
|
@@ -679,9 +1078,13 @@ function productFlowPage(ctx, kit, answer, lightbox) {
|
|
|
679
1078
|
const neighbour = (item, label) =>
|
|
680
1079
|
item === null
|
|
681
1080
|
? null
|
|
682
|
-
: kit.link(
|
|
683
|
-
|
|
684
|
-
|
|
1081
|
+
: kit.link(
|
|
1082
|
+
`product/flow/${productEncode(flow.feature)}/${productEncode(item.id)}`,
|
|
1083
|
+
`${label}: ${item.heading ?? item.id}`,
|
|
1084
|
+
{
|
|
1085
|
+
class: "pm-button",
|
|
1086
|
+
},
|
|
1087
|
+
);
|
|
685
1088
|
const sections = [
|
|
686
1089
|
productBreadcrumb(kit, [
|
|
687
1090
|
{ text: "Product map", to: "product" },
|
|
@@ -689,11 +1092,16 @@ function productFlowPage(ctx, kit, answer, lightbox) {
|
|
|
689
1092
|
{ text: flow.title },
|
|
690
1093
|
]),
|
|
691
1094
|
kit.el("header", { class: "pm-title" }, [
|
|
692
|
-
kit.el("div", { class: "pm-title-row" }, [
|
|
1095
|
+
kit.el("div", { class: "pm-title-row" }, [
|
|
1096
|
+
kit.el("h2", { text: flow.title }),
|
|
1097
|
+
productStatusChip(kit, flow.status),
|
|
1098
|
+
]),
|
|
693
1099
|
kit.el("p", { class: "pm-lead", text: flow.summary ?? "No summary yet." }),
|
|
694
1100
|
kit.el("p", { class: "pm-muted", text: `For ${flow.who} · since version ${flow.since}` }),
|
|
695
1101
|
]),
|
|
696
|
-
kit.el("section", { class: "pm-section pm-callout", "aria-label": "Health" }, [
|
|
1102
|
+
kit.el("section", { class: "pm-section pm-callout", "aria-label": "Health" }, [
|
|
1103
|
+
productHealth(kit, answer.health),
|
|
1104
|
+
]),
|
|
697
1105
|
productSection(kit, "How it goes", productStory(ctx, kit, answer.story, lightbox)),
|
|
698
1106
|
productSection(
|
|
699
1107
|
kit,
|
|
@@ -715,7 +1123,11 @@ function productFlowPage(ctx, kit, answer, lightbox) {
|
|
|
715
1123
|
|
|
716
1124
|
/** A step's file counts, like the technical flow page: the type-only count only when there is one. */
|
|
717
1125
|
function productStepCounts(counts) {
|
|
718
|
-
const parts = [
|
|
1126
|
+
const parts = [
|
|
1127
|
+
`${counts.direct} direct`,
|
|
1128
|
+
`${counts.feature} in this feature`,
|
|
1129
|
+
`${counts.reachable} reachable`,
|
|
1130
|
+
];
|
|
719
1131
|
|
|
720
1132
|
if (counts.typeOnly > 0) parts.push(`${counts.typeOnly} type-only`);
|
|
721
1133
|
|
|
@@ -759,13 +1171,20 @@ export async function productMapView(ctx, parts = []) {
|
|
|
759
1171
|
const main = el("main", { class: "pm-main", "aria-busy": "true" });
|
|
760
1172
|
const [kind, first, second] = parts.map(productDecode);
|
|
761
1173
|
|
|
1174
|
+
let answerHost = null;
|
|
1175
|
+
|
|
762
1176
|
root.append(main);
|
|
763
1177
|
|
|
764
1178
|
try {
|
|
765
1179
|
if (kind === "feature" && first) {
|
|
766
1180
|
const answer = await ctx.api(`product/features/${productEncode(first)}`);
|
|
1181
|
+
|
|
1182
|
+
answerHost = answer.host;
|
|
767
1183
|
const body = [
|
|
768
|
-
productBreadcrumb(kit, [
|
|
1184
|
+
productBreadcrumb(kit, [
|
|
1185
|
+
{ text: "Product map", to: "product" },
|
|
1186
|
+
{ text: answer.feature.title },
|
|
1187
|
+
]),
|
|
769
1188
|
...productFeaturePage(ctx, kit, answer, lightbox),
|
|
770
1189
|
];
|
|
771
1190
|
|
|
@@ -778,7 +1197,11 @@ export async function productMapView(ctx, parts = []) {
|
|
|
778
1197
|
|
|
779
1198
|
main.append(el("div", { class: "pm-page" }, body));
|
|
780
1199
|
} else if (kind === "flow" && first && second) {
|
|
781
|
-
const answer = await ctx.api(
|
|
1200
|
+
const answer = await ctx.api(
|
|
1201
|
+
`product/flows/${productEncode(first)}/${productEncode(second)}`,
|
|
1202
|
+
);
|
|
1203
|
+
|
|
1204
|
+
answerHost = answer.host;
|
|
782
1205
|
const body = productFlowPage(ctx, kit, answer, lightbox);
|
|
783
1206
|
|
|
784
1207
|
if (!kit.shared && answer.developer) {
|
|
@@ -790,16 +1213,40 @@ export async function productMapView(ctx, parts = []) {
|
|
|
790
1213
|
|
|
791
1214
|
main.append(el("div", { class: "pm-page" }, body));
|
|
792
1215
|
} else {
|
|
793
|
-
|
|
1216
|
+
const answer = await ctx.api("product");
|
|
1217
|
+
|
|
1218
|
+
answerHost = answer.host;
|
|
1219
|
+
main.append(productMapPage(ctx, kit, answer));
|
|
794
1220
|
}
|
|
795
1221
|
} catch (error) {
|
|
796
|
-
main.append(
|
|
1222
|
+
main.append(
|
|
1223
|
+
productLoadError(
|
|
1224
|
+
ctx,
|
|
1225
|
+
kit,
|
|
1226
|
+
kind === "feature" ? "this feature" : kind === "flow" ? "this flow" : "the product map",
|
|
1227
|
+
error,
|
|
1228
|
+
),
|
|
1229
|
+
);
|
|
797
1230
|
}
|
|
798
1231
|
|
|
799
1232
|
main.setAttribute("aria-busy", "false");
|
|
800
1233
|
root.append(lightbox.dialog);
|
|
801
1234
|
|
|
802
|
-
if (kit.shared)
|
|
1235
|
+
if (kit.shared) {
|
|
1236
|
+
const host = productHost(answerHost);
|
|
1237
|
+
const app =
|
|
1238
|
+
host && host.app && host.app.name
|
|
1239
|
+
? `${host.app.name}${host.app.version ? ` ${host.app.version}` : ""}`
|
|
1240
|
+
: null;
|
|
1241
|
+
|
|
1242
|
+
root.append(
|
|
1243
|
+
el("footer", { class: "pm-footer" }, [
|
|
1244
|
+
el("span", { text: "Read-only view" }),
|
|
1245
|
+
app ? el("span", { class: "pm-mono", text: app }) : null,
|
|
1246
|
+
host && host.name ? productBrandLine(kit, host) : null,
|
|
1247
|
+
]),
|
|
1248
|
+
);
|
|
1249
|
+
}
|
|
803
1250
|
|
|
804
1251
|
return root;
|
|
805
1252
|
}
|
|
@@ -808,7 +1255,8 @@ export async function productMapView(ctx, parts = []) {
|
|
|
808
1255
|
async function renderProductMap(context) {
|
|
809
1256
|
const parts = (context.route ?? "").split("/").filter(Boolean);
|
|
810
1257
|
|
|
811
|
-
if (parts[0] === "share" && (parts.length === 1 || parts[1] === "feature" || parts[1] === "flow"))
|
|
1258
|
+
if (parts[0] === "share" && (parts.length === 1 || parts[1] === "feature" || parts[1] === "flow"))
|
|
1259
|
+
parts.shift();
|
|
812
1260
|
if (parts[0] === "product") parts.shift();
|
|
813
1261
|
|
|
814
1262
|
return productMapView({ ...context, shared: true }, parts);
|