@jossuealcala/madre 1.1.1 → 1.1.3

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 (108) hide show
  1. package/CHANGELOG.en.md +42 -1
  2. package/CHANGELOG.md +42 -1
  3. package/README.en.md +4 -4
  4. package/README.md +4 -4
  5. package/SECURITY.md +11 -6
  6. package/bin/madre.mjs +74 -11
  7. package/docs/REFERENCE.md +15 -8
  8. package/docs/SDK.md +8 -8
  9. package/docs/en/REFERENCE.md +12 -7
  10. package/docs/en/SDK.md +8 -8
  11. package/docs/en/training/README.md +1 -1
  12. package/docs/sdk/connector-module.mjs +1 -1
  13. package/docs/sdk/hello-module.mjs +1 -1
  14. package/docs/training/README.md +1 -1
  15. package/docs/training/train.sh +3 -0
  16. package/package.json +4 -2
  17. package/public/activity.js +9 -0
  18. package/public/app.js +990 -173
  19. package/public/attribution.js +9 -0
  20. package/public/brands.js +27 -13
  21. package/public/en.js +2 -3
  22. package/public/es.js +968 -258
  23. package/public/index.html +3 -0
  24. package/public/macroverso.js +24 -5
  25. package/public/manual-content.js +38 -8
  26. package/public/market-view.js +116 -9
  27. package/public/market.js +28 -2
  28. package/public/news-scenes.js +185 -0
  29. package/public/notices.js +66 -0
  30. package/public/power.js +1 -1
  31. package/public/resay.js +3 -0
  32. package/public/salas-mac.css +294 -22
  33. package/public/salas-mac.html +3 -0
  34. package/public/salas-mac.js +760 -38
  35. package/public/styles.css +393 -17
  36. package/public/tips.js +124 -0
  37. package/public/tour-chapters.js +75 -75
  38. package/public/tour.js +36 -8
  39. package/public/troubleshooting.js +215 -22
  40. package/public/welcome-scene.js +358 -0
  41. package/public/welcome.js +523 -254
  42. package/src/adapters/gemini-rest.mjs +236 -0
  43. package/src/adapters/gemini.mjs +9 -7
  44. package/src/adapters/grok.mjs +288 -0
  45. package/src/adapters/process.mjs +14 -3
  46. package/src/auth-probe.mjs +32 -0
  47. package/src/bridge/policy.mjs +1 -1
  48. package/src/capabilities.mjs +30 -0
  49. package/src/checkpoint.mjs +115 -1
  50. package/src/codex-route.mjs +113 -0
  51. package/src/credentials.mjs +46 -8
  52. package/src/dataset.mjs +21 -8
  53. package/src/embeddings.mjs +2 -2
  54. package/src/event-store.mjs +10 -2
  55. package/src/ficha.mjs +142 -0
  56. package/src/file-ops.mjs +9 -3
  57. package/src/files.mjs +36 -2
  58. package/src/github.mjs +5 -3
  59. package/src/lease.mjs +5 -0
  60. package/src/market-check.mjs +1 -1
  61. package/src/market-remote.mjs +170 -3
  62. package/src/mcp/image-server.mjs +1 -1
  63. package/src/mcp/memory-server.mjs +22 -3
  64. package/src/mcp/proxy.mjs +31 -8
  65. package/src/memory-tools.mjs +12 -2
  66. package/src/memory.mjs +44 -3
  67. package/src/models.mjs +21 -3
  68. package/src/modules/ahp.mjs +8 -3
  69. package/src/modules/bishop-exam.mjs +41 -12
  70. package/src/modules/bishop.mjs +2 -2
  71. package/src/modules/check-alone.mjs +25 -0
  72. package/src/modules/choices.mjs +12 -10
  73. package/src/modules/fetch-alone.mjs +7 -0
  74. package/src/modules/helpers.mjs +23 -5
  75. package/src/modules/image-studio.mjs +13 -27
  76. package/src/modules/index.mjs +88 -11
  77. package/src/modules/isolated.mjs +160 -0
  78. package/src/modules/ollama.mjs +35 -6
  79. package/src/modules/playwright.mjs +46 -17
  80. package/src/modules/run-alone.mjs +122 -0
  81. package/src/modules/runs.mjs +11 -8
  82. package/src/modules/sdk.mjs +4 -2
  83. package/src/mother.mjs +6 -1
  84. package/src/notices-key.mjs +8 -0
  85. package/src/notices.mjs +185 -0
  86. package/src/ollama.mjs +57 -15
  87. package/src/outbound.mjs +56 -11
  88. package/src/room/archivist.mjs +36 -5
  89. package/src/room/busy.mjs +16 -0
  90. package/src/room/context.mjs +6 -3
  91. package/src/room/control.mjs +36 -6
  92. package/src/room/copilot.mjs +22 -28
  93. package/src/room/guard.mjs +32 -2
  94. package/src/room/prompt.mjs +32 -5
  95. package/src/room/vectors.mjs +7 -1
  96. package/src/room.mjs +98 -32
  97. package/src/router.mjs +1 -1
  98. package/src/runs.mjs +39 -0
  99. package/src/runtime-detection.mjs +46 -6
  100. package/src/salas.mjs +253 -15
  101. package/src/server.mjs +686 -87
  102. package/src/service.mjs +116 -0
  103. package/src/setup-trouble.mjs +20 -1
  104. package/src/skill-check.mjs +269 -0
  105. package/src/skills-import.mjs +128 -0
  106. package/src/skills.mjs +492 -0
  107. package/src/tour.mjs +15 -4
  108. package/src/whats-new.mjs +71 -0
@@ -9,7 +9,9 @@
9
9
 
10
10
  import { browserLanguage, sessionDetail, setLanguage, t } from './i18n.js';
11
11
  import { brandOf, monogram } from './brands.js';
12
+ import { installTips } from './tips.js';
12
13
  import { SPONSORS_URL, startReviewAsk } from './review-ask.js';
14
+ import { mountNotices } from './notices.js';
13
15
  import { startTour } from './tour.js';
14
16
  import { dropStickyHover } from './touch.js';
15
17
  import { AUTHOR, AUTHOR_URL, YEAR, drawAttribution, drawColophonKeys, drawLegal } from './attribution.js';
@@ -29,6 +31,7 @@ import { trazo, trazoDrawing } from './icons.js';
29
31
  import { tellFailures } from './page-errors.js';
30
32
  import { mountActivity } from './activity.js';
31
33
  import { ensureTerms } from './terms.js';
34
+ import { createNewsScene } from './news-scenes.js';
32
35
 
33
36
  // Nothing of MADRE starts before its license and privacy notice are accepted on this computer
34
37
  // (public/terms.js, src/terms.mjs): the page waits here.
@@ -61,6 +64,8 @@ let arming = 0;
61
64
  let data = null;
62
65
  let macro = null; // the macroverse, while it is open
63
66
  let welcomed = false; // the welcome was offered this visit (public/welcome.js)
67
+ // Whether this copy is owed the invitation to a first project (2026-11-01, homeInvite), asked once.
68
+ const inviteAsk = fetch('/api/invite/project', { cache: 'no-store' }).then((response) => (response.ok ? response.json() : null)).catch(() => null);
64
69
  let welcomeSeen = null; // where the welcome is (src/tour.mjs, `welcome`), as last saved
65
70
  let agentsSeen = null; // what /api/settings said of the agents, last time it was asked
66
71
  let localSeen = null; // what /api/salas/local-ai said: the mode and which projects use the local AI
@@ -78,6 +83,7 @@ const failed = new Map(); // room id → what went wrong, said on its card
78
83
  const conversationsCount = (n) => (n === 1 ? t('1 conversation') : t('{n} conversations', { n }));
79
84
  const memoriesCount = (n) => (n === 1 ? t('1 memory') : t('{n} memories', { n }));
80
85
  const revoking = new Set(); // link ids whose row asks before revoking
86
+ const linksOpen = new Set(); // link ids unfolded in the list (2026-11-07: folded by default)
81
87
 
82
88
  // The room's looks, from this browser: the same keys the room's own page keeps (app.js, LOOKS),
83
89
  // so a choice made here is the room's too when the room is served at this address.
