@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/welcome.js CHANGED
@@ -1,24 +1,33 @@
1
1
  // SPDX-License-Identifier: BUSL-1.1
2
2
  // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
3
  // THE WELCOME of 1.0.6 (2026-10-28, docs/private/BIENVENIDA-1.0.6.md): after `npx madre`, the
4
- // person never needs the terminal again. Seven steps leave MADRE ready — the agents, an AI on the
4
+ // person never needs the terminal again. Its steps leave MADRE ready — the agents, an AI on the
5
5
  // computer when it can carry one, the memory's search and the first project — each adapted to where
6
6
  // MADRE runs (src/environment.mjs: macOS, Linux, WSL, a virtual machine, SSH) and to what the
7
7
  // computer can do (src/modules/local-models.mjs). Every step can be left for later and says what is
8
8
  // lost; a failure is said in the same step, in plain words, with the way out.
9
9
  //
10
+ // 1.1 (2026-11-08, docs/private/BIENVENIDA-1.1.md): set up like a new phone. Six steps, each with
11
+ // one question in everyday words and a picture of what it is doing (welcome-scene.js, the brand's
12
+ // pulse). What can be done alone is done alone: the computer is read during the greeting, the AIs
13
+ // already signed in on it come connected, the folders the person already opened with other tools
14
+ // come marked, and the local AI, its memory and the first word with it download while the person
15
+ // goes on. It ends inside a project with a first message written, chosen for what MADRE is for to
16
+ // this person (`profile`), not for a programmer.
17
+ //
10
18
  // Where the person is lives in ~/.pulse/tour.json (src/tour.mjs, `welcome`), not in the browser:
11
19
  // closing the page halfway brings them back to the same step, from any project or port.
12
20
  //
13
21
  // The host page hands in what only it can do: `agentsPanel(options)` and `projectPicker(options)`
14
- // (Home's own), `mark(id, size)`, `closeKey(onClick)`, `projects()`, `openProject(room)`,
15
- // `setLanguage(code)`, `agentState(agent, answer)`, `openLinks()`, `openMarket()`, `saved(welcome)`
16
- // and `closed()`.
22
+ // (Home's own), `mark(id, size)`, `projects()`, `openProject(room, { draft })`,
23
+ // `setLanguage(code)`, `agentState(agent, answer)`, `saved(welcome)`, `refresh()` (Home's projects
24
+ // read again) and `closed()`.
17
25
 
18
26
  import { t, language } from './i18n.js';
19
27
  import { platformOf, remedyKey } from './remedy.js';
20
28
  import { MADRE_LOGO as BRAND_LOGO, playOpening } from './loader.js';
21
29
  import { trazo } from './icons.js';
30
+ import { createScene } from './welcome-scene.js';
22
31
 
23
32
  const el = (tag, className = null, text = null) => {
24
33
  const node = document.createElement(tag);
@@ -43,10 +52,45 @@ const post = async (url, payload = {}) => {
43
52
  const getJson = (url) => fetch(url, { cache: 'no-store' }).then((response) => (response.ok ? response.json() : null)).catch(() => null);
44
53
  const number = (value) => new Intl.NumberFormat(language(), { maximumFractionDigits: 1 }).format(value);
45
54
 
46
- export const WELCOME_STEPS = ['hello', 'machine', 'agents', 'ai', 'memory', 'project', 'ready'];
55
+ // The project comes right after the agents (2026-11-01): 90 of 147 copies never opened one, and
56
+ // the AI on the computer and the memory, heavy and optional, stood in front of it.
57
+ export const WELCOME_STEPS = ['hello', 'use', 'agents', 'project', 'ai', 'ready'];
47
58
  const STEP_NAMES = {
48
- hello: () => t('Hello'), machine: () => t('Your computer'), agents: () => t('Your agents'), ai: () => t('AI on your computer'),
49
- memory: () => t('Memory'), project: () => t('Your project'), ready: () => t('Ready'),
59
+ hello: () => t('Hello'), use: () => t('What you want it for'), agents: () => t('Your AIs'), project: () => t('Your projects'),
60
+ ai: () => t('AI on your computer'), ready: () => t('Your first message'),
61
+ };
62
+ // What MADRE is for to this person (src/tour.mjs, WELCOME_PROFILES): the examples follow it.
63
+ const PROFILES = [
64
+ { id: 'business', title: () => t('My business'), sub: () => t('What I sell, my customers, my social media.') },
65
+ { id: 'numbers', title: () => t('Invoices and numbers'), sub: () => t('The spreadsheet, the expenses, what the accountant asks for.') },
66
+ { id: 'code', title: () => t('Programming'), sub: () => t('Websites, apps, the usual repository.') },
67
+ { id: 'notes', title: () => t('Writing and getting organised'), sub: () => t('Loose notes, to-dos, long texts.') },
68
+ { id: 'curious', title: () => t('I just want to see what it does'), sub: () => t('Show me, and then I will decide.') },
69
+ ];
70
+ // A first message for each, written as a person would ask it, and what to say first to @madre.
71
+ const IDEAS = {
72
+ business: () => [t('Write the description of my 5 best-selling products'), t('Make me a simple page with my opening hours and my WhatsApp'), t('Answer the questions my customers always ask me')],
73
+ numbers: () => [t('Sort these invoices by month in a table'), t('Check this sheet and tell me what does not add up'), t('Make the expense summary I send to my accountant')],
74
+ code: () => [t('Explain this project to me as if it were my first day'), t('Find out why it does not start'), t('Propose three small fixes and make them in a separate branch')],
75
+ notes: () => [t('Group my loose notes by topic'), t('Plan my week with what I have pending'), t('Remind me on Friday to check this')],
76
+ curious: () => [t('Change the colours of the page'), t('Add a task to the list'), t('Tell me what is in this folder')],
77
+ none: () => [t('Tell me what is in this folder'), t('Sum up this project for me in five lines'), t('What would you improve first here, and why?')],
78
+ };
79
+ const SUGGESTIONS = {
80
+ business: () => [t('Name an end-of-month promotion'), t('Write to a customer who has not paid, without sounding rude')],
81
+ numbers: () => [t('How do I sort my invoices so I never lose one?'), t('Make the list of what I ask my accountant every month')],
82
+ code: () => [t('Explain what a git branch is in two lines'), t('Give me a name for a booking app')],
83
+ notes: () => [t('Make me a list to organise my week'), t('Give me an idea to start a long text')],
84
+ curious: () => [t('What can you do for me?'), t('Tell me something fun in one line')],
85
+ };
86
+ // «Do you already pay for an AI?»: each agent by the plan people know it by.
87
+ const PLANS = {
88
+ codex: () => t('You pay for ChatGPT Plus or Pro: here it is called Codex, ChatGPT working in your files.'),
89
+ claude: () => t('You pay for Claude Pro or Max: you sign in with the same account as on its website.'),
90
+ grok: () => t('You pay for SuperGrok: you sign in with your grok.com account.'),
91
+ cursor: () => t('You pay for Cursor: you sign in with your Cursor account.'),
92
+ gemini: () => t('With your company\'s Google account, or a free key from Google AI Studio.'),
93
+ opencode: () => t('You do not pay for any? OpenCode comes with free models, with a daily limit.'),
50
94
  };
51
95
  // Ollama's own installer for Linux, shown to copy where it asks for the administrator's password: MADRE
52
96
  // never asks for a password nor keeps one (src/modules/ollama.mjs, NEEDS_PASSWORD).
@@ -63,16 +107,24 @@ const TROUBLE = {
63
107
  network: () => t('It could not download: there is no internet connection, or something on this network blocked it. Check your connection and try again.'),
64
108
  disk: () => t('There is not enough free space on this computer. Free up some space or choose a smaller model.'),
65
109
  permission: () => t('This computer did not let MADRE install it. Copy the line below into a terminal, once.'),
110
+ dns: () => t('This computer could not find the address it downloads from (DNS). In WSL, close it from Windows and open it again; with a VPN on, try without it.'),
111
+ 'ollama-closed': () => t('Ollama closed the connection while downloading the model. Check that Ollama is still running and try again; what already arrived stays.'),
112
+ registry: () => t('Ollama\'s model server did not answer (an error on its side). It is not your connection: try again in a few minutes; what already arrived stays.'),
66
113
  timeout: () => t('It took too long and was stopped. Try again.'),
67
114
  };
68
115
 
69
116
  // The card of Diagnostics that explains each of those, with its steps for this system (remedy.js).
70
- const TROUBLE_CARD = { network: 'install-offline', disk: 'disk-full', permission: 'install-needs-admin', timeout: 'install-offline', 'npm-missing': 'node-missing' };
117
+ const TROUBLE_CARD = { network: 'install-offline', dns: 'name-lookup', disk: 'disk-full', permission: 'install-needs-admin', timeout: 'install-offline', 'npm-missing': 'node-missing', 'ollama-closed': 'model-download', registry: 'model-download' };
71
118
 
72
119
  // Ollama prints each piece it downloads as «pulling <digest> · 45%» (src/ollama.mjs, pullModel). The
73
120
  // first piece is the model itself, by far the heaviest: its share is the download's.
74
121
  const PULL_LINE = /^pulling ([0-9a-f]{6,})\b.*?(\d{1,3})%\s*$/;
75
122
 
123
+ // The tools other than MADRE a folder may come from (src/salas.mjs, TOOL_NAMES): their own names.
124
+ const TOOL_NAMES = { claude: 'Claude Code', codex: 'Codex', gemini: 'Gemini', cursor: 'Cursor', vscode: 'VS Code' };
125
+ // How many of the folders other tools know come marked: the newest, the ones the person works in.
126
+ const MARKED = 5;
127
+
76
128
  // THE OPENING plays before the first step (loader.js, shared with the projects).
77
129
 
78
130
  let current = null;
@@ -88,28 +140,36 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
88
140
  const main = el('section', 'wl-main');
89
141
  const content = el('div', 'wl-content');
90
142
  const actions = el('div', 'wl-actions');
91
- const close = host.closeKey?.(() => dialog.close()) ?? button('wl-close', '×', () => dialog.close());
92
- close.classList.add('wl-close');
93
- main.append(close, content, actions);
143
+ // No close key (1.1): the welcome is left through its own keys, «Skip for now» on a step or «Go to
144
+ // Home» at the end, so nobody leaves it halfway by a corner without knowing what was left undone.
145
+ main.append(content, actions);
146
+ dialog.addEventListener('cancel', (event) => event.preventDefault());
94
147
  shell.append(rail, main);
95
148
  dialog.append(shell);
96
149
  document.body.append(dialog);
150
+ // One picture for the whole welcome, kept across the steps: it changes shape, it is never rebuilt.
151
+ const scene = createScene();
97
152
 
98
153
  // Everything the steps decide on, read once when it opens and again when it changes.
99
154
  const s = {
100
155
  step: 0,
101
- progress: { at: null, done: [], skipped: [], finished: null },
156
+ progress: { at: null, done: [], skipped: [], finished: null, profile: [] },
102
157
  env: null, hardware: null, geminiKey: false, memory: null,
103
158
  ollama: null, recommended: null,
104
- choice: null, // the AI step: here · windows · remote · skip
159
+ scanned: false, // the greeting has read the computer
160
+ profile: new Set(), // what MADRE is for to this person
161
+ choice: null, // the AI step: here · other · windows · remote · skip
105
162
  model: null, // the model chosen for this computer (a rung of the Qwen2.5 ladder)
106
163
  pulls: new Map(), // model → { pct, first, phase, error, trouble, running }
164
+ queue: [], // what downloads after the one running: Ollama takes one at a time
107
165
  install: null, // Ollama's own install, while it runs: { lines, error, trouble, running }
108
- tried: null, // «try it»: { said, answer, error, busy }
109
166
  address: null, // the AI of another computer: { host, busy, error, ok }
110
- memoryChoice: null, // local · gemini · off
167
+ talk: null, // the talk with @madre
111
168
  agents: null, // /api/settings, as the agents panel last read it
112
169
  ready: 0, // agents connected
170
+ found: null, // the folders that look like projects, and the ones other tools know
171
+ picked: null, // the ones marked to bring
172
+ picker: false, // «another folder or a new one» open
113
173
  added: [], // the projects added while the welcome was open
114
174
  };
115
175
  let leave = null; // what the step on screen stops when another one comes
@@ -151,17 +211,22 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
151
211
  if (!best) return 'no';
152
212
  return fit().accelerated ? 'yes' : 'slow';
153
213
  };
154
- // The model offered first: the one MADRE recommends here, or the one the person stepped down to.
214
+ // The model offered first: the one MADRE recommends here, or the one the person chose instead.
155
215
  const offered = () => s.model ?? fit()?.recommended?.run ?? null;
216
+ const fitting = () => (fit()?.models ?? []).filter((model) => model.run !== 'no');
156
217
  const smaller = () => {
157
- const rungs = (fit()?.models ?? []).filter((model) => model.run !== 'no');
218
+ const rungs = fitting();
158
219
  const now = offered();
159
220
  const at = rungs.findIndex((model) => model.id === now?.id);
160
221
  return at > 0 ? rungs[at - 1] : null;
161
222
  };
162
223
  const roomFor = (gb) => (s.env?.disk?.freeGb == null ? true : s.env.disk.freeGb >= gb + 2);
224
+ const aiReady = () => Boolean(s.ollama?.running && chatModels().length > 0);
225
+ const pulling = () => [...s.pulls.entries()].find(([, pull]) => pull.running) ?? null;
226
+ const profileOf = () => [...s.profile][0] ?? null;
227
+ const who = () => (s.env?.os === 'macos' ? t('Your Mac') : t('Your computer'));
163
228
 
164
- // ---- The rail: the seven steps, where the person is, what is done and what was left for later.
229
+ // ---- The rail: the steps, where the person is, what is done and what was left for later.
165
230
  // The logo draws itself in once, when the welcome opens, and stays in the rail from then on: the
166
231
  // steps are repainted under it, never the logo, or its drawing started over with every step.
167
232
  const brand = el('div', 'wl-brand');
@@ -185,12 +250,16 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
185
250
  item.append(key);
186
251
  list.append(item);
187
252
  });
