@zenera/cli 1.3.22 → 1.3.23

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.
Files changed (23) hide show
  1. package/package.json +6 -6
  2. package/templates/editor/.github/skills/zen-review/scripts/check-paths.sh +1 -1
  3. package/templates/project/agents/skills/html-page/SKILL.md +96 -51
  4. package/templates/project/agents/skills/html-page/assets/app/api/items.api.py +3 -2
  5. package/templates/project/agents/skills/html-page/assets/app/app.tsx +140 -0
  6. package/templates/project/agents/skills/html-page/assets/dashboard.tsx +162 -0
  7. package/templates/project/agents/skills/html-page/kit/Chart.tsx +79 -0
  8. package/templates/project/agents/skills/html-page/kit/Table.tsx +89 -0
  9. package/templates/project/agents/skills/html-page/kit/api.ts +93 -0
  10. package/templates/project/agents/skills/html-page/kit/components.tsx +266 -0
  11. package/templates/project/agents/skills/html-page/kit/format.ts +60 -0
  12. package/templates/project/agents/skills/html-page/kit/hooks.ts +159 -0
  13. package/templates/project/agents/skills/html-page/kit/index.ts +35 -0
  14. package/templates/project/agents/skills/html-page/kit/modules.d.ts +37 -0
  15. package/templates/project/agents/skills/html-page/kit/mount.tsx +62 -0
  16. package/templates/project/agents/skills/html-page/kit/shell.html +19 -0
  17. package/templates/project/agents/skills/html-page/kit/theme.css +326 -0
  18. package/templates/project/agents/skills/html-page/references/charts-and-tables.md +105 -53
  19. package/templates/project/agents/skills/html-page/references/python-functions.md +37 -29
  20. package/templates/project/agents/skills/html-page/scripts/build.ts +825 -0
  21. package/templates/project/agents/skills/html-page/assets/api.js +0 -87
  22. package/templates/project/agents/skills/html-page/assets/app/index.html +0 -278
  23. package/templates/project/agents/skills/html-page/assets/dashboard.html +0 -423
