@joenandez/tldr 1.0.1 → 1.1.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.
Files changed (31) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/bin/tldr-agent +3 -2
  4. package/install/tldr-agent-bootstrap.sh +7 -0
  5. package/package.json +7 -6
  6. package/release/activation-manifest.json +6 -6
  7. package/release/payloads/arm64/TldrAgentAegis.pkg +0 -0
  8. package/release/payloads/arm64/tldr-agent.tar.gz +0 -0
  9. package/release/starport-release.json +2 -2
  10. package/skills/tldr/SKILL.md +37 -36
  11. package/src/lib/aegis_native_distribution.mjs +1 -1
  12. package/src/lib/aegis_protocol.mjs +1 -1
  13. package/src/lib/starport_onboarding.mjs +303 -6
  14. package/src/lib/starport_orchestrator.mjs +21 -20
  15. package/src/lib/starport_runtime.mjs +28 -5
  16. package/src/lib/tightbeam_channel.mjs +63 -119
  17. package/src/lib/tightbeam_channel_runtime.mjs +76 -17
  18. package/src/lib/tightbeam_email_adapter.mjs +10 -0
  19. package/src/lib/tightbeam_email_delivery_channel.mjs +107 -133
  20. package/src/lib/tightbeam_email_provider_map.mjs +337 -0
  21. package/src/lib/tightbeam_inbound_publish.mjs +84 -0
  22. package/src/lib/tightbeam_welcome_dispatch.mjs +129 -33
  23. package/src/lib/tldr_agent_diagnostic_schema.mjs +1 -0
  24. package/src/lib/transports/email/render/email.mjs +66 -180
  25. package/src/lib/transports/email/render/html.mjs +37 -80
  26. package/src/lib/transports/email/render/text.mjs +2 -2
  27. package/src/lib/transports/email/render/tldr.mjs +10 -88
  28. package/src/lib/transports/email/render/tokens.mjs +56 -75
  29. package/src/lib/transports/email/templates.mjs +38 -27
  30. package/src/lib/transports/email.mjs +21 -1
  31. package/src/lib/transports/email/render/glyphs.mjs +0 -66
@@ -1,25 +1,9 @@
1
- /* tldr; — the email envelope.
1
+ /* Quiet rich-text correspondence for owner and agent email.
2
2
  *
3
- * Four parts: the subject set as the TLDR block, the agent's Markdown, and a
4
- * context line closing the message. A system message adds a fifth above them
5
- * all, and it is an exception on purpose.
6
- *
7
- * THE TLDR BLOCK is the product's name made literal, and it is the one place
8
- * this system speaks above the agent. It carries the result, the owner action,
9
- * and the next moment — and it invents none of them. The subject's grammar is
10
- * already "state word, colon, the decision", so the state word becomes the
11
- * action and the decision becomes the result. The block sets a structure that
12
- * was always in the string; it does not add a claim to it.
13
- *
14
- * That is also why the subject is not printed twice. A card that repeats its own
15
- * subject above a summary of its own subject has spent the owner's first two
16
- * seconds saying one thing three times.
17
- *
18
- * THE LIVE EDGE is allocated here and only here. Citron means the point where
19
- * attention is active, so it appears on the action chip when the message needs
20
- * the owner, and nowhere at all when it does not — seeing citron in an inbox has
21
- * to mean something. No block renderer can emit the accent; html.mjs never
22
- * receives it.
3
+ * Normal messages begin with the agent's body. There is no product masthead,
4
+ * repeated subject, summary panel, action chip, or decorative mark. System mail
5
+ * identifies itself with a compact label and heading; all tldr; branding lives
6
+ * at the very end of the footer.
23
7
  */
24
8
 