188
- railBody.replaceChildren(list, el('p', 'wl-rail-foot', t('Anything you leave for later can be done afterwards in Settings.')));
253
+ railBody.replaceChildren(list, el('p', 'wl-rail-foot', t('It takes about three minutes. What takes long to download keeps downloading while you go on.')));
189
254
  }
190
255
 
191
256
  // ---- The parts every step is made of.
192
- const head = (title, lead) => {
193
- const nodes = [el('p', 'wl-eyebrow', s.step ? t('Step {n} of {total}', { n: s.step + 1, total: WELCOME_STEPS.length }) : t('Welcome')), el('h2', 'wl-title', title)];
257
+ // The picture first, then the question and what it means. `caption` says what is happening now.
258
+ const head = (title, lead, picture = null, caption = null) => {
259
+ const nodes = [];
260
+ if (picture) { scene.show(picture.id, picture.data); nodes.push(scene.node); }
261
+ if (caption !== null) scene.say(caption);
262
+ nodes.push(el('h2', 'wl-title', title));
194
263
  if (lead) nodes.push(el('p', 'wl-lead', lead));
195
264
  return nodes;
196
265
  };
@@ -199,6 +268,12 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
199
268
  box.append(...children.filter(Boolean).map((child) => (typeof child === 'string' ? el('p', null, child) : child)));
200
269
  return box;
201
270
  };
271
+ // A word MADRE uses, explained where it first appears, folded: «what is this?».
272
+ const what = (question, answer) => {
273
+ const box = el('details', 'wl-what');
274
+ box.append(el('summary', null, question), el('p', null, answer));
275
+ return box;
276
+ };
202
277
  // «See how to fix it», under what went wrong: the card of Diagnostics for it, for this system.
203
278
  const fix = (id) => (id ? remedyKey(id, { platform: platformOf(s.env) }) : null);
204
279
  const chip = (tone, words) => { const node = el('span', `wl-chip${tone ? ` ${tone}` : ''}`); node.append(el('i'), el('span', null, words)); return node; };
@@ -243,46 +318,18 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
243
318
  actions.replaceChildren(...parts);
244
319
  return primary;
245
320
  };
321
+ const ago = (iso) => {
322
+ if (!iso) return null;
323
+ const days = Math.round((Date.parse(iso) - Date.now()) / 86400000);
324
+ const say = new Intl.RelativeTimeFormat(language(), { numeric: 'auto' });
325
+ if (days > -1) return say.format(0, 'day');
326
+ if (days > -14) return say.format(days, 'day');
327
+ if (days > -60) return say.format(Math.round(days / 7), 'week');
328
+ return say.format(Math.round(days / 30), 'month');
329
+ };
330
+ const homeWord = (path) => String(path ?? '').replace(/^\/(Users|home)\/[^/]+/, '~');
246
331
 
247
- // ---- 1 · HELLO: the language, what gets ready and how long it takes.
248
- function hello() {
249
- const seg = el('div', 'wl-seg');
250
- seg.setAttribute('role', 'radiogroup');
251
- seg.setAttribute('aria-label', 'Idioma · Language');
252
- for (const [code, words] of [['es', 'Español'], ['en', 'English']]) {
253
- const option = button(null, words, async () => {
254
- if (code === language()) return;
255
- await host.setLanguage?.(code);
256
- dialog.setAttribute('aria-label', t('Welcome to MADRE'));
257
- paintRail();
258
- show();
259
- });
260
- option.setAttribute('role', 'radio');
261
- option.setAttribute('aria-checked', String(code === language()));
262
- seg.append(option);
263
- }
264
- const lang = el('div', 'wl-row');
265
- lang.append(el('span', 'wl-muted', t('Language')), seg);
266
- const list = el('div', 'wl-card wl-checks');
267
- for (const [title, sub] of [
268
- [t('Your agents'), t('The AIs that work in your projects (Claude, Codex, Gemini…). We install and connect them here.')],
269
- [t('AI on your computer'), t('If your computer can carry it, a free and private AI that works without internet.')],
270
- [t('Memory'), t('So MADRE finds what it remembers even when you ask in other words.')],
271
- [t('Your first project'), t('A folder you work in. It is ready when we finish.')],
272
- ]) {
273
- const row = el('div', 'wl-check');
274
- const tick = el('span', 'wl-tick');
275
- tick.innerHTML = TICK; // trusted: our own SVG string
276
- const words = el('div');
277
- words.append(el('b', null, title), el('small', null, sub));
278
- row.append(tick, words);
279
- list.append(row);
280
- }
281
- content.replaceChildren(...head(t('Hi. Let\'s get MADRE ready.'), t('It takes about 10 minutes, plus the download if you choose an AI on your computer. You will not need the terminal.')), lang, list);
282
- footer({ next: t('Start'), back: false });
283
- }
284
-
285
- // ---- 2 · YOUR COMPUTER: what MADRE found, in plain words, and what it means for the next steps.
332
+ // ---- 1 · HELLO: the language, what MADRE is, and the computer read while the person reads.
286
333
  function placeWords() {
287
334
  const env = s.env ?? {};
288
335
  if (env.place === 'ssh') return t('You\'re connected from another computer (SSH)');
@@ -297,7 +344,8 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
297
344
  if (hw.accelerator === 'nvidia') return `${hw.gpus?.[0]?.name ?? 'NVIDIA'} · ${number(hw.acceleratorGb)} GB`;
298
345
  return t('None the AI can use');
299
346
  }
