@celljs/ta-glance 0.0.0-stage → 4.11.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.11.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.11.0",
30
+ "@celljs/ta-web": "4.11.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,933 @@
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) {
145
+ const value = object(item);
146
+ const shown = text(value?.text ?? value?.label ?? item);
147
+ return shown ? { text: shown, status: oneOf(value?.status, STEPS) ?? "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) {
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, step);
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) {
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, block).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
+ }, /* @__PURE__ */ React.createElement(Text, {
359
+ text: item.label
360
+ }), item.delta && /* @__PURE__ */ React.createElement("span", {
361
+ className: "tag-delta"
362
+ }, item.delta)))));
363
+ }
364
+ function Squares({ change: change2, largest }) {
365
+ const add = change2.add ?? 0;
366
+ const del = change2.del ?? 0;
367
+ const total = add + del;
368
+ if (!total) {
369
+ return null;
370
+ }
371
+ const filled = Math.max(1, Math.round(Math.min(total, largest) / largest * SQUARES));
372
+ const green = Math.round(add / total * filled);
373
+ return /* @__PURE__ */ React.createElement("span", {
374
+ className: "tag-squares",
375
+ "aria-hidden": "true"
376
+ }, Array.from({ length: SQUARES }, (_, index) => /* @__PURE__ */ React.createElement("i", {
377
+ key: index,
378
+ "data-kind": index < green ? "add" : index < filled ? "del" : undefined
379
+ })));
380
+ }
381
+ function Changes({ block: block2, words }) {
382
+ const add = block2.items.reduce((sum, item) => sum + (item.add ?? 0), 0);
383
+ const del = block2.items.reduce((sum, item) => sum + (item.del ?? 0), 0);
384
+ const largest = Math.max(LINES, ...block2.items.map((item) => (item.add ?? 0) + (item.del ?? 0)));
385
+ return /* @__PURE__ */ React.createElement("div", {
386
+ className: "tag-changes"
387
+ }, /* @__PURE__ */ React.createElement("div", {
388
+ className: "tag-section-head"
389
+ }, /* @__PURE__ */ React.createElement("span", null, GlanceWords.format(words.files, { count: block2.items.length })), add > 0 && /* @__PURE__ */ React.createElement("span", {
390
+ className: "tag-add"
391
+ }, "+", add), del > 0 && /* @__PURE__ */ React.createElement("span", {
392
+ className: "tag-del"
393
+ }, "−", del)), block2.items.map((item, index) => /* @__PURE__ */ React.createElement("div", {
394
+ key: index,
395
+ className: "tag-change"
396
+ }, /* @__PURE__ */ React.createElement("span", {
397
+ className: "tag-kind",
398
+ "data-kind": item.kind
399
+ }, item.kind === "add" ? "A" : item.kind === "delete" ? "D" : "M"), /* @__PURE__ */ React.createElement("span", {
400
+ className: "tag-change-path"
401
+ }, /* @__PURE__ */ React.createElement("span", {
402
+ className: "tag-change-file"
403
+ }, /* @__PURE__ */ React.createElement("span", {
404
+ className: "tag-change-name"
405
+ }, /* @__PURE__ */ React.createElement(Text, {
406
+ text: `[${fileName(item.path)}](<${item.path}>)`
407
+ })), directory(item.path) && /* @__PURE__ */ React.createElement("span", {
408
+ className: "tag-change-dir",
409
+ title: item.path
410
+ }, /* @__PURE__ */ React.createElement("bdi", null, directory(item.path)))), item.note && /* @__PURE__ */ React.createElement("span", {
411
+ className: "tag-change-note"
412
+ }, /* @__PURE__ */ React.createElement(Text, {
413
+ text: item.note
414
+ }))), /* @__PURE__ */ React.createElement("span", {
415
+ className: "tag-change-count"
416
+ }, item.add ? /* @__PURE__ */ React.createElement("span", {
417
+ className: "tag-add"
418
+ }, "+", item.add) : null, item.del ? /* @__PURE__ */ React.createElement("span", {
419
+ className: "tag-del"
420
+ }, "−", item.del) : null, /* @__PURE__ */ React.createElement(Squares, {
421
+ change: item,
422
+ largest
423
+ })))));
424
+ }
425
+ const STEP_ICON = { done: "Check", failed: "X", skipped: "Minus", doing: undefined, todo: undefined };
426
+ function Steps({ block: block2 }) {
427
+ return /* @__PURE__ */ React.createElement("ol", {
428
+ className: "tag-steps"
429
+ }, block2.items.map((item, index) => /* @__PURE__ */ React.createElement("li", {
430
+ key: index,
431
+ className: "tag-step",
432
+ "data-status": item.status
433
+ }, /* @__PURE__ */ React.createElement("span", {
434
+ className: "tag-step-mark"
435
+ }, STEP_ICON[item.status] && /* @__PURE__ */ React.createElement(Icon, {
436
+ name: STEP_ICON[item.status],
437
+ size: 11
438
+ })), /* @__PURE__ */ React.createElement("span", {
439
+ className: "tag-step-text"
440
+ }, /* @__PURE__ */ React.createElement(Text, {
441
+ text: item.text
442
+ })))));
443
+ }
444
+ function Compare({ block: block2, words }) {
445
+ const largest = Math.max(...block2.items.flatMap((item) => [Math.abs(item.before), Math.abs(item.after)]), 0) || 1;
446
+ const unit = block2.unit ? ` ${block2.unit}` : "";
447
+ return /* @__PURE__ */ React.createElement("div", {
448
+ className: "tag-compare"
449
+ }, /* @__PURE__ */ React.createElement("div", {
450
+ className: "tag-legend"
451
+ }, /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("i", {
452
+ "data-bar": "before"
453
+ }), words.before), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("i", {
454
+ "data-bar": "after"
455
+ }), words.after)), block2.items.map((item, index) => {
456
+ const better = block2.better === "higher" ? item.after > item.before : item.after < item.before;
457
+ const tone = item.after === item.before ? "neutral" : better ? "good" : "bad";
458
+ return /* @__PURE__ */ React.createElement("div", {
459
+ key: index,
460
+ className: "tag-measure"
461
+ }, /* @__PURE__ */ React.createElement("div", {
462
+ className: "tag-measure-head"
463
+ }, /* @__PURE__ */ React.createElement("span", {
464
+ className: "tag-measure-label"
465
+ }, /* @__PURE__ */ React.createElement(Text, {
466
+ text: item.label
467
+ })), /* @__PURE__ */ React.createElement("span", {
468
+ className: "tag-measure-value"
469
+ }, count(item.before), " → ", /* @__PURE__ */ React.createElement("b", null, count(item.after)), unit, percent(item.before, item.after) && /* @__PURE__ */ React.createElement("span", {
470
+ className: "tag-delta",
471
+ "data-tone": tone
472
+ }, percent(item.before, item.after)))), /* @__PURE__ */ React.createElement("div", {
473
+ className: "tag-track"
474
+ }, /* @__PURE__ */ React.createElement("i", {
475
+ "data-bar": "before",
476
+ style: { width: `${Math.abs(item.before) / largest * 100}%` }
477
+ })), /* @__PURE__ */ React.createElement("div", {
478
+ className: "tag-track"
479
+ }, /* @__PURE__ */ React.createElement("i", {
480
+ "data-bar": "after",
481
+ "data-tone": tone,
482
+ style: { width: `${Math.abs(item.after) / largest * 100}%` }
483
+ })));
484
+ }));
485
+ }
486
+ function Bars({ block: block2 }) {
487
+ const largest = Math.max(...block2.items.map((item) => Math.abs(item.value)), 0) || 1;
488
+ const unit = block2.unit ? ` ${block2.unit}` : "";
489
+ return /* @__PURE__ */ React.createElement("div", {
490
+ className: "tag-bars"
491
+ }, block2.items.map((item, index) => /* @__PURE__ */ React.createElement("div", {
492
+ key: index,
493
+ className: "tag-bar"
494
+ }, /* @__PURE__ */ React.createElement("span", {
495
+ className: "tag-bar-label"
496
+ }, /* @__PURE__ */ React.createElement(Text, {
497
+ text: item.label
498
+ })), /* @__PURE__ */ React.createElement("span", {
499
+ className: "tag-track"
500
+ }, /* @__PURE__ */ React.createElement("i", {
501
+ style: { width: `${Math.abs(item.value) / largest * 100}%` }
502
+ })), /* @__PURE__ */ React.createElement("span", {
503
+ className: "tag-bar-value"
504
+ }, count(item.value), unit))));
505
+ }
506
+ function Flow({ block: block2 }) {
507
+ return /* @__PURE__ */ React.createElement("div", {
508
+ className: "tag-flow"
509
+ }, block2.items.map((item, index) => /* @__PURE__ */ React.createElement(React.Fragment, {
510
+ key: index
511
+ }, index > 0 && /* @__PURE__ */ React.createElement("span", {
512
+ className: "tag-flow-arrow",
513
+ "aria-hidden": "true"
514
+ }, /* @__PURE__ */ React.createElement(Icon, {
515
+ name: "ArrowRight",
516
+ size: 13
517
+ })), /* @__PURE__ */ React.createElement("span", {
518
+ className: "tag-flow-node"
519
+ }, /* @__PURE__ */ React.createElement(Text, {
520
+ text: item
521
+ })))));
522
+ }
523
+ function Table({ block: block2 }) {
524
+ return /* @__PURE__ */ React.createElement("div", {
525
+ className: "ta-table tag-table"
526
+ }, /* @__PURE__ */ React.createElement("table", null, /* @__PURE__ */ React.createElement("thead", null, /* @__PURE__ */ React.createElement("tr", null, block2.columns.map((column, index) => /* @__PURE__ */ React.createElement("th", {
527
+ key: index
528
+ }, /* @__PURE__ */ React.createElement(Text, {
529
+ text: column
530
+ }))))), /* @__PURE__ */ React.createElement("tbody", null, block2.rows.map((row, index) => /* @__PURE__ */ React.createElement("tr", {
531
+ key: index
532
+ }, row.map((cell, column) => /* @__PURE__ */ React.createElement("td", {
533
+ key: column
534
+ }, /* @__PURE__ */ React.createElement(Text, {
535
+ text: cell
536
+ }))))))));
537
+ }
538
+ function Options({ block: block2, words, closed }) {
539
+ const [chosen, setChosen] = React.useState();
540
+ const choose = (label) => {
541
+ setChosen(label);
542
+ pi.sendUserMessage(GlanceWords.format(words.pick, { label })).catch((error) => {
543
+ setChosen(undefined);
544
+ pi.ui.notify(error instanceof Error ? error.message : String(error), "error");
545
+ });
546
+ };
547
+ return /* @__PURE__ */ React.createElement("div", {
548
+ className: "tag-options-block"
549
+ }, block2.question && /* @__PURE__ */ React.createElement("div", {
550
+ className: "tag-question"
551
+ }, /* @__PURE__ */ React.createElement(Text, {
552
+ text: block2.question
553
+ })), /* @__PURE__ */ React.createElement("div", {
554
+ className: "tag-options"
555
+ }, block2.items.map((item, index) => {
556
+ const picked = chosen === item.label;
557
+ return /* @__PURE__ */ React.createElement("div", {
558
+ key: index,
559
+ className: "tag-option",
560
+ "data-recommended": item.recommended || undefined,
561
+ "data-chosen": picked || undefined,
562
+ "data-other": chosen && !picked || undefined
563
+ }, /* @__PURE__ */ React.createElement("div", {
564
+ className: "tag-option-main"
565
+ }, /* @__PURE__ */ React.createElement("div", {
566
+ className: "tag-option-head"
567
+ }, /* @__PURE__ */ React.createElement("span", {
568
+ className: "tag-option-label"
569
+ }, /* @__PURE__ */ React.createElement(Text, {
570
+ text: item.label
571
+ })), item.recommended && /* @__PURE__ */ React.createElement("span", {
572
+ className: "tag-badge"
573
+ }, words.recommended)), item.detail && /* @__PURE__ */ React.createElement("div", {
574
+ className: "tag-option-detail"
575
+ }, /* @__PURE__ */ React.createElement(Text, {
576
+ text: item.detail
577
+ })), (item.pros.length > 0 || item.cons.length > 0) && /* @__PURE__ */ React.createElement("div", {
578
+ className: "tag-points"
579
+ }, item.pros.map((point, at) => /* @__PURE__ */ React.createElement("span", {
580
+ key: `p${at}`,
581
+ "data-tone": "good"
582
+ }, /* @__PURE__ */ React.createElement(Text, {
583
+ text: point
584
+ }))), item.cons.map((point, at) => /* @__PURE__ */ React.createElement("span", {
585
+ key: `c${at}`,
586
+ "data-tone": "bad"
587
+ }, /* @__PURE__ */ React.createElement(Text, {
588
+ text: point
589
+ }))))), /* @__PURE__ */ React.createElement("button", {
590
+ type: "button",
591
+ className: `ta-button tag-choose${item.recommended && !chosen ? " ta-primary" : ""}`,
592
+ disabled: !closed || chosen !== undefined,
593
+ onClick: () => choose(item.label)
594
+ }, picked && /* @__PURE__ */ React.createElement(Icon, {
595
+ name: "Check",
596
+ size: 13
597
+ }), /* @__PURE__ */ React.createElement("span", null, picked ? words.chosen : words.choose)));
598
+ })));
599
+ }
600
+ const NOTE_ICON = { risk: "CircleAlert", info: "Info", todo: "Square" };
601
+ function Notes({ block: block2 }) {
602
+ return /* @__PURE__ */ React.createElement("ul", {
603
+ className: "tag-notes"
604
+ }, block2.items.map((item, index) => /* @__PURE__ */ React.createElement("li", {
605
+ key: index,
606
+ "data-tone": item.tone
607
+ }, /* @__PURE__ */ React.createElement("span", {
608
+ className: "tag-note-mark"
609
+ }, /* @__PURE__ */ React.createElement(Icon, {
610
+ name: NOTE_ICON[item.tone],
611
+ size: 14
612
+ })), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement(Text, {
613
+ text: item.text
614
+ })))));
615
+ }
616
+ function Next({ block: block2, closed }) {
617
+ return /* @__PURE__ */ React.createElement("div", {
618
+ className: "tag-next"
619
+ }, block2.items.map((item, index) => /* @__PURE__ */ React.createElement("button", {
620
+ key: index,
621
+ type: "button",
622
+ className: "tag-chip",
623
+ disabled: !closed,
624
+ onClick: () => void pi.sendUserMessage(item)
625
+ }, /* @__PURE__ */ React.createElement(Icon, {
626
+ name: "CornerDownRight",
627
+ size: 13
628
+ }), /* @__PURE__ */ React.createElement("span", null, item.replace(/\*\*|`/g, "")))));
629
+ }
630
+ function Details({ block: block2, words }) {
631
+ const [open, setOpen] = React.useState(false);
632
+ return /* @__PURE__ */ React.createElement("div", {
633
+ className: "tag-details"
634
+ }, /* @__PURE__ */ React.createElement("button", {
635
+ type: "button",
636
+ className: "tag-details-toggle",
637
+ "aria-expanded": open,
638
+ onClick: () => setOpen(!open)
639
+ }, /* @__PURE__ */ React.createElement(Icon, {
640
+ name: open ? "ChevronDown" : "ChevronRight",
641
+ size: 14
642
+ }), /* @__PURE__ */ React.createElement("span", null, block2.title ?? words.details)), open && /* @__PURE__ */ React.createElement("div", {
643
+ className: "tag-details-body"
644
+ }, /* @__PURE__ */ React.createElement(Markdown, {
645
+ text: block2.markdown
646
+ })));
647
+ }
648
+ function Part({ block: block2, words, closed }) {
649
+ switch (block2.type) {
650
+ case "stats":
651
+ return /* @__PURE__ */ React.createElement(Stats, {
652
+ block: block2
653
+ });
654
+ case "changes":
655
+ return /* @__PURE__ */ React.createElement(Changes, {
656
+ block: block2,
657
+ words
658
+ });
659
+ case "steps":
660
+ return /* @__PURE__ */ React.createElement(Steps, {
661
+ block: block2
662
+ });
663
+ case "compare":
664
+ return /* @__PURE__ */ React.createElement(Compare, {
665
+ block: block2,
666
+ words
667
+ });
668
+ case "bars":
669
+ return /* @__PURE__ */ React.createElement(Bars, {
670
+ block: block2
671
+ });
672
+ case "flow":
673
+ return /* @__PURE__ */ React.createElement(Flow, {
674
+ block: block2
675
+ });
676
+ case "diagram":
677
+ return closed ? /* @__PURE__ */ React.createElement(Markdown, {
678
+ text: `\`\`\`mermaid
679
+ ${block2.mermaid}
680
+ \`\`\``
681
+ }) : null;
682
+ case "table":
683
+ return /* @__PURE__ */ React.createElement(Table, {
684
+ block: block2
685
+ });
686
+ case "options":
687
+ return /* @__PURE__ */ React.createElement(Options, {
688
+ block: block2,
689
+ words,
690
+ closed
691
+ });
692
+ case "notes":
693
+ return /* @__PURE__ */ React.createElement(Notes, {
694
+ block: block2
695
+ });
696
+ case "next":
697
+ return /* @__PURE__ */ React.createElement(Next, {
698
+ block: block2,
699
+ closed
700
+ });
701
+ case "details":
702
+ return /* @__PURE__ */ React.createElement(Details, {
703
+ block: block2,
704
+ words
705
+ });
706
+ }
707
+ }
708
+ function Head({ card, words }) {
709
+ const status = card.status && words.status[card.status];
710
+ if (!status && !card.title) {
711
+ return null;
712
+ }
713
+ return /* @__PURE__ */ React.createElement("div", {
714
+ className: "tag-head"
715
+ }, status && /* @__PURE__ */ React.createElement("span", {
716
+ className: "tag-status",
717
+ "data-status": card.status
718
+ }, /* @__PURE__ */ React.createElement("i", null), status), card.title && /* @__PURE__ */ React.createElement("span", {
719
+ className: "tag-title"
720
+ }, /* @__PURE__ */ React.createElement(Text, {
721
+ text: card.title
722
+ })));
723
+ }
724
+ return function GlanceCard({ code, closed }) {
725
+ const words = GlanceWords.of(pi.ui.language);
726
+ const card = React.useMemo(() => GlanceSpec.read(GlanceJson.parse(code, !closed)), [code, closed]);
727
+ if (!card) {
728
+ return closed ? /* @__PURE__ */ React.createElement(Markdown, {
729
+ text: `\`\`\`json
730
+ ${code}
731
+ \`\`\``
732
+ }) : /* @__PURE__ */ React.createElement("div", {
733
+ className: "tag-card tag-writing"
734
+ }, /* @__PURE__ */ React.createElement("span", {
735
+ className: "ta-spinner"
736
+ }), /* @__PURE__ */ React.createElement("span", null, words.writing));
737
+ }
738
+ return /* @__PURE__ */ React.createElement("div", {
739
+ className: "tag-card",
740
+ "data-streaming": !closed || undefined
741
+ }, /* @__PURE__ */ React.createElement(Head, {
742
+ card,
743
+ words
744
+ }), card.blocks.map((block2, index) => /* @__PURE__ */ React.createElement("div", {
745
+ key: index,
746
+ className: "tag-part",
747
+ "data-type": block2.type
748
+ }, /* @__PURE__ */ React.createElement(Part, {
749
+ block: block2,
750
+ words,
751
+ closed
752
+ }))));
753
+ };
754
+ }
755
+
756
+ // web-src/glance-protocol.ts
757
+ var LANGUAGE = "ta-glance";
758
+
759
+ // web-src/style.ts
760
+ var STYLE = `
761
+ /* A card of a reply (\`\`\`ta-glance): parts one under another, a hairline between them */
762
+ .tag-card { container-type: inline-size; margin: 6px 0 12px; border: 1px solid var(--ta-border-muted); border-radius: 12px; background: var(--ta-card); max-width: 680px; overflow: hidden; font-size: calc(13px * var(--ta-font-scale)); line-height: 1.5; color: var(--ta-text); }
763
+ .tag-card > * + * { border-top: 1px solid var(--ta-border-muted); }
764
+ .tag-part { padding: 12px 14px; min-width: 0; }
765
+ .tag-writing { display: flex; align-items: center; gap: 8px; padding: 12px 14px; color: var(--ta-muted); }
766
+ .tag-inline .ta-markdown, .tag-inline .ta-markdown > p { display: inline; margin: 0; }
767
+ .tag-inline .ta-markdown code { font-size: 0.92em; }
768
+ .tag-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 12px 14px 0; }
769
+ .tag-card > .tag-head + .tag-part { border-top: 0; padding-top: 10px; }
770
+ .tag-card ul, .tag-card ol { margin: 0; padding: 0; list-style: none; }
771
+ .tag-card li { margin: 0; }
772
+ .tag-title { font-weight: 600; font-size: calc(14px * var(--ta-font-scale)); min-width: 0; overflow-wrap: anywhere; }
773
+ .tag-status { --tag-tone: var(--ta-muted); display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: calc(12px * var(--ta-font-scale)); font-weight: 600; color: var(--tag-tone); background: color-mix(in srgb, var(--tag-tone) 12%, transparent); flex: none; }
774
+ .tag-status i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
775
+ .tag-status[data-status='done'] { --tag-tone: var(--ta-green); }
776
+ .tag-status[data-status='partial'], .tag-status[data-status='blocked'] { --tag-tone: var(--ta-yellow); }
777
+ .tag-status[data-status='failed'] { --tag-tone: var(--ta-red); }
778
+ .tag-section-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
779
+ .tag-add { color: var(--ta-green); font-variant-numeric: tabular-nums; }
780
+ .tag-del { color: var(--ta-red); font-variant-numeric: tabular-nums; }
781
+ .tag-delta { margin-left: 6px; font-size: calc(12px * var(--ta-font-scale)); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ta-muted); }
782
+ [data-tone='good'] > .tag-stat-label > .tag-delta, .tag-delta[data-tone='good'] { color: var(--ta-green); }
783
+ [data-tone='bad'] > .tag-stat-label > .tag-delta, .tag-delta[data-tone='bad'] { color: var(--ta-red); }
784
+ [data-tone='warn'] > .tag-stat-label > .tag-delta { color: var(--ta-yellow); }
785
+
786
+ /* Key numbers: large, their names under them */
787
+ .tag-stats { --tag-columns: 3; display: grid; grid-template-columns: repeat(var(--tag-columns), minmax(0, 1fr)); gap: 12px 16px; }
788
+ .tag-stats[data-count='1'] { --tag-columns: 1; }
789
+ .tag-stats[data-count='2'], .tag-stats[data-count='4'] { --tag-columns: 2; }
790
+ @container (min-width: 460px) { .tag-stats[data-count='4'] { --tag-columns: 4; } }
791
+ @container (max-width: 340px) { .tag-stats[data-count='3'], .tag-stats[data-count='5'], .tag-stats[data-count='6'] { --tag-columns: 2; } }
792
+ .tag-stat { min-width: 0; }
793
+ .tag-stat-value { font-size: calc(20px * var(--ta-font-scale)); font-weight: 650; line-height: 1.25; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
794
+ .tag-stat[data-tone='good'] .tag-stat-value { color: var(--ta-green); }
795
+ .tag-stat[data-tone='bad'] .tag-stat-value { color: var(--ta-red); }
796
+ .tag-stat[data-tone='warn'] .tag-stat-value { color: var(--ta-yellow); }
797
+ .tag-stat-label { margin-top: 2px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); overflow-wrap: anywhere; }
798
+
799
+ /* Files: a letter of what happened, the path, the lines, the squares of a forge */
800
+ .tag-change { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 8px; padding: 3px 0; }
801
+ .tag-change > .tag-kind, .tag-change > .tag-change-count, .tag-change-file { line-height: 22px; }
802
+ .tag-kind { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 4px; font: 600 10px/1 var(--ta-mono, ui-monospace, monospace); color: var(--ta-blue); background: color-mix(in srgb, currentColor 14%, transparent); margin-top: 3px; }
803
+ .tag-kind[data-kind='add'] { color: var(--ta-green); }
804
+ .tag-kind[data-kind='delete'] { color: var(--ta-red); }
805
+ .tag-change-path { display: flex; flex-direction: column; min-width: 0; }
806
+ .tag-change-file { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
807
+ .tag-change-name { flex: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
808
+ .tag-change-name .ta-markdown a { color: var(--ta-text); }
809
+ .tag-change-dir { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
810
+ .tag-change-dir bdi { direction: ltr; unicode-bidi: isolate; }
811
+ .tag-change-note { color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); line-height: 1.4; overflow-wrap: anywhere; }
812
+ .tag-change-count { display: inline-flex; align-items: center; height: 22px; gap: 6px; font-size: calc(12px * var(--ta-font-scale)); white-space: nowrap; }
813
+ .tag-squares { display: inline-flex; gap: 2px; }
814
+ .tag-squares i { width: 7px; height: 7px; border-radius: 1.5px; background: var(--ta-border); }
815
+ .tag-squares i[data-kind='add'] { background: var(--ta-green); }
816
+ .tag-squares i[data-kind='del'] { background: var(--ta-red); }
817
+
818
+ /* Steps: marks on a thread */
819
+ .tag-steps { list-style: none; margin: 0; padding: 0; }
820
+ .tag-step { position: relative; display: flex; gap: 10px; padding: 3px 0; }
821
+ .tag-step + .tag-step::before { content: ''; position: absolute; left: 8px; top: -7px; height: 12px; width: 1px; background: var(--ta-border); }
822
+ .tag-step-mark { position: relative; z-index: 1; background: var(--ta-card); flex: none; display: inline-grid; place-items: center; width: 17px; height: 17px; margin-top: 2px; border-radius: 50%; border: 1.5px solid var(--ta-border-field); color: #fff; box-sizing: border-box; }
823
+ .tag-step[data-status='done'] .tag-step-mark { border: 0; background: var(--ta-green); }
824
+ .tag-step[data-status='failed'] .tag-step-mark { border: 0; background: var(--ta-red); }
825
+ .tag-step[data-status='skipped'] .tag-step-mark { color: var(--ta-muted); }
826
+ .tag-step[data-status='doing'] .tag-step-mark { border-color: var(--ta-blue); border-top-color: transparent; animation: ta-spin 1s linear infinite; }
827
+ .tag-step[data-status='todo'] .tag-step-text, .tag-step[data-status='skipped'] .tag-step-text { color: var(--ta-muted); }
828
+ .tag-step[data-status='skipped'] .tag-step-text { text-decoration: line-through; }
829
+ .tag-step-text { min-width: 0; overflow-wrap: anywhere; }
830
+
831
+ /* Before and after: two bars a measure */
832
+ .tag-legend { display: flex; gap: 14px; margin-bottom: 4px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
833
+ .tag-legend span { display: inline-flex; align-items: center; gap: 5px; }
834
+ .tag-legend i { width: 10px; height: 6px; border-radius: 3px; }
835
+ .tag-measure + .tag-measure { margin-top: 8px; }
836
+ .tag-measure-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 3px; }
837
+ .tag-measure-label { min-width: 0; overflow-wrap: anywhere; }
838
+ .tag-measure-value { color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); white-space: nowrap; font-variant-numeric: tabular-nums; }
839
+ .tag-measure-value b { color: var(--ta-text); font-weight: 600; }
840
+ .tag-track { display: block; height: 6px; margin-top: 3px; border-radius: 3px; background: var(--ta-hover); overflow: hidden; }
841
+ .tag-track i { display: block; height: 100%; border-radius: 3px; background: var(--ta-accent); transition: width 0.4s var(--ta-ease, ease); }
842
+ [data-bar='before'] { background: var(--ta-border-field) !important; }
843
+ .tag-legend [data-bar='after'], [data-bar='after'][data-tone='good'] { background: var(--ta-green); }
844
+ [data-bar='after'][data-tone='bad'] { background: var(--ta-red); }
845
+ [data-bar='after'][data-tone='neutral'] { background: var(--ta-secondary); }
846
+
847
+ /* Amounts side by side */
848
+ .tag-bars { display: grid; grid-template-columns: minmax(0, max-content) minmax(60px, 1fr) auto; align-items: center; gap: 8px 10px; }
849
+ .tag-bar { display: contents; }
850
+ .tag-bar-label { min-width: 0; overflow-wrap: anywhere; max-width: 14em; }
851
+ .tag-bar .tag-track { margin: 0; height: 8px; border-radius: 4px; }
852
+ .tag-bar-value { color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); white-space: nowrap; font-variant-numeric: tabular-nums; }
853
+
854
+ /* A path: chips and arrows */
855
+ .tag-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 4px; }
856
+ .tag-flow-node { padding: 3px 10px; border: 1px solid var(--ta-border); border-radius: 8px; background: var(--ta-hover); overflow-wrap: anywhere; }
857
+ .tag-flow-arrow { display: inline-flex; color: var(--ta-muted); }
858
+ .tag-part[data-type='diagram'] .ta-markdown > :last-child { margin-bottom: 0; }
859
+ .tag-card > .tag-part[data-type='table'] { padding: 0; }
860
+ .tag-card .tag-table { margin: 0; border: 0; border-radius: 0; }
861
+ .tag-card .tag-table tr:last-child td { border-bottom: 0; }
862
+ .tag-card .tag-table th:first-child, .tag-card .tag-table td:first-child { padding-left: 14px; }
863
+ .tag-card .tag-table th:last-child, .tag-card .tag-table td:last-child { padding-right: 14px; }
864
+
865
+ /* Choices: a card each, a button that answers */
866
+ .tag-question { margin-bottom: 8px; font-weight: 600; }
867
+ .tag-options { display: flex; flex-direction: column; gap: 8px; }
868
+ .tag-option { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--ta-border); border-radius: 10px; transition: opacity 0.2s, border-color 0.2s; }
869
+ .tag-option-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
870
+ .tag-option[data-recommended] { border-color: color-mix(in srgb, var(--ta-green) 55%, var(--ta-border)); }
871
+ .tag-option[data-chosen] { border-color: var(--ta-green); box-shadow: 0 0 0 1px var(--ta-green) inset; }
872
+ .tag-option[data-other] { opacity: 0.5; }
873
+ .tag-option-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
874
+ .tag-option-label { font-weight: 600; overflow-wrap: anywhere; }
875
+ .tag-badge { padding: 0 6px; border-radius: 999px; font-size: calc(11px * var(--ta-font-scale)); line-height: 18px; font-weight: 600; color: var(--ta-green); background: color-mix(in srgb, var(--ta-green) 13%, transparent); }
876
+ .tag-option-detail { color: var(--ta-secondary); font-size: calc(12.5px * var(--ta-font-scale)); overflow-wrap: anywhere; }
877
+ .tag-points { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: calc(12px * var(--ta-font-scale)); color: var(--ta-secondary); }
878
+ .tag-points span { overflow-wrap: anywhere; }
879
+ .tag-points span::before { margin-right: 3px; font-weight: 700; }
880
+ .tag-points span[data-tone='good']::before { content: '+'; color: var(--ta-green); }
881
+ .tag-points span[data-tone='bad']::before { content: '−'; color: var(--ta-red); }
882
+ .tag-choose { flex: none; display: inline-flex; align-items: center; gap: 4px; }
883
+
884
+ /* Risks, notes, what to do */
885
+ .tag-notes { list-style: none; margin: 0; padding: 0; }
886
+ .tag-notes li { display: flex; gap: 8px; padding: 2px 0; }
887
+ .tag-notes li > span:last-child { min-width: 0; overflow-wrap: anywhere; }
888
+ .tag-note-mark { flex: none; display: inline-flex; margin-top: 3px; color: var(--ta-muted); }
889
+ .tag-notes li[data-tone='risk'] .tag-note-mark { color: var(--ta-yellow); }
890
+ .tag-notes li[data-tone='todo'] .tag-note-mark { color: var(--ta-blue); }
891
+
892
+ /* What to ask next: chips that send it */
893
+ .tag-next { display: flex; flex-wrap: wrap; gap: 6px; }
894
+ .tag-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 5px 11px; border: 1px solid var(--ta-border); border-radius: 999px; background: transparent; color: var(--ta-text); font: inherit; font-size: calc(12.5px * var(--ta-font-scale)); cursor: pointer; text-align: left; }
895
+ .tag-chip svg { flex: none; color: var(--ta-muted); }
896
+ .tag-chip:hover:not(:disabled) { background: var(--ta-hover); }
897
+ .tag-chip:disabled { opacity: 0.5; cursor: default; }
898
+ .tag-part[data-type='next'] { padding-top: 10px; padding-bottom: 10px; }
899
+
900
+ /* Details, folded */
901
+ .tag-part[data-type='details'] { padding-top: 8px; padding-bottom: 8px; }
902
+ .tag-details-toggle { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: var(--ta-muted); font: inherit; font-size: calc(12.5px * var(--ta-font-scale)); cursor: pointer; }
903
+ .tag-details-toggle:hover { color: var(--ta-text); }
904
+ .tag-details-body { margin-top: 6px; font-size: calc(13px * var(--ta-font-scale)); }
905
+ .tag-details-body .ta-markdown > :last-child { margin-bottom: 0; }
906
+
907
+ [data-touch] .tag-chip, [data-touch] .tag-choose { min-height: 34px; }
908
+ [data-layout='compact'] .tag-part:not([data-type='table']) { padding: 11px 12px; }
909
+ [data-layout='compact'] .tag-head { padding: 9px 12px; }
910
+ `;
911
+ function injectStyle() {
912
+ const element = document.createElement("style");
913
+ element.dataset.taPackage = "ta-glance";
914
+ element.textContent = STYLE;
915
+ document.head.appendChild(element);
916
+ return () => element.remove();
917
+ }
918
+
919
+ // web-src/index.tsx
920
+ function activate(pi) {
921
+ bind(pi.React);
922
+ if (!pi.registerCodeRenderer) {
923
+ return () => {
924
+ return;
925
+ };
926
+ }
927
+ const removeStyle = injectStyle();
928
+ pi.registerCodeRenderer(LANGUAGE, glanceCard(pi));
929
+ return removeStyle;
930
+ }
931
+ export {
932
+ activate as default
933
+ };