@celljs/ta-glance 0.0.0-stage → 4.12.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.en.md ADDED
@@ -0,0 +1,11 @@
1
+ # Cell - Ta Glance
2
+
3
+ A pi package that comes with Ta (on by default; Settings → Extensions of the web client turns it off): Glance. Replies lead with the answer and show results as a card, all of it at a glance, rather than paragraphs to read.
4
+
5
+ - **The answer first, little of the process**: under the Ta service, every turn's system prompt gets a `<ta-glance>` section: the first line is the conclusion in one sentence, what matters in bold; then only what the user needs to act or decide; a short question gets one to three sentences.
6
+ - **Results as a card**: when a reply reports work done, results, a comparison, choices to make, or several facts or relations, Ta writes a `ta-glance` block (JSON) after the first line, which the web client draws as a card: key numbers, files changed (opened by a click), steps, before and after, bars, a flow, a Mermaid diagram, a table, choices to tap, risks and to-dos, buttons of what to ask next, folded details. The card grows as the reply streams.
7
+ - **Elsewhere**: the preview of the list of conversations shows the first line; replies to WeChat and WeCom bots draw no card and stay short paragraphs; `ta` in a terminal replies as before. External agents (ta-agents) get the section too.
8
+
9
+ The card's format is in `web-src/glance-protocol.ts`, the prompt in `web-src/glance-prompt.ts`. Other packages draw cards for fenced blocks of their own languages with `registerCodeRenderer`.
10
+
11
+ Design notes: `docs/design/ta-glance.md`.
package/README.md CHANGED
@@ -1,3 +1,11 @@
1
- # Temporary Holding Version
1
+ # Cell - Ta Glance
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Ta 自带的 pi 包(默认开启,可在 Web 客户端的 设置 → 扩展 关闭):速览。回复先说结论,结果画成一张卡片,一眼看到全貌,不用读大段文字。
4
+
5
+ - **先说结论、少说过程**:在 Ta 服务下,每一轮的系统提示里多一段 `<ta-glance>`:第一行一句话结论、关键词加粗;只写你要行动或决定的东西;小问题一到三句。
6
+ - **结果画成卡片**:汇报完成的工作、结果、对比、要你选的方案、多个事实或关系时,Ta 在第一行之后写一个 `ta-glance` 代码块(JSON),Web 把它画成卡片:关键数字、改了的文件(点开)、步骤、前后对比、横条、流程、Mermaid 关系图、表格、可点选的方案、风险与待办、下一步按钮、折叠的细节。卡片随回复流式长出来。
7
+ - **别处**:对话列表的预览显示第一行结论;发到微信、企业微信机器人的回复不画卡片,照常是短段落;终端里的 `ta` 回复照旧。外部 Agent(ta-agents)也会拿到这段写法。
8
+
9
+ 卡片的格式见 `web-src/glance-protocol.ts`,提示词见 `web-src/glance-prompt.ts`。别的包也能用 `registerCodeRenderer` 为自己的代码块语言画卡片。
10
+
11
+ 设计记录:`docs/design/ta-glance.md`。
@@ -0,0 +1,67 @@
1
+ // ../ta-protocol/esm/common/ta-extension-host.js
2
+ var TA_HOST_EVENT = "ta:host";
3
+ var TaHostUtil;
4
+ (function(TaHostUtil2) {
5
+ TaHostUtil2.WAIT_MS = 1000;
6
+ function reach(events, name, waitMs = TaHostUtil2.WAIT_MS) {
7
+ return new Promise((resolve) => {
8
+ const timer = setTimeout(() => resolve(undefined), waitMs);
9
+ const request = {
10
+ name,
11
+ resolve: (answer) => {
12
+ clearTimeout(timer);
13
+ resolve(answer);
14
+ }
15
+ };
16
+ events.emit(TA_HOST_EVENT, request);
17
+ });
18
+ }
19
+ TaHostUtil2.reach = reach;
20
+ })(TaHostUtil || (TaHostUtil = {}));
21
+
22
+ // web-src/glance-protocol.ts
23
+ var NAME = "@celljs/ta-glance";
24
+ var LANGUAGE = "ta-glance";
25
+
26
+ // web-src/glance-prompt.ts
27
+ var GLANCE_PROMPT = `The user reads your replies in Ta, often on a phone, and wants to take in the result at a glance, not read long text.
28
+
29
+ How to reply:
30
+ - Lead with the answer. The first line is the conclusion in one sentence, what matters in **bold**. Nothing before it: no "Sure", no restating the request.
31
+ - Then only what the user needs to act or decide. Leave out the process (what you read, ran, tried), what the user already knows and repeating yourself. Prefer numbers and names to adjectives.
32
+ - A short question or small talk: one to three sentences, no card.
33
+ - When the reply reports work done, results, a comparison, choices to make, or an analysis with several facts or relations: after the first line put one card, a fenced block of language ${LANGUAGE} holding JSON, instead of paragraphs, headings and long lists. Ta draws it as a picture. After the card at most two short lines, only for what it cannot hold; never repeat what it shows.
34
+ - Code the user must read or copy stays in ordinary code blocks.
35
+
36
+ The card: {"status": "done" | "partial" | "failed" | "blocked" | "info", "title"?: string, "blocks": [...]}
37
+ status: done = finished, partial = done in part, failed, blocked = waiting for the user, info = an answer, no work. Leave out title: the first line already says it.
38
+ Blocks, 1 to 4 of them, the most important first. Every text a few words, in the user's language; inline Markdown works (**bold**, \`path/to/file\` opens the file).
39
+ - {"type":"stats","items":[{"label":"Tests","value":"128/128","tone":"good"},{"label":"Startup","value":"210 ms","delta":"-34%","tone":"good"}]}: key numbers, at most 6; tone good | bad | warn.
40
+ - {"type":"changes","items":[{"path":"src/a.ts","kind":"edit","add":12,"del":3,"note":"why, in a few words"}]}: files changed; kind add | edit | delete.
41
+ - {"type":"steps","items":[{"text":"...","status":"done"}]}: progress or a plan; status done | doing | todo | failed | skipped.
42
+ - {"type":"compare","unit":"ms","better":"lower","items":[{"label":"Startup","before":320,"after":210}]}: before and after, numbers only.
43
+ - {"type":"bars","unit":"MB","items":[{"label":"ta","value":66},{"label":"pi","value":129}]}: amounts side by side.
44
+ - {"type":"flow","items":["Request","Gateway","Session","Model"]}: a sequence or a path.
45
+ - {"type":"diagram","mermaid":"graph LR; A-->B"}: relations a flow cannot show, under 12 nodes.
46
+ - {"type":"table","columns":["",""],"rows":[["",""]]}: a few rows that compare things on several points.
47
+ - {"type":"options","question":"Which one?","items":[{"label":"A","detail":"one line","pros":["..."],"cons":["..."],"recommended":true}]}: when the user must choose; each is a button that answers with its label.
48
+ - {"type":"notes","items":[{"text":"...","tone":"risk"}]}: risks, caveats, what the user must do; tone risk | info | todo.
49
+ - {"type":"next","items":["Run the e2e tests"]}: at most 3 things the user may well ask next, each a button that sends it.
50
+ - {"type":"details","title":"How","markdown":"..."}: what few will read, folded.`;
51
+
52
+ // web-src/extension.ts
53
+ function activate(pi) {
54
+ let served;
55
+ const underServe = () => served ??= TaHostUtil.reach(pi.events, NAME).then((answer) => answer !== undefined);
56
+ pi.on("session_start", () => {
57
+ underServe();
58
+ });
59
+ pi.on("before_agent_start", async (event) => {
60
+ if (await underServe()) {
61
+ event.systemPromptOptions.sections = { ...event.systemPromptOptions.sections, [LANGUAGE]: GLANCE_PROMPT };
62
+ }
63
+ });
64
+ }
65
+ export {
66
+ activate as default
67
+ };
package/package.json CHANGED
@@ -1,6 +1,53 @@
1
1
  {
2
2
  "name": "@celljs/ta-glance",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "4.12.0",
4
+ "description": "A pi package for Ta: replies lead with the answer, short, and show results as cards (key numbers, files, steps, comparisons, choices) rather than paragraphs",
5
+ "keywords": [
6
+ "pi-package"
7
+ ],
8
+ "homepage": "https://github.com/cellbang/cell",
9
+ "bugs": {
10
+ "url": "https://github.com/cellbang/cell/issues"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/cellbang/cell.git"
15
+ },
16
+ "license": "MIT",
17
+ "files": [
18
+ "web",
19
+ "extension",
20
+ "!**/*.map"
21
+ ],
22
+ "scripts": {
23
+ "build": "tsc -b && bun build web-src/index.tsx --format esm --target browser --outfile web/index.js && bun build web-src/extension.ts --format esm --target node --outfile extension/index.mjs",
24
+ "clean": "rm -rf lib web extension *.tsbuildinfo",
25
+ "test": "bun test ./lib",
26
+ "watch": "tsc -b -w --preserveWatchOutput"
27
+ },
28
+ "devDependencies": {
29
+ "@celljs/ta-protocol": "4.12.0",
30
+ "@celljs/ta-web": "4.12.0",
31
+ "@types/react": "^19.3.0"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "pi": {
37
+ "title": {
38
+ "en": "Glance",
39
+ "zh-CN": "速览"
40
+ },
41
+ "summary": {
42
+ "en": "Replies lead with the answer and show results as cards: key numbers, files, steps, before and after, choices to tap.",
43
+ "zh-CN": "回复先说结论,结果画成卡片:关键数字、改了哪些文件、步骤、前后对比、点一下就能选的方案。"
44
+ },
45
+ "icon": "LayoutDashboard",
46
+ "web": [
47
+ "./web/index.js"
48
+ ],
49
+ "extensions": [
50
+ "./extension/index.mjs"
51
+ ]
52
+ }
53
+ }
package/web/index.js ADDED
@@ -0,0 +1,1013 @@
1
+ // web-src/glance-json.ts
2
+ var GlanceJson;
3
+ ((GlanceJson) => {
4
+ const TRIES = 40;
5
+ function parse(text, partial) {
6
+ const source = text.trim().replace(/,\s*([}\]])/g, "$1");
7
+ if (!source) {
8
+ return;
9
+ }
10
+ try {
11
+ return JSON.parse(source);
12
+ } catch {
13
+ if (!partial) {
14
+ return;
15
+ }
16
+ }
17
+ let end = source.length;
18
+ for (let tries = 0;tries < TRIES && end > 0; tries++) {
19
+ const closed = close(source.slice(0, end));
20
+ if (closed !== undefined) {
21
+ try {
22
+ return JSON.parse(closed);
23
+ } catch {}
24
+ }
25
+ end = Math.max(source.lastIndexOf(",", end - 1), source.lastIndexOf("{", end - 1) + 1, source.lastIndexOf("[", end - 1) + 1);
26
+ }
27
+ return;
28
+ }
29
+ GlanceJson.parse = parse;
30
+ function close(text) {
31
+ const open = [];
32
+ let inString = false;
33
+ let escaped = false;
34
+ for (const char of text) {
35
+ if (inString) {
36
+ if (escaped) {
37
+ escaped = false;
38
+ } else if (char === "\\") {
39
+ escaped = true;
40
+ } else if (char === '"') {
41
+ inString = false;
42
+ }
43
+ } else if (char === '"') {
44
+ inString = true;
45
+ } else if (char === "{" || char === "[") {
46
+ open.push(char === "{" ? "}" : "]");
47
+ } else if (char === "}" || char === "]") {
48
+ open.pop();
49
+ }
50
+ }
51
+ if (!open.length && !inString) {
52
+ return;
53
+ }
54
+ let body = text;
55
+ if (inString) {
56
+ body = `${escaped ? body.slice(0, -1) : body}"`;
57
+ }
58
+ body = body.replace(/[\s,:]+$/, "");
59
+ if (open[open.length - 1] === "}" && /[{,]\s*"(?:[^"\\]|\\.)*"$/.test(body)) {
60
+ body = body.replace(/,?\s*"(?:[^"\\]|\\.)*"$/, "");
61
+ }
62
+ return body + open.reverse().join("");
63
+ }
64
+ })(GlanceJson ||= {});
65
+
66
+ // web-src/glance-spec.ts
67
+ var ITEMS = 12;
68
+ var BLOCKS = 8;
69
+ var TEXT = 400;
70
+ var MARKDOWN = 8000;
71
+ var STATUSES = ["done", "partial", "failed", "blocked", "info"];
72
+ var TONES = ["good", "bad", "warn", "neutral"];
73
+ var STEPS = ["done", "doing", "todo", "failed", "skipped"];
74
+ var NOTES = ["risk", "info", "todo"];
75
+ function object(value) {
76
+ return value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
77
+ }
78
+ function text(value, max = TEXT) {
79
+ if (typeof value === "number" && Number.isFinite(value)) {
80
+ return String(value);
81
+ }
82
+ if (typeof value !== "string") {
83
+ return;
84
+ }
85
+ const trimmed = value.trim();
86
+ return trimmed ? trimmed.slice(0, max) : undefined;
87
+ }
88
+ function number(value) {
89
+ const parsed = typeof value === "string" ? Number.parseFloat(value.replace(/[^\d.eE+-]/g, "")) : value;
90
+ return typeof parsed === "number" && Number.isFinite(parsed) ? parsed : undefined;
91
+ }
92
+ function oneOf(value, values) {
93
+ const lower = typeof value === "string" ? value.trim().toLowerCase() : undefined;
94
+ return values.find((candidate) => candidate === lower);
95
+ }
96
+ function items(value, read) {
97
+ if (!Array.isArray(value)) {
98
+ return [];
99
+ }
100
+ const out = [];
101
+ for (const item of value) {
102
+ const made = read(item);
103
+ if (made !== undefined) {
104
+ out.push(made);
105
+ }
106
+ if (out.length === ITEMS) {
107
+ break;
108
+ }
109
+ }
110
+ return out;
111
+ }
112
+ function strings(value, max = ITEMS) {
113
+ return items(value, (item) => text(item) ?? text(object(item)?.label) ?? text(object(item)?.text)).slice(0, max);
114
+ }
115
+ function stat(item) {
116
+ const value = object(item);
117
+ const label = text(value?.label);
118
+ const shown = text(value?.value);
119
+ if (!label || shown === undefined) {
120
+ return;
121
+ }
122
+ const tone = oneOf(value?.tone, TONES);
123
+ const delta = text(value?.delta);
124
+ return { label, value: shown, ...tone ? { tone } : {}, ...delta ? { delta } : {} };
125
+ }
126
+ function change(item) {
127
+ const value = object(item);
128
+ const path = text(value?.path ?? item);
129
+ if (!path) {
130
+ return;
131
+ }
132
+ const kind = oneOf(value?.kind, ["add", "edit", "delete"]) ?? "edit";
133
+ const add = number(value?.add);
134
+ const del = number(value?.del);
135
+ const note = text(value?.note);
136
+ return {
137
+ path,
138
+ kind,
139
+ ...add !== undefined ? { add: Math.max(0, Math.round(add)) } : {},
140
+ ...del !== undefined ? { del: Math.max(0, Math.round(del)) } : {},
141
+ ...note ? { note } : {}
142
+ };
143
+ }
144
+ function step(item, partial) {
145
+ const value = object(item);
146
+ const shown = text(value?.text ?? value?.label ?? item);
147
+ return shown ? { text: shown, status: oneOf(value?.status, STEPS) ?? (partial ? "todo" : "done") } : undefined;
148
+ }
149
+ function option(item) {
150
+ const value = object(item);
151
+ const label = text(value?.label ?? item);
152
+ if (!label) {
153
+ return;
154
+ }
155
+ const detail = text(value?.detail);
156
+ return {
157
+ label,
158
+ ...detail ? { detail } : {},
159
+ pros: strings(value?.pros, 4),
160
+ cons: strings(value?.cons, 4),
161
+ ...value?.recommended === true ? { recommended: true } : {}
162
+ };
163
+ }
164
+ function note(item) {
165
+ const value = object(item);
166
+ const shown = text(value?.text ?? item);
167
+ return shown ? { text: shown, tone: oneOf(value?.tone, NOTES) ?? "info" } : undefined;
168
+ }
169
+ function block(item, partial) {
170
+ const value = object(item);
171
+ const type = typeof value?.type === "string" ? value.type.trim().toLowerCase() : undefined;
172
+ const unit = text(value?.unit, 16);
173
+ switch (type) {
174
+ case "stats": {
175
+ const list = items(value?.items, stat).slice(0, 6);
176
+ return list.length ? { type, items: list } : undefined;
177
+ }
178
+ case "changes": {
179
+ const list = items(value?.items, change);
180
+ return list.length ? { type, items: list } : undefined;
181
+ }
182
+ case "steps": {
183
+ const list = items(value?.items, (entry) => step(entry, partial));
184
+ return list.length ? { type, items: list } : undefined;
185
+ }
186
+ case "compare": {
187
+ const list = items(value?.items, (entry) => {
188
+ const measure = object(entry);
189
+ const label = text(measure?.label);
190
+ const before = number(measure?.before);
191
+ const after = number(measure?.after);
192
+ return label && before !== undefined && after !== undefined ? { label, before, after } : undefined;
193
+ });
194
+ const better = oneOf(value?.better, ["lower", "higher"]) ?? "lower";
195
+ return list.length ? { type, better, items: list, ...unit ? { unit } : {} } : undefined;
196
+ }
197
+ case "bars": {
198
+ const list = items(value?.items, (entry) => {
199
+ const amount = object(entry);
200
+ const label = text(amount?.label);
201
+ const shown = number(amount?.value);
202
+ return label && shown !== undefined ? { label, value: shown } : undefined;
203
+ });
204
+ return list.length ? { type, items: list, ...unit ? { unit } : {} } : undefined;
205
+ }
206
+ case "flow": {
207
+ const list = strings(value?.items);
208
+ return list.length ? { type, items: list } : undefined;
209
+ }
210
+ case "diagram": {
211
+ const mermaid = text(value?.mermaid, MARKDOWN);
212
+ return mermaid ? { type, mermaid } : undefined;
213
+ }
214
+ case "table": {
215
+ const columns = strings(value?.columns, 6);
216
+ const rows = items(value?.rows, (row) => Array.isArray(row) ? columns.map((_, index) => text(row[index]) ?? "") : undefined);
217
+ return columns.length && rows.length ? { type, columns, rows } : undefined;
218
+ }
219
+ case "options": {
220
+ const list = items(value?.items, option).slice(0, 5);
221
+ const question = text(value?.question);
222
+ return list.length ? { type, items: list, ...question ? { question } : {} } : undefined;
223
+ }
224
+ case "notes": {
225
+ const list = items(value?.items, note);
226
+ return list.length ? { type, items: list } : undefined;
227
+ }
228
+ case "next": {
229
+ const list = strings(value?.items, 3);
230
+ return list.length ? { type, items: list } : undefined;
231
+ }
232
+ case "details": {
233
+ const markdown = text(value?.markdown, MARKDOWN);
234
+ const title = text(value?.title);
235
+ return markdown ? { type, markdown, ...title ? { title } : {} } : undefined;
236
+ }
237
+ default:
238
+ return;
239
+ }
240
+ }
241
+ var GlanceSpec;
242
+ ((GlanceSpec) => {
243
+ function read(value, partial = false) {
244
+ const card = object(value);
245
+ if (!card) {
246
+ return;
247
+ }
248
+ const status = oneOf(card.status, STATUSES);
249
+ const title = text(card.title);
250
+ const blocks = items(card.blocks, (entry) => block(entry, partial)).slice(0, BLOCKS);
251
+ if (!blocks.length && !title) {
252
+ return;
253
+ }
254
+ return { blocks, ...status ? { status } : {}, ...title ? { title } : {} };
255
+ }
256
+ GlanceSpec.read = read;
257
+ })(GlanceSpec ||= {});
258
+
259
+ // web-src/glance-util.ts
260
+ function percent(before, after) {
261
+ if (!before) {
262
+ return "";
263
+ }
264
+ const change2 = Math.round((after - before) / Math.abs(before) * 100);
265
+ return `${change2 > 0 ? "+" : ""}${change2}%`;
266
+ }
267
+
268
+ // web-src/i18n.ts
269
+ var EN = {
270
+ status: { done: "Done", partial: "Partly done", failed: "Failed", blocked: "Needs you", info: "" },
271
+ before: "Before",
272
+ after: "After",
273
+ recommended: "Recommended",
274
+ choose: "Choose",
275
+ chosen: "Chosen",
276
+ pick: "I choose: {label}",
277
+ details: "Details",
278
+ hide: "Hide",
279
+ files: "{count} files",
280
+ writing: "Drawing the summary…"
281
+ };
282
+ var ZH = {
283
+ status: { done: "已完成", partial: "部分完成", failed: "失败", blocked: "需要你", info: "" },
284
+ before: "之前",
285
+ after: "之后",
286
+ recommended: "推荐",
287
+ choose: "选这个",
288
+ chosen: "已选",
289
+ pick: "我选:{label}",
290
+ details: "详情",
291
+ hide: "收起",
292
+ files: "{count} 个文件",
293
+ writing: "正在整理摘要…"
294
+ };
295
+ var GlanceWords;
296
+ ((GlanceWords) => {
297
+ function of(language) {
298
+ return language === "zh-CN" ? ZH : EN;
299
+ }
300
+ GlanceWords.of = of;
301
+ function format(text2, values) {
302
+ return text2.replace(/\{(\w+)\}/g, (all, key) => (key in values) ? String(values[key]) : all);
303
+ }
304
+ GlanceWords.format = format;
305
+ })(GlanceWords ||= {});
306
+
307
+ // web-src/react.ts
308
+ var React;
309
+ function bind(react) {
310
+ React = react;
311
+ }
312
+
313
+ // web-src/card.tsx
314
+ var MARKS = /[*_`[\]$\\]/;
315
+ var SQUARES = 5;
316
+ var LINES = 20;
317
+ function fileName(path) {
318
+ return path.replace(/\/+$/, "").split("/").pop() || path;
319
+ }
320
+ function directory(path) {
321
+ const trimmed = path.replace(/\/+$/, "");
322
+ return trimmed.slice(0, Math.max(0, trimmed.lastIndexOf("/")));
323
+ }
324
+ function count(value) {
325
+ return Math.abs(value) >= 1000 ? value.toLocaleString() : String(Number(value.toFixed(2)));
326
+ }
327
+ function glanceCard(pi) {
328
+ const icons = pi.ui.icons;
329
+ const Markdown = pi.ui.Markdown;
330
+ function Text({ text: text2 }) {
331
+ return MARKS.test(text2) ? /* @__PURE__ */ React.createElement("span", {
332
+ className: "tag-inline"
333
+ }, /* @__PURE__ */ React.createElement(Markdown, {
334
+ text: text2
335
+ })) : text2;
336
+ }
337
+ function Icon({ name, size = 14 }) {
338
+ const Found = icons[name];
339
+ return Found ? /* @__PURE__ */ React.createElement(Found, {
340
+ size,
341
+ strokeWidth: 2
342
+ }) : null;
343
+ }
344
+ function Stats({ block: block2 }) {
345
+ return /* @__PURE__ */ React.createElement("div", {
346
+ className: "tag-stats",
347
+ "data-count": block2.items.length
348
+ }, block2.items.map((item, index) => /* @__PURE__ */ React.createElement("div", {
349
+ key: index,
350
+ className: "tag-stat",
351
+ "data-tone": item.tone
352
+ }, /* @__PURE__ */ React.createElement("div", {
353
+ className: "tag-stat-value"
354
+ }, /* @__PURE__ */ React.createElement(Text, {
355
+ text: item.value
356
+ })), /* @__PURE__ */ React.createElement("div", {
357
+ className: "tag-stat-label"
358
+ }, item.tone && !item.delta && /* @__PURE__ */ React.createElement("i", {
359
+ className: "tag-tone-dot"
360
+ }), /* @__PURE__ */ React.createElement(Text, {
361
+ text: item.label
362
+ }), item.delta && /* @__PURE__ */ React.createElement("span", {
363
+ className: "tag-delta"
364
+ }, item.delta)))));
365
+ }
366
+ function Squares({ change: change2, largest }) {
367
+ const add = change2.add ?? 0;
368
+ const del = change2.del ?? 0;
369
+ const total = add + del;
370
+ if (!total) {
371
+ return null;
372
+ }
373
+ const filled = Math.max(1, Math.round(Math.min(total, largest) / largest * SQUARES));
374
+ const green = Math.round(add / total * filled);
375
+ return /* @__PURE__ */ React.createElement("span", {
376
+ className: "tag-squares",
377
+ "aria-hidden": "true"
378
+ }, Array.from({ length: SQUARES }, (_, index) => /* @__PURE__ */ React.createElement("i", {
379
+ key: index,
380
+ "data-kind": index < green ? "add" : index < filled ? "del" : undefined
381
+ })));
382
+ }
383
+ function Changes({ block: block2, words }) {
384
+ const add = block2.items.reduce((sum, item) => sum + (item.add ?? 0), 0);
385
+ const del = block2.items.reduce((sum, item) => sum + (item.del ?? 0), 0);
386
+ const largest = Math.max(LINES, ...block2.items.map((item) => (item.add ?? 0) + (item.del ?? 0)));
387
+ return /* @__PURE__ */ React.createElement("div", {
388
+ className: "tag-changes"
389
+ }, /* @__PURE__ */ React.createElement("div", {
390
+ className: "tag-section-head"
391
+ }, /* @__PURE__ */ React.createElement("span", null, GlanceWords.format(words.files, { count: block2.items.length })), add > 0 && /* @__PURE__ */ React.createElement("span", {
392
+ className: "tag-add"
393
+ }, "+", add), del > 0 && /* @__PURE__ */ React.createElement("span", {
394
+ className: "tag-del"
395
+ }, "−", del)), block2.items.map((item, index) => /* @__PURE__ */ React.createElement("div", {
396
+ key: index,
397
+ className: "tag-change"
398
+ }, /* @__PURE__ */ React.createElement("span", {
399
+ className: "tag-kind",
400
+ "data-kind": item.kind
401
+ }, item.kind === "add" ? "A" : item.kind === "delete" ? "D" : "M"), /* @__PURE__ */ React.createElement("span", {
402
+ className: "tag-change-path"
403
+ }, /* @__PURE__ */ React.createElement("span", {
404
+ className: "tag-change-file"
405
+ }, /* @__PURE__ */ React.createElement("span", {
406
+ className: "tag-change-name"
407
+ }, /* @__PURE__ */ React.createElement(Text, {
408
+ text: `[${fileName(item.path)}](<${item.path}>)`
409
+ })), directory(item.path) && /* @__PURE__ */ React.createElement("span", {
410
+ className: "tag-change-dir",
411
+ title: item.path
412
+ }, /* @__PURE__ */ React.createElement("bdi", null, directory(item.path)))), item.note && /* @__PURE__ */ React.createElement("span", {
413
+ className: "tag-change-note"
414
+ }, /* @__PURE__ */ React.createElement(Text, {
415
+ text: item.note
416
+ }))), /* @__PURE__ */ React.createElement("span", {
417
+ className: "tag-change-count"
418
+ }, item.add ? /* @__PURE__ */ React.createElement("span", {
419
+ className: "tag-add"
420
+ }, "+", item.add) : null, item.del ? /* @__PURE__ */ React.createElement("span", {
421
+ className: "tag-del"
422
+ }, "−", item.del) : null, /* @__PURE__ */ React.createElement(Squares, {
423
+ change: item,
424
+ largest
425
+ })))));
426
+ }
427
+ const STEP_ICON = { done: "Check", failed: "X", skipped: "Minus", doing: undefined, todo: undefined };
428
+ function Steps({ block: block2 }) {
429
+ return /* @__PURE__ */ React.createElement("ol", {
430
+ className: "tag-steps"
431
+ }, block2.items.map((item, index) => /* @__PURE__ */ React.createElement("li", {
432
+ key: index,
433
+ className: "tag-step",
434
+ "data-status": item.status
435
+ }, /* @__PURE__ */ React.createElement("span", {
436
+ className: "tag-step-mark"
437
+ }, STEP_ICON[item.status] && /* @__PURE__ */ React.createElement(Icon, {
438
+ name: STEP_ICON[item.status],
439
+ size: 11
440
+ })), /* @__PURE__ */ React.createElement("span", {
441
+ className: "tag-step-text"
442
+ }, /* @__PURE__ */ React.createElement(Text, {
443
+ text: item.text
444
+ })))));
445
+ }
446
+ function Compare({ block: block2, words }) {
447
+ const largest = Math.max(...block2.items.flatMap((item) => [Math.abs(item.before), Math.abs(item.after)]), 0) || 1;
448
+ const unit = block2.unit ? ` ${block2.unit}` : "";
449
+ return /* @__PURE__ */ React.createElement("div", {
450
+ className: "tag-compare"
451
+ }, /* @__PURE__ */ React.createElement("div", {
452
+ className: "tag-section-head tag-legend"
453
+ }, /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("i", {
454
+ "data-bar": "before"
455
+ }), words.before), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("i", {
456
+ "data-bar": "after"
457
+ }), words.after)), block2.items.map((item, index) => {
458
+ const better = block2.better === "higher" ? item.after > item.before : item.after < item.before;
459
+ const tone = item.after === item.before ? "neutral" : better ? "good" : "bad";
460
+ return /* @__PURE__ */ React.createElement("div", {
461
+ key: index,
462
+ className: "tag-measure"
463
+ }, /* @__PURE__ */ React.createElement("div", {
464
+ className: "tag-measure-head"
465
+ }, /* @__PURE__ */ React.createElement("span", {
466
+ className: "tag-measure-label"
467
+ }, /* @__PURE__ */ React.createElement(Text, {
468
+ text: item.label
469
+ })), /* @__PURE__ */ React.createElement("span", {
470
+ className: "tag-measure-value"
471
+ }, count(item.before), " → ", /* @__PURE__ */ React.createElement("b", null, count(item.after)), unit, percent(item.before, item.after) && /* @__PURE__ */ React.createElement("span", {
472
+ className: "tag-delta",
473
+ "data-tone": tone
474
+ }, percent(item.before, item.after)))), /* @__PURE__ */ React.createElement("div", {
475
+ className: "tag-track"
476
+ }, /* @__PURE__ */ React.createElement("i", {
477
+ "data-bar": "before",
478
+ style: { width: `${Math.abs(item.before) / largest * 100}%` }
479
+ })), /* @__PURE__ */ React.createElement("div", {
480
+ className: "tag-track"
481
+ }, /* @__PURE__ */ React.createElement("i", {
482
+ "data-bar": "after",
483
+ "data-tone": tone,
484
+ style: { width: `${Math.abs(item.after) / largest * 100}%` }
485
+ })));
486
+ }));
487
+ }
488
+ function Bars({ block: block2 }) {
489
+ const largest = Math.max(...block2.items.map((item) => Math.abs(item.value)), 0) || 1;
490
+ const unit = block2.unit ? ` ${block2.unit}` : "";
491
+ return /* @__PURE__ */ React.createElement("div", {
492
+ className: "tag-bars"
493
+ }, block2.items.map((item, index) => /* @__PURE__ */ React.createElement("div", {
494
+ key: index,
495
+ className: "tag-bar"
496
+ }, /* @__PURE__ */ React.createElement("span", {
497
+ className: "tag-bar-label"
498
+ }, /* @__PURE__ */ React.createElement(Text, {
499
+ text: item.label
500
+ })), /* @__PURE__ */ React.createElement("span", {
501
+ className: "tag-track"
502
+ }, /* @__PURE__ */ React.createElement("i", {
503
+ style: { width: `${Math.abs(item.value) / largest * 100}%` }
504
+ })), /* @__PURE__ */ React.createElement("span", {
505
+ className: "tag-bar-value"
506
+ }, count(item.value), unit))));
507
+ }
508
+ function Flow({ block: block2 }) {
509
+ return /* @__PURE__ */ React.createElement("div", {
510
+ className: "tag-flow"
511
+ }, block2.items.map((item, index) => /* @__PURE__ */ React.createElement("span", {
512
+ key: index,
513
+ className: "tag-flow-step"
514
+ }, index > 0 && /* @__PURE__ */ React.createElement("span", {
515
+ className: "tag-flow-arrow",
516
+ "aria-hidden": "true"
517
+ }, /* @__PURE__ */ React.createElement(Icon, {
518
+ name: "ArrowRight",
519
+ size: 13
520
+ })), /* @__PURE__ */ React.createElement("span", {
521
+ className: "tag-flow-node"
522
+ }, /* @__PURE__ */ React.createElement(Text, {
523
+ text: item
524
+ })))));
525
+ }
526
+ function Table({ block: block2 }) {
527
+ return /* @__PURE__ */ React.createElement("div", {
528
+ className: "ta-table tag-table"
529
+ }, /* @__PURE__ */ React.createElement("table", null, /* @__PURE__ */ React.createElement("thead", null, /* @__PURE__ */ React.createElement("tr", null, block2.columns.map((column, index) => /* @__PURE__ */ React.createElement("th", {
530
+ key: index
531
+ }, /* @__PURE__ */ React.createElement(Text, {
532
+ text: column
533
+ }))))), /* @__PURE__ */ React.createElement("tbody", null, block2.rows.map((row, index) => /* @__PURE__ */ React.createElement("tr", {
534
+ key: index
535
+ }, row.map((cell, column) => /* @__PURE__ */ React.createElement("td", {
536
+ key: column
537
+ }, /* @__PURE__ */ React.createElement(Text, {
538
+ text: cell
539
+ }))))))));
540
+ }
541
+ function Options({ block: block2, words, closed }) {
542
+ const [chosen, setChosen] = React.useState();
543
+ const choose = (label) => {
544
+ setChosen(label);
545
+ pi.sendUserMessage(GlanceWords.format(words.pick, { label })).catch((error) => {
546
+ setChosen(undefined);
547
+ pi.ui.notify(error instanceof Error ? error.message : String(error), "error");
548
+ });
549
+ };
550
+ return /* @__PURE__ */ React.createElement("div", {
551
+ className: "tag-options-block"
552
+ }, block2.question && /* @__PURE__ */ React.createElement("div", {
553
+ className: "tag-question"
554
+ }, /* @__PURE__ */ React.createElement(Text, {
555
+ text: block2.question
556
+ })), /* @__PURE__ */ React.createElement("div", {
557
+ className: "tag-options"
558
+ }, block2.items.map((item, index) => {
559
+ const picked = chosen === item.label;
560
+ return /* @__PURE__ */ React.createElement("div", {
561
+ key: index,
562
+ className: "tag-option",
563
+ "data-recommended": item.recommended || undefined,
564
+ "data-chosen": picked || undefined,
565
+ "data-other": chosen && !picked || undefined
566
+ }, /* @__PURE__ */ React.createElement("div", {
567
+ className: "tag-option-main"
568
+ }, /* @__PURE__ */ React.createElement("div", {
569
+ className: "tag-option-head"
570
+ }, /* @__PURE__ */ React.createElement("span", {
571
+ className: "tag-option-label"
572
+ }, /* @__PURE__ */ React.createElement(Text, {
573
+ text: item.label
574
+ })), item.recommended && /* @__PURE__ */ React.createElement("span", {
575
+ className: "tag-badge"
576
+ }, words.recommended)), item.detail && /* @__PURE__ */ React.createElement("div", {
577
+ className: "tag-option-detail"
578
+ }, /* @__PURE__ */ React.createElement(Text, {
579
+ text: item.detail
580
+ })), (item.pros.length > 0 || item.cons.length > 0) && /* @__PURE__ */ React.createElement("div", {
581
+ className: "tag-points"
582
+ }, item.pros.map((point, at) => /* @__PURE__ */ React.createElement("span", {
583
+ key: `p${at}`,
584
+ "data-tone": "good"
585
+ }, /* @__PURE__ */ React.createElement(Text, {
586
+ text: point
587
+ }))), item.cons.map((point, at) => /* @__PURE__ */ React.createElement("span", {
588
+ key: `c${at}`,
589
+ "data-tone": "bad"
590
+ }, /* @__PURE__ */ React.createElement(Text, {
591
+ text: point
592
+ }))))), /* @__PURE__ */ React.createElement("button", {
593
+ type: "button",
594
+ className: `ta-button tag-choose${item.recommended && !chosen ? " ta-primary" : ""}`,
595
+ disabled: !closed || chosen !== undefined,
596
+ onClick: () => choose(item.label)
597
+ }, picked && /* @__PURE__ */ React.createElement(Icon, {
598
+ name: "Check",
599
+ size: 13
600
+ }), /* @__PURE__ */ React.createElement("span", null, picked ? words.chosen : words.choose)));
601
+ })));
602
+ }
603
+ const NOTE_ICON = { risk: "CircleAlert", info: "Info", todo: "Square" };
604
+ function Notes({ block: block2 }) {
605
+ return /* @__PURE__ */ React.createElement("ul", {
606
+ className: "tag-notes"
607
+ }, block2.items.map((item, index) => /* @__PURE__ */ React.createElement("li", {
608
+ key: index,
609
+ "data-tone": item.tone
610
+ }, /* @__PURE__ */ React.createElement("span", {
611
+ className: "tag-note-mark"
612
+ }, /* @__PURE__ */ React.createElement(Icon, {
613
+ name: NOTE_ICON[item.tone],
614
+ size: 14
615
+ })), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement(Text, {
616
+ text: item.text
617
+ })))));
618
+ }
619
+ function Next({ block: block2, closed }) {
620
+ return /* @__PURE__ */ React.createElement("div", {
621
+ className: "tag-next"
622
+ }, block2.items.map((item, index) => /* @__PURE__ */ React.createElement("button", {
623
+ key: index,
624
+ type: "button",
625
+ className: "tag-chip",
626
+ disabled: !closed,
627
+ onClick: () => void pi.sendUserMessage(item)
628
+ }, /* @__PURE__ */ React.createElement(Icon, {
629
+ name: "CornerDownRight",
630
+ size: 13
631
+ }), /* @__PURE__ */ React.createElement("span", null, item.replace(/\*\*|`/g, "")))));
632
+ }
633
+ function Details({ block: block2, words }) {
634
+ const [open, setOpen] = React.useState(false);
635
+ return /* @__PURE__ */ React.createElement("div", {
636
+ className: "tag-details"
637
+ }, /* @__PURE__ */ React.createElement("button", {
638
+ type: "button",
639
+ className: "tag-details-toggle",
640
+ "aria-expanded": open,
641
+ onClick: () => setOpen(!open)
642
+ }, /* @__PURE__ */ React.createElement(Icon, {
643
+ name: "ChevronRight",
644
+ size: 14
645
+ }), /* @__PURE__ */ React.createElement("span", null, block2.title ?? words.details)), open && /* @__PURE__ */ React.createElement("div", {
646
+ className: "tag-details-body"
647
+ }, /* @__PURE__ */ React.createElement(Markdown, {
648
+ text: block2.markdown
649
+ })));
650
+ }
651
+ function Part({ block: block2, words, closed }) {
652
+ switch (block2.type) {
653
+ case "stats":
654
+ return /* @__PURE__ */ React.createElement(Stats, {
655
+ block: block2
656
+ });
657
+ case "changes":
658
+ return /* @__PURE__ */ React.createElement(Changes, {
659
+ block: block2,
660
+ words
661
+ });
662
+ case "steps":
663
+ return /* @__PURE__ */ React.createElement(Steps, {
664
+ block: block2
665
+ });
666
+ case "compare":
667
+ return /* @__PURE__ */ React.createElement(Compare, {
668
+ block: block2,
669
+ words
670
+ });
671
+ case "bars":
672
+ return /* @__PURE__ */ React.createElement(Bars, {
673
+ block: block2
674
+ });
675
+ case "flow":
676
+ return /* @__PURE__ */ React.createElement(Flow, {
677
+ block: block2
678
+ });
679
+ case "diagram":
680
+ return closed ? /* @__PURE__ */ React.createElement(Markdown, {
681
+ text: `\`\`\`mermaid
682
+ ${block2.mermaid}
683
+ \`\`\``
684
+ }) : null;
685
+ case "table":
686
+ return /* @__PURE__ */ React.createElement(Table, {
687
+ block: block2
688
+ });
689
+ case "options":
690
+ return /* @__PURE__ */ React.createElement(Options, {
691
+ block: block2,
692
+ words,
693
+ closed
694
+ });
695
+ case "notes":
696
+ return /* @__PURE__ */ React.createElement(Notes, {
697
+ block: block2
698
+ });
699
+ case "next":
700
+ return /* @__PURE__ */ React.createElement(Next, {
701
+ block: block2,
702
+ closed
703
+ });
704
+ case "details":
705
+ return /* @__PURE__ */ React.createElement(Details, {
706
+ block: block2,
707
+ words
708
+ });
709
+ }
710
+ }
711
+ function Head({ card, words }) {
712
+ const status = card.status && words.status[card.status];
713
+ if (!status && !card.title) {
714
+ return null;
715
+ }
716
+ return /* @__PURE__ */ React.createElement("div", {
717
+ className: "tag-head"
718
+ }, status && /* @__PURE__ */ React.createElement("span", {
719
+ className: "tag-status",
720
+ "data-status": card.status
721
+ }, /* @__PURE__ */ React.createElement("i", null), status), card.title && /* @__PURE__ */ React.createElement("span", {
722
+ className: "tag-title"
723
+ }, /* @__PURE__ */ React.createElement(Text, {
724
+ text: card.title
725
+ })));
726
+ }
727
+ return function GlanceCard({ code, closed }) {
728
+ const words = GlanceWords.of(pi.ui.language);
729
+ const card = React.useMemo(() => GlanceSpec.read(GlanceJson.parse(code, !closed), !closed), [code, closed]);
730
+ if (!card) {
731
+ return closed ? /* @__PURE__ */ React.createElement(Markdown, {
732
+ text: `\`\`\`json
733
+ ${code}
734
+ \`\`\``
735
+ }) : /* @__PURE__ */ React.createElement("div", {
736
+ className: "tag-card tag-writing"
737
+ }, /* @__PURE__ */ React.createElement("span", {
738
+ className: "ta-spinner"
739
+ }), /* @__PURE__ */ React.createElement("span", null, words.writing));
740
+ }
741
+ return /* @__PURE__ */ React.createElement("div", {
742
+ className: "tag-card",
743
+ "data-streaming": !closed || undefined
744
+ }, /* @__PURE__ */ React.createElement(Head, {
745
+ card,
746
+ words
747
+ }), card.blocks.map((block2, index) => /* @__PURE__ */ React.createElement("div", {
748
+ key: index,
749
+ className: "tag-part",
750
+ "data-type": block2.type
751
+ }, /* @__PURE__ */ React.createElement(Part, {
752
+ block: block2,
753
+ words,
754
+ closed
755
+ }))));
756
+ };
757
+ }
758
+
759
+ // web-src/glance-protocol.ts
760
+ var LANGUAGE = "ta-glance";
761
+
762
+ // web-src/style.ts
763
+ var STYLE = `
764
+ /*
765
+ * A card of a reply (\`\`\`ta-glance): parts one under another, a hairline between them. Its sizes follow the font
766
+ * scale of the conversation, and its layout the width of the card itself (a container), not the screen's, so that it
767
+ * reads the same in a phone, in the workbench and in a wide window.
768
+ * --tag-x / --tag-y the padding of a part (12 / 10 when narrow); tables and diagrams reach the edges with them
769
+ * --tag-lh the line of body text; marks (kinds, steps, notes) are centred on its first line
770
+ * --tag-mark the size of those marks
771
+ * Radii: the card 12, a box in it 8, a node 6, a letter 4, chips and pills round.
772
+ */
773
+ .tag-card {
774
+ --tag-s: var(--ta-font-scale, 1);
775
+ --tag-x: 14px;
776
+ --tag-y: 12px;
777
+ --tag-text: calc(13px * var(--tag-s));
778
+ --tag-small: calc(12px * var(--tag-s));
779
+ --tag-tiny: calc(11px * var(--tag-s));
780
+ --tag-lh: calc(19.5px * var(--tag-s));
781
+ --tag-mark: calc(16px * var(--tag-s));
782
+ --tag-mark-top: calc((var(--tag-lh) - var(--tag-mark)) / 2);
783
+ --tag-line: var(--ta-border-muted);
784
+ container: tag-card / inline-size;
785
+ position: relative;
786
+ margin: 2px 0 12px;
787
+ border: 1px solid var(--ta-border);
788
+ border-radius: 12px;
789
+ background: var(--ta-card);
790
+ overflow: hidden;
791
+ font-size: var(--tag-text);
792
+ line-height: 1.5;
793
+ color: var(--ta-text);
794
+ overflow-wrap: anywhere;
795
+ text-align: left;
796
+ }
797
+ @container tag-card (max-width: 400px) { .tag-card > * { --tag-x: 12px; --tag-y: 10px; } }
798
+ .tag-card > * + * { border-top: 1px solid var(--tag-line); }
799
+ .tag-card ul, .tag-card ol { margin: 0; padding: 0; list-style: none; }
800
+ .tag-card li { margin: 0; }
801
+ .tag-card button { font-family: inherit; }
802
+ .tag-part { padding: var(--tag-y) var(--tag-x); min-width: 0; }
803
+ .tag-card[data-streaming] > .tag-part:last-child { animation: ta-in 200ms var(--ta-ease, ease) both; }
804
+ .tag-writing { display: flex; align-items: center; gap: 8px; padding: var(--tag-y) var(--tag-x); color: var(--ta-muted); font-size: var(--tag-small); }
805
+ .tag-inline .ta-markdown, .tag-inline .ta-markdown > p { display: inline; margin: 0; }
806
+ .tag-inline .ta-markdown :not(pre) > code { padding: 0 4px; font-size: 0.92em; }
807
+ .tag-num { font-variant-numeric: tabular-nums; }
808
+
809
+ /* The head: how it went, as a pill, and a title beside it that wraps under it when long */
810
+ .tag-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: var(--tag-y) var(--tag-x) 0; }
811
+ .tag-card > .tag-head + .tag-part { border-top: 0; padding-top: 8px; }
812
+ .tag-title { flex: 1 1 14em; min-width: 0; font-weight: 600; font-size: calc(14px * var(--tag-s)); line-height: 1.45; color: var(--ta-text); }
813
+ .tag-status { --tag-tone: var(--ta-muted); flex: none; display: inline-flex; align-items: center; gap: 6px; height: calc(22px * var(--tag-s)); padding: 0 9px; border-radius: 999px; font-size: var(--tag-small); font-weight: 600; line-height: 1; white-space: nowrap; color: var(--tag-tone); background: color-mix(in srgb, var(--tag-tone) 12%, transparent); }
814
+ .tag-status i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
815
+ .tag-status[data-status='done'] { --tag-tone: var(--ta-green); }
816
+ .tag-status[data-status='partial'], .tag-status[data-status='blocked'] { --tag-tone: var(--ta-yellow); }
817
+ .tag-status[data-status='failed'] { --tag-tone: var(--ta-red); }
818
+
819
+ /* What a part is about, in small muted type above it */
820
+ .tag-section-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 6px; color: var(--ta-muted); font-size: var(--tag-small); line-height: 1.4; }
821
+ .tag-section-head > span { display: inline-flex; align-items: center; gap: 5px; }
822
+ .tag-add { color: var(--ta-green); font-variant-numeric: tabular-nums; }
823
+ .tag-del { color: var(--ta-red); font-variant-numeric: tabular-nums; }
824
+ .tag-delta { margin-left: 6px; font-size: var(--tag-small); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ta-muted); }
825
+ .tag-delta[data-tone='good'], [data-tone='good'] > .tag-stat-label > .tag-delta { color: var(--ta-green); }
826
+ .tag-delta[data-tone='bad'], [data-tone='bad'] > .tag-stat-label > .tag-delta { color: var(--ta-red); }
827
+ [data-tone='warn'] > .tag-stat-label > .tag-delta { color: var(--ta-yellow); }
828
+
829
+ /* Key numbers: large, their names under them; as many in a row as the card holds well */
830
+ .tag-stats { --tag-columns: 3; display: grid; grid-template-columns: repeat(var(--tag-columns), minmax(0, 1fr)); gap: 8px; }
831
+ .tag-stats[data-count='1'] { --tag-columns: 1; }
832
+ .tag-stats[data-count='2'], .tag-stats[data-count='4'] { --tag-columns: 2; }
833
+ @container tag-card (min-width: 480px) { .tag-stats[data-count='4'] { --tag-columns: 4; } }
834
+ @container tag-card (min-width: 640px) { .tag-stats[data-count='5'] { --tag-columns: 5; } }
835
+ @container tag-card (max-width: 400px) { .tag-stats[data-count='5'], .tag-stats[data-count='6'] { --tag-columns: 2; } .tag-stats { gap: 6px; } .tag-stat { padding: 8px 10px; } }
836
+ @container tag-card (max-width: 300px) { .tag-stats[data-count='3'] { --tag-columns: 2; } }
837
+ .tag-stat { min-width: 0; padding: 10px 12px; border-radius: 8px; background: var(--ta-raised); }
838
+ .tag-stat-value { font-size: calc(20px * var(--tag-s)); font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; color: var(--ta-text); }
839
+ @container tag-card (max-width: 400px) { .tag-stat-value { font-size: calc(18px * var(--tag-s)); } }
840
+ .tag-stat-label { margin-top: 2px; color: var(--ta-muted); font-size: var(--tag-small); line-height: 1.4; }
841
+ .tag-tone-dot { display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; vertical-align: 0.1em; background: var(--ta-muted); }
842
+ [data-tone='good'] > .tag-stat-label > .tag-tone-dot { background: var(--ta-green); }
843
+ [data-tone='bad'] > .tag-stat-label > .tag-tone-dot { background: var(--ta-red); }
844
+ [data-tone='warn'] > .tag-stat-label > .tag-tone-dot { background: var(--ta-yellow); }
845
+
846
+ /* Rows with a mark: the mark on the first line of the text, whatever the font size */
847
+ .tag-change, .tag-step, .tag-notes li { padding: 3px 0; }
848
+ .tag-kind, .tag-step-mark, .tag-note-mark { flex: none; box-sizing: border-box; width: var(--tag-mark); height: var(--tag-mark); margin-top: var(--tag-mark-top); }
849
+
850
+ /* Files: a letter of what happened, the name and its folder, the lines, the squares of a forge */
851
+ .tag-change { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; column-gap: 8px; }
852
+ .tag-kind { display: inline-grid; place-items: center; border-radius: 4px; font: 600 calc(10px * var(--tag-s)) / 1 var(--ta-mono, ui-monospace, monospace); color: var(--ta-blue); background: color-mix(in srgb, currentColor 14%, transparent); }
853
+ .tag-kind[data-kind='add'] { color: var(--ta-green); }
854
+ .tag-kind[data-kind='delete'] { color: var(--ta-red); }
855
+ .tag-change-path { min-width: 0; }
856
+ .tag-change-file { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; min-width: 0; line-height: var(--tag-lh); }
857
+ .tag-change-name { flex: 0 1 auto; max-width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
858
+ .tag-change-name .ta-markdown :is(a, .ta-link-path) { color: var(--ta-text); }
859
+ .tag-change-name :is(a, button) { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: top; }
860
+ .tag-change-dir { flex: 1 1 7em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; color: var(--ta-muted); font-size: var(--tag-small); line-height: 1.4; }
861
+ .tag-change-dir bdi { direction: ltr; unicode-bidi: isolate; }
862
+ .tag-change-note { margin-top: 1px; color: var(--ta-muted); font-size: var(--tag-small); line-height: 1.45; }
863
+ .tag-change-count { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; height: var(--tag-lh); font-size: var(--tag-small); white-space: nowrap; }
864
+ .tag-squares { display: inline-flex; gap: 2px; }
865
+ .tag-squares i { width: calc(7px * var(--tag-s)); height: calc(7px * var(--tag-s)); border-radius: 1.5px; background: var(--ta-border); }
866
+ .tag-squares i[data-kind='add'] { background: var(--ta-green); }
867
+ .tag-squares i[data-kind='del'] { background: var(--ta-red); }
868
+ @container tag-card (max-width: 400px) { .tag-squares { display: none; } }
869
+
870
+ /* Steps: marks on a thread; the thread is green where the steps are done */
871
+ .tag-step { position: relative; display: flex; gap: 10px; }
872
+ .tag-step:not(:last-child)::after { content: ''; position: absolute; left: calc(var(--tag-mark) / 2 - 0.5px); width: 1px; top: calc(3px + var(--tag-mark-top) + var(--tag-mark) + 2px); bottom: calc(2px - 3px - var(--tag-mark-top)); background: var(--ta-border); }
873
+ .tag-step[data-status='done']:not(:last-child)::after { background: color-mix(in srgb, var(--ta-green) 45%, var(--ta-border)); }
874
+ .tag-step-mark { display: inline-grid; place-items: center; border-radius: 50%; border: 1.5px solid var(--ta-border-field); color: var(--ta-card); }
875
+ .tag-step-mark svg { width: calc(10px * var(--tag-s)); height: calc(10px * var(--tag-s)); stroke-width: 3; }
876
+ .tag-step[data-status='done'] .tag-step-mark { border: 0; background: var(--ta-green); }
877
+ .tag-step[data-status='failed'] .tag-step-mark { border: 0; background: var(--ta-red); }
878
+ .tag-step[data-status='skipped'] .tag-step-mark { border-style: dashed; color: var(--ta-muted); }
879
+ .tag-step[data-status='doing'] .tag-step-mark { border-color: var(--ta-blue); border-top-color: transparent; animation: ta-spin 1s linear infinite; }
880
+ .tag-step-text { flex: 1; min-width: 0; }
881
+ .tag-step[data-status='doing'] .tag-step-text { font-weight: 500; }
882
+ .tag-step[data-status='todo'] .tag-step-text, .tag-step[data-status='skipped'] .tag-step-text { color: var(--ta-muted); }
883
+ .tag-step[data-status='skipped'] .tag-step-text { text-decoration: line-through; text-decoration-color: color-mix(in srgb, currentColor 60%, transparent); }
884
+
885
+ /* Before and after: a measure, its numbers, two bars */
886
+ .tag-legend i { display: inline-block; width: 10px; height: 6px; border-radius: 3px; }
887
+ .tag-measure + .tag-measure { margin-top: 10px; }
888
+ .tag-measure-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 12px; }
889
+ .tag-measure-label { flex: 1 1 auto; min-width: 0; }
890
+ .tag-measure-value { margin-left: auto; color: var(--ta-muted); font-size: var(--tag-small); white-space: nowrap; font-variant-numeric: tabular-nums; }
891
+ .tag-measure-value b { color: var(--ta-text); font-weight: 600; }
892
+ .tag-measure .tag-track { height: 5px; background: none; }
893
+ .tag-measure .tag-track + .tag-track { margin-top: 3px; }
894
+ .tag-measure-head + .tag-track { margin-top: 5px; }
895
+ .tag-track { display: block; height: 6px; border-radius: 3px; background: var(--ta-hover); overflow: hidden; }
896
+ .tag-track i { display: block; height: 100%; min-width: 0; border-radius: inherit; background: var(--ta-accent); transition: width 0.4s var(--ta-ease, ease); }
897
+ .tag-track i[data-bar='before'], .tag-legend i[data-bar='before'] { background: var(--ta-border-field); }
898
+ .tag-legend i[data-bar='after'], .tag-track i[data-bar='after'][data-tone='good'] { background: var(--ta-green); }
899
+ .tag-track i[data-bar='after'][data-tone='bad'] { background: var(--ta-red); }
900
+ .tag-track i[data-bar='after'][data-tone='neutral'] { background: var(--ta-secondary); }
901
+
902
+ /* Amounts side by side: label, bar, value in a row; when narrow, the bar under its label and value */
903
+ .tag-bars { display: grid; grid-template-columns: minmax(0, max-content) minmax(64px, 1fr) auto; align-items: center; gap: 8px 12px; }
904
+ .tag-bar { display: contents; }
905
+ .tag-bar-label { min-width: 0; max-width: 16em; line-height: 1.4; }
906
+ .tag-bar .tag-track { height: 6px; }
907
+ .tag-bar .tag-track i { background: var(--ta-blue); }
908
+ .tag-bar-value { text-align: right; color: var(--ta-muted); font-size: var(--tag-small); white-space: nowrap; font-variant-numeric: tabular-nums; }
909
+ @container tag-card (max-width: 400px) {
910
+ .tag-bars { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
911
+ .tag-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 5px 12px; }
912
+ .tag-bar-label { max-width: none; grid-area: 1 / 1; }
913
+ .tag-bar-value { grid-area: 1 / 2; }
914
+ .tag-bar .tag-track { grid-area: 2 / 1 / 3 / 3; }
915
+ }
916
+
917
+ /* A path: nodes and arrows; an arrow keeps to the node after it, so that no line ends with one */
918
+ .tag-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 6px; }
919
+ .tag-flow-step { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-width: 0; }
920
+ .tag-flow-node { min-width: 0; padding: 2px 10px; border: 1px solid var(--ta-border); border-radius: 6px; background: var(--ta-raised); line-height: var(--tag-lh); }
921
+ .tag-flow-arrow { flex: none; display: inline-flex; color: var(--ta-muted); }
922
+ .tag-flow-arrow svg { width: calc(13px * var(--tag-s)); height: calc(13px * var(--tag-s)); }
923
+
924
+ /* A table and a diagram reach the edges of the card, their columns lined up with the text above */
925
+ .tag-card > .tag-part[data-type='table'], .tag-card > .tag-part[data-type='diagram'] { padding: 0; }
926
+ .tag-card .tag-table { margin: 0; border: 0; border-radius: 0; }
927
+ .tag-card .tag-table table { font-size: var(--tag-text); }
928
+ .tag-card .tag-table th, .tag-card .tag-table td { padding: 7px 10px; }
929
+ .tag-card .tag-table th:first-child, .tag-card .tag-table td:first-child { padding-left: var(--tag-x); }
930
+ .tag-card .tag-table th:last-child, .tag-card .tag-table td:last-child { padding-right: var(--tag-x); }
931
+ .tag-card .tag-table th { font-size: var(--tag-small); color: var(--ta-secondary); }
932
+ .tag-card .ta-mermaid { margin: 0; border: 0; border-radius: 0; background: transparent; }
933
+ .tag-card .ta-mermaid .ta-code-bar { padding-left: var(--tag-x); padding-right: calc(var(--tag-x) - 4px); }
934
+ .tag-card .ta-markdown:has(> .ta-mermaid) { margin: 0; }
935
+
936
+ /* Choices: a box each, a button that answers; when narrow, the button under its choice */
937
+ .tag-question { margin-bottom: 8px; font-weight: 600; }
938
+ .tag-options { display: flex; flex-direction: column; gap: 8px; }
939
+ .tag-option { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--ta-border); border-radius: 8px; transition: opacity 0.2s, border-color 0.2s, box-shadow 0.2s; }
940
+ .tag-option-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
941
+ .tag-option[data-recommended] { border-color: color-mix(in srgb, var(--ta-green) 50%, var(--ta-border)); background: color-mix(in srgb, var(--ta-green) 4%, transparent); }
942
+ .tag-option[data-chosen] { border-color: var(--ta-green); box-shadow: 0 0 0 1px var(--ta-green) inset; }
943
+ .tag-option[data-other] { opacity: 0.5; }
944
+ .tag-option-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; }
945
+ .tag-option-label { font-weight: 600; }
946
+ .tag-badge { flex: none; padding: 0 6px; border-radius: 999px; font-size: var(--tag-tiny); line-height: calc(18px * var(--tag-s)); font-weight: 600; white-space: nowrap; color: var(--ta-green); background: color-mix(in srgb, var(--ta-green) 13%, transparent); }
947
+ .tag-option-detail { color: var(--ta-secondary); font-size: var(--tag-small); line-height: 1.45; }
948
+ .tag-points { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 2px; font-size: var(--tag-small); line-height: 1.45; color: var(--ta-secondary); }
949
+ .tag-points span::before { margin-right: 3px; font-weight: 700; }
950
+ .tag-points span[data-tone='good']::before { content: '+'; color: var(--ta-green); }
951
+ .tag-points span[data-tone='bad']::before { content: '−'; color: var(--ta-red); }
952
+ .tag-choose { flex: none; display: inline-flex; align-items: center; gap: 4px; }
953
+ @container tag-card (max-width: 400px) {
954
+ .tag-option { flex-direction: column; align-items: stretch; gap: 10px; }
955
+ .tag-choose { width: 100%; }
956
+ }
957
+
958
+ /* Risks, notes, what to do */
959
+ .tag-notes li { display: flex; gap: 8px; }
960
+ .tag-notes li > span:last-child { flex: 1; min-width: 0; }
961
+ .tag-note-mark { display: inline-grid; place-items: center; color: var(--ta-muted); }
962
+ .tag-note-mark svg { width: calc(14px * var(--tag-s)); height: calc(14px * var(--tag-s)); }
963
+ .tag-notes li[data-tone='risk'] .tag-note-mark { color: var(--ta-yellow); }
964
+ .tag-notes li[data-tone='todo'] .tag-note-mark { color: var(--ta-blue); }
965
+
966
+ /* What to ask next: chips that send it */
967
+ .tag-next { display: flex; flex-wrap: wrap; gap: 6px; }
968
+ .tag-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: calc(28px * var(--tag-s)); padding: 3px 12px 3px 10px; border: 1px solid var(--ta-border); border-radius: 999px; background: transparent; color: var(--ta-text); font-size: var(--tag-small); line-height: 1.4; cursor: pointer; text-align: left; transition: background 120ms, border-color 120ms; }
969
+ .tag-chip svg { flex: none; width: calc(13px * var(--tag-s)); height: calc(13px * var(--tag-s)); color: var(--ta-muted); }
970
+ .tag-chip:disabled { opacity: 0.5; cursor: default; }
971
+ .tag-part[data-type='next'] { padding-top: calc(var(--tag-y) - 2px); padding-bottom: calc(var(--tag-y) - 2px); }
972
+
973
+ /* Details, folded */
974
+ .tag-part[data-type='details'] { padding-top: 8px; padding-bottom: 8px; }
975
+ .tag-details-toggle { display: inline-flex; align-items: center; gap: 4px; min-height: calc(24px * var(--tag-s)); margin-left: -4px; padding: 0 6px 0 4px; border: 0; border-radius: 6px; background: none; color: var(--ta-muted); font-size: var(--tag-small); cursor: pointer; transition: color 120ms, background 120ms; }
976
+ .tag-details-toggle svg { width: calc(14px * var(--tag-s)); height: calc(14px * var(--tag-s)); transition: transform 150ms var(--ta-ease, ease); }
977
+ .tag-details-toggle[aria-expanded='true'] svg { transform: rotate(90deg); }
978
+ .tag-details-body { margin-top: 4px; padding-bottom: 4px; font-size: var(--tag-text); color: var(--ta-body); animation: ta-in 180ms var(--ta-ease, ease); }
979
+ .tag-details-body .ta-markdown > :last-child { margin-bottom: 0; }
980
+
981
+ @media (hover: hover) {
982
+ .tag-chip:hover:not(:disabled) { background: var(--ta-hover); border-color: var(--ta-border-field); }
983
+ .tag-details-toggle:hover { color: var(--ta-text); background: var(--ta-hover); }
984
+ }
985
+
986
+ /* Touch: what is tapped is a finger high */
987
+ [data-touch] .tag-chip { min-height: 36px; padding-top: 6px; padding-bottom: 6px; }
988
+ [data-touch] .tag-choose { height: 36px; }
989
+ [data-touch] .tag-details-toggle { min-height: 32px; }
990
+ `;
991
+ function injectStyle() {
992
+ const element = document.createElement("style");
993
+ element.dataset.taPackage = "ta-glance";
994
+ element.textContent = STYLE;
995
+ document.head.appendChild(element);
996
+ return () => element.remove();
997
+ }
998
+
999
+ // web-src/index.tsx
1000
+ function activate(pi) {
1001
+ bind(pi.React);
1002
+ if (!pi.registerCodeRenderer) {
1003
+ return () => {
1004
+ return;
1005
+ };
1006
+ }
1007
+ const removeStyle = injectStyle();
1008
+ pi.registerCodeRenderer(LANGUAGE, glanceCard(pi));
1009
+ return removeStyle;
1010
+ }
1011
+ export {
1012
+ activate as default
1013
+ };