300
- function machine() {
347
+ // What the computer is, folded: the person can look, nothing to decide.
348
+ function machineFacts() {
301
349
  const env = s.env ?? {};
302
350
  const hw = facts();
303
351
  const grid = el('div', 'wl-facts');
@@ -308,11 +356,14 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
308
356
  fact(t('Memory'), hw.memoryGb ? `${number(hw.memoryGb)} GB` : null);
309
357
  fact(t('Graphics card'), graphicsWords());
310
358
  fact(t('Free space'), env.disk ? t('{n} GB free', { n: number(env.disk.freeGb) }) : null);
359
+ const fold = el('details', 'wl-more');
360
+ fold.append(el('summary', null, t('See what we found on your computer')), grid, el('p', 'wl-tiny', t('This never leaves your computer. We only use it to know which AI fits.')));
361
+ return fold;
362
+ }
363
+ // What only some places need to know, said in the greeting so nothing surprises later.
364
+ function placeNotes() {
365
+ const env = s.env ?? {};
311
366
  const notes = [];
312
- const carry = canCarry();
313
- if (carry === 'yes') notes.push(note('ok', t('Your computer can run its own AI. We recommend a model in step 4.')));
314
- else if (carry === 'slow') notes.push(note('warn', t('Your computer can run a small AI, but slowly: it has no graphics card the AI can use.')));
315
- else notes.push(note('warn', t('This computer does not have enough memory for an AI of its own. MADRE works just the same with your agents.')));
316
367
  if (env.place === 'wsl') notes.push(note('', t('MADRE runs here on Linux, inside Windows (WSL). Your Windows browser opens it directly.')));
317
368
  // On Windows itself (docs/WINDOWS.md, D-001): from 1.1.0 MADRE runs inside WSL2, not on Windows directly.
318
369
  if (env.os === 'windows') notes.push(note('warn', t('On Windows, MADRE runs inside WSL2, the Linux that comes with Windows 10 and 11. It does not run on Windows directly.'), fix('windows-use-wsl')));
@@ -320,20 +371,95 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
320
371
  if (env.vm && env.vm !== 'macOS') notes.push(note('warn', t('MADRE runs in a virtual machine: an AI here runs slower than on the computer itself. If that computer runs Windows, MADRE works better in WSL.')));
321
372
  if (env.place === 'ssh') notes.push(note('', t('You\'re connected from another computer. Some agents connect with a code instead of opening a page; each one says so.'), fix('ssh-tunnel')));
322
373
  if (env.place === 'container') notes.push(note('', t('MADRE runs inside a container: what it installs stays in that container.')));
323
- if (env.disk && env.disk.freeGb < 10) notes.push(note('warn', t('Only {n} GB free. Agents fit, but an AI of its own needs more room: free some up before step 4.', { n: number(env.disk.freeGb) })));
324
- content.replaceChildren(...head(t('Here is what we found'), t('We use it to recommend what works best on your computer. It never leaves your computer.')), grid, ...notes);
325
- footer();
374
+ if (env.disk && env.disk.freeGb < 10) notes.push(note('warn', t('Only {n} GB free. Your AIs fit, but an AI of its own needs more room: free some up before you get to it.', { n: number(env.disk.freeGb) })));
375
+ return notes;
376
+ }
377
+ function helloCaption() {
378
+ if (!s.scanned) return t('Seeing how powerful your computer is…');
379
+ const gb = number(facts().memoryGb ?? 0);
380
+ const carry = canCarry();
381
+ if (carry === 'yes') return t('{who} has {gb} GB of memory: an AI of its own fits without trouble.', { who: who(), gb });
382
+ if (carry === 'slow') return t('{who} has {gb} GB and no graphics card: a small AI fits, though it will answer slowly.', { who: who(), gb });
383
+ return t('{who} has {gb} GB: not enough for an AI of its own. Your AIs do the work just the same.', { who: who(), gb });
384
+ }
385
+ function hello() {
386
+ const seg = el('div', 'wl-seg');
387
+ seg.setAttribute('role', 'radiogroup');
388
+ seg.setAttribute('aria-label', 'Idioma · Language');
389
+ for (const [code, words] of [['es', 'Español'], ['en', 'English']]) {
390
+ const option = button(null, words, async () => {
391
+ if (code === language()) return;
392
+ await host.setLanguage?.(code);
393
+ dialog.setAttribute('aria-label', t('Welcome to MADRE'));
394
+ paintRail();
395
+ show();
396
+ });
397
+ option.setAttribute('role', 'radio');
398
+ option.setAttribute('aria-checked', String(code === language()));
399
+ seg.append(option);
400
+ }
401
+ const picture = { id: 'hello', data: () => ({ scanned: s.scanned }) };
402
+ const greeting = el('div', 'wl-hello');
403
+ greeting.append(...head(t('Hello'), t('MADRE puts AIs to work in your folders. You ask for things the way you would ask someone on your team, and MADRE remembers what gets decided.'), picture, helloCaption()), seg);
404
+ content.replaceChildren(greeting, machineFacts(), ...placeNotes());
405
+ footer({ next: t('Start'), back: false });
406
+ // The computer was read when the welcome opened: the picture takes a moment to say so, as a
407
+ // person would look before answering.
408
+ if (!s.scanned) {
409
+ const timer = setTimeout(() => { s.scanned = true; if (stepId() === 'hello') scene.say(helloCaption()); }, 2400);
410
+ leave = () => clearTimeout(timer);
411
+ }
326
412
  }
327
413
 
328
- // ---- 3 · YOUR AGENTS: Home's own panel, with what each one needs said first.
414
+ // ---- 2 · WHAT YOU WANT IT FOR: one or several; the examples from here on follow it.
415
+ function use() {
416
+ const picture = { id: 'use', data: () => ({ items: PROFILES.map((one) => ({ id: one.id, on: s.profile.has(one.id) })) }) };
417
+ const parts = head(t('What do you want it for?'), t('Mark whatever looks like yours. That way the examples we show you are ones that help you, not a programmer\'s.'), picture, s.profile.size ? t('This picks the examples you will see.') : t('Mark one or several.'));
418
+ const grid = el('div', 'wl-tiles');
419
+ for (const one of PROFILES) {
420
+ const tile = button('wl-tile', null, () => {
421
+ if (s.profile.has(one.id)) s.profile.delete(one.id); else s.profile.add(one.id);
422
+ tile.setAttribute('aria-pressed', String(s.profile.has(one.id)));
423
+ scene.say(s.profile.size ? t('This picks the examples you will see.') : t('Mark one or several.'));
424
+ paintUseKeys();
425
+ });
426
+ tile.setAttribute('aria-pressed', String(s.profile.has(one.id)));
427
+ tile.append(el('b', null, one.title()), el('small', null, one.sub()));
428
+ grid.append(tile);
429
+ }
430
+ parts.push(grid);
431
+ parts.push(what(t('Do I need to know how to program?'), t('No. Websites and apps are made of code, which is written instructions. You say «put a WhatsApp button on my page» and the AI writes the code. Before anything is kept, MADRE shows you what changed.')));
432
+ content.replaceChildren(...parts);
433
+ paintUseKeys();
434
+ }
435
+ function paintUseKeys() {
436
+ footer({
437
+ next: s.profile.size ? t('Continue') : t('Continue without marking'),
438
+ onNext: async () => {
439
+ await save({ profile: [...s.profile] });
440
+ go(s.step + 1, s.profile.size ? 'done' : 'skip');
441
+ },
442
+ });
443
+ }
444
+
445
+ // ---- 3 · YOUR AIs: «do you already pay for one?», in the names people know them by. Home's own
446
+ // panel connects them; the ones already signed in on this computer come connected.
329
447
  function explainAgent(agent, state) {
330
448
  const env = s.env ?? {};
331
- if (agent.id === 'gemini' && !state.ok) return el('p', 'wl-agent-why', t('Gemini no longer works with personal Google accounts: it needs an access key (API key) from Google AI Studio. You pay for what you use, usually very little. «Where do I get one?» opens the page that gives it.'));
332
- if (agent.id === 'cursor' && !agent.detected) return el('p', 'wl-agent-why', t('Cursor installs with its own installer. For your safety MADRE does not run installers downloaded from the internet: copy the line below into a terminal (the window where you type commands), once, then press «I did it». Or skip it: it is optional.'));
333
- if (env.place === 'ssh' && agent.detected && !state.ok && (agent.login?.methods ?? []).some((method) => method.id === 'device')) return el('p', 'wl-agent-why', t('You\'re connected from another computer: choose «With a code», and type the code on the page from any device.'));
334
- if (env.place === 'ssh' && agent.detected && !state.ok) return el('p', 'wl-agent-why', t('You\'re connected from another computer: open the page it gives you on your own computer, and paste back here the code it shows.'));
335
- return null;
449
+ const lines = [];
450
+ if (!state.ok && PLANS[agent.id]) lines.push(el('p', 'wl-agent-plan', PLANS[agent.id]()));
451
+ if (agent.id === 'gemini' && !state.ok) lines.push(el('p', 'wl-agent-why', t('Sign in with your Google account (Workspace / business) or paste a Gemini API key from Google AI Studio, free or paid (recommended for personal accounts).')));
452
+ else if (agent.id === 'cursor' && !agent.detected) lines.push(el('p', 'wl-agent-why', t('Cursor installs with its own installer. For your safety MADRE does not run installers downloaded from the internet: copy the line below into a terminal (the window where you type commands), once, then press «I did it». Or skip it: it is optional.')));
453
+ else if (env.place === 'ssh' && agent.detected && !state.ok && (agent.login?.methods ?? []).some((method) => method.id === 'device')) lines.push(el('p', 'wl-agent-why', t('You\'re connected from another computer: choose «With a code», and type the code on the page from any device.')));
454
+ else if (env.place === 'ssh' && agent.detected && !state.ok) lines.push(el('p', 'wl-agent-why', t('You\'re connected from another computer: open the page it gives you on your own computer, and paste back here the code it shows.')));
455
+ if (!lines.length) return null;
456
+ if (lines.length === 1) return lines[0];
457
+ const box = el('div', 'wl-agent-notes');
458
+ box.append(...lines);
459
+ return box;
336
460
  }
461
+ const agentItems = () => (s.agents?.agents ?? []).filter((agent) => agent.id !== 'madre').map((agent) => ({ id: agent.id, on: Boolean(host.agentState?.(agent, s.agents)?.ok) }));
462
+ const agentsCaption = () => (s.ready ? (s.ready === 1 ? t('One connected. One is enough to start.') : t('{n} connected. Each one works in all your projects.', { n: s.ready })) : t('Each AI you connect joins the centre.'));
337
463
  function agents() {
338
464
  const panel = host.agentsPanel?.({
339
465
  compact: true,
@@ -341,15 +467,18 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
341
467
  onPaint: (ready, answer) => {
342
468
  s.ready = ready;
343
469
  s.agents = answer;
470
+ scene.say(agentsCaption());
344
471
  paintAgentKeys();
345
472
  },
346
473
  });
347
- content.replaceChildren(...head(t('Connect your agents'), t('Agents are the AIs that read and write in your projects. Each one is connected once, and every project uses it. One is enough to start.')));
474
+ const picture = { id: 'agents', data: () => ({ items: agentItems() }) };
475
+ content.replaceChildren(...head(t('Do you already pay for an AI?'), t('If you already pay for ChatGPT, Claude or Grok, you use it here with the same account. Nothing more to pay.'), picture, agentsCaption()));
348
476
  if (panel) {
349
477
  content.append(panel.node);
350
478
  void panel.paint().then(() => panel.live());
351
479
  leave = () => panel.stop();
352
480
  }
481
+ content.append(what(t('What does an AI do in here?'), t('The same as in the chat you already know, but with your files at hand: it reads them, sorts them and writes what you ask. It never touches anything without the permission you gave it. If a command has to run, which is a written order for the computer, the AI runs it: you never open the terminal.')));
353
482
  footer({ nextOff: !s.ready, skip: { note: t('Without agents, MADRE cannot work for you.') } });
354
483
  paintAgentKeys();
355
484
  }
@@ -360,78 +489,238 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
360
489
  for (const node of actions.querySelectorAll('.wl-skipnote, [data-skip]')) node.hidden = Boolean(s.ready);
361
490
  }
362
491
 