@@ -1,423 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1" />
6
- <title>Dashboard</title>
7
- <link
8
- rel="stylesheet"
9
- href="https://cdn.jsdelivr.net/npm/tabulator-tables@6.3.1/dist/css/tabulator_simple.min.css"
10
- />
11
- <script src="https://cdn.jsdelivr.net/npm/echarts@5.6.0/dist/echarts.min.js"></script>
12
- <script src="https://cdn.jsdelivr.net/npm/tabulator-tables@6.3.1/dist/js/tabulator.min.js"></script>
13
- <style>
14
- :root {
15
- color-scheme: light dark;
16
- --bg: #f7f7f8;
17
- --card: #ffffff;
18
- --fg: #1d1d1f;
19
- --muted: #6e6e73;
20
- --line: #e3e3e6;
21
- --accent: #2563eb;
22
- --up: #15803d;
23
- --down: #b91c1c;
24
- --gap: 16px;
25
- --radius: 10px;
26
- font:
27
- 14px/1.45 system-ui,
28
- -apple-system,
29
- 'Segoe UI',
30
- Roboto,
31
- sans-serif;
32
- }
33
- @media (prefers-color-scheme: dark) {
34
- :root {
35
- --bg: #141416;
36
- --card: #1e1e21;
37
- --fg: #ececf0;
38
- --muted: #9a9aa2;
39
- --line: #2e2e33;
40
- --accent: #60a5fa;
41
- --up: #4ade80;
42
- --down: #f87171;
43
- }
44
- }
45
- * {
46
- box-sizing: border-box;
47
- }
48
- body {
49
- margin: 0;
50
- background: var(--bg);
51
- color: var(--fg);
52
- }
53
- main {
54
- max-width: 1400px;
55
- margin: 0 auto;
56
- padding: var(--gap);
57
- display: grid;
58
- gap: var(--gap);
59
- }
60
- header h1 {
61
- margin: 0;
62
- font-size: 1.4rem;
63
- }
64
- header p {
65
- margin: 4px 0 0;
66
- color: var(--muted);
67
- }
68
- .card {
69
- background: var(--card);
70
- border: 1px solid var(--line);
71
- border-radius: var(--radius);
72
- padding: var(--gap);
73
- min-width: 0;
74
- }
75
- .card h2 {
76
- margin: 0 0 8px;
77
- font-size: 1rem;
78
- }
79
-
80
- .filters {
81
- display: flex;
82
- flex-wrap: wrap;
83
- gap: 8px 16px;
84
- align-items: end;
85
- }
86
- .filters label {
87
- display: grid;
88
- gap: 2px;
89
- font-size: 0.85rem;
90
- color: var(--muted);
91
- }
92
- .filters select,
93
- .filters input {
94
- font: inherit;
95
- color: var(--fg);
96
- background: var(--card);
97
- border: 1px solid var(--line);
98
- border-radius: 6px;
99
- padding: 4px 8px;
100
- min-width: 9rem;
101
- }
102
-
103
- .kpis {
104
- display: grid;
105
- gap: var(--gap);
106
- grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
107
- }
108
- .kpi .label {
109
- color: var(--muted);
110
- font-size: 0.85rem;
111
- }
112
- .kpi .value {
113
- font-size: 1.6rem;
114
- font-weight: 600;
115
- font-variant-numeric: tabular-nums;
116
- }
117
- .kpi .delta.up {
118
- color: var(--up);
119
- }
120
- .kpi .delta.down {
121
- color: var(--down);
122
- }
123
-
124
- .grid {
125
- display: grid;
126
- gap: var(--gap);
127
- grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
128
- }
129
- .wide {
130
- grid-column: 1 / -1;
131
- }
132
- .chart {
133
- width: 100%;
134
- height: 320px;
135
- }
136
-
137
- .tabulator {
138
- font-size: 0.9rem;
139
- background: transparent;
140
- border-color: var(--line);
141
- }
142
- .tabulator .tabulator-header,
143
- .tabulator .tabulator-header .tabulator-col,
144
- .tabulator .tabulator-tableholder,
145
- .tabulator .tabulator-tableholder .tabulator-table,
146
- .tabulator-row,
147
- .tabulator .tabulator-footer {
148
- background: var(--card);
149
- color: var(--fg);
150
- border-color: var(--line);
151
- }
152
- .tabulator-row.tabulator-row-even {
153
- background: color-mix(in srgb, var(--card) 94%, var(--fg));
154
- }
155
- .tabulator-row.tabulator-selectable:hover {
156
- background: color-mix(in srgb, var(--card) 85%, var(--accent));
157
- }
158
- .tabulator input,
159
- .tabulator select {
160
- color: var(--fg);
161
- background: var(--bg);
162
- border: 1px solid var(--line);
163
- }
164
-
165
- footer {
166
- color: var(--muted);
167
- font-size: 0.8rem;
168
- }
169
-
170
- @media (max-width: 520px) {
171
- :root {
172
- --gap: 10px;
173
- font-size: 13px;
174
- }
175
- .chart {
176
- height: 260px;
177
- }
178
- .kpi .value {
179
- font-size: 1.3rem;
180
- }
181
- }
182
- </style>
183
- </head>
184
- <body>
185
- <main>
186
- <header>
187
- <h1 id="title">Dashboard</h1>
188
- <p id="subtitle"></p>
189
- </header>
190
-
191
- <section class="card filters" id="filters"></section>
192
- <section class="kpis" id="kpis"></section>
193
-
194
- <section class="grid">
195
- <div class="card">
196
- <h2>By category</h2>
197
- <div class="chart" id="chart-bar"></div>
198
- </div>
199
- <div class="card">
200
- <h2>Over time</h2>
201
- <div class="chart" id="chart-line"></div>
202
- </div>
203
- <div class="card wide">
204
- <h2>Rows</h2>
205
- <div id="table"></div>
206
- </div>
207
- </section>
208
-
209
- <footer id="source"></footer>
210
- </main>
211
-
212
- <script>
213
- // ---- Helpers: keep these, change the page below them. ----
214
-
215
- const dark = matchMedia('(prefers-color-scheme: dark)');
216
- const charts = [];
217
-
218
- // Data inlined in <script type="application/json" id="data"> wins; otherwise data.json beside the page.
219
- // Live data instead: copy api.js beside the page, load it with <script src="api.js"> above
220
- // this script, and return api('api/report').get_data() here (references/python-functions.md).
221
- async function loadData(file = 'data.json') {
222
- const inline = document.getElementById('data');
223
- if (inline) return JSON.parse(inline.textContent);
224
- const res = await fetch(file);
225
- if (!res.ok) throw new Error(`${file}: ${res.status}`);
226
- return res.json();
227
- }
228
-
229
- // An ECharts chart that follows its box's size and the light/dark scheme.
230
- function chart(id, option = {}) {
231
- const el = document.getElementById(id);
232
- const base = {
233
- backgroundColor: 'transparent',
234
- tooltip: { trigger: 'axis', confine: true },
235
- grid: { left: 8, right: 16, top: 32, bottom: 8, containLabel: true },
236
- };
237
- let c = echarts.init(el, dark.matches ? 'dark' : null);
238
- const handlers = [];
239
- const entry = { option: { ...base, ...option } };
240
- entry.set = (opt) => {
241
- entry.option = { ...base, ...opt };
242
- c.setOption(entry.option, true);
243
- };
244
- entry.on = (event, fn) => {
245
- handlers.push([event, fn]);
246
- c.on(event, fn);
247
- };
248
- entry.retheme = () => {
249
- c.dispose();
250
- c = echarts.init(el, dark.matches ? 'dark' : null);
251
- c.setOption(entry.option);
252
- handlers.forEach(([e, fn]) => c.on(e, fn));
253
- };
254
- c.setOption(entry.option);
255
- new ResizeObserver(() => c.resize()).observe(el);
256
- charts.push(entry);
257
- return entry;
258
- }
259
- dark.addEventListener('change', () => charts.forEach((c) => c.retheme()));
260
-
261
- // A sortable, filterable table; collapses columns that do not fit a narrow panel.
262
- // .set(rows) replaces the rows, waiting for the table to finish building if it has to.
263
- function table(id, rows, columns) {
264
- const t = new Tabulator('#' + id, {
265
- data: rows,
266
- columns,
267
- layout: 'fitDataStretch',
268
- responsiveLayout: 'collapse',
269
- pagination: true,
270
- paginationSize: 25,
271
- paginationCounter: 'rows',
272
- placeholder: 'No rows match the filters',
273
- });
274
- const built = new Promise((resolve) => t.on('tableBuilt', resolve));
275
- return { tabulator: t, set: (next) => built.then(() => t.setData(next)) };
276
- }
277
-
278
- const fmt = {
279
- num: (v, d = 0) =>
280
- v == null
281
- ? '–'
282
- : new Intl.NumberFormat(undefined, { maximumFractionDigits: d }).format(v),
283
- money: (v, cur = 'USD') =>
284
- v == null
285
- ? '–'
286
- : new Intl.NumberFormat(undefined, {
287
- style: 'currency',
288
- currency: cur,
289
- maximumFractionDigits: 0,
290
- }).format(v),
291
- pct: (v, d = 1) =>
292
- v == null
293
- ? '–'
294
- : new Intl.NumberFormat(undefined, {
295
- style: 'percent',
296
- maximumFractionDigits: d,
297
- }).format(v),
298
- };
299
- const esc = (s) => String(s).replace(/[&<>"']/g, (ch) => `&#${ch.charCodeAt(0)};`);
300
-
301
- // [{ label, value, delta? }] - value already formatted, delta a fraction (0.12 = +12%).
302
- function kpis(items) {
303
- document.getElementById('kpis').innerHTML = items
304
- .map(
305
- (k) => `
306
- <div class="card kpi"><div class="label">${esc(k.label)}</div>
307
- <div class="value">${esc(k.value)}</div>
308
- ${k.delta == null ? '' : `<div class="delta ${k.delta >= 0 ? 'up' : 'down'}">${k.delta >= 0 ? '▲' : '▼'} ${fmt.pct(Math.abs(k.delta))}</div>`}
309
- </div>`,
310
- )
311
- .join('');
312
- }
313
-
314
- // A <select> per field, "All" first; onChange gets { field: value or '' }.
315
- function filters(defs, onChange) {
316
- const box = document.getElementById('filters');
317
- const state = {};
318
- box.innerHTML = defs
319
- .map(
320
- (d) => `<label>${esc(d.label)}<select data-field="${esc(d.field)}">
321
- <option value="">All</option>${d.values.map((v) => `<option>${esc(v)}</option>`).join('')}</select></label>`,
322
- )
323
- .join('');
324
- box.addEventListener('change', (e) => {
325
- state[e.target.dataset.field] = e.target.value;
326
- onChange({ ...state });
327
- });
328
- }
329
-
330
- const sum = (rows, f) => rows.reduce((a, r) => a + (+r[f] || 0), 0);
331
- const groupSum = (rows, key, f) => {
332
- const m = new Map();
333
- for (const r of rows) m.set(r[key], (m.get(r[key]) || 0) + (+r[f] || 0));
334
- return [...m.entries()];
335
- };
336
- const uniq = (rows, f) => [...new Set(rows.map((r) => r[f]))].sort();
337
-
338
- // ---- The page: replace from here with the real data's fields. ----
339
- // Expects { "title", "subtitle", "source", "rows": [{ "date", "category", "region", "amount" }] }.
340
-
341
- loadData()
342
- .then((data) => {
343
- document.title = data.title;
344
- document.getElementById('title').textContent = data.title;
345
- document.getElementById('subtitle').textContent = data.subtitle || '';
346
- document.getElementById('source').textContent = data.source || '';
347
-
348
- const all = data.rows;
349
- const bar = chart('chart-bar');
350
- const line = chart('chart-line');
351
- const grid = table('table', all, [
352
- { title: 'Date', field: 'date', headerFilter: 'input', minWidth: 100 },
353
- { title: 'Category', field: 'category', headerFilter: 'input' },
354
- { title: 'Region', field: 'region', headerFilter: 'input' },
355
- {
356
- title: 'Amount',
357
- field: 'amount',
358
- hozAlign: 'right',
359
- sorter: 'number',
360
- formatter: (c) => fmt.num(c.getValue(), 2),
361
- },
362
- ]);
363
-
364
- function render(state) {
365
- const rows = all.filter((r) =>
366
- Object.entries(state).every(([f, v]) => !v || String(r[f]) === v),
367
- );
368
- kpis([
369
- { label: 'Total amount', value: fmt.num(sum(rows, 'amount')) },
370
- { label: 'Rows', value: fmt.num(rows.length) },
371
- { label: 'Categories', value: fmt.num(uniq(rows, 'category').length) },
372
- ]);
373
- const byCat = groupSum(rows, 'category', 'amount').sort(
374
- (a, b) => b[1] - a[1],
375
- );
376
- bar.set({
377
- xAxis: {
378
- type: 'category',
379
- data: byCat.map((d) => d[0]),
380
- axisLabel: { interval: 0, rotate: byCat.length > 5 ? 30 : 0 },
381
- },
382
- yAxis: { type: 'value' },
383
- series: [{ type: 'bar', data: byCat.map((d) => d[1]) }],
384
- });
385
- const byDate = groupSum(rows, 'date', 'amount').sort((a, b) =>
386
- String(a[0]).localeCompare(String(b[0])),
387
- );
388
- line.set({
389
- xAxis: { type: 'category', data: byDate.map((d) => d[0]) },
390
- yAxis: { type: 'value' },
391
- dataZoom: byDate.length > 30 ? [{ type: 'inside' }] : [],
392
- series: [
393
- {
394
- type: 'line',
395
- showSymbol: false,
396
- areaStyle: { opacity: 0.15 },
397
- data: byDate.map((d) => d[1]),
398
- },
399
- ],
400
- });
401
- grid.set(rows);
402
- }
403
-
404
- filters(
405
- [
406
- { field: 'category', label: 'Category', values: uniq(all, 'category') },
407
- { field: 'region', label: 'Region', values: uniq(all, 'region') },
408
- ],
409
- render,
410
- );
411
- render({});
412
- })
413
- .catch((err) => {
414
- document
415
- .querySelector('main')
416
- .insertAdjacentHTML(
417
- 'afterbegin',
418
- `<div class="card" style="border-color:var(--down)">Could not load the data: ${esc(err.message)}</div>`,
419
- );
420
- });
421
- </script>
422
- </body>
423
- </html>