@@ -158,6 +164,8 @@ function applyLooks() {
158
164
  // The person's picture as this browser last knew it, before the first look is painted.
159
165
  paintCustomWall(rememberedWall());
160
166
  applyLooks();
167
+ // One small solid label for every key that explains itself (public/tips.js).
168
+ installTips();
161
169
  function saveLooks({ theme, accent, wallpaper, style, bubbles, text }) {
162
170
  // The first value of each look is the room as it always was, kept as no choice at all (app.js, saveLook).
163
171
  const keep = (key, value, first) => { if (value === first) localStorage.removeItem(key); else localStorage.setItem(key, value); };
@@ -507,7 +515,14 @@ function draw() {
507
515
  // An empty Home opens the welcome where it was left, or at the project when it was finished
508
516
  // without one; someone new meets it in place of the bonjour (public/tour.js).
509
517
  // Not for whoever updated from before 1.1.0: they meet the news, and «Add project» is on Home (2026-10-30).
510
- if (!all.length && !welcomed) { welcomed = true; void homeTour.loaded.then((answer) => { if (!answer?.owed && !answer?.upgraded) openHomeWelcome({ at: answer?.state?.welcome?.finished ? 'project' : null }); }); }
518
+ // After an update with no project yet (2026-11-01), the invitation to add one takes the welcome's place.
519
+ if (!all.length && !welcomed) {
520
+ welcomed = true;
521
+ void Promise.all([homeTour.loaded, inviteAsk]).then(([answer, invite]) => {
522
+ if (invite?.show) { void homeInvite(); return; }
523
+ if (!answer?.owed && !answer?.upgraded) openHomeWelcome({ at: answer?.state?.welcome?.finished ? 'project' : null });
524
+ });
525
+ }
511
526
  welcomeHome();
512
527
  // Home is drawn: the ground over its first frame goes (loader.js, bootDone) — unless the welcome is
513
528
  // about to open, whose opening comes first; then it goes as the welcome opens (openHomeWelcome).
@@ -959,21 +974,33 @@ const LINK_ARROW = '<svg viewBox="0 0 60 16" aria-hidden="true"><path d="M58 8H6
959
974
  const LINK_BOTH = '<svg viewBox="0 0 60 16" aria-hidden="true"><path d="M6 8h48M12 2.5 6 8l6 5.5M48 2.5 54 8l-6 5.5" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>';
960
975
  function linkRow(enlace) {
961
976
  const { source, reader } = endsOf(enlace);
962
- const node = el('article', `sm-link${revoking.has(enlace.id) ? ' revoking' : ''}`);
977
+ // Folded by default (2026-11-07): one even row per connection — the pair centred, its kind and its
978
+ // readings under it — so a person with many finds theirs without scrolling; it unfolds in place.
979
+ const node = el('details', `sm-link${revoking.has(enlace.id) ? ' revoking' : ''}`);
963
980
  node.dataset.link = enlace.id;
964
- node.append(el('span', 'sm-link-kind', source === data.salas || reader === data.salas ? t('With the Coordinator') : t('Between projects')));
981
+ node.open = linksOpen.has(enlace.id) || revoking.has(enlace.id);
982
+ node.addEventListener('toggle', () => { if (node.open) linksOpen.add(enlace.id); else linksOpen.delete(enlace.id); });
983
+ const summary = el('summary', 'sm-link-summary');
984
+ const body = el('div', 'sm-link-body');
965
985
  // Who looks up whom, as the map draws it.
966
986
  const pair = el('div', 'sm-link-pair');
967
987
  const arrow = el('span', 'sm-link-arrow');
968
988
  arrow.innerHTML = enlace.direction === 'both' ? LINK_BOTH : LINK_ARROW; // trusted: our own SVG strings
969
989
  arrow.append(el('small', null, enlace.direction === 'both' ? t('read each other') : t('looks up')));
970
- pair.append(LINK_MARK(reader), arrow, LINK_MARK(source));
990
+ const left = LINK_MARK(reader);
991
+ const right = LINK_MARK(source);
992
+ left.classList.add('left');
993
+ right.classList.add('right');
994
+ pair.append(left, arrow, right);
971
995
  // The drawing says it; the sentence is kept for whoever hears the page.
972
996
  const who = el('span');
973
997
  who.append(enlace.direction === 'both' ? sayTinted('{a} and {b} read each other', { a: enlace.rooms.a, b: enlace.rooms.b }) : sayTinted('{reader} reads from {source}', { reader, source }));
974
998
  pair.setAttribute('role', 'img');
975
999
  pair.setAttribute('aria-label', who.textContent);
976
- node.append(pair);
1000
+ summary.append(pair);
1001
+ // In order (2026-11-07): who reads whom, then what crosses, then on what terms, then the switches,
1002
+ // and at the foot how much it was read and the way out. Each part under its own small heading.
1003
+ const section = (title) => { const part = el('div', 'sm-link-part'); part.append(el('span', 'sm-link-part-title', title)); body.append(part); return part; };
977
1004
  // What crosses, until when, and whether orders go.
978
1005
  const tags = el('div', 'sm-link-tags');
979
1006
  for (const kind of enlace.kinds ?? []) {
@@ -982,15 +1009,24 @@ function linkRow(enlace) {
982
1009
  tag.append(el('i', `k-${kind}`), word.slice(0, 1).toLocaleUpperCase(language) + word.slice(1));
983
1010
  tags.append(tag);
984
1011
  }
985
- tags.append(el('span', 'sm-link-tag plain', enlace.expires ? t('until {date}', { date: new Date(enlace.expires).toLocaleDateString(language, { day: 'numeric', month: 'short' }) }) : t('no expiry')));
986
- tags.append(el('span', 'sm-link-tag plain', enlace.orders?.allowed ? t('orders up to #{n}', { n: enlace.orders.maxMode }) : t('no orders')));
1012
+ section(t('What crosses')).append(tags);
1013
+ const terms = el('div', 'sm-link-tags terms');
1014
+ terms.append(el('span', 'sm-link-tag plain', enlace.expires ? t('until {date}', { date: new Date(enlace.expires).toLocaleDateString(language, { day: 'numeric', month: 'short' }) }) : t('no expiry')));
1015
+ terms.append(el('span', 'sm-link-tag plain', enlace.orders?.allowed ? t('orders up to #{n}', { n: enlace.orders.maxMode }) : t('no orders')));
987
1016
  // D-S13: a link BISHOP signed on its own says so, so it is never mistaken for one you signed.
988
- if (enlace.signed?.by === 'bishop') tags.append(el('span', 'sm-link-tag plain', t('signed by the Coordinator')));
989
- node.append(tags);
1017
+ if (enlace.signed?.by === 'bishop') terms.append(el('span', 'sm-link-tag plain', t('signed by the Coordinator')));
1018
+ section(t('Terms')).append(terms);
990
1019
  const traffic = enlace.traffic ?? {};
991
1020
  // S-021: the last reading says who read, as the room that asked said it.
992
1021
  const last = traffic.lastAt ? (traffic.lastAgent ? t('last by @{agent} of {room}, {when}', { agent: traffic.lastAgent, room: roomName(traffic.lastRoom), when: ago(traffic.lastAt) }) : t('last {when}', { when: ago(traffic.lastAt) })) : t('none yet');
993
- node.append(el('p', 'traffic', [t('{n} reads in 24 h', { n: traffic.reads24h ?? 0 }), last].join(' · ')));
1022
+ const trafficLine = el('p', 'traffic', [t('{n} reads in 24 h', { n: traffic.reads24h ?? 0 }), last].join(' · '));
1023
+ // Under the pair, folded: what kind of connection it is and how much it was read.
1024
+ const meta = el('span', 'sm-link-meta');
1025
+ meta.append(el('b', null, source === data.salas || reader === data.salas ? t('With the Coordinator') : t('Between projects')), el('span', null, t('{n} reads in 24 h', { n: traffic.reads24h ?? 0 })));
1026
+ const dots = el('span', 'sm-link-dots');
1027
+ for (const kind of enlace.kinds ?? []) dots.append(el('i', `k-${kind}`));
1028
+ meta.append(dots);
1029
+ summary.append(meta, el('span', 'sm-link-chevron'));
994
1030
  // What else it allows, each a switch that says what it does (Fase 3e, D-S15, D-S16, D-S17).
995
1031
  const options = el('div', 'sm-link-options');
996
1032
  const option = (on, title, says, path, payload) => {
@@ -1017,11 +1053,14 @@ function linkRow(enlace) {
1017
1053
  if (reader === data.salas) option(enlace.train, t('The Coordinator learns from it'), t('What the Coordinator reads here also goes into what it is trained with.'), '/api/salas/enlaces/train', (on) => ({ id: enlace.id, train: on }));
1018
1054
  option(enlace.state, t('It shares its state'), t('Its goal, phase, next step and what is open can be read too, never its files.'), '/api/salas/enlaces/allow', (on) => ({ id: enlace.id, field: 'state', on }));
1019
1055
  option(enlace.deliver, t('It receives delivered notes'), t('Notes can be handed to it; they wait for you to accept them before entering its memory.'), '/api/salas/enlaces/allow', (on) => ({ id: enlace.id, field: 'deliver', on }));
1020
- node.append(options);
1056
+ section(t('What it allows')).append(options);
1021
1057
  const actions = el('div', 'sm-actions');
1022
1058
  if (revoking.has(enlace.id)) actions.append(el('span', 'sm-ask', t('Nothing crosses from then on.')), button('sm-btn danger small', t('Yes, cancel it'), () => revokeLink(enlace.id)), button('sm-btn ghost small', t('Keep the connection'), () => { revoking.delete(enlace.id); draw(); }));
1023
1059
  else actions.append(button('sm-btn ghost small', t('Cancel the connection'), () => { revoking.add(enlace.id); draw(); }));
1024
- node.append(actions);
1060
+ const foot = el('div', 'sm-link-foot');
1061
+ foot.append(trafficLine, actions);
1062
+ body.append(foot);
1063
+ node.append(summary, body);
1025
1064
  return node;
1026
1065
  }
1027
1066
  // How a connection works, in three steps under the sheet's title, as the project map says its own
@@ -1522,6 +1561,15 @@ const WIDGETS = {
1522
1561
  'w-live': { kind: 'live', owner: true, name: () => t('MADRE live'), about: () => t('How many copies of MADRE are on right now, and how many of this month\'s are off. Only you see this.'), size: 4, rows: 3 },
1523
1562
  'w-installs': { kind: 'installs', owner: true, name: () => t('Installs'), about: () => t('Installs, updates and uninstalls of MADRE by day, the last 30 days. Only you see this.'), size: 8, rows: 3 },
1524
1563
  'w-environments': { kind: 'environments', owner: true, name: () => t('Where MADRE runs'), about: () => t('The systems, memory, agents, projects per copy and modules of the copies this month. Only you see this.'), size: 8, rows: 5 },
1564
+ // MADRE's course (2026-11-01, src/rumbo.mjs): the variables that decide where the project goes,
1565
+ // from madre.run's funnel, GitHub and npm. Only in the author's copy run from source.
1566
+ 'w-rumbo': { kind: 'rumbo', owner: true, name: () => t('MADRE\'s course'), about: () => t('The variables that decide where MADRE goes: from a visit to a habit, what the numbers decide, and GitHub and npm. Only you see this.'), size: 12, sizes: [12] },
1567
+ // The author's error log (2026-11-05, src/madre-logs.mjs): ~/madre-logs as agents add and close
1568
+ // errors, read from this Mac's disk every few seconds. Only in the author's copy run from source.
1569
+ 'w-madrelogs': { kind: 'madrelogs', owner: true, every: 5000, name: () => 'madre-logs', about: () => t('MADRE\'s errors as they are added and fixed: what is still to fix by class and type, what waits to be verified, and the last changes. Read from this Mac; only you see this.'), size: 8, rows: 8 },
1570
+ // The author's notices (Q-11, src/notices.mjs): written here, signed on this computer, read by every
1571
+ // copy. Only in the author's copy run from source, with the token and the notices' key.
1572
+ 'w-notices': { kind: 'notices', owner: true, every: 60000, name: () => t('Notices to every copy'), about: () => t('Write a notice that every copy of MADRE shows, with or without diagnostics: signed on this computer, read from madre.run. Only you see this.'), size: 8, rows: 0 },
1525
1573
  'w-models': { kind: 'models', name: () => t('Local models'), about: () => t('Ollama, its models, and how close each project is to its own.'), size: 4, rows: 3 },
1526
1574
  // Your agenda (2026-10-28): every project's reminders by when they are due — late, today, tomorrow,
1527
1575
  // this week, later —, each settled here, and a new one written as you would say it. Read from the
@@ -1553,6 +1601,9 @@ const TILE_ICONS = {
1553
1601
  'w-live': trazo('broadcast'),
1554
1602
  'w-installs': trazo('download'),
1555
1603
  'w-environments': trazo('globe'),
1604
+ 'w-rumbo': trazo('trending'),
1605
+ 'w-madrelogs': trazo('list'),
1606
+ 'w-notices': trazo('broadcast'),
1556
1607
  };
1557
1608
  const tileIcon = (id) => { const box = el('span', 'sm-tile-icon'); box.innerHTML = TILE_ICONS[id] ?? ''; return box; }; // trusted: our own SVG strings
1558
1609
  const known = (id) => Object.hasOwn(HOME_TILES, id) || Object.hasOwn(WIDGETS, id);
@@ -1963,6 +2014,10 @@ function meter(value, tone = null) {
1963
2014
  const toneFor = (share) => (share >= 0.85 ? 'hot' : share >= 0.6 ? 'warm' : null);
1964
2015
  const OS_WORDS = { darwin: 'macOS', linux: 'Linux', win32: 'Windows', other: () => t('other') };
1965
2016
  const osWord = (name) => { const word = OS_WORDS[name] ?? name; return typeof word === 'function' ? word() : word; };
2017
+ // What is being written in the notices' widget, kept across its re-readings (it reads every minute).
2018
+ const freshNoticeDraft = () => ({ level: 'info', titleEs: '', titleEn: '', bodyEs: '', bodyEn: '', link: '', min: '', max: '', os: [], days: 7 });
2019
+ const noticeDraft = freshNoticeDraft();
2020
+ const noticeFlash = { text: '' };
1966
2021
  const WIDGET_PAINT = {
1967
2022
  // The agenda: what is late and what is today first, then tomorrow, this week and later; a line per
1968
2023
  // reminder with its project and its keys; and a box for a new one, in the person's own words.
@@ -2117,7 +2172,7 @@ const WIDGET_PAINT = {
2117
2172
  const SYSTEMS = { darwin: 'macOS', linux: 'Linux', win32: 'Windows', wsl: 'WSL', other: t('other') };
2118
2173
  const CHANNELS = { npx: 'npx', global: t('installed (npm -g)'), project: t('inside a project'), source: t('from source') };
2119
2174
  const LANGS = { es: t('Spanish'), en: t('English') };
2120
- const AGENT_NAMES = { claude: 'Claude', codex: 'Codex', gemini: 'Gemini', opencode: 'OpenCode', cursor: 'Cursor' };
2175
+ const AGENT_NAMES = { claude: 'Claude', codex: 'Codex', gemini: 'Gemini', opencode: 'OpenCode', cursor: 'Cursor', grok: 'Grok' };
2121
2176
  const said = (list, words = {}) => (list ?? []).filter((one) => one.name !== '?').slice(0, 5).map((one) => `${words[one.name] ?? one.name} ${share(one.n)}`).join(' · ') || '—';
2122
2177
  const lines = el('div', 'sm-usage-lines sm-env-lines');
2123
2178
  for (const [label, text] of [
@@ -2153,6 +2208,341 @@ const WIDGET_PAINT = {
2153
2208
  }
2154
2209
  body.append(box);
2155
2210
  },
2211
+ // MADRE's course (2026-11-01, src/rumbo.mjs): the week's north star, the funnel from a visit to a
2212
+ // habit with its leak marked, what the numbers decide, every variable with how sure it is, the
2213
+ // weeks, and the project's record on GitHub and npm. Read again every 20 s; each source keeps its
2214
+ // own clock on the server.
2215
+ // The author's notices (Q-11): write one for every copy, see how it will read, send it, and take
2216
+ // back one that is out. Only in the author's copy run from source (src/server.mjs, ownerCanNotify).
2217
+ notices(body, reading, { again } = {}) {
2218
+ const d = noticeDraft;
2219
+ const LEVEL_NAMES = { info: () => t('Information'), important: () => t('Important'), security: () => t('Security') };
2220
+ const form = el('form', 'sm-notice-form');
2221
+ const field = (label, node) => { const row = el('label', 'sm-notice-field'); if (!node.matches('div')) node.setAttribute('aria-label', label); row.append(el('small', null, label), node); return row; };
2222
+ const input = (key, max, placeholder = '') => { const node = el('input'); node.type = 'text'; node.maxLength = max; node.value = d[key] ?? ''; node.placeholder = placeholder; node.addEventListener('input', () => { d[key] = node.value; preview(); }); return node; };
2223
+ const area = (key, max) => { const node = el('textarea'); node.maxLength = max; node.rows = 3; node.value = d[key] ?? ''; node.addEventListener('input', () => { d[key] = node.value; preview(); }); return node; };
2224
+ const level = el('select');
2225
+ for (const one of ['info', 'important', 'security']) { const option = el('option', null, LEVEL_NAMES[one]()); option.value = one; option.selected = d.level === one; level.append(option); }
2226
+ level.addEventListener('change', () => { d.level = level.value; preview(); });
2227
+ const days = el('select');
2228
+ for (const n of [1, 3, 7, 14, 30]) { const option = el('option', null, n === 1 ? t('1 day') : t('{n} days', { n })); option.value = String(n); option.selected = d.days === n; days.append(option); }
2229
+ days.addEventListener('change', () => { d.days = Number(days.value); });
2230
+ const systems = el('div', 'sm-notice-systems');
2231
+ for (const [id, name] of [['darwin', 'macOS'], ['linux', 'Linux'], ['win32', 'Windows'], ['wsl', 'WSL']]) {
2232
+ const box = el('input'); box.type = 'checkbox'; box.checked = d.os.includes(id);
2233
+ box.addEventListener('change', () => { d.os = box.checked ? [...new Set([...d.os, id])] : d.os.filter((one) => one !== id); });
2234
+ const label = el('label'); label.append(box, ` ${name}`); systems.append(label);
2235
+ }
2236
+ form.append(
2237
+ field(t('Level'), level),
2238
+ field(t('Title · Spanish'), input('titleEs', 80)), field(t('Title · English'), input('titleEn', 80)),
2239
+ field(t('Text · Spanish'), area('bodyEs', 400)), field(t('Text · English'), area('bodyEn', 400)),
2240
+ field(t('Link (madre.run only, optional)'), input('link', 200, 'https://madre.run/…')),
2241
+ field(t('From version (optional)'), input('min', 12, '1.1.3')), field(t('Up to version (optional)'), input('max', 12)),
2242
+ field(t('Systems (none: all)'), systems), field(t('Shows for'), days),
2243
+ );
2244
+ // How it will read, in both languages, in the same card every copy draws (public/notices.js).
2245
+ const look = el('div', 'sm-notice-preview');
2246
+ function preview() {
2247
+ look.replaceChildren();
2248
+ for (const [lang, title, words] of [['es', d.titleEs, d.bodyEs], ['en', d.titleEn, d.bodyEn]]) {
2249
+ const card = el('section', `madre-notice is-${d.level}`);
2250
+ const box = el('div', 'madre-notice-words');
2251
+ box.append(el('small', 'madre-notice-kind', `${lang.toUpperCase()} · ${LEVEL_NAMES[d.level]()}`), el('b', 'madre-notice-title', title || '—'), el('p', 'madre-notice-body', words || '—'));
2252
+ card.append(box);
2253
+ look.append(card);
2254
+ }
2255
+ }
2256
+ preview();
2257
+ // Said once, after the widget reads again with what was just sent.
2258
+ const said = el('small', 'sm-notice-said', noticeFlash.text);
2259
+ noticeFlash.text = '';
2260
+ let armed = false;
2261
+ const send = button('sm-btn primary small', t('Send to every copy'), async (event) => {
2262
+ event.preventDefault();
2263
+ if (!armed) { armed = true; send.textContent = t('Sure? It reaches every copy · Send'); setTimeout(() => { armed = false; send.textContent = t('Send to every copy'); }, 5000); return; }
2264
+ send.disabled = true;
2265
+ const now = new Date();
2266
+ const stamp = now.toISOString().slice(0, 10).replaceAll('-', '');
2267
+ const slug = String(d.titleEs || d.titleEn).normalize('NFD').replace(/[̀-ͯ]/g, '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 30) || 'aviso';
2268
+ const notice = {
2269
+ id: `${stamp}-${slug}`.slice(0, 40).replace(/-+$/, ''), level: d.level,
2270
+ title: { es: d.titleEs.trim(), en: d.titleEn.trim() }, body: { es: d.bodyEs.trim(), en: d.bodyEn.trim() },
2271
+ link: d.link.trim() || null, to: { min: d.min.trim() || null, max: d.max.trim() || null, os: d.os },
2272
+ from: now.toISOString(), until: new Date(now.getTime() + d.days * 86_400_000).toISOString(),
2273
+ };
2274
+ const answer = await fetch('/api/owner/notices', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ notice }) }).then(async (response) => ({ ok: response.ok, body: await response.json().catch(() => ({})) })).catch(() => ({ ok: false, body: {} }));
2275
+ if (answer.ok) { Object.assign(noticeDraft, freshNoticeDraft()); noticeFlash.text = t('Sent: every copy shows it within 15 minutes.'); again?.(); }
2276
+ else { said.textContent = answer.body.error ?? t('It was not sent.'); send.disabled = false; }
2277
+ });
2278
+ form.append(look, send, said);
2279
+ // What is out now, with its way back.
2280
+ const out = el('div', 'sm-notice-list');
2281
+ const list = reading.notices ?? [];
2282
+ if (!reading.read) out.append(el('p', 'sm-hint', t('madre.run could not be read just now.')));
2283
+ else if (!list.length) out.append(el('p', 'sm-hint', t('No notice is out.')));
2284
+ for (const one of list) {
2285
+ const row = el('div', `sm-notice-row is-${one.level}`);
2286
+ const when = one.when === 'later' ? t('from {date}', { date: new Date(one.from).toLocaleString() }) : one.when === 'over' ? t('ended') : t('until {date}', { date: new Date(one.until).toLocaleString() });
2287
+ row.append(el('b', null, one.title?.[language] ?? one.title?.es ?? one.id), el('small', null, `${LEVEL_NAMES[one.level]()} · ${when}`));
2288
+ let sure = false;
2289
+ const back = button('sm-btn small', t('Take back'), async () => {
2290
+ if (!sure) { sure = true; back.textContent = t('Sure? Take back'); setTimeout(() => { sure = false; back.textContent = t('Take back'); }, 5000); return; }
2291
+ back.disabled = true;
2292
+ const ok = await fetch('/api/owner/notices/retire', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: one.id }) }).then((response) => response.ok).catch(() => false);
2293
+ if (ok) again?.(); else { back.disabled = false; back.textContent = t('Take back'); }
2294
+ });
2295
+ row.append(back);
2296
+ out.append(row);
2297
+ }
2298
+ if (reading.unverified) out.append(el('p', 'sm-hint', t('{n} served by madre.run do not carry your signature: no copy shows them.', { n: reading.unverified })));
2299
+ body.append(out, form);
2300
+ },
2301
+ rumbo(body, reading) {
2302
+ if (!reading.available) { body.append(el('p', 'sm-hint', reading.status ? t('madre.run answered {status}.', { status: reading.status }) : t('madre.run could not be reached.'))); return; }
2303
+ const n = (value) => (value === null || value === undefined ? '—' : Number(value).toLocaleString());
2304
+ const signed = (value) => (value === null || value === undefined ? '—' : `${value > 0 ? '+' : ''}${Math.round(value * 100)}%`);
2305
+ const shortDay = (day) => new Date(`${day}T12:00:00Z`).toLocaleDateString(document.documentElement.lang === 'en' ? 'en-US' : 'es-MX', { day: 'numeric', month: 'short' });
2306
+ const section = (title, line) => { const head = el('div', 'sm-rumbo-head'); head.append(el('b', null, title)); if (line) head.append(el('small', null, line)); return head; };
2307
+ const byId = Object.fromEntries((reading.variables ?? []).map((one) => [one.id, one]));
2308
+
2309
+ // The north star: copies that asked an AI something this week.
2310
+ const north = reading.north;
2311
+ if (north) {
2312
+ const lead = el('div', 'sm-usage-lead');
2313
+ const change = north.before ? (north.activated - north.before) / north.before : null;
2314
+ const trend = change === null ? t('the first week the diagnostics can tell') : change === 0 ? t('same as the week before') : change > 0 ? t('{n}% more than the week before', { n: Math.round(change * 100) }) : t('{n}% fewer than the week before', { n: Math.round(-change * 100) });
2315
+ lead.append(el('b', 'sm-w-big', n(north.activated)), el('span', null, t('copies asked an AI something this week')), el('small', `sm-usage-trend${change > 0 ? ' up' : change < 0 ? ' down' : ''}`, `${trend} · ${t('{active} copies on this week, {fresh} of them new', { active: n(north.active), fresh: n(north.new) })}`));
2316
+ body.append(lead);
2317
+ }
2318
+
2319
+ const grid = el('div', 'sm-rumbo');
2320
+ const left = el('div', 'sm-rumbo-col');
2321
+ const right = el('div', 'sm-rumbo-col');
2322
+ grid.append(left, right);
2323
+ body.append(grid);
2324
+
2325
+ // THE FUNNEL: each step against the one before it; the leak in red.
2326
+ const LEAK = { ready: 'ready', firstProject: 'used', readyToUse: 'used', d1: 'back', habit: 'habit' };
2327
+ const leak = LEAK[(reading.decisions ?? []).find((one) => one.id === 'bottleneck')?.verdict] ?? null;
2328
+ const STAGES = {
2329
+ visits: [t('GitHub visitors'), t('people, 14 days')],
2330
+ downloads: [t('npm downloads'), t('14 days, mirrors included')],
2331
+ new: [t('New copies'), t('30 days')],
2332
+ told: [t('With diagnostics'), t('1.1.0 or newer')],
2333
+ ready: [t('An AI ready'), null],
2334
+ used: [t('Asked an AI'), null],
2335
+ back: [t('Came back another day'), null],
2336
+ habit: [t('Used it on 2 days'), null],
2337
+ };
2338
+ const funnel = el('div', 'sm-rumbo-funnel');
2339
+ const stages = (reading.funnel ?? []).filter((one) => one.n !== null);
2340
+ const top = Math.max(1, ...stages.filter((one) => !one.side).map((one) => one.n));
2341
+ let before = null;
2342
+ for (const stage of stages) {
2343
+ const [label, line] = STAGES[stage.id] ?? [stage.id, null];
2344
+ const row = el('div', `sm-rumbo-stage${stage.side ? ' side' : ''}${leak === stage.id ? ' is-leak' : ''}`);
2345
+ const words = el('span', 'sm-rumbo-stage-words');
2346
+ words.append(el('b', null, label));
2347
+ const of = stage.of ? t('of {n} at least a day old', { n: n(stage.of) }) : line;
2348
+ if (of) words.append(el('small', null, of));
2349
+ const base = stage.of ?? before;
2350
+ const share = base && !stage.side && !['visits', 'new'].includes(stage.id) ? stage.n / base : null;
2351
+ row.append(words, meter(stage.side ? stage.n / Math.max(stage.n, top) : stage.n / top, leak === stage.id ? 'hot' : null), el('b', 'sm-rumbo-n', n(stage.n)), el('small', 'sm-rumbo-pct', share === null ? '' : `${Math.round(share * 100)}%`));
2352
+ if (leak === stage.id) row.title = t('The leak to fix first');
2353
+ funnel.append(row);
2354
+ if (!stage.side && stage.id !== 'visits') before = stage.n;
2355
+ }
2356
+ left.append(section(t('From a visit to a habit'), t('% is of the step before')), funnel);
2357
+
2358
+ // WHAT THE NUMBERS DECIDE.
2359
+ const pctOf = (value) => (value === null || value === undefined ? '—' : `${Math.round(value * 100)}%`);
2360
+ const BARS = {
2361
+ activatedWeek: (one) => t('{value} of {need} copies asking an AI a week', { value: n(one.value), need: n(one.need) }),
2362
+ d7: (one) => t('{value} of {need} back after 7 days', { value: pctOf(one.value), need: pctOf(one.need) }),
2363
+ habit: (one) => t('{value} of {need} using it on 2 days', { value: pctOf(one.value), need: pctOf(one.need) }),
2364
+ heavy: (one) => t('{value} of {need} with 2 projects or more', { value: pctOf(one.value), need: pctOf(one.need) }),
2365
+ weeksGrowing: (one) => t('{value} of {need} weeks growing in a row', { value: n(one.value), need: n(one.need) }),
2366
+ };
2367
+ const SAYS = {
2368
+ bottleneck: [t('Where people are lost'), (d) => ({
2369
+ ready: t('Setting up an AI: only {pct} of new copies get one ready. The way to a first AI is the leak to fix first.', { pct: pctOf(d.figures.value) }),
2370
+ firstProject: t('Opening a project: {n} of {total} copies never opened one. Without a project there is nothing to ask; the way to a first project is the leak to fix first.', { n: n(d.figures.noProject), total: n(d.figures.projectsKnown) }),
2371
+ readyToUse: t('The first question: {pct} of the copies with an AI ready never asked it anything.', { pct: pctOf(1 - (d.figures.value ?? 0)) }),
2372
+ d1: t('Coming back: only {pct} return after the first day.', { pct: pctOf(d.figures.value) }),
2373
+ habit: t('Habit: only {pct} used an AI on two days or more.', { pct: pctOf(d.figures.value) }),
2374
+ })[d.verdict]],
2375
+ focus: [t('Product or reach'), (d) => ({
2376
+ product: t('Product first: {used} of new copies ask an AI something and {d1} come back. More visitors now would only fill the leak.', { used: pctOf(d.figures.used), d1: pctOf(d.figures.d1) }),
2377
+ reach: t('Reach: new copies use it and come back, but the week did not grow. Time to tell more people.'),
2378
+ both: t('Both hold: copies use it, come back and the week grows.'),
2379
+ })[d.verdict]],
2380
+ windows: [t('Windows and the native app'), (d) => ({
2381
+ priority: t('{share} of new copies come from Windows, and {win} of them ask an AI (the rest, {rest}). Windows is the main door: the native app weighs on the course.', { share: pctOf(d.figures.share), win: pctOf(d.figures.winUse), rest: pctOf(d.figures.restUse) }),
2382
+ relevant: t('{share} of new copies come from Windows ({win} ask an AI; the rest, {rest}).', { share: pctOf(d.figures.share), win: pctOf(d.figures.winUse), rest: pctOf(d.figures.restUse) }),
2383
+ minor: t('Windows is {share} of new copies: not the main door yet.', { share: pctOf(d.figures.share) }),
2384
+ })[d.verdict]],
2385
+ pro: [t('Charging for MADRE Pro'), (d) => ({
2386
+ ready: t('The four bars are met: there is a base to charge for Pro.'),
2387
+ close: t('{met} of 4 bars met.', { met: d.figures.met }),
2388
+ early: t('Not yet: {met} of 4 bars met.', { met: d.figures.met }),
2389
+ })[d.verdict]],
2390
+ invest: [t('Traction to show'), (d) => ({
2391
+ ready: t('Growing week after week with people who stay: there is traction to show.'),
2392
+ waiting: t('It takes two weeks with diagnostics to tell whether it grows week after week.'),
2393
+ close: t('{met} of 3 bars met.', { met: d.figures.met }),
2394
+ early: t('Not yet: {met} of 3 bars met.', { met: d.figures.met }),
2395
+ })[d.verdict]],
2396
+ english: [t('English'), (d) => ({
2397
+ invest: t('{share} of copies speak English: worth building for it.', { share: pctOf(d.figures.share) }),
2398
+ keep: t('{share} of copies speak English: keep it working, Spanish leads.', { share: pctOf(d.figures.share) }),
2399
+ spanish: t('{share} of copies speak English: Spanish is where MADRE is used.', { share: pctOf(d.figures.share) }),
2400
+ })[d.verdict]],
2401
+ quality: [t('Failures'), (d) => ({
2402
+ fix: t('{share} of copies met a failure ({k} of {n}): fix before spreading MADRE further.', { share: pctOf(d.figures.value), k: n(d.figures.k), n: n(d.figures.n) }),
2403
+ watch: t('{share} of copies met a failure ({k} of {n}): keep an eye on MADRE errors.', { share: pctOf(d.figures.value), k: n(d.figures.k), n: n(d.figures.n) }),
2404
+ fine: t('{share} of copies met a failure: it holds up.', { share: pctOf(d.figures.value) }),
2405
+ })[d.verdict]],
2406
+ };
2407
+ const decisions = el('div', 'sm-rumbo-decisions');
2408
+ for (const one of reading.decisions ?? []) {
2409
+ const [question, say] = SAYS[one.id] ?? [];
2410
+ if (!question) continue;
2411
+ const row = el('div', `sm-rumbo-decision is-${one.signal}`);
2412
+ const words = el('div', 'sm-rumbo-decision-words');
2413
+ words.append(el('b', null, question), el('span', null, say(one) ?? ''));
2414
+ if (one.figures?.bars) {
2415
+ const chips = el('div', 'sm-rumbo-bars');
2416
+ for (const bar of one.figures.bars) chips.append(el('small', bar.met ? 'met' : null, `${bar.met ? '✓' : '·'} ${BARS[bar.id]?.(bar) ?? bar.id}`));
2417
+ words.append(chips);
2418
+ }
2419
+ row.append(el('i', 'sm-rumbo-dot'), words);
2420
+ decisions.append(row);
2421
+ }
2422
+ right.append(section(t('What the numbers say'), t('Green holds, amber to watch, red to act on')), decisions);
2423
+
2424
+ // THE VARIABLES, each with its band: where the true figure lies nine times out of ten.
2425
+ const NAMES = {
2426
+ ready: t('New copies with an AI ready'),
2427
+ used: t('New copies that asked an AI'),
2428
+ readyToUse: t('With an AI ready, asked it'),
2429
+ firstProject: t('Copies with a project'),
2430
+ d1: t('Back after a day'),
2431
+ d7: t('Back after 7 days'),
2432
+ habit: t('Used it on 2 days or more'),
2433
+ growth: t('Copies asking an AI, week on week'),
2434
+ newGrowth: t('New copies, week on week'),
2435
+ starGrowth: t('Stars, week on week'),
2436
+ starRate: t('Stars per GitHub visitor'),
2437
+ failing: t('Copies that met a failure'),
2438
+ uninstall: t('Uninstalls per install'),
2439
+ windowsShare: t('New copies from Windows'),
2440
+ englishShare: t('Copies in English'),
2441
+ coverage: t('New copies with diagnostics'),
2442
+ topSource: t('Visitors from the top source'),
2443
+ };
2444
+ const GROUPS = { activation: t('Activation'), retention: t('Retention'), momentum: t('Momentum'), quality: t('Quality'), market: t('Market') };
2445
+ const SURE = { high: t('sure'), medium: t('fairly sure'), low: t('small sample') };
2446
+ const table = el('div', 'sm-rumbo-vars');
2447
+ for (const [group, title] of Object.entries(GROUPS)) {
2448
+ const mine = (reading.variables ?? []).filter((one) => one.group === group);
2449
+ if (!mine.length) continue;
2450
+ table.append(el('span', 'sm-rumbo-group', title));
2451
+ for (const one of mine) {
2452
+ const row = el('div', `sm-rumbo-var is-${one.signal}`);
2453
+ const name = one.id === 'topSource' && one.source ? `${NAMES[one.id]} · ${one.source}` : NAMES[one.id] ?? one.id;
2454
+ const value = one.kind === 'change' ? signed(one.value) : pctOf(one.value);
2455
+ const band = el('span', 'sm-rumbo-band');
2456
+ if (one.kind === 'rate' && one.interval) {
2457
+ const fill = el('i');
2458
+ fill.style.left = `${one.interval.low * 100}%`;
2459
+ fill.style.width = `${Math.max(1, (one.interval.high - one.interval.low) * 100)}%`;
2460
+ const dot = el('b');
2461
+ dot.style.left = `${(one.value ?? 0) * 100}%`;
2462
+ band.append(fill, dot);
2463
+ if (one.threshold) for (const at of [one.threshold.bad, one.threshold.good]) { const tick = el('em'); tick.style.left = `${at * 100}%`; band.append(tick); }
2464
+ band.title = t('Between {low} and {high}, nine times out of ten', { low: pctOf(one.interval.low), high: pctOf(one.interval.high) });
2465
+ }
2466
+ const count = one.kind === 'change' ? t('{now} vs {before}', { now: n(one.now), before: n(one.before) }) : t('{k} of {n}', { k: n(one.k), n: n(one.n) });
2467
+ row.append(el('i', 'sm-rumbo-dot'), el('span', 'sm-rumbo-var-name', name), el('b', 'sm-rumbo-n', value), band, el('small', null, `${count} · ${SURE[one.confidence] ?? ''}`));
2468
+ if (one.threshold) row.title = one.threshold.lower ? t('Good at {good} or less, red over {bad}', { good: pctOf(one.threshold.good), bad: pctOf(one.threshold.bad) }) : one.kind === 'change' ? t('Good from {good}, red under {bad}', { good: signed(one.threshold.good), bad: signed(one.threshold.bad) }) : t('Good from {good}, red under {bad}', { good: pctOf(one.threshold.good), bad: pctOf(one.threshold.bad) });
2469
+ table.append(row);
2470
+ }
2471
+ }
2472
+ body.append(section(t('The variables'), t('The band is where the true figure lies nine times out of ten; the ticks, where it turns amber and green')), table);
2473
+
2474
+ // THE WEEKS: on, new, and the ones that asked an AI.
2475
+ const weeks = (reading.weeks ?? []).filter((one, i, all) => one.active || all.slice(0, i).some((before) => before.active));
2476
+ const lower = el('div', 'sm-rumbo');
2477
+ if (weeks.length) {
2478
+ const peak = Math.max(1, ...weeks.map((one) => one.active));
2479
+ const chart = el('div', 'sm-rumbo-weeks');
2480
+ chart.setAttribute('role', 'img');
2481
+ chart.setAttribute('aria-label', t('Copies on, new and asking an AI, week by week'));
2482
+ for (const one of weeks) {
2483
+ const week = el('span');
2484
+ for (const [field, tone] of [['active', 'on'], ['new', 'new'], ['activated', 'used']]) {
2485
+ const bar = el('i', tone);
2486
+ bar.style.setProperty('--h', String(one[field] / peak));
2487
+ week.append(bar);
2488
+ }
2489
+ week.append(el('small', null, shortDay(one.start)));
2490
+ week.title = t('Week of {day}: {active} on · {fresh} new · {used} asked an AI', { day: shortDay(one.start), active: one.active, fresh: one.new, used: one.activated });
2491
+ chart.append(week);
2492
+ }
2493
+ const box = el('div', 'sm-rumbo-col');
2494
+ const legend = el('small', 'sm-usage-legend');
2495
+ legend.append(el('i', 'is-on'), t('on'), el('i', 'is-new'), t('new'), el('i', 'is-used'), t('asked an AI'));
2496
+ box.append(section(t('Week by week'), null), chart, legend);
2497
+ lower.append(box);
2498
+ }
2499
+
2500
+ // THE RECORD: GitHub and npm since the start.
2501
+ const record = reading.record ?? {};
2502
+ const facts = el('div', 'sm-usage-lines sm-rumbo-record');
2503
+ const lines = [];
2504
+ if (record.stars !== null && record.stars !== undefined) lines.push([t('Stars'), t('{n} · {week} this week · {forks} forks', { n: n(record.stars), week: n(record.stars7), forks: n(record.forks) })]);
2505
+ if (record.visits) lines.push([t('GitHub, 14 days'), t('{v} visits from {u} people · {c} clones', { v: n(record.visits.count), u: n(record.visits.uniques), c: n(record.clones?.count) })]);
2506
+ if (record.installer) lines.push([t('Windows installer'), t('{n} downloads from GitHub', { n: n(record.installer.total) })]);
2507
+ if (record.npm) lines.push([t('npm'), t('{week} last week · {total} in 90 days · {top}', { week: n(record.npm.lastWeek), total: n(record.npm.total), top: (record.npm.byVersion ?? []).slice(0, 3).map((one) => `${one.version} ${n(one.n)}`).join(' · ') })]);
2508
+ const sources = byId.topSource?.sources ?? [];
2509
+ if (sources.length) lines.push([t('Visitors come from'), sources.map((one) => `${one.name} ${n(one.n)}`).join(' · ')]);
2510
+ for (const [label, said] of lines) {
2511
+ const row = el('div', 'sm-w-line');
2512
+ row.append(el('b', null, label), el('small', null, said));
2513
+ facts.append(row);
2514
+ }
2515
+ // Stars by day since the first one: the project's own history.
2516
+ const stars = record.starsByDay ?? [];
2517
+ const box = el('div', 'sm-rumbo-col');
2518
+ box.append(section(t('GitHub and npm'), null), facts);
2519
+ if (stars.length) {
2520
+ const first = Date.parse(`${stars[0].day}T12:00:00Z`);
2521
+ const span = Math.max(1, Math.round((Date.now() - first) / 86_400_000) + 1);
2522
+ const perDay = new Map(stars.map((one) => [one.day, one.n]));
2523
+ const values = Array.from({ length: span }, (_, i) => perDay.get(new Date(first + i * 86_400_000).toISOString().slice(0, 10)) ?? 0);
2524
+ const peak = Math.max(1, ...values);
2525
+ const strip = el('div', 'sm-rumbo-strip');
2526
+ strip.style.setProperty('--days', String(span));
2527
+ strip.setAttribute('role', 'img');
2528
+ strip.setAttribute('aria-label', t('Stars each day since the first'));
2529
+ values.forEach((value, i) => { const bar = el('i'); bar.style.setProperty('--h', String(value / peak)); bar.title = `${shortDay(new Date(first + i * 86_400_000).toISOString().slice(0, 10))}: ${value}`; strip.append(bar); });
2530
+ const axis = el('div', 'sm-usage-axis');
2531
+ axis.append(el('small', null, shortDay(stars[0].day)), el('small', null, t('stars each day')), el('small', null, t('today')));
2532
+ box.append(strip, axis);
2533
+ }
2534
+ lower.append(box);
2535
+ body.append(lower);
2536
+
2537
+ // Where each figure came from, and when.
2538
+ const said = reading.sources ?? {};
2539
+ const when = (one) => (one?.at ? ago(one.at) : t('never'));
2540
+ const foot = el('small', 'sm-w-foot', t('Read: madre.run {a} · GitHub {b} · npm {c}', { a: when(said.madre), b: when(said.github), c: when(said.npm) }));
2541
+ body.append(foot);
2542
+ if (said.madre?.failed && !said.madre.at) body.append(el('p', 'sm-hint', t('madre.run does not give the funnel yet (it answered {status}): publish the site so it has /api/rumbo.', { status: said.madre.status || '—' })));
2543
+ else if (said.madre?.failed) body.append(el('p', 'sm-hint', t('madre.run did not answer just now: these are its last figures.')));
2544
+ if (!said.github?.at) body.append(el('p', 'sm-hint', t('GitHub is read with your gh session: sign in with gh auth login to see stars and visits.')));
2545
+ },
2156
2546
  usage(body, reading) {
2157
2547
  if (!reading.available) { body.append(el('p', 'sm-hint', reading.status ? t('madre.run answered {status}.', { status: reading.status }) : t('madre.run could not be reached.'))); return; }
2158
2548
  const n = (value) => Number(value ?? 0).toLocaleString();
@@ -2241,6 +2631,119 @@ const WIDGET_PAINT = {
2241
2631
  // What fails in every copy, the widest first (2026-10-28). Each with what it is (its MU code when
2242
2632
  // Diagnostics knows it), how many copies and times, which versions and systems, MADRE's own lines
2243
2633
  // it went through, and the author's word on it.
2634
+ // madre-logs (2026-11-05): what is to fix, grouped by level (P0 and P1 first), each error in a row
2635
+ // of its own: id and level on the left, what happens and its state, then its class, type and
2636
+ // origin as tags. Then what waits to be verified, folded, and what the agents saved last.
2637
+ madrelogs(body, reading) {
2638
+ const { counts } = reading;
2639
+ const lead = el('div', 'sm-logs-lead');
2640
+ const figure = (n, words, tone) => { const one = el('div', `sm-logs-fig${tone ? ` ${tone}` : ''}`); one.append(el('b', null, String(n)), el('span', null, words)); return one; };
2641
+ lead.append(figure(counts.toFix, t('to fix'), counts.toFix ? 'is-due' : ''), figure(counts.inProgress, t('in progress'), counts.inProgress ? 'is-busy' : ''), figure(counts.toVerify, t('to verify')), figure(counts.verified, t('verified')));
2642
+ body.append(lead);
2643
+ const tags = (label, list) => {
2644
+ const row = el('div', 'sm-logs-tally');
2645
+ row.append(el('span', 'sm-logs-tally-label', label));
2646
+ const box = el('div', 'sm-logs-chips');
2647
+ for (const one of list) box.append(el('span', 'sm-logs-chip', `${one.name} ${one.n}`));
2648
+ row.append(box);
2649
+ return row;
2650
+ };
2651
+ // Who is working now (madre-logs' EN-CURSO.md): Claude, Codex and Antigravity each with its badge.
2652
+ const AGENTS = { claude: 'Claude', codex: 'Codex', antigravity: 'Antigravity' };
2653
+ // Whoever the row names, in its own words when they say more than the agent's name: the author
2654
+ // works with two Claude accounts (2026-11-08) and «claude-personal» is which one.
2655
+ const badge = (agent, who) => {
2656
+ const said = String(who ?? '').split('·')[0].trim();
2657
+ const known = AGENTS[agent] ?? null;
2658
+ return el('span', `sm-logs-agent ag-${agent ?? 'other'}`, said && said.toLowerCase() !== (known ?? '').toLowerCase() ? said : known ?? said);
2659
+ };
2660
+ const loose = reading.unregistered ?? [];
2661
+ if (reading.working?.length || loose.length) {
2662
+ const now = el('section', 'sm-logs-group sm-logs-working');
2663
+ const head = el('header', 'sm-logs-group-head');
2664
+ head.append(el('span', null, t('Working now')), el('small', null, String((reading.working?.length ?? 0) + loose.length)));
2665
+ now.append(head);
2666
+ // At work in the last minutes without its row in EN-CURSO.md: what it works on cannot be said.
2667
+ // One that took its row out a few minutes ago finished: its session may still be writing.
2668
+ for (const one of loose) {
2669
+ const row = el('div', `sm-logs-work ${one.finished ? 'is-done' : 'is-loose'}`);
2670
+ const top = el('div', 'sm-logs-top');
2671
+ top.append(badge(one.agent), el('b', 'sm-logs-title', one.finished ? t('Finished its work') : t('Working without registering in EN-CURSO.md')), el('small', 'sm-logs-when', ago(one.finished ?? one.at)));
2672
+ row.append(top, el('small', 'sm-logs-zone', one.finished ? t('It took its row out of EN-CURSO.md; it may still be saving or answering.') : t('Nobody can tell which error it has. Ask it to follow rule 12 of ~/madre-logs/AGENTS.md.')));
2673
+ now.append(row);
2674
+ }
2675
+ for (const work of reading.working ?? []) {
2676
+ const row = el('div', 'sm-logs-work');
2677
+ const top = el('div', 'sm-logs-top');
2678
+ top.append(badge(work.agent, work.who), el('b', 'sm-logs-title', work.what));
2679
+ row.append(top);
2680
+ if (work.zone) row.append(el('small', 'sm-logs-zone', work.zone));
2681
+ now.append(row);
2682
+ }
2683
+ body.append(now);
2684
+ }
2685
+ if (reading.byClase.length) body.append(tags(t('Class'), reading.byClase), tags(t('Type'), reading.byTipo));
2686
+ const STATE = { 'en-curso': t('in progress'), abierto: t('open'), investigando: t('investigating'), decision: t('your decision'), arreglado: t('fixed'), publicado: t('published'), verificado: t('verified') };
2687
+ const GROUPS = [
2688
+ [t('Urgent · P0 and P1'), (one) => one.nivel === 'P0' || one.nivel === 'P1', 'lv-urgent'],
2689
+ [t('Minor · P2'), (one) => one.nivel === 'P2', 'lv-minor'],
2690
+ [t('To investigate'), (one) => one.nivel === 'Investigar', 'lv-look'],
2691
+ [t('To watch'), (one) => one.nivel === 'Vigilar', 'lv-watch'],
2692
+ [t('Your decision'), (one) => one.nivel === 'Decisión', 'lv-decide'],
2693
+ // Planned work, not a failure (madre-logs, 2026-11-08): a lot of a plan the author already
2694
+ // asked for. Last, and it never looks urgent.
2695
+ [t('Planned work'), (one) => one.nivel === 'Obra', 'lv-work'],
2696
+ ];
2697
+ const card = (one, tone) => {
2698
+ const row = el('article', `sm-logs-item ${tone} is-${one.estado}`);
2699
+ const side = el('div', 'sm-logs-side');
2700
+ side.append(el('code', 'sm-logs-id', one.id), el('span', 'sm-logs-level', one.nivel === 'Investigar' ? t('Investigate') : one.nivel === 'Vigilar' ? t('Watch') : one.nivel === 'Decisión' ? t('Decide') : one.nivel === 'Obra' ? t('Build') : one.nivel));
2701
+ const main = el('div', 'sm-logs-main');
2702
+ const top = el('div', 'sm-logs-top');
2703
+ top.append(el('b', 'sm-logs-title', one.title));
2704
+ if (one.estado === 'en-curso' && (one.agent || one.responsable)) top.append(badge(one.agent, one.responsable));
2705
+ top.append(el('span', 'sm-logs-state', STATE[one.estado] ?? one.estado));
2706
+ const meta = el('div', 'sm-logs-meta');
2707
+ for (const word of [one.clase, one.tipo, one.origen].filter(Boolean)) meta.append(el('span', null, word));
2708
+ if (one.commit) meta.append(el('code', null, one.commit));
2709
+ main.append(top, meta);
2710
+ row.append(side, main);
2711
+ return row;
2712
+ };
2713
+ const left = [...reading.toFix];
2714
+ for (const [title, fits, tone] of GROUPS) {
2715
+ const these = left.filter(fits);
2716
+ if (!these.length) continue;
2717
+ const group = el('section', `sm-logs-group ${tone}`);
2718
+ const head = el('header', 'sm-logs-group-head');
2719
+ head.append(el('span', null, title), el('small', null, String(these.length)));
2720
+ group.append(head);
2721
+ for (const one of these) group.append(card(one, tone));
2722
+ body.append(group);
2723
+ }
2724
+ if (reading.toVerify.length) {
2725
+ const wait = el('details', 'sm-logs-group sm-logs-wait');
2726
+ const head = el('summary', 'sm-logs-group-head');
2727
+ head.append(el('span', null, t('Fixed, to verify')), el('small', null, String(reading.toVerify.length)));
2728
+ wait.append(head);
2729
+ for (const one of reading.toVerify) wait.append(card(one, 'lv-done'));
2730
+ body.append(wait);
2731
+ }
2732
+ if (reading.log.length) {
2733
+ const moves = el('section', 'sm-logs-group sm-logs-moves');
2734
+ const head = el('header', 'sm-logs-group-head');
2735
+ head.append(el('span', null, t('Last changes')));
2736
+ moves.append(head);
2737
+ for (const one of reading.log.slice(0, 5)) {
2738
+ const row = el('div', 'sm-logs-move');
2739
+ row.append(el('span', null, one.said), el('small', null, ago(one.at)));
2740
+ row.title = `${one.hash} · ${one.said}`;
2741
+ moves.append(row);
2742
+ }
2743
+ body.append(moves);
2744
+ }
2745
+ body.append(el('small', 'sm-w-foot', t('From ~/madre-logs · INDICE.md has the whole table')));
2746
+ },
2244
2747
  errors(body, reading, { again } = {}) {
2245
2748
  if (!reading.available) { body.append(el('p', 'sm-hint', reading.status ? t('madre.run answered {status}.', { status: reading.status }) : t('madre.run could not be reached.'))); return; }
2246
2749
  const open = reading.errors.filter((one) => one.status !== 'ignored' && one.status !== 'fixed');
@@ -2387,7 +2890,7 @@ function makeWidget(id) {
2387
2890
  // The first time it shows, what it is (homeTour is set up below this, so it is read late).
2388
2891
  if (!node.dataset.guided) { node.dataset.guided = '1'; setTimeout(() => { try { guideWidget(node, spec.kind); } catch { /* the tour is not up yet */ } }, 1500); }
2389
2892
  };
2390
- node.start = () => { if (timer) return; void read(); timer = setInterval(() => void read(), 20000); };
2893
+ node.start = () => { if (timer) return; void read(); timer = setInterval(() => void read(), spec.every ?? 20000); };
2391
2894
  node.stop = () => { clearInterval(timer); timer = 0; };
2392
2895
  // Said again in the language Home settled on: a widget is made once, before the first answer
2393
2896
  // tells Home which language MADRE speaks (a new MADRE starts in Spanish and may adopt English),
@@ -2449,6 +2952,31 @@ homeTour.firstOpen('home-settings', ui.gear, {
2449
2952
  title: () => t('Home settings'),
2450
2953
  text: () => t('How Home looks and what its bar holds, your agents, the Coordinator, which projects use the local AI, your projects and the version. ⌘ , opens it from anywhere.'),
2451
2954
  });
2955
+ // The other main keys of Home (1.1, 2026-11-08): what each one is, said once, the first time it is pressed.
2956
+ homeTour.firstOpen('home-activity', $('sm-tb-activity'), {
2957
+ opened: () => document.querySelector('.activity-panel:not([hidden])'),
2958
+ title: () => t('Running now'),
2959
+ text: () => t('Everything MADRE is doing right now in your open projects: an AI answering, a command being run, something installing. If something takes too long, you stop it from here.'),
2960
+ });
2961
+ homeTour.firstOpen('home-market', $('sm-tb-market'), {
2962
+ opened: () => document.querySelector('.mk[role="dialog"]'),
2963
+ title: () => t('Market'),
2964
+ text: () => t('Extra features for MADRE, made by its author and by the community: images, reminders, GitHub and more. Each one tells you what it does and what it touches before you install it.'),
2965
+ after: 700,
2966
+ });
2967
+ homeTour.firstOpen('home-modules', $('sm-tb-modules'), {
2968
+ opened: () => document.querySelector('.mk[role="dialog"]'),
2969
+ title: () => t('Modules'),
2970
+ text: () => t('The modules you already have, and in which projects each one is on. Switch one on only where you need it.'),
2971
+ after: 700,
2972
+ });
2973
+ homeTour.firstOpen('home-agents', ui.bar.agents, {
2974
+ // Beside the list of agents it opened, under its title: Settings here is a window, not a modal sheet.
2975
+ opened: () => topSheet()?.querySelector('.settings-detail .settings-detail-head, .settings-detail') ?? topSheet(),
2976
+ inside: (box) => box.closest('.sm-settings-window') ?? box,
2977
+ title: () => t('Your AIs'),
2978
+ text: () => t('Each circle is one of your AIs, with a light that says whether it is ready. One that looks switched off still needs you to sign in: press it and MADRE takes you there.'),
2979
+ });
2452
2980
  // What each widget shows, the first time it is on Home: its own line, and how to change it.
2453
2981
  const WIDGET_GUIDE = {
2454
2982
  system: () => t('How busy this Mac\'s processor is and how much memory is free. It updates on its own.'),
@@ -2461,6 +2989,7 @@ const WIDGET_GUIDE = {
2461
2989
  live: () => t('Copies on right now: a copy is on when it said so in the last ten minutes. Off are the ones used this month that are not on now. It reads again every minute.'),
2462
2990
  installs: () => t('Installs, updates and uninstalls by day. An uninstall counts only when made from Settings; whoever simply stops using MADRE shows as off.'),
2463
2991
  environments: () => t('Each copy once, by what it said last this month: its system, memory, agents, how many projects and which modules. Copies from before 1.1.0 say less.'),
2992
+ rumbo: () => t('The model of what decides MADRE\'s course: the funnel from a GitHub visit to using it on two days, with its leak in red; what the numbers say about product or reach, Windows, Pro, traction, English and failures; and every variable with how sure it is. It reads itself again on its own.'),
2464
2993
  agenda: () => t('Your reminders from every project, by day. ✓ settles one, «Later» moves it, and the box below sets a new one as you would say it.'),
2465
2994
  };
2466
2995
  function guideWidget(node, kind) {
@@ -3041,18 +3570,29 @@ async function homeNews(tries = 0) {
3041
3570
  const dialog = el('dialog', 'whats-new home-news');
3042
3571
  dialog.setAttribute('aria-label', t("What's new in MADRE {version}", { version: news.version }));
3043
3572
  const sheet = el('div', 'wn-sheet');
3573
+ // The sheet takes the focus, not «Start»: a key already marked looked chosen for you (2026-11-08).
3574
+ // Tab reaches each thing from here.
3575
+ sheet.tabIndex = -1;
3044
3576
  const head = el('header', 'wn-head');
3045
3577
  const words = el('div', 'wn-headline');
3046
3578
  const logo = document.querySelector('.side-brand .brand-logo, #sm-back .brand-logo')?.cloneNode?.(true);
3047
3579
  if (logo) { logo.setAttribute('class', 'brand-logo wn-logo'); words.append(logo); }
3048
- words.append(el('span', 'wn-eyebrow', t("What's new")), el('h2', null, t('You now have {version}', { version: String(news.version).replace(/\.0$/, '') })));
3580
+ // Its own words when the version has them (1.1.3: «Good to see you again»), with no label above.
3581
+ words.append(el('h2', null, pick(notes.title) ?? t('You now have {version}', { version: String(news.version).replace(/\.0$/, '') })));
3049
3582
  if (notes.intro) words.append(el('p', 'wn-intro', pick(notes.intro)));
3050
3583
  head.append(words, closeKey(() => dialog.close()));
3051
3584
  const grid = el('div', 'wn-board');
3585
+ const scenes = [];
3052
3586
  for (const item of notes.items ?? []) {
3053
3587
  const card = el('div', 'wn-card');
3054
3588
  const shot = el('span', 'wn-shot wn-card-shot');
3055
- if (item.image) {
3589
+ // A moving picture of what it is (1.1.3, public/news-scenes.js) in place of a screenshot.
3590
+ if (item.scene) {
3591
+ const scene = createNewsScene(item.scene);
3592
+ scenes.push(scene);
3593
+ shot.classList.add('scene');
3594
+ shot.append(scene.node);
3595
+ } else if (item.image) {
3056
3596
  const image = el('img');
3057
3597
  image.alt = pick(item.title) ?? '';
3058
3598
  image.loading = 'lazy';
@@ -3078,18 +3618,59 @@ async function homeNews(tries = 0) {
3078
3618
  foot.append(start);
3079
3619
  sheet.append(head, body, foot);
3080
3620
  dialog.append(sheet);
3081
- dialog.addEventListener('close', () => dialog.remove());
3621
+ dialog.addEventListener('close', () => { for (const scene of scenes) scene.stop(); dialog.remove(); });
3082
3622
  document.body.append(dialog);
3083
3623
  dialog.showModal();
3084
3624
  // Whoever comes from an older MADRE meets MADRE's opening first (2026-10-30), as a new person does in
3085
3625
  // the welcome (loader.js, playOpening), and the board comes after it — unless this page just played it
3086
3626
  // (public/terms.js, after the new license was accepted).
3087
- if (openingPlayed()) start.focus({ preventScroll: true });
3088
- else void playOpening(dialog, { skipLabel: t('Skip') }).then(() => start.focus({ preventScroll: true }));
3627
+ if (openingPlayed()) sheet.focus({ preventScroll: true });
3628
+ else void playOpening(dialog, { skipLabel: t('Skip') }).then(() => sheet.focus({ preventScroll: true }));
3089
3629
  // Seen once shown, as in a project: a board left open and the page closed is not owed again.
3090
3630
  void fetch('/api/whats-new/seen', { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}' }).catch(() => null);
3091
3631
  }
3092
3632
 
3633
+ // THE INVITATION TO A FIRST PROJECT (2026-11-01): whoever updates MADRE and still has no project is
3634
+ // asked once per version, on Home, to add one. 90 of 147 copies never opened a project, and MADRE does
3635
+ // nothing without one. Two ways in, the folder they work in or the project to try (src/salas.mjs,
3636
+ // createSampleProject), which opens straight on its first messages; and «Not now». Never over the
3637
+ // news, the welcome or another window. What they choose is counted with the anonymous diagnostics.
3638
+ const tellInvite = (answer) => fetch('/api/invite/project', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ answer }) }).catch(() => null);
3639
+ async function homeInvite(tries = 0) {
3640
+ if (welcomeOpen() || document.querySelector('dialog[open]')) { if (tries < 120) setTimeout(() => void homeInvite(tries + 1), 3000); return; }
3641
+ const dialog = el('dialog', 'sm-sheet sm-invite');
3642
+ const inner = el('div', 'sm-sheet-body');
3643
+ const head = el('header', 'sm-sheet-head');
3644
+ let answered = false;
3645
+ const answer = (said) => { if (answered) return; answered = true; void tellInvite(said); };
3646
+ head.append(el('h3', null, t('Add your first project')), closeKey(() => dialog.close()));
3647
+ const lead = el('p', null, t('MADRE works inside a project: a folder with your store, your website or your documents. There your AIs read, remember what you decide and show you every change.'));
3648
+ const hint = el('p', 'hint', t('You have none yet. Choose a folder you already work in, or make one to try: a page with a list of tasks, to ask your AIs for changes without fear of breaking anything.'));
3649
+ const keys = el('div', 'sm-invite-keys');
3650
+ const later = button('sm-btn', t('Not now'), () => dialog.close());
3651
+ const sample = button('sm-btn', t('Make the project to try'), async () => {
3652
+ sample.disabled = true;
3653
+ answer('sample');
3654
+ const made = await fetch('/api/salas/new', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ sample: true, language }) })
3655
+ .then(async (response) => ({ ok: response.ok, body: await response.json().catch(() => ({})) })).catch(() => ({ ok: false, body: {} }));
3656
+ const room = made.ok ? made.body.added?.[0] : null;
3657
+ if (!room) { hint.textContent = made.body?.error ?? t('The project to try MADRE could not be made.'); sample.disabled = false; return; }
3658
+ dialog.close();
3659
+ await refresh();
3660
+ await startRoom(room, { enter: true });
3661
+ });
3662
+ const pick = button('sm-btn primary', t('Choose a folder'), () => { answer('picked'); dialog.close(); openAddSheet(); });
3663
+ keys.append(later, sample, pick);
3664
+ inner.append(head, wizardScene('projects'), lead, hint, keys);
3665
+ dialog.append(inner);
3666
+ dialog.addEventListener('close', () => { answer('later'); dialog.remove(); });
3667
+ document.body.append(dialog);
3668
+ dialog.showModal();
3669
+ bootDone();
3670
+ void tellInvite('shown');
3671
+ pick.focus({ preventScroll: true });
3672
+ }
3673
+
3093
3674
  // Home in another language, without a reload: what it says now, and every widget and the tour's pill.
3094
3675
  function sayIn(code) {
3095
3676
  language = setLanguage(code);
@@ -3109,7 +3690,7 @@ async function adoptLanguage(code) {
3109
3690
  sayIn(code);
3110
3691
  }
3111
3692
 
3112
- async function startRoom(room, { enter = false } = {}) {
3693
+ async function startRoom(room, { enter = false, draft = null } = {}) {
3113
3694
  busy.set(room.id, 'starting');
3114
3695
  failed.delete(room.id);
3115
3696
  draw();
@@ -3119,7 +3700,9 @@ async function startRoom(room, { enter = false } = {}) {
3119
3700
  busy.delete(room.id);
3120
3701
  if (!answer.ok) failed.set(room.id, answer.body.error ?? t('The project did not open.'));
3121
3702
  // Opened from its card, the person goes in: that is what «Open» means.
3122
- else if (enter && answer.body.port) { leaveTo(`http://127.0.0.1:${answer.body.port}/`); return answer; }
3703
+ // From the welcome, with the first message already written: the project's page finds it in its address
3704
+ // (#escribe=, app.js) and leaves it in the box, for the person to send.
3705
+ else if (enter && answer.body.port) { leaveTo(`http://127.0.0.1:${answer.body.port}/${draft ? `#escribe=${encodeURIComponent(draft)}` : ''}`); return answer; }
3123
3706
  await refresh();
3124
3707
  return answer;
3125
3708
  }
@@ -4006,6 +4589,39 @@ function toast(words, tone = 'done', action = null) {
4006
4589
  const post = (url, payload) => fetch(url, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(payload ?? {}) })
4007
4590
  .then(async (response) => ({ ok: response.ok, status: response.status, body: await response.json().catch(() => ({})) }))
4008
4591
  .catch(() => ({ ok: false, status: 0, body: {} }));
4592
+ // Home's Settings sheet is as wide as you pull it, as a project's is (app.js, gripSettingsSheet;
4593
+ // 2026-11-07): a grip on its edge, the width kept apart from the projects', twice on it to reset.
4594
+ function gripHomeSettings(sheet) {
4595
+ let kept = null;
4596
+ try { kept = Number(localStorage.getItem('pulse.homeSettingsSheet')) || null; } catch { /* no storage */ }
4597
+ if (kept) sheet.style.setProperty('--sheet-w', `${kept}px`);
4598
+ const grip = el('div', 'settings-grip');
4599
+ grip.setAttribute('aria-hidden', 'true');
4600
+ grip.addEventListener('pointerdown', (event) => {
4601
+ event.preventDefault();
4602
+ const startX = event.clientX;
4603
+ const startWidth = sheet.getBoundingClientRect().width;
4604
+ const room = sheet.parentElement?.getBoundingClientRect().width ?? 980;
4605
+ try { grip.setPointerCapture(event.pointerId); } catch { /* a pointer the page no longer holds */ }
4606
+ sheet.classList.add('dragging');
4607
+ const move = (moving) => {
4608
+ const width = Math.round(Math.max(360, Math.min(room - 120, startWidth + startX - moving.clientX)));
4609
+ sheet.style.setProperty('--sheet-w', `${width}px`);
4610
+ };
4611
+ const done = () => {
4612
+ grip.removeEventListener('pointermove', move);
4613
+ sheet.classList.remove('dragging');
4614
+ try { localStorage.setItem('pulse.homeSettingsSheet', String(Math.round(sheet.getBoundingClientRect().width))); } catch { /* no storage */ }
4615
+ };
4616
+ grip.addEventListener('pointermove', move);
4617
+ grip.addEventListener('pointerup', done, { once: true });
4618
+ grip.addEventListener('pointercancel', done, { once: true });
4619
+ });
4620
+ // Twice on the grip goes back to the width it opens with.
4621
+ grip.addEventListener('dblclick', () => { sheet.style.removeProperty('--sheet-w'); try { localStorage.removeItem('pulse.homeSettingsSheet'); } catch { /* no storage */ } });
4622
+ sheet.prepend(grip);
4623
+ }
4624
+
4009
4625
  function mark(id, size = 40) {
4010
4626
  const brand = brandOf(id);
4011
4627
  const node = el('span', 'sm-mark');
@@ -4423,7 +5039,7 @@ void loadMarket({ toast: (words, action) => toast(words, action ? 'news' : 'done
4423
5039
  // `compact` is the welcome's first step: there, a connected agent is done, and a button to change
4424
5040
  // the account it signs in with is a question nobody asked on their first minute.
4425
5041
  // Who makes each agent, said under its name as the project's AJUSTES says it.
4426
- const VENDOR_WORDS = { codex: 'OpenAI', claude: 'Anthropic', gemini: 'Google', opencode: 'OpenCode', cursor: 'Cursor' };
5042
+ const VENDOR_WORDS = { codex: 'OpenAI', claude: 'Anthropic', gemini: 'Google', opencode: 'OpenCode', cursor: 'Cursor', grok: 'xAI' };
4427
5043
 
4428
5044
  // OpenCode's providers in Home, the same block as the project's AJUSTES › Agents › OpenCode: a line
4429
5045
  // per provider with a key or an account and its switch for the chat, one row to add another, and
@@ -4540,6 +5156,10 @@ const TROUBLE_WORDS = {
4540
5156
  disk: () => t('There is not enough free space on this computer to install it.'),
4541
5157
  'npm-missing': () => t('Installing it needs Node and npm, and this computer does not have them. Install Node from nodejs.org, then try again.'),
4542
5158
  'zstd-missing': () => t('Installing it needs zstd, which this Linux does not have. In a terminal: sudo apt install -y zstd, then try again.'),
5159
+ dns: () => t('This computer could not find the address it downloads from (DNS). In WSL, close it from Windows and open it again; with a VPN on, try without it.'),
5160
+ 'ollama-closed': () => t('Ollama closed the connection while downloading the model. Check that Ollama is still running and try again; what already arrived stays.'),
5161
+ // D-29: the registry's own error, not the person's connection, and not MADRE stopping it.
5162
+ registry: () => t('Ollama\'s model server did not answer (an error on its side). It is not your connection: try again in a few minutes; what already arrived stays.'),
4543
5163
  timeout: () => t('It took too long and was stopped. Try again.'),
4544
5164
  unknown: () => t('It did not install.'),
4545
5165
  },
@@ -4553,7 +5173,7 @@ const TROUBLE_WORDS = {
4553
5173
  };
4554
5174
  // The card of Diagnostics for each of those (public/troubleshooting.js), opened beside the failure.
4555
5175
  const TROUBLE_CARDS = {
4556
- install: { network: 'install-offline', timeout: 'install-offline', permission: 'install-needs-admin', disk: 'disk-full', 'npm-missing': 'node-missing' },
5176
+ install: { network: 'install-offline', dns: 'name-lookup', timeout: 'install-offline', permission: 'install-needs-admin', disk: 'disk-full', 'npm-missing': 'node-missing', 'ollama-closed': 'model-download', registry: 'model-download' },
4557
5177
  login: { network: 'install-offline', timeout: 'sign-in-unfinished', cancelled: 'sign-in-unfinished', unknown: 'sign-in-unfinished' },
4558
5178
  };
4559
5179
  const troubleCard = (agent, kind, cause) => (kind === 'login' && cause === 'refused-account' ? (agent === 'gemini' ? 'gemini-ineligible-tier' : 'not-signed-in') : TROUBLE_CARDS[kind]?.[cause] ?? null);
@@ -4710,6 +5330,8 @@ function agentsPanel({ onPaint = null, compact = false, explain = null } = {}) {
4710
5330
  if (agent.detected && agent.version) facts.append(el('code', 'sm-agent-line', `${agent.version}${agent.path ? ` · ${agent.path}` : ''}`));
4711
5331
  const said = agent.detected ? sessionDetail(answer.sessions?.[agent.id]) : null;
4712
5332
  if (said) facts.append(el('small', 'sm-agent-line', said));
5333
+ // Through its API it only answers: said where its connection is, with the way to the rest.
5334
+ if (agent.viaApi) facts.append(el('small', 'sm-agent-note', t('Answers through Google\'s API with your key: it does not read your projects or write in them. Install the Gemini CLI for that.')));
4713
5335
  // In the welcome, Gemini's account is already said above its card (welcome.js, explainAgent):
4714
5336
  // said twice in two ways, it read as two different requirements (QA 1.1.0, NUE-04).
4715
5337
  if (agent.account && !(compact && agent.id === 'gemini' && !state.ok)) facts.append(el('small', 'sm-agent-note', agent.account));
@@ -4748,7 +5370,7 @@ function agentsPanel({ onPaint = null, compact = false, explain = null } = {}) {
4748
5370
  const choosing = choosingAccount.has(agent.id);
4749
5371
  const doors = !state.ok ? (methods.length ? methods : [{ id: null, label: null, note: agent.login?.note }])
4750
5372
  : methods.length > 1 && choosing ? methods
4751
- : [{ id: methods.length === 1 ? methods[0].id : null, label: null, note: methods.length === 1 ? methods[0].note : agent.login?.note, choose: methods.length > 1 }];
5373
+ : [{ id: methods.length === 1 ? methods[0].id : null, label: methods.length === 1 ? methods[0].label : null, note: methods.length === 1 ? methods[0].note : agent.login?.note, choose: methods.length > 1 }];
4752
5374
  return doors.map((door) => {
4753
5375
  const name = door.label ? t(door.label) : state.ok ? t('Sign in again') : t('Sign in');
4754
5376
  const key = button(`sm-btn ${(state.ok && !choosing) || agent.key?.first ? '' : 'primary'} small`, name, async (event) => {
@@ -4765,16 +5387,18 @@ function agentsPanel({ onPaint = null, compact = false, explain = null } = {}) {
4765
5387
  });
4766
5388
  };
4767
5389
  // Gemini's key is its way in (agent.key.first): the field before the Google door.
4768
- const keyFirst = Boolean(agent.detected && agent.key?.first);
5390
+ const keyFirst = Boolean((agent.detected || agent.id === 'gemini') && agent.key?.first);
4769
5391
  if (keyFirst) body.append(keyForm(agent));
4770
5392
  const acts = el('div', 'sm-agent-acts');
4771
5393
  if (!state.busyNow) {
4772
- if (!agent.detected && installing.has(agent.id)) {
5394
+ // Gemini answering through its API can still get its CLI, for what the API cannot do.
5395
+ const canInstall = !agent.detected || agent.viaApi;
5396
+ if (canInstall && installing.has(agent.id)) {
4773
5397
  const wait = button('sm-btn primary small is-busy', t('Installing…'), () => {});
4774
5398
  wait.disabled = true;
4775
5399
  wait.setAttribute('aria-busy', 'true');
4776
5400
  acts.append(wait);
4777
- } else if (!agent.detected && agent.install?.command) acts.append(button('sm-btn primary small', wrongAt(agent.id, 'install') ? t('Try again') : t('Install'), async (event) => {
5401
+ } else if (canInstall && agent.install?.command) acts.append(button(`sm-btn ${agent.viaApi ? '' : 'primary'} small`, wrongAt(agent.id, 'install') ? t('Try again') : agent.viaApi ? t('Install the Gemini CLI') : t('Install'), async (event) => {
4778
5402
  event.currentTarget.disabled = true;
4779
5403
  event.currentTarget.textContent = t('Installing…');
4780
5404
  trouble.delete(agent.id);
@@ -4794,10 +5418,10 @@ function agentsPanel({ onPaint = null, compact = false, explain = null } = {}) {
4794
5418
  const ask = askBlock(agent);
4795
5419
  if (ask) body.append(ask);
4796
5420
  // A key, pasted here; OpenCode's are its providers', in the block below.
4797
- if (agent.detected && agent.key && agent.id !== 'opencode' && !keyFirst) body.append(keyForm(agent));
5421
+ if ((agent.detected || agent.id === 'gemini') && agent.key && agent.id !== 'opencode' && !keyFirst) body.append(keyForm(agent));
4798
5422
  // The same install or sign-in typed in a terminal, folded for whoever prefers it. Signed in,
4799
5423
  // OpenCode's providers are added in the block below; its terminal is for a first sign-in.
4800
- const way = !agent.detected ? agent.install && [agent.install.display, ...(agent.install.alternatives ?? []).map((line) => `# ${t(line)}`)]
5424
+ const way = !agent.detected || agent.viaApi ? agent.install && [agent.install.display, ...(agent.install.alternatives ?? []).map((line) => `# ${t(line)}`)]
4801
5425
  : agent.login?.terminal && !(agent.id === 'opencode' && state.ok) ? [agent.login.terminal.command, ...(agent.login.terminal.note ? [`# ${t(agent.login.terminal.note)}`] : [])] : null;
4802
5426
  if (way && !state.busyNow) body.append(terminalWay(way, agent.id));
4803
5427
  if (agent.id === 'opencode' && agent.detected) body.append(openCodeProviders.node());
@@ -4902,13 +5526,17 @@ const welcomeHost = {
4902
5526
  closeKey: (onClick) => closeKey(onClick),
4903
5527
  agentState: (agent, answer) => agentState(agent, answer),
4904
5528
  projects: () => (data ? projectsInOrder().all : []),
4905
- openProject: (room) => startRoom(room, { enter: true }),
5529
+ openProject: (room, { draft = null } = {}) => startRoom(room, { enter: true, draft }),
5530
+ // Started ahead, quietly (1.1): the welcome's last step wakes the project it will open, so «Open» goes
5531
+ // straight in instead of waiting on Home. The promise says when it is up.
5532
+ warmProject: (room) => (room?.open ? Promise.resolve(true) : fetch('/api/salas/start', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ room: room.id }) }).then((response) => response.ok, () => false)),
4906
5533
  setLanguage: (code) => adoptLanguage(code),
4907
5534
  openLinks: () => openLinkSheet(),
4908
5535
  openMarket: () => void openHomeMarket('shop'),
4909
5536
  chapters: () => homeTour.openChapters('home'),
4910
5537
  saved: (welcome) => { welcomeSeen = welcome; drawAttention(); },
4911
5538
  closed: () => { void loadAgents(); void refresh(); },
5539
+ refresh: () => refresh(),
4912
5540
  };
4913
5541
  function openHomeWelcome({ at = null, then = null } = {}) {
4914
5542
  welcomed = true;
@@ -4927,7 +5555,7 @@ function openHomeWelcome({ at = null, then = null } = {}) {
4927
5555
  // in that room. Nothing scrolls inside the window: the screen behind it does.
4928
5556
  const SET_SECTIONS = [
4929
5557
  ['You', 'How Home looks and what its bar holds', ['look', 'bar']],
4930
- ['The agents', 'Who works on this Mac', ['agents', 'bishop', 'local']],
5558
+ ['The agents', 'Who works on this Mac', ['agents', 'bishop', 'memory', 'local']],
4931
5559
  ['System', 'The projects of this Mac, the version and the manual', ['projects', 'release', 'manual']],
4932
5560
  ];
4933
5561
  // The room's own icons where the room has the category (app.js, SETTINGS_CATS); the bar, BISHOP
@@ -4937,12 +5565,13 @@ const SET_CATS = {
4937
5565
  bar: { name: 'Top bar', icon: trazoDrawing('arrange') },
4938
5566
  agents: { name: 'Agents', icon: trazoDrawing('agents') },
4939
5567
  bishop: { name: 'Coordinator', icon: trazoDrawing('coordinator') },
5568
+ memory: { name: 'Memory', icon: trazoDrawing('chip') },
4940
5569
  local: { name: 'Local AI', icon: trazoDrawing('spark') },
4941
5570
  projects: { name: 'Projects', icon: trazoDrawing('folder') },
4942
5571
  release: { name: 'Version', icon: trazoDrawing('refresh') },
4943
5572
  manual: { name: 'User manual', icon: trazoDrawing('book') },
4944
5573
  };
4945
- const SET_ORDER = ['look', 'bar', 'agents', 'bishop', 'local', 'projects', 'release'];
5574
+ const SET_ORDER = ['look', 'bar', 'agents', 'bishop', 'memory', 'local', 'projects', 'release'];
4946
5575
  // The words the search knows, each pointing to the category that holds it (app.js, SETTINGS_INDEX).
4947
5576
  const SET_INDEX = [
4948
5577
  ['look', 'Preview'], ['look', 'Theme'], ['look', 'Accent'], ['look', 'Wallpaper'], ['look', 'Intensity'], ['look', 'Blur'], ['look', 'Project cards'], ['look', 'Text'], ['look', 'Project order'], ['look', 'Language'],
@@ -5025,6 +5654,8 @@ function setStatus(id) {
5025
5654
  return { line: t('{n} of {total} signed in', { n: here.length - off.length, total: here.length }), warn: off.length ? t('{agents} without a session', { agents: off.map((agent) => agent.label ?? agent.id).join(', ') }) : null };
5026
5655
  }
5027
5656
  if (id === 'bishop') { const room = bishopRoom(); return { line: room ? stateOf(room).words : t('Reading…') }; }
5657
+ // Home's own, never the projects' (L-10): /api/settings is asked of Home's room.
5658
+ if (id === 'memory') { const stats = agentsSeen?.settings?.memory?.stats; return { line: stats ? memoriesCount(stats.memories ?? 0) : t('Reading…') }; }
5028
5659
  if (id === 'local') {
5029
5660
  if (!localSeen) return { line: localFailed ? t('Home did not answer.') : t('Reading…') };
5030
5661
  const on = localSeen.projects.filter((one) => one.on).length;
@@ -5062,14 +5693,19 @@ function setQuick(id) {
5062
5693
  add(t('Theme'), seg);
5063
5694
  }
5064
5695
  if (id === 'bar' && !homeShellOn()) add(t('Arrange the bar'), sxButton(t('Arrange'), (event) => { event.stopPropagation(); settingsSheet?.close(); pinsEdit(true); }));
5696
+ // The agents as a quick way in (2026-11-07): each one's mark and its session, three to a row; a tile
5697
+ // opens that agent in the panel (the card itself wires the click, openSettings › card).
5065
5698
  if (id === 'agents' && agentsSeen) {
5699
+ rows.classList.add('agents-grid');
5066
5700
  for (const agent of agentsSeen.agents.filter((one) => one.id !== 'madre' && one.detected)) {
5067
5701
  const state = agentState(agent, agentsSeen);
5068
- const row = el('div', 'settings-quick-row agent');
5069
- const who = el('span', 'who', agent.label ?? agent.id);
5070
- who.style.setProperty('--agent', brandOf(agent.id).color);
5071
- row.append(who, el('span', `state session-lamp ${state.ok ? 'on ok' : state.key === 'bad' ? 'off bad' : 'wait'}`, state.ok ? t('signed in') : state.key === 'bad' ? t('no session') : t('unknown')));
5072
- rows.append(row);
5702
+ const label = agent.label ?? agent.id;
5703
+ const tile = el('button', 'settings-quick-tile agent');
5704
+ tile.type = 'button';
5705
+ tile.dataset.agent = label;
5706
+ tile.setAttribute('aria-label', `${label} · ${state.ok ? t('signed in') : state.key === 'bad' ? t('no session') : t('unknown')}`);
5707
+ tile.append(mark(agent.id, 26), el('span', `state session-lamp ${state.ok ? 'on ok' : state.key === 'bad' ? 'off bad' : 'wait'}`, state.ok ? t('signed in') : state.key === 'bad' ? t('no session') : t('unknown')));
5708
+ rows.append(tile);
5073
5709
  }
5074
5710
  }
5075
5711
  return rows.children.length ? rows : null;
@@ -5310,6 +5946,28 @@ function fillBishop(host) {
5310
5946
  sxRow(block, t('Talk to the Coordinator'), room ? stateOf(room).words : null, sxButton(t('Open'), () => { settingsSheet?.close(); openBishop(); }, { tone: 'primary' }));
5311
5947
  sxRow(block, t('Open the Coordinator in a new tab'), null, sxButton(t('Open'), () => openBishop({ newTab: true })));
5312
5948
  }
5949
+ // MEMORY (L-10, 2026-11-05): what Home itself remembers — the Coordinator and what is said here —
5950
+ // and nothing of the projects. The Memory tile on Home adds up the open projects, and that was read
5951
+ // as Home's; each project keeps its own in its own Settings. Asked of Home's room, the routes a
5952
+ // project's Settings › What it remembers asks of its own; the rest of the settings stay there.
5953
+ async function fillMemory(host) {
5954
+ const block = sxBlock(host, t('Home\'s memory'), t('What Home remembers: the Coordinator and what is said here. Each project keeps its own memory, in its own Settings.'));
5955
+ sxRow(block, t('Reading…'), null);
5956
+ const ask = (path) => fetch(path, { cache: 'no-store' }).then((answer) => (answer.ok ? answer.json() : null)).catch(() => null);
5957
+ const [dash, settings] = await Promise.all([ask('/api/memory/dashboard').then((one) => one?.dashboard ?? null), ask('/api/settings').then((one) => one?.settings?.memory ?? null)]);
5958
+ if (!block.isConnected) return;
5959
+ block.rows.replaceChildren();
5960
+ if (!dash && !settings) sxRow(block, t('Home did not answer.'), null);
5961
+ else {
5962
+ const totals = dash?.totals ?? settings?.stats ?? {};
5963
+ sxRow(block, t('Memories'), totals.pending ? t('{n} exchanges still to sort', { n: totals.pending }) : null, el('b', null, memoriesCount(totals.memories ?? 0)));
5964
+ const kinds = KINDS.filter((kind) => dash?.kinds?.[kind]).map((kind) => `${kindWord(kind)} · ${dash.kinds[kind]}`);
5965
+ if (kinds.length) sxRow(block, t('By kind'), kinds.join(' · '));
5966
+ if (settings) sxRow(block, t('Who takes notes'), settings.enabled === false ? t('Off') : settings.archivist === 'ollama' ? t('Local AI') : settings.archivist && settings.archivist !== 'auto' ? `@${settings.archivist}` : t('Automatic · the cheapest one'));
5967
+ }
5968
+ const more = sxBlock(host, t('The rest'), t('Who may take notes, how often and how it searches are set in the Coordinator, in its Settings › What it remembers.'));
5969
+ sxRow(more, t('Talk to the Coordinator'), null, sxButton(t('Open'), () => { settingsSheet?.close(); openBishop(); }, { tone: 'primary' }));
5970
+ }
5313
5971
  // LOCAL AI (src/local-ai.mjs): whether every project uses Ollama, the ones picked here, or each
5314
5972
  // one as it decides in its own Settings. The switch of each project is the same one its Settings
5315
5973
  // show. Since 2026-10-20 Ollama itself is governed here too, as the agents are: the server, the
@@ -5551,6 +6209,16 @@ function watchPull(model) {
5551
6209
  const look = async () => {
5552
6210
  await loadLocal({ probe: true });
5553
6211
  if ((localOllama?.ollama?.models ?? []).some((one) => one.name.replace(/:latest$/, '') === model)) { pulling.delete(model); toast(t('{model} is ready. Choose it in Settings › Local AI.', { model })); return; }
6212
+ if (localOllama?.lastPull?.model === model && !localOllama.lastPull.ok && !localOllama.pulling) {
6213
+ pulling.delete(model);
6214
+ // Said in Home's words for why (the same ones as an install), not Go's error as it came: a
6215
+ // download cut by DNS or the network read as «pull model manifest: … i/o timeout».
6216
+ const said = localOllama.lastPull;
6217
+ if (said.cancelled) return;
6218
+ toast(TROUBLE_WORDS.install[said.trouble]?.() ?? (said.detail || t('The download stopped: {error}', { error: model })));
6219
+ settingsSheet?.sync({ detail: true, only: 'local' });
6220
+ return;
6221
+ }
5554
6222
  if (Date.now() - started > 60 * 60 * 1000) { pulling.delete(model); return; }
5555
6223
  setTimeout(look, 8000);
5556
6224
  };
@@ -5562,6 +6230,49 @@ function fillProjects(host) {
5562
6230
  sxRow(block, t('See the welcome again'), t('Agents, AI on your computer, memory and a project, step by step.'), sxButton(t('Open'), () => { settingsSheet?.close(); openHomeWelcome({ at: 'hello' }); }));
5563
6231
  const back = homeTour.path() === 'back';
5564
6232
  sxRow(block, back ? t('The tour of MADRE 1.0') : t('Getting to know MADRE'), back ? t('Everything new, chapter by chapter. ? opens the gestures anywhere.') : t('The essentials, chapter by chapter. ? opens the gestures anywhere.'), sxButton(t('See the tour'), () => { settingsSheet?.close(); homeTour.openChapters(); }));
6233
+ void drawService(host);
6234
+ }
6235
+ // MADRE as a service of this Linux (src/service.mjs, L-3, Carlos's server): Home starts with the
6236
+ // computer and again if it falls, with the projects that were open. Only where it can be: a Mac,
6237
+ // or a Linux without systemd for the user, shows nothing.
6238
+ async function drawService(host) {
6239
+ const state = await fetch('/api/madre/service', { cache: 'no-store' }).then((response) => (response.ok ? response.json() : null)).catch(() => null);
6240
+ if (!state?.supported || !host.isConnected) return;
6241
+ const block = sxBlock(host, t('When this computer starts'), t('For a server: Home opens with it, and again if it falls, with the projects that were open. A project you close stays closed.'));
6242
+ const said = el('p', 'sx-hint');
6243
+ const paint = (now) => {
6244
+ block.rows.replaceChildren();
6245
+ const key = sxButton(now.enabled ? t('Turn off') : t('Turn on'), async () => {
6246
+ key.disabled = true;
6247
+ said.textContent = '';
6248
+ const answer = await post('/api/madre/service', { on: !now.enabled });
6249
+ if (!answer.ok) { key.disabled = false; said.textContent = answer.body?.error ?? t('It did not change.'); return; }
6250
+ paint(answer.body);
6251
+ }, { tone: now.enabled ? null : 'primary' });
6252
+ sxRow(block, now.enabled ? t('Starts with the computer') : t('Does not start on its own'), now.enabled ? t('Home starts with this computer.') : t('MADRE starts only when you open it.'), key);
6253
+ if (now.enabled && !now.linger) sxRow(block, t('One more step, once'), t('For it to start before anyone signs in, this computer asks for its password. Run this in its terminal: {command}', { command: now.lingerCommand }), null, { stack: true });
6254
+ block.rows.append(said);
6255
+ };
6256
+ paint(state);
6257
+ }
6258
+ // The author's notices (Q-11): info and important ones can be turned off; security ones always show.
6259
+ function noticesRow(block) {
6260
+ const wrap = el('label', 'settings-switch');
6261
+ const box = el('input');
6262
+ box.type = 'checkbox';
6263
+ box.checked = true;
6264
+ box.disabled = true;
6265
+ box.setAttribute('aria-label', t('Notices from MADRE'));
6266
+ wrap.append(box, el('i'));
6267
+ sxRow(block, t('Notices from MADRE'), t('What MADRE\'s author tells every copy: a new version, a fix, a service stop. Nothing about you is sent to receive them. Security notices always show.'), wrap);
6268
+ void fetch('/api/notices', { cache: 'no-store' }).then((response) => (response.ok ? response.json() : null)).then((answer) => { if (answer) { box.checked = answer.enabled !== false; box.disabled = false; } }).catch(() => null);
6269
+ box.addEventListener('change', async () => {
6270
+ box.disabled = true;
6271
+ const answer = await fetch('/api/notices/settings', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ enabled: box.checked }) }).then((response) => (response.ok ? response.json() : null)).catch(() => null);
6272
+ if (!answer) box.checked = !box.checked;
6273
+ box.disabled = false;
6274
+ askNoticesAgain();
6275
+ });
5565
6276
  }
5566
6277
  function fillRelease(host) {
5567
6278
  const info = versionSeen;
@@ -5584,6 +6295,7 @@ function fillRelease(host) {
5584
6295
  const row = sxRow(block, t('This copy\'s identifier'), t('Random and unique: this copy made it for itself. It lets the author tell one copy\'s errors from another\'s and find the fix for yours, without knowing who you are: no name, no projects.'), copy);
5585
6296
  row.querySelector('.sx-words')?.append(el('code', 'sm-install-id', info.copyId));
5586
6297
  }
6298
+ noticesRow(block);
5587
6299
  drawDonate(host);
5588
6300
  if (info?.available) {
5589
6301
  const notes = el('a', 'sx-btn', t('What it brings'));
@@ -5652,7 +6364,7 @@ async function updateHome(info, key, said) {
5652
6364
  }
5653
6365
  drop(t('Home did not come back on its own. Start MADRE again from your terminal.'));
5654
6366
  }
5655
- const SET_FILL = { look: fillLook, bar: fillBar, agents: fillAgents, bishop: fillBishop, local: fillLocal, projects: fillProjects, release: fillRelease };
6367
+ const SET_FILL = { look: fillLook, bar: fillBar, agents: fillAgents, bishop: fillBishop, memory: (host) => void fillMemory(host), local: fillLocal, projects: fillProjects, release: fillRelease };
5656
6368
 
5657
6369
  let settingsSheet = null;
5658
6370
  function openSettings(section = null) {
@@ -5707,6 +6419,10 @@ function openSettings(section = null) {
5707
6419
  if (status.warn) node.append(el('p', 'settings-warn', status.warn));
5708
6420
  const quick = setQuick(id);
5709
6421
  if (quick) node.append(quick);
6422
+ // An agent's tile goes straight to that agent, not to the list.
6423
+ for (const tile of quick?.querySelectorAll('.settings-quick-tile.agent') ?? []) {
6424
+ tile.addEventListener('click', (event) => { event.stopPropagation(); openCategory('agents', tile.dataset.agent); });
6425
+ }
5710
6426
  // The manual is a page of its own, not a panel.
5711
6427
  const go = () => (id === 'manual' ? openManual() : openCategory(id));
5712
6428
  node.addEventListener('click', go);
@@ -5772,6 +6488,7 @@ function openSettings(section = null) {
5772
6488
  scroll.append(detail(state.open));
5773
6489
  sheet.append(scroll);
5774
6490
  if (full) { body.replaceChildren(sheet); return; }
6491
+ gripHomeSettings(sheet);
5775
6492
  const scrim = el('div', 'settings-scrim');
5776
6493
  scrim.addEventListener('click', () => closeCategory());
5777
6494
  body.replaceChildren(board(), scrim, sheet);
@@ -6270,3 +6987,8 @@ setInterval(() => { if (!document.hidden) void loadReminders(); }, 60 * 1000);
6270
6987
  // Asking for a star or a review (review-ask.js), when Home is quiet: nothing waking or closing,
6271
6988
  // the bar not being arranged.
6272
6989
  startReviewAsk({ busy: () => busy.size > 0 || pins.editing || Boolean(pins.drag) || Boolean(pins.dropping) });
6990
+ // The author's notices (Q-11): every one for this copy, above the board, until «Got it».
6991
+ const noticesHost = el('div', 'sm-notices');
6992
+ noticesHost.hidden = true;
6993
+ document.querySelector('.sm-hero')?.append(noticesHost);
6994
+ const askNoticesAgain = mountNotices(noticesHost);