363
- // ---- 4 · AI ON YOUR COMPUTER: install Ollama, download the model, try it — or use another
364
- // computer's, or leave it for later.
492
+ // ---- 4 · YOUR PROJECTS: what the person already has, brought along like a phone's backup.
493
+ async function loadFound() {
494
+ const answer = await getJson('/api/salas/suggestions');
495
+ s.found = answer?.suggestions ?? [];
496
+ s.finding = false;
497
+ // The newest folders another tool knows come marked; with none, nothing is marked for them.
498
+ if (!s.picked) s.picked = new Set(s.found.filter((one) => one.from?.length).slice(0, MARKED).map((one) => one.path));
499
+ if (stepId() === 'project') project();
500
+ }
501
+ const projectCaption = () => {
502
+ const n = s.picked?.size ?? 0;
503
+ return n ? t('{n} on their way. They stay where they are; MADRE only learns where to find them.', { n }) : t('Mark the folders you want to bring.');
504
+ };
505
+ function project() {
506
+ const had = host.projects?.() ?? [];
507
+ if (!s.found && !s.finding) { s.finding = true; void loadFound(); }
508
+ const found = s.found ?? [];
509
+ const looking = !s.found;
510
+ const known = found.some((one) => one.from?.length);
511
+ const picture = { id: 'project', data: () => ({ count: s.picked?.size ?? 0 }) };
512
+ const lead = looking ? t('Looking for your folders…') : !found.length ? t('Choose a folder you work in, or make a new one.')
513
+ : known ? t('You already opened these folders with other tools. We marked the ones you used most recently; untick the ones you do not want.')
514
+ : t('These folders look like projects. Mark the ones you want to bring.');
515
+ const parts = head(t('Bring what you already have'), lead, picture, projectCaption());
516
+ parts.push(what(t('What is a project?'), t('Each folder you bring is a project: your shop, this year\'s invoices, your website. Each one keeps its own conversations and what has been decided, without mixing with the others. Bringing it does not move it or change anything in it.')));
517
+ if (had.length) parts.push(note('ok', had.length === 1 ? t('You already have a project in Home: {name}. Add another one, or continue.', { name: had[0].name }) : t('You already have {n} projects in Home. Add another one, or continue.', { n: had.length })));
518
+ if (s.env?.place === 'wsl') parts.push(note('warn', t('Keep your projects inside Linux (your folder in /home). A Windows folder (/mnt/c/…) makes MADRE slower and protects your files less.'), fix('wsl-windows-folder')));
519
+ if (found.length) {
520
+ const list = el('div', 'wl-found');
521
+ for (const one of found) {
522
+ const on = s.picked?.has(one.path);
523
+ const row = button('wl-found-row', null, () => {
524
+ if (s.picked.has(one.path)) s.picked.delete(one.path); else s.picked.add(one.path);
525
+ row.setAttribute('aria-checked', String(s.picked.has(one.path)));
526
+ scene.say(projectCaption());
527
+ paintProjectKeys();
528
+ });
529
+ row.setAttribute('role', 'checkbox');
530
+ row.setAttribute('aria-checked', String(Boolean(on)));
531
+ const box = el('span', 'wl-box');
532
+ box.innerHTML = TICK; // trusted: our own SVG string
533
+ const words = el('span', 'wl-found-words');
534
+ words.append(el('b', null, one.name), el('small', null, [homeWord(one.path), ago(one.when)].filter(Boolean).join(' · ')));
535
+ const from = el('span', 'wl-from');
536
+ if (one.from?.length) for (const tool of one.from) from.append(el('span', null, t('You opened it with {tool}', { tool: TOOL_NAMES[tool] ?? tool })));
537
+ else from.append(el('span', null, t('Looks like a project')));
538
+ row.append(box, words, from);
539
+ list.append(row);
540
+ }
541
+ parts.push(list);
542
+ }
543
+ // Other ways in: any folder or a new one (Home's own picker), or a project made to practise in.
544
+ const others = el('div', 'wl-otherways');
545
+ const browse = button('wl-tile', null, () => { s.picker = !s.picker; project(); });
546
+ browse.setAttribute('aria-pressed', String(s.picker));
547
+ browse.append(el('b', null, t('Another folder, or a new one')), el('small', null, t('Look on your computer, or make an empty folder with a name.')));
548
+ // No project at hand (2026-11-01): one made to try MADRE, a page with a list of tasks and a README
549
+ // with what to ask. «I do not know what I would do with MADRE» is answered by having something.
550
+ const sample = button('wl-tile', null, async () => {
551
+ sample.disabled = true;
552
+ const answer = await post('/api/salas/new', { sample: true, language: language() });
553
+ if (!answer.ok) { sampleSaid.textContent = answer.body?.error ?? t('The project to try MADRE could not be made.'); sample.disabled = false; return; }
554
+ s.added = [...s.added, ...(answer.body.added ?? [])];
555
+ await host.refresh?.();
556
+ if (stepId() === 'project') go(s.step + 1, 'done');
557
+ });
558
+ const sampleSaid = el('small', null, t('A page with a list of tasks, to ask your AIs for changes without fear of breaking anything.'));
559
+ sample.append(el('b', null, t('A practice one')), sampleSaid);
560
+ others.append(browse, sample);
561
+ parts.push(el('p', 'wl-section', found.length ? t('Would you rather start another way?') : t('Or start another way')), others);
562
+ if (s.picker) {
563
+ const picker = host.projectPicker?.({
564
+ // A project made new here does not drop the folders already chosen (QA 1.1.0, NUE-08): they
565
+ // are added too, and the found ones stay marked.
566
+ onAdded: (added) => {
567
+ s.added = [...s.added, ...(added ?? [])];
568
+ s.picker = false;
569
+ s.found = null;
570
+ if (stepId() === 'project') project();
571
+ },
572
+ });
573
+ if (picker) parts.push(picker.node);
574
+ }
575
+ if (s.added.length) parts.push(note('ok', s.added.length === 1 ? t('{name} was added to Home.', { name: s.added[0].name }) : t('{n} projects were added to Home.', { n: s.added.length })));
576
+ content.replaceChildren(...parts);
577
+ paintProjectKeys();
578
+ }
579
+ function paintProjectKeys() {
580
+ const n = s.picked?.size ?? 0;
581
+ const had = (host.projects?.() ?? []).length + s.added.length;
582
+ footer({
583
+ next: n ? (n === 1 ? t('Bring 1 project') : t('Bring {n} projects', { n })) : t('Continue'),
584
+ nextOff: !n && !had,
585
+ onNext: async () => {
586
+ if (n) {
587
+ const answer = await post('/api/salas/projects', { roots: [...s.picked] });
588
+ if (!answer.ok) { content.append(note('bad', answer.body?.refused?.[0]?.error ?? answer.body?.error ?? t('They could not be added.'))); return; }
589
+ s.added = [...s.added, ...(answer.body.added ?? [])];
590
+ s.picked.clear();
591
+ s.found = null;
592
+ await host.refresh?.();
593
+ }
594
+ go(s.step + 1, 'done');
595
+ },
596
+ skip: n || had ? null : { note: t('You can add it from Home.') },
597
+ });
598
+ }
599
+
600
+ // ---- 5 · AI ON YOUR COMPUTER: what it is, who uses it (the Coordinator), and one press that
601
+ // brings Ollama, the model and the memory's model, downloading while the person goes on. Or another
602
+ // computer's, or later. Once it is there, a first talk with it.
603
+ function aiPicture() {
604
+ const pull = pulling();
605
+ const model = offered();
606
+ if (aiReady() && !pull) return { state: 'ready', model: s.ollama?.chatModel ?? chatModels()[0]?.name ?? model?.label ?? '', detail: localHost(s.ollama?.host) ? t('No internet') : t('On the other computer') };
607
+ if (pull) return { state: 'downloading', pct: pull[1].pct ?? 0, model: pull[0] === EMBED_MODEL ? t('Its memory') : (model?.label ?? pull[0]), detail: `${Math.round(pull[1].pct ?? 0)} %` };
608
+ return { state: s.choice === 'skip' ? 'skip' : 'idle', model: model?.label ?? '', detail: '' };
609
+ }
610
+ function aiCaption() {
611
+ const pull = pulling();
612
+ if (pull) return pull[0] === EMBED_MODEL ? t('Downloading its memory. You can go on: it does not stop.') : t('Downloading {model}. You can go on: it does not stop.', { model: offered()?.label ?? pull[0] });
613
+ if (aiReady()) return t('It lives here now. Say hello below.');
614
+ if (s.choice === 'skip') return t('You can turn it on whenever you want.');
615
+ return t('Choose, and it downloads while you go on.');
616
+ }
365
617
  function aiChoices() {
366
618
  const env = s.env ?? {};
367
619
  const carry = canCarry();
368
- const model = offered();
369
620
  const pick = (value) => {
370
621
  s.choice = value;
371
622
  // Back to this computer's Ollama after pointing at another one.
372
- if (value === 'here' && s.ollama?.host && !localHost(s.ollama.host)) void post('/api/local-ai/host', { host: null }).then(() => readOllama({ probe: true })).then(() => paintAi());
623
+ if ((value === 'here' || value === 'other') && s.ollama?.host && !localHost(s.ollama.host)) void post('/api/local-ai/host', { host: null }).then(() => readOllama({ probe: true })).then(() => paintAi());
373
624
  paintAi();
374
625
  };
375
626
  const options = [];
376
- if (model) {
627
+ const recommended = fit()?.recommended?.run ?? null;
628
+ if (recommended) {
377
629
  const sub = carry === 'yes'
378
- ? t('The one that fits your computer best. A {size} GB download.', { size: number(model.sizeGb ?? 0) })
379
- : t('The one that fits your computer. A {size} GB download; it will answer slowly.', { size: number(model.sizeGb ?? 0) });
380
- options.push(choice('ai', 'here', s.choice, t('Install it here · {model}', { model: model.label }), sub, pick, { badge: carry === 'yes' ? t('Recommended') : null }));
630
+ ? t('Ollama, the program that runs it; the AI ({size} GB) and its memory ({mb} MB). One press, and it keeps downloading while you go on.', { size: number(recommended.sizeGb ?? 0), mb: EMBED_MB })
631
+ : t('The lightest one, {size} GB, with its memory. It will answer slowly: your computer has no graphics card the AI can use.', { size: number(recommended.sizeGb ?? 0) });
632
+ options.push(choice('ai', 'here', s.choice, s.env?.os === 'macos' ? t('The one that fits your Mac · {model}', { model: recommended.label }) : t('The one that fits your computer · {model}', { model: recommended.label }), sub, (value) => { s.model = null; pick(value); }, { badge: carry === 'yes' ? t('We recommend it') : null }));
381
633
  }
634
+ if (fitting().length > 1) options.push(choice('ai', 'other', s.choice, t('Choose another one'), t('Only the ones that fit in your {gb} GB without slowing your computer down.', { gb: number(facts().memoryGb ?? 0) }), pick));
382
635
  if (env.place === 'wsl') options.push(choice('ai', 'windows', s.choice, t('Use the Ollama on Windows'), t('If Ollama is already installed on Windows, MADRE connects to it.'), pick));
383
636
  if (env.vm || env.place === 'wsl' || env.place === 'ssh' || carry !== 'yes') options.push(choice('ai', 'remote', s.choice, t('Use another computer\'s AI'), t('A computer on your network with Ollama and a graphics card.'), pick));
384
637
  options.push(choice('ai', 'skip', s.choice, t('Not now'), t('MADRE works just the same with your agents. You can turn it on later in Settings › Local AI.'), pick));
385
638
  return choices(t('AI on your computer'), ...options);
386
639
  }
640
+ // The other models this computer carries: the same ladder, each with what it weighs.
641
+ function otherModels() {
642
+ const grid = el('div', 'wl-models');
643
+ const best = fit()?.recommended?.run?.id;
644
+ for (const model of fitting()) {
645
+ const key = button('wl-model', null, () => { s.model = model; paintAi(); });
646
+ key.setAttribute('aria-pressed', String(offered()?.id === model.id));
647
+ key.append(el('b', null, model.label), el('small', null, t('{size} GB to download', { size: number(model.sizeGb ?? 0) })), el('span', 'wl-model-fit', model.id === best ? t('The one we recommend') : model.run === 'slow' ? t('Fits, answering slowly') : t('Fits without slowing it down')));
648
+ grid.append(key);
649
+ }
650
+ return grid;
651
+ }
387
652
  let aiBody = null;
388
653
  function ai() {
389
654
  const carry = canCarry();
390
- const intro = carry === 'yes' ? note('ok', t('Your computer can run its own AI: free, private and offline. It powers @madre, the archivist and the search in your memory.'))
391
- : carry === 'slow' ? note('warn', t('Your computer can, but it will be slow ({gb} GB, no graphics card the AI can use). We recommend a small model.', { gb: number(facts().memoryGb ?? 0) }))
392
- : note('warn', t('This computer does not have enough memory for an AI of its own: here it would be too slow. MADRE works just the same with your agents.'));
655
+ const lead = carry === 'no'
656
+ ? t('This computer does not have enough memory for an AI of its own: here it would be too slow. MADRE works just the same with your agents.')
657
+ : carry === 'slow'
658
+ ? t('It needs no internet, costs nothing, and what you write to it does not leave here. Your computer can carry a small one; with no graphics card it will answer slowly, so we suggest the lightest.')
659
+ : t('It needs no internet, costs nothing, and what you write to it does not leave here. It is smaller than ChatGPT or Claude, but it is plenty to sum up, sort and remember what you decide.');
393
660
  // Chosen before: what is already there says which way this goes.
394
661
  if (!s.choice && s.ollama?.running && chatModels().length) s.choice = localHost(s.ollama.host) ? 'here' : (s.env?.place === 'wsl' ? 'windows' : 'remote');
662
+ const coordinator = el('div', 'wl-coordinator');
663
+ const words = el('div');
664
+ words.append(
665
+ el('b', null, t('Your Coordinator works with it')),
666
+ el('p', null, t('In Home you have a Coordinator: the one that sees all your projects together. You ask it «what was left pending this week?» and it goes through all of them before answering.')),
667
+ el('p', null, t('The AI on your computer helps it sum up and search each project\'s memory without sending anything outside your computer: even if you ask in other words, it finds what you decided.')),
668
+ );
669
+ coordinator.append(host.mark?.('bishop', 34) ?? el('span'), words);
395
670
  aiBody = el('div', 'wl-ai');
396
- content.replaceChildren(...head(t('AI on your computer'), t('Ollama is the app that runs AI on your computer. A bigger model is smarter and heavier; we suggest the one that fits yours best.')), intro, aiBody);
671
+ content.replaceChildren(...head(t('An AI that lives on your computer'), lead, { id: 'ai', data: aiPicture }, aiCaption()), coordinator, aiBody);
397
672
  paintAi();
398
673
  // While Ollama is not there yet, MADRE looks every few seconds: «I did it» is a courtesy.
399
674
  clearInterval(pollTimer);
400
675
  pollTimer = setInterval(() => {
401
- if (document.hidden || !['here', 'windows', 'remote'].includes(s.choice) || s.ollama?.running) return;
402
- if (s.choice !== 'here') return;
676
+ if (document.hidden || !['here', 'other'].includes(s.choice) || s.ollama?.running) return;
403
677
  void readOllama({ probe: true }).then(() => { if (stepId() === 'ai') paintAi(); });
404
678
  }, 5000);
405
679
  leave = () => { clearInterval(pollTimer); pollTimer = 0; };
406
680
  }
407
681
  function paintAi() {
408
682
  if (!aiBody?.isConnected) return;
683
+ scene.say(aiCaption());
684
+ scene.redraw();
409
685
  const blocks = [aiChoices()];
410
- if (s.choice === 'here') blocks.push(installFlow());
686
+ if (s.choice === 'other') blocks.push(otherModels());
687
+ if (s.choice === 'here' || s.choice === 'other') blocks.push(installFlow());
411
688
  if (s.choice === 'windows' || s.choice === 'remote') blocks.push(addressFlow());
689
+ // Once its model is there, a first talk with it, wherever it runs.
690
+ if (s.choice !== 'skip' && aiReady()) blocks.push(talkFlow());
412
691
  aiBody.replaceChildren(...blocks);
413
- const ready = s.ollama?.running && chatModels().length > 0;
692
+ // With the AI there, its memory comes on its own: nothing to press.
693
+ if ((s.choice === 'here' || s.choice === 'other') && aiReady() && !hasModel(EMBED_MODEL) && !s.pulls.has(EMBED_MODEL) && !pulling()) void startPull(EMBED_MODEL);
694
+ const going = Boolean(pulling()) || s.queue.length > 0;
414
695
  // «Not now» is one of the choices: no second key to leave it for later.
415
696
  footer({
416
- nextOff: s.choice === null || (s.choice !== 'skip' && !ready),
697
+ next: going ? t('Continue while it downloads') : t('Continue'),
698
+ nextOff: s.choice === null || (s.choice !== 'skip' && !aiReady() && !going),
417
699
  onNext: async () => {
418
700
  if (s.choice === 'skip') { go(s.step + 1, 'skip'); return; }
419
- await enableLocal();
701
+ if (s.ollama?.running) await enableLocal();
420
702
  go(s.step + 1, 'done');
421
703
  },
422
704
  });
423
705
  }
424
- // On for every project, and every open project told (Home › Settings › Local AI does the same).
706
+ // On for every project, and every open project told (Home › Settings › Local AI does the same). The
707
+ // memory searches by meaning on this computer as soon as its model is there.
425
708
  async function enableLocal() {
426
709
  await post('/api/ollama/settings', { enabled: true, embeddings: true });
427
710
  await post('/api/salas/local-ai', {});
711
+ if (hasModel(EMBED_MODEL)) await useLocalMemory();
712
+ }
713
+ async function useLocalMemory() {
714
+ if (s.memory?.embedProvider === 'ollama') return;
715
+ const answer = await post('/api/settings', { memory: { embedProvider: 'ollama' } });
716
+ if (answer.ok) s.memory = { ...(s.memory ?? {}), embedProvider: 'ollama' };
428
717
  }
429
718
  function installFlow() {
430
719
  const env = s.env ?? {};
431
720
  const box = el('div', 'wl-card wl-flow');
432
721
  const info = s.ollama ?? {};
433
722
  // 1 · Ollama itself.
434
- box.append(el('b', 'wl-flow-title', t('1 · Install Ollama')));
723
+ box.append(el('b', 'wl-flow-title', t('1 · Ollama, the program that runs it')));
435
724
  if (info.running) box.append(chip('ok', info.version ? t('Installed and open · {version}', { version: info.version }) : t('Installed and open')));
436
725
  else if (info.binary) {
437
726
  box.append(el('p', 'wl-muted', env.os === 'macos' ? t('Ollama is installed but not open. MADRE opens it; if it does not answer, open the Ollama app yourself.') : t('Ollama is installed but not running. MADRE starts it.')));
@@ -477,7 +766,7 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
477
766
  box.append(row);
478
767
  }
479
768
  if (s.install?.error && !info.running) box.append(note('bad', s.install.trouble && TROUBLE[s.install.trouble] ? TROUBLE[s.install.trouble]() : s.install.error, fix(s.install.card ?? (s.install.trouble === 'permission' ? 'ollama' : TROUBLE_CARD[s.install.trouble]) ?? 'ollama')));
480
- // 2 · The model, and 3 · trying it, once Ollama answers.
769
+ // 2 · The model and its memory, once Ollama answers.
481
770
  if (info.running) box.append(...modelFlow());
482
771
  return box;
483
772
  }
@@ -493,52 +782,73 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
493
782
  });
