@celljs/ta-glance 4.17.0 → 4.18.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/extension/index.mjs +18 -12
- package/package.json +3 -3
- package/web/index.js +717 -445
package/extension/index.mjs
CHANGED
|
@@ -225,9 +225,14 @@ var BLOCKS = 8;
|
|
|
225
225
|
var TEXT = 400;
|
|
226
226
|
var MARKDOWN = 8000;
|
|
227
227
|
var STATUSES = ["done", "partial", "failed", "blocked", "info"];
|
|
228
|
+
var QUIET = ["done", "info"];
|
|
228
229
|
var TONES = ["good", "bad", "warn", "neutral"];
|
|
229
230
|
var STEPS = ["done", "doing", "todo", "failed", "skipped"];
|
|
230
|
-
var NOTES = ["risk", "
|
|
231
|
+
var NOTES = ["risk", "todo", "info"];
|
|
232
|
+
var CHECKS = 3;
|
|
233
|
+
function passed(list, least) {
|
|
234
|
+
return list.length >= least && list.every((item) => item.tone === "good");
|
|
235
|
+
}
|
|
231
236
|
function object(value) {
|
|
232
237
|
return value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
233
238
|
}
|
|
@@ -382,7 +387,7 @@ function blockOf(item, partial, labels) {
|
|
|
382
387
|
switch (type) {
|
|
383
388
|
case "stats": {
|
|
384
389
|
const list = items(value?.items, stat).slice(0, 6);
|
|
385
|
-
return list.length ? { type, items: list } : undefined;
|
|
390
|
+
return list.length ? { type, items: list, ...passed(list, CHECKS) ? { checks: true } : {} } : undefined;
|
|
386
391
|
}
|
|
387
392
|
case "changes": {
|
|
388
393
|
const raw = Array.isArray(value?.items) ? value.items : [];
|
|
@@ -451,10 +456,10 @@ function blockOf(item, partial, labels) {
|
|
|
451
456
|
case "options": {
|
|
452
457
|
const list = items(value?.items, option).slice(0, 5);
|
|
453
458
|
const question = text(value?.question);
|
|
454
|
-
return list.length ? { type, items: list, ...question ? { question } : {} } : undefined;
|
|
459
|
+
return list.length ? { type, items: list, ...question ? { question } : {}, ...value?.multi === true ? { multi: true } : {} } : undefined;
|
|
455
460
|
}
|
|
456
461
|
case "notes": {
|
|
457
|
-
const list = items(value?.items, note);
|
|
462
|
+
const list = items(value?.items, note).sort((a, b) => NOTES.indexOf(a.tone) - NOTES.indexOf(b.tone));
|
|
458
463
|
return list.length ? { type, items: list } : undefined;
|
|
459
464
|
}
|
|
460
465
|
case "next": {
|
|
@@ -497,7 +502,7 @@ var GlanceSpec;
|
|
|
497
502
|
}
|
|
498
503
|
const status = oneOf(card.status, STATUSES);
|
|
499
504
|
const title = text(card.title);
|
|
500
|
-
const blocks = placed(items(Array.isArray(card.blocks) ? card.blocks : loose(card), (entry) => block(entry, partial, labels)).slice(0, BLOCKS));
|
|
505
|
+
const blocks = placed(items(Array.isArray(card.blocks) ? card.blocks : loose(card), (entry) => block(entry, partial, labels)).slice(0, BLOCKS)).map((made) => made.type === "stats" && !made.checks && status && !QUIET.includes(status) && passed(made.items, 1) ? { ...made, checks: true } : made);
|
|
501
506
|
if (!blocks.length && !title) {
|
|
502
507
|
return;
|
|
503
508
|
}
|
|
@@ -587,17 +592,18 @@ var GlanceAsk;
|
|
|
587
592
|
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.
|
|
588
593
|
|
|
589
594
|
How to reply:
|
|
590
|
-
- 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.
|
|
591
|
-
-
|
|
595
|
+
- Lead with the answer. The first line is the conclusion in one short sentence (about 25 Chinese characters or 15 words at most), what matters in **bold**. Nothing before it: no "Sure", no restating the request.
|
|
596
|
+
- Report by exception. What went as expected is said once, as a whole ("all 6 checks pass"), never a row or a sentence each. Words go only to what is wrong, unfinished, at risk, or the user must decide. Leave out the process (what you read, ran, tried), reasons and evidence nobody asked for, what the user already knows and repeating yourself. Prefer numbers and names to adjectives.
|
|
592
597
|
- A short question or small talk: one to three sentences, no card.
|
|
598
|
+
- A message may ask for its answer in a form of its own (PASS or FAIL first, a verdict, "in a few lines", "report…"), whether the user's or sent by a program or another agent (the double, a scheduled task, a goal): the user reads it here all the same. Keep what it asks (the word or line it wants first, the order, how short) and still put the rest in the card: short makes the card smaller, not plain lines. Leave the card out only when the message says the answer goes where nothing draws one (plain text, no Markdown).
|
|
593
599
|
- 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.
|
|
594
600
|
- Code the user must read or copy stays in ordinary code blocks.
|
|
595
601
|
- Several pictures (screenshots, before and after, light and dark): one after another, each \`\` with nothing else between them. Ta shows them together as a grid, the words under each.
|
|
596
602
|
|
|
597
603
|
The card: {"status": "done" | "partial" | "failed" | "blocked" | "info", "title"?: string, "blocks": [...]}
|
|
598
604
|
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.
|
|
599
|
-
Blocks, 1 to
|
|
600
|
-
- {"type":"stats","items":[{"label":"Tests","value":"128/128","tone":"good"},{"label":"Startup","value":"210 ms","delta":"-34%","tone":"good","trend":[320,290,210]}]}: key numbers, at most
|
|
605
|
+
Blocks, 1 to 3 of them, the most important first (Ta puts stats on top and notes, next and details at the bottom), each with only the fields shown. A block few need but some may want (the full list, how it was measured, the rest of a comparison, why, where in the code) may have "fold": "a few words": Ta draws it folded under them, opened by a tap; it does not count in the 3. Long lists are folded by Ta after their first items, so give them whole. Every text of a card fits one line of a phone: about 20 Chinese characters or 12 words at most, a label 2 to 6; Ta cuts a row at two lines. In the user's language; inline Markdown works (**bold**, \`path/to/file\` opens the file).
|
|
606
|
+
- {"type":"stats","items":[{"label":"Tests","value":"128/128","tone":"good"},{"label":"Startup","value":"210 ms","delta":"-34%","tone":"good","trend":[320,290,210]}]}: key numbers, at most 4, each value a number with its unit (a fact in words goes in notes); tone good | bad | warn; trend, its values over time when known, draws a small line. Checks that passed (tests, build, lint) are one stats block, tone good each: Ta draws it as a single line of ticks.
|
|
601
607
|
- {"type":"changes","items":[{"path":"src/a.ts","kind":"edit","add":12,"del":3,"note":"why, in a few words"}]}: files changed, a path each (what changed without a file goes in notes); kind add | edit | delete.
|
|
602
608
|
- {"type":"steps","items":[{"text":"...","status":"done"}]}: progress or a plan; status done | doing | todo | failed | skipped.
|
|
603
609
|
- {"type":"compare","unit":"ms","better":"lower","items":[{"label":"Startup","before":320,"after":210}]}: before and after, numbers only (words go in a table).
|
|
@@ -606,9 +612,9 @@ Blocks, 1 to 4 of them, the most important first (Ta puts stats on top and notes
|
|
|
606
612
|
- {"type":"share","unit":"MB","items":[{"label":"pi","value":129},{"label":"ta","value":66}]}: the parts of a whole.
|
|
607
613
|
- {"type":"flow","items":["Request",{"text":"Gateway","icon":"Server"},"Session","Model"]}: a sequence or a path.
|
|
608
614
|
- {"type":"diagram","mermaid":"graph LR; A-->B"}: relations a flow cannot show, under 12 nodes.
|
|
609
|
-
- {"type":"table","columns":["",""],"rows":[["",""]]}: a few rows that compare things on several points, the first column naming each row (columns ["", "Before", "After"] for before and after in words).
|
|
610
|
-
- {"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.
|
|
611
|
-
- {"type":"notes","items":[{"text":"...","tone":"risk"}]}: risks, caveats, what the user must do; tone risk | info | todo.
|
|
615
|
+
- {"type":"table","columns":["",""],"rows":[["",""]]}: a few rows that compare things on several points, the first column naming each row (columns ["", "Before", "After"] for before and after in words); cells of a few words, never sentences, and no row for what is fine.
|
|
616
|
+
- {"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. Add "multi": true when they may choose several. Several things to decide at once: an options block for each, in the same card; the user picks in all of them and sends the choices together.
|
|
617
|
+
- {"type":"notes","items":[{"text":"...","tone":"risk"}]}: risks, caveats, what the user must do, at most 3, a line each; tone risk | info | todo.
|
|
612
618
|
- {"type":"next","items":["Run the e2e tests"]}: at most 3 things the user may well ask next, each a button that sends it.
|
|
613
619
|
- {"type":"details","title":"How","markdown":"..."}: what few will read, folded.
|
|
614
620
|
An item of stats, flow, options, notes or next may have "icon", where it tells items apart at a glance (an item of flow or next then {"text","icon"}): one of ${GLANCE_ICONS.join(", ")}; else leave it out. Never write an emoji, in a card or out of it.`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-glance",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.18.0",
|
|
4
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
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@celljs/ta-protocol": "4.
|
|
30
|
-
"@celljs/ta-web": "4.
|
|
29
|
+
"@celljs/ta-protocol": "4.18.0",
|
|
30
|
+
"@celljs/ta-web": "4.18.0",
|
|
31
31
|
"@types/react": "^19.3.0"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|