@whzxc/agent-design-gallery 0.14.1 → 0.15.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/README.md +26 -16
- package/package.json +1 -1
- package/public/access.css +15 -2
- package/public/app.js +708 -483
- package/public/arrangement-worker.js +7 -7
- package/public/arrangement.js +35 -30
- package/public/assets.js +60 -38
- package/public/auth.js +59 -4
- package/public/boards.js +124 -0
- package/public/comment-anchors.js +50 -0
- package/public/comments.css +400 -0
- package/public/comments.js +1106 -0
- package/public/context-menu.js +97 -0
- package/public/frame-identity.js +26 -2
- package/public/hub.css +25 -3
- package/public/hub.html +10 -2
- package/public/hub.js +127 -23
- package/public/icons.js +2 -0
- package/public/index.html +13 -9
- package/public/instance-actions.js +9 -2
- package/public/layout.js +156 -86
- package/public/selection.js +1 -1
- package/public/style.css +74 -152
- package/public/switcher.css +5 -4
- package/public/switcher.js +109 -34
- package/public/token-catalog.js +8 -3
- package/public/tokens.css +14 -1
- package/public/view-route.js +0 -1
- package/src/boards/board.mjs +30 -0
- package/src/boards/token-board.mjs +196 -0
- package/src/cli-output.mjs +8 -5
- package/src/cli.mjs +49 -29
- package/src/comments.mjs +293 -0
- package/src/http.mjs +2 -3
- package/src/hub/project-link.mjs +41 -0
- package/src/hub/registry.mjs +5 -0
- package/src/hub.mjs +14 -10
- package/src/link.mjs +13 -1
- package/src/server.mjs +57 -93
- package/src/service.mjs +46 -12
- package/src/toolkit/arch.mjs +3 -2
- package/src/toolkit/asset-rules.mjs +24 -1
- package/src/toolkit/commands.mjs +12 -7
- package/{public/review.js → src/toolkit/diff-document.mjs} +137 -43
- package/src/toolkit/diff-inputs.mjs +66 -30
- package/src/toolkit/diff.mjs +181 -39
- package/src/toolkit/impact-selection.mjs +25 -10
- package/src/toolkit/impact.mjs +32 -12
- package/src/toolkit/move-pairing.mjs +140 -0
- package/src/toolkit/project-index.mjs +2 -2
- package/src/toolkit/results.mjs +1 -1
- package/src/toolkit/review-document.mjs +435 -0
- package/src/toolkit/review-groups.mjs +29 -0
- package/src/toolkit/review-observation.mjs +131 -0
- package/src/toolkit/review-sheet.mjs +117 -0
- package/src/toolkit/review-specimens.mjs +60 -0
- package/src/toolkit/review.mjs +140 -0
- package/src/toolkit/runtime.mjs +1 -1
- package/src/toolkit/theme.mjs +16 -0
- package/public/annotations.js +0 -816
- package/public/labels.js +0 -122
- package/src/annotations.mjs +0 -238
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { groupReview } from './review-groups.mjs';
|
|
2
|
+
|
|
1
3
|
const escapeHtml = value => String(value ?? '').replace(/[&<>"']/g, char => (
|
|
2
4
|
{ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[char]
|
|
3
5
|
));
|
|
@@ -25,14 +27,24 @@ function themeSummary(item) {
|
|
|
25
27
|
|
|
26
28
|
export function buildReview(data, imagesById = new Map(), { label } = {}) {
|
|
27
29
|
const grouped = new Map();
|
|
30
|
+
const moves = new Map();
|
|
28
31
|
for (const row of data.comparisons ?? []) {
|
|
29
32
|
const key = JSON.stringify([row.source, row.frame]);
|
|
33
|
+
if (row.status === 'moved') {
|
|
34
|
+
if (!moves.has(key)) moves.set(key, {
|
|
35
|
+
before: row.before ?? { source: row.previousSource, frame: row.frame },
|
|
36
|
+
after: row.after ?? { source: row.source, frame: row.frame },
|
|
37
|
+
});
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
30
40
|
let entry = grouped.get(key);
|
|
31
41
|
if (!entry) {
|
|
32
42
|
entry = {
|
|
33
43
|
source: row.source,
|
|
34
44
|
frame: row.frame,
|
|
35
45
|
status: row.status,
|
|
46
|
+
change: row.change,
|
|
47
|
+
previousSource: row.previousSource,
|
|
36
48
|
rows: new Map(),
|
|
37
49
|
};
|
|
38
50
|
grouped.set(key, entry);
|
|
@@ -63,133 +75,210 @@ export function buildReview(data, imagesById = new Map(), { label } = {}) {
|
|
|
63
75
|
sections.added.push({ source: entry.source, frame: entry.frame, status: 'added', themes: orderedThemes });
|
|
64
76
|
} else if (entry.status === 'removed') {
|
|
65
77
|
sections.removed.push({ source: entry.source, frame: entry.frame, status: 'removed', themes: orderedThemes });
|
|
66
|
-
} else if (orderedThemes.some(item => item.verdict === 'changed')) {
|
|
67
|
-
|
|
78
|
+
} else if (entry.previousSource || orderedThemes.some(item => item.verdict === 'changed')) {
|
|
79
|
+
// Core classifies moves across both themes, even when only one theme is displayed.
|
|
80
|
+
sections.changed.push({ source: entry.source, frame: entry.frame, status: 'changed', change: entry.change,
|
|
81
|
+
...(entry.previousSource ? { previousSource: entry.previousSource } : {}), themes: orderedThemes });
|
|
68
82
|
}
|
|
69
83
|
}
|
|
70
84
|
|
|
71
85
|
const fallbackLabel = data.project ? data.project.split(/[\\/]/).filter(Boolean).at(-1) : 'Design review';
|
|
72
|
-
|
|
86
|
+
const review = {
|
|
73
87
|
label: label || fallbackLabel || 'Design review',
|
|
74
88
|
base: data.base ?? { rev: 'HEAD', sha: '' },
|
|
75
89
|
current: data.current ?? { kind: 'working_tree', head: null },
|
|
76
90
|
complete: !!data.complete,
|
|
91
|
+
failures: data.failures ?? [],
|
|
77
92
|
verdict: data.verdict ?? null,
|
|
78
93
|
counts: {
|
|
79
94
|
added: sections.added.length,
|
|
80
95
|
removed: sections.removed.length,
|
|
96
|
+
moved: moves.size,
|
|
81
97
|
changed: sections.changed.length,
|
|
82
98
|
},
|
|
99
|
+
movePairs: [...moves.values()],
|
|
83
100
|
sections,
|
|
84
101
|
};
|
|
102
|
+
return { ...review, ...groupReview(review) };
|
|
85
103
|
}
|
|
86
104
|
|
|
87
|
-
function renderSide(side, label, src, absentLabel, alt, theme) {
|
|
105
|
+
function renderSide(side, label, src, absentLabel, alt, theme, source) {
|
|
88
106
|
const diffClass = side === 'difference' ? ' review-stage-diff' : '';
|
|
89
107
|
const body = src
|
|
90
108
|
? `<div class="review-stage${diffClass}" data-stage-theme="${escapeHtml(theme)}"><img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}" loading="lazy"></div>`
|
|
91
109
|
: `<div class="review-absent">${escapeHtml(absentLabel)}</div>`;
|
|
92
|
-
return `<figure class="review-pane" data-side="${escapeHtml(side)}"><figcaption>${escapeHtml(label)}</figcaption>${body}</figure>`;
|
|
110
|
+
return `<figure class="review-pane" data-side="${escapeHtml(side)}"><figcaption>${escapeHtml(label)}${source ? ` · <code>${escapeHtml(source)}</code>` : ''}</figcaption>${body}</figure>`;
|
|
93
111
|
}
|
|
94
112
|
|
|
95
|
-
function renderFrameCard(item) {
|
|
96
|
-
const label = `${item.source}
|
|
113
|
+
function renderFrameCard(item, { paired = false, label: statusLabel = item.status } = {}) {
|
|
114
|
+
const label = `${item.source}#${item.frame}`;
|
|
115
|
+
const sides = item.status === 'added'
|
|
116
|
+
? ['after']
|
|
117
|
+
: (paired && !item.themes.some(t => t.images?.difference))
|
|
118
|
+
? ['before', 'after']
|
|
119
|
+
: ['before', 'after', 'difference'];
|
|
97
120
|
const themeBlocks = item.themes.map(themeItem => {
|
|
98
121
|
const theme = themeItem.theme;
|
|
99
122
|
const summary = themeSummary(themeItem);
|
|
123
|
+
const absentLabels = { before: 'Absent at base', after: 'Removed in working tree', difference: 'No difference image' };
|
|
124
|
+
const panes = sides.map(side => {
|
|
125
|
+
const source = side === 'before' ? item.previousSource : null;
|
|
126
|
+
const alt = `${source ? `${source}#${item.frame}` : label} (${theme} ${side})`;
|
|
127
|
+
return renderSide(side, side[0].toUpperCase() + side.slice(1), themeItem.images?.[side], absentLabels[side], alt, theme, source);
|
|
128
|
+
}).join('');
|
|
100
129
|
return `<div class="review-theme" data-theme-row="${escapeHtml(theme)}" data-verdict="${escapeHtml(themeItem.verdict)}">
|
|
101
130
|
<div class="review-theme-head">
|
|
102
131
|
<span class="review-theme-name">${escapeHtml(theme)}</span>
|
|
103
132
|
<span class="review-theme-meta">${escapeHtml(summary)}</span>
|
|
104
133
|
</div>
|
|
105
|
-
<div class="review-columns">
|
|
106
|
-
${
|
|
107
|
-
${renderSide('after', 'After', themeItem.images.after, 'Removed in working tree', `${label} (${theme} after)`, theme)}
|
|
108
|
-
${renderSide('difference', 'Difference', themeItem.images.difference, 'No difference image', `${label} (${theme} difference)`, theme)}
|
|
134
|
+
<div class="review-columns" style="--review-columns:${sides.length}">
|
|
135
|
+
${panes}
|
|
109
136
|
</div>
|
|
110
137
|
</div>`;
|
|
111
138
|
}).join('');
|
|
112
139
|
return `<article class="review-frame" data-source="${escapeHtml(item.source)}" data-frame="${escapeHtml(item.frame)}" data-status="${escapeHtml(item.status)}">
|
|
113
140
|
<header class="review-frame-head">
|
|
114
|
-
<h3><code>${escapeHtml(
|
|
115
|
-
<
|
|
141
|
+
<h3><code>${escapeHtml(label)}</code></h3>
|
|
142
|
+
<div class="review-frame-actions">
|
|
143
|
+
<span class="review-status-pill" data-status="${escapeHtml(item.status)}">${escapeHtml(statusLabel)}</span>
|
|
144
|
+
</div>
|
|
116
145
|
</header>
|
|
117
146
|
<div class="review-themes">${themeBlocks}</div>
|
|
118
147
|
</article>`;
|
|
119
148
|
}
|
|
120
149
|
|
|
121
|
-
export function
|
|
122
|
-
|
|
150
|
+
export function renderReviewFailures(failures = []) {
|
|
151
|
+
if (!failures.length) return '';
|
|
152
|
+
return `<section class="review-failures" role="alert"><h2>Some sources could not be built</h2><ul>${failures.map(failure =>
|
|
153
|
+
`<li><code>${escapeHtml(failure.source)}</code> (${escapeHtml(failure.side)}) — ${escapeHtml(failure.message)}</li>`
|
|
154
|
+
).join('')}</ul></section>`;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function renderNames(entries) {
|
|
158
|
+
return `<ul class="review-names">${entries.map(entry => `<li data-source="${escapeHtml(entry.source)}" data-frame="${escapeHtml(entry.frame)}" data-status="${escapeHtml(entry.status)}"><code>${escapeHtml(entry.source)}#${escapeHtml(entry.frame)}</code></li>`).join('')}</ul>`;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function renderReviewMoves(pairs) {
|
|
162
|
+
const groups = new Map();
|
|
163
|
+
for (const { before, after } of pairs) {
|
|
164
|
+
const key = JSON.stringify([before.source, after.source]);
|
|
165
|
+
if (!groups.has(key)) groups.set(key, { from: before.source, to: after.source, count: 0, renamed: [] });
|
|
166
|
+
const group = groups.get(key);
|
|
167
|
+
group.count++;
|
|
168
|
+
if (before.frame !== after.frame) group.renamed.push({ before, after });
|
|
169
|
+
}
|
|
170
|
+
const frameLabel = ({ source, frame }) => `<code>${escapeHtml(`${source}#${frame}`)}</code>`;
|
|
171
|
+
return `<ul class="review-names">${[...groups.values()].map(({ from, to, count, renamed }) =>
|
|
172
|
+
`<li data-moved-count="${count}"><code>${escapeHtml(from)}</code> → <code>${escapeHtml(to)}</code> · ${count} ${count === 1 ? 'frame' : 'frames'}${
|
|
173
|
+
renamed.length ? `<ul>${renamed.map(({ before, after }) => `<li>${frameLabel(before)} → ${frameLabel(after)}</li>`).join('')}</ul>` : ''}</li>`
|
|
174
|
+
).join('')}</ul>`;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function sameFrame(left, right) {
|
|
178
|
+
return left.source === right.source && left.frame === right.frame;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function renderGroup(group) {
|
|
182
|
+
const outliers = group.outliers.filter(entry => !sameFrame(entry, group.representative));
|
|
183
|
+
const others = group.frames.filter(entry => !sameFrame(entry, group.representative));
|
|
184
|
+
const remaining = others.filter(entry => !outliers.some(outlier => sameFrame(entry, outlier)));
|
|
185
|
+
const causes = group.causes.map(cause => `<code>${escapeHtml(cause)}</code>`).join(', ');
|
|
186
|
+
return `<article class="review-group">
|
|
187
|
+
<header class="review-group-head"><h3>${causes}</h3><span>${group.frames.length} ${group.frames.length === 1 ? 'frame' : 'frames'}</span></header>
|
|
188
|
+
${renderFrameCard(group.representative, { paired: true, label: 'Representative' })}
|
|
189
|
+
${outliers.map(entry => renderFrameCard(entry, { paired: true, label: 'Outlier' })).join('')}
|
|
190
|
+
${remaining.length ? `<details class="review-group-members"><summary>Show ${remaining.length} more inherited ${remaining.length === 1 ? 'frame' : 'frames'}</summary><div class="review-section-list">${remaining.map(entry => renderFrameCard(entry, { paired: true, label: 'Inherited' })).join('')}</div></details>` : ''}
|
|
191
|
+
</article>`;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function renderReviewBody(review) {
|
|
195
|
+
const grouped = { ...review, ...groupReview(review) };
|
|
196
|
+
const { counts } = grouped;
|
|
197
|
+
const count = (kind, content) => `<span class="review-count" data-kind="${kind}"${counts[kind] === 0 ? ' data-zero="true"' : ''}>${content}</span>`;
|
|
123
198
|
const baseLabel = review.base?.sha
|
|
124
199
|
? `${review.base.rev} (${shortSha(review.base.sha)})`
|
|
125
200
|
: (review.base?.rev ?? 'base');
|
|
126
201
|
const headLabel = review.current?.head ? `working tree (${shortSha(review.current.head)})` : 'working tree';
|
|
202
|
+
const direct = (review.sections?.changed ?? []).filter(entry => entry.change?.kind !== 'inherited');
|
|
127
203
|
const sectionSpecs = [
|
|
128
|
-
['added', 'Added', review.sections?.added ?? []],
|
|
129
|
-
['
|
|
130
|
-
['
|
|
204
|
+
['added', 'Added', review.sections?.added ?? [], items => items.map(item => renderFrameCard(item)).join('')],
|
|
205
|
+
['direct', 'Direct changes', direct, items => items.map(item => renderFrameCard(item)).join('')],
|
|
206
|
+
['inherited', 'Inherited changes', grouped.groups ?? [], items => items.map(group => renderGroup(group)).join('')],
|
|
207
|
+
['removed', 'Removed', review.sections?.removed ?? [], renderNames],
|
|
208
|
+
['moved', 'Moved', review.movePairs ?? [], renderReviewMoves],
|
|
131
209
|
];
|
|
132
210
|
const renderedSections = sectionSpecs
|
|
133
211
|
.filter(([, , items]) => items.length > 0)
|
|
134
|
-
.map(([kind, title, items]) => `<section class="review-section" data-section="${kind}">
|
|
135
|
-
<h2 class="review-section-title">${escapeHtml(title)} <span class="review-section-count">${items.length}</span></h2>
|
|
136
|
-
<div class="review-section-list">${items
|
|
212
|
+
.map(([kind, title, items, render]) => `<section class="review-section" data-section="${kind}">
|
|
213
|
+
<h2 class="review-section-title">${escapeHtml(title)} <span class="review-section-count">${kind === 'inherited' ? counts.inherited : items.length}</span></h2>
|
|
214
|
+
<div class="review-section-list">${render(items)}</div>
|
|
137
215
|
</section>`)
|
|
138
216
|
.join('');
|
|
139
217
|
const empty = renderedSections
|
|
140
218
|
? ''
|
|
141
|
-
: `<p class="review-empty" role="status">No added, removed, or changed frames against <code>${escapeHtml(review.base?.rev ?? 'base')}</code>.</p>`;
|
|
142
|
-
|
|
219
|
+
: `<p class="review-empty" role="status">No added, removed, moved, or changed frames against <code>${escapeHtml(review.base?.rev ?? 'base')}</code>.</p>`;
|
|
143
220
|
return `<header class="review-header">
|
|
144
221
|
<div class="review-heading">
|
|
145
222
|
<h1 id="review-title">${escapeHtml(review.label)}</h1>
|
|
146
223
|
<code class="review-revisions">base ${escapeHtml(baseLabel)} → ${escapeHtml(headLabel)}</code>
|
|
147
224
|
</div>
|
|
148
225
|
<div class="review-counts" data-review-counts>
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
226
|
+
${count('added', `<strong>${counts.added}</strong> added`)}
|
|
227
|
+
${count('removed', `<strong>${counts.removed}</strong> removed`)}
|
|
228
|
+
${count('moved', `<strong>${counts.moved}</strong> moved`)}
|
|
229
|
+
${count('changed', `<strong>${counts.changed}</strong> changed (direct ${counts.direct}, inherited ${counts.inherited})`)}
|
|
152
230
|
</div>
|
|
153
231
|
</header>
|
|
154
|
-
<div class="review-scroll">${renderedSections}${empty}</div>`;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export function renderReview(container, review) {
|
|
158
|
-
container.innerHTML = renderReviewBody(review);
|
|
232
|
+
<div class="review-scroll">${renderReviewFailures(review.failures)}${renderedSections}${empty}</div>`;
|
|
159
233
|
}
|
|
160
234
|
|
|
161
235
|
export const REVIEW_STYLES = `
|
|
162
|
-
.review-
|
|
163
|
-
.review-
|
|
236
|
+
.review-failures { padding:16px; border:1px solid var(--border); border-radius:var(--radius-row); background:var(--surface-sunken); overflow-wrap:anywhere; }
|
|
237
|
+
.review-failures h2 { margin:0 0 8px; font-size:var(--text-section); }
|
|
238
|
+
.review-failures ul { margin:0; padding-left:20px; }
|
|
239
|
+
.review-failures li + li { margin-top:8px; }
|
|
240
|
+
|
|
241
|
+
.review-header { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:12px 16px; padding:16px 20px; border-bottom:1px solid var(--border); flex:none; }
|
|
242
|
+
.review-heading { display:flex; align-items:baseline; flex-wrap:wrap; gap:8px 12px; min-width:0; margin-right:auto; }
|
|
164
243
|
.review-heading h1 { font-size:var(--text-title); font-weight:650; line-height:20px; margin:0; }
|
|
165
244
|
.review-revisions { font:var(--text-meta)/1.4 var(--font-mono); color:var(--text-secondary); }
|
|
166
245
|
.review-counts { display:flex; align-items:center; flex-wrap:wrap; gap:8px; }
|
|
167
|
-
.review-count { display:inline-flex; align-items:center; gap:5px; padding:4px 10px; border-radius:999px; background:var(--surface-sunken); font
|
|
246
|
+
.review-count { display:inline-flex; align-items:center; gap:5px; padding:4px 10px; border:1px solid transparent; border-radius:var(--radius-pill, 999px); background:var(--surface-sunken); font:var(--text-meta)/1.2 var(--font-ui); color:var(--text-secondary); }
|
|
247
|
+
.review-count[data-zero="true"] { opacity:.6; }
|
|
168
248
|
.review-count strong { font-family:var(--font-mono); font-weight:650; color:var(--text); }
|
|
169
249
|
.review-scroll { min-height:0; flex:1; overflow:auto; padding:20px; display:flex; flex-direction:column; gap:28px; }
|
|
170
250
|
.review-section { display:flex; flex-direction:column; gap:14px; }
|
|
171
251
|
.review-section-title { display:flex; align-items:center; gap:8px; font-size:var(--text-section); font-weight:650; color:var(--text); margin:0; }
|
|
172
|
-
.review-section-count { display:inline-flex; align-items:center; justify-content:center; min-width:22px; height:20px; padding:0 6px; border-radius:999px; background:var(--surface-sunken); font:600 var(--text-caption)/1 var(--font-mono); color:var(--text-secondary); }
|
|
252
|
+
.review-section-count { display:inline-flex; align-items:center; justify-content:center; min-width:22px; height:20px; padding:0 6px; border-radius:var(--radius-pill, 999px); background:var(--surface-sunken); font:600 var(--text-caption)/1 var(--font-mono); color:var(--text-secondary); }
|
|
173
253
|
.review-section-list { display:flex; flex-direction:column; gap:16px; }
|
|
174
254
|
.review-frame { border:1px solid var(--border); border-radius:var(--radius-menu); background:var(--surface-section); overflow:hidden; }
|
|
175
255
|
.review-frame-head { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 16px; border-bottom:1px solid var(--border); background:var(--surface); }
|
|
176
|
-
.review-frame-head h3 { display:flex; align-items:baseline; flex-wrap:wrap; gap:6px; margin:0; font-size:var(--text-body); font-weight:600; color:var(--text); }
|
|
177
|
-
.review-frame-head code { font:var(--text-meta)/1.4 var(--font-mono); color:var(--text-secondary); }
|
|
256
|
+
.review-frame-head h3 { display:flex; align-items:baseline; flex-wrap:wrap; gap:6px; margin:0; min-width:0; font-size:var(--text-body); font-weight:600; color:var(--text); }
|
|
257
|
+
.review-frame-head code { font:var(--text-meta)/1.4 var(--font-mono); color:var(--text-secondary); overflow-wrap:anywhere; }
|
|
258
|
+
.review-frame-actions { display:flex; align-items:center; gap:8px; flex:none; }
|
|
259
|
+
.review-group { display:flex; flex-direction:column; gap:14px; padding:16px; border:1px solid var(--border); border-radius:var(--radius-menu); }
|
|
260
|
+
.review-group-head { display:flex; align-items:baseline; justify-content:space-between; gap:12px; }
|
|
261
|
+
.review-group-head h3 { margin:0; font:var(--text-meta)/1.5 var(--font-mono); overflow-wrap:anywhere; }
|
|
262
|
+
.review-group-head span { flex:none; color:var(--text-secondary); }
|
|
263
|
+
.review-names { margin:0; padding-left:20px; font:var(--text-meta)/1.6 var(--font-mono); overflow-wrap:anywhere; }
|
|
264
|
+
.review-group-members summary { cursor:pointer; color:var(--text-secondary); font-size:var(--text-meta); font-weight:550; }
|
|
265
|
+
.review-group-members summary:hover { color:var(--text); }
|
|
266
|
+
.review-group-members[open] summary { margin-bottom:14px; }
|
|
178
267
|
.review-dot { color:var(--text-tertiary); }
|
|
179
|
-
.review-status-pill { flex:none; padding:2px 8px; border-radius:999px; background:var(--surface-sunken); font-size:var(--text-caption); font-weight:600; text-transform:capitalize; color:var(--text-secondary); }
|
|
268
|
+
.review-status-pill { flex:none; padding:2px 8px; border-radius:var(--radius-pill, 999px); background:var(--surface-sunken); font-size:var(--text-caption); font-weight:600; text-transform:capitalize; color:var(--text-secondary); }
|
|
180
269
|
.review-themes { display:flex; flex-direction:column; gap:1px; background:var(--border); }
|
|
181
270
|
.review-theme { background:var(--surface); padding:14px 16px 16px; display:flex; flex-direction:column; gap:10px; }
|
|
182
271
|
.review-theme-head { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:8px; }
|
|
183
272
|
.review-theme-name { font-size:var(--text-meta); font-weight:650; text-transform:capitalize; color:var(--text); }
|
|
184
273
|
.review-theme-meta { font:var(--text-caption)/1.4 var(--font-mono); color:var(--text-tertiary); }
|
|
185
|
-
.review-columns { display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:12px; align-items:start; }
|
|
274
|
+
.review-columns { display:grid; grid-template-columns:repeat(var(--review-columns, 3), minmax(0, 1fr)); gap:12px; align-items:start; }
|
|
186
275
|
@media (max-width:900px) { .review-columns { grid-template-columns:1fr; } }
|
|
187
276
|
.review-pane { margin:0; display:flex; flex-direction:column; gap:6px; min-width:0; }
|
|
188
277
|
.review-pane figcaption { font-size:var(--text-caption); font-weight:550; color:var(--text-secondary); }
|
|
189
|
-
.review-stage { border:1px solid var(--border); border-radius:var(--radius-row); padding:10px; display:flex; align-items:center; justify-content:center; min-height:96px; overflow:auto; background
|
|
190
|
-
.review-stage[data-stage-theme="dark"] {
|
|
191
|
-
.review-stage-diff { background:repeating-conic-gradient(var(--
|
|
192
|
-
.review-stage-diff[data-stage-theme="dark"] {
|
|
278
|
+
.review-stage { --review-stage-bg:var(--review-canvas-light, #ecece9); --review-stage-border:var(--border); border:1px solid var(--review-stage-border); border-radius:var(--radius-row); padding:10px; display:flex; align-items:center; justify-content:center; min-height:96px; overflow:auto; background:var(--review-stage-bg); }
|
|
279
|
+
.review-stage[data-stage-theme="dark"] { --review-stage-bg:var(--review-canvas-dark, #121212); --review-stage-border:var(--review-border-dark, #2d2d2d); }
|
|
280
|
+
.review-stage-diff { --review-checker-a:var(--review-checker-light-a, #f1f1ee); --review-checker-b:var(--review-checker-light-b, #ffffff); background:repeating-conic-gradient(var(--review-checker-a) 0% 25%, var(--review-checker-b) 0% 50%) 50% / 14px 14px; }
|
|
281
|
+
.review-stage-diff[data-stage-theme="dark"] { --review-checker-a:var(--review-checker-dark-a, #1f1f1f); --review-checker-b:var(--review-checker-dark-b, #161616); }
|
|
193
282
|
.review-stage img { display:block; max-width:100%; height:auto; }
|
|
194
283
|
.review-absent { border:1px dashed var(--border); border-radius:var(--radius-row); min-height:96px; padding:12px; display:flex; align-items:center; justify-content:center; text-align:center; font-size:var(--text-meta); color:var(--text-tertiary); background:var(--surface-sunken); }
|
|
195
284
|
.review-empty { margin:12px 0; color:var(--text-secondary); font-size:var(--text-body); }
|
|
@@ -216,7 +305,10 @@ export function reviewDocumentHtml(review) {
|
|
|
216
305
|
--text-caption: 11px;
|
|
217
306
|
--radius-panel: 14px;
|
|
218
307
|
--radius-menu: 12px;
|
|
308
|
+
--radius-field: 9px;
|
|
219
309
|
--radius-row: 8px;
|
|
310
|
+
--radius-keycap: 6px;
|
|
311
|
+
--radius-pill: 999px;
|
|
220
312
|
--canvas: #ecece9;
|
|
221
313
|
--surface: #ffffff;
|
|
222
314
|
--surface-section: #f5f5f3;
|
|
@@ -225,6 +317,7 @@ export function reviewDocumentHtml(review) {
|
|
|
225
317
|
--text: #1c1c1a;
|
|
226
318
|
--text-secondary: #5b5b57;
|
|
227
319
|
--text-tertiary: #7c7c77;
|
|
320
|
+
--accent: #1c1c1a;
|
|
228
321
|
}
|
|
229
322
|
@media (prefers-color-scheme: dark) {
|
|
230
323
|
:root {
|
|
@@ -236,6 +329,7 @@ export function reviewDocumentHtml(review) {
|
|
|
236
329
|
--text: #efefed;
|
|
237
330
|
--text-secondary: #a8a8a4;
|
|
238
331
|
--text-tertiary: #85857f;
|
|
332
|
+
--accent: #efefed;
|
|
239
333
|
}
|
|
240
334
|
}
|
|
241
335
|
* { box-sizing: border-box; }
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
3
|
import { mkdir, readFile, realpath, rm, symlink } from 'node:fs/promises';
|
|
4
|
-
import { resolveBase, materializeBase, sourceRenames, revisionValue, revisionError } from './arch-git.mjs';
|
|
4
|
+
import { resolveBase, materializeBase, sourceRenames, revisionValue, revisionError, revisionChanges } from './arch-git.mjs';
|
|
5
|
+
import { configInputFiles } from './input-generation.mjs';
|
|
5
6
|
import { loadConfig, legacyConfigFile } from './config.mjs';
|
|
6
7
|
import { selectSources, relative } from './project.mjs';
|
|
7
8
|
import { buildSource } from './build.mjs';
|
|
8
9
|
import { cleanup } from './results.mjs';
|
|
9
|
-
import { CliError, withHumanOutputMapping } from '../cli-output.mjs';
|
|
10
|
+
import { CliError, asCliError, withHumanOutputMapping } from '../cli-output.mjs';
|
|
10
11
|
|
|
11
12
|
const environmentFiles = ['package.json', 'package-lock.json', 'npm-shrinkwrap.json', 'pnpm-lock.yaml', 'yarn.lock', 'bun.lock', 'bun.lockb'];
|
|
12
13
|
const slash = value => value.split(path.sep).join('/');
|
|
@@ -54,6 +55,12 @@ function historicalFailure(error) {
|
|
|
54
55
|
return new CliError('DIFF_BASE_DEPENDENCIES_UNAVAILABLE', `Historical import failed: ${error.message}`, { cause: error });
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
export function sourceFailure(error, source, side, translate = value => value) {
|
|
59
|
+
if (['OWNER_INDEX_CHANGED', 'IMPACT_INPUT_CHANGED'].includes(error.code)) throw error;
|
|
60
|
+
const failure = asCliError(side === 'base' ? historicalFailure(error) : error, 'SOURCE_BUILD_FAILED');
|
|
61
|
+
return { source, side, code: failure.code, message: translate(failure.message) };
|
|
62
|
+
}
|
|
63
|
+
|
|
57
64
|
function inventory(config, repository) {
|
|
58
65
|
return new Map(selectSources(config, [], { write: false }).map(file => {
|
|
59
66
|
const source = relative(config, file);
|
|
@@ -180,50 +187,79 @@ export async function prepareDiffInputs(config, args = [], options = {}) {
|
|
|
180
187
|
const current = path.relative(root, path.join(base.root, rename.after));
|
|
181
188
|
return outside(old) || outside(current) ? [] : [{ before: slash(old), after: slash(current) }];
|
|
182
189
|
});
|
|
190
|
+
const changes = (await revisionChanges(base)).map(change => Object.fromEntries(['before', 'after'].map(side => [side,
|
|
191
|
+
change[side] === null ? null : slash(path.relative(root, path.join(base.root, change[side])))])));
|
|
192
|
+
const changed = new Set(changes.flatMap(change => [change.before, change.after]).filter(Boolean));
|
|
193
|
+
const configFiles = await Promise.all([before, after].map(async side =>
|
|
194
|
+
(await configInputFiles(side.config)).map(file => relative(side.config, file))));
|
|
195
|
+
const globalChanges = [...new Set([...configFiles.flat(), ...configDependencies.changedFiles.map(name =>
|
|
196
|
+
slash(path.relative(root, path.join(base.root, name))))])].filter(name => changed.has(name));
|
|
183
197
|
let closed = false;
|
|
184
198
|
return {
|
|
185
|
-
base, before, after, sources, warnings, translateDiagnostic: translate, environment: { configDependencies, baseMigration },
|
|
186
|
-
async buildFrames({ browser, materialized, sources: requestedSources = sources, frame: requestedFrame = options.frame } = {}) {
|
|
199
|
+
base, before, after, sources, renames, changes, globalChanges, warnings, translateDiagnostic: translate, environment: { configDependencies, baseMigration },
|
|
200
|
+
async buildFrames({ browser, materialized, failures: previousFailures = [], sources: requestedSources = sources, frame: requestedFrame = options.frame, deferParts = false } = {}) {
|
|
187
201
|
if (closed) throw new CliError('SOURCE_BUILD_FAILED', 'Diff inputs are closed; prepare a new comparison.');
|
|
188
202
|
const built = materialized ? materialized.map(values => new Map(values)) : [new Map(), new Map()], snapshots = [new Map(), new Map()];
|
|
203
|
+
const failures = [...previousFailures];
|
|
204
|
+
const failed = new Set(failures.map(failure => failure.source));
|
|
205
|
+
const attempts = [new Set(), new Set()];
|
|
189
206
|
const build = async (side, index, source) => {
|
|
190
|
-
if (built[index].has(source) || !side.sources.has(source)) return;
|
|
207
|
+
if (attempts[index].has(source) || previousFailures.some(failure => failure.source === source) || built[index].has(source) || !side.sources.has(source)) return;
|
|
208
|
+
attempts[index].add(source);
|
|
191
209
|
try {
|
|
192
210
|
const work = () => buildSource(side.config, side.sources.get(source), { write: false, allowLegacy: false, snapshot: snapshots[index], browser });
|
|
193
211
|
built[index].set(source, await (side === before ? withHumanOutputMapping(work, translate) : work()));
|
|
194
212
|
} catch (error) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
throw failure;
|
|
213
|
+
failures.push(sourceFailure(error, source, index === 0 ? 'base' : 'current', translate));
|
|
214
|
+
failed.add(source);
|
|
198
215
|
}
|
|
199
216
|
};
|
|
200
217
|
for (const source of requestedSources) {
|
|
201
218
|
await build(before, 0, source);
|
|
202
219
|
await build(after, 1, source);
|
|
203
220
|
}
|
|
204
|
-
const frames = matchDiffFrames(requestedSources, built[0], built[1], renames
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
const ref = row.after.parent, key = frameKey({ source: ref.source, frame: ref.frame });
|
|
209
|
-
if (!parents.has(key)) {
|
|
210
|
-
await build(before, 0, ref.source);
|
|
211
|
-
await build(after, 1, ref.source);
|
|
212
|
-
const old = built[0].get(ref.source)?.frames.find(frame => frame.name === ref.frame);
|
|
213
|
-
const current = built[1].get(ref.source)?.frames.find(frame => frame.name === ref.frame);
|
|
214
|
-
if (!old || !current) throw new CliError('DIFF_REFERENCE_INVALID', `${row.source}: ${row.frame}: parent ${ref.source}: ${ref.frame} must exist at both revisions.`);
|
|
215
|
-
const parent = selected.get(key) ?? { source: ref.source, frame: ref.frame, before: old, after: current, status: 'matched', matchKind: 'exact', matchCandidates: [] };
|
|
216
|
-
parents.set(key, parent);
|
|
217
|
-
if (!selected.has(key)) support.push(parent);
|
|
218
|
-
}
|
|
219
|
-
row.parentRow = parents.get(key);
|
|
221
|
+
const frames = matchDiffFrames(requestedSources.filter(source => !failed.has(source)), built[0], built[1], renames)
|
|
222
|
+
.filter(row => requestedFrame === undefined || row.frame === requestedFrame);
|
|
223
|
+
if (requestedFrame !== undefined && !frames.some(row => row.frame === requestedFrame) && !failures.length) {
|
|
224
|
+
throw new CliError('FRAME_NOT_FOUND', `Unknown frame ${requestedFrame}; choose a frame present on either side.`);
|
|
220
225
|
}
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
226
|
+
const result = { frames, before: built[0], after: built[1], support: [], failures };
|
|
227
|
+
// Diff pairs moves before linking structural additions to their parents.
|
|
228
|
+
const prepareParts = async () => {
|
|
229
|
+
const { frames, support } = result, parents = new Map();
|
|
230
|
+
const selected = new Map(frames.map(row => [frameKey(row), row]));
|
|
231
|
+
for (const row of frames.filter(row => row.status === 'added' && row.after.parent)) {
|
|
232
|
+
if (failed.has(row.source)) continue;
|
|
233
|
+
const ref = row.after.parent, key = frameKey({ source: ref.source, frame: ref.frame });
|
|
234
|
+
if (!parents.has(key)) {
|
|
235
|
+
await build(before, 0, ref.source);
|
|
236
|
+
await build(after, 1, ref.source);
|
|
237
|
+
if (failed.has(ref.source)) {
|
|
238
|
+
failures.push({ source: row.source, side: 'current', code: 'DIFF_REFERENCE_INVALID', message: `${row.source}: ${row.frame}: parent source ${ref.source} failed to build.` });
|
|
239
|
+
failed.add(row.source);
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
const old = built[0].get(ref.source)?.frames.find(frame => frame.name === ref.frame);
|
|
243
|
+
const current = built[1].get(ref.source)?.frames.find(frame => frame.name === ref.frame);
|
|
244
|
+
if (!old || !current) throw new CliError('DIFF_REFERENCE_INVALID', `${row.source}: ${row.frame}: parent ${ref.source}: ${ref.frame} must exist at both revisions.`);
|
|
245
|
+
const parent = selected.get(key) ?? { source: ref.source, frame: ref.frame, before: old, after: current, status: 'matched', matchKind: 'exact', matchCandidates: [] };
|
|
246
|
+
parents.set(key, parent);
|
|
247
|
+
if (!selected.has(key)) support.push(parent);
|
|
248
|
+
}
|
|
249
|
+
row.parentRow = parents.get(key);
|
|
250
|
+
}
|
|
251
|
+
const candidates = frames.filter(row => row.matchKind === 'renamed_or_unknown');
|
|
252
|
+
if (candidates.length) warnings.push({
|
|
253
|
+
code: 'DIFF_RENAMED_OR_UNKNOWN',
|
|
254
|
+
message: `Unmatched frames have rename candidates: ${candidates.map(row => frameKey(row)).join(', ')}.`, next: [],
|
|
255
|
+
});
|
|
256
|
+
for (const source of failed) for (const values of built) values.delete(source);
|
|
257
|
+
result.frames = frames.filter(row => !failed.has(row.source));
|
|
258
|
+
result.support = support.filter(row => !failed.has(row.source));
|
|
259
|
+
};
|
|
260
|
+
if (deferParts) result.prepareParts = prepareParts;
|
|
261
|
+
else await prepareParts();
|
|
262
|
+
return result;
|
|
227
263
|
},
|
|
228
264
|
async close() { closed = true; await tree.close(); },
|
|
229
265
|
};
|