494
783
  return key;
495
784
  };
496
- // The model, downloaded with its real share, and a first word with it.
785
+ // The model and the memory's model, downloaded one after the other with their real share.
497
786
  function modelFlow() {
498
787
  const parts = [];
499
788
  const have = chatModels();
500
789
  const model = offered();
501
- const using = have[0]?.name ?? null;
502
- if (have.length && (!model || !s.pulls.get(model.ollama)?.running)) {
503
- parts.push(el('b', 'wl-flow-title', t('2 · The model')));
504
- parts.push(chip('ok', t('Ready · {model}', { model: s.ollama?.chatModel ?? using })));
505
- parts.push(...tryFlow());
790
+ const memory = memoryLine();
791
+ // Another model chosen and not there yet is downloaded; otherwise the one there is used.
792
+ const wantsOther = s.choice === 'other' && s.model && !hasModel(s.model.ollama);
793
+ if (have.length && !wantsOther && (!model || !s.pulls.get(model.ollama)?.running)) {
794
+ parts.push(el('b', 'wl-flow-title', t('2 · The AI and its memory')));
795
+ parts.push(chip('ok', t('Ready · {model}', { model: s.ollama?.chatModel ?? have[0].name })));
796
+ if (memory) parts.push(...memory);
506
797
  return parts;
507
798
  }
508
799
  if (!model) {
509
- parts.push(el('b', 'wl-flow-title', t('2 · The model')), el('p', 'wl-muted', t('This computer cannot carry a model. Use another computer\'s AI, or leave it for later.')));
800
+ parts.push(el('b', 'wl-flow-title', t('2 · The AI and its memory')), el('p', 'wl-muted', t('This computer cannot carry a model. Use another computer\'s AI, or leave it for later.')));
510
801
  return parts;
511
802
  }
512
- parts.push(el('b', 'wl-flow-title', t('2 · Download {model}', { model: model.label })));
803
+ parts.push(el('b', 'wl-flow-title', t('2 · Download {model} and its memory', { model: model.label })));
513
804
  const pull = s.pulls.get(model.ollama);
514
805
  if (pull?.running) {
515
806
  const pct = pull.pct ?? 0;
516
807
  const got = ((model.sizeGb ?? 0) * pct) / 100;
517
808
  const line = el('div', 'wl-row wl-pull-line');
518
809
  line.append(el('small', 'wl-tiny', pull.phase === 'verify' ? t('Checking the download…') : t('{pct} % · {got} of {size} GB', { pct: Math.round(pct), got: number(got), size: number(model.sizeGb ?? 0) })), el('span', 'wl-grow'), cancelKey(model.ollama, pull));
519
- parts.push(bar(pct), line);
810
+ parts.push(bar(pct), line, el('small', 'wl-tiny', t('Then its memory, {mb} MB. You can go on to the next step meanwhile.', { mb: EMBED_MB })));
520
811
  return parts;
521
812
  }
522
813
  if (pull?.cancelled) parts.push(note('', t('You cancelled the download. What already arrived stays in Ollama: download it again and it picks up from there.')));
523
814
  if (pull?.error) {
524
- parts.push(note('bad', pull.trouble && TROUBLE[pull.trouble] ? TROUBLE[pull.trouble]() : t('The download stopped: {error}', { error: pull.error }), fix(pull.trouble === 'disk' ? 'disk-full' : 'model-download')));
815
+ parts.push(note('bad', pull.trouble && TROUBLE[pull.trouble] ? TROUBLE[pull.trouble]() : t('The download stopped: {error}', { error: pull.error }), fix(pull.trouble === 'disk' ? 'disk-full' : pull.trouble === 'dns' ? 'name-lookup' : pull.trouble === 'network' ? 'install-offline' : 'model-download')));
525
816
  }
526
817
  if (!roomFor(model.sizeGb ?? 0)) parts.push(note('warn', t('There are {free} GB free and this model needs {size} GB plus some room. Free up space or choose a smaller model.', { free: number(s.env.disk.freeGb), size: number(model.sizeGb ?? 0) }), fix('disk-full')));
527
818
  const row = el('div', 'wl-row');
528
- const get = button('wl-btn primary small', pull?.error ? t('Try again') : pull?.cancelled ? t('Continue the download') : t('Download · {size} GB', { size: number(model.sizeGb ?? 0) }), () => void startPull(model.ollama));
819
+ const get = button('wl-btn primary small', pull?.error ? t('Try again') : pull?.cancelled ? t('Continue the download') : t('Download · {size} GB', { size: number((model.sizeGb ?? 0) + EMBED_MB / 1000) }), () => void getAll(model.ollama));
529
820
  get.disabled = !roomFor(model.sizeGb ?? 0) && !pull?.error;
530
821
  row.append(get);
531
822
  const down = smaller();
532
- if (down) row.append(button('wl-btn ghost small', t('Choose a smaller one · {model}', { model: down.label }), () => { s.model = down; paintAi(); }));
823
+ if (down && s.choice !== 'other') row.append(button('wl-btn ghost small', t('Choose a smaller one · {model}', { model: down.label }), () => { s.model = down; paintAi(); }));
533
824
  parts.push(row, el('small', 'wl-tiny', t('It downloads once and stays in Ollama.')));
534
825
  return parts;
535
826
  }
827
+ // The memory's own line: its model downloading after the AI, or there.
828
+ function memoryLine() {
829
+ if (hasModel(EMBED_MODEL)) return [chip('ok', t('Memory model ready · {model}', { model: EMBED_MODEL }))];
830
+ const pull = s.pulls.get(EMBED_MODEL);
831
+ if (pull?.running) {
832
+ const line = el('div', 'wl-row wl-pull-line');
833
+ line.append(el('small', 'wl-tiny', t('Its memory · {pct} % · {mb} MB', { pct: Math.round(pull.pct ?? 0), mb: EMBED_MB })), el('span', 'wl-grow'), cancelKey(EMBED_MODEL, pull));
834
+ return [bar(pull.pct ?? 0), line];
835
+ }
836
+ if (pull?.error) return [note('bad', pull.trouble && TROUBLE[pull.trouble] ? TROUBLE[pull.trouble]() : t('The download stopped: {error}', { error: pull.error }), fix(pull.trouble === 'disk' ? 'disk-full' : pull.trouble === 'dns' ? 'name-lookup' : pull.trouble === 'network' ? 'install-offline' : 'model-download')), button('wl-btn small', t('Try again'), () => void startPull(EMBED_MODEL))];
837
+ if (pull?.cancelled) return [button('wl-btn small', t('Continue the download'), () => void startPull(EMBED_MODEL))];
838
+ return [button('wl-btn small', t('Download the memory model · {mb} MB', { mb: EMBED_MB }), () => void startPull(EMBED_MODEL))];
839
+ }
840
+ // One press: the AI, then its memory. Ollama takes one download at a time, so the second waits.
841
+ function getAll(model) {
842
+ s.queue = hasModel(EMBED_MODEL) || s.pulls.get(EMBED_MODEL)?.running ? [] : [EMBED_MODEL];
843
+ return startPull(model);
844
+ }
536
845
  // Stopping a download halfway: the server stops asking Ollama for it (/api/ollama/pull/cancel).
537
846
  const cancelKey = (model, pull) => {
538
847
  const key = button('wl-btn ghost small', pull.cancelling ? t('Cancelling…') : t('Cancel'), async () => {
539
848
  pull.cancelling = true;
540
849
  key.disabled = true;
541
850
  key.textContent = t('Cancelling…');
851
+ s.queue = [];
542
852
  const answer = await post('/api/ollama/pull/cancel', { model });
543
853
  if (!answer.ok) { pull.cancelling = false; key.disabled = false; key.textContent = t('Cancel'); }
544
854
  });
@@ -552,24 +862,28 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
552
862
  if (!answer.ok) s.pulls.set(model, { error: answer.body?.error ?? t('Home did not answer.') });
553
863
  repaint();
554
864
  }
555
- // «Try it» (2026-10-28): a talk with @madre, not a form. It greets first as soon as its model is
556
- // there, answers as it writes (the server streams what Ollama says), and keeps the turns before, so
557
- // the person can go on. Built once per step and kept: the download's events repaint the step, and a
558
- // talk being written must not be rebuilt under the person.
559
- const GREETING = () => t('Introduce yourself in one short, warm sentence: you are @madre, the AI on this computer, and you are ready to help.');
560
- const SUGGESTIONS = () => [t('What can you do for me?'), t('Explain what MADRE is in one line'), t('Tell me something fun in one line')];
561
- function tryFlow() {
562
- s.talk ??= { messages: [], busy: false, error: null, node: null, greeted: false };
865
+ // «Say hello» (2026-10-28, again in 1.1): a talk with @madre, not a form. It greets first as soon
866
+ // as its model is there, answers as it writes (the server streams what Ollama says), and keeps the
867
+ // turns before, so the person can go on. Under each answer, how long it took and where it ran. Its
868
+ // suggestions follow what MADRE is for to this person, and leave once used. Built once and kept:
869
+ // the downloads repaint the step, and a talk being written must not be rebuilt under the person.
870
+ const GREETING = () => t('Introduce yourself in one or two short, warm sentences, as a person would: you are @madre, you live on this computer, and what is written to you stays here, even without internet. Ask how you can help.');
871
+ const offline = () => localHost(s.ollama?.host);
872
+ function talkFlow() {
873
+ s.talk ??= { messages: [], busy: false, error: null, node: null, greeted: false, asked: new Set() };
563
874
  if (!s.talk.node) s.talk.node = talkNode();
564
875
  if (!s.talk.greeted) { s.talk.greeted = true; void say(GREETING(), { hidden: true }); }
565
- return [el('b', 'wl-flow-title', t('3 · Talk to it')), s.talk.node];
876
+ return s.talk.node;
566
877
  }
567
878
  function talkNode() {
568
879
  const box = el('div', 'wl-talk-card');
880
+ const top = el('div', 'wl-talk-head');
881
+ const words = el('div');
882
+ words.append(el('b', null, '@madre'), el('small', null, t('In any project you call it by writing @madre.')));
883
+ top.append(host.mark?.('madre', 28) ?? el('span', 'wl-msg-face'), words, chip('ok', offline() ? t('No internet') : t('On the other computer')));
569
884
  const list = el('div', 'wl-talk');
570
885
  list.setAttribute('aria-live', 'polite');
571
886
  const chips = el('div', 'wl-chips');
572
- for (const words of SUGGESTIONS()) chips.append(button('wl-chip-key', words, () => void say(words)));
573
887
  const form = el('form', 'wl-try wl-talk-form');
574
888
  const input = el('input', 'wl-field');
575
889
  input.placeholder = t('Write to @madre…');
@@ -578,11 +892,18 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
578
892
  send.type = 'submit';
579
893
  form.append(input, send);
580
894
  form.addEventListener('submit', (event) => { event.preventDefault(); const words = input.value.trim(); if (!words) return; input.value = ''; void say(words); });
581
- const where = localHost(s.ollama?.host) ? t('It runs on this computer: nothing you write here leaves it.') : t('It runs on the other computer you chose, on your network.');
582
- box.append(list, chips, form, el('small', 'wl-tiny', where));
895
+ box.append(top, list, chips, form);
583
896
  box.refs = { list, chips, input, send };
897
+ paintChips(box.refs);
584
898
  return box;
585
899
  }
900
+ function paintChips({ chips }) {
901
+ const said = s.talk?.asked ?? new Set();
902
+ const own = SUGGESTIONS[profileOf()]?.() ?? SUGGESTIONS.curious();
903
+ chips.replaceChildren();
904
+ for (const words of [...own, t('What can you do without internet?')].filter((one) => !said.has(one))) chips.append(button('wl-chip-key', words, () => void say(words)));
905
+ chips.hidden = (s.talk?.messages ?? []).filter((one) => one.role === 'user').length > 3;
906
+ }
586
907
  async function say(words, { hidden = false } = {}) {
587
908
  const talk = s.talk;
588
909
  const { list, chips, input, send } = talk.node.refs;
@@ -591,17 +912,18 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
591
912
  talk.error = null;
592
913
  send.disabled = true;
593
914
  chips.hidden = true;
915
+ if (!hidden) talk.asked.add(words);
594
916
  talk.node.querySelector('.wl-talk-error')?.remove();
595
917
  talk.messages.push({ role: 'user', content: words });
596
918
  if (!hidden) list.append(el('p', 'wl-bubble me', words));
597
- // @madre's turn: its mark, three dots while it thinks, then its words as they come.
919
+ // @madre's turn: three dots while it thinks, then its words as they come, then how it went.
598
920
  const row = el('div', 'wl-msg');
599
- const face = host.mark?.('madre', 26) ?? el('span', 'wl-msg-face');
600
921
  const bubble = el('p', 'wl-bubble wl-typing');
601
922
  bubble.append(el('i'), el('i'), el('i'));
602
- row.append(face, bubble);
923
+ row.append(bubble);
603
924
  list.append(row);
604
925
  list.scrollTop = list.scrollHeight;
926
+ const started = performance.now();
605
927
  let text = '';
606
928
  try {
607
929
  const response = await fetch('/api/local-ai/try', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ messages: talk.messages }) });
@@ -616,6 +938,8 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
616
938
  }
