@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.
- package/CHANGELOG.en.md +42 -1
- package/CHANGELOG.md +42 -1
- package/README.en.md +4 -4
- package/README.md +4 -4
- package/SECURITY.md +11 -6
- package/bin/madre.mjs +74 -11
- package/docs/REFERENCE.md +15 -8
- package/docs/SDK.md +8 -8
- package/docs/en/REFERENCE.md +12 -7
- package/docs/en/SDK.md +8 -8
- package/docs/en/training/README.md +1 -1
- package/docs/sdk/connector-module.mjs +1 -1
- package/docs/sdk/hello-module.mjs +1 -1
- package/docs/training/README.md +1 -1
- package/docs/training/train.sh +3 -0
- package/package.json +4 -2
- package/public/activity.js +9 -0
- package/public/app.js +990 -173
- package/public/attribution.js +9 -0
- package/public/brands.js +27 -13
- package/public/en.js +2 -3
- package/public/es.js +968 -258
- package/public/index.html +3 -0
- package/public/macroverso.js +24 -5
- package/public/manual-content.js +38 -8
- package/public/market-view.js +116 -9
- package/public/market.js +28 -2
- package/public/news-scenes.js +185 -0
- package/public/notices.js +66 -0
- package/public/power.js +1 -1
- package/public/resay.js +3 -0
- package/public/salas-mac.css +294 -22
- package/public/salas-mac.html +3 -0
- package/public/salas-mac.js +760 -38
- package/public/styles.css +393 -17
- package/public/tips.js +124 -0
- package/public/tour-chapters.js +75 -75
- package/public/tour.js +36 -8
- package/public/troubleshooting.js +215 -22
- package/public/welcome-scene.js +358 -0
- package/public/welcome.js +523 -254
- package/src/adapters/gemini-rest.mjs +236 -0
- package/src/adapters/gemini.mjs +9 -7
- package/src/adapters/grok.mjs +288 -0
- package/src/adapters/process.mjs +14 -3
- package/src/auth-probe.mjs +32 -0
- package/src/bridge/policy.mjs +1 -1
- package/src/capabilities.mjs +30 -0
- package/src/checkpoint.mjs +115 -1
- package/src/codex-route.mjs +113 -0
- package/src/credentials.mjs +46 -8
- package/src/dataset.mjs +21 -8
- package/src/embeddings.mjs +2 -2
- package/src/event-store.mjs +10 -2
- package/src/ficha.mjs +142 -0
- package/src/file-ops.mjs +9 -3
- package/src/files.mjs +36 -2
- package/src/github.mjs +5 -3
- package/src/lease.mjs +5 -0
- package/src/market-check.mjs +1 -1
- package/src/market-remote.mjs +170 -3
- package/src/mcp/image-server.mjs +1 -1
- package/src/mcp/memory-server.mjs +22 -3
- package/src/mcp/proxy.mjs +31 -8
- package/src/memory-tools.mjs +12 -2
- package/src/memory.mjs +44 -3
- package/src/models.mjs +21 -3
- package/src/modules/ahp.mjs +8 -3
- package/src/modules/bishop-exam.mjs +41 -12
- package/src/modules/bishop.mjs +2 -2
- package/src/modules/check-alone.mjs +25 -0
- package/src/modules/choices.mjs +12 -10
- package/src/modules/fetch-alone.mjs +7 -0
- package/src/modules/helpers.mjs +23 -5
- package/src/modules/image-studio.mjs +13 -27
- package/src/modules/index.mjs +88 -11
- package/src/modules/isolated.mjs +160 -0
- package/src/modules/ollama.mjs +35 -6
- package/src/modules/playwright.mjs +46 -17
- package/src/modules/run-alone.mjs +122 -0
- package/src/modules/runs.mjs +11 -8
- package/src/modules/sdk.mjs +4 -2
- package/src/mother.mjs +6 -1
- package/src/notices-key.mjs +8 -0
- package/src/notices.mjs +185 -0
- package/src/ollama.mjs +57 -15
- package/src/outbound.mjs +56 -11
- package/src/room/archivist.mjs +36 -5
- package/src/room/busy.mjs +16 -0
- package/src/room/context.mjs +6 -3
- package/src/room/control.mjs +36 -6
- package/src/room/copilot.mjs +22 -28
- package/src/room/guard.mjs +32 -2
- package/src/room/prompt.mjs +32 -5
- package/src/room/vectors.mjs +7 -1
- package/src/room.mjs +98 -32
- package/src/router.mjs +1 -1
- package/src/runs.mjs +39 -0
- package/src/runtime-detection.mjs +46 -6
- package/src/salas.mjs +253 -15
- package/src/server.mjs +686 -87
- package/src/service.mjs +116 -0
- package/src/setup-trouble.mjs +20 -1
- package/src/skill-check.mjs +269 -0
- package/src/skills-import.mjs +128 -0
- package/src/skills.mjs +492 -0
- package/src/tour.mjs +15 -4
- package/src/whats-new.mjs +71 -0
package/src/salas.mjs
CHANGED
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
|
|
13
13
|
import { spawn } from 'node:child_process';
|
|
14
14
|
import { createHash } from 'node:crypto';
|
|
15
|
-
import { closeSync,
|
|
16
|
-
import { mkdir, readdir, readFile, rename, stat } from 'node:fs/promises';
|
|
15
|
+
import { closeSync, realpathSync } from 'node:fs';
|
|
16
|
+
import { mkdir, open, readdir, readFile, rename, stat, writeFile } from 'node:fs/promises';
|
|
17
17
|
import * as nodePath from 'node:path';
|
|
18
18
|
import { basename, dirname, join, resolve } from 'node:path';
|
|
19
19
|
import { fileURLToPath } from 'node:url';
|
|
20
20
|
import { oneAtATime, writeWhole } from './json-file.mjs';
|
|
21
|
+
import { defaultStateRoot, fichaHeaders, openPrivateLog } from './ficha.mjs';
|
|
21
22
|
|
|
22
23
|
const MADRE_BIN = fileURLToPath(new URL('../bin/madre.mjs', import.meta.url));
|
|
23
24
|
|
|
@@ -89,11 +90,55 @@ export function projectRootFor({ command, named = true, project, cwd, home, stat
|
|
|
89
90
|
|
|
90
91
|
// Where the project is, kept beside its record (S-002): the room's id is a hash of the path and
|
|
91
92
|
// cannot be turned back into it, and a room that is closed has to be found to be opened again.
|
|
92
|
-
// Written whole or not at all.
|
|
93
|
-
export async function markProject(roomDir, projectRoot, { now = new Date() } = {}) {
|
|
93
|
+
// Written whole or not at all. With the port it opened on (L-6): what else the record holds stays.
|
|
94
|
+
export async function markProject(roomDir, projectRoot, { now = new Date(), port = null, keepOpen = null } = {}) {
|
|
94
95
|
await mkdir(roomDir, { recursive: true });
|
|
95
96
|
const file = join(roomDir, 'project.json');
|
|
96
|
-
await oneAtATime(file, () =>
|
|
97
|
+
await oneAtATime(file, async () => {
|
|
98
|
+
const was = await readJson(file);
|
|
99
|
+
await writeWhole(file, `${JSON.stringify({ ...(was ?? {}), root: projectRoot, name: basename(projectRoot), lastOpened: now.toISOString(), ...(Number.isInteger(port) ? { port } : {}), ...(typeof keepOpen === 'boolean' ? { keepOpen } : {}) })}\n`);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Whether a project comes back when MADRE starts as a service (L-3): set when it opens, taken away
|
|
104
|
+
// only when the person closes it. A restart of the computer or a fall of MADRE leaves it on.
|
|
105
|
+
export async function keepOpenProject(stateRoot, id, keepOpen) {
|
|
106
|
+
if (typeof id !== 'string' || !/^[^/\\]+$/.test(id) || id === '.' || id === '..') return false;
|
|
107
|
+
const file = join(stateRoot, 'rooms', id, 'project.json');
|
|
108
|
+
return oneAtATime(file, async () => {
|
|
109
|
+
const was = await readJson(file);
|
|
110
|
+
if (!was) return false;
|
|
111
|
+
await writeWhole(file, `${JSON.stringify({ ...was, keepOpen: Boolean(keepOpen) })}\n`);
|
|
112
|
+
return true;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Each project keeps its port (L-6, Carlos's server, 2026-11-04). A project opened from Home took
|
|
117
|
+
// the first free port from 4317, so its number depended on the order things were opened in and
|
|
118
|
+
// changed after a restart; on a server reached through a tunnel the new one fell outside the
|
|
119
|
+
// tunnel, and links between projects need the same number on both ends. What a project opened on
|
|
120
|
+
// is kept in its record; the next time it asks for that one first, and a project with none skips
|
|
121
|
+
// the ports other projects already keep.
|
|
122
|
+
export async function keptPorts(stateRoot, projectRoot) {
|
|
123
|
+
const mine = projectRoomId(projectRoot);
|
|
124
|
+
const dir = join(stateRoot, 'rooms');
|
|
125
|
+
const others = new Set();
|
|
126
|
+
let own = null;
|
|
127
|
+
for (const id of await readdir(dir).catch(() => [])) {
|
|
128
|
+
const port = (await readJson(join(dir, id, 'project.json')))?.port;
|
|
129
|
+
if (!Number.isInteger(port)) continue;
|
|
130
|
+
if (id === mine) own = port; else others.add(port);
|
|
131
|
+
}
|
|
132
|
+
return { mine: own, others };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// The port to try: its own when it has one and it is free, else the first free one from `base`
|
|
136
|
+
// that no other project keeps. `taken(port)` says whether something is listening there.
|
|
137
|
+
export async function choosePort({ base, mine = null, others = new Set(), taken }) {
|
|
138
|
+
if (Number.isInteger(mine) && !(await taken(mine))) return mine;
|
|
139
|
+
let port = base;
|
|
140
|
+
while (others.has(port) || await taken(port)) port += 1;
|
|
141
|
+
return port;
|
|
97
142
|
}
|
|
98
143
|
|
|
99
144
|
// ---- The lobby: adding projects (2026-10-10). A browser cannot hand MADRE the path of a folder,
|
|
@@ -155,12 +200,30 @@ export async function listFolders({ path = null, home, stateRoot }) {
|
|
|
155
200
|
}
|
|
156
201
|
|
|
157
202
|
// Folders that look like projects in the places people keep them, newest first, none already here.
|
|
158
|
-
|
|
203
|
+
// Since 1.1 (the welcome of 2026-11-08, docs/private/BIENVENIDA-1.1.md) also the folders the
|
|
204
|
+
// person already opened with another tool, each saying which: like moving to a new phone, what was
|
|
205
|
+
// there comes along. Only the folder paths those tools keep are read, never a conversation, a key or
|
|
206
|
+
// a setting (see foldersFromTools).
|
|
207
|
+
export async function suggestProjects({ home, stateRoot, limit = 24, tools = true, platform = process.platform }) {
|
|
159
208
|
const top = realFolder(home);
|
|
160
209
|
const known = await knownRoots(stateRoot);
|
|
161
210
|
const state = realFolder(stateRoot);
|
|
162
211
|
const seen = new Map();
|
|
163
212
|
const places = new Set(); // `Projects` and `projects` are one folder on a Mac: read it once
|
|
213
|
+
const keep = async (full, from = null) => {
|
|
214
|
+
const real = realFolder(full);
|
|
215
|
+
if (known.has(real) || inside(real, state)) return;
|
|
216
|
+
const had = seen.get(real);
|
|
217
|
+
if (had) { if (from && !had.from.includes(from)) had.from.push(from); return; }
|
|
218
|
+
const info = await stat(real).catch(() => null);
|
|
219
|
+
if (!info?.isDirectory()) return;
|
|
220
|
+
seen.set(real, { name: basename(real), path: real, when: info.mtimeMs ?? 0, from: from ? [from] : [] });
|
|
221
|
+
};
|
|
222
|
+
if (tools) for (const { path, from } of await foldersFromTools({ home: top, platform })) {
|
|
223
|
+
const real = realFolder(path);
|
|
224
|
+
if (!toolFolderFits(real, top)) continue;
|
|
225
|
+
await keep(real, from);
|
|
226
|
+
}
|
|
164
227
|
for (const place of PROJECT_HOMES) {
|
|
165
228
|
const base = join(top, place);
|
|
166
229
|
const info = await stat(base).catch(() => null);
|
|
@@ -170,12 +233,83 @@ export async function suggestProjects({ home, stateRoot, limit = 24 }) {
|
|
|
170
233
|
for (const entry of names) {
|
|
171
234
|
if (!entry.isDirectory() || entry.name.startsWith('.') || NOT_PROJECTS.has(entry.name)) continue;
|
|
172
235
|
const full = join(base, entry.name);
|
|
173
|
-
if (seen.has(
|
|
174
|
-
|
|
175
|
-
seen.set(full, { name: entry.name, path: full, when });
|
|
236
|
+
if (seen.has(realFolder(full)) || !(await looksLikeProject(full))) continue;
|
|
237
|
+
await keep(full);
|
|
176
238
|
}
|
|
177
239
|
}
|
|
178
|
-
|
|
240
|
+
// What another tool already knows comes first, then the rest; the newest first in each.
|
|
241
|
+
return [...seen.values()]
|
|
242
|
+
.sort((a, b) => Number(b.from.length > 0) - Number(a.from.length > 0) || b.when - a.when)
|
|
243
|
+
.slice(0, limit)
|
|
244
|
+
.map(({ name, path, when, from }) => ({ name, path, when: when ? new Date(when).toISOString() : null, from }));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// A folder another tool knows is offered only inside the home, never the home itself, a folder
|
|
248
|
+
// hidden anywhere on its way (a worktree under .claude/, a tool's own state) or one of the places
|
|
249
|
+
// that hold everything (Documents, Desktop…): those are where projects live, not projects.
|
|
250
|
+
const HOLDERS = new Set(['documents', 'documentos', 'desktop', 'escritorio', 'downloads', 'descargas', ...PROJECT_HOMES.filter(Boolean).map((one) => one.toLowerCase())]);
|
|
251
|
+
export function toolFolderFits(folder, home, path = nodePath) {
|
|
252
|
+
if (!insideFolder(folder, home, path) || sameFolder(folder, home, path)) return false;
|
|
253
|
+
const parts = path.relative(home, folder).split(path.sep);
|
|
254
|
+
if (parts.some((part) => part.startsWith('.') || NOT_PROJECTS.has(part))) return false;
|
|
255
|
+
return !(parts.length === 1 && HOLDERS.has(parts[0].toLowerCase()));
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// The folders other tools on this computer already worked in, by tool. Each one is read for paths
|
|
259
|
+
// and nothing else, and a tool that is not there, or writes its file differently, simply adds none:
|
|
260
|
+
// claude ~/.claude.json, the names of its `projects` (Claude Code keeps one entry per folder)
|
|
261
|
+
// codex ~/.codex/sessions, the `cwd` on the first line of the newest sessions
|
|
262
|
+
// gemini ~/.gemini/projects.json, the names of its `projects`
|
|
263
|
+
// cursor Cursor's storage.json, the folders of its recent windows
|
|
264
|
+
// vscode the same file of Visual Studio Code
|
|
265
|
+
// In WSL, Cursor and VS Code keep theirs on the Windows side: only Linux's own are read.
|
|
266
|
+
export const TOOL_NAMES = { claude: 'Claude Code', codex: 'Codex', gemini: 'Gemini', cursor: 'Cursor', vscode: 'VS Code' };
|
|
267
|
+
const CODEX_SESSIONS_READ = 300;
|
|
268
|
+
export async function foldersFromTools({ home, platform = process.platform }) {
|
|
269
|
+
const found = [];
|
|
270
|
+
const add = (path, from) => { if (typeof path === 'string' && nodePath.isAbsolute(path)) found.push({ path, from }); };
|
|
271
|
+
const claude = await readJson(join(home, '.claude.json'));
|
|
272
|
+
for (const path of Object.keys(claude?.projects ?? {})) add(path, 'claude');
|
|
273
|
+
const gemini = await readJson(join(home, '.gemini', 'projects.json'));
|
|
274
|
+
for (const path of Object.keys(gemini?.projects ?? {})) add(path, 'gemini');
|
|
275
|
+
for (const path of await codexFolders(join(home, '.codex', 'sessions'))) add(path, 'codex');
|
|
276
|
+
const appData = platform === 'darwin' ? join(home, 'Library', 'Application Support') : join(home, '.config');
|
|
277
|
+
for (const [from, app] of [['cursor', 'Cursor'], ['vscode', 'Code']]) {
|
|
278
|
+
const storage = await readJson(join(appData, app, 'User', 'globalStorage', 'storage.json'));
|
|
279
|
+
const uris = [...Object.keys(storage?.profileAssociations?.workspaces ?? {}), ...(storage?.backupWorkspaces?.folders ?? []).map((one) => one?.folderUri)];
|
|
280
|
+
for (const uri of uris) { if (typeof uri === 'string' && uri.startsWith('file://')) { try { add(fileURLToPath(uri), from); } catch { /* not a local folder */ } } }
|
|
281
|
+
}
|
|
282
|
+
return found;
|
|
283
|
+
}
|
|
284
|
+
// Codex writes one file per session under year/month/day; the newest are read, and of each only its
|
|
285
|
+
// first line, the one that says where the session ran.
|
|
286
|
+
async function codexFolders(root) {
|
|
287
|
+
const files = [];
|
|
288
|
+
const walk = async (dir, depth) => {
|
|
289
|
+
const entries = await readdir(dir, { withFileTypes: true }).catch(() => []);
|
|
290
|
+
for (const entry of entries.sort((a, b) => b.name.localeCompare(a.name))) {
|
|
291
|
+
if (files.length >= CODEX_SESSIONS_READ) return;
|
|
292
|
+
const full = join(dir, entry.name);
|
|
293
|
+
if (entry.isDirectory() && depth < 3) await walk(full, depth + 1);
|
|
294
|
+
else if (entry.isFile() && entry.name.endsWith('.jsonl')) files.push(full);
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
await walk(root, 0);
|
|
298
|
+
const folders = new Set();
|
|
299
|
+
for (const file of files) {
|
|
300
|
+
// The first line may be longer than what is read: then the `cwd` is taken from the text itself.
|
|
301
|
+
const said = /"cwd":"((?:[^"\\]|\\.)*)"/.exec(await firstLine(file));
|
|
302
|
+
try { const cwd = said ? JSON.parse(`"${said[1]}"`) : null; if (cwd) folders.add(cwd); } catch { /* not a session */ }
|
|
303
|
+
}
|
|
304
|
+
return [...folders];
|
|
305
|
+
}
|
|
306
|
+
async function firstLine(file) {
|
|
307
|
+
const handle = await open(file, 'r').catch(() => null);
|
|
308
|
+
if (!handle) return '';
|
|
309
|
+
try {
|
|
310
|
+
const { buffer, bytesRead } = await handle.read(Buffer.alloc(16384), 0, 16384, 0);
|
|
311
|
+
return buffer.subarray(0, bytesRead).toString('utf8').split('\n')[0];
|
|
312
|
+
} finally { await handle.close(); }
|
|
179
313
|
}
|
|
180
314
|
|
|
181
315
|
// Associates one folder with the lobby: a project inside the home, not the home itself and not
|
|
@@ -194,7 +328,7 @@ export async function associateProject({ root, home, stateRoot, now = new Date()
|
|
|
194
328
|
const file = join(roomDir, 'project.json');
|
|
195
329
|
const before = await oneAtATime(file, async () => {
|
|
196
330
|
const was = await readJson(file);
|
|
197
|
-
await writeWhole(file, `${JSON.stringify({ root: folder, name: basename(folder), lastOpened: was?.lastOpened ?? null, added: was?.added ?? now.toISOString() })}\n`);
|
|
331
|
+
await writeWhole(file, `${JSON.stringify({ ...(was ?? {}), root: folder, name: basename(folder), lastOpened: was?.lastOpened ?? null, added: was?.added ?? now.toISOString() })}\n`);
|
|
198
332
|
return was;
|
|
199
333
|
});
|
|
200
334
|
return { id, name: basename(folder), root: folder, already: Boolean(before) };
|
|
@@ -237,6 +371,108 @@ export async function createProject({ name, parent = null, home, stateRoot, now
|
|
|
237
371
|
return { ...(await associateProject({ root: folder, home, stateRoot, now })), created: true };
|
|
238
372
|
}
|
|
239
373
|
|
|
374
|
+
// A project to try MADRE with (2026-11-01): 90 of 147 copies never opened a project, and «I read it
|
|
375
|
+
// all and do not know what I would do with MADRE» was said on Facebook. One page, a list of tasks,
|
|
376
|
+
// small enough to read and safe to break, and a README with what to ask the agents about it. Made
|
|
377
|
+
// in the projects folder under a name that is free, in the person's language.
|
|
378
|
+
const SAMPLE = {
|
|
379
|
+
es: {
|
|
380
|
+
names: ['mi-primer-proyecto'],
|
|
381
|
+
readme: `# Mi primer proyecto
|
|
382
|
+
|
|
383
|
+
Una lista de tareas en una sola página, \`index.html\`, para probar MADRE sin miedo a romper nada. Ábrela con doble clic para verla en tu navegador.
|
|
384
|
+
|
|
385
|
+
## Cosas para pedirle a tus IAs
|
|
386
|
+
|
|
387
|
+
- Explícame este proyecto.
|
|
388
|
+
- Agrega un botón para borrar las tareas terminadas.
|
|
389
|
+
- Haz que las tareas se guarden aunque cierre la página.
|
|
390
|
+
- Revisa el código y dime qué mejorarías primero.
|
|
391
|
+
- Pídele a una IA que lo cambie y a otra que revise lo que hizo.
|
|
392
|
+
|
|
393
|
+
Si algo sale mal, DESHACER en MADRE lo regresa a como estaba.
|
|
394
|
+
`,
|
|
395
|
+
title: 'Mis tareas', placeholder: 'Escribe una tarea', add: 'Agregar', empty: 'Nada pendiente.',
|
|
396
|
+
},
|
|
397
|
+
en: {
|
|
398
|
+
names: ['my-first-project'],
|
|
399
|
+
readme: `# My first project
|
|
400
|
+
|
|
401
|
+
A to-do list on a single page, \`index.html\`, to try MADRE without fear of breaking anything. Double-click it to see it in your browser.
|
|
402
|
+
|
|
403
|
+
## Things to ask your AIs
|
|
404
|
+
|
|
405
|
+
- Explain this project to me.
|
|
406
|
+
- Add a button that clears the finished tasks.
|
|
407
|
+
- Make the tasks stay when I close the page.
|
|
408
|
+
- Read the code and tell me what you would improve first.
|
|
409
|
+
- Ask one AI to change it and another to review what it did.
|
|
410
|
+
|
|
411
|
+
If something goes wrong, UNDO in MADRE puts it back as it was.
|
|
412
|
+
`,
|
|
413
|
+
title: 'My tasks', placeholder: 'Write a task', add: 'Add', empty: 'Nothing pending.',
|
|
414
|
+
},
|
|
415
|
+
};
|
|
416
|
+
const samplePage = (words, lang) => `<!doctype html>
|
|
417
|
+
<html lang="${lang}">
|
|
418
|
+
<head>
|
|
419
|
+
<meta charset="utf-8">
|
|
420
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
421
|
+
<title>${words.title}</title>
|
|
422
|
+
<style>
|
|
423
|
+
body { font-family: system-ui, sans-serif; max-width: 32rem; margin: 3rem auto; padding: 0 1rem; color: #222; }
|
|
424
|
+
form { display: flex; gap: .5rem; }
|
|
425
|
+
input[type=text] { flex: 1; padding: .5rem; }
|
|
426
|
+
li { list-style: none; padding: .35rem 0; }
|
|
427
|
+
.done span { text-decoration: line-through; color: #888; }
|
|
428
|
+
</style>
|
|
429
|
+
</head>
|
|
430
|
+
<body>
|
|
431
|
+
<h1>${words.title}</h1>
|
|
432
|
+
<form id="new">
|
|
433
|
+
<input id="text" type="text" placeholder="${words.placeholder}" autocomplete="off">
|
|
434
|
+
<button>${words.add}</button>
|
|
435
|
+
</form>
|
|
436
|
+
<p id="empty">${words.empty}</p>
|
|
437
|
+
<ul id="list"></ul>
|
|
438
|
+
<script>
|
|
439
|
+
const list = document.getElementById('list');
|
|
440
|
+
const empty = document.getElementById('empty');
|
|
441
|
+
document.getElementById('new').addEventListener('submit', (event) => {
|
|
442
|
+
event.preventDefault();
|
|
443
|
+
const input = document.getElementById('text');
|
|
444
|
+
const text = input.value.trim();
|
|
445
|
+
if (!text) return;
|
|
446
|
+
const item = document.createElement('li');
|
|
447
|
+
const box = document.createElement('input');
|
|
448
|
+
box.type = 'checkbox';
|
|
449
|
+
box.addEventListener('change', () => item.classList.toggle('done', box.checked));
|
|
450
|
+
const words = document.createElement('span');
|
|
451
|
+
words.textContent = ' ' + text;
|
|
452
|
+
item.append(box, words);
|
|
453
|
+
list.append(item);
|
|
454
|
+
empty.hidden = true;
|
|
455
|
+
input.value = '';
|
|
456
|
+
});
|
|
457
|
+
</script>
|
|
458
|
+
</body>
|
|
459
|
+
</html>
|
|
460
|
+
`;
|
|
461
|
+
export async function createSampleProject({ home, stateRoot, language = 'es', now = new Date() }) {
|
|
462
|
+
const lang = SAMPLE[language] ? language : 'en';
|
|
463
|
+
const words = SAMPLE[lang];
|
|
464
|
+
for (let n = 1; n <= 9; n += 1) {
|
|
465
|
+
const name = n === 1 ? words.names[0] : `${words.names[0]}-${n}`;
|
|
466
|
+
const made = await createProject({ name, home, stateRoot, now });
|
|
467
|
+
if (made.error === 'exists') continue;
|
|
468
|
+
if (made.error) return made;
|
|
469
|
+
await writeFile(join(made.root, 'README.md'), words.readme);
|
|
470
|
+
await writeFile(join(made.root, 'index.html'), samplePage(words, lang));
|
|
471
|
+
return { ...made, sample: true };
|
|
472
|
+
}
|
|
473
|
+
return { error: 'exists' };
|
|
474
|
+
}
|
|
475
|
+
|
|
240
476
|
// Takes a project out of MADRE (2026-10-10): its record of where it is goes aside, so Home no
|
|
241
477
|
// longer lists it. Nothing in the project's folder is touched, and its conversations and its
|
|
242
478
|
// memory stay beside the record: added again, the folder gets the same id and finds them there.
|
|
@@ -272,6 +508,7 @@ export async function knownRooms(stateRoot) {
|
|
|
272
508
|
name: typeof where?.name === 'string' ? where.name : typeof mark?.project === 'string' ? mark.project : id.replace(/-[0-9a-f]{16}$/, ''),
|
|
273
509
|
root: there ? root : null,
|
|
274
510
|
lastOpened: where?.lastOpened ?? mark?.at ?? null,
|
|
511
|
+
keepOpen: where?.keepOpen === true,
|
|
275
512
|
open,
|
|
276
513
|
});
|
|
277
514
|
}
|
|
@@ -282,7 +519,7 @@ export async function knownRooms(stateRoot) {
|
|
|
282
519
|
// the way up lands in start.log beside its record: if it never comes up, that file says why.
|
|
283
520
|
export function startRoom({ projectRoot, roomDir, env = process.env, spawnImpl = spawn, bin = MADRE_BIN }) {
|
|
284
521
|
let log = 'ignore';
|
|
285
|
-
try { log =
|
|
522
|
+
try { log = openPrivateLog(join(roomDir, 'start.log')); } catch { /* no witness, still start */ }
|
|
286
523
|
// The new room is its own: what this room set for itself on the way up is not handed on.
|
|
287
524
|
const own = { ...env };
|
|
288
525
|
for (const name of ['PULSE_UPDATE_RESTART', 'PULSE_OUTBOUND_LOG']) delete own[name];
|
|
@@ -348,12 +585,13 @@ export function universeOf(research, { full = false } = {}) {
|
|
|
348
585
|
}
|
|
349
586
|
|
|
350
587
|
// What a room says about itself, read from its own page's address. A room on an older MADRE
|
|
351
|
-
// answers 404 to the routes it does not have yet, and is said to be outdated (S-005).
|
|
352
|
-
|
|
588
|
+
// answers 404 to the routes it does not have yet, and is said to be outdated (S-005). It goes with
|
|
589
|
+
// the ficha of this computer (src/ficha.mjs), as the page's own requests do.
|
|
590
|
+
export async function askRoom(port, path, { method = 'GET', body = null, fetchImpl = globalThis.fetch, timeoutMs = 1500, stateRoot = defaultStateRoot() } = {}) {
|
|
353
591
|
try {
|
|
354
592
|
const response = await fetchImpl(`http://127.0.0.1:${port}${path}`, {
|
|
355
593
|
method,
|
|
356
|
-
headers: body ? { 'content-type': 'application/json' } : {},
|
|
594
|
+
headers: { ...(await fichaHeaders(stateRoot)), ...(body ? { 'content-type': 'application/json' } : {}) },
|
|
357
595
|
body: body ? JSON.stringify(body) : undefined,
|
|
358
596
|
signal: AbortSignal.timeout(timeoutMs),
|
|
359
597
|
});
|