25
9
  import {
@@ -27,20 +11,19 @@ import {
27
11
  CARD_WIDTH,
28
12
  DAY,
29
13
  DISPLAY,
14
+ GUTTER,
30
15
  MONO,
31
16
  NIGHT,
32
17
  TYPE,
33
18
  } from "./tokens.mjs";
34
19
  import { parseInline, parseMarkdown } from "./markdown.mjs";
35
20
  import { blocksHtml, esc, presentationTable as pt } from "./html.mjs";
36
- import { blocksText, COLUMNS, inlineText, wrap } from "./text.mjs";
37
- import { TEXT_GLYPH } from "./glyphs.mjs";
21
+ import { blocksText, inlineText, wrap } from "./text.mjs";
38
22
  import {
39
23
  ACTION,
40
24
  inlineMarkdownHtml,
41
25
  resolveAction,
42
26
  splitSubject,
43
- tldrHtml,
44
27
  } from "./tldr.mjs";
45
28
 
46
29
  export const AGENTS = Object.freeze({
@@ -54,89 +37,39 @@ const NOTICE_DEFAULT =
54
37
  "Only replies from your verified address reach the session.";
55
38
 
56
39
  export const WORDMARK = "tldr;";
57
-
58
- /* The twin resolves the same inline Markdown the HTML does, and shows the result
59
- * rather than the notation. */
60
40
  const footerInlineText = (value) => inlineText(parseInline(value));
61
41
 
62
- /* The wordmark, set as live text rather than loaded as an asset.
63
- *
64
- * DESIGN.md's identity rule is that the wordmark is an SVG and is never rebuilt
65
- * from type. Email is the declared exception, and it has to be: clients block
66
- * remote images, so an emailed wordmark that is an image is a wordmark most
67
- * owners never see.
68
- *
69
- * Proportions come off brand/logotype/wordmark.svg — the semicolon's dot sits at
70
- * the ascender line and its tail drops well below the baseline, about a quarter
71
- * taller overall than the letters beside it. The negative margin cancels the
72
- * tracking the `r` would otherwise carry, because the asset has the semicolon
73
- * hugging the `r` rather than sitting a letter away from it.
74
- *
75
- * All of it link blue, as the asset is. Blue without an underline cannot be
76
- * mistaken for a link here: in this system a link is always underlined. */
77
- function wordmarkHtml(t) {
42
+ function wordmarkHtml(tokens) {
78
43
  return (
79
- `<span class="tl-link" style="font-family:${BODY};font-size:17px;line-height:1;` +
80
- `letter-spacing:.16em;font-weight:400;color:${t.link};">tldr</span>` +
81
- `<span class="tl-link" style="font-family:${DISPLAY};font-size:25px;line-height:1;` +
82
- `font-weight:700;color:${t.link};margin-left:-1px;">;</span>`
44
+ `<span class="tl-muted" style="${TYPE.colophon}color:${tokens.muted};">Sent via tldr</span>` +
45
+ `<span class="tl-link" style="${TYPE.colophon}color:${tokens.link};">;</span>`
83
46
  );
84
47
  }
85
48
 
86
- /* The system bar: a solid identity plane across the head of the card, the
87
- * wordmark on the left and the kind of message on the right.
88
- *
89
- * It is the loudest piece of chrome in the system, spent on the one distinction
90
- * that matters at 3am: an agent's message says a thing about your code, a system
91
- * message says a thing about tldr;, and the owner has to be able to tell which
92
- * before reading a word. Never citron — it is a label, not an ask. */
93
- function systemBarHtml(kind, t) {
94
- const cell =
95
- `class="tl-solid" style="background:${t.solid};color:${t.onSolid};${TYPE.stamp}` +
96
- `line-height:1.2;white-space:nowrap;vertical-align:middle;`;
97
-
98
- /* The kind is uppercased; the wordmark is not. The name is lowercase and it
99
- * stays lowercase in the one place the product signs itself loudest. */
49
+ function systemHeaderHtml(spec, tokens) {
50
+ const { result } = splitSubject(spec.subject);
100
51
  return pt(
101
- `<tr>` +
102
- `<td ${cell}padding:12px 10px 12px 24px;font-size:14px;letter-spacing:.04em;">${WORDMARK}</td>` +
103
- `<td align="right" ${cell}padding:12px 24px 12px 10px;text-transform:uppercase;">${esc(kind)}</td>` +
104
- `</tr>`,
52
+ `<tr><td class="tl-muted" style="${TYPE.systemLabel}color:${tokens.muted};">` +
53
+ `tldr; <span class="tl-line" style="color:${tokens.line};">&middot;</span> ${esc(spec.system)}` +
54
+ `</td></tr>` +
55
+ `<tr><td class="tl-ink" style="${TYPE.systemTitle}color:${tokens.ink};padding:10px 0 0 0;">${esc(result)}</td></tr>`,
105
56
  );
106
57
  }
107
58
 
108
- /* A value the owner has to read off the screen and type somewhere else.
109
- *
110
- * It gets the mono face at display size rather than the 13px a fenced block
111
- * would give it, because this is the one string in the system whose whole job is
112
- * to be transcribed correctly at arm's length. The subject carries it too, so it
113
- * reaches the lock screen without the email being opened; that repetition is the
114
- * point rather than an oversight. */
115
- function codePlateHtml(code, t) {
59
+ function codePlateHtml(code, tokens) {
116
60
  return pt(
117
- `<tr><td class="tl-raised" style="border:1px solid ${t.line};border-radius:2px;` +
118
- `background:${t.raised};padding:20px 24px;font-family:${MONO};font-size:30px;` +
119
- `line-height:1.2;font-weight:500;letter-spacing:.16em;color:${t.ink};` +
61
+ `<tr><td class="tl-raised" style="border:1px solid ${tokens.line};border-radius:4px;` +
62
+ `background:${tokens.raised};padding:18px 20px;${TYPE.codePlate}color:${tokens.ink};` +
120
63
  `white-space:nowrap;">${esc(code)}</td></tr>`,
121
64
  );
122
65
  }
123
66
 
124
- /* Provenance is useful, not important enough to be a form. One line, fixed
125
- * order, widest scope inward — across a thread of six messages the values have
126
- * to be in the same places or the line stops being scannable and becomes
127
- * something to read. */
128
67
  const CONTEXT_ORDER = ["DIRECTORY", "AGENT", "BRANCH", "SESSION"];
129
-
130
68
  const contextRank = (label) => {
131
69
  const index = CONTEXT_ORDER.indexOf(label);
132
70
  return index === -1 ? CONTEXT_ORDER.length : index;
133
71
  };
134
72
 
135
- /* Labels stay, lowercased. Dropping them makes the line shorter and the values
136
- * ambiguous — `rate-limit` beside `1f4a9c2` is a branch and a session only if
137
- * you already knew that, and the owner reading this is half awake. The label
138
- * recedes to muted and the value holds the ink, so the pairs scan without the
139
- * separators having to do all the work. */
140
73
  export const contextPairs = (spec) =>
141
74
  [
142
75
  ...(spec.statePanel ?? []),
@@ -146,98 +79,87 @@ export const contextPairs = (spec) =>
146
79
  .sort(([a], [b]) => contextRank(a) - contextRank(b))
147
80
  .map(([label, value]) => [String(label).toLowerCase(), String(value)]);
148
81
 
149
- function footerHtml(spec, t) {
82
+ function footerHtml(spec, tokens) {
150
83
  const context = contextPairs(spec);
151
84
  const contextRow = context.length
152
- ? `<tr><td style="${TYPE.context}padding:16px 0 0 0;word-break:break-word;">` +
85
+ ? `<tr><td class="tl-muted" style="${TYPE.context}color:${tokens.muted};padding:10px 0 0 0;word-break:break-word;">` +
153
86
  context
154
87
  .map(
155
88
  ([label, value]) =>
156
- `<span class="tl-muted" style="color:${t.muted};">${esc(label)}</span>` +
157
- `<span class="tl-ink" style="color:${t.ink};"> ${esc(value)}</span>`,
89
+ `<span style="font-weight:600;">${esc(label)}</span> ${esc(value)}`,
158
90
  )
159
91
  .join(
160
- `<span class="tl-line" style="color:${t.line};"> &middot; </span>`,
92
+ `<span class="tl-line" style="color:${tokens.line};"> &middot; </span>`,
161
93
  ) +
162
94
  `</td></tr>`
163
95
  : "";
164
96
 
165
97
  return pt(
166
- `<tr><td style="padding:0 24px;">` +
98
+ `<tr><td style="padding:0 ${GUTTER}px;">` +
167
99
  pt(
168
- `<tr><td style="padding:0;"><div class="tl-hair" style="height:1px;background:${t.line};font-size:0;line-height:1px;">&nbsp;</div></td></tr>` +
100
+ `<tr><td style="padding:0;"><div class="tl-hair" style="height:1px;background:${tokens.line};font-size:0;line-height:1px;">&nbsp;</div></td></tr>` +
101
+ `<tr><td class="tl-muted" style="${TYPE.small}color:${tokens.muted};padding:14px 0 0 0;">` +
102
+ `${inlineMarkdownHtml(spec.reply ?? REPLY_DEFAULT, tokens)}</td></tr>` +
169
103
  contextRow +
170
- `<tr><td style="padding:22px 0 0 0;">${wordmarkHtml(t)}</td></tr>` +
171
- `<tr><td class="tl-muted" style="${TYPE.context}color:${t.muted};padding:10px 0 0 0;">` +
172
- `${inlineMarkdownHtml(spec.notice ?? NOTICE_DEFAULT, t)}</td></tr>`,
104
+ `<tr><td class="tl-muted" style="${TYPE.context}color:${tokens.muted};padding:7px 0 0 0;">` +
105
+ `${inlineMarkdownHtml(spec.notice ?? NOTICE_DEFAULT, tokens)}</td></tr>` +
106
+ `<tr><td style="padding:18px 0 0 0;">${wordmarkHtml(tokens)}</td></tr>`,
173
107
  ) +
174
108
  `</td></tr>`,
175
109
  );
176
110
  }
177
111
 
178
- /* Night lighting. Day values are hard-coded inline above this block, so a client
179
- * that strips <style> still renders the document correctly. Every day colour
180
- * this renderer emits sits on one of these classes. */
181
112
  function nightCss() {
182
113
  const n = NIGHT;
183
- return `@media (prefers-color-scheme: dark){
114
+ /* The :root declaration is what Apple Mail 13+ actually reads for scheme
115
+ * opt-in; the meta tags cover Mail 12 and signal intent to inverting
116
+ * clients. Both ship because neither alone covers the version range. */
117
+ return `:root{color-scheme:light dark;supported-color-schemes:light dark;}
118
+ @media (prefers-color-scheme: dark){
184
119
  .tl-page,.tl-card{background:${n.stock}!important;}
185
120
  .tl-ink,.tl-ink a{color:${n.ink}!important;}
186
121
  .tl-muted,.tl-muted a{color:${n.muted}!important;}
187
122
  .tl-link,.tl-link a,a.tl-link{color:${n.link}!important;}
188
123
  .tl-line{color:${n.line}!important;}
189
124
  .tl-hair{background:${n.line}!important;}
190
- .tl-hair-link{background:${n.link}!important;}
191
- .tl-bar{background:${n.link}!important;}
192
125
  .tl-ruled{border-bottom-color:${n.line}!important;}
193
- .tl-field{background:${n.field}!important;}
194
126
  .tl-raised{background:${n.raised}!important;border-color:${n.line}!important;color:${n.ink}!important;}
195
- .tl-code{background:${n.field}!important;color:${n.ink}!important;}
196
- .tl-tab,.tl-solid,.tl-chip-wait{background:${n.solid}!important;color:${n.onSolid}!important;}
197
- .tl-chip-live{background:${n.accent}!important;color:${n.onAccent}!important;}
198
- .tl-check-on{background:${n.solid}!important;color:${n.onSolid}!important;}
199
- .tl-check-off{border-color:${n.line}!important;}
200
- .tl-fill-link{background:${n.link}!important;}
127
+ .tl-code{background:${n.raised}!important;color:${n.ink}!important;}
128
+ .tl-check-on{background:${n.ink}!important;color:${n.stock}!important;}
129
+ .tl-check-off{border-color:${n.strongLine}!important;}
201
130
  }`;
202
131
  }
203
132
 
204
- /* The card only — used by the gallery, which needs day and night side by side
205
- * and therefore cannot rely on a media query. */
206
133
  export function renderCard(spec, mode = "day") {
207
- const t = mode === "night" ? NIGHT : DAY;
134
+ const tokens = mode === "night" ? NIGHT : DAY;
208
135
  const body = parseMarkdown(spec.body ?? "");
209
136
 
210
137
  return (
211
138
  `<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" class="tl-card" ` +
212
- `style="border-collapse:collapse;width:100%;max-width:${CARD_WIDTH}px;background:${t.stock};">` +
213
- (spec.system
214
- ? `<tr><td style="padding:0;">${systemBarHtml(spec.system, t)}</td></tr>`
139
+ `style="border-collapse:collapse;table-layout:fixed;width:100%;max-width:${CARD_WIDTH}px;background:${tokens.stock};">` +
140
+ (spec.system && !spec.code
141
+ ? `<tr><td style="padding:30px ${GUTTER}px 0 ${GUTTER}px;">${systemHeaderHtml(spec, tokens)}</td></tr>`
215
142
  : "") +
216
- `<tr><td style="padding:${spec.system ? 24 : 28}px 24px 0 24px;">${tldrHtml(spec, t, spec.reply ?? REPLY_DEFAULT)}</td></tr>` +
217
143
  (spec.code
218
- ? `<tr><td style="padding:20px 24px 0 24px;">${codePlateHtml(spec.code, t)}</td></tr>`
144
+ ? `<tr><td style="padding:30px ${GUTTER}px 0 ${GUTTER}px;">${codePlateHtml(spec.code, tokens)}</td></tr>`
219
145
  : "") +
220
146
  (body.length
221
- ? `<tr><td style="padding:32px 24px 0 24px;">${blocksHtml(body, t)}</td></tr>`
147
+ ? `<tr><td style="padding:${spec.system || spec.code ? 22 : 30}px ${GUTTER}px 0 ${GUTTER}px;">${blocksHtml(body, tokens)}</td></tr>`
222
148
  : "") +
223
- `<tr><td style="padding:36px 0 0 0;">${footerHtml(spec, t)}</td></tr>` +
149
+ `<tr><td style="padding:34px 0 0 0;">${footerHtml(spec, tokens)}</td></tr>` +
224
150
  `<tr><td style="height:28px;line-height:28px;font-size:0;">&nbsp;</td></tr>` +
225
151
  `</table>`
226
152
  );
227
153
  }
228
154
 
229
- /* The line the inbox shows under the subject. The subject already carries the
230
- * result, so the preheader spends itself on what the subject cannot say: what
231
- * this means for the owner, then the first sentence of the message. */
232
155
  function preheader(spec) {
233
156
  const first = parseMarkdown(spec.body ?? "").find(
234
- (n) => n.type === "paragraph",
235
- );
236
- const lead = (first?.text ?? "").replace(/\s+/g, " ").trim();
237
- return `${ACTION[resolveAction(spec)]}${lead ? ` — ${lead}` : ""}`.slice(
238
- 0,
239
- 140,
157
+ (node) => node.type === "paragraph",
240
158
  );
159
+ return (first?.text ?? spec.subject ?? "")
160
+ .replace(/\s+/g, " ")
161
+ .trim()
162
+ .slice(0, 140);
241
163
  }
242
164
 
243
165
  export function renderHtml(spec) {
@@ -250,79 +172,43 @@ export function renderHtml(spec) {
250
172
  <title>${esc(spec.subject)}</title>
251
173
  <style>${nightCss()}</style>
252
174
  </head>
253
- <body class="tl-page" style="margin:0;padding:0;background:${DAY.stock};">
175
+ <body class="tl-page" style="margin:0;padding:0;background:${DAY.page};">
254
176
  <div style="display:none;max-height:0;overflow:hidden;opacity:0;">${esc(preheader(spec))}</div>
255
- <table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" class="tl-page" style="background:${DAY.stock};">
256
- <tr><td align="center" style="padding:28px 12px 40px 12px;">${renderCard(spec, "day")}</td></tr>
177
+ <table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" class="tl-page" style="table-layout:fixed;background:${DAY.page};">
178
+ <tr><td align="center" style="padding:20px 12px 32px 12px;">${renderCard(spec, "day")}</td></tr>
257
179
  </table>
258
180
  </body></html>
259
181
  `;
260
182
  }
261
183
 
262
- /* ------------------------------------------------------------------ text */
263
-
264
184
  export function renderText(spec) {
265
185
  const out = [];
266
- const { result } = splitSubject(spec.subject);
267
- const action = ACTION[resolveAction(spec)].toUpperCase();
268
186
 
269
- /* The twin carries the same distinctions in the material it has: a rule above
270
- * and below, which is the heaviest thing 72 columns of ASCII can say. */
271
- if (spec.system) {
272
- const kind = spec.system.toUpperCase();
273
- out.push(
274
- "=".repeat(COLUMNS),
275
- `${WORDMARK}${" ".repeat(Math.max(COLUMNS - WORDMARK.length - kind.length, 1))}${kind}`,
276
- "=".repeat(COLUMNS),
277
- "",
278
- );
187
+ if (spec.system && !spec.code) {
188
+ const { result } = splitSubject(spec.subject);
189
+ out.push(`${WORDMARK} · ${spec.system.toUpperCase()}`, "", ...wrap(result));
279
190
  }
280
191
 
281
- out.push(
282
- `TLDR${" ".repeat(Math.max(COLUMNS - 4 - action.length, 1))}${action}`,
283
- "",
284
- ...wrap(result),
285
- "",
286
- );
287
-
288
- /* The reply mark owns a gutter in the twin too, so a wrapped instruction stays
289
- * visibly attached to it. The twin is an equal document, not a dump: it
290
- * resolves the same inline Markdown the HTML does and shows the result rather
291
- * than the notation. */
292
- const reply = wrap(
293
- footerInlineText(spec.reply ?? REPLY_DEFAULT),
294
- COLUMNS - 3,
295
- );
296
- out.push(
297
- `${TEXT_GLYPH.reply} ${reply[0]}`,
298
- ...reply.slice(1).map((l) => ` ${l}`),
299
- );
300
-
301
- /* The twin gives the code its own indented line and nothing else on it. There
302
- * is no type size to reach for here, so isolation does the work instead. */
303
192
  if (spec.code) out.push("", ` ${spec.code}`);
304
-
305
193
  if (spec.body?.trim()) {
306
- out.push(
307
- "",
308
- "-".repeat(COLUMNS),
309
- "",
310
- ...blocksText(parseMarkdown(spec.body)),
311
- );
194
+ if (out.length) out.push("");
195
+ out.push(...blocksText(parseMarkdown(spec.body)));
312
196
  }
313
197
 
314
- out.push("", "-".repeat(COLUMNS), "");
198
+ out.push("", "--", ...wrap(footerInlineText(spec.reply ?? REPLY_DEFAULT)));
315
199
 
316
200
  const context = contextPairs(spec);
317
- if (context.length)
201
+ if (context.length) {
318
202
  out.push(
319
203
  ...wrap(context.map(([label, value]) => `${label} ${value}`).join(" · ")),
320
- "",
321
204
  );
205
+ }
322
206
 
323
- out.push(WORDMARK);
324
- out.push(...wrap(footerInlineText(spec.notice ?? NOTICE_DEFAULT)), "");
325
-
207
+ out.push(
208
+ ...wrap(footerInlineText(spec.notice ?? NOTICE_DEFAULT)),
209
+ "Sent via tldr;",
210
+ "",
211
+ );
326
212
  return out.join("\n");
327
213
  }
328
214
 
@@ -1,20 +1,15 @@
1
- /* tldr; — Markdown tree to email HTML.
1
+ /* Markdown tree to quiet, client-safe email HTML.
2
2
  *
3
3
  * Every block becomes a row in one outer table and carries its whole style in a
4
4
  * style attribute, because a client that strips <style> must still get the
5
5
  * document right. Classes are emitted alongside, and only ever used by the
6
6
  * night-lighting media query.
7
7
  *
8
- * Rules this file exists to hold:
9
- * - flat. A change of plane or a 1px boundary, never a shadow.
10
- * - the reading face sets every sentence; the condensed face sets short
11
- * phrases and meaningful numerals; mono sets things you could type.
12
- * - no citron. The live edge is the envelope's judgment about the message,
13
- * not something the agent's Markdown can reach for. Nothing in this file
14
- * can emit the accent, which is a stronger guarantee than a budget.
8
+ * The body should read like well-formatted correspondence: one native reading
9
+ * face, restrained neutral structure, and blue reserved for actual links.
15
10
  */
16
11
 
17
- import { BODY, DISPLAY, MONO, RADIUS, TYPE } from "./tokens.mjs";
12
+ import { BODY, MONO, RADIUS, TYPE } from "./tokens.mjs";
18
13
  import { parseInline } from "./markdown.mjs";
19
14
 
20
15
  export function esc(value) {
@@ -42,18 +37,9 @@ export function inlineHtml(nodes, t) {
42
37
  case "softbreak":
43
38
  return " ";
44
39
  case "code":
45
- /* Identifiers, flags and file paths — the densest thing in agent
46
- * prose, six to a paragraph in a real handoff.
47
- *
48
- * The chip is a fill and not a bounded box. A 1px boundary around
49
- * every identifier puts four hard edges into the middle of a sentence
50
- * and the paragraph stops being readable; the powder fill separates
51
- * the token just as clearly with no edge at all. A code block is a
52
- * slab and gets the boundary; an identifier is a word and gets a
53
- * highlight. */
54
40
  return (
55
41
  `<code class="tl-code" style="font-family:${MONO};font-size:.95em;` +
56
- `background:${t.field};color:${t.ink};border-radius:${RADIUS.sm};` +
42
+ `background:${t.raised};color:${t.ink};border-radius:${RADIUS.sm};` +
57
43
  `padding:1px 4px;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word;">${esc(node.value)}</code>`
58
44
  );
59
45
  case "strong":
@@ -63,8 +49,6 @@ export function inlineHtml(nodes, t) {
63
49
  case "strike":
64
50
  return `<span class="tl-muted" style="text-decoration:line-through;color:${t.muted};">${inlineHtml(node.children, t)}</span>`;
65
51
  case "link":
66
- /* Link blue, underlined, always. The identity colour is the one the
67
- * whole world already reads as "this goes somewhere". */
68
52
  return (
69
53
  `<a class="tl-link" href="${esc(node.href)}" style="color:${t.link};` +
70
54
  `text-decoration:underline;overflow-wrap:anywhere;word-break:break-word;">${inlineHtml(node.children, t)}</a>`
@@ -89,7 +73,7 @@ function imagePlaceholder(node, t) {
89
73
  `<a class="tl-muted" href="${esc(node.href)}" style="color:${t.muted};text-decoration:underline;">${esc(node.href)}</a></div>`
90
74
  : "";
91
75
  return (
92
- `<div class="tl-raised" style="border:1px solid ${t.line};border-radius:${RADIUS.sm};background:${t.raised};padding:14px 16px;">` +
76
+ `<div class="tl-raised" style="border:1px solid ${t.line};border-radius:${RADIUS.sm};background:${t.raised};padding:12px 14px;">` +
93
77
  `<div class="tl-muted" style="${TYPE.tag}color:${t.muted};text-transform:uppercase;padding-bottom:6px;">Image — not loaded</div>` +
94
78
  `<div class="tl-ink" style="${TYPE.small}color:${t.ink};">${esc(label)}</div>${href}</div>`
95
79
  );
@@ -97,18 +81,16 @@ function imagePlaceholder(node, t) {
97
81
 
98
82
  /* ---------------------------------------------------------------- blocks */
99
83
 
100
- /* The declared spacing scale. A normal transition is 24; a major reading
101
- * section separates by 40; a heading always takes more space above than below. */
102
84
  const GAP = {
103
- paragraph: 16,
104
- heading: 40,
105
- subheading: 28,
106
- list: 16,
107
- code: 24,
108
- table: 24,
109
- quote: 24,
110
- rule: 24,
111
- image: 24,
85
+ paragraph: 14,
86
+ heading: 28,
87
+ subheading: 22,
88
+ list: 14,
89
+ code: 20,
90
+ table: 20,
91
+ quote: 20,
92
+ rule: 20,
93
+ image: 20,
112
94
  };
113
95
 
114
96
  export function blocksHtml(nodes, t, { first = true } = {}) {
@@ -116,7 +98,7 @@ export function blocksHtml(nodes, t, { first = true } = {}) {
116
98
  let isFirst = first;
117
99
 
118
100
  const rows = nodes.map((node) => {
119
- const gap = isFirst ? 0 : afterHeading ? 12 : GAP[gapKey(node)];
101
+ const gap = isFirst ? 0 : afterHeading ? 8 : GAP[gapKey(node)];
120
102
  isFirst = false;
121
103
  afterHeading = node.type === "heading";
122
104
  return `<tr><td style="padding:${gap}px 0 0 0;">${blockHtml(node, t)}</td></tr>`;
@@ -177,24 +159,18 @@ function onlyImage(node) {
177
159
  : null;
178
160
  }
179
161
 
180
- /* The subject owns the top of the document, so `#` is a section rather than a
181
- * competing title. Sections are where the condensed face does its work: a short
182
- * phrase at 21px over a 1px link-blue rule. */
183
162
  function headingHtml(node, t) {
184
163
  const text = inlineText(node.text, t);
185
164
  if (node.level <= 2) {
186
- return table(
187
- `<tr><td class="tl-ink" style="${TYPE.section}color:${t.ink};padding:0 0 8px 0;">${text}</td></tr>` +
188
- `<tr><td style="padding:0;"><div class="tl-hair-link" style="height:1px;background:${t.link};font-size:0;line-height:1px;">&nbsp;</div></td></tr>`,
189
- );
165
+ return `<div class="tl-ink" style="${TYPE.section}color:${t.ink};">${text}</div>`;
190
166
  }
191
- return `<div class="tl-muted" style="${TYPE.sub}color:${t.muted};">${text}</div>`;
167
+ return `<div class="tl-ink" style="${TYPE.sub}color:${t.ink};">${text}</div>`;
192
168
  }
193
169
 
194
170
  /* Fenced code with an info string takes a muted label above the field. It is how
195
171
  * you know at a glance whether you are looking at a shell, a diff or a config. */
196
172
  function codeHtml(node, t) {
197
- const lang = node.lang ? node.lang.toUpperCase() : "";
173
+ const lang = node.lang ? node.lang : "";
198
174
  const label = lang
199
175
  ? `<tr><td class="tl-muted" style="${TYPE.tag}color:${t.muted};padding:0 0 6px 0;">${esc(lang)}</td></tr>`
200
176
  : "";
@@ -207,20 +183,17 @@ function codeHtml(node, t) {
207
183
  return table(
208
184
  label +
209
185
  `<tr><td class="tl-raised" style="border:1px solid ${t.line};border-radius:${RADIUS.sm};background:${t.raised};` +
210
- `padding:14px 16px;${TYPE.code}color:${t.ink};white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word;">${body}</td></tr>`,
186
+ `padding:12px 14px;${TYPE.code}color:${t.ink};white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-all;">${body}</td></tr>`,
211
187
  );
212
188
  }
213
189
 
214
- /* No red and no green, anywhere. A diff is weighted instead: additions at full
215
- * ink and bold, removals receded, hunk headers set as labels. It survives a
216
- * monochrome print and a colour-blind reader unchanged. */
217
190
  function diffLine(line, t) {
218
191
  const safe = esc(line) || "&nbsp;";
219
192
  if (line.startsWith("@@")) {
220
193
  return `<span class="tl-muted" style="color:${t.muted};letter-spacing:.04em;">${safe}</span>`;
221
194
  }
222
195
  if (line.startsWith("+")) {
223
- return `<span class="tl-ink" style="color:${t.ink};font-weight:700;">${safe}</span>`;
196
+ return `<span class="tl-ink" style="color:${t.ink};font-weight:600;">${safe}</span>`;
224
197
  }
225
198
  return `<span class="tl-muted" style="color:${t.muted};">${safe}</span>`;
226
199
  }
@@ -250,7 +223,7 @@ function quoteHtml(node, t) {
250
223
  if (band) return bandHtml(band.label, blocksHtml(band.children, t), t);
251
224
  return table(
252
225
  `<tr><td width="1" class="tl-hair" style="background:${t.line};width:1px;font-size:0;line-height:1px;">&nbsp;</td>` +
253
- `<td class="tl-muted" style="padding:0 0 0 16px;color:${t.muted};">${quoteInner(node.children, t)}</td></tr>`,
226
+ `<td class="tl-muted" style="padding:0 0 0 14px;color:${t.muted};">${quoteInner(node.children, t)}</td></tr>`,
254
227
  );
255
228
  }
256
229
 
@@ -263,38 +236,27 @@ function quoteInner(children, t) {
263
236
  );
264
237
  }
265
238
 
266
- /* The banded box: a solid identity-plane tab over a bounded field. Bands are
267
- * told apart by the word, never by a colour — there is no warning amber and no
268
- * error red in this system, and a reader who cannot separate two hues still
269
- * reads CAUTION and ABORT perfectly. */
270
239
  export function bandHtml(label, innerHtml, t) {
271
240
  return table(
272
- `<tr><td style="padding:0;"><span class="tl-tab" style="display:inline-block;background:${t.solid};` +
273
- `color:${t.onSolid};${TYPE.chip}text-transform:uppercase;border-radius:${RADIUS.sm} ${RADIUS.sm} 0 0;padding:5px 10px;">${esc(label)}</span></td></tr>` +
274
- `<tr><td class="tl-raised" style="border:1px solid ${t.line};border-radius:0 ${RADIUS.sm} ${RADIUS.sm} ${RADIUS.sm};` +
275
- `background:${t.raised};padding:14px 16px;">${innerHtml}</td></tr>`,
241
+ `<tr><td class="tl-raised" style="border:1px solid ${t.strongLine};border-radius:${RADIUS.sm};` +
242
+ `background:${t.raised};padding:12px 14px;">` +
243
+ `<div class="tl-ink" style="${TYPE.label}color:${t.ink};padding:0 0 8px 0;">${esc(label)}</div>` +
244
+ `${innerHtml}</td></tr>`,
276
245
  );
277
246
  }
278
247
 
279
- /* Lists are tables. Real <ul>/<ol> lose their indentation in Outlook, and the
280
- * numerals belong in a fixed gutter anyway. */
281
248
  function listHtml(node, t) {
282
249
  const rows = node.items.map((item, index) => {
283
250
  const marker =
284
251
  item.checked === null
285
252
  ? node.ordered
286
- ? /* The numeral device: an oversized condensed figure indexing a real
287
- * step. Numerals are never decorative and never invented. */
288
- `<span class="tl-link" style="${TYPE.numeral}color:${t.link};">${node.start + index}</span>`
289
- : `<span class="tl-line" style="font-family:${BODY};font-size:16px;line-height:1;color:${t.line};">&#8212;</span>`
253
+ ? `<span class="tl-muted" style="font-family:${BODY};font-size:13px;line-height:1.4;color:${t.muted};">${node.start + index}.</span>`
254
+ : `<span class="tl-muted" style="font-family:${BODY};font-size:13.5px;line-height:1;color:${t.muted};">&bull;</span>`
290
255
  : checkbox(item.checked, t);
291
256
 
292
- const gutter = node.ordered ? 30 : 22;
293
- const pad = node.loose ? 6 : 3;
294
- /* A 20px numeral and a 16px body line do not share a baseline on their own,
295
- * and a checkbox is a block in a line box rather than a glyph on a baseline.
296
- * Each marker gets the offset that seats it optically. */
297
- const top = item.checked === null ? pad + (node.ordered ? 1 : 5) : pad + 5;
257
+ const gutter = node.ordered ? 24 : 18;
258
+ const pad = node.loose ? 5 : 3;
259
+ const top = item.checked === null ? pad + (node.ordered ? 2 : 4) : pad + 4;
298
260
  return (
299
261
  `<tr><td width="${gutter}" align="${node.ordered ? "right" : "left"}" valign="top" ` +
300
262
  `style="padding:${top}px 10px ${pad}px 0;line-height:1;">${marker}</td>` +
@@ -304,26 +266,21 @@ function listHtml(node, t) {
304
266
  return table(rows.join(""));
305
267
  }
306
268
 
307
- /* Completion has no colour of its own: a done item is a solid identity-plane box
308
- * with the check reversed out of it, so if a client drops the glyph the filled
309
- * box still reads as done. */
310
269
  function checkbox(checked, t) {
311
270
  const box = `display:inline-block;width:13px;height:13px;line-height:13px;text-align:center;border-radius:${RADIUS.sm};`;
312
271
  return checked
313
- ? `<span class="tl-check-on" style="${box}background:${t.solid};color:${t.onSolid};font-family:${BODY};font-size:10px;font-weight:700;">&#10003;</span>`
314
- : `<span class="tl-check-off" style="${box}border:1px solid ${t.line};">&nbsp;</span>`;
272
+ ? `<span class="tl-check-on" style="${box}background:${t.ink};color:${t.stock};font-family:${BODY};font-size:10px;font-weight:600;">&#10003;</span>`
273
+ : `<span class="tl-check-off" style="${box}border:1px solid ${t.strongLine};">&nbsp;</span>`;
315
274
  }
316
275
 
317
- /* A ledger, not a grid: condensed caps heads over a solid rule, 1px separators
318
- * between rows, no cell borders and no zebra. */
319
276
  function tableHtml(node, t) {
320
277
  const last = node.headers.length - 1;
321
278
  const head = node.headers
322
279
  .map(
323
280
  (cell, i) =>
324
281
  `<td align="${node.align[i]}" class="tl-ink" style="${TYPE.tableHead}color:${t.ink};` +
325
- `text-transform:uppercase;padding:0 ${i === last ? 0 : 14}px 8px 0;` +
326
- `border-bottom:1px solid ${t.ink};vertical-align:bottom;">${inlineText(cell, t)}</td>`,
282
+ `padding:0 ${i === last ? 0 : 12}px 7px 0;` +
283
+ `border-bottom:1px solid ${t.strongLine};vertical-align:bottom;">${inlineText(cell, t)}</td>`,
327
284
  )
328
285
  .join("");
329
286
 
@@ -334,7 +291,7 @@ function tableHtml(node, t) {
334
291
  .map(
335
292
  (cell, i) =>
336
293
  `<td align="${node.align[i]}" class="tl-ink tl-ruled" style="${TYPE.tableCell}color:${t.ink};` +
337
- `padding:9px ${i === last ? 0 : 14}px 9px 0;border-bottom:1px solid ${t.line};vertical-align:top;">` +
294
+ `padding:8px ${i === last ? 0 : 12}px 8px 0;border-bottom:1px solid ${t.line};vertical-align:top;">` +
338
295
  `${inlineText(cell, t)}</td>`,
339
296
  )
340
297
  .join("")}</tr>`,
@@ -344,4 +301,4 @@ function tableHtml(node, t) {
344
301
  return table(`<tr>${head}</tr>${body}`);
345
302
  }
346
303
 
347
- export { table as presentationTable, imagePlaceholder, DISPLAY, BODY, MONO };
304
+ export { table as presentationTable, imagePlaceholder, BODY, MONO };
@@ -2,8 +2,8 @@
2
2
  *
3
3
  * The plain-text twin is an equal document, not a stripped fallback. It comes
4
4
  * off the same tree as the HTML, so the two cannot say different things, and it
5
- * keeps the structure the HTML carries: the TLDR block, banded boxes, ledger
6
- * tables, a numbered gutter.
5
+ * keeps the structure the HTML carries: headings, callouts, ledger tables and
6
+ * list gutters. Product metadata stays below a conventional signature divider.
7
7
  *
8
8
  * Fixed 72-column measure. Wider wraps badly in the clients that show plain text
9
9
  * at all, and narrower breaks the tables.