617
939
  if (!text.trim()) throw new Error(t('The local AI did not answer.'));
618
940
  talk.messages.push({ role: 'assistant', content: text.trim() });
941
+ const seconds = number(Math.max(0.1, (performance.now() - started) / 1000));
942
+ row.append(el('small', 'wl-msg-meta', offline() ? t('Answered in {s} s · on your computer · no internet', { s: seconds }) : t('Answered in {s} s · on the other computer', { s: seconds })));
619
943
  } catch (error) {
620
944
  row.remove();
621
945
  talk.messages.pop();
@@ -627,11 +951,11 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
627
951
  bubble.classList.remove('wl-writing');
628
952
  talk.busy = false;
629
953
  send.disabled = false;
630
- chips.hidden = talk.messages.filter((one) => one.role === 'user').length > 2;
954
+ paintChips(talk.node.refs);
955
+ list.scrollTop = list.scrollHeight;
631
956
  if (!hidden && document.activeElement === document.body) input.focus({ preventScroll: true });
632
957
  }
633
958
  }
634
- // The AI of another computer, or of Windows from inside WSL: its address, tried before it is kept.
635
959
  function addressFlow() {
636
960
  const env = s.env ?? {};
637
961
  const box = el('div', 'wl-card wl-flow');
@@ -669,100 +993,10 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
669
993
  return box;
670
994
  }
