@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
package/public/app.js CHANGED
@@ -3,6 +3,7 @@
3
3
  import { archiveQuestion, modeAskedWithTime, MODE_WINDOWS, windowFor } from './routing.js';
4
4
  import { calledByName, abduct } from './abduction.js';
5
5
  import { brandOf, monogram } from './brands.js';
6
+ import { installTips } from './tips.js';
6
7
  import { allConditions, detectPlatform, diagnose, findConditions, fixesFor, PLATFORMS } from './troubleshooting.js';
7
8
  import { answerFor, INQUIRIES, STRIKES } from './inquiry.js';
8
9
  import { DEFAULT_LANGUAGE, LANGUAGES, browserLanguage, isLanguage, language, pick, sessionDetail, setLanguage, t, fill } from './i18n.js';
@@ -12,6 +13,7 @@ import { drawHardware, hardwareLine } from './hardware.js';
12
13
  import { CUSTOM_WALL, addPicture, customTile, customTools, customWall, paintCustomWall, rememberedWall } from './wallpaper.js';
13
14
  import { createStrain, inviteNeural, mapKeys, neuralChosen, neuralKey, paintNeuralKey, rememberNeural, tellViews } from './neural.js';
14
15
  import { resay } from './resay.js';
16
+ import { mountNotices } from './notices.js';
15
17
  import { SPONSORS_URL, startReviewAsk } from './review-ask.js';
16
18
  import { spotlight, startTour as startWelcome } from './tour.js';
17
19
  import { dropStickyHover } from './touch.js';
@@ -35,6 +37,7 @@ import { trazo, trazoDrawing } from './icons.js';
35
37
  import { tellFailures } from './page-errors.js';
36
38
  import { mountActivity } from './activity.js';
37
39
  import { ensureTerms } from './terms.js';
40
+ import { createNewsScene } from './news-scenes.js';
38
41
 
39
42
  // Nothing of MADRE starts before its license and privacy notice are accepted on this computer
40
43
  // (public/terms.js, src/terms.mjs): the page waits here.