671
995
 
672
- // ---- 5 · MEMORY: search by meaning on this computer, with Gemini, or exact words.
673
- let memoryBody = null;
674
- function memoryStep() {
675
- memoryBody = el('div', 'wl-memory');
676
- content.replaceChildren(...head(t('Memory'), t('MADRE remembers what you decide in each project. With search by meaning it finds it even when you ask in other words.')), memoryBody);
677
- paintMemory();
678
- // A Gemini key pasted in step 3 counts here: asked again, not the one read when the welcome opened.
679
- void getJson('/api/environment').then((environment) => {
680
- if (!environment) return;
681
- const had = s.geminiKey;
682
- s.geminiKey = Boolean(environment.geminiKey);
683
- s.memory = environment.memory ?? s.memory;
684
- if (had !== s.geminiKey) paintMemory();
685
- });
686
- // With the AI of step 4 there, its memory model comes on its own: nothing to press — unless
687
- // another download is still running (step 4's model): Ollama takes one at a time.
688
- const busy = [...s.pulls.values()].some((one) => one.running);
689
- if (s.memoryChoice === 'local' && !hasModel(EMBED_MODEL) && !s.pulls.has(EMBED_MODEL) && !busy) void startPull(EMBED_MODEL);
690
- }
691
- function paintMemory() {
692
- if (!memoryBody?.isConnected) return;
693
- const local = Boolean(s.ollama?.running);
694
- const said = s.memory?.embedProvider;
695
- s.memoryChoice ??= said === 'ollama' && local ? 'local' : said === 'gemini' ? 'gemini' : said === 'off' ? 'off' : local ? 'local' : s.geminiKey ? 'gemini' : 'off';
696
- if (s.memoryChoice === 'local' && !local) s.memoryChoice = s.geminiKey ? 'gemini' : 'off';
697
- const pick = (value) => { s.memoryChoice = value; if (value === 'local' && !hasModel(EMBED_MODEL) && !s.pulls.get(EMBED_MODEL)?.running) void startPull(EMBED_MODEL); paintMemory(); };
698
- const embedReady = hasModel(EMBED_MODEL);
699
- const group = choices(t('Memory'),
700
- choice('memory', 'local', s.memoryChoice, s.ollama?.host && !localHost(s.ollama.host) ? t('With your Ollama') : t('On your computer'), local ? (embedReady ? (s.ollama?.host && !localHost(s.ollama.host) ? t('With the Ollama of the other computer, on your network. Its memory model is already there. Free and private.') : t('With Ollama. Its memory model is already here. Free and private.')) : t('With Ollama. Downloads a memory model of {mb} MB. Free and private.', { mb: EMBED_MB })) : t('Needs the AI on your computer (step 4).'), pick, { badge: local ? t('Recommended') : null, disabled: !local }),
701
- choice('memory', 'gemini', s.memoryChoice, t('With Gemini'), s.geminiKey ? t('Uses your Gemini key, already on this computer. Paid per use, very little. What it searches is sent to Google.') : t('Needs your Gemini key: paste it in step 3, in Gemini.'), pick, { badge: !local && s.geminiKey ? t('Recommended') : null }),
702
- choice('memory', 'off', s.memoryChoice, t('Exact words only'), t('Nothing extra. It finds what you ask for with the same words.'), pick),
703
- );
704
- const parts = [group];
705
- if (s.memoryChoice === 'local') {
706
- const pull = s.pulls.get(EMBED_MODEL);
707
- if (embedReady) parts.push(chip('ok', t('Memory model ready · {model}', { model: EMBED_MODEL })));
708
- else if (pull?.running) {
709
- const line = el('div', 'wl-row wl-pull-line');
710
- line.append(el('small', 'wl-tiny', t('{pct} % · {mb} MB', { pct: Math.round(pull.pct ?? 0), mb: EMBED_MB })), el('span', 'wl-grow'), cancelKey(EMBED_MODEL, pull));
711
- parts.push(bar(pull.pct ?? 0), line);
712
- } else if (pull?.cancelled) parts.push(note('', t('You cancelled the download. What already arrived stays in Ollama: download it again and it picks up from there.')), button('wl-btn primary small', t('Continue the download'), () => void startPull(EMBED_MODEL)));
713
- else if (pull?.error) parts.push(note('bad', pull.trouble && TROUBLE[pull.trouble] ? TROUBLE[pull.trouble]() : t('The download stopped: {error}', { error: pull.error }), fix(pull.trouble === 'disk' ? 'disk-full' : 'model-download')), button('wl-btn small', t('Try again'), () => void startPull(EMBED_MODEL)));
714
- else parts.push(button('wl-btn primary small', t('Download the memory model · {mb} MB', { mb: EMBED_MB }), () => void startPull(EMBED_MODEL)));
715
- }
716
- if (s.memoryChoice === 'gemini' && !s.geminiKey) parts.push(button('wl-btn small', t('Go to step 3'), () => go('agents')));
717
- memoryBody.replaceChildren(...parts);
718
- const blocked = (s.memoryChoice === 'local' && !embedReady) || (s.memoryChoice === 'gemini' && !s.geminiKey);
719
- footer({
720
- nextOff: blocked,
721
- onNext: async () => {
722
- const provider = { local: 'ollama', gemini: 'gemini', off: 'off' }[s.memoryChoice];
723
- const answer = await post('/api/settings', { memory: { embedProvider: provider } });
724
- if (answer.ok) s.memory = { ...(s.memory ?? {}), embedProvider: provider };
725
- go(s.step + 1, s.memoryChoice === 'off' ? 'skip' : 'done');
726
- },
727
- });
728
- }
729
-
730
- // ---- 6 · YOUR PROJECT: a new one or a folder that already is one.
731
- function project() {
732
- const had = host.projects?.() ?? [];
733
- const lead = t('A project is a folder you work in: a store, a website, your documents. Each one has its own conversations and its own memory.');
734
- const parts = [...head(t('Your first project'), lead)];
735
- if (had.length) parts.push(note('ok', had.length === 1 ? t('You already have a project in Home: {name}. Add another one, or continue.', { name: had[0].name }) : t('You already have {n} projects in Home. Add another one, or continue.', { n: had.length })));
736
- if (s.env?.place === 'wsl') parts.push(note('warn', t('Keep your projects inside Linux (your folder in /home). A Windows folder (/mnt/c/…) makes MADRE slower and protects your files less.'), fix('wsl-windows-folder')));
737
- let picker = null;
738
- const primary = () => actions.querySelector('[data-next]');
739
- picker = host.projectPicker?.({
740
- withAdd: false,
741
- onChange: (n) => { const key = primary(); if (key) { key.textContent = n ? t('Add and continue') : t('Continue'); key.disabled = !n && !(host.projects?.() ?? []).length; } },
742
- // A project made new here does not drop the folders already chosen (QA 1.1.0, NUE-08): they
743
- // are added too, and only then the step is done.
744
- onAdded: (added) => {
745
- s.added = [...s.added, ...(added ?? [])];
746
- if (stepId() !== 'project') return;
747
- if (picker?.count()) { void picker.add(); return; }
748
- go(s.step + 1, 'done');
749
- },
750
- });
751
- if (picker) parts.push(picker.node);
752
- content.replaceChildren(...parts);
753
- footer({
754
- nextOff: !had.length,
755
- onNext: async () => {
756
- if (picker?.count()) { await picker.add(); return; }
757
- go(s.step + 1, 'done');
758
- },
759
- skip: had.length ? null : { note: t('You can add it from Home.') },
760
- });
761
- }
762
-
763
- // ---- 7 · READY: what is set, what was left for later with its key, and what comes next.
996
+ // ---- 6 · YOUR FIRST MESSAGE: what is ready, said in one line each, and a project opened with a
997
+ // first message already written for this person. Anything left for later has its key.
764
998
  async function ready() {
765
- content.replaceChildren(...head(t('MADRE is ready'), t('Here is what is ready. Anything you left for later has its button.')), el('p', 'wl-muted', t('Reading…')));
999
+ content.replaceChildren(...head(t('Where do we start?'), null, { id: 'ready', data: () => ({ text: '' }) }, t('Reading…')));
766
1000
  actions.replaceChildren();
767
1001
  const settings = s.agents ?? await getJson('/api/settings');
768
1002
  await readOllama();
@@ -771,13 +1005,16 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
771
1005
  const rooms = host.projects?.() ?? [];
772
1006
  const added = s.added.map((one) => rooms.find((room) => room.root === one.root || room.name === one.name)).filter(Boolean);
773
1007
  const room = added[0] ?? rooms[0] ?? null;
774
- const aiOn = s.ollama?.running && chatModels().length > 0;
775
- const provider = s.memory?.embedProvider;
1008
+ const sample = s.added.some((one) => one.sample && (room?.root === one.root || room?.name === one.name));
1009
+ const ideas = (IDEAS[sample ? 'curious' : profileOf() ?? 'none'] ?? IDEAS.none)();
1010
+ const pull = pulling();
1011
+ const aiWords = aiReady() && !pull
1012
+ ? (s.talk?.messages?.length > 1 ? t('Ready, and you have already met') : `${s.ollama.chatModel ?? chatModels()[0].name}${localHost(s.ollama.host) ? '' : ` · ${t('on another computer')}`}`)
1013
+ : pull ? t('Still downloading; we will tell you when it arrives') : t('Whenever you want, in Settings');
776
1014
  const rows = [
777
- [t('Agents'), connected.length ? new Intl.ListFormat(language(), { type: 'conjunction' }).format(connected) : t('None connected yet'), connected.length > 0, 'agents'],
778
- [t('AI on your computer'), aiOn ? `${s.ollama.chatModel ?? chatModels()[0].name}${localHost(s.ollama.host) ? '' : ` · ${t('on another computer')}`}` : t('For later'), aiOn, 'ai'],
779
- [t('Memory'), provider === 'ollama' ? (s.ollama?.host && !localHost(s.ollama.host) ? t('Search by meaning, on the other computer') : t('Search by meaning, on your computer')) : provider === 'gemini' ? t('Search by meaning, with Gemini') : t('Exact words'), provider === 'ollama' || provider === 'gemini', 'memory'],
780
- [t('Project'), room ? room.name : t('None yet'), Boolean(room), 'project'],
1015
+ [t('Your AIs'), connected.length ? new Intl.ListFormat(language(), { type: 'conjunction' }).format(connected) : t('None connected yet'), connected.length > 0, 'agents'],
1016
+ [t('Your projects'), s.added.length ? (s.added.length === 1 ? t('You brought {name}', { name: s.added[0].name }) : t('You brought {n}', { n: s.added.length })) : room ? room.name : t('None yet'), Boolean(room), 'project'],
1017
+ [t('AI on your computer'), aiWords, aiReady() || Boolean(pull), 'ai'],
781
1018
  ];
782
1019
  const summary = el('div', 'wl-card wl-checks');
783
1020
  for (const [title, sub, ok, id] of rows) {
@@ -791,32 +1028,51 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
791
1028
  if (!ok) row.append(button('wl-btn small', t('Do it now'), () => go(id)));
792
1029
  summary.append(row);
793
1030
  }
794
- const nextCards = el('div', 'wl-split');
795
- const card = (title, sub, onClick) => { const node = button('wl-card wl-next', null, onClick); node.append(el('b', null, title), el('small', null, sub)); return node; };
796
- nextCards.append(
797
- card(t('Connect your projects'), t('So one can look up what another knows.'), () => { finish(); host.openLinks?.(); }),
798
- card(t('Module Market'), t('Images, reminders, GitHub and more.'), () => { finish(); host.openMarket?.(); }),
799
- );
800
- // Training (B-7): ready here, switched on in a project's Settings.
801
- const fitNow = fit();
802
- const train = fitNow?.recommended?.train ?? null;
803
- const trainCard = el('div', 'wl-card wl-train');
804
- trainCard.append(el('b', null, t('Train your own AI')));
805
- if (train) {
806
- trainCard.append(el('p', 'wl-muted', t('Your computer can train its own AI with what your project knows, up to {model}. Everything is ready: you turn it on in your project\'s Settings › Memory › Train your own AI.', { model: train.label })));
807
- const reqs = el('ul', 'wl-reqs');
808
- reqs.append(el('li', null, facts().accelerator === 'apple' ? t('Apple chip with 12 GB of memory or more') : t('NVIDIA card with 9 GB or more and CUDA 12 (experimental)')));
809
- reqs.append(el('li', null, t('About {gb} GB free while it trains', { gb: Math.ceil(train.params * 5.5) + 2 })));
810
- trainCard.append(reqs);
811
- // How it is done, step by step, in the manual (2026-10-28).
812
- trainCard.append(button('wl-btn ghost small', t('How it is trained'), () => window.open(`/manual?lang=${language()}#entrena`, '_blank', 'noopener')));
813
- } else {
814
- trainCard.append(el('p', 'wl-muted', t('This computer cannot train. It takes a Mac with an Apple chip and 12 GB of memory, or an NVIDIA card with 9 GB or more.')));
1031
+ const parts = [];
1032
+ const lead = room && connected.length
1033
+ ? t('We open {name}. Tap an idea and it stays written so you only send it, or write your own.', { name: room.name })
1034
+ : t('Here is what is ready. Anything you left for later has its button.');
1035
+ parts.push(...head(t('Where do we start?'), lead, { id: 'ready', data: () => ({ text: ideas[0] }) }, room && connected.length ? t('Your first message, almost written.') : t('Almost there.')), summary);
1036
+ // The AI arrived while the person was elsewhere: say so, and offer the hello.
1037
+ if (aiReady() && !pull && !(s.talk?.messages?.length > 1)) {
1038
+ const arrived = el('div', 'wl-arrived');
1039
+ arrived.append(el('span', null, t('The AI on your computer has arrived.')), button('wl-btn small', t('Say hello'), () => go('ai')));
1040
+ parts.push(arrived);
1041
+ }
1042
+ const learn = button('wl-btn ghost', t('Get to know MADRE'), () => { const after = then ?? host.chapters; finish(); after?.(); });
1043
+ // Into the project without a stop on Home (1.1): it starts waking as this step shows, and the
1044
+ // welcome stays on screen, saying it is opening, until the project's page takes over.
1045
+ const warm = room && connected.length ? (host.warmProject?.(room) ?? Promise.resolve(true)) : null;
1046
+ const enter = async (draft = null, key = null) => {
1047
+ for (const one of actions.querySelectorAll('button')) one.disabled = true;
1048
+ for (const one of content.querySelectorAll('.wl-idea')) one.disabled = true;
1049
+ if (key) key.textContent = t('Opening {name}…', { name: room.name });
1050
+ scene.say(t('Opening {name}…', { name: room.name }));
1051
+ finished = true;
1052
+ await save({ finished: true, done: 'ready', at: 'ready' });
1053
+ await warm?.catch(() => null);
1054
+ const answer = await host.openProject?.(room, { draft });
1055
+ // It did not open: Home says why, on the project's card.
1056
+ if (!answer?.ok) dialog.close();
1057
+ };
1058
+ // Into the project when there is one and an agent to answer (2026-11-01): 90 of 147 copies never
1059
+ // opened a project. Since 1.1 with the first message already written (`#escribe=`): the person only
1060
+ // sends it. Without a project or an agent, Home as before, whose first-time cards walk them there.
1061
+ if (room && connected.length) {
1062
+ parts.push(el('p', 'wl-section', t('Ideas for {name}', { name: room.name })));
1063
+ const list = el('div', 'wl-ideas');
1064
+ for (const idea of ideas) { const key = button('wl-idea', idea, () => void enter(idea, key)); list.append(key); }
1065
+ parts.push(list);
1066
+ content.replaceChildren(...parts);
1067
+ const home = button('wl-btn ghost', t('Go to Home'), () => finish());
1068
+ const opening = footer({
1069
+ next: t('Open {name}', { name: room.name }),
1070
+ onNext: () => enter(null, opening),
1071
+ extra: (() => { const keys = el('span', 'wl-keys'); keys.append(learn, home); return keys; })(),
1072
+ });
1073
+ return;
815
1074
  }
816
- content.replaceChildren(...head(t('MADRE is ready'), t('Here is what is ready. Anything you left for later has its button.')), summary, el('p', 'wl-eyebrow wl-gap', t('What comes next')), nextCards, trainCard);
817
- const learn = button('wl-btn', t('Get to know MADRE'), () => { const after = then ?? host.chapters; finish(); after?.(); });
818
- // Home first (2026-10-30): its first-time cards walk the person to their project; the project's
819
- // own cards come when they open it. Going straight into the project skipped Home's.
1075
+ content.replaceChildren(...parts);
820
1076
  footer({
821
1077
  next: t('Go to Home'),
822
1078
  onNext: () => finish(),
@@ -854,12 +1110,22 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
854
1110
  } else if (s.install?.running) {
855
1111
  s.install = event.payload.ok ? null : { error: event.payload.detail ?? t('It did not install.'), trouble: event.payload.trouble ?? null, manual: event.payload.trouble === 'permission' };
856
1112
  }
857
- void readOllama({ probe: true }).then(repaint);
1113
+ void readOllama({ probe: true }).then(async () => {
1114
+ // The next in line goes once the one before is done; the memory is switched on when it is there.
1115
+ if (pull && event.payload.ok && s.queue.length) void startPull(s.queue.shift());
1116
+ if (pull && !event.payload.ok) s.queue = [];
1117
+ if (hasModel(EMBED_MODEL) && s.choice !== 'skip' && s.ollama?.running) { await enableLocal(); }
1118
+ repaint();
1119
+ });
858
1120
  }
859
1121
  };
860
1122
  } catch { /* no stream: «I did it» and the probe keep it current */ }
861
1123
  }
862
- const repaint = () => { if (stepId() === 'ai') paintAi(); else if (stepId() === 'memory') paintMemory(); };
1124
+ const repaint = () => {
1125
+ if (stepId() === 'ai') paintAi();
1126
+ else if (stepId() === 'ready' && !pulling()) void ready();
1127
+ scene.redraw();
1128
+ };
863
1129
 
864
1130
  function show() {
865
1131
  leave?.();
@@ -868,10 +1134,9 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
868
1134
  content.scrollTop = 0;
869
1135
  const id = stepId();
870
1136
  if (id === 'hello') hello();
871
- else if (id === 'machine') machine();
1137
+ else if (id === 'use') use();
872
1138
  else if (id === 'agents') agents();
873
1139
  else if (id === 'ai') ai();
874
- else if (id === 'memory') memoryStep();
875
1140
  else if (id === 'project') project();
876
1141
  else void ready();
877
1142
  // The key just pressed left with the step it was on: the keyboard and a screen reader start
@@ -892,6 +1157,7 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
892
1157
  leave?.();
893
1158
  stream?.close();
894
1159
  clearInterval(pollTimer);
1160
+ scene.stop();
895
1161
  current = null;
896
1162
  dialog.remove();
897
1163
  host.closed?.();
@@ -905,13 +1171,16 @@ export function openWelcome({ at = null, then = null, host = {} } = {}) {
905
1171
  current = { go: (to) => { s.step = Math.max(0, WELCOME_STEPS.indexOf(to)); show(); }, close: () => dialog.close(), node: dialog };
906
1172
  void Promise.all([getJson('/api/tour'), getJson('/api/environment'), readOllama()]).then(([tour, environment]) => {
907
1173
  if (!current) return;
908
- s.progress = tour?.state?.welcome ?? s.progress;
1174
+ s.progress = { ...s.progress, ...(tour?.state?.welcome ?? {}) };
1175
+ s.profile = new Set(s.progress.profile ?? []);
909
1176
  s.env = environment?.environment ?? null;
910
1177
  s.hardware = environment?.hardware ?? null;
911
1178
  s.geminiKey = Boolean(environment?.geminiKey);
912
1179
  s.memory = environment?.memory ?? null;
913
1180
  const from = at ?? s.progress.at ?? 'hello';
914
1181
  s.step = Math.max(0, WELCOME_STEPS.indexOf(from));
1182
+ // Back to a later step, the computer was already read.
1183
+ if (s.step > 0) s.scanned = true;
915
1184
  listen();
916
1185
  show();
917
1186
  if (!s.progress.at) void save({ at: WELCOME_STEPS[s.step] });