@@ -210,6 +213,7 @@ function spokenCommand(item) {
210
213
  const CLIENT_COMMANDS = [
211
214
  // /create went away (2026-10-27): choosing #2 on the mode chip is the same thing, said once.
212
215
  { name: 'module', title: 'MODULE', usage: `/module ${t('<what it should do>')}`, summary: t('Build one MADRE module with the guided SDK flow: the agent writes it, then you review and install it.'), available: true, client: true },
216
+ { name: 'habilidad', title: 'SKILL', usage: `/habilidad ${t('<how you work>')}`, summary: t('Write one skill: a way of working every agent of this room follows. The agent writes it, you read it and keep it.'), available: true, client: true },
213
217
  { name: 'image', title: t('Image'), usage: `/image ${t('<what to draw>')}`, summary: t('Ask for an image: arms CREATE with the image scope and routes to an agent that can generate images.'), available: true, client: true },
214
218
  { name: 'stopall', title: t('STOP ALL'), usage: '/stopall', summary: t('Master brake: halt every plan and turn in flight. Never reaches an agent.'), available: true, client: true },
215
219
  // Notes and Reminders through an agent (2026-10-20): the message goes to the agent chosen, and
@@ -624,17 +628,17 @@ function roomForToast(on) {
624
628
  requestAnimationFrame?.(follow);
625
629
  }
626
630
 
627
- // Nothing in the room speaks on hover: not a button, not a chip, not a cut-off title. Every
628
- // `title` in the page is taken off the first time the pointer or the focus reaches it, so the
629
- // browser's grey box never comes either. What it said is kept as the element's name for a screen
630
- // reader when the element has no words of its own, and as its description when it does — the
631
- // words stay reachable for whoever navigates without seeing, and stop covering the page for
632
- // everyone else.
631
+ // The browser's grey box never comes: every `title` in the page is taken off the first time the
632
+ // pointer or the focus reaches it. What it said is kept as the element's name for a screen reader
633
+ // when the element has no words of its own, and as its description when it does. From 2026-11-07
634
+ // it is also what MADRE's own small tip says (public/tips.js, `data-tip`), at the author's request:
635
+ // the room used to say nothing on hover at all.
633
636
  function adoptTitle(node) {
634
637
  const said = node.getAttribute('title');
635
638
  if (said === null) return;
636
639
  node.removeAttribute('title');
637
640
  if (!said.trim()) return;
641
+ node.dataset.tip = said;
638
642
  if (!node.hasAttribute('aria-label') && !node.textContent.trim()) node.setAttribute('aria-label', said);
639
643
  else if (!node.hasAttribute('aria-description')) node.setAttribute('aria-description', said);
640
644
  }
@@ -3241,6 +3245,7 @@ async function openViewer({ root = 'project', path = null, url = null, label = n
3241
3245
  viewer.open.href = src;
3242
3246
  viewer.body.replaceChildren(el('div', null, t('loading…')));
3243
3247
  viewerUI.path = root === 'project' ? path : null;
3248
+ keepAttachmentUI?.show(root === 'attachments' && path && !url ? { fileName: path, name: label ?? path } : null);
3244
3249
  setSelection(null, null);
3245
3250
  viewerMode.kind = null;
3246
3251
  viewerMode.editable = false;
@@ -3279,6 +3284,70 @@ async function openViewer({ root = 'project', path = null, url = null, label = n
3279
3284
  viewer.body.replaceChildren(el('div', 'err', error.message));
3280
3285
  }
3281
3286
  }
3287
+ // An attachment of the conversation, saved into the project where the person says (L-2, Carlos's
3288
+ // server): a patient's photo into pacientes/…/fotos/, a guide into conocimiento/. The button sits in
3289
+ // the viewer, beside «Open raw», only while what is open is an attachment; the folder used last is
3290
+ // offered again. A file already there is never replaced (src/files.mjs, keepAttachment).
3291
+ const KEEP_FOLDER = 'madre.keepFolder';
3292
+ const keepAttachmentUI = (() => {
3293
+ const head = viewer.dialog?.querySelector('.viewer-head');
3294
+ if (!head || !viewer.open) return null;
3295
+ const button = el('button', 'viewer-review viewer-keep', t('Save in the project…'));
3296
+ button.type = 'button';
3297
+ button.hidden = true;
3298
+ // Beside «Open raw», wherever the head keeps it: another part of the page moves it into a group,
3299
+ // and inserting into the head itself threw and stopped the whole page.
3300
+ viewer.open.parentNode.insertBefore(button, viewer.open);
3301
+ const box = el('form', 'viewer-keep-box');
3302
+ box.hidden = true;
3303
+ head.after(box);
3304
+ let current = null;
3305
+ let input = null;
3306
+ const close = () => { box.hidden = true; box.replaceChildren(); input = null; };
3307
+ const lastFolder = () => { try { return localStorage.getItem(KEEP_FOLDER) ?? ''; } catch { return ''; } };
3308
+ button.addEventListener('click', () => {
3309
+ if (!current) return;
3310
+ if (!box.hidden) { close(); return; }
3311
+ input = el('input');
3312
+ input.type = 'text';
3313
+ input.spellcheck = false;
3314
+ input.autocomplete = 'off';
3315
+ input.value = `${lastFolder()}${current.name}`;
3316
+ input.setAttribute('aria-label', t('Folder and name inside the project'));
3317
+ const save = el('button', 'go', t('SAVE'));
3318
+ save.type = 'submit';
3319
+ const cancel = el('button', null, t('CANCEL'));
3320
+ cancel.type = 'button';
3321
+ cancel.addEventListener('click', close);
3322
+ const actions = el('div', 'ask-actions');
3323
+ actions.append(cancel, save);
3324
+ box.replaceChildren(el('div', 'ask-label', t('Save in the project')), el('div', 'ask-hint', t('Folder and name inside the project, for example conocimiento/guia.pdf. A file that is already there is never replaced.')), input, actions);
3325
+ box.hidden = false;
3326
+ input.focus();
3327
+ const dot = input.value.lastIndexOf('.');
3328
+ input.setSelectionRange(lastFolder().length, dot > lastFolder().length ? dot : input.value.length);
3329
+ });
3330
+ box.addEventListener('submit', async (event) => {
3331
+ event.preventDefault();
3332
+ const to = input?.value.trim();
3333
+ if (!to || !current) return;
3334
+ const send = (extra = {}) => fetch('/api/attachments/keep', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ fileName: current.fileName, to, ...extra }) })
3335
+ .then(async (response) => ({ response, result: await response.json().catch(() => ({})) }), () => ({ response: null, result: {} }));
3336
+ let { response, result } = await send();
3337
+ // A place the project guards asks for its name, as a new file in Archivos does.
3338
+ if (response?.status === 403 && result.guarded) {
3339
+ const word = await roomAsk({ title: t('A file the project guards'), body: t('This file is one the project guards. Type the project name to save it.'), input: { placeholder: t('the project folder\'s name') }, choices: [{ value: 'no', label: t('CANCEL') }, { value: 'save', label: t('SAVE'), tone: 'primary', submit: true }] });
3340
+ if (!word) return;
3341
+ ({ response, result } = await send({ designation: word }));
3342
+ }
3343
+ if (!response?.ok) { toast(`${t('Diagnostics › ')}${result.error ?? t('That could not be done.')}`); return; }
3344
+ try { localStorage.setItem(KEEP_FOLDER, result.path.includes('/') ? result.path.slice(0, result.path.lastIndexOf('/') + 1) : ''); } catch { /* only the suggestion is lost */ }
3345
+ toast(t('Saved in the project: {path}', { path: result.path }));
3346
+ close();
3347
+ finderRefresh(result.path);
3348
+ });
3349
+ return { show(attachment) { current = attachment; button.hidden = !attachment; close(); } };
3350
+ })();
3282
3351
  viewer.close.addEventListener('click', async () => {
3283
3352
  let docked = false;
3284
3353
  try { docked = codeOn(); } catch { /* not yet */ }
@@ -3444,6 +3513,8 @@ export function renderMarkdown(text) {
3444
3513
 
3445
3514
  /* ---------- agents bar, picker & onboarding ---------- */
3446
3515
 
3516
+ // A plan's window in words: «5 hours», «7 days» (1.1).
3517
+ const humanWindow = (minutes) => { const m = Number(minutes); if (!Number.isFinite(m)) return t('a while'); if (m % 1440 === 0) return m === 1440 ? t('day') : t('{n} days', { n: m / 1440 }); if (m % 60 === 0) return m === 60 ? t('hour') : t('{n} hours', { n: m / 60 }); return t('{n} min', { n: m }); };
3447
3518
  const fmtWindow = (minutes) => (!Number.isFinite(Number(minutes)) ? 'window' : Number(minutes) % 1440 === 0 ? `${Number(minutes) / 1440}d` : Number(minutes) % 60 === 0 ? `${Number(minutes) / 60}h` : `${minutes}m`);
3448
3519
  const fmtReset = (iso) => { if (!iso) return ''; const date = new Date(iso); if (Number.isNaN(date.getTime())) return ''; const sameDay = date.toDateString() === new Date().toDateString(); return sameDay ? date.toLocaleTimeString(language(), { hour: '2-digit', minute: '2-digit' }) : date.toLocaleString(language(), { weekday: 'short', hour: '2-digit', minute: '2-digit' }); };
3449
3520
  // An official window whose reset time has passed counts as empty until the CLI reports again.
@@ -3507,11 +3578,11 @@ function renderAgents() {
3507
3578
  node.title = [
3508
3579
  `${agent.label}${vendorWord(agent.id) ? ` · ${vendorWord(agent.id)}` : ''}`,
3509
3580
  signedOut ? t('Not signed in') : agent.ready ? t('Ready') : agent.detected ? t('Detected, but MADRE cannot use it yet') : t('Not installed'),
3510
- agent.version ? agent.version : null,
3581
+ // Said plainly (1.1): how much of the plan is used and when it renews; the details are one click in.
3511
3582
  official === null
3512
- ? (agent.tokens ? t('Usage: local 5h window · {pct}% of {total} budget tokens', { pct: Math.round(percent), total: formatTokens(state.budget ?? 0) }) : t('Usage: local window · nothing used yet'))
3513
- : t('Usage: provider limit · {pct}% used', { pct: Math.round(official) }) + (agent.officialResetAt ? t(' · resets {when}', { when: fmtReset(agent.officialResetAt) }) : ''),
3514
- agent.tokens ? t('{n} budget tokens in the local window', { n: agent.tokens.toLocaleString() }) : null,
3583
+ ? (agent.tokens ? t('{pct}% of the limit you gave it in this project', { pct: Math.round(percent) }) : t('Nothing used yet in this project'))
3584
+ : t('Your plan: {pct}% used', { pct: Math.round(official) }) + (agent.officialResetAt ? t(' · renews {when}', { when: fmtReset(agent.officialResetAt) }) : ''),
3585
+ t('Click for its usage and what it can do'),
3515
3586
  ].filter(Boolean).join('\n');
3516
3587
  fresh.push(node);
3517
3588
  }
@@ -3574,13 +3645,13 @@ function renderPicker() {
3574
3645
  closeModeMenu();
3575
3646
  els.target.value = agent.id;
3576
3647
  state.typedTarget = null;
3577
- setMode(defaultModeFor(agent.id));
3648
+ setMode(nextModeFor(agent.id));
3578
3649
  focusComposer();
3579
3650
  };
3580
3651
  pick.title = els.target.value === agent.id ? t('{label} · click again to choose its model', { label: agent.label }) : agent.label;
3581
3652
  // Under the pointer, the provider's name comes out of the sphere.
3582
3653
  const vendor = brandOf(agent.id).vendor;
3583
- if (vendor) pick.append(el('span', 'pick-vendor', t(vendor)));
3654
+ if (vendor) { pick.append(el('span', 'pick-vendor', t(vendor))); pick.dataset.tipOff = ''; }
3584
3655
  pick.addEventListener('click', (event) => { event.stopPropagation(); els.picker.classList.remove('open'); choose(); });
3585
3656
  pick.addEventListener('keydown', (event) => { if (event.key === ' ' || event.key === 'Enter') { event.preventDefault(); els.picker.classList.remove('open'); choose(); } });
3586
3657
  stack.append(pick);
@@ -3601,7 +3672,9 @@ function renderPicker() {
3601
3672
  const shown = state.typedPending ?? state.mode;
3602
3673
  const modeChip = el('button', `mode-chip m${shown}${state.typedPending ? ' pending' : ''}`);
3603
3674
  modeChip.type = 'button';
3604
- modeChip.append(el('b', null, `#${shown}`), el('span', 'word', sentence(MODES[shown].label)), chevron());
3675
+ // And a short word for a box too narrow for the whole one (Q-17, 2026-11-06): «#1» alone told
3676
+ // someone new nothing on a phone.
3677
+ modeChip.append(el('b', null, `#${shown}`), el('span', 'word', sentence(MODES[shown].label)), el('span', 'nick', MODE_NICKS[shown]?.() ?? ''), chevron());
3605
3678
  modeChip.title = state.typedPending
3606
3679
  ? t('#{n} {label} is written in the message: you will be asked to confirm it when you send it.', { n: shown, label: sentence(MODES[shown].label) })
3607
3680
  : t('Permission mode for this message · {hint}', { hint: MODES[state.mode].hint });
@@ -3617,7 +3690,7 @@ function renderPicker() {
3617
3690
  grace.dataset.agent = current.id;
3618
3691
  grace.title = t('{label} does not ask you to confirm again for @{agent} until this runs out. Click to end it now.', { label: `«${sentence(MODES[mode].label)}»`, agent: current.id });
3619
3692
  grace.append(el('b', null, `#${mode}`), el('span', null, t('open')), el('span', 'left', graceWords(left)), el('i', null, '×'));
3620
- grace.addEventListener('click', (event) => { event.stopPropagation(); closeOverrideGrace(mode, current.id); toast(t('Diagnostics › {label} locked again for @{agent}: the next message asks you to confirm again.', { label: `«${sentence(MODES[mode].label)}»`, agent: current.id }), { tone: 'done' }); });
3693
+ grace.addEventListener('click', (event) => { event.stopPropagation(); closeOverrideGrace(mode, current.id, { back: true }); toast(t('Diagnostics › {label} locked again for @{agent}: the next message asks you to confirm again.', { label: `«${sentence(MODES[mode].label)}»`, agent: current.id }), { tone: 'done' }); });
3621
3694
  text.append(grace);
3622
3695
  break;
3623
3696
  }
@@ -3708,8 +3781,8 @@ let modelMenuFor = null;
3708
3781
  async function ensureModels(id) {
3709
3782
  if (state.models[id]) return state.models[id];
3710
3783
  try {
3711
- // OpenCode, Cursor and Gemini are asked for their own lists only when their chooser opens: each asks its CLI or its maker.
3712
- const data = await fetch(`/api/models${['opencode', 'cursor', 'gemini'].includes(id) ? `?${id}=1` : ''}`).then((response) => response.json());
3784
+ // OpenCode, Cursor, Gemini and Grok are asked for their own lists only when their chooser opens: each asks its CLI or its maker.
3785
+ const data = await fetch(`/api/models${['opencode', 'cursor', 'gemini', 'grok'].includes(id) ? `?${id}=1` : ''}`).then((response) => response.json());
3713
3786
  state.models = { ...state.models, ...(data.models ?? {}) };
3714
3787
  takeEfforts(data.models);
3715
3788
  } catch { /* offline: fall back to whatever we know */ }
@@ -4203,7 +4276,7 @@ function applyCopilot(said = {}) {
4203
4276
  }, 30000);
4204
4277
  }
4205
4278
  // The mode follows: #3 while it lasts, the agent's own default after.
4206
- if (was !== copilotOn() && els.target?.value) { state.modeArmedFor = null; setMode(defaultModeFor(els.target.value)); }
4279
+ if (was !== copilotOn() && els.target?.value) { state.modeArmedFor = null; setMode(nextModeFor(els.target.value)); }
4207
4280
  else renderPicker();
4208
4281
  if (!copilotMenu.hidden) toggleCopilotMenu(copilotMenu.anchor, { keep: true });
4209
4282
  }
@@ -4212,6 +4285,15 @@ async function loadCopilot() {
4212
4285
  }
4213
4286
  function ceilingFor(id) { return state.capabilities[id]?.scopes?.maxMode ?? 1; }
4214
4287
  function defaultModeFor(id) { return copilotOn() && canWrite(id) ? 3 : state.capabilities[id]?.scopes?.defaultMode ?? 1; }
4288
+ // Where the next message to an agent starts (Q-13, 2026-11-06). A permission still open for it (the
4289
+ // «#3 open» chip) is where it goes: it fell back to #1 after every message, so the agent read it,
4290
+ // answered «I need #3» and asked again, and each change cost a second turn. Within the agent's
4291
+ // ceiling, and only with the pass the project gave; the chip's × closes it and the mode goes back.
4292
+ const MODE_NICKS = { 0: () => t('Incognito'), 1: () => t('Chat'), 2: () => t('Create'), 3: () => t('Edit'), 4: () => t('Full access') };
4293
+ function nextModeFor(id) {
4294
+ for (const mode of [4, 3]) if (overrideGraceLeft(mode, id) && overridePass(mode, id) && mode <= ceilingFor(id)) return mode;
4295
+ return defaultModeFor(id);
4296
+ }
4215
4297
 
4216
4298
  // The robot beside mode · model · effort: what the copilot does, its switch and how long.
4217
4299
  const copilotMenu = el('div', 'model-menu copilot-menu');
@@ -4257,7 +4339,7 @@ function toggleCopilotMenu(anchor, { keep = false } = {}) {
4257
4339
  title.append(toggle);
4258
4340
  const body = el('div', 'copilot-body');
4259
4341
  body.append(
4260
- el('p', 'copilot-lead', t('The agent you write to drives the project: it edits, makes plans with the other agents (each step can go up to #3 EDIT), and runs the safe commands — reading, tests, builds, local git — on its own.')),
4342
+ el('p', 'copilot-lead', t('The agent you write to drives the project: it edits and makes plans with the other agents (each step can go up to #3 EDIT). It runs on its own only the commands that read; tests, builds and commits wait for your click.')),
4261
4343
  el('p', 'copilot-never', t('It never deletes, never touches MADRE\'s folders or your secrets, and never pushes, publishes or sends anything off this computer: that stays with you.')),
4262
4344
  );
4263
4345
  if (on) {
@@ -4281,6 +4363,13 @@ function openCopilotKey(minutes) {
4281
4363
  openOverride(els.target.value, { mode: 3, copilot: minutes, forceKey: true });
4282
4364
  }
4283
4365
 
4366
+ // Whether the computer MADRE runs on lacks git (D-5): the server writes it into the page
4367
+ // (<meta name="madre-host">), and the modes that write, which need a restore point, say so before
4368
+ // they are chosen instead of failing with «spawn git ENOENT» after.
4369
+ function hostLacksGit() {
4370
+ try { return JSON.parse(document.querySelector('meta[name="madre-host"]')?.content ?? 'null')?.git === false; } catch { return false; }
4371
+ }
4372
+
4284
4373
  function toggleModeMenu(id, anchor) {
4285
4374
  if (!modeMenu.hidden && modeMenuFor === id) { closeModeMenu(); return; }
4286
4375
  closeModelMenu();
@@ -4312,23 +4401,25 @@ function toggleModeMenu(id, anchor) {
4312
4401
  body.append(el('span', 'name', sentence(MODES[n].label)), el('span', 'hint', chatShellOn() ? MODE_BRIEF[n] : MODES[n].hint));
4313
4402
  option.append(el('span', 'n', `#${n}`), body);
4314
4403
  if (onTheMac) option.title = t('#3 EDIT and #4 FULL ACCESS are opened from the Mac.');
4404
+ const noGit = n >= 2 && !locked && hostLacksGit();
4315
4405
  // In the chat shell the list is quieter (2026-10-26): the mode in use wears a check, and #3 and
4316
4406
  // #4 say nothing of their confirming — the unlock itself asks.
4317
4407
  // The agent's default mode wears the same light badge as the default model, in use or not.
4318
4408
  if (chatShellOn()) {
4319
- const note = onTheMac ? t('ON THE MAC') : raise ? t('RAISE TO #{n} ›', { n }) : locked ? t('LOCKED') : '';
4409
+ const note = onTheMac ? t('ON THE MAC') : raise ? t('RAISE TO #{n} ›', { n }) : locked ? t('LOCKED') : noGit ? t('NEEDS GIT') : '';
4320
4410
  if (note) option.append(el('span', `tag${raise ? ' raise' : ''}`, note));
4321
4411
  else if (n === defaultModeFor(id)) option.querySelector('.name')?.append(el('span', 'model-default', t('default')));
4322
4412
  if (state.mode === n) option.append(menuCheck());
4323
4413
  } else {
4324
- const tag = state.mode === n ? t('NOW') : onTheMac ? t('ON THE MAC') : raise ? t('RAISE TO #{n} ›', { n }) : locked ? t('LOCKED') : n === 4 ? t('CONFIRM ×2') : n === 3 ? t('CONFIRM') : n === defaultModeFor(id) ? t('DEFAULT') : '';
4414
+ const tag = state.mode === n ? t('NOW') : onTheMac ? t('ON THE MAC') : raise ? t('RAISE TO #{n} ›', { n }) : locked ? t('LOCKED') : noGit ? t('NEEDS GIT') : n === 4 ? t('CONFIRM ×2') : n === 3 ? t('CONFIRM') : n === defaultModeFor(id) ? t('DEFAULT') : '';
4325
4415
  if (tag) {
4326
4416
  const label = el('span', `tag${raise ? ' raise' : ''}`, tag);
4327
4417
  if (state.mode === n) label.append(el('span', 'dot'));
4328
4418
  option.append(label);
4329
4419
  }
4330
4420
  }
4331
- option.title = !locked ? MODES[n].hint
4421
+ option.title = noGit ? t('This computer does not have git, which MADRE needs to take the restore point before an AI writes. Install git and reload this page.')
4422
+ : !locked ? MODES[n].hint
4332
4423
  : raise ? t('@{id} is capped at #{cap}. This raises its max mode to #{n} in Settings › Permissions and opens the unlock.', { id, cap, n })
4333
4424
  : n >= 3 ? `@${id}'s CLI cannot write files, so ${MODES[n].label} is not possible for it.`
4334
4425
  : t("Above @{id}'s max mode (#{cap}). Raise it in Settings › Permissions.", { id, cap });
@@ -4378,7 +4469,7 @@ function resetModeAfterSend() {
4378
4469
  if (state.typedTarget && state.agents.has(state.typedTarget.from)) els.target.value = state.typedTarget.from;
4379
4470
  state.typedTarget = null;
4380
4471
  state.typedPending = null;
4381
- setMode(defaultModeFor(els.target.value));
4472
+ setMode(nextModeFor(els.target.value));
4382
4473
  }
4383
4474
 
4384
4475
  // What is typed shows before it is sent. A leading @agent moves the picker to it, with its model and
@@ -4442,6 +4533,7 @@ const override = {
4442
4533
  again: false, // the second time, for #4
4443
4534
  key: 'confirm', // the key chosen in AJUSTES › Permissions for this mode
4444
4535
  words: [], // what was typed, once or twice, sent to the project to be checked
4536
+ module: null, // installing a module: handed what was typed, it goes with the install
4445
4537
  };
4446
4538
  // The key for #3 and #4 is an alert of the room, said plainly: what the mode lets the agent do in
4447
4539
  // one sentence, what keeps it safe in a quieter one, and the field says what to type.
@@ -4482,11 +4574,14 @@ function overrideGraceLeft(mode, agent) {
4482
4574
  overrideGrace.delete(`${mode}:${agent}`);
4483
4575
  return 0;
4484
4576
  }
4485
- function closeOverrideGrace(mode = null, agent = null) {
4577
+ function closeOverrideGrace(mode = null, agent = null, { back = false } = {}) {
4486
4578
  for (const key of [...overrideGrace.keys()]) {
4487
4579
  const [m, a] = key.split(':');
4488
4580
  if ((mode === null || Number(m) === mode) && (agent === null || a === agent)) { overrideGrace.delete(key); overridePasses.delete(key); }
4489
4581
  }
4582
+ // Closed by hand, or by STOP ALL: a message waiting at that mode goes back to where it starts. Not
4583
+ // when a send closes it to ask for the key again: that message goes at its mode once the key is in.
4584
+ if (back && els.target?.value && state.mode >= 3 && !overrideGraceLeft(state.mode, els.target.value)) setMode(nextModeFor(els.target.value));
4490
4585
  renderPicker();
4491
4586
  }
4492
4587
  // The chip counts down only while a grace is open; with none, nothing ticks.
@@ -4496,6 +4591,8 @@ function tickGrace() {
4496
4591
  graceTick = setInterval(() => {
4497
4592
  const before = overrideGrace.size;
4498
4593
  for (const key of [...overrideGrace.keys()]) { const [m, a] = key.split(':'); overrideGraceLeft(Number(m), a); }
4594
+ // Run out: the next message no longer starts at that mode, and the box says so (Q-13).
4595
+ if (overrideGrace.size !== before && els.target?.value && state.mode >= 3 && !overrideGraceLeft(state.mode, els.target.value) && !state.typedPending) setMode(nextModeFor(els.target.value));
4499
4596
  if (overrideGrace.size !== before) renderPicker();
4500
4597
  else for (const chip of document.querySelectorAll('.grace-chip')) chip.querySelector('.left').textContent = graceWords(overrideGraceLeft(Number(chip.dataset.mode), chip.dataset.agent));
4501
4598
  if (!overrideGrace.size) { clearInterval(graceTick); graceTick = null; }
@@ -4519,7 +4616,32 @@ function askOverrideKey(stage, { again = false } = {}) {
4519
4616
  override.form.querySelector('.k').textContent = again ? t('Type your phrase again') : t('Type your phrase');
4520
4617
  override.input.placeholder = '';
4521
4618
  // Back at the first ask (a new key, or one the project turned down), the key says it again.
4522
- if (!again && override.arm) override.arm.textContent = override.copilot ? t('Turn on') : override.mode === 4 ? t('Open') : t('Unlock');
4619
+ if (!again && override.arm) override.arm.textContent = override.module ? t('Install') : override.copilot ? t('Turn on') : override.mode === 4 ? t('Open') : t('Unlock');
4620
+ }
4621
+ // A module installed by hand still asks for the #4 key with the install (2026-11-02).
4622
+ // Answers what was typed, or null if they walked away.
4623
+ function askModuleKey({ title, what, safe = t('MADRE checks that it loads and keeps to the house rules; what it intends, only you can judge.') }) {
4624
+ return new Promise((resolve) => {
4625
+ if (!override.dialog) { resolve(null); return; }
4626
+ override.module = { title, what, safe, resolve };
4627
+ override.copilot = 0;
4628
+ override.raise = false;
4629
+ override.mode = 4;
4630
+ override.then = null;
4631
+ override.cancelled = () => { override.module = null; resolve(null); };
4632
+ override.key = overrideKeyFor(4);
4633
+ askOverrideKey(overrideStage(override.key));
4634
+ override.title.textContent = title;
4635
+ override.dialog.classList.add('m4');
4636
+ override.brief.textContent = what;
4637
+ override.safe.textContent = safe;
4638
+ override.raised.hidden = true;
4639
+ override.raised.textContent = '';
4640
+ override.reply.textContent = '';
4641
+ override.reply.className = 'key-reply';
4642
+ override.dialog.showModal();
4643
+ (override.input.hidden ? override.arm : override.input).focus();
4644
+ });
4523
4645
  }
4524
4646
  function openOverride(id, { raise = false, mode = 3, then = null, cancelled = null, preserveComposer = false, forceKey = false, minutes = 0, copilot = 0 } = {}) {
4525
4647
  if (!override.dialog) return;
@@ -4528,6 +4650,7 @@ function openOverride(id, { raise = false, mode = 3, then = null, cancelled = nu
4528
4650
  const left = raise || forceKey ? 0 : overrideGraceLeft(mode, id);
4529
4651
  if (left) { void grantOverride({ agent: id, raise: false, mode, then, delay: 0, left, preserveComposer }); return; }
4530
4652
  override.agent = id;
4653
+ override.module = null;
4531
4654
  // The copilot's key: the same #3 key, opening the copilot for that long instead of one agent.
4532
4655
  override.copilot = copilot || 0;
4533
4656
  // A window chosen on an agent's request, instead of the one set in Permissions.
@@ -4550,7 +4673,7 @@ function openOverride(id, { raise = false, mode = 3, then = null, cancelled = nu
4550
4673
  if (!slot && override.form) { slot = el('div', 'tour-hint-slot'); override.form.before(slot); }
4551
4674
  if (slot) void roomTour().hint('key4', slot, { inside: true, title: t('#4 asks you to confirm twice'), text: t('With #4 the agent may run commands, publish and deploy: what leaves your Mac does not come back. That is why it asks you to confirm twice.') });
4552
4675
  }
4553
- override.brief.textContent = override.copilot ? t('The agent you write to edits the project and runs the safe commands by itself, without asking you to confirm each message, until it ends.') : OVERRIDE_BRIEF[mode].what(id);
4676
+ override.brief.textContent = override.copilot ? t('The agent you write to edits the project without asking you to confirm each message, until it ends. It runs on its own only the commands that read; tests, builds and commits wait for your click.') : OVERRIDE_BRIEF[mode].what(id);
4554
4677
  override.safe.textContent = override.copilot ? t('It never deletes, pushes, publishes or deploys; each change gets a restore point; STOP ALL ends it.') : OVERRIDE_BRIEF[mode].safe();
4555
4678
  override.raised.hidden = !raise;
4556
4679
  override.raised.textContent = raise ? t('This also raises its max mode to #{n}.', { n: mode }) : '';
@@ -4584,10 +4707,21 @@ override.form?.addEventListener('submit', async (event) => {
4584
4707
  askOverrideKey(override.stage, { again: true });
4585
4708
  override.reply.textContent = override.stage === 'phrase' ? t('Type it once more to open it.') : t('Confirm once more to open it: what leaves your computer does not come back.');
4586
4709
  override.reply.className = 'key-reply';
4587
- if (override.stage === 'confirm') override.arm.textContent = t('Yes, open #4');
4710
+ if (override.module) override.reply.textContent = override.stage === 'phrase' ? t('Type it once more to install it.') : t('Confirm once more to install it: review its code and network destinations.');
4711
+ if (override.stage === 'confirm') override.arm.textContent = override.module ? t('Yes, install') : t('Yes, open #4');
4588
4712
  (override.input.hidden ? override.arm : override.input).focus();
4589
4713
  return;
4590
4714
  }
4715
+ // A module's key is not checked here: it goes with the install, and the project checks both.
4716
+ if (override.module) {
4717
+ const { resolve } = override.module;
4718
+ const words = [...override.words];
4719
+ override.module = null;
4720
+ override.cancelled = null;
4721
+ override.dialog.close();
4722
+ resolve(words);
4723
+ return;
4724
+ }
4591
4725
  override.arm.disabled = true;
4592
4726
  let answer;
4593
4727
  try {
@@ -5087,6 +5221,33 @@ function subDetail(one, mode) {
5087
5221
  return item;
5088
5222
  }
5089
5223
  // The chips under «working…»: drawn again each time the CLI says something new about them.
5224
+ // WHICH WAY OF WORKING WENT INTO THIS TURN, said while it works (H-3). Pressing one opens what it
5225
+ // says: a skill nobody can see is a skill nobody can switch off when it was the wrong one.
5226
+ function showSkills(event) {
5227
+ const { messageId, skills = [] } = event.payload ?? {};
5228
+ const node = document.getElementById(`working-${messageId}`);
5229
+ if (!node || !skills.length) return;
5230
+ let strip = node.querySelector(':scope > .turn-skills');
5231
+ if (!strip) { strip = el('div', 'turn-skills'); node.append(strip); }
5232
+ strip.replaceChildren();
5233
+ strip.append(el('span', 'sx-hint', skills.length === 1 ? t('Skill:') : t('Skills:')));
5234
+ for (const skill of skills) {
5235
+ const name = skillWords(skill.name) ?? skill.id;
5236
+ const chip = el('button', 'turn-skill', name);
5237
+ chip.type = 'button';
5238
+ chip.title = skill.state === 'always' ? t('You keep it on in this project. Press to read it.') : skill.why?.length ? t('It came in because you said: {words}. Press to read it.', { words: skill.why.join(', ') }) : t('Press to read it.');
5239
+ chip.addEventListener('click', () => void openSkillById(skill.id));
5240
+ strip.append(chip);
5241
+ }
5242
+ }
5243
+ // From the room, where only its name travelled: its text is read from the folder it lives in.
5244
+ async function openSkillById(id) {
5245
+ const data = await fetch('/api/skills').then((response) => response.json()).catch(() => null);
5246
+ const skill = (data?.skills ?? []).find((one) => one.id === id);
5247
+ if (!skill) { toast(t('No skill «{id}».', { id })); return; }
5248
+ openSkillText(skill);
5249
+ }
5250
+
5090
5251
  function showHelpers(event) {
5091
5252
  const { messageId, subagents = [], mode } = event.payload ?? {};
5092
5253
  const node = document.getElementById(`working-${messageId}`);
@@ -5455,9 +5616,11 @@ function plainQuote(text) {
5455
5616
  return said.length > REPLY_CLIP ? `${said.slice(0, REPLY_CLIP - 1)}…` : said;
5456
5617
  }
5457
5618
 
5619
+ // No message number (Q-14, 2026-11-06): «↩ @codex #4: …» read as #4 FULL ACCESS beside the modes
5620
+ // #0–#4. The quoted words say which answer it is.
5458
5621
  function quoteHead(reply) {
5459
5622
  if (!reply) return '';
5460
- return `↩ @${reply.sender}${reply.sequence ? ` #${reply.sequence}` : ''}: “${reply.text}”\n`;
5623
+ return `↩ @${reply.sender}: “${reply.text}”\n`;
5461
5624
  }
5462
5625
 
5463
5626
  function renderReplyQuote() {
@@ -5550,6 +5713,12 @@ const WORKING_VOICE = {
5550
5713
  late: [t('Working through it…'), t('Double-checking…'), t('Piecing it together…')],
5551
5714
  long: [t('Writing the response…'), t('Tidying the answer…'), t('Nearly done…')],
5552
5715
  },
5716
+ grok: {
5717
+ early: [t('Reading the repo…'), t('Searching the project…'), t('Grabbing context…')],
5718
+ middle: [t('Thinking…'), t('Digging through the code…'), t('Following the references…'), t('Looking closer…')],
5719
+ late: [t('Working through it…'), t('Double-checking…'), t('Piecing it together…')],
5720
+ long: [t('Writing the response…'), t('Tidying the answer…'), t('Nearly done…')],
5721
+ },
5553
5722
  opencode: {
5554
5723
  early: [t('Reading the repo…'), t('Listing files…'), t('Grabbing context…')],
5555
5724
  middle: [t('Thinking…'), t('Digging through the code…'), t('Following the call chain…'), t('Looking closer…')],
@@ -5763,7 +5932,7 @@ function claimHead(node, kind, who) {
5763
5932
  // module · @codex
5764
5933
  // Wrote read-mail.module.mjs.
5765
5934
  // [INSTALL FOR EVERY ROOM] [INSTALL FOR THIS PROJECT]
5766
- // Read it first: a module runs inside MADRE with your permissions.
5935
+ // Read the module file and its network destinations before installing it.
5767
5936
  function renderModuleProposed(event) {
5768
5937
  const { agent, path, name, responseMessageId } = event.payload;
5769
5938
  const node = el('div', 'system module-proposed');
@@ -5774,9 +5943,11 @@ function renderModuleProposed(event) {
5774
5943
  said.append(t('Wrote '), link);
5775
5944
  node.append(said);
5776
5945
  const install = async (scope, button) => {
5946
+ const words = await askModuleKey({ title: t('Install {name}?', { name: String(name ?? path).split('/').pop() }), what: t('A module runs in a separate Node process with limited permissions. Node cannot guarantee containment of malicious code. Review the file and its network destinations before installing it.') });
5947
+ if (!words) return;
5777
5948
  button.disabled = true;
5778
5949
  try {
5779
- const payload = await fetch('/api/extensions/install-file', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ path, scope }) }).then((response) => response.json());
5950
+ const payload = await fetch('/api/extensions/install-file', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ path, scope, words }) }).then((response) => response.json());
5780
5951
  if (payload.error) throw new Error(payload.error);
5781
5952
  toast(t('Diagnostics › {name} installed for {where}. Switch it on in MODULES.', { name: payload.installed.name, where: scope === 'project' ? t('this project') : t('every project') }));
5782
5953
  warnUnknownModuleFields(payload.installed);
@@ -5788,7 +5959,7 @@ function renderModuleProposed(event) {
5788
5959
  const thisProject = el('button', 'claim-act', t('INSTALL FOR THIS PROJECT')); thisProject.type = 'button'; thisProject.addEventListener('click', () => install('project', thisProject));
5789
5960
  const acts = el('span', 'claim-acts');
5790
5961
  acts.append(everyRoom, thisProject);
5791
- node.append(acts, el('span', 'claim-note', t('Read it first: a module runs inside MADRE with your permissions.')));
5962
+ node.append(acts, el('span', 'claim-note', t('Read the module file and its network destinations before installing it.')));
5792
5963
  // An agent asked to fix a module writes a new file beside the old one; the room keeps running
5793
5964
  // the copy that was installed until this one is. The card says so, or a fixed module looks
5794
5965
  // installed while the broken one keeps answering.
@@ -5803,6 +5974,59 @@ function renderModuleProposed(event) {
5803
5974
  if (responseMessageId) node.dataset.for = responseMessageId;
5804
5975
  return node;
5805
5976
  }
5977
+ // skill · @codex
5978
+ // Wrote cotizaciones.habilidad.md.
5979
+ // [READ IT] [INSTALL FOR EVERY PROJECT] [INSTALL FOR THIS PROJECT]
5980
+ //
5981
+ // A skill is a page of instructions, so «read it» is a real option here in a way it never is for a
5982
+ // module: the person can actually read the whole thing before any of their agents does.
5983
+ function renderSkillProposed(event) {
5984
+ const { agent, path, name, id, responseMessageId } = event.payload;
5985
+ const node = el('div', 'system module-proposed');
5986
+ tint(node, agent);
5987
+ claimHead(node, t('SKILL'), `@${agent}`);
5988
+ const link = el('a', 'file-link', name ?? path);
5989
+ link.href = '#';
5990
+ link.addEventListener('click', (ev) => { ev.preventDefault(); void openViewer({ root: 'project', path, label: `/${path}` }); });
5991
+ const said = el('span', 'claim-body');
5992
+ said.append(t('Wrote '), link);
5993
+ node.append(said);
5994
+ const ask = (extra = {}) => fetch('/api/skills/install-file', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ path, ...extra }) }).then((response) => response.json());
5995
+ const read = el('button', 'claim-act', t('READ IT'));
5996
+ read.type = 'button';
5997
+ read.addEventListener('click', async () => {
5998
+ const payload = await ask({ review: true });
5999
+ if (payload.error) { toast(t('It could not be read: {error}', { error: payload.error })); return; }
6000
+ openSkillText({ ...payload, dir: null, license: null, credit: payload.declares?.credit ?? null });
6001
+ });
6002
+ const install = async (scope, button) => {
6003
+ button.disabled = true;
6004
+ try {
6005
+ const payload = await ask({ scope });
6006
+ if (payload.error) throw new Error(payload.error);
6007
+ toast(t('Diagnostics › {name} is yours now, for {where}. It comes in when it fits; change that in MODULES.', { name: skillWords(payload.installed.name) ?? payload.installed.id, where: scope === 'project' ? t('this project') : t('every project') }));
6008
+ void refreshSkills();
6009
+ } catch (error) { toast(t('The skill was not installed: {error}', { error: error.message })); button.disabled = false; }
6010
+ };
6011
+ const everyRoom = el('button', 'claim-act', t('INSTALL FOR EVERY PROJECT'));
6012
+ everyRoom.type = 'button';
6013
+ everyRoom.addEventListener('click', () => install('user', everyRoom));
6014
+ const thisProject = el('button', 'claim-act', t('INSTALL FOR THIS PROJECT'));
6015
+ thisProject.type = 'button';
6016
+ thisProject.addEventListener('click', () => install('project', thisProject));
6017
+ const acts = el('span', 'claim-acts');
6018
+ acts.append(read, everyRoom, thisProject);
6019
+ node.append(acts, el('span', 'claim-note', t('A skill gives no permission: it tells your agents how you work, inside whatever mode you give them. Read it before it reaches them.')));
6020
+ // Already one by that name: the one installed keeps answering until this file replaces it.
6021
+ if (id && (modules.skills ?? []).some((one) => one.id === id)) {
6022
+ everyRoom.textContent = t('REPLACE FOR EVERY PROJECT');
6023
+ thisProject.textContent = t('REPLACE FOR THIS PROJECT');
6024
+ node.append(el('span', 'claim-note replaces', t('You already have a skill called «{id}»; it keeps coming into your turns until this file replaces it.', { id })));
6025
+ }
6026
+ if (responseMessageId) node.dataset.for = responseMessageId;
6027
+ return node;
6028
+ }
6029
+
5806
6030
  // The modules this room has, asked once per page load and shared by every card that wants to know.
5807
6031
  let installedModulesAsked = null;
5808
6032
  function installedModules() {
@@ -5969,6 +6193,10 @@ function renderDistilled(event) {
5969
6193
  // to the human, for an instruction of their own; NOT NOW folds the card. Both used to read as the
5970
6194
  // same press («GRANT AND CONTINUE» against «WRITE IT MYSELF») until one was pressed.
5971
6195
  const modeAsks = []; // { agent, wanted, card } still waiting for an answer in this page
6196
+ // How many times each agent asked for #3 in this page, live (Q-16, 2026-11-06): from the second one,
6197
+ // the card offers Copilot, which is what spares the asking. It was a small icon nobody found (30
6198
+ // copies turned it on, against 298 #3 messages).
6199
+ const threeAsks = new Map();
5972
6200
  function attachModeAsk(payload, { sequence = null } = {}) {
5973
6201
  if (!payload || payload.role !== 'assistant' || payload.sender === 'you') return null;
5974
6202
  const ran = state.userMessages.get(payload.messageId)?.mode ?? payload.mode ?? 1;
@@ -5977,6 +6205,8 @@ function attachModeAsk(payload, { sequence = null } = {}) {
5977
6205
  if (!wanted || wanted <= state.mode) return null;
5978
6206
  const agent = payload.sender;
5979
6207
  if (!state.agents.get(agent)?.ready) return null;
6208
+ // An agent that reads at every mode (Grok, Gemini through its API) cannot be given more: no card.
6209
+ if (wanted >= 2 && !canWrite(agent)) return null;
5980
6210
  const label = MODES[wanted]?.label ?? '';
5981
6211
  const card = el('div', 'mode-ask');
5982
6212
  tint(card, agent);
@@ -6020,6 +6250,19 @@ function attachModeAsk(payload, { sequence = null } = {}) {
6020
6250
  later.type = 'button';
6021
6251
  actions.append(go, myself, later);
6022
6252
  card.append(what, why, ...(time ? [time] : []), actions);
6253
+ if (wanted === 3 && !replaying) {
6254
+ const times = (threeAsks.get(agent) ?? 0) + 1;
6255
+ threeAsks.set(agent, times);
6256
+ if (times >= 2 && !copilotOn() && canWrite(agent)) {
6257
+ const tip = el('div', 'mode-why mode-copilot', t('@{agent} asked for #3 again. With Copilot it edits without asking at every step, for as long as you choose.', { agent }));
6258
+ const see = el('button', 'mode-alt', t('SEE COPILOT'));
6259
+ see.type = 'button';
6260
+ // Opened where it lives, by the box; the click stops here, or the page would close it at once.
6261
+ see.addEventListener('click', (event) => { event.stopPropagation(); toggleCopilotMenu(document.querySelector('.copilot-chip') ?? see, { keep: true }); });
6262
+ tip.append(' ', see);
6263
+ card.append(tip);
6264
+ }
6265
+ }
6023
6266
  const quoted = { sender: agent, sequence, text: plainQuote(payload.text) };
6024
6267
  const ask = { agent, wanted, card };
6025
6268
  modeAsks.push(ask);
@@ -6150,7 +6393,7 @@ function attachMemoryHint(event) {
6150
6393
  pill.type = 'button';
6151
6394
  pill.style.setProperty('--kind', MEMORY_COLORS[note.kind] ?? MEMORY_COLORS.fact);
6152
6395
  pill.append(el('b', null, kindWord(note.kind).toLowerCase()), ` ${note.text.length > 64 ? `${note.text.slice(0, 63)}…` : note.text}`);
6153
- pill.title = `${note.text}\n${t('Saved by @{agent} for every future turn · #{from}–#{through}. Click to see it in the memory map.', { agent, from: note.fromSequence, through: note.throughSequence })}`;
6396
+ pill.title = `${note.text}\n${note.unsourced ? t('Saved by @{agent} for every future turn, with no source. Click to see it in the memory map.', { agent }) : t('Saved by @{agent} for every future turn · #{from}–#{through}. Click to see it in the memory map.', { agent, from: note.fromSequence, through: note.throughSequence })}`;
6154
6397
  pill.addEventListener('click', () => { nostromo.focusId = note.id; nostromo.button?.click(); });
6155
6398
  hint.append(pill);
6156
6399
  }
@@ -6475,18 +6718,18 @@ function renderControlStarted(event) {
6475
6718
  const node = el('div', 'system control');
6476
6719
  tint(node, agent);
6477
6720
  node.append(el('b', null, sentence(t('EDIT'))), el('b', 'who', `@${agent}`), t(' holds the project · restore point '), el('code', null, (commit ?? '').slice(0, 7)));
6478
- node.title = message;
6479
- if (!replaying) toast(t('Diagnostics › @{agent} holds EDIT mode. Restore point taken; UNDO will be one click.', { agent }));
6721
+ // Said once, in the conversation (Q-15): a toast beside it repeated the same thing.
6722
+ node.title = t('@{agent} holds EDIT mode. Restore point taken; UNDO will be one click.', { agent });
6480
6723
  state.lastSender = null;
6481
6724
  return node;
6482
6725
  }
6483
6726
  function renderControlChanged(event) {
6484
- const { agent, checkpointId, files = [], stat, forbiddenReverted = [], message, unreadable = null } = event.payload;
6485
- const node = el('div', `system control changed${files.length || unreadable ? '' : ' quiet'}`);
6727
+ const { agent, checkpointId, files = [], stat, forbiddenReverted = [], message, unreadable = null, outsideRestore = [], outsideCreated = [], outsideModified = [] } = event.payload;
6728
+ const node = el('div', `system control changed${files.length || unreadable || outsideRestore.length || outsideCreated.length ? '' : ' quiet'}`);
6486
6729
  node.id = `control-${checkpointId}`;
6487
6730
  tint(node, agent);
6488
6731
  const head = el('div', 'head');
6489
- head.append(el('b', null, sentence(t('EDIT'))), el('b', 'who', `@${agent}`), el('span', null, (unreadable ? t('could not read what changed') : files.length === 1 ? t(' changed 1 file') : files.length ? t(' changed {n} files', { n: files.length }) : t(' changed nothing')).trim()));
6732
+ head.append(el('b', null, sentence(t('EDIT'))), el('b', 'who', `@${agent}`), el('span', null, (unreadable ? t('could not read what changed') : files.length === 1 ? t(' changed 1 file') : files.length ? t(' changed {n} files', { n: files.length }) : (outsideRestore.length || outsideCreated.length) ? t(' wrote only in folders git ignores') : t(' changed nothing')).trim()));
6490
6733
  node.append(head);
6491
6734
  // The turn finished; only the reading of it did not. The checkpoint is still the way back.
6492
6735
  if (unreadable) node.append(el('div', 'forbidden', t('Git could not list the changes ({reason}). The restore point from before the turn is still there.', { reason: unreadable.slice(0, 160) })));
@@ -6507,7 +6750,15 @@ function renderControlChanged(event) {
6507
6750
  if (stat) { const pre = el('pre', 'stat', statWords(stat.split('\n').slice(-1)[0])); pre.title = stat; node.append(pre); }
6508
6751
  }
6509
6752
  if (forbiddenReverted.length) node.append(el('div', 'forbidden', t('{n} writes into forbidden zones reverted: {where}', { n: forbiddenReverted.length, where: forbiddenReverted.join(', ') })));
6510
- if (files.length || unreadable) {
6753
+ // Written where git does not look (L-5, L-5b): newly created files in light ignored folders
6754
+ // will be removed on UNDO; preexisting ones that were modified cannot be brought back.
6755
+ if (outsideCreated.length) node.append(el('div', 'forbidden', t('In folders git ignores (created; UNDO removes them): {where}', { where: outsideCreated.slice(0, 8).join(', ') + (outsideCreated.length > 8 ? ', …' : '') })));
6756
+ // Everything else written there stays on UNDO: changed files that were there before, and ones that
6757
+ // could not be told new from old because those folders hold too many files (L-5b).
6758
+ const left = outsideRestore.filter((path) => !outsideCreated.includes(path));
6759
+ const leftShown = left.length ? left : outsideModified;
6760
+ if (leftShown.length) node.append(el('div', 'forbidden', t('Outside the restore point, because git ignores them; UNDO does not bring them back: {where}', { where: leftShown.slice(0, 8).join(', ') + (leftShown.length > 8 ? ', …' : '') })));
6761
+ if (files.length || unreadable || outsideCreated.length) {
6511
6762
  const undo = el('button', 'undo', t('UNDO · GO BACK TO THE RESTORE POINT'));
6512
6763
  undo.type = 'button';
6513
6764
  undo.title = t('Put the project back exactly as it was before this EDIT turn.');
@@ -6537,7 +6788,7 @@ function renderControlReverted(event) {
6537
6788
  node.title = message;
6538
6789
  const card = document.getElementById(`control-${checkpointId}`);
6539
6790
  card?.querySelector('.undo')?.replaceWith(el('span', 'outcome', t('RESTORED')));
6540
- if (!replaying) toast(`${t('Diagnostics › ')}${message}`);
6791
+ // Said once, in the conversation (Q-15): the toast repeated it, in English, as «CONTROL».
6541
6792
  state.lastSender = null;
6542
6793
  return node;
6543
6794
  }
@@ -6929,7 +7180,9 @@ function renderRunRequest(event) {
6929
7180
  const button = el('button', `choice-option run-line${command.argv ? '' : ' refused'}`);
6930
7181
  button.type = 'button';
6931
7182
  button.dataset.index = String(index);
6932
- button.append(el('span', 'choice-key', '$'), el('code', 'choice-text', command.line));
7183
+ const code = el('code', 'choice-text', command.line);
7184
+ if (command.script) code.append(el('span', 'run-script', command.script));
7185
+ button.append(el('span', 'choice-key', '$'), code);
6933
7186
  if (!command.argv) {
6934
7187
  button.disabled = true;
6935
7188
  button.append(el('span', 'choice-tag', t('WILL NOT RUN')));
@@ -6938,7 +7191,10 @@ function renderRunRequest(event) {
6938
7191
  return;
6939
7192
  }
6940
7193
  button.append(el('span', 'choice-tag', t('RUN')));
6941
- button.title = t('Runs {command} from the project root, with no shell. A restore point is taken first.', { command: command.line });
7194
+ // The script package.json held when the agent asked (src/runs.mjs, attachCommandScripts, RX-3).
7195
+ button.title = command.script
7196
+ ? t('Runs {command} ({script}) from the project root, with no shell. A restore point is taken first.', { command: command.line, script: command.script })
7197
+ : t('Runs {command} from the project root, with no shell. A restore point is taken first.', { command: command.line });
6942
7198
  button.addEventListener('click', () => { void pressRun(button, { responseMessageId, index, startedAt: event.timestamp }); });
6943
7199
  list.append(button);
6944
7200
  });
@@ -7452,7 +7708,7 @@ async function stopAll() {
7452
7708
  const button = document.querySelector('#stop-all');
7453
7709
  if (button) button.disabled = true;
7454
7710
  // STOPALL revokes it: every key still holding from a grace is closed with the turns.
7455
- if (overrideGrace.size) closeOverrideGrace();
7711
+ if (overrideGrace.size) closeOverrideGrace(null, null, { back: true });
7456
7712
  try {
7457
7713
  const response = await fetch('/api/stop-all', { method: 'POST' });
7458
7714
  if (!response.ok) { toast(t('STOPALL failed to reach the project.')); return; }
@@ -7861,6 +8117,7 @@ function renderEventNode(event) {
7861
8117
  case 'agent.started': state.running.set(event.payload.messageId, event.payload.agent); updateStopAll(); node = renderThinking(event); break;
7862
8118
  case 'turn.reading': showReading(event); return;
7863
8119
  case 'turn.subagents': showHelpers(event); return;
8120
+ case 'turn.skills': showSkills(event); return;
7864
8121
  // Who has a session, once the probe that runs when the project starts comes back: the crew is
7865
8122
  // drawn again, so a first message never goes to an agent without one (QA 1.1.0, NUE-11).
7866
8123
  case 'sessions.updated': {
@@ -7887,6 +8144,7 @@ function renderEventNode(event) {
7887
8144
  case 'message.rated': { const { messageId: rated, rating } = event.payload; if (rating === 'none') state.ratings.delete(rated); else state.ratings.set(rated, rating); state.ratingNodes.get(rated)?.apply(rating === 'none' ? null : rating); return; }
7888
8145
  case 'privacy.redacted': node = renderPrivacy(event); break;
7889
8146
  case 'module.proposed': node = renderModuleProposed(event); break;
8147
+ case 'skill.proposed': node = renderSkillProposed(event); break;
7890
8148
  // A module from the Market, a file or an update: its card and its commands, at once (2026-10-30).
7891
8149
  case 'extension.installed': case 'extension.removed': if (!replaying) { void refreshCommands(); installedModulesAsked = null; void refreshModules(); } node = renderModuleInstalledOrRemoved(event); break;
7892
8150
  case 'privacy.purged': node = renderPrivacy(event); break;
@@ -8048,10 +8306,11 @@ function renderEventNode(event) {
8048
8306
  // its piece, and after ten seconds — later if the pointer is on it — it becomes a dot in the
8049
8307
  // colour of its kind, beside the dots around it; a click opens it again with everything it said.
8050
8308
  // What still asks for something stays as it is: a failure with its RETRY, a permission waiting, a
8051
- // module to install, the changes a turn made with their UNDO, MU/TH/UR. History folds at once.
8309
+ // module to install, MU/TH/UR. History folds at once. The changes a turn made fold too (2026-11-08):
8310
+ // a card per turn was a wall between the answers, and its UNDO is one click away inside its dot.
8052
8311
  const NOTICE_FOLD_MS = 10000;
8053
8312
  // A limit warning folds too (2026-10-14): the agent's ring in the bar already says it, in red.
8054
- const NOTICE_KEEP = '.fail, .mother-alert, .mother, .escalation, .lease.missing, .lease.refused, .module-proposed, .control.changed, .local-model, .memory.forgotten';
8313
+ const NOTICE_KEEP = '.fail, .mother-alert, .mother, .escalation, .lease.missing, .lease.refused, .module-proposed, .local-model, .memory.forgotten';
8055
8314
  // In the chat shell a failure folds too (2026-10-27), into a red dot, once nothing on it waits for
8056
8315
  // a press (noticeWaits): RETRY and the way out of a provider keep it open while they are live.
8057
8316
  // But not one that is the only answer to something the person asked (QA 1.1.0, NUE-13): reloaded,
@@ -8066,6 +8325,8 @@ function noticeTone(node) {
8066
8325
  // A notice folds only once it asks for nothing: any button still live keeps it open. STOP ALL on
8067
8326
  // an alert is the exception — the brake lives in the bar too.
8068
8327
  function noticeWaits(node) {
8328
+ // The changes a turn made ask for nothing: UNDO and the files stay inside the dot.
8329
+ if (node.matches('.control.changed')) return false;
8069
8330
  return [...node.querySelectorAll('button')].some((button) => !button.disabled && !button.hidden && !button.classList.contains('cmd'));
8070
8331
  }
8071
8332
  function foldableNotice(node) {
@@ -8847,7 +9108,7 @@ const SETTINGS_INDEX = [
8847
9108
  ['files', 'Files'], ['files', 'Your servers'], ['files', 'File viewer'], ['files', 'Preview'], ['files', "Test browser"],
8848
9109
  ['room', 'Usage limit per agent'], ['room', 'Default time limit'], ['room', 'Silence limit'], ['room', 'Retries'], ['room', 'Model'],
8849
9110
  ['agents', 'Max mode'], ['agents', 'Starting mode'], ['agents', 'Web access'], ['agents', 'Generate images'], ['agents', 'Time limit'], ['agents', 'Sign in'],
8850
- ['memory', 'Who takes notes first'], ['memory', 'Who may take notes'], ['memory', 'Room for memories'], ['memory', 'Related memories'], ['memory', 'Search by meaning'], ['memory', 'Training data'], ['memory', 'Details and checkups'],
9111
+ ['memory', 'Who does it first'], ['memory', 'Who may do it'], ['memory', 'How many notes it hands over'], ['memory', 'Related notes'], ['memory', 'Search by meaning'], ['memory', 'Training data'], ['memory', 'Details and checkups'],
8851
9112
  ['mcp', 'Outside tools (MCP)'], ['mcp', 'Add a tool'], ['mcp', 'Import from your apps'], ['mcp', 'Can act from'],
8852
9113
  ['permissions', 'How you unlock modes'], ['permissions', 'Your phrase'], ['permissions', 'Remember permission'], ['permissions', 'Memory access'], ['permissions', 'Who may do what'],
8853
9114
  ['privacy', 'Words to hide'], ['privacy', 'Replaced with'], ['privacy', 'Access keys and emails'], ['privacy', 'Your home folder'], ['privacy', 'Erase private data'],
@@ -8874,8 +9135,8 @@ function settingsStatus(id) {
8874
9135
  }
8875
9136
  if (id === 'room') {
8876
9137
  const turns = turnsUI.turns;
8877
- const how = !turns ? t('Reading…') : turns.enabled ? t('Several at once · {n}', { n: turns.chats }) : t('One conversation at a time');
8878
- return { line: data ? `${how} · ${t('{n} tokens per agent', { n: formatTokens(data.settings.softTokenBudget) })}` : how };
9138
+ const how = !turns ? t('Reading…') : turns.enabled ? t('{n} conversations at once', { n: turns.chats }) : t('One conversation at a time');
9139
+ return { line: data ? `${how} · ${t('up to {n} tokens per AI every 5 hours', { n: formatTokens(data.settings.softTokenBudget) })}` : how };
8879
9140
  }
8880
9141
  if (id === 'files') {
8881
9142
  const finder = surfaceModes.tree === 'window' ? t('Files as a window') : t('Files beside');
@@ -8902,7 +9163,9 @@ function settingsStatus(id) {
8902
9163
  const mem = data.settings.memory;
8903
9164
  if (!mem) return { line: t('This project has no memory yet') };
8904
9165
  const who = mem.archivist === 'auto' || !mem.archivist ? t('the cheapest agent') : `@${mem.archivist}`;
8905
- return { line: t('Notes: {who} · search: {how}', { who, how: (mem.embedProvider ?? 'auto').toUpperCase() }) };
9166
+ // Who writes the notes and how they are found, in words (1.1): «search: AUTO» told nobody anything.
9167
+ const how = { ollama: t('with the AI on your computer'), gemini: t('with Gemini'), off: t('by exact words') }[mem.embedProvider] ?? t('the best way available');
9168
+ return { line: t('Notes by {who} · found {how}', { who, how }) };
8906
9169
  }
8907
9170
  if (id === 'permissions') {
8908
9171
  const config = data.settings.override ?? OVERRIDE_DEFAULT;
@@ -8958,13 +9221,25 @@ function settingsQuick(id) {
8958
9221
  renderMotherSentinel();
8959
9222
  }));
8960
9223
  }
9224
+ // The agents as a quick way in (2026-11-07), as in Home: each one's mark and its session, three to
9225
+ // a row; a tile opens that agent in the panel (settingsCard wires the click).
8961
9226
  if (id === 'agents' && settingsUI.data) {
8962
- for (const agent of settingsUI.data.agents.filter((one) => one.detected)) {
9227
+ rows.classList.add('agents-grid');
9228
+ for (const agent of settingsUI.data.agents.filter((one) => one.detected && one.id !== 'madre')) {
8963
9229
  const session = settingsUI.data.sessions?.[agent.id]?.state;
8964
- const row = el('div', 'settings-quick-row agent');
8965
- row.append(paint(el('span', 'who'), agent.id), el('span', `state session-lamp ${session === 'signed-in' ? 'on ok' : session === 'signed-out' ? 'off bad' : 'wait'}`, session === 'signed-in' ? t('signed in') : session === 'signed-out' ? t('no session') : t('unknown')));
8966
- row.firstChild.textContent = agent.label;
8967
- rows.append(row);
9230
+ const said = session === 'signed-in' ? t('signed in') : session === 'signed-out' ? t('no session') : t('unknown');
9231
+ const tile = el('button', 'settings-quick-tile agent');
9232
+ tile.type = 'button';
9233
+ tile.dataset.agent = agent.label;
9234
+ tile.setAttribute('aria-label', `${agent.label} · ${said}`);
9235
+ // The mark on its own colour, as Home draws it (salas-mac.js, mark): not the conversation's ring.
9236
+ const brand = brandOf(agent.id);
9237
+ const face = el('span', 'settings-agent-mark');
9238
+ face.style.setProperty('--b', brand.solid ?? brand.color);
9239
+ face.style.setProperty('--b-ink', brand.ink);
9240
+ face.innerHTML = brand.mark(); // trusted: our own SVG strings from brands.js
9241
+ tile.append(face, el('span', `state session-lamp ${session === 'signed-in' ? 'on ok' : session === 'signed-out' ? 'off bad' : 'wait'}`, said));
9242
+ rows.append(tile);
8968
9243
  }
8969
9244
  }
8970
9245
  if (id === 'privacy' && settingsUI.data?.settings.privacy) {
@@ -9213,6 +9488,10 @@ function settingsCard(id) {
9213
9488
  if (status.warn) card.append(el('p', 'settings-warn', status.warn));
9214
9489
  const quick = settingsQuick(id);
9215
9490
  if (quick) card.append(quick);
9491
+ // An agent's tile goes straight to that agent, not to the list.
9492
+ for (const tile of quick?.querySelectorAll('.settings-quick-tile.agent') ?? []) {
9493
+ tile.addEventListener('click', (event) => { event.stopPropagation(); openSettingsCategory('agents', tile.dataset.agent); });
9494
+ }
9216
9495
  const go = () => (id === 'manual' ? openManual() : openSettingsCategory(id));
9217
9496
  card.addEventListener('click', go);
9218
9497
  card.addEventListener('keydown', (event) => { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); go(); } });
@@ -12264,21 +12543,12 @@ function tradePanes() {
12264
12543
  panes.swap?.addEventListener('click', () => tradePanes());
12265
12544
  if (!SPLIT_CHAT) paintPanes();
12266
12545
 
12267
- /* ---------- easter egg: hold the scroll at the end of the record ---------- */
12546
+ /* ---------- easter egg: MOTHER reviews the next message ---------- */
12268
12547
 
12269
- // A trackpad only reports while the fingers move, so "holding the scroll
12270
- // down" arrives as bursts. We count distinct downward pushes at the end of
12271
- // the record: at least three of them, spanning six seconds, with no more
12272
- // than two seconds of silence between pushes and no push upward.
12273
- const HOLD_MS = 4000;
12274
- const HOLD_GAP_MS = 2000;
12275
- const HOLD_MIN_PUSHES = 3;
12276
- const BURST_MS = 150;
12277
- let pushes = [];
12278
-
12279
- function atBottom() {
12280
- return scroller.height - scroller.top - scroller.view < 4;
12281
- }
12548
+ // It used to arm itself when the scroll was held down at the end of the record: three pushes in
12549
+ // four seconds. A trackpad's own momentum at the end of a long answer is exactly that, so people
12550
+ // reading met «end of record… agent status under review» and a jump to the end without having done
12551
+ // anything (2026-11-08). Scrolling never arms it now: only resting the cursor on MU/TH/UR does.
12282
12552
 
12283
12553
  // The conversation is not cut where the composer begins: it runs on beneath it. The thread is told
12284
12554
  // how tall the strip under it is, so its last line can still come up above the box; a reader at
@@ -12346,7 +12616,6 @@ if (document.querySelector('.shell') && els.composer?.getBoundingClientRect) {
12346
12616
  function armExpendable() {
12347
12617
  if (state.expendable) return;
12348
12618
  state.expendable = true;
12349
- pushes = [];
12350
12619
  els.composer.classList.add('expendable');
12351
12620
  updateCrewLabel();
12352
12621
  updatePlaceholder();
@@ -12365,22 +12634,7 @@ function disarmExpendable() {
12365
12634
  updatePlaceholder();
12366
12635
  }
12367
12636
 
12368
- function trackHold(downward, now = Date.now()) {
12369
- if (state.expendable) return false;
12370
- if (!downward || !atBottom()) { pushes = []; return false; }
12371
- const last = pushes.at(-1);
12372
- if (last !== undefined && now - last < BURST_MS) return false; // same burst
12373
- if (last !== undefined && now - last > HOLD_GAP_MS) pushes = []; // gave up, start over
12374
- pushes.push(now);
12375
- const span = pushes.at(-1) - pushes[0];
12376
- if (pushes.length >= HOLD_MIN_PUSHES && span >= HOLD_MS) {
12377
- armExpendable();
12378
- return true;
12379
- }
12380
- return false;
12381
- }
12382
-
12383
- // Second way in: rest the cursor on MU/TH/UR for three seconds.
12637
+ // The other way in: rest the cursor on MU/TH/UR for three seconds.
12384
12638
  const HOVER_MS = 3000;
12385
12639
  let hoverTimer = null;
12386
12640
  function beginHover() {
@@ -12399,18 +12653,9 @@ document.querySelector('#mother-button')?.addEventListener('mouseenter', beginHo
12399
12653
  document.querySelector('#mother-button')?.addEventListener('mouseleave', endHover);
12400
12654
  document.querySelector('#mother-button')?.addEventListener('click', endHover);
12401
12655
 
12402
- // Debug surface for tests and for the curious: window.__pulse.trackHold(true, t)
12403
- globalThis.__pulse = { toast: (...args) => toast(...args), jobProgress: (event) => jobProgress(event), nostromoCard: (index = 0) => showNostromoCard(nostromo.nodes[index]), nostromoTick: (now) => nostromoTick(now), roomAsk: (...args) => roomAsk(...args), openWhatsNew: () => openWhatsNew(), whatsNew: (version = null) => openWhatsNew(version), showWhatsNew: (...args) => showWhatsNew(...args), whatsNewIfOwed: () => maybeShowWhatsNew(), openModuleGuide: () => openModuleGuide(), openViewer: (...args) => openViewer(...args), openNostromo: () => openNostromo(), floatModule: (...args) => floatModule(...args), loadVersion: (...args) => loadVersion(...args), trackHold, armExpendable, disarmExpendable, beginHover, endHover, state, moduleCard, moduleGlance, renderModulesDev, runSlashCommand, syncModuleComposer, syncIntentOffer, openIntentsWindow, openSettings, settingsWindow: () => settingsWindow, openCore: (...args) => openCore(...args), get core() { return core; } };
12656
+ // Debug surface for tests and for the curious: window.__pulse.armExpendable()
12657
+ globalThis.__pulse = { toast: (...args) => toast(...args), jobProgress: (event) => jobProgress(event), nostromoCard: (index = 0) => showNostromoCard(nostromo.nodes[index]), nostromoTick: (now) => nostromoTick(now), roomAsk: (...args) => roomAsk(...args), openWhatsNew: () => openWhatsNew(), whatsNew: (version = null) => openWhatsNew(version), showWhatsNew: (...args) => showWhatsNew(...args), whatsNewIfOwed: () => maybeShowWhatsNew(), openModuleGuide: () => openModuleGuide(), openViewer: (...args) => openViewer(...args), openNostromo: () => openNostromo(), floatModule: (...args) => floatModule(...args), loadVersion: (...args) => loadVersion(...args), armExpendable, disarmExpendable, beginHover, endHover, state, moduleCard, moduleGlance, renderModulesDev, runSlashCommand, syncModuleComposer, syncIntentOffer, openIntentsWindow, openSettings, settingsWindow: () => settingsWindow, openCore: (...args) => openCore(...args), get core() { return core; } };
12404
12658
 
12405
- els.thread.addEventListener('wheel', (event) => trackHold(event.deltaY > 0), { passive: true });
12406
- let touchY = null;
12407
- els.thread.addEventListener('touchstart', (event) => { touchY = event.touches[0]?.clientY ?? null; }, { passive: true });
12408
- els.thread.addEventListener('touchmove', (event) => {
12409
- const y = event.touches[0]?.clientY ?? null;
12410
- if (touchY !== null && y !== null) trackHold(y < touchY);
12411
- touchY = y;
12412
- }, { passive: true });
12413
- els.thread.addEventListener('keydown', (event) => trackHold(event.key === 'ArrowDown' || event.key === 'End' || event.key === 'PageDown'));
12414
12659
 
12415
12660
  /* ---------- First steps: six things done once, ticked as they happen ----------
12416
12661
  The tour shows where things are; this list is what makes a person use them. A pill in the bar
@@ -12815,6 +13060,7 @@ state.ripley = Boolean(initial.ripley?.enabled);
12815
13060
  state.projectRoot = initial.projectRoot ?? '';
12816
13061
  state.projectName = initial.projectName ?? '';
12817
13062
  state.platform = initial.platform ?? null;
13063
+ state.maxMessageChars = Number(initial.maxMessageChars) || 20000;
12818
13064
  for (const plan of initial.plans ?? []) state.plansRunning.add(plan.planId);
12819
13065
  for (const agent of initial.agents) {
12820
13066
  const window = initial.budgetWindow?.[agent.id];
@@ -12966,7 +13212,9 @@ if (typeof ResizeObserver === 'function') {
12966
13212
  // /module has its own visual language before it ever reaches an agent. The class is also the
12967
13213
  // animation trigger: it is added once when the prefix becomes a command, and removed when the
12968
13214
  // human edits away from it or the message leaves the composer.
12969
- const MODULE_COMMAND = /^\/module(?:\s|$)/i;
13215
+ // `/habilidad` asks for exactly what `/module` asks for — #2 CREATE and a draft folder of its own —
13216
+ // so it wears the same clothes in the composer.
13217
+ const MODULE_COMMAND = /^\/(?:module|habilidad|skill)(?:\s|$)/i;
12970
13218
  function syncModuleComposer() {
12971
13219
  const active = MODULE_COMMAND.test(els.input.value.trimStart());
12972
13220
  if (state.moduleCommand === active) return;
@@ -13132,7 +13380,8 @@ function declineTry(said) {
13132
13380
 
13133
13381
  // Why, in one line: what the request looks like, and what was seen or what gave it away.
13134
13382
  function intentReason(said) {
13135
- const level = effortLabel(said.effort).toUpperCase();
13383
+ // A way back to the CLI's own default names no rung (D-4): reading one here broke the page.
13384
+ const level = said.effort ? effortLabel(said.effort).toUpperCase() : null;
13136
13385
  const what = t('Looks like {what}', { what: t(INTENT_NAMES[said.intent] ?? 'an explanation') });
13137
13386
  if (said.basis === 'measured' && said.measured?.needsReference) return `${what} · ${t('below {level} it fell short in {n} measured cases', { level, n: said.measured.n })}`;
13138
13387
  // A try that fell short: the next one of its kind offers the way back, once.
@@ -13645,6 +13894,14 @@ function renderPendingAttachments() {
13645
13894
  els.attachments.append(chip);
13646
13895
  }
13647
13896
  }
13897
+ // A text longer than a message may be goes as a file, as the agents read every attachment (D-15, a
13898
+ // copy in WSL, 2026-11-05): the room refused it for length and nothing told the person what to do.
13899
+ // Its name says it was pasted; the agent reads it whole. True once it is attached.
13900
+ async function attachText(text) {
13901
+ const before = state.pending.length;
13902
+ await addFiles([new File([text], `${t('pasted text')}.txt`, { type: 'text/plain;charset=utf-8' })]);
13903
+ return state.pending.length > before;
13904
+ }
13648
13905
  async function addFiles(files) {
13649
13906
  for (const file of files) {
13650
13907
  const item = { name: file.name || 'pasted-image.png', uploading: true, id: null, previewUrl: file.type?.startsWith('image/') ? URL.createObjectURL(file) : null };
@@ -13655,6 +13912,18 @@ async function addFiles(files) {
13655
13912
  const result = await response.json().catch(() => ({}));
13656
13913
  if (!response.ok) throw new Error(result.error ?? t('Upload failed ({status}).', { status: response.status }));
13657
13914
  item.id = result.attachment.id; item.uploading = false;
13915
+ // A card of MADRE's own, put in the conversation outside the ledger: the same shape every system
13916
+ // line has (tidySystemLine, scheduleFold), for something that happened to the person and not to the
13917
+ // room — a file they just dropped in.
13918
+ function addSystem(node) {
13919
+ els.column.append(tidySystemLine(node));
13920
+ scheduleFold(node);
13921
+ if (pinnedToEnd) scrollToEnd();
13922
+ }
13923
+
13924
+ // A SKILL SOMEBODY SENT YOU (C-1). It came in as an attachment because that is how a file
13925
+ // reaches MADRE, and MADRE recognised it: offered here, never installed on its own.
13926
+ if (result.skill) offerSentSkill(result.skill, item);
13658
13927
  } catch (error) {
13659
13928
  state.pending = state.pending.filter((other) => other !== item);
13660
13929
  toast(t('The attachment was rejected: {error}', { error: error.message }));
@@ -13813,7 +14082,14 @@ els.attach.addEventListener('click', () => els.fileInput.click());
13813
14082
  els.fileInput.addEventListener('change', () => { void addFiles([...els.fileInput.files]); els.fileInput.value = ''; });
13814
14083
  els.input.addEventListener('paste', (event) => {
13815
14084
  const files = [...(event.clipboardData?.files ?? [])];
13816
- if (files.length) { event.preventDefault(); void addFiles(files); }
14085
+ if (files.length) { event.preventDefault(); void addFiles(files); return; }
14086
+ // A text that would not fit in the message goes beside it, and what was written stays (D-15).
14087
+ const pasted = event.clipboardData?.getData('text/plain') ?? '';
14088
+ const kept = els.input.value.length - (els.input.selectionEnd - els.input.selectionStart);
14089
+ if (pasted && kept + pasted.length > state.maxMessageChars) {
14090
+ event.preventDefault();
14091
+ void attachText(pasted).then((attached) => { if (attached) toast(t('The text is too long for a message: it goes as an attachment. Say what to do with it and send.'), { tone: 'note' }); });
14092
+ }
13817
14093
  });
13818
14094
  for (const type of ['dragenter', 'dragover']) els.composer.addEventListener(type, (event) => { event.preventDefault(); els.composer.classList.add('dropping'); });
13819
14095
  for (const type of ['dragleave', 'drop']) els.composer.addEventListener(type, (event) => { event.preventDefault(); els.composer.classList.remove('dropping'); });
@@ -13845,6 +14121,15 @@ els.composer.addEventListener('submit', async (event) => {
13845
14121
  await stopAll();
13846
14122
  return;
13847
14123
  }
14124
+ // Longer than a message may be, written or pasted bit by bit: the text goes as an attachment and
14125
+ // the message keeps who it is for (D-15). The room refused it whole before.
14126
+ if (text.length > state.maxMessageChars && !text.startsWith('/')) {
14127
+ if (!(await attachText(text))) return;
14128
+ els.input.value = `${text.match(/^(?:@[a-z0-9_-]+[\s,]+)*/i)[0]}${t('My message is in the attached text.')}`;
14129
+ autosize();
14130
+ els.composer.requestSubmit();
14131
+ return;
14132
+ }
13848
14133
  let outgoing = text;
13849
14134
  let target = els.target.value;
13850
14135
  let draft = false;
@@ -14575,7 +14860,14 @@ function renderTerminalCard(event) {
14575
14860
  if (yes) termOpen.add(id); else termOpen.delete(id);
14576
14861
  };
14577
14862
  open(termOpen.has(id));
14578
- head.addEventListener('click', () => open(!node.classList.contains('open')));
14863
+ // Opening is reading (2026-11-08): the thread stops following the end, or a card near the end grew
14864
+ // upward as the end was kept in view. It opens down, and comes into view if it has to.
14865
+ head.addEventListener('click', () => {
14866
+ const now = !node.classList.contains('open');
14867
+ if (now) setPinned(false);
14868
+ open(now);
14869
+ if (now) setTimeout(() => { ourScroll(900); node.scrollIntoView?.({ block: 'nearest', behavior: 'smooth' }); }, 260);
14870
+ });
14579
14871
  // A module's page (a report to print) sits on the same row as its title, a small key at its end:
14580
14872
  // under it, it turned the pill into a bulging oval (2026-10-20).
14581
14873
  if (page && fromModule) {
@@ -14764,21 +15056,50 @@ function drawMcpSettings(host) {
14764
15056
  // MADRE saves it, signs in when it asks, and reads its tools before any agent gets them.
14765
15057
  function drawMcpCatalog(host) {
14766
15058
  const norm = (address) => { try { return new URL(address).toString(); } catch { return address; } };
15059
+ // A search over the catalog (2026-11-07): by name, what it does and who makes it, accents aside.
15060
+ const search = el('label', 'settings-search mcp-search');
15061
+ search.insertAdjacentHTML('afterbegin', trazo('search')); // trusted: our own SVG string
15062
+ const input = el('input');
15063
+ input.type = 'search';
15064
+ input.placeholder = t('Search connectors');
15065
+ input.setAttribute('aria-label', t('Search connectors'));
15066
+ input.spellcheck = false;
15067
+ input.value = mcpUI.catalogQuery ?? '';
15068
+ search.append(input);
14767
15069
  const have = new Map((mcpUI.servers ?? []).filter((one) => one.url).map((one) => [norm(one.url), one]));
14768
- const block = sxBlock(host, t('Connectors'), t('The best known services, checked against MADRE on {date}. One press connects one to this project; any other MCP server goes in with «Add a tool».', { date: new Date(`${CATALOG_CHECKED}T12:00:00`).toLocaleDateString(document.documentElement.lang === 'en' ? 'en-US' : 'es-MX', { day: 'numeric', month: 'long', year: 'numeric' }) }), { className: 'mcp-block mcp-catalog-block' });
15070
+ const block = sxBlock(host, t('Connectors'), t('The best known services, checked against MADRE on {date}. One press connects one to this project; any other MCP server goes in with «Add a tool».', { date: new Date(`${CATALOG_CHECKED}T12:00:00`).toLocaleDateString(document.documentElement.lang === 'en' ? 'en-US' : 'es-MX', { day: 'numeric', month: 'long', year: 'numeric' }) }), { className: 'mcp-block mcp-catalog-block', aside: search });
14769
15071
  for (const group of MCP_GROUPS) {
14770
15072
  const items = MCP_CATALOG.filter((one) => one.group === group.id);
14771
15073
  if (!items.length) continue;
14772
15074
  const head = el('div', 'mcp-cat-head');
14773
15075
  head.append(el('b', null, t(group.title)), el('span', null, t(group.about)));
14774
15076
  const grid = el('div', 'mcp-catalog');
14775
- for (const item of items) grid.append(mcpConnectorCard(item, have.get(norm(item.url)) ?? null));
15077
+ for (const item of items) {
15078
+ const card = mcpConnectorCard(item, have.get(norm(item.url)) ?? null);
15079
+ card.dataset.find = settingsFold(`${item.label} ${t(item.about)} ${item.maker ?? ''} ${t(group.title)}`);
15080
+ grid.append(card);
15081
+ }
14776
15082
  block.rows.append(head, grid);
14777
15083
  }
14778
- // A server that is not on the list: by hand, as it always was.
14779
- const other = el('div', 'mcp-cat-other');
14780
- other.append(el('span', null, t('Another MCP server, yours or a third party\'s?')), sxButton(t('Add a tool'), () => { mcpUI.adding = { transport: 'http', auth: 'none', env: [] }; drawMcpTarget(); state.settingsTargets.mcp?.querySelector('.mcp-form')?.scrollIntoView?.({ block: 'start', behavior: 'smooth' }); }));
14781
- block.rows.append(other);
15084
+ const none = el('p', 'mcp-cat-none', t('No connector matches. Any other MCP server goes in with «Add a tool», above.'));
15085
+ none.hidden = true;
15086
+ block.rows.append(none);
15087
+ const filter = () => {
15088
+ const query = settingsFold(input.value.trim());
15089
+ mcpUI.catalogQuery = input.value;
15090
+ let shown = 0;
15091
+ for (const grid of block.rows.querySelectorAll('.mcp-catalog')) {
15092
+ let here = 0;
15093
+ for (const card of grid.children) { const hit = !query || card.dataset.find.includes(query); card.hidden = !hit; if (hit) here += 1; }
15094
+ grid.hidden = !here;
15095
+ grid.previousElementSibling.hidden = !here;
15096
+ shown += here;
15097
+ }
15098
+ none.hidden = shown > 0;
15099
+ };
15100
+ input.addEventListener('input', filter);
15101
+ if (input.value) filter();
15102
+ // Another server goes in with «Add a tool», at the top of Outside tools (MCP): one key, not two (2026-11-07).
14782
15103
  }
14783
15104
  const MCP_CHECKED_WORDS = { tools: () => t('Checked'), signin: () => t('With your account'), token: () => t('With a token') };
14784
15105
  function mcpConnectorCard(item, connected) {
@@ -15067,6 +15388,9 @@ async function refreshModules() {
15067
15388
  const data = await fetch('/api/extensions').then((response) => response.json());
15068
15389
  modules.failures = data.failures ?? []; modules.folders = data.folders ?? null; modules.sdk = data.sdk ?? null; modules.items = data.extensions ?? [];
15069
15390
  modules.installing = data.installing ?? null;
15391
+ // The ways of working this project keeps (H-3). Asked beside the modules and never in their way:
15392
+ // a board without them is the board as it always was.
15393
+ void refreshSkills();
15070
15394
  if (state.salas) {
15071
15395
  const card = modules.items.find((item) => item.id === 'bishop');
15072
15396
  const selected = card?.status?.installed ? card.controls?.find((control) => control.key === 'agent')?.value ?? null : null;
@@ -15418,28 +15742,27 @@ function cardControls(panel, item) {
15418
15742
  box.append(row);
15419
15743
  }
15420
15744
 
15421
- // Somebody's own module, handed to MADRE from the panel. A module runs inside MADRE with the
15422
- // human's permissions, so the choice is theirs to make knowingly: the file is named, what it
15423
- // means is said in one line, and MADRE checks it before it is installed rather than after.
15745
+ // Somebody's own module, handed to MADRE from the panel. The file is named and its limits are
15746
+ // stated before the human confirms it; MADRE checks it before installing it.
15424
15747
  modules.add?.addEventListener('click', () => modules.file?.click());
15425
15748
  modules.file?.addEventListener('change', async () => {
15426
15749
  const file = modules.file.files?.[0];
15427
15750
  modules.file.value = '';
15428
15751
  if (!file) return;
15429
15752
  if (!/\.m?js$/.test(file.name)) { toast(t('Diagnostics › a module is a .mjs file.')); return; }
15430
- const install = await roomAsk({
15753
+ // The question is the #4 key itself: a module can do what #4 can.
15754
+ const words = await askModuleKey({
15431
15755
  title: t('Install {name}?', { name: file.name }),
15432
- body: t('A module runs inside MADRE, with your permissions, on this computer. MADRE checks that it loads and keeps to the house rules before installing it — it cannot check what it intends. Install it only if you trust where it came from.'),
15433
- choices: [{ value: 'no', label: t('Cancel'), focus: true }, { value: 'install', label: t('Install'), tone: 'primary' }],
15756
+ what: t('A module runs in a separate Node process with limited permissions. Node cannot guarantee containment of malicious code. Review the file and its network destinations before installing it.'),
15434
15757
  });
15435
- if (install !== 'install') return;
15758
+ if (!words) return;
15436
15759
  let text;
15437
15760
  try { text = await file.text(); } catch (error) { toast(t('That file could not be read: {error}', { error: error.message })); return; }
15438
15761
  modules.add.disabled = true;
15439
15762
  try {
15440
15763
  const response = await fetch('/api/extensions/upload', {
15441
15764
  method: 'POST', headers: { 'content-type': 'application/json' },
15442
- body: JSON.stringify({ text, name: file.name, scope: 'user' }),
15765
+ body: JSON.stringify({ text, name: file.name, scope: 'user', words }),
15443
15766
  });
15444
15767
  const result = await response.json().catch(() => ({}));
15445
15768
  if (!response.ok) { toast(`${t('Diagnostics › ')}${result.error ?? 'that module was not installed.'}`); return; }
@@ -15570,9 +15893,9 @@ async function sendToMarket(host, item, opener) {
15570
15893
 
15571
15894
  async function refreshModuleFile(item, button) {
15572
15895
  button.disabled = true;
15573
- const ask = async (confirm) => {
15896
+ const ask = async (confirm, words = undefined) => {
15574
15897
  const response = await reach(`/api/extensions/${item.id}/refresh`, {
15575
- method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ confirm }),
15898
+ method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ confirm, words }),
15576
15899
  });
15577
15900
  return { ok: response.ok, result: await response.json().catch(() => ({})) };
15578
15901
  };
@@ -15580,13 +15903,13 @@ async function refreshModuleFile(item, button) {
15580
15903
  if (!looked.ok) { toast(`${t('Diagnostics › ')}${looked.result.error ?? 'that module could not be checked.'}`); button.disabled = false; return; }
15581
15904
  const { origin, current, candidate, same } = looked.result;
15582
15905
  if (same) { toast(t('Diagnostics › {name} is already {version} · {from}', { name: item.name, version: current ?? t('what is published'), from: origin.from })); button.disabled = false; return; }
15583
- const update = await roomAsk({
15906
+ const words = await askModuleKey({
15584
15907
  title: t('Update {name}?', { name: item.name }),
15585
- body: `${current ?? t('unversioned')} → ${candidate ?? t('unversioned')}\n${t('From {from}', { from: origin.from })}\n\n${t('It loads and keeps to the house rules. What it intends, only you can judge.')}`,
15586
- choices: [{ value: 'no', label: t('Cancel'), focus: true }, { value: 'update', label: t('Update'), tone: 'primary' }],
15908
+ what: `${current ?? t('unversioned')} → ${candidate ?? t('unversioned')} · ${t('From {from}', { from: origin.from })}`,
15909
+ safe: t('It loads and keeps to the house rules. What it intends, only you can judge.'),
15587
15910
  });
15588
- if (update !== 'update') { button.disabled = false; return; }
15589
- const done = await ask(true);
15911
+ if (!words) { button.disabled = false; return; }
15912
+ const done = await ask(true, words);
15590
15913
  if (!done.ok) { toast(`${t('Diagnostics › ')}${done.result.error ?? 'the module was not updated.'}`); button.disabled = false; return; }
15591
15914
  modules.items = done.result.extensions ?? modules.items;
15592
15915
  renderModules();
@@ -16937,6 +17260,7 @@ function renderModules() {
16937
17260
  grid.append(make);
16938
17261
  } else if (!shown.length) grid.append(el('p', 'settings-reading', t('Nothing called «{query}».', { query: modules.query.trim() })));
16939
17262
  board.append(grid);
17263
+ if (!query) skillsSection(board);
16940
17264
  const item = modules.items.find((one) => one.id === modules.open);
16941
17265
  if (!item) { modules.open = null; list.replaceChildren(board); renderModuleWindows(); renderModulesDev(); return; }
16942
17266
  const sheet = el('div', `settings-sheet mods-sheet${modules.push ? ' full' : ''}`);
@@ -16953,6 +17277,354 @@ function renderModules() {
16953
17277
  renderModulesDev();
16954
17278
  }
16955
17279
 
17280
+ // ---- HABILIDADES (H-3). A skill is not a module: it adds no button and no page, it tells the
17281
+ // agents how the human works. So it is a row and not a tile — what matters about it is a sentence
17282
+ // (when it is for) and a page (what it says), which a tile cannot hold.
17283
+ //
17284
+ // Everything here is the person's: whether it waits for a match, is always on or is off, and
17285
+ // whether that word is this project's or every project's. And «What it says» shows the whole text
17286
+ // before any of that, because a skill reaching an agent that may hold CONTROL is something to read
17287
+ // first — and unlike a module's JavaScript, a person actually can.
17288
+ async function refreshSkills() {
17289
+ try {
17290
+ const data = await fetch('/api/skills').then((response) => response.json());
17291
+ modules.skills = data.skills ?? [];
17292
+ modules.skillFailures = data.failures ?? [];
17293
+ modules.skillProject = Boolean(data.project);
17294
+ // Drawn only while the board is open, as every other reading of it is.
17295
+ if (modules.dialog?.open) renderModules();
17296
+ } catch { /* the board keeps the skills it had */ }
17297
+ }
17298
+
17299
+ const SKILL_STATES = () => [
17300
+ ['match', t('When it fits')],
17301
+ ['always', t('Always on')],
17302
+ ['off', t('Off')],
17303
+ ];
17304
+ async function switchSkill(skill, state, scope) {
17305
+ const response = await fetch(`/api/skills/${skill.id}/state`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ state, scope }) });
17306
+ const payload = await response.json().catch(() => ({}));
17307
+ if (!response.ok) { toast(payload.error ?? t('{name} could not be changed.', { name: skillName(skill) })); return; }
17308
+ await refreshSkills();
17309
+ }
17310
+ const skillName = (skill) => skillWords(skill?.name) ?? skill?.id ?? '';
17311
+ // Its name or its sentence, in the language the room speaks. Not i18n's `pick`: that one wants
17312
+ // both languages present, and a skill may well have written only one.
17313
+ function skillWords(value) {
17314
+ if (!value || typeof value !== 'object') return value ?? null;
17315
+ return value[language()] ?? value.es ?? value.en ?? null;
17316
+ }
17317
+
17318
+ // WHAT IT SAYS: the whole page, what it carries, and every script marked with the one mode that
17319
+ // could run it. The same screen the Market will show before installing one (H-4).
17320
+ function openSkillText(skill) {
17321
+ // The same dialog «Create your module» uses, so it looks like the rest of the board.
17322
+ const dialog = el('dialog', 'module-guide skill-text');
17323
+ const head = el('header', 'module-guide-head');
17324
+ const named = el('div', 'skill-text-name');
17325
+ named.append(el('span', 'custom-title', skillName(skill)), el('span', 'sx-hint', t('What it tells your agents')));
17326
+ const close = el('button', 'module-guide-close', '×');
17327
+ close.type = 'button';
17328
+ close.setAttribute('aria-label', t('CLOSE'));
17329
+ close.addEventListener('click', () => dialog.close());
17330
+ head.append(named, close);
17331
+ const body = el('div', 'module-guide-body');
17332
+ if (skill.when) body.append(el('p', 'skill-when', `${t('It comes in when:')} ${skillWords(skill.when)}`));
17333
+ body.append(el('pre', 'skill-body', skill.body));
17334
+ const carries = skill.declares?.references?.filter((path) => !/^(HABILIDAD|SKILL)\.md$/.test(path)) ?? [];
17335
+ if (carries.length) body.append(el('p', 'sx-hint', t('It carries: {list}', { list: carries.join(', ') })));
17336
+ if (skill.declares?.scripts?.length) {
17337
+ const warn = el('p', 'mods-submit-warn');
17338
+ warn.append(el('b', null, t('It carries programs: {list}', { list: skill.declares.scripts.join(', ') })));
17339
+ warn.append(el('span', null, ` ${t('MADRE never runs one. Only an agent can, and only in #4 AIRLOCK: in every other mode they do nothing. Read one before you open that mode.')}`));
17340
+ body.append(warn);
17341
+ }
17342
+ for (const [label, value] of [[t('Version'), skill.version], [t('Idea by'), skill.credit], [t('License'), skill.license], [t('Folder'), skill.dir]]) {
17343
+ if (value) body.append(el('p', 'sx-hint', `${label}: ${value}`));
17344
+ }
17345
+ if (skill.unknown?.length) body.append(el('p', 'mods-submit-warn', t('Fields MADRE does not know: {list}', { list: skill.unknown.join(', ') })));
17346
+ dialog.append(head, body);
17347
+ document.body.append(dialog);
17348
+ dialog.addEventListener('close', () => dialog.remove());
17349
+ dialog.addEventListener('click', (event) => { if (event.target === dialog) dialog.close(); });
17350
+ dialog.showModal();
17351
+ }
17352
+
17353
+ function skillRow(skill) {
17354
+ const row = el('article', `skill-row is-${skill.state}`);
17355
+ const words = el('div', 'skill-words');
17356
+ const top = el('div', 'skill-top');
17357
+ top.append(el('b', 'skill-name', skillName(skill)));
17358
+ if (skill.origin === 'project') top.append(el('span', 'skill-tag', t('this project only')));
17359
+ if (skill.version) top.append(el('span', 'skill-tag', skill.version));
17360
+ if (skill.declares?.scripts?.length) top.append(el('span', 'skill-tag warn', t('{n} program(s)', { n: skill.declares.scripts.length })));
17361
+ words.append(top);
17362
+ words.append(el('span', 'sx-hint', skillWords(skill.when) ?? t('It has no sentence saying when it fits, so it only ever comes in switched on.')));
17363
+ const keys = el('div', 'skill-keys');
17364
+ const choose = sxSelect(SKILL_STATES(), skill.state, (value) => void switchSkill(skill, value, 'project'), t('When this skill comes in'));
17365
+ keys.append(choose);
17366
+ keys.append(sxButton(t('What it says'), () => openSkillText(skill)));
17367
+ const gone = sxButton(t('Remove'), async () => {
17368
+ const answer = await roomAsk({
17369
+ title: t('Remove {name}?', { name: skillName(skill) }),
17370
+ body: t('Its folder {dir} is deleted. What it told your agents stops reaching them. Nothing a program of its own may have written elsewhere is touched.', { dir: skill.dir }),
17371
+ choices: [{ value: 'keep', label: t('Keep it'), focus: true }, { value: 'remove', label: t('Remove'), tone: 'danger' }],
17372
+ });
17373
+ if (answer !== 'remove') return;
17374
+ gone.disabled = true;
17375
+ const response = await fetch(`/api/skills/${skill.id}/remove`, { method: 'POST' });
17376
+ const payload = await response.json().catch(() => ({}));
17377
+ if (!response.ok) { gone.disabled = false; toast(payload.error ?? t('{name} could not be removed.', { name: skillName(skill) })); return; }
17378
+ await refreshSkills();
17379
+ }, { tone: 'danger' });
17380
+ keys.append(gone);
17381
+ // Sending one's own: only for a skill that is the person's, never for one the Market signed.
17382
+ const share = sxButton(t('Share'), () => void shareSkillNow(skill, share), { title: t('MADRE prepares its files for you to send; it sends nothing.') });
17383
+ keys.append(share);
17384
+ if (!skill.market) keys.append(sxButton(t('Send to the Market'), () => openSkillSubmit(skill)));
17385
+ row.append(words, keys);
17386
+ // The word for every project, said only when this project has one of its own: otherwise it is
17387
+ // the same word twice and the row reads like a puzzle.
17388
+ if (modules.skillProject && skill.state !== skill.everywhere) {
17389
+ const all = el('div', 'skill-all');
17390
+ all.append(el('span', 'sx-hint', t('In every other project: {state}', { state: SKILL_STATES().find(([value]) => value === skill.everywhere)?.[1] ?? skill.everywhere })));
17391
+ all.append(sxButton(t('Use it everywhere'), () => void switchSkill(skill, skill.state, 'everywhere')));
17392
+ row.append(all);
17393
+ }
17394
+ return row;
17395
+ }
17396
+
17397
+ // BRING OVER WHAT YOU ALREADY HAVE (H-7). MADRE keeps every agent's own skills out of a turn on
17398
+ // purpose, so somebody arriving from Claude lost what they had written. This is the door back.
17399
+ // Nothing is brought on its own: each one says what would happen to it, and the person picks.
17400
+ function openSkillImport() {
17401
+ const dialog = el('dialog', 'module-guide skill-text');
17402
+ const head = el('header', 'module-guide-head');
17403
+ const named = el('div', 'skill-text-name');
17404
+ named.append(el('span', 'custom-title', t('Bring over what you already have')), el('span', 'sx-hint', t('The skills your agents keep on this computer')));
17405
+ const close = el('button', 'module-guide-close', '×');
17406
+ close.type = 'button';
17407
+ close.setAttribute('aria-label', t('CLOSE'));
17408
+ close.addEventListener('click', () => dialog.close());
17409
+ head.append(named, close);
17410
+ const body = el('div', 'module-guide-body');
17411
+ body.append(el('p', 'sx-intro', t('Inside MADRE your agents never read their own skills: that is how one way of working can be the same for all of them. Here you bring the ones you want into MADRE, and from then on every agent follows them.')));
17412
+ const list = el('div', 'skill-import-list');
17413
+ body.append(list, el('p', 'sx-hint', t('Reading them changes nothing. What you bring is copied into MADRE; the original stays where it is.')));
17414
+ const bring = sxButton(t('Bring the ones I ticked'), null, { tone: 'primary' });
17415
+ const said = el('p', 'sx-hint');
17416
+ body.append(bring, said);
17417
+ const picked = new Set();
17418
+ const draw = (found) => {
17419
+ list.replaceChildren();
17420
+ if (!found.length) { list.append(el('p', 'settings-reading', t('No agent on this computer keeps skills of its own.'))); bring.hidden = true; return; }
17421
+ for (const one of found) {
17422
+ const row = el('label', `skill-import ${one.fits ? 'fits' : 'off'}`);
17423
+ const box = el('input');
17424
+ box.type = 'checkbox';
17425
+ box.disabled = !one.fits;
17426
+ box.addEventListener('change', () => { if (box.checked) picked.add(one.id); else picked.delete(one.id); said.textContent = ''; });
17427
+ // Each part says what it is (2026-11-08: name, a paragraph, numbers and a warning ran together).
17428
+ const words = el('div', 'skill-import-words');
17429
+ const top = el('div', 'skill-top');
17430
+ top.append(el('b', 'skill-name', skillWords(one.name) ?? one.id), el('span', 'skill-tag', one.label));
17431
+ if (one.synced) top.append(el('span', 'skill-tag', t('from your account')));
17432
+ if (one.replaces) top.append(el('span', 'skill-tag warn', t('replaces the one you have')));
17433
+ words.append(top);
17434
+ const note = (text) => el('span', 'skill-import-note', text);
17435
+ if (one.fits) {
17436
+ const when = el('div', 'skill-import-part');
17437
+ const sentence = el('span', 'skill-import-when', skillWords(one.when) ?? t('It has no sentence saying when it fits, so it only ever comes in switched on.'));
17438
+ when.append(el('span', 'skill-import-label', t('When it comes in')), sentence);
17439
+ // A long sentence shows three lines; the rest is a press away, on the line itself.
17440
+ if (String(one.when ?? '').length > 220) {
17441
+ const more = el('button', 'skill-import-more', t('Read it all'));
17442
+ more.type = 'button';
17443
+ more.addEventListener('click', (event) => { event.preventDefault(); sentence.classList.add('whole'); more.remove(); });
17444
+ when.append(more);
17445
+ }
17446
+ words.append(when);
17447
+ words.append(el('span', 'skill-import-facts', t('Instructions of {chars} characters · {files} file(s)', { chars: one.chars.toLocaleString(), files: one.files })));
17448
+ if (one.scripts?.length) words.append(note(t('It brings {n} program(s). MADRE never runs them; only an agent at #4 can.', { n: one.scripts.length })));
17449
+ // A skill that says it is proprietary may be kept and used; it may not be sent to the Market.
17450
+ if (one.license && !/^(CC|MIT|Apache|AGPL|GPL|ISC|BSD|MPL)/i.test(one.license)) words.append(note(t('Its license ({license}) lets you use it, not share it: it cannot go to the Market.', { license: String(one.license).split(/[.;]/)[0].trim() })));
17451
+ } else {
17452
+ words.append(note(one.why));
17453
+ words.append(el('span', 'skill-import-facts', t('Ask an agent to shorten it with /habilidad, and bring that one over instead.')));
17454
+ }
17455
+ row.append(box, words);
17456
+ list.append(row);
17457
+ }
17458
+ };
17459
+ bring.addEventListener('click', async () => {
17460
+ if (!picked.size) { said.textContent = t('Tick at least one.'); return; }
17461
+ bring.disabled = true;
17462
+ const payload = await fetch('/api/skills/import', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ ids: [...picked] }) }).then((response) => response.json()).catch(() => ({ error: 'network' }));
17463
+ bring.disabled = false;
17464
+ if (payload.error) { said.textContent = t('They could not be brought over: {error}', { error: payload.error }); return; }
17465
+ said.textContent = payload.brought.length
17466
+ ? t('{n} brought in. They come in when they fit; change that in MODULES.', { n: payload.brought.length })
17467
+ : t('None could come. Each one says why.');
17468
+ for (const one of payload.left ?? []) said.textContent += ` · ${one.id}: ${one.why}`;
17469
+ picked.clear();
17470
+ await refreshSkills();
17471
+ void fetch('/api/skills/import').then((response) => response.json()).then((data) => draw(data.found ?? [])).catch(() => {});
17472
+ });
17473
+ dialog.append(head, body);
17474
+ document.body.append(dialog);
17475
+ dialog.addEventListener('close', () => dialog.remove());
17476
+ dialog.addEventListener('click', (event) => { if (event.target === dialog) dialog.close(); });
17477
+ dialog.showModal();
17478
+ list.append(el('p', 'settings-reading', t('Looking…')));
17479
+ void fetch('/api/skills/import').then((response) => response.json()).then((data) => draw(data.found ?? [])).catch(() => { list.replaceChildren(el('p', 'mods-submit-warn', t('MADRE could not read them.'))); });
17480
+ }
17481
+
17482
+ // A SKILL SOMEBODY SENT YOU (C-1). The Market is the curated road: read and signed by the author of
17483
+ // MADRE, updated on its own, and taken back from everywhere if it turns out badly. This is the other
17484
+ // road, and the card says so plainly — because nobody read this one but you, and nothing will ever
17485
+ // update it or take it back.
17486
+ function offerSentSkill(sent, item) {
17487
+ if (sent.error) { toast(sent.error); return; }
17488
+ const node = el('div', 'system module-proposed');
17489
+ claimHead(node, t('SKILL'), t('sent to you'));
17490
+ const said = el('span', 'claim-body');
17491
+ said.append(t('{name} arrived with your file.', { name: skillWords(sent.name) ?? sent.id }));
17492
+ node.append(said);
17493
+ if (sent.when) node.append(el('span', 'claim-note', `${t('It comes in when:')} ${skillWords(sent.when)}`));
17494
+ const ask = (extra = {}) => fetch('/api/skills/install-file', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ path: sent.fileName, root: 'attachments', ...extra }) }).then((response) => response.json());
17495
+ const read = el('button', 'claim-act', t('READ IT'));
17496
+ read.type = 'button';
17497
+ read.addEventListener('click', () => openSkillText({ ...sent, dir: null, license: null, credit: sent.declares?.credit ?? null }));
17498
+ const install = async (scope, key) => {
17499
+ key.disabled = true;
17500
+ try {
17501
+ const payload = await ask({ scope });
17502
+ if (payload.error) throw new Error(payload.error);
17503
+ toast(t('Diagnostics › {name} is yours now, for {where}. It comes in when it fits; change that in MODULES.', { name: skillWords(payload.installed.name) ?? payload.installed.id, where: scope === 'project' ? t('this project') : t('every project') }));
17504
+ void refreshSkills();
17505
+ // Attached it was a file for an agent to read; kept, it is a skill, and the composer lets go.
17506
+ state.pending = state.pending.filter((other) => other !== item);
17507
+ renderPendingAttachments();
17508
+ } catch (error) { toast(t('The skill was not installed: {error}', { error: error.message })); key.disabled = false; }
17509
+ };
17510
+ const everyRoom = el('button', 'claim-act', t('KEEP IT FOR EVERY PROJECT'));
17511
+ everyRoom.type = 'button';
17512
+ everyRoom.addEventListener('click', () => install('user', everyRoom));
17513
+ const thisProject = el('button', 'claim-act', t('ONLY IN THIS PROJECT'));
17514
+ thisProject.type = 'button';
17515
+ thisProject.addEventListener('click', () => install('project', thisProject));
17516
+ const acts = el('span', 'claim-acts');
17517
+ acts.append(read, everyRoom, thisProject);
17518
+ node.append(acts, el('span', 'claim-note', t('Somebody sent you this: the author of MADRE did not read it, nothing will update it on its own and nobody can take it back. Read it before your agents do. It gives no permission — it tells them how to work, inside whatever mode you give them.')));
17519
+ if (sent.declares?.scripts?.length) node.append(el('span', 'claim-note replaces', t('It mentions programs, and they did not come with the file.')));
17520
+ addSystem(node);
17521
+ }
17522
+
17523
+ // Giving one away: MADRE prepares its files and shows you where they are. It sends nothing.
17524
+ async function shareSkillNow(skill, key) {
17525
+ key.disabled = true;
17526
+ const payload = await fetch('/api/skills/share', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: skill.id }) }).then((response) => response.json()).catch(() => ({ error: t('MADRE did not answer.') }));
17527
+ key.disabled = false;
17528
+ if (payload.error) { toast(payload.error); return; }
17529
+ const what = payload.alone
17530
+ ? t('{name} is ready to send: one file, {file}. Whoever gets it drags it into their conversation.', { name: skillWords(skill.name) ?? skill.id, file: payload.files[0] })
17531
+ : t('{name} is ready to send: {n} files, in {folder}. They travel together; one on its own would point at what is not there.', { name: skillWords(skill.name) ?? skill.id, n: payload.files.length, folder: payload.folder });
17532
+ toast(payload.shown ? what : `${what} ${t('Open that folder from your file browser.')}`);
17533
+ }
17534
+
17535
+ // SENDING YOUR OWN SKILL (H-8). A skill is one file, so this asks only what nobody but the person
17536
+ // can say — which shelf, their name, which license — and writes it into the skill's own header.
17537
+ // Everything else it already said about itself.
17538
+ function openSkillSubmit(skill) {
17539
+ const dialog = el('dialog', 'module-guide skill-text');
17540
+ const head = el('header', 'module-guide-head');
17541
+ const named = el('div', 'skill-text-name');
17542
+ named.append(el('span', 'custom-title', t('Send {name} to the Market', { name: skillName(skill) })), el('span', 'sx-hint', t('MADRE checks it here, the author of MADRE reads it and signs it, and then anyone can find it.')));
17543
+ const close = el('button', 'module-guide-close', '×');
17544
+ close.type = 'button';
17545
+ close.setAttribute('aria-label', t('CLOSE'));
17546
+ close.addEventListener('click', () => dialog.close());
17547
+ head.append(named, close);
17548
+ const body = el('div', 'module-guide-body');
17549
+ dialog.append(head, body);
17550
+ document.body.append(dialog);
17551
+ dialog.addEventListener('close', () => dialog.remove());
17552
+ dialog.showModal();
17553
+ const ask = (payload = {}) => fetch('/api/skills/submission', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: skill.id, ...payload }) }).then((response) => response.json());
17554
+ body.append(el('p', 'settings-reading', t('Looking…')));
17555
+ void ask().then((first) => {
17556
+ if (first.error) { body.replaceChildren(el('p', 'mods-submit-warn', first.error)); return; }
17557
+ body.replaceChildren();
17558
+ const draft = first.draft;
17559
+ const pair = (value, { area = false } = {}) => {
17560
+ const box = el('div', 'sx-field mods-pair');
17561
+ const made = (lang, label) => { const node = el(area ? 'textarea' : 'input', 'sx-input'); node.value = (value && typeof value === 'object' ? value[lang] : lang === 'es' ? value : '') ?? ''; node.placeholder = label; node.setAttribute('aria-label', label); if (area) node.rows = 3; return node; };
17562
+ const es = made('es', t('Spanish'));
17563
+ const en = made('en', t('English'));
17564
+ box.append(es, en);
17565
+ // One language is enough: a skill written in Spanish does not have to invent an English line.
17566
+ return { box, read: () => { const said = {}; if (es.value.trim()) said.es = es.value.trim(); if (en.value.trim()) said.en = en.value.trim(); return Object.keys(said).length ? said : null; } };
17567
+ };
17568
+ const line = pair(draft.line);
17569
+ const summary = pair(draft.summary, { area: true });
17570
+ const block = sxBlock(body, t('What the Market will show'), t('In Spanish, in English, or in one of the two: the Market shows whichever it has.'));
17571
+ sxRow(block, t('In one line'), null, line.box, { stack: true });
17572
+ sxRow(block, t('What it does and when to use it'), null, summary.box, { stack: true });
17573
+ const shelf = sxSelect([['', t('Choose…')], ...first.shelves.map((id) => [id, t(MARKET_SHELVES.find((one) => one.id === id)?.title ?? id)])], draft.shelf ?? '', () => {}, t('Shelf'));
17574
+ sxRow(block, t('Shelf'), t('Where it sits in the Market.'), shelf);
17575
+ const who = el('div', 'sx-field mods-pair');
17576
+ const author = el('input', 'sx-input'); author.value = draft.author?.name ?? ''; author.placeholder = t('Your name');
17577
+ const github = el('input', 'sx-input'); github.value = draft.author?.github ?? ''; github.placeholder = t('Your GitHub user, if you have one');
17578
+ who.append(author, github);
17579
+ sxRow(block, t('Who made it'), t('Your name is what the Market shows. The GitHub user is only how the pull request is signed.'), who, { stack: true });
17580
+ const license = sxSelect([['', t('Choose…')], ...first.licenses.map((id) => [id, id])], draft.license ?? '', () => {}, t('License of your text'));
17581
+ sxRow(block, t('License of your text'), t('Under which others may read it, use it and change it.'), license);
17582
+ const oldest = el('input', 'sx-input mono'); oldest.value = draft.minMadre ?? ''; oldest.placeholder = '1.1.2';
17583
+ sxRow(block, t('Oldest MADRE it works with'), null, oldest);
17584
+ if (draft.scripts?.length) block.rows.append(el('p', 'mods-submit-warn', t('It carries programs: {list}. Whoever reviews it reads every one of them, and so does whoever installs it.', { list: draft.scripts.join(', ') })));
17585
+ const said = el('div', 'mods-submit-said');
17586
+ const read = () => ({ line: line.read(), summary: summary.read(), shelf: shelf.value, author: author.value.trim() ? { name: author.value.trim(), github: github.value.trim() } : null, license: license.value, minMadre: oldest.value.trim() });
17587
+ const show = (result) => {
17588
+ said.replaceChildren();
17589
+ if (result.problems?.length) {
17590
+ const list = el('ul', 'mods-submit-problems');
17591
+ for (const one of result.problems) list.append(el('li', null, one));
17592
+ said.append(el('b', null, t('To fix first')), list);
17593
+ }
17594
+ if (!result.folder) return;
17595
+ const ready = el('div', 'mods-submit-ready');
17596
+ ready.append(el('b', null, t('Your skill is ready to send')), el('code', null, result.folder));
17597
+ const steps = el('ol', 'mods-submit-steps');
17598
+ for (const step of [t('Open GitHub: it asks you to sign in if you are not.'), t('Drag every file of that folder onto the page.'), t('Say in one line what your skill is for and press «Propose changes».'), t('The author of MADRE reads it; once signed, it is in the Market for everyone.')]) steps.append(el('li', null, step));
17599
+ const go = el('a', 'sx-btn primary', t('Open GitHub'));
17600
+ go.href = result.upload; go.target = '_blank'; go.rel = 'noopener';
17601
+ const again = sxButton(t('Show the folder'), () => void ask({ entry: read(), write: true, reveal: true }));
17602
+ const keys = el('div', 'mods-submit-keys');
17603
+ keys.append(go, again);
17604
+ ready.append(steps, keys);
17605
+ said.append(ready);
17606
+ };
17607
+ const prepare = sxButton(t('Prepare'), async () => {
17608
+ prepare.disabled = true;
17609
+ const result = await ask({ entry: read(), write: true });
17610
+ prepare.disabled = false;
17611
+ if (result.error) { said.replaceChildren(el('p', 'mods-submit-warn', result.error)); return; }
17612
+ show(result);
17613
+ }, { tone: 'primary' });
17614
+ body.append(prepare, said);
17615
+ }).catch(() => { body.replaceChildren(el('p', 'mods-submit-warn', t('MADRE did not answer.'))); });
17616
+ }
17617
+
17618
+ function skillsSection(board) {
17619
+ const skills = modules.skills ?? [];
17620
+ const failures = modules.skillFailures ?? [];
17621
+ const aside = sxButton(t('Bring over what you already have'), () => openSkillImport());
17622
+ const block = sxBlock(board, t('Skills'), t('Ways of working you keep, handed to whichever agent answers. They tell your agents how you work; they never give them permission.'), { className: 'skills-block', aside });
17623
+ if (!skills.length) block.rows.append(el('p', 'settings-reading', t('None yet. Write one with /habilidad in the conversation, or bring over the ones your agents already keep.')));
17624
+ for (const skill of skills) block.rows.append(skillRow(skill));
17625
+ for (const one of failures) block.rows.append(el('p', 'mods-submit-warn', t('{dir} was not read: {error}', { dir: one.dir, error: one.error })));
17626
+ }
17627
+
16956
17628
  // A module that has something to read can float: its card in a window of its own, kept up to date
16957
17629
  // with the board, placed where it was left.
16958
17630
  const moduleWindows = new Map();
@@ -17692,6 +18364,7 @@ function openRoomMarket(focus = null) {
17692
18364
  toast: (words) => toast(words),
17693
18365
  installHere: async (item) => { openModules(); await refreshModules(); renderModules(); openModuleSheet(item.id); },
17694
18366
  changed: async () => { await refreshModules(); if (modules.dialog.open) renderModules(); barModulesChanged(); },
18367
+ importSkills: () => openSkillImport(),
17695
18368
  },
17696
18369
  });
17697
18370
  }
@@ -17705,6 +18378,8 @@ function openRoomMarket(focus = null) {
17705
18378
  market.innerHTML = trazo('market-key'); // trusted: our own SVG string
17706
18379
  market.append(el('span', null, t('Market')));
17707
18380
  market.title = t('Every module MADRE can add to this project');
18381
+ // Its name when a narrow window shows only the basket.
18382
+ market.setAttribute('aria-label', t('Market'));
17708
18383
  market.addEventListener('click', () => openRoomMarket());
17709
18384
  add.before(market);
17710
18385
  }
@@ -17724,6 +18399,14 @@ if (/^#chat=/.test(globalThis.location?.hash ?? '')) {
17724
18399
  history.replaceState(null, '', location.pathname + location.search);
17725
18400
  if (/^[a-z0-9]+$/.test(id ?? '')) setTimeout(() => { void openChatAt(id, messageId || null); }, motion(500));
17726
18401
  }
18402
+ // A first message written by the welcome (1.1, #escribe=<words>): it waits in the box, for the person
18403
+ // to read and send. Nothing is sent on its own.
18404
+ if (/^#escribe=/.test(globalThis.location?.hash ?? '')) {
18405
+ let words = '';
18406
+ try { words = decodeURIComponent(location.hash.slice(9)).slice(0, 2000); } catch { words = ''; }
18407
+ history.replaceState(null, '', location.pathname + location.search);
18408
+ if (words.trim()) setTimeout(() => { els.input.value = words; els.input.focus(); autosize(); renderHighlight(); }, motion(500));
18409
+ }
17727
18410
  // The Market's address in a project: #mercado, or #mercado=<module> on its page.
17728
18411
  if (/^#mercado(=|$)/.test(globalThis.location?.hash ?? '')) {
17729
18412
  const id = decodeURIComponent(location.hash.split('=')[1] ?? '') || null;
@@ -17773,17 +18456,28 @@ function trackStats(event) {
17773
18456
  function fmtUsd(value) { return value > 0 && value < 0.01 ? '< $0.01' : `$${value.toFixed(2)}`; }
17774
18457
  function fmtMs(ms) { return ms === null ? '—' : ms < 1000 ? `${ms}ms` : `${Math.round(ms / 1000)}s`; }
17775
18458
 
17776
- function capabilityBadges(id) {
18459
+ // What an agent can do, as things it does (1.1, 2026-11-08): what it can, ticked; what it cannot, said
18460
+ // as such, so a person knows before asking.
18461
+ const CAN_DO = {
18462
+ read: [() => t('Read your project'), () => t('It cannot read your project')],
18463
+ imageIn: [() => t('See the images you send it'), () => t('It cannot see images')],
18464
+ write: [() => t('Create and change files, when you allow it'), () => t('It cannot change files: it only reads')],
18465
+ imageGen: [() => t('Make images'), () => t('It cannot make images')],
18466
+ web: [() => t('Look things up on the internet'), () => t('It cannot look things up on the internet')],
18467
+ };
18468
+ function capabilityList(id) {
17777
18469
  const caps = state.capabilities[id] ?? {};
17778
- const wrap = el('div', 'caps');
17779
- wrap.style.marginTop = '10px';
17780
- for (const [key, labelText] of Object.entries(CAP_LABELS)) {
17781
- const badge = el('span', `cap${caps[key] ? ' on' : ''}`, labelText);
18470
+ const box = el('section', 'pop-can');
18471
+ box.append(el('h4', null, t('What it can do')));
18472
+ const list = el('ul');
18473
+ for (const [key, [can, cannot]] of Object.entries(CAN_DO)) {
18474
+ const item = el('li', caps[key] ? 'on' : 'off', caps[key] ? can() : cannot());
17782
18475
  const detail = caps.detail?.[key];
17783
- badge.title = caps[key] ? `${labelText}: ${detail?.how ?? t('available')}${detail?.note ? ` · ${detail.note}` : ''}` : t('{what}: not available from this CLI', { what: labelText });
17784
- wrap.append(badge);
18476
+ if (caps[key] && (detail?.how || detail?.note)) item.title = [detail.how, detail.note].filter(Boolean).join(' · ');
18477
+ list.append(item);
17785
18478
  }
17786
- return wrap;
18479
+ box.append(list);
18480
+ return box;
17787
18481
  }
17788
18482
 
17789
18483
  // Where a card stands: under what opened it, inside the window.
@@ -17861,21 +18555,24 @@ function openAgentPop(id, anchor, { back = null } = {}) {
17861
18555
  const lamp = session?.state === 'signed-in' ? 'ok' : session?.state === 'signed-out' || !agent.ready ? 'bad' : 'wait';
17862
18556
  head.append(el('span', `pop-session ${lamp}`, session ? ({ 'signed-in': t('signed in'), 'signed-out': t('signed out') }[session.state] ?? t('unknown')) : agent.ready ? t('unknown') : t('not ready')));
17863
18557
  pop.append(head);
17864
- // Read top to bottom (2026-10-14): one figure and its gauge, four plain numbers, what the
17865
- // provider says (or that it says nothing), the connection in one line, what it can do, and the
17866
- // way to its settings.
18558
+ // Read top to bottom (2026-10-14; said plainly in 1.1, 2026-11-08): how much of your plan is used and
18559
+ // when it renews, what it spent here (with what a token is), how long MADRE waits for it, what it
18560
+ // can do — said as things it does, not as labels — and the way to its settings.
17867
18561
  const hero = el('div', 'pop-hero');
17868
18562
  let figure;
17869
18563
  let caption;
17870
18564
  if (official !== null) {
17871
18565
  figure = `${Math.round(official)}%`;
17872
- caption = t("of the provider's {window} limit", { window: fmtWindow(agent.officialWindows?.primary?.windowMinutes ?? 300) });
18566
+ // The figure is the window closest to its limit, which is not always the 5-hour one: say which.
18567
+ const windows = [agent.officialWindows?.primary, agent.officialWindows?.secondary].filter(Boolean);
18568
+ const binding = windows.find((one) => Math.round(one.usedPercent) === Math.round(official)) ?? windows[0];
18569
+ caption = t('of what your plan lets you use every {window}', { window: humanWindow(binding?.windowMinutes ?? 300) });
17873
18570
  } else if (state.budget) {
17874
18571
  figure = `${Math.round(percent)}%`;
17875
- caption = t("of this project's limit · last 5 h");
18572
+ caption = t('of the limit you gave it in this project, over the last 5 hours');
17876
18573
  } else {
17877
18574
  figure = formatTokens(agent.tokens ?? 0) || '0';
17878
- caption = t('tokens in the last 5 h');
18575
+ caption = t('tokens in the last 5 hours');
17879
18576
  }
17880
18577
  const big = el('div', 'big', figure);
17881
18578
  big.append(el('small', null, caption));
@@ -17884,28 +18581,36 @@ function openAgentPop(id, anchor, { back = null } = {}) {
17884
18581
  const fill = el('i'); fill.style.width = `${shown}%`; gauge.append(fill);
17885
18582
  hero.append(gauge);
17886
18583
  const under = official !== null
17887
- ? (agent.officialResetAt ? t(' · resets {when}', { when: fmtReset(agent.officialResetAt) }) : t(' · window reset')).replace(/^\s*·\s*/, '')
18584
+ ? (agent.officialResetAt ? t('It renews {when}.', { when: fmtReset(agent.officialResetAt) }) : t('It has just renewed.'))
17888
18585
  : state.budget ? t('{used} of {total} tokens', { used: formatTokens(agent.tokens ?? 0) || '0', total: formatTokens(state.budget) }) + (agent.rollsOverAt ? t(' · oldest turn drops {when}', { when: fmtReset(agent.rollsOverAt) }) : '') : null;
17889
18586
  if (under) hero.append(el('div', 'pop-reset', under));
17890
18587
  pop.append(hero);
17891
18588
 
17892
18589
  const grid = el('div', 'pop-stats');
17893
- const stat = (label, value) => { const box = el('div', 'pop-stat'); box.append(el('span', null, label), el('b', null, value)); grid.append(box); };
17894
- stat(t('In this project'), `${formatTokens(agent.rawTokens ?? 0) || '0'} tok`);
17895
- stat(t('Answers'), String(stats.turns));
17896
- stat(t('Last answer'), stats.lastTurnMs ? `${fmtMs(stats.lastTurnMs)}${stats.lastTurnTokens ? ` · ${formatTokens(stats.lastTurnTokens)}` : ''}` : '—');
18590
+ const stat = (label, value) => { const box = el('div', 'pop-stat'); box.append(el('span', null, label), el('b', null, value)); grid.append(box); return box; };
18591
+ // What a token is, where it is asked: on the figure, not as a paragraph under it.
18592
+ stat(t('Spent in this project'), `${formatTokens(agent.rawTokens ?? 0) || '0'} tokens`).title = t('A token is a piece of a word: it is how AIs count what they read and write. A short answer is a few hundred.');
18593
+ stat(t('Answers here'), String(stats.turns));
18594
+ stat(t('Its last answer'), stats.lastTurnMs ? `${fmtMs(stats.lastTurnMs)}${stats.lastTurnTokens ? ` · ${formatTokens(stats.lastTurnTokens)}` : ''}` : '—');
17897
18595
  stat(stats.costEstimated ? t('Cost (estimated)') : t('Cost'), stats.cost > 0 ? `${stats.costEstimated ? '≈ ' : ''}${fmtUsd(stats.cost)}` : '—');
17898
18596
  pop.append(grid);
17899
18597
 
17900
18598
  const provider = el('section', 'pop-provider');
17901
18599
  if (agent.officialWindows) {
17902
18600
  const { primary, secondary } = agent.officialWindows;
18601
+ // Each limit of the plan as its own small gauge (1.1): the window, how full, and when it renews.
17903
18602
  const line = (one) => {
17904
- const row = el('div', `pop-limit${one.usedPercent >= 80 ? ' hot' : ''}`);
17905
- row.append(el('span', null, t('{window} limit', { window: fmtWindow(one.windowMinutes) })), el('b', null, one.resetAt ? t('{pct}% · resets {when}', { pct: Math.round(one.usedPercent), when: fmtReset(one.resetAt) }) : `${Math.round(one.usedPercent)}%`));
18603
+ const pct = Math.max(0, Math.min(100, Math.round(one.usedPercent)));
18604
+ const row = el('div', `pop-limit${pct >= 80 ? ' hot' : ''}`);
18605
+ const meter = el('span', 'pop-meter');
18606
+ const fill = el('i'); fill.style.width = `${pct}%`; meter.append(fill);
18607
+ row.append(el('span', 'pop-window', humanWindow(one.windowMinutes)), meter, el('b', null, `${pct} %`));
18608
+ if (one.resetAt && pct > 0) row.append(el('small', null, t('renews {when}', { when: fmtReset(one.resetAt) })));
17906
18609
  provider.append(row);
17907
18610
  };
17908
- provider.append(el('h4', null, t('Your plan')));
18611
+ const title = el('h4', null, t('Your plan'));
18612
+ title.title = t('Your plan lets you use this AI up to a limit, which renews every so often. When it reaches 100 %, it waits until it renews.');
18613
+ provider.append(title);
17909
18614
  if (primary) line(primary);
17910
18615
  if (secondary) line(secondary);
17911
18616
  } else if (Number.isFinite(agent.officialPercent)) {
@@ -17916,9 +18621,26 @@ function openAgentPop(id, anchor, { back = null } = {}) {
17916
18621
  pop.append(provider);
17917
18622
 
17918
18623
  const timeout = Math.round((state.timeouts[id] ?? 180000) / 1000);
17919
- const meta = [session?.detail, agent.version ? t('version {version}', { version: agent.version }) : null, t('waits up to {time}', { time: timeout >= 120 ? t('{n} min', { n: Math.round(timeout / 60) }) : `${timeout}s` })].filter(Boolean);
17920
- pop.append(el('p', 'pop-meta', meta.join(' · ')));
17921
- pop.append(capabilityBadges(id));
18624
+ const wait = timeout >= 120 ? t('{n} min', { n: Math.round(timeout / 60) }) : `${timeout}s`;
18625
+ // How it is connected, how long MADRE waits for it and its version, as three small chips.
18626
+ const meta = el('div', 'pop-chips');
18627
+ // An agent signed in through several providers (OpenCode) shows each as its own chip, by name, and
18628
+ // says on it whether it entered with your account or with a key — not «OpenAI (oauth), …» in a line.
18629
+ const providers = Array.isArray(session?.providers) ? session.providers : [];
18630
+ if (providers.length) {
18631
+ for (const one of providers.slice(0, 4)) {
18632
+ const chip = el('span', 'pop-provider-chip', one.name);
18633
+ chip.title = /oauth/i.test(one.type ?? '') ? t('Signed in with your {name} account', { name: one.name }) : t('Connected with a {name} API key', { name: one.name });
18634
+ meta.append(chip);
18635
+ }
18636
+ if (providers.length > 4) meta.append(el('span', null, `+${providers.length - 4}`));
18637
+ } else if (session?.detail) meta.append(el('span', null, session.detail));
18638
+ const waits = el('span', null, t('waits {time}', { time: wait }));
18639
+ waits.title = t('If it takes longer than {time} to answer, MADRE stops waiting.', { time: wait });
18640
+ meta.append(waits);
18641
+ if (agent.version) meta.append(el('span', null, agent.version));
18642
+ pop.append(meta);
18643
+ pop.append(capabilityList(id));
17922
18644
  const go = el('button', 'pop-go', t('Connection and limits in Settings'));
17923
18645
  go.type = 'button';
17924
18646
  go.addEventListener('click', (event) => { event.stopPropagation(); closeAgentPop(); openSettingsOn('agents', { agent: id }); });
@@ -19203,7 +19925,7 @@ async function drawMemoryDashboard(glance, analysis, stamp) {
19203
19925
  for (const [id, n] of [['search', dash.via.search], ['cascade', dash.via.cascade]]) { const part = el('i', id); part.style.flexGrow = String(n); split.append(part); }
19204
19926
  recall.append(split);
19205
19927
  const legend = el('div', 'mem-legend');
19206
- for (const [id, label, n] of [['search', t('Search'), dash.via.search], ['cascade', t('Related memories'), dash.via.cascade]]) {
19928
+ for (const [id, label, n] of [['search', t('Search'), dash.via.search], ['cascade', t('Related notes'), dash.via.cascade]]) {
19207
19929
  const key = el('span', `k ${id}`);
19208
19930
  key.append(el('i'), `${label} `, el('b', null, `${memFmt(n)} · ${memPct(n / carried)}`));
19209
19931
  legend.append(key);
@@ -19249,7 +19971,7 @@ function examRow(id, state, run, pass = null) {
19249
19971
  row.append(el('p', 'note about', EXAM_ABOUT[id]));
19250
19972
  if (last?.says) {
19251
19973
  const said = el('p', 'said', last.says);
19252
- const when = last.at ? ` · ${new Date(last.at).toLocaleString()}` : '';
19974
+ const when = last.at ? ` · ${new Date(last.at).toLocaleString(language(), { day: 'numeric', month: 'short', hour: '2-digit', minute: '2-digit' })}` : '';
19253
19975
  const how = last.ran && last.rate !== undefined ? `${Math.round(last.rate * 100)}% · ${t('{n} CASES', { n: last.n })}${last.method ? t(' · BY {method}', { method: last.method.toUpperCase() }) : ''}${last.bar ? t(' · BAR {bar}', { bar: last.bar }) : ''}${when}` : when.replace(' · ', '');
19254
19976
  row.append(said);
19255
19977
  // The rate against the line it has to reach: the bar fills to what it scored, the mark
@@ -19454,11 +20176,17 @@ function connectionCard(agent) {
19454
20176
  }
19455
20177
  // The ceiling lives with every other agent's in PERMISSIONS: here it is said, and one key goes there.
19456
20178
  const currentCap = agentScopes.maxMode ?? 1;
19457
- const capRow = sxRow(modes, t('Max mode'), `#${currentCap} ${MODES[currentCap].label}`, sxButton(t('Change it'), () => openSettingsOn('permissions', { part: 'permissions' })));
20179
+ // An agent that reads at every mode (Grok, Gemini through its API): no ceiling to change and no
20180
+ // «Create» to unlock — both rows say so instead of offering a key that can do nothing (2026-11-06).
20181
+ const readsOnly = Boolean(agentScopes.write) && !agentScopes.write.capable;
20182
+ const capRow = readsOnly
20183
+ ? sxRow(modes, t('Max mode'), t('#1 CHAT ONLY · in MADRE this agent reads and answers; no mode lets it write.'))
20184
+ : sxRow(modes, t('Max mode'), `#${currentCap} ${MODES[currentCap].label}`, sxButton(t('Change it'), () => openSettingsOn('permissions', { part: 'permissions' })));
19458
20185
  capRow.querySelector('.sx-hint').title = MODES[currentCap].hint;
19459
20186
  // The start: where a message to this agent begins. #2 means every turn may create files without arming CREATE.
19460
20187
  const currentStart = agentScopes.defaultMode ?? 1;
19461
- sxRow(modes, t('Starting mode'), currentStart === 2 ? t('Every turn may create files, plan steps too.') : t('Read-only until you unlock CREATE.'), sxSeg([1, 2].map((n) => ({
20188
+ if (readsOnly) sxRow(modes, t('Starting mode'), t('Always #1: every message to it is answered by reading.'));
20189
+ else sxRow(modes, t('Starting mode'), currentStart === 2 ? t('Every answer may create files and plan steps.') : t('It only reads and answers until you let it create.'), sxSeg([1, 2].map((n) => ({
19462
20190
  value: n, text: `#${n}`, className: `o${n}`, disabled: n > currentCap,
19463
20191
  title: n === 2 ? t('Every message to this agent starts in #2 CREATE: it may add new files, but existing files stay untouched. Plan steps sent to it too.') : t('Messages start in #1 CHAT ONLY; turn on #2 CREATE when you want files.'),
19464
20192
  })), currentStart, async (n, seg) => {
@@ -19483,8 +20211,9 @@ function connectionCard(agent) {
19483
20211
  if (result?.sessions) renderSettings();
19484
20212
  recheck.disabled = false;
19485
20213
  });
19486
- if (!agent.detected && agent.install?.command) {
19487
- const install = sxButton(t('Install'), async () => {
20214
+ // Gemini answering through its API (a key, no CLI) can still get its CLI, for the rest it does.
20215
+ if ((!agent.detected || agent.viaApi) && agent.install?.command) {
20216
+ const install = sxButton(agent.viaApi ? t('Install the Gemini CLI') : t('Install'), async () => {
19488
20217
  install.disabled = true;
19489
20218
  state.loginLogs.set(agent.id, []);
19490
20219
  const response = await fetch(`/api/agents/${agent.id}/install`, { method: 'POST' });
@@ -19512,14 +20241,15 @@ function connectionCard(agent) {
19512
20241
  acts.append(recheck);
19513
20242
  const slot = el('div', 'sx-slot');
19514
20243
  // OpenCode's keys are its providers', added in the block under its settings, one row for all.
19515
- if (agent.detected && agent.key && agent.id !== 'opencode') slot.append(keyForm(agent, { onDone: () => { void loadSettings(); renderOnboarding(); } }));
20244
+ // Gemini takes its key with or without its CLI: the key alone is how it answers through its API.
20245
+ if ((agent.detected || agent.id === 'gemini') && agent.key && agent.id !== 'opencode') slot.append(keyForm(agent, { onDone: () => { void loadSettings(); renderOnboarding(); } }));
19516
20246
  // Gemini's key is its way in (agent.key.first): the field before the Google door.
19517
20247
  if (agent.key?.first && slot.firstChild) { const first = el('div', 'sx-slot'); first.append(slot.firstChild); body.append(first); }
19518
20248
  body.append(acts);
19519
20249
  if (agent.detected && agent.login?.headless) slot.append(loginAskSlot(agent.id));
19520
20250
  // The same, typed in a terminal, folded for whoever prefers it. Signed in, OpenCode's providers
19521
20251
  // are added in its block below; its terminal is for a first sign-in.
19522
- const way = !agent.detected ? installTerminalWay(agent) : agent.id === 'opencode' && session?.state === 'signed-in' ? null : signInTerminalWay(agent);
20252
+ const way = !agent.detected || agent.viaApi ? installTerminalWay(agent) : agent.id === 'opencode' && session?.state === 'signed-in' ? null : signInTerminalWay(agent);
19523
20253
  if (way) slot.append(way);
19524
20254
  const log = state.loginLogs.get(agent.id) ?? [];
19525
20255
  if (log.length || busy) {
@@ -19629,8 +20359,8 @@ function drawMemory(host, data) {
19629
20359
  aside.append(sxButton(t('Refresh'), () => void drawMemoryDashboard(glance, analysis, stamp)));
19630
20360
  void drawMemoryDashboard(glance, analysis, stamp);
19631
20361
 
19632
- const keep = sxBlock(host, t('Who takes notes'), t('An agent rereads recent conversations and saves only what is worth remembering. The cheapest one goes first; local AI is free and private.'));
19633
- sxRow(keep, t('Who takes notes first'), null, select([['auto', t('Automatic · the cheapest one')], ...mem.candidates.map((c) => [c.id, `@${c.id}${c.local ? ` · ${c.label}` : ''}`])], mem.archivist, (value) => save({ archivist: value }, value === 'auto' ? t('notes: the cheapest agent goes first.') : t('notes: @{agent} goes first.', { agent: value })), t('Who takes notes first')));
20362
+ const keep = sxBlock(host, t('Who takes notes'), t('So that MADRE remembers, every so often an AI rereads your latest conversations and writes down what matters: decisions, names, to-dos. The cheapest one does it first; the AI on your computer does it free, without anything leaving it.'));
20363
+ sxRow(keep, t('Who does it first'), null, select([['auto', t('Automatic · the cheapest one')], ...mem.candidates.map((c) => [c.id, `@${c.id}${c.local ? ` · ${c.label}` : ''}`])], mem.archivist, (value) => save({ archivist: value }, value === 'auto' ? t('notes: the cheapest agent goes first.') : t('notes: @{agent} goes first.', { agent: value })), t('Who takes notes first')));
19634
20364
  const allowed = new Set(mem.archivists ?? mem.candidates.map((c) => c.id));
19635
20365
  const who = el('div', 'sx-chips');
19636
20366
  for (const candidate of mem.candidates) {
@@ -19645,25 +20375,26 @@ function drawMemory(host, data) {
19645
20375
  });
19646
20376
  who.append(chip);
19647
20377
  }
19648
- sxRow(keep, t('Who may take notes'), t('Only the agents switched on here take notes.'), who, { stack: true });
19649
- sxRow(keep, t('Every'), t('How many exchanges pass before it takes notes again.'), sxNumber(mem.every, t('exchanges'), { min: 1, label: t('Every'), wire: { toPatch: (value) => ({ memory: { every: value } }), describe: (value) => t('notes every {n} exchanges.', { n: value }) } }));
19650
- sxRow(keep, t('Or after'), t('Or take notes after this many quiet minutes.'), sxNumber(mem.idleMinutes, t('min'), { min: 1, label: t('Or after'), wire: { toPatch: (value) => ({ memory: { idleMinutes: value } }), describe: (value) => t('or after {n} quiet minutes.', { n: value }) } }));
19651
-
19652
- const recall = sxBlock(host, t('Using memories'), t('How many memories each answer uses, and how they are found.'));
19653
- sxRow(recall, t('Room for memories'), t('At most, how much of what an agent reads can be memories.'), sxNumber(Math.round(mem.recallShare * 100), '%', { min: 0, step: 5, label: t('Room for memories'), wire: { toPatch: (value) => ({ memory: { recallShare: Math.min(60, value) / 100 } }), describe: (value) => t("memories may take up to {n}% of what each agent reads.", { n: Math.min(60, value) }) } }));
19654
- const cascade = sxSwitch(mem.cascade !== false, (on) => save({ cascade: on }, on ? t('related memories come along too.') : t('only memories that match come along.')), { label: t('Related memories') });
19655
- sxRow(recall, t('Related memories'), t('Memories that are often used together are brought in together.'), cascade);
19656
- const embedNow = mem.embedder ? mem.embedder : t('off');
19657
- sxRow(recall, t('Search by meaning'), t('Finds memories by what they mean, not only by exact words. Now: {what}.', { what: embedNow }), select([
20378
+ sxRow(keep, t('Who may do it'), t('Only the AIs switched on here.'), who, { stack: true });
20379
+ sxRow(keep, t('Every'), t('It writes notes again after this many messages.'), sxNumber(mem.every, t('exchanges'), { min: 1, label: t('Every'), wire: { toPatch: (value) => ({ memory: { every: value } }), describe: (value) => t('notes every {n} exchanges.', { n: value }) } }));
20380
+ sxRow(keep, t('Or after'), t('Or when the project has been quiet this long.'), sxNumber(mem.idleMinutes, t('min'), { min: 1, label: t('Or after'), wire: { toPatch: (value) => ({ memory: { idleMinutes: value } }), describe: (value) => t('or after {n} quiet minutes.', { n: value }) } }));
20381
+
20382
+ const recall = sxBlock(host, t('Using memories'), t('When you ask something, MADRE hands the AI the notes that have to do with it. Here you choose how many, and how it finds them.'));
20383
+ sxRow(recall, t('How many notes it hands over'), t('At most, this share of what the AI reads can be notes. More notes, a better memory, and also more tokens.'), sxNumber(Math.round(mem.recallShare * 100), '%', { min: 0, step: 5, label: t('How many notes it hands over'), wire: { toPatch: (value) => ({ memory: { recallShare: Math.min(60, value) / 100 } }), describe: (value) => t("memories may take up to {n}% of what each agent reads.", { n: Math.min(60, value) }) } }));
20384
+ const cascade = sxSwitch(mem.cascade !== false, (on) => save({ cascade: on }, on ? t('related memories come along too.') : t('only memories that match come along.')), { label: t('Related notes') });
20385
+ sxRow(recall, t('Related notes'), t('Notes that are usually needed together come together: if one about your prices comes, the one about your discounts comes too.'), cascade);
20386
+ // Said as where it happens, not as the model's name (1.1): «ollama:nomic-embed-text:latest» told nobody anything.
20387
+ const embedNow = !mem.embedder ? t('off') : /^ollama/i.test(mem.embedder) ? t('with the AI on your computer') : /^gemini/i.test(mem.embedder) ? t('with Gemini') : mem.embedder;
20388
+ sxRow(recall, t('Search by meaning'), t('It finds a note even if you ask in other words: «how much do we charge?» finds «price: 450». Now: {what}.', { what: embedNow }), select([
19658
20389
  ['auto', t('Automatic · Local AI if running, else Gemini')],
19659
- ['ollama', `Ollama · ${t('local')}${mem.ollama.embedModel ? ` · ${mem.ollama.embedModel}` : ` · ${t('no model yet')}`}`],
20390
+ ['ollama', mem.ollama.embedModel ? t('With the AI on your computer · free and private') : t('With the AI on your computer · its model is not there yet')],
19660
20391
  ['gemini', t('Gemini · needs your key')],
19661
20392
  ['off', t('Off · exact words only')],
19662
20393
  ], mem.embedProvider ?? data.config?.memory?.embedProvider ?? 'auto', (value, node) => save({ embedProvider: value }, t('search by meaning: {what}.', { what: node.options[node.selectedIndex].textContent.toLowerCase() })), t('Search by meaning')));
19663
20394
  if (mem.envWins) sxFoot(recall, t('Some of these values are fixed by how MADRE was started; those win next time it starts.'));
19664
20395
 
19665
20396
  // The dataset behind MADRE AI, and the recipe that trains on it, outside MADRE.
19666
- const train = sxBlock(host, t('Train your own AI'), t('Advanced: export what the project learned, train a model on your computer, and @madre answers with it.'));
20397
+ const train = sxBlock(host, t('Train your own AI'), t('For later, if you want: MADRE can teach a small AI on your computer what this project learned, so that @madre answers with it. It takes a while and it is optional.'));
19667
20398
  const datasetHint = el('span', 'sx-hint', t('Reading…'));
19668
20399
  const exportButton = sxButton(t('Export'), async () => {
19669
20400
  exportButton.disabled = true;
@@ -19675,7 +20406,15 @@ function drawMemory(host, data) {
19675
20406
  datasetRow.querySelector('.sx-words').append(datasetHint);
19676
20407
  // What it is, then the recipe in order (2026-10-14): one command per step, for a Mac with an
19677
20408
  // Apple chip or — tried, not promised — Linux with an NVIDIA card through MLX's CUDA package.
19678
- train.append(el('p', 'sx-hint sx-train-what', t('The training data are question-and-answer pairs taken from this project\'s conversations and notes, with private details hidden. With them a small model is adjusted on your computer, and @madre answers with it.')));
20409
+ // How it works, in three lines (1.1, 2026-11-08), before the recipe: what goes in, where it happens,
20410
+ // and what comes out — and that the lines below already carry this computer's own folders.
20411
+ const how = el('ol', 'sx-train-how');
20412
+ for (const line of [
20413
+ t('MADRE gathers questions and answers from this project\'s conversations and notes, with private details hidden.'),
20414
+ t('With them, a small AI on your computer learns how this project works. Nothing leaves your computer, and it costs nothing.'),
20415
+ t('When it is ready, @madre answers with it in this project on its own. You try it before trusting it.'),
20416
+ ]) how.append(el('li', null, line));
20417
+ train.append(how, el('p', 'sx-hint sx-train-what', t('Each step is a line you copy into a terminal (the window where you type commands). The lines already carry this project\'s folders on your computer: copy them as they are.')));
19679
20418
  const recipe = el('details', 'sx-more');
19680
20419
  recipe.append(el('summary', null, t('Step by step')));
19681
20420
  // Windows trains inside WSL with its NVIDIA card (2026-10-28): the same recipe as Linux, run in
@@ -19756,6 +20495,8 @@ function drawMemory(host, data) {
19756
20495
  step(t('Turn it into a file Ollama reads (GGUF)'), t('The first time, it downloads llama.cpp\'s converter.'), `${venv} && cd ${quote(info.roomDir)} && git clone --depth 1 https://github.com/ggml-org/llama.cpp && pip install -r llama.cpp/requirements.txt && python3 llama.cpp/convert_hf_to_gguf.py fused --outfile madre.gguf --outtype ${quantized ? 'f16' : 'q8_0'}`);
19757
20496
  step(t('Register it in Ollama as {model}', { model: info.modelName }), quantized ? t('Ollama keeps it in 4 bits, the size the table counts on. @madre switches to it at the next recheck of Local AI.') : t('@madre switches to it at the next recheck of Local AI.'), `cd ${quote(info.roomDir)} && cp ${quote(`${info.recipeDir}Modelfile`)} . && ollama create ${info.modelName} -f Modelfile${quantized ? ' --quantize q4_K_M' : ''}`);
19758
20497
  step(t('Try it before trusting it'), t('Ask @madre ten things the project decided and five it never discussed. It should get the first right and say it never discussed the others; if it makes things up, remove it with «ollama rm {model}» and train with more pairs.', { model: info.modelName }));
20498
+ // How it is part of MADRE from then on (1.1): nothing to switch on, and the way back out.
20499
+ step(t('It is part of MADRE now'), t('@madre answers with {model} in this project without you doing anything; Settings › Local AI shows it in use. To go back to the usual model, delete it with «ollama rm {model}».', { model: info.modelName }));
19759
20500
  if (state.salas) drawExam();
19760
20501
  };
19761
20502
  // D-S18 · in Home, the exam the Coordinator's local model passes before it gives orders: the
@@ -20078,7 +20819,7 @@ function drawPermissions(host, data) {
20078
20819
  const options = mode === 3 ? [0, 5, 15, 30, 60, 240, 480] : [0, 5, 15, 30, 60];
20079
20820
  sxRow(grace, `#${mode} ${sentence(MODES[mode].label)}`, mode === 4 ? t('Up to an hour: what leaves the computer does not come back.') : t('Raising an agent\'s max mode always asks, remembered permission or not.'), sxSelect(options.map((minutes) => [String(minutes), minutes ? minutesWords(minutes) : t('Off')]), String(config.grace[mode] ?? 0), (value) => {
20080
20821
  const minutes = Number(value);
20081
- if (!minutes) closeOverrideGrace(mode);
20822
+ if (!minutes) closeOverrideGrace(mode, null, { back: true });
20082
20823
  return saveOverride({ grace: { [mode]: minutes } }, minutes ? t('#{n} {label} stays unlocked for {time} after you confirm it.', { n: mode, label: sentence(MODES[mode].label), time: minutesWords(minutes) }) : t('#{n} {label} asks you to confirm every message.', { n: mode, label: sentence(MODES[mode].label) }));
20083
20824
  }, t('Remember permission for #{n}', { n: mode })));
20084
20825
  }
@@ -21388,8 +22129,10 @@ function showNostromoCard(node) {
21388
22129
  card.style.setProperty('--kind', node.color);
21389
22130
  cardPart(card, 'kind').textContent = askWords(kindWord(memory.kind));
21390
22131
  cardPart(card, 'text').textContent = memory.text;
21391
- cardPart(card, 'span').textContent = memory.fromSequence === memory.throughSequence ? `#${memory.fromSequence}` : `#${memory.fromSequence}–#${memory.throughSequence}${memory.sources?.length ? ` · cites ${memory.sources.map((n) => `#${n}`).join(' ')}` : ''}`;
21392
- cardPart(card, 'agent').textContent = `@${memory.agent}${memory.origin === 'noted' ? t(" · on the human's request") : memory.origin === 'flagged' ? t(' · flagged by {who}', { who: memory.detector ?? t('the project') }) : t(' · distilled')}`;
22132
+ // A note an agent wrote with no source says so, never a number of the history it does not come from.
22133
+ const noSource = memory.origin === 'noted' && !memory.sources?.length;
22134
+ cardPart(card, 'span').textContent = noSource ? t('no source') : memory.fromSequence === memory.throughSequence ? `#${memory.fromSequence}` : `#${memory.fromSequence}–#${memory.throughSequence}${memory.sources?.length ? ` · cites ${memory.sources.map((n) => `#${n}`).join(' ')}` : ''}`;
22135
+ cardPart(card, 'agent').textContent = `@${memory.agent}${memory.origin === 'noted' ? t(' · noted by the agent') : memory.origin === 'flagged' ? t(' · flagged by {who}', { who: memory.detector ?? t('the project') }) : t(' · distilled')}`;
21393
22136
  cardPart(card, 'when').textContent = memory.created ? new Date(memory.created).toLocaleString() : '';
21394
22137
  // Where it stands aboard, said where it can be seen: the word on a mark of its own and what it
21395
22138
  // means on the line under it. The meaning used to live only in a tooltip, which a finger never
@@ -21614,6 +22357,27 @@ function roomTour() {
21614
22357
  // what it is for. Once per button: after that the button is just a button. From 1.1 every key of
21615
22358
  // the bar that opens something says so too (2026-10-14).
21616
22359
  const FIRST_TOUCH = {
22360
+ copilot: {
22361
+ button: '.copilot-chip',
22362
+ title: t('Copilot'),
22363
+ text: t('The copilot lets an AI work on its own for a while. You choose for how long, and the AI you are writing to can change files and make plans without asking you at every step. It never deletes anything, never sends anything outside this computer, and you stop it whenever you want.'),
22364
+ },
22365
+ // The keys every person presses in their first minutes (1.1, 2026-11-08): what each does, once.
22366
+ activity: {
22367
+ button: '#activity-button',
22368
+ title: t('Running now'),
22369
+ 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.'),
22370
+ },
22371
+ attach: {
22372
+ button: '#attach',
22373
+ title: t('Attach'),
22374
+ text: t('Add an image or a file to your message: a screenshot of what is failing, a PDF, a spreadsheet. You can also drop it on the box or paste it with ⌘ V.'),
22375
+ },
22376
+ options: {
22377
+ button: '#pick-options',
22378
+ title: t('Model and effort'),
22379
+ text: t('Under the box you choose how far the AI may go, which model answers and how hard it thinks. A bigger model and more effort answer better, but take longer.'),
22380
+ },
21617
22381
  // Code (1.0.3) said nothing the first time it opened, and nor did Outside tools (2026-10-21).
21618
22382
  code: {
21619
22383
  button: '#code-button',
@@ -21796,7 +22560,18 @@ function showFirstTouch(hint, button, { step = 0, of = 0, skip = null } = {}) {
21796
22560
  }, 0);
21797
22561
  ok.focus({ preventScroll: true });
21798
22562
  }
21799
- for (const id of Object.keys(FIRST_TOUCH)) document.querySelector(FIRST_TOUCH[id].button)?.addEventListener('click', () => firstTouch(id));
22563
+ // Listened to on the page, not on each key (1.1): some keys are drawn again (the copilot's chip, under
22564
+ // the box), and a listener on the old one heard nothing; heard on the way down, since some keys stop
22565
+ // their click. A press inside two of them (the copilot's chip inside the row under the box) speaks of
22566
+ // the innermost.
22567
+ document.addEventListener('click', (event) => {
22568
+ let best = null;
22569
+ for (const id of Object.keys(FIRST_TOUCH)) {
22570
+ const hit = event.target?.closest?.(FIRST_TOUCH[id].button);
22571
+ if (hit && (!best || best.hit.contains(hit))) best = { id, hit };
22572
+ }
22573
+ if (best) firstTouch(best.id);
22574
+ }, true);
21800
22575
 
21801
22576
  // What a small version brings is said with the same cards, once each, on their own: no welcome and
21802
22577
  // no tour (1.0.2: the copilot, outside tools, the Finder, the memory's door and the folded
@@ -21931,8 +22706,17 @@ const NEWS_GO = {
21931
22706
  const firstSentence = (text) => String(text ?? '').match(/^.*?[.!?…](?=\s|$)/s)?.[0] ?? String(text ?? '');
21932
22707
  // A note's picture, with the colour of its place while it loads; one that does not come shows the
21933
22708
  // note's own 8-bit mark there instead.
22709
+ const newsScenes = new Set();
21934
22710
  function newsShot(item, className) {
21935
22711
  const shot = el('span', `wn-shot ${className}`);
22712
+ // A moving picture of what it is (1.1.3, public/news-scenes.js) in place of a screenshot.
22713
+ if (item.scene) {
22714
+ const scene = createNewsScene(item.scene);
22715
+ newsScenes.add(scene);
22716
+ shot.classList.add('scene');
22717
+ shot.append(scene.node);
22718
+ return shot;
22719
+ }
21936
22720
  const icon = pixelIcon(item.icon, 'pixel-icon wn-shot-icon');
21937
22721
  if (!item.image) { shot.classList.add('missing'); shot.append(icon); return shot; }
21938
22722
  const image = el('img');
@@ -21955,13 +22739,17 @@ function showWhatsNew(news, { after = null } = {}) {
21955
22739
  const dialog = el('dialog', 'whats-new');
21956
22740
  dialog.setAttribute('aria-label', t("What's new in MADRE {version}", { version: news.version }));
21957
22741
  const sheet = el('div', 'wn-sheet');
22742
+ // The sheet takes the focus, not the first card: a card already marked looked chosen for you
22743
+ // (2026-11-08). Tab reaches each thing from here.
22744
+ sheet.tabIndex = -1;
21958
22745
 
21959
22746
  // The head: the mark, the version you now have, what it is about, and the window's ×.
21960
22747
  const head = el('header', 'wn-head');
21961
22748
  const words = el('div', 'wn-headline');
21962
22749
  const logo = document.querySelector('.bar .brand-logo, .brand .brand-logo')?.cloneNode?.(true);
21963
22750
  if (logo) { logo.setAttribute('class', 'brand-logo wn-logo'); words.append(logo); }
21964
- words.append(el('span', 'wn-eyebrow', t("What's new")), el('h2', null, t('You now have {version}', { version: shown })));
22751
+ // Its own words when the version has them (1.1.3: «Good to see you again»), with no label above.
22752
+ words.append(el('h2', null, notes.title ?? t('You now have {version}', { version: shown })));
21965
22753
  if (notes.intro) words.append(el('p', 'wn-intro', notes.intro));
21966
22754
  const keys = el('span', 'surface-modes wn-keys');
21967
22755
  const close = el('button', 'surface-mode close x-close x-only');
@@ -22084,6 +22872,8 @@ function showWhatsNew(news, { after = null } = {}) {
22084
22872
  document.body.append(dialog);
22085
22873
  drawBoard();
22086
22874
  dialog.addEventListener('close', () => {
22875
+ for (const scene of newsScenes) scene.stop();
22876
+ newsScenes.clear();
22087
22877
  dialog.remove();
22088
22878
  if (!board.went) after?.();
22089
22879
  });
@@ -22092,7 +22882,7 @@ function showWhatsNew(news, { after = null } = {}) {
22092
22882
  setTimeout(() => {
22093
22883
  dialog.showModal();
22094
22884
  if (!news.preview) void fetch('/api/whats-new/seen', { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}' }).catch(() => null);
22095
- cards[0]?.focus?.({ preventScroll: true });
22885
+ sheet.focus({ preventScroll: true });
22096
22886
  body.scrollTop = 0;
22097
22887
  }, after ? 700 : 0);
22098
22888
  return dialog;
@@ -22149,6 +22939,21 @@ function drawRelease(section, info) {
22149
22939
  }, { disabled: Boolean(info.envWins), label: t('Look for new versions') });
22150
22940
  sxRow(block, t('Look for new versions'), t('Once a day MADRE checks whether there\'s a new version. Only the app\'s name is sent.') + (info.envWins ? ` ${t('Set by PULSE_UPDATE_CHECK.')}` : ''), check);
22151
22941
  if (info.enabled) sxRow(block, t('Last check'), when ?? t('Not yet.'), sxButton(t('Check now'), () => void loadVersion({ force: true })));
22942
+ // The author's notices (Q-11): info and important ones can be turned off; security ones always show.
22943
+ if (!state.device) {
22944
+ const notices = sxSwitch(true, async (on, box) => {
22945
+ box.disabled = true;
22946
+ const answer = await fetch('/api/notices/settings', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ enabled: on }) }).then((response) => (response.ok ? response.json() : null)).catch(() => null);
22947
+ if (!answer) box.checked = !on;
22948
+ box.disabled = false;
22949
+ askNoticesAgain();
22950
+ }, { disabled: true, label: t('Notices from MADRE') });
22951
+ 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.'), notices);
22952
+ void fetch('/api/notices', { cache: 'no-store' }).then((response) => (response.ok ? response.json() : null)).then((answer) => {
22953
+ const box = notices.querySelector('input');
22954
+ if (answer && box) { box.checked = answer.enabled !== false; box.disabled = false; }
22955
+ }).catch(() => null);
22956
+ }
22152
22957
  // Supporting MADRE (2026-10-30): a donation on GitHub Sponsors, in the person's browser, as Home's
22153
22958
  // Settings › Version has it under this copy's identifier (salas-mac.js, drawDonate). Not from a phone.
22154
22959
  if (!state.device) {
@@ -24076,11 +24881,23 @@ function phoneKeyboard() {
24076
24881
  }
24077
24882
 
24078
24883
  // Every name above exists now: the room is painted (boot, beside the state it reads).
24884
+ // One small solid label for every key that explains itself (public/tips.js).
24885
+ installTips();
24079
24886
  boot();
24080
24887
  // Asking for a star or a review (review-ask.js): on the Mac, and never while something is going on
24081
24888
  // — an agent at work, a plan running, words half written in the box.
24082
24889
  // Asked by the page, never by the half on the right of a split view, which is this same page (WEB-12).
24083
24890
  if (!SPLIT_CHAT) startReviewAsk({ busy: () => Boolean(state.device || state.running.size || state.plansRunning.size || els.input?.value?.trim()) });
24891
+ // The author's notices (Q-11): in a project only the important and security ones, as a strip above
24892
+ // the conversation; the rest wait in Home. Not in the right half of a split view: the left one has it.
24893
+ let askNoticesAgain = () => {};
24894
+ if (!SPLIT_CHAT && !state.device && typeof els.thread?.before === 'function') {
24895
+ const strip = document.createElement('div');
24896
+ strip.className = 'chat-notices';
24897
+ strip.hidden = true;
24898
+ els.thread?.before(strip);
24899
+ askNoticesAgain = mountNotices(strip, { levels: ['important', 'security'] });
24900
+ }
24084
24901
  // The tour of 1.0 reads where the person is as the room opens, so First steps knows whether to
24085
24902
  // wait; on a phone, the phone's card is said the first time.
24086
24903
  if (!SPLIT_CHAT) roomTour();