@jossuealcala/madre 1.0.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. package/ADDITIONAL-TERMS.md +7 -2
  2. package/CHANGELOG.en.md +152 -1
  3. package/CHANGELOG.md +152 -1
  4. package/CONTRIBUTING.md +2 -2
  5. package/LICENSE +111 -661
  6. package/NOTICE +59 -24
  7. package/README.en.md +36 -204
  8. package/README.md +36 -210
  9. package/SECURITY.md +1 -0
  10. package/TRADEMARKS.en.md +13 -14
  11. package/TRADEMARKS.md +42 -26
  12. package/bin/madre.cjs +2 -2
  13. package/bin/madre.mjs +114 -42
  14. package/docs/REFERENCE.md +53 -6
  15. package/docs/SDK.md +44 -5
  16. package/docs/en/REFERENCE.md +53 -6
  17. package/docs/en/SDK.md +43 -4
  18. package/docs/madre-banner.png +0 -0
  19. package/docs/sdk/hello-module.mjs +3 -0
  20. package/package.json +3 -2
  21. package/public/abduction.js +6 -6
  22. package/public/activity.js +425 -0
  23. package/public/app.js +3519 -647
  24. package/public/assets/abduction-cat-blink.webp +0 -0
  25. package/public/assets/abduction-cat-control-left.webp +0 -0
  26. package/public/assets/abduction-cat-control-right.webp +0 -0
  27. package/public/assets/abduction-cat.webp +0 -0
  28. package/public/assets/manual/shots/en-agents.webp +0 -0
  29. package/public/assets/manual/shots/en-chats.webp +0 -0
  30. package/public/assets/manual/shots/en-code.webp +0 -0
  31. package/public/assets/manual/shots/en-composer.webp +0 -0
  32. package/public/assets/manual/shots/en-connectors.webp +0 -0
  33. package/public/assets/manual/shots/en-continuity.webp +0 -0
  34. package/public/assets/manual/shots/en-coordinator.webp +0 -0
  35. package/public/assets/manual/shots/en-copilot.webp +0 -0
  36. package/public/assets/manual/shots/en-diagnostics.webp +0 -0
  37. package/public/assets/manual/shots/en-home.webp +0 -0
  38. package/public/assets/manual/shots/en-local.webp +0 -0
  39. package/public/assets/manual/shots/en-market.webp +0 -0
  40. package/public/assets/manual/shots/en-memory.webp +0 -0
  41. package/public/assets/manual/shots/en-modes.webp +0 -0
  42. package/public/assets/manual/shots/en-notes.webp +0 -0
  43. package/public/assets/manual/shots/en-settings.webp +0 -0
  44. package/public/assets/manual/shots/en-welcome.webp +0 -0
  45. package/public/assets/manual/shots/en-windows.webp +0 -0
  46. package/public/assets/manual/shots/es-agents.webp +0 -0
  47. package/public/assets/manual/shots/es-chats.webp +0 -0
  48. package/public/assets/manual/shots/es-code.webp +0 -0
  49. package/public/assets/manual/shots/es-composer.webp +0 -0
  50. package/public/assets/manual/shots/es-connectors.webp +0 -0
  51. package/public/assets/manual/shots/es-continuity.webp +0 -0
  52. package/public/assets/manual/shots/es-coordinator.webp +0 -0
  53. package/public/assets/manual/shots/es-copilot.webp +0 -0
  54. package/public/assets/manual/shots/es-diagnostics.webp +0 -0
  55. package/public/assets/manual/shots/es-home.webp +0 -0
  56. package/public/assets/manual/shots/es-local.webp +0 -0
  57. package/public/assets/manual/shots/es-market.webp +0 -0
  58. package/public/assets/manual/shots/es-memory.webp +0 -0
  59. package/public/assets/manual/shots/es-modes.webp +0 -0
  60. package/public/assets/manual/shots/es-notes.webp +0 -0
  61. package/public/assets/manual/shots/es-settings.webp +0 -0
  62. package/public/assets/manual/shots/es-welcome.webp +0 -0
  63. package/public/assets/manual/shots/es-windows.webp +0 -0
  64. package/public/assets/news/1.1/en/chats.webp +0 -0
  65. package/public/assets/news/1.1/en/home.webp +0 -0
  66. package/public/assets/news/1.1/en/maps.webp +0 -0
  67. package/public/assets/news/1.1/en/market.webp +0 -0
  68. package/public/assets/news/1.1/en/permissions.webp +0 -0
  69. package/public/assets/news/1.1/en/privacy.webp +0 -0
  70. package/public/assets/news/1.1/en/welcome.webp +0 -0
  71. package/public/assets/news/1.1/es/chats.webp +0 -0
  72. package/public/assets/news/1.1/es/home.webp +0 -0
  73. package/public/assets/news/1.1/es/maps.webp +0 -0
  74. package/public/assets/news/1.1/es/market.webp +0 -0
  75. package/public/assets/news/1.1/es/permissions.webp +0 -0
  76. package/public/assets/news/1.1/es/privacy.webp +0 -0
  77. package/public/assets/news/1.1/es/welcome.webp +0 -0
  78. package/public/attribution.js +15 -16
  79. package/public/brands.js +2 -2
  80. package/public/code-tools.js +2 -2
  81. package/public/editor.js +13 -13
  82. package/public/en.js +483 -0
  83. package/public/es.js +1817 -598
  84. package/public/hardware.js +2 -2
  85. package/public/i18n.js +47 -9
  86. package/public/icons.js +158 -0
  87. package/public/index.html +68 -51
  88. package/public/inquiry.js +2 -2
  89. package/public/loader.js +271 -2
  90. package/public/macroverso.js +60 -21
  91. package/public/manual-content.js +900 -0
  92. package/public/manual-shots.js +47 -0
  93. package/public/manual.css +246 -0
  94. package/public/manual.html +15 -0
  95. package/public/manual.js +427 -0
  96. package/public/market-art.js +99 -41
  97. package/public/market-view.js +243 -47
  98. package/public/market.js +139 -26
  99. package/public/mcp-catalog.js +62 -0
  100. package/public/neural.js +64 -8
  101. package/public/nostromo-engine.js +709 -40
  102. package/public/page-errors.js +29 -0
  103. package/public/power.js +350 -11
  104. package/public/remedy.js +89 -0
  105. package/public/resay.js +4 -2
  106. package/public/review-ask.js +12 -7
  107. package/public/routing.js +3 -3
  108. package/public/salas-mac.css +875 -48
  109. package/public/salas-mac.html +27 -15
  110. package/public/salas-mac.js +1668 -338
  111. package/public/salas.css +2 -2
  112. package/public/salas.html +3 -3
  113. package/public/salas.js +3 -3
  114. package/public/styles.css +2694 -323
  115. package/public/syntax.js +2 -2
  116. package/public/terms.js +152 -0
  117. package/public/touch.js +2 -2
  118. package/public/tour-chapters.js +100 -92
  119. package/public/tour.js +118 -28
  120. package/public/troubleshooting.js +327 -21
  121. package/public/wallpaper.js +4 -3
  122. package/public/welcome.js +923 -0
  123. package/src/activity.mjs +85 -0
  124. package/src/adapters/claude.mjs +61 -35
  125. package/src/adapters/codex.mjs +18 -5
  126. package/src/adapters/cursor.mjs +60 -9
  127. package/src/adapters/gemini.mjs +17 -4
  128. package/src/adapters/madre.mjs +30 -9
  129. package/src/adapters/opencode.mjs +73 -10
  130. package/src/adapters/process.mjs +19 -15
  131. package/src/adapters/subagents.mjs +159 -0
  132. package/src/asking.mjs +8 -2
  133. package/src/auth-probe.mjs +47 -11
  134. package/src/bridge/devices.mjs +2 -2
  135. package/src/bridge/handoff.mjs +2 -2
  136. package/src/bridge/host.mjs +2 -2
  137. package/src/bridge/network.mjs +2 -2
  138. package/src/bridge/policy.mjs +3 -3
  139. package/src/bridge/qr.mjs +2 -2
  140. package/src/bridge/server.mjs +3 -3
  141. package/src/builtin-updates.mjs +87 -0
  142. package/src/capabilities.mjs +5 -5
  143. package/src/chats.mjs +51 -2
  144. package/src/checkpoint.mjs +67 -9
  145. package/src/choices.mjs +2 -2
  146. package/src/cli-args.mjs +2 -2
  147. package/src/cold.mjs +2 -2
  148. package/src/commands.mjs +2 -2
  149. package/src/config.mjs +2 -2
  150. package/src/conversation-context.mjs +2 -2
  151. package/src/credentials.mjs +80 -18
  152. package/src/dataset.mjs +2 -2
  153. package/src/directives.mjs +2 -2
  154. package/src/distiller.mjs +2 -2
  155. package/src/embeddings.mjs +2 -2
  156. package/src/enlaces.mjs +2 -2
  157. package/src/environment.mjs +147 -0
  158. package/src/event-store.mjs +2 -2
  159. package/src/exam.mjs +2 -2
  160. package/src/extensions.mjs +2 -2
  161. package/src/eyecat-watch.mjs +2 -2
  162. package/src/eyecat.mjs +2 -2
  163. package/src/file-ops.mjs +2 -2
  164. package/src/files.mjs +2 -2
  165. package/src/github.mjs +2 -2
  166. package/src/heartbeat.mjs +2 -2
  167. package/src/history.mjs +76 -0
  168. package/src/i18n.mjs +32 -3
  169. package/src/image-studio.mjs +2 -2
  170. package/src/install-metrics.mjs +109 -0
  171. package/src/json-file.mjs +2 -2
  172. package/src/launch.mjs +2 -2
  173. package/src/lease.mjs +15 -4
  174. package/src/lobby-work.mjs +11 -4
  175. package/src/local-ai.mjs +12 -4
  176. package/src/looks.mjs +19 -7
  177. package/src/market-check.mjs +165 -0
  178. package/src/market-key.mjs +10 -2
  179. package/src/market-license.mjs +104 -0
  180. package/src/market-remote.mjs +71 -13
  181. package/src/maturity.mjs +2 -2
  182. package/src/mcp/connect.mjs +2 -2
  183. package/src/mcp/github-server.mjs +2 -2
  184. package/src/mcp/image-server.mjs +2 -2
  185. package/src/mcp/memory-server.mjs +2 -2
  186. package/src/mcp/proxy.mjs +16 -5
  187. package/src/mcp/smtp-server.mjs +2 -2
  188. package/src/memory-dashboard.mjs +2 -2
  189. package/src/memory-tools.mjs +2 -2
  190. package/src/memory.mjs +2 -2
  191. package/src/models.mjs +115 -12
  192. package/src/module-scope.mjs +2 -2
  193. package/src/modules/ahp.mjs +2 -2
  194. package/src/modules/ash-policy.mjs +2 -2
  195. package/src/modules/ash.mjs +2 -2
  196. package/src/modules/bishop-exam.mjs +2 -2
  197. package/src/modules/bishop-plan.mjs +2 -2
  198. package/src/modules/bishop.mjs +9 -3
  199. package/src/modules/choices.mjs +2 -2
  200. package/src/modules/correo.mjs +2 -2
  201. package/src/modules/enlaces.mjs +2 -2
  202. package/src/modules/git-pulse.mjs +2 -2
  203. package/src/modules/github.mjs +2 -2
  204. package/src/modules/helpers.mjs +2 -2
  205. package/src/modules/image-studio.mjs +2 -2
  206. package/src/modules/index.mjs +92 -5
  207. package/src/modules/intents-calibration.mjs +2 -2
  208. package/src/modules/intents-desk.mjs +4 -3
  209. package/src/modules/intents-observe.mjs +2 -2
  210. package/src/modules/intents-policy.mjs +2 -2
  211. package/src/modules/intents-try.mjs +2 -2
  212. package/src/modules/intents.mjs +2 -2
  213. package/src/modules/local-models.mjs +41 -10
  214. package/src/modules/mcp-connect.mjs +2 -2
  215. package/src/modules/notes.mjs +281 -0
  216. package/src/modules/ollama.mjs +48 -13
  217. package/src/modules/playwright.mjs +16 -5
  218. package/src/modules/reminders.mjs +664 -0
  219. package/src/modules/ripley.mjs +3 -3
  220. package/src/modules/runs.mjs +2 -2
  221. package/src/modules/sdk.mjs +57 -9
  222. package/src/modules/updates.mjs +2 -2
  223. package/src/mother.mjs +13 -3
  224. package/src/npm-launch.mjs +2 -2
  225. package/src/ollama.mjs +8 -6
  226. package/src/opencode-health.mjs +83 -0
  227. package/src/outbound.mjs +35 -3
  228. package/src/override.mjs +27 -22
  229. package/src/ports.mjs +2 -2
  230. package/src/prices.mjs +2 -2
  231. package/src/privacy.mjs +2 -2
  232. package/src/quota-monitor.mjs +2 -2
  233. package/src/quota-sources.mjs +2 -2
  234. package/src/request-guard.mjs +2 -2
  235. package/src/review-ask.mjs +4 -3
  236. package/src/room/archivist.mjs +2 -2
  237. package/src/room/attachments.mjs +2 -2
  238. package/src/room/budget.mjs +2 -2
  239. package/src/room/context.mjs +2 -2
  240. package/src/room/control.mjs +2 -2
  241. package/src/room/copilot.mjs +2 -2
  242. package/src/room/economy.mjs +2 -2
  243. package/src/room/escalation.mjs +2 -2
  244. package/src/room/ghost.mjs +2 -2
  245. package/src/room/guard.mjs +6 -4
  246. package/src/room/prompt.mjs +3 -3
  247. package/src/room/returns.mjs +2 -2
  248. package/src/room/runs.mjs +6 -4
  249. package/src/room/vectors.mjs +2 -2
  250. package/src/room.mjs +144 -36
  251. package/src/router.mjs +2 -2
  252. package/src/runs.mjs +2 -2
  253. package/src/runtime-detection.mjs +36 -6
  254. package/src/salas.mjs +31 -6
  255. package/src/sentinel-errors.mjs +17 -7
  256. package/src/server-sentinel.mjs +2 -2
  257. package/src/server.mjs +980 -139
  258. package/src/setup-trouble.mjs +33 -0
  259. package/src/setup.mjs +4 -4
  260. package/src/smtp.mjs +2 -2
  261. package/src/telemetry.mjs +266 -0
  262. package/src/terms.mjs +43 -0
  263. package/src/tour.mjs +60 -7
  264. package/src/uninstall.mjs +225 -0
  265. package/src/updates.mjs +2 -2
  266. package/src/usage-sentinel.mjs +2 -2
  267. package/src/vault.mjs +2 -2
  268. package/src/verdict.mjs +13 -10
  269. package/src/whats-new.mjs +97 -3
  270. package/public/assets/abduction-cat-blink.png +0 -0
  271. package/public/assets/abduction-cat-control-left.png +0 -0
  272. package/public/assets/abduction-cat-control-right.png +0 -0
  273. package/public/assets/abduction-cat.png +0 -0
package/src/local-ai.mjs CHANGED
@@ -1,5 +1,5 @@
1
- // SPDX-License-Identifier: AGPL-3.0-only
2
- // MADRE · © 2026 Jossue Alcalá · GNU AGPL v3 with additional terms (Section 7): ADDITIONAL-TERMS.md
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
3
  // Which projects use the local AI (Ollama), decided from Home (2026-10-13).
4
4
  //
5
5
  // Ollama is one per computer and its switches live in ~/.pulse/config.json, which every project
@@ -11,6 +11,8 @@
11
11
  // 'pick' only the projects switched on. New ones start without it.
12
12
  // 'manual' each project decides in its own Settings. New ones start with it.
13
13
  // localAi.rooms { <room id>: true | false } what was switched, from Home or from the project.
14
+ // localAi.model the chat model the person chose (2026-10-20), one for the whole computer as
15
+ // Ollama is. Nothing written: MADRE picks the best one installed (src/ollama.mjs).
14
16
  //
15
17
  // With nothing written the mode is 'auto', which is what MADRE did before this existed. The
16
18
  // master switch (`modules.ollama.enabled`) still wins: off there is off everywhere. Home's own
@@ -23,9 +25,12 @@ export function localAiConfig(config = {}) {
23
25
  const mode = LOCAL_MODES.includes(raw.mode) ? raw.mode : 'auto';
24
26
  const rooms = {};
25
27
  for (const [id, on] of Object.entries(raw.rooms ?? {})) if (typeof on === 'boolean') rooms[id] = on;
26
- return { mode, rooms };
28
+ return { mode, rooms, model: MODEL_NAME.test(raw.model ?? '') ? raw.model : null };
27
29
  }
28
30
 
31
+ // A name as Ollama writes it: qwen2.5:7b, llama3.1:8b, someone/model:tag.
32
+ export const MODEL_NAME = /^[a-z0-9][a-z0-9._:/-]{1,80}$/i;
33
+
29
34
  // What one project gets. `on`: whether it uses the local AI now; `chosen`: what this project's
30
35
  // switch says, before the master switch; `editable`: whether its switch can be moved (not in auto).
31
36
  export function localAiFor(config = {}, roomId = null, { home = false } = {}) {
@@ -38,9 +43,12 @@ export function localAiFor(config = {}, roomId = null, { home = false } = {}) {
38
43
 
39
44
  // The patch for config.json: the whole `localAi` block, because updateConfig merges one level
40
45
  // down and a partial `rooms` would drop the projects it does not name.
41
- export function localAiPatch(config = {}, { mode, rooms } = {}) {
46
+ export function localAiPatch(config = {}, { mode, rooms, model } = {}) {
42
47
  const now = localAiConfig(config);
43
48
  const next = { mode: LOCAL_MODES.includes(mode) ? mode : now.mode, rooms: { ...now.rooms } };
49
+ // null goes back to MADRE's own pick; anything else that is not a model name changes nothing.
50
+ // Written as null, not left out: updateConfig merges one level down and would keep the old one.
51
+ next.model = model === null ? null : MODEL_NAME.test(model ?? '') ? model : now.model;
44
52
  for (const [id, on] of Object.entries(rooms ?? {})) {
45
53
  if (typeof id !== 'string' || !id || id.length > 200) continue;
46
54
  if (typeof on === 'boolean') next.rooms[id] = on;
package/src/looks.mjs CHANGED
@@ -1,5 +1,5 @@
1
- // SPDX-License-Identifier: AGPL-3.0-only
2
- // MADRE · © 2026 Jossue Alcalá · GNU AGPL v3 with additional terms (Section 7): ADDITIONAL-TERMS.md
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
3
  // How the person wants MADRE to look, once for every page (2026-10-12). Each project is its own
4
4
  // origin — another port — and Home is one more, so what a browser keeps for one is invisible to
5
5
  // the others: the dark theme chosen in Home left every project light. The choices live here, in
@@ -35,10 +35,16 @@ const looksFile = (stateRoot) => join(stateRoot, 'looks.json');
35
35
  // It lives beside the shared looks, under `rooms`, by the room's id; every other look stays shared.
36
36
  const ROOM_ID = /^[\w .-]{1,120}$/;
37
37
  const readFileLooks = (stateRoot) => readFile(looksFile(stateRoot), 'utf8').then((text) => JSON.parse(text)).catch(() => null);
38
+ // And its own accent (1.0.5): chosen in a project, it is that project's; Home keeps the shared one,
39
+ // and a project that has none of its own wears Home's.
38
40
  function roomsOf(raw) {
39
41
  const rooms = {};
40
42
  for (const [id, own] of Object.entries(raw?.rooms ?? {})) {
41
- if (ROOM_ID.test(id) && typeof own?.wallpaper === 'string' && CHOICE.test(own.wallpaper)) rooms[id] = { wallpaper: own.wallpaper };
43
+ if (!ROOM_ID.test(id)) continue;
44
+ const kept = {};
45
+ if (typeof own?.wallpaper === 'string' && CHOICE.test(own.wallpaper)) kept.wallpaper = own.wallpaper;
46
+ if (typeof own?.accent === 'string' && CHOICE.test(own.accent)) kept.accent = own.accent;
47
+ if (Object.keys(kept).length) rooms[id] = kept;
42
48
  }
43
49
  return rooms;
44
50
  }
@@ -61,15 +67,21 @@ export async function readLooks(stateRoot, { room = null } = {}) {
61
67
  export async function roomLooks(stateRoot) {
62
68
  return roomsOf(await readFileLooks(stateRoot));
63
69
  }
64
- // A project's own wallpaper set, or taken away (`null`): it follows the shared one again.
65
- export function changeRoomLook(stateRoot, room, wallpaper) {
70
+ // A project's own wallpaper or accent set, or taken away (`null`): it follows the shared one again.
71
+ // `change` names what it changes ({ wallpaper }, { accent }); a bare value is the wallpaper, as before.
72
+ export function changeRoomLook(stateRoot, room, change) {
66
73
  return oneAtATime(looksFile(stateRoot), async () => {
67
74
  if (typeof room !== 'string' || !ROOM_ID.test(room)) return { error: 'room' };
68
- if (wallpaper !== null && (typeof wallpaper !== 'string' || !CHOICE.test(wallpaper))) return { error: 'value' };
75
+ const patch = change !== null && typeof change === 'object' ? change : { wallpaper: change };
76
+ const keys = Object.keys(patch).filter((key) => key === 'wallpaper' || key === 'accent');
77
+ if (!keys.length) return { error: 'value' };
78
+ for (const key of keys) if (patch[key] !== null && (typeof patch[key] !== 'string' || !CHOICE.test(patch[key]))) return { error: 'value' };
69
79
  const raw = await readFileLooks(stateRoot);
70
80
  const { looks } = await readLooks(stateRoot);
71
81
  const rooms = roomsOf(raw);
72
- if (wallpaper === null) delete rooms[room]; else rooms[room] = { wallpaper };
82
+ const own = { ...(rooms[room] ?? {}) };
83
+ for (const key of keys) { if (patch[key] === null) delete own[key]; else own[key] = patch[key]; }
84
+ if (Object.keys(own).length) rooms[room] = own; else delete rooms[room];
73
85
  await writeWhole(looksFile(stateRoot), `${JSON.stringify({ looks, ...(Object.keys(rooms).length ? { rooms } : {}), at: new Date().toISOString() }, null, 2)}\n`);
74
86
  return { own: rooms[room] ?? null };
75
87
  });
@@ -0,0 +1,165 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
+ // THE COMMUNITY MARKET'S CHECK (2026-10-28, docs/private/MODULOS-MERCADO-1.0.6.md, stage 3). A module
4
+ // somebody sends to the Market — a pull request to the public `madre-mercado` repository, curated: the
5
+ // author of MADRE reads it, signs it and publishes it — is checked here first, the same way on the
6
+ // sender's computer («Send to the Market» in a module's card), in the repository's CI and in
7
+ // scripts/market-publish.mjs before it is signed:
8
+ // · it loads alone, as MADRE loads any module before installing it (verifyModuleText), says it is
9
+ // the module its entry names, at the same version, and speaks a contract this MADRE knows;
10
+ // · its entry says what the Market shows (name, line and summary in Spanish and English, a shelf,
11
+ // its author and the license of its code) and is free — paid community modules come later (D-M4);
12
+ // · and what it declares, next to what its code reaches for (commands, the network, files, the
13
+ // environment, code built at run time), is written out so reviewing it takes minutes.
14
+ // Nothing here runs the module beyond loading it: what a module does when it is used is for the
15
+ // reviewer to read, which is why the summary says what it reaches for.
16
+
17
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
18
+ import { join } from 'node:path';
19
+ import { t } from './i18n.mjs';
20
+ import { verifyModuleText } from './modules/index.mjs';
21
+
22
+ // Where community modules are sent: a pull request adding modulos/<id>/ to this repository.
23
+ export const MARKET_REPO = 'jossuealcacao-exe/madre-mercado';
24
+ // GitHub's own page to add files to that folder: for whoever cannot write in the repository it makes
25
+ // the fork and the pull request itself, so sending a module needs no terminal.
26
+ export const uploadUrl = (id) => `https://github.com/${MARKET_REPO}/upload/main/modulos/${id}`;
27
+
28
+ export const COMMUNITY_ID = /^[a-z][a-z0-9-]{1,39}$/;
29
+ const SEMVER = /^\d+\.\d+\.\d+$/;
30
+ const GITHUB = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/;
31
+ const COLOR = /^#[0-9a-f]{6}$/i;
32
+ // The shelves of the Market (public/market.js, MARKET_SHELVES).
33
+ export const COMMUNITY_SHELVES = ['no-terminal', 'create', 'organize', 'save', 'connect'];
34
+ // Licenses a community module's code may carry: open ones a person can read, share and reuse.
35
+ // The author of MADRE decides this list with the terms for whoever publishes (D-M3, a draft).
36
+ export const COMMUNITY_LICENSES = ['AGPL-3.0-only', 'AGPL-3.0-or-later', 'GPL-3.0-only', 'GPL-3.0-or-later', 'MIT', 'Apache-2.0', 'BSD-2-Clause', 'BSD-3-Clause', 'ISC', 'MPL-2.0'];
37
+
38
+ // What the code reaches for, read from its text: what a reviewer looks at first.
39
+ const REACHES = [
40
+ ['commands', 'runs commands on the computer', /child_process|\bspawn(?:Sync)?\s*\(|\bexec(?:File)?(?:Sync)?\s*\(|\bfork\s*\(/],
41
+ ['network', 'talks to the network', /\bfetch\s*\(|node:https?|\bWebSocket\b|node:net|node:dgram|node:tls/],
42
+ ['files', 'reads or writes files', /node:fs|\breadFile|\bwriteFile|\bappendFile|\bunlink|\brmSync|\brm\s*\(|\bmkdir/],
43
+ ['environment', 'reads environment variables', /process\.env/],
44
+ ['dynamic', 'builds or loads code at run time', /\beval\s*\(|new\s+Function\s*\(|\bimport\s*\(|\brequire\s*\(/],
45
+ ['process', 'touches the MADRE process', /process\.(?:exit|kill|chdir|on\s*\()/],
46
+ ];
47
+ export function reachesOf(text) {
48
+ return REACHES.filter(([, , pattern]) => pattern.test(String(text ?? ''))).map(([id, words]) => ({ id, words: t(words) }));
49
+ }
50
+
51
+ const words = (value, max) => typeof value === 'string' && value.trim() && value.length <= max;
52
+ const both = (value, max) => value && typeof value === 'object' && words(value.es, max) && words(value.en, max);
53
+
54
+ // The entry the Market shows, as the sender wrote it: what is missing or wrong, in plain words, each
55
+ // with the field it is about (the form in a module's card marks that field).
56
+ export const entryProblems = (entry, module = null) => entryFaults(entry, module).map((one) => one.words);
57
+ export function entryFaults(entry, module = null) {
58
+ const wrong = [];
59
+ const say = (field, words) => wrong.push({ field, words });
60
+ if (!entry || typeof entry !== 'object') return [{ field: 'entry', words: t('The entry is missing: entrada.json, beside the module.') }];
61
+ if (!COMMUNITY_ID.test(entry.id ?? '')) say('id', t('id: lowercase letters, numbers and dashes, 2 to 40, starting with a letter.'));
62
+ if (module && entry.id !== module.id) say('id', t('id: the entry says "{entry}" and the module says "{module}".', { entry: entry.id, module: module.id }));
63
+ if (!SEMVER.test(entry.version ?? '')) say('version', t('version: like 1.0.0.'));
64
+ if (module && entry.version !== module.version) say('version', t('version: the entry says {entry} and the module says {module}.', { entry: entry.version, module: module.version ?? t('nothing') }));
65
+ if (!both(entry.name, 60)) say('name', t('name: in Spanish and English (es, en), up to 60 characters each.'));
66
+ if (!both(entry.line, 140)) say('line', t('line: what it does in one line, in Spanish and English, up to 140 characters.'));
67
+ if (!both(entry.summary, 1200)) say('summary', t('summary: what it does and when to use it, in Spanish and English, up to 1200 characters.'));
68
+ if (!COMMUNITY_SHELVES.includes(entry.shelf)) say('shelf', t('shelf: one of {list}.', { list: COMMUNITY_SHELVES.join(', ') }));
69
+ if (entry.price !== undefined && entry.price !== 0) say('price', t('price: community modules are free for now (0).'));
70
+ if (!SEMVER.test(entry.minMadre ?? '')) say('minMadre', t('minMadre: the oldest MADRE it works with, like 1.1.0.'));
71
+ if (!words(entry.author?.name, 60) || !GITHUB.test(entry.author?.github ?? '')) say('author', t('author: { "name": your name, "github": your GitHub user }.'));
72
+ if (!COMMUNITY_LICENSES.includes(entry.spdx)) say('spdx', t('spdx: the license of its code, one of {list}.', { list: COMMUNITY_LICENSES.join(', ') }));
73
+ if (entry.changes !== undefined && !both(entry.changes, 400)) say('changes', t('changes: what changed in this version, in Spanish and English, up to 400 characters.'));
74
+ if (entry.hue !== undefined && !(Array.isArray(entry.hue) && entry.hue.length === 2 && entry.hue.every((one) => COLOR.test(one)))) say('hue', t('hue: two colors like ["#60a5fa", "#1d4ed8"].'));
75
+ if (entry.icon !== undefined) {
76
+ if (typeof entry.icon !== 'string' || entry.icon.length > 8000) say('icon', t('icon: the shapes of a 20×20 drawing, up to 8000 characters.'));
77
+ else if (/<script|\son\w+\s*=|javascript:|<foreignObject|href\s*=/i.test(entry.icon)) say('icon', t('icon: only shapes; no scripts, events or links.'));
78
+ }
79
+ return wrong;
80
+ }
81
+
82
+ // Everything at once: the module, its entry and what it reaches for, and the summary for a person.
83
+ export async function checkSubmission({ text, entry, name = null }) {
84
+ const faults = [];
85
+ let module = null;
86
+ try {
87
+ module = await verifyModuleText({ text, name: name ?? `${entry?.id ?? 'module'}.mjs`, replace: true });
88
+ } catch (error) {
89
+ faults.push({ field: 'module', words: t('The module does not load as MADRE loads one: {error}', { error: error.message }) });
90
+ }
91
+ faults.push(...entryFaults(entry, module));
92
+ const problems = faults.map((one) => one.words);
93
+ const reaches = reachesOf(text);
94
+ const declares = module?.declares ?? null;
95
+ // What the code reaches for and the module never declared: the first thing to ask its author.
96
+ const undeclared = [];
97
+ if (reaches.some((one) => one.id === 'network') && !(declares?.reaches ?? []).length) undeclared.push(t('It talks to the network but declares no `reaches`: say where it goes and why.'));
98
+ const result = { ok: problems.length === 0, problems, faults, fields: [...new Set(faults.map((one) => one.field))], undeclared, module: module ? { id: module.id, name: module.name, version: module.version, unknown: module.unknown ?? [] } : null, declares, reaches };
99
+ return { ...result, markdown: submissionMarkdown(result, entry) };
100
+ }
101
+
102
+ // The summary a reviewer reads in the pull request (the CI writes it to the job's summary).
103
+ export function submissionMarkdown(result, entry = {}) {
104
+ const lines = [];
105
+ const title = entry?.name?.es ?? result.module?.name ?? entry?.id ?? 'module';
106
+ lines.push(`## ${result.ok ? '✅' : '❌'} ${title} ${result.module?.version ?? entry?.version ?? ''}`.trim());
107
+ if (entry?.author?.github) lines.push(t('By **{name}** (@{github}) · {license} · shelf `{shelf}`', { name: entry.author.name ?? entry.author.github, github: entry.author.github, license: entry.spdx ?? t('no license'), shelf: entry.shelf ?? '—' }));
108
+ if (result.problems.length) {
109
+ lines.push('', `### ${t('To fix before it can be reviewed')}`);
110
+ for (const one of result.problems) lines.push(`- ${one}`);
111
+ }
112
+ const declares = result.declares;
113
+ if (declares) {
114
+ const yes = (value) => (value ? t('yes') : t('no'));
115
+ lines.push('', `### ${t('What it declares')}`);
116
+ lines.push(`- ${t('Reaches: {list}', { list: declares.reaches.length ? declares.reaches.map((one) => `${one.host ?? one.to ?? '?'}${one.what ? ` (${one.what})` : ''}`).join(', ') : t('nothing') })}`);
117
+ lines.push(`- ${t('Keys it asks for: {list}', { list: declares.secrets.length ? declares.secrets.map((one) => one.label).join(', ') : t('nothing') })}`);
118
+ lines.push(`- ${t('Tools for the agents: {tools} · reads the conversations: {reads} · pages: {pages} · writes in the project: {writes}', { tools: yes(declares.tools), reads: yes(declares.reads), pages: declares.pages, writes: yes(declares.writes) })}`);
119
+ lines.push(`- ${t('Commands: {list}', { list: declares.commands.length ? declares.commands.join(', ') : t('nothing') })}`);
120
+ }
121
+ lines.push('', `### ${t('What its code reaches for')}`);
122
+ lines.push(result.reaches.length ? result.reaches.map((one) => `- ${one.words}`).join('\n') : `- ${t('Nothing beyond what MADRE hands every module.')}`);
123
+ for (const one of result.undeclared) lines.push(`- ⚠️ ${one}`);
124
+ if (result.module?.unknown?.length) lines.push(`- ⚠️ ${t('Fields MADRE does not know: {list}', { list: result.module.unknown.join(', ') })}`);
125
+ lines.push('', `_${t('Checked by MADRE (src/market-check.mjs). A person still reads the code before it is signed: a module runs with the permissions of whoever opens MADRE.')}_`);
126
+ return lines.join('\n');
127
+ }
128
+
129
+ // SENDING ONE'S OWN MODULE («Send to the Market» in its card). The entry starts from what the module
130
+ // already says — its id, version, name and what it does, in both languages when it wrote both — and
131
+ // from what the person wrote the last time; the rest (the shelf, who they are on GitHub, the license
132
+ // of their code) is theirs to say. Ready, the module and its entry are written to a folder of their
133
+ // own, the two files the repository asks for, to add with GitHub's page.
134
+ export const submissionFolder = (stateRoot, id) => join(stateRoot, 'market', 'submissions', id);
135
+ const bilingual = (value) => (value && typeof value === 'object' ? { es: value.es ?? value.en ?? '', en: value.en ?? value.es ?? '' } : { es: String(value ?? ''), en: String(value ?? '') });
136
+ const firstLine = (text) => String(text ?? '').split(/(?<=[.!?])\s/)[0].slice(0, 140);
137
+ export async function submissionDraft({ stateRoot, module, text, madre, entry = null }) {
138
+ const saved = entry ?? (await readFile(join(submissionFolder(stateRoot, module.id), 'entrada.json'), 'utf8').then(JSON.parse).catch(() => null)) ?? {};
139
+ let checked = null;
140
+ try { checked = await verifyModuleText({ text, name: `${module.id}.mjs`, replace: true }); } catch { /* said by the check */ }
141
+ const summary = bilingual(checked?.words?.summary ?? checked?.summary ?? module.summary ?? '');
142
+ const draft = {
143
+ id: module.id,
144
+ version: checked?.version ?? module.version ?? '',
145
+ name: bilingual(checked?.words?.name ?? checked?.name ?? module.name ?? module.id),
146
+ line: { es: firstLine(summary.es), en: firstLine(summary.en) },
147
+ summary,
148
+ shelf: '',
149
+ minMadre: madre ?? '',
150
+ author: { name: checked?.credit ?? '', github: '' },
151
+ spdx: '',
152
+ };
153
+ // What the person wrote wins, field by field; the id and the version are always the module's.
154
+ const merged = { ...draft, ...saved, id: draft.id, version: draft.version };
155
+ for (const key of ['name', 'line', 'summary']) merged[key] = { ...draft[key], ...(saved[key] ?? {}) };
156
+ merged.author = { ...draft.author, ...(saved.author ?? {}) };
157
+ return merged;
158
+ }
159
+ export async function writeSubmission({ stateRoot, text, entry }) {
160
+ const folder = submissionFolder(stateRoot, entry.id);
161
+ await mkdir(folder, { recursive: true });
162
+ await writeFile(join(folder, `${entry.id}.module.mjs`), text);
163
+ await writeFile(join(folder, 'entrada.json'), `${JSON.stringify(entry, null, 2)}\n`);
164
+ return { folder, files: [`${entry.id}.module.mjs`, 'entrada.json'], upload: uploadUrl(entry.id) };
165
+ }
@@ -1,8 +1,16 @@
1
- // SPDX-License-Identifier: AGPL-3.0-only
2
- // MADRE · © 2026 Jossue Alcalá · GNU AGPL v3 with additional terms (Section 7): ADDITIONAL-TERMS.md
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
3
  // The public half of the Market's key (scripts/market-key.mjs). The catalog at madre.run/mercado/
4
4
  // is signed with the private half, which lives only on the author's computer; a catalog this key
5
5
  // does not verify is not read, and nothing in it is installed (src/market-remote.mjs).
6
6
  export const MARKET_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
7
7
  MCowBQYDK2VwAyEA4/DXYprFh2wfiOPpkJheWR0uEtJA+Wl3+AnJXE1YGt0=
8
8
  -----END PUBLIC KEY-----`;
9
+
10
+ // The public half of the FACTORY key (2026-10-25, scripts/market-key.mjs --fabrica): a second key,
11
+ // kept apart from the Market's, that signs the newer files of MADRE's own modules. Those reach every
12
+ // MADRE on their own, so the Market's key alone must not be enough to replace one
13
+ // (src/builtin-updates.mjs). Were it null, no such file would ever run.
14
+ export const FACTORY_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
15
+ MCowBQYDK2VwAyEA6EMrbXJptG+Qc1Zzeiw2FrTDKBz63BXN6S/BlkI7tUQ=
16
+ -----END PUBLIC KEY-----`;
@@ -0,0 +1,104 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
+ // THE MARKET'S PAID MODULES (2026-10-19). A paid module is bought at its checkout (Lemon Squeezy,
4
+ // the seller of record, which charges and handles each country's taxes), and the key the buyer
5
+ // gets by email is pasted in MADRE once. MADRE asks Lemon Squeezy, that one time and because the
6
+ // person pressed «Activate», whether the key is good and is for this module: the answer must name
7
+ // the store and the product the signed catalog names, or the key is refused. Kept in
8
+ // ~/.pulse/market/licenses.json, readable only by this person, and never asked again: the module
9
+ // works offline from then on. «Release» gives the activation back, to use the key elsewhere.
10
+ //
11
+ // What travels: the key and a name for this computer made from MADRE's random install id
12
+ // («MADRE 1a2b3c4d»), never the computer's own name. The module's code stays readable: what is paid
13
+ // for is installing it from the Market, its updates and its support, not a lock on the code.
14
+
15
+ import { chmod, mkdir, readFile, rename, writeFile } from 'node:fs/promises';
16
+ import { join } from 'node:path';
17
+ import { t } from './i18n.mjs';
18
+
19
+ export const LICENSE_API = 'https://api.lemonsqueezy.com/v1/licenses';
20
+ const TIMEOUT_MS = 10000;
21
+ const KEY = /^[A-Za-z0-9-]{8,80}$/;
22
+
23
+ const file = (stateRoot) => join(stateRoot, 'market', 'licenses.json');
24
+ const readJson = (path) => readFile(path, 'utf8').then((raw) => JSON.parse(raw)).catch(() => null);
25
+ async function keep(stateRoot, licenses) {
26
+ await mkdir(join(stateRoot, 'market'), { recursive: true });
27
+ const temp = `${file(stateRoot)}.${process.pid}.${Date.now()}.tmp`;
28
+ await writeFile(temp, JSON.stringify(licenses, null, 2), { mode: 0o600 });
29
+ await rename(temp, file(stateRoot));
30
+ await chmod(file(stateRoot), 0o600).catch(() => {});
31
+ }
32
+
33
+ export const licensesFrom = async (stateRoot) => (await readJson(file(stateRoot))) ?? {};
34
+ // What the page may know: which modules are bought, never the keys.
35
+ export async function licensedIds(stateRoot) {
36
+ const licenses = await licensesFrom(stateRoot);
37
+ return Object.fromEntries(Object.entries(licenses).map(([id, one]) => [id, { at: one.at ?? null }]));
38
+ }
39
+ export const isLicensed = async (stateRoot, id) => Boolean((await licensesFrom(stateRoot))[id]?.key);
40
+ // A module that costs nothing needs no license; one with a price needs one kept here.
41
+ export const mayInstall = async (stateRoot, entry) => !(entry?.price > 0) || isLicensed(stateRoot, entry.id);
42
+
43
+ async function ask(fetchImpl, path, fields, api) {
44
+ const controller = new AbortController();
45
+ const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
46
+ try {
47
+ const response = await fetchImpl(`${api}/${path}`, {
48
+ method: 'POST',
49
+ signal: controller.signal,
50
+ headers: { accept: 'application/json', 'content-type': 'application/x-www-form-urlencoded' },
51
+ body: new URLSearchParams(fields).toString(),
52
+ });
53
+ const answer = await response.json().catch(() => null);
54
+ return { status: response.status, answer };
55
+ } catch {
56
+ throw new Error(t('MADRE could not reach Lemon Squeezy to check the license. Check your internet connection and try again.'));
57
+ } finally { clearTimeout(timer); }
58
+ }
59
+
60
+ // The catalog's own word on where a module is sold: Lemon Squeezy, and which store and product.
61
+ export function saleOf(entry) {
62
+ const license = entry?.license;
63
+ if (!(entry?.price > 0) || license?.provider !== 'lemonsqueezy') return null;
64
+ if (!Number.isInteger(license.store) || !Number.isInteger(license.product)) return null;
65
+ return { store: license.store, product: license.product };
66
+ }
67
+
68
+ export async function activateLicense({ stateRoot, entry, key, installId, fetchImpl = globalThis.fetch, api = LICENSE_API }) {
69
+ const sale = saleOf(entry);
70
+ if (!sale) throw new Error(t('This module is not sold through the Market.'));
71
+ const typed = String(key ?? '').trim();
72
+ if (!KEY.test(typed)) throw new Error(t('That does not look like a license key. Copy it whole from the purchase email.'));
73
+ const { answer } = await ask(fetchImpl, 'activate', { license_key: typed, instance_name: `MADRE ${String(installId ?? '').replace(/-/g, '').slice(0, 8) || 'sin-id'}` }, api);
74
+ if (!answer?.activated) {
75
+ const said = String(answer?.error ?? '');
76
+ if (/limit/i.test(said)) throw new Error(t('This license is already active on as many computers as it allows. Release it on another computer, or buy another one.'));
77
+ throw new Error(t('Lemon Squeezy did not accept that key: {error}', { error: said.slice(0, 200) || t('no reason given') }));
78
+ }
79
+ // A good key for something else is not a key for this module: given back at once.
80
+ const meta = answer.meta ?? {};
81
+ if (meta.store_id !== sale.store || meta.product_id !== sale.product) {
82
+ if (answer.instance?.id) await ask(fetchImpl, 'deactivate', { license_key: typed, instance_id: answer.instance.id }, api).catch(() => null);
83
+ throw new Error(t('That license is for another product, not for «{name}».', { name: entry.id }));
84
+ }
85
+ const licenses = await licensesFrom(stateRoot);
86
+ licenses[entry.id] = { provider: 'lemonsqueezy', key: typed, instance: answer.instance?.id ?? null, at: new Date().toISOString() };
87
+ await keep(stateRoot, licenses);
88
+ return { id: entry.id, at: licenses[entry.id].at };
89
+ }
90
+
91
+ // The activation given back to Lemon Squeezy, so the key can be used on another computer. The
92
+ // module stays installed; it is the Market's updates that stop until a key is active again.
93
+ export async function releaseLicense({ stateRoot, id, fetchImpl = globalThis.fetch, api = LICENSE_API }) {
94
+ const licenses = await licensesFrom(stateRoot);
95
+ const held = licenses[id];
96
+ if (!held?.key) throw new Error(t('There is no license for «{id}» on this computer.', { id }));
97
+ if (held.instance) {
98
+ const { answer } = await ask(fetchImpl, 'deactivate', { license_key: held.key, instance_id: held.instance }, api);
99
+ if (!answer?.deactivated && !/not found|invalid/i.test(String(answer?.error ?? ''))) throw new Error(t('Lemon Squeezy did not release the license: {error}', { error: String(answer?.error ?? '').slice(0, 200) || t('no reason given') }));
100
+ }
101
+ delete licenses[id];
102
+ await keep(stateRoot, licenses);
103
+ return { id };
104
+ }
@@ -1,5 +1,5 @@
1
- // SPDX-License-Identifier: AGPL-3.0-only
2
- // MADRE · © 2026 Jossue Alcalá · GNU AGPL v3 with additional terms (Section 7): ADDITIONAL-TERMS.md
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
3
  // THE MARKET, from madre.run (2026-10-18). What the Market shows and the modules it hands out do
4
4
  // not wait for a new MADRE: they live in a catalog the author publishes at madre.run/mercado/,
5
5
  // signed with a key only the author holds (scripts/market-key.mjs). MADRE reads it when it opens —
@@ -25,11 +25,12 @@ import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
25
25
  import { join } from 'node:path';
26
26
  import { t } from './i18n.mjs';
27
27
  import { MARKET_PUBLIC_KEY } from './market-key.mjs';
28
+ import { mayInstall } from './market-license.mjs';
28
29
 
29
30
  export const MARKET_URL = 'https://madre.run/mercado/catalogo.json';
30
31
  const MAX_CATALOG = 1024 * 1024;
31
32
  const MAX_SIGNATURE = 1024;
32
- const MAX_MODULE = 512 * 1024;
33
+ export const MAX_MODULE = 512 * 1024;
33
34
  const FRESH_MS = 10 * 60 * 1000;
34
35
  const TIMEOUT_MS = 8000;
35
36
  const ID = /^[a-z][a-z0-9-]{1,40}$/;
@@ -38,8 +39,8 @@ const COLOR = /^#[0-9a-f]{6}$/i;
38
39
 
39
40
  export const marketUrl = (env = process.env) => env.PULSE_MARKET_URL || MARKET_URL;
40
41
  const folder = (stateRoot) => join(stateRoot, 'market');
41
- const readJson = (file) => readFile(file, 'utf8').then((raw) => JSON.parse(raw)).catch(() => null);
42
- async function writeAtomic(file, data) {
42
+ export const readJson = (file) => readFile(file, 'utf8').then((raw) => JSON.parse(raw)).catch(() => null);
43
+ export async function writeAtomic(file, data) {
43
44
  const temp = `${file}.${process.pid}.${Date.now()}.tmp`;
44
45
  await writeFile(temp, data);
45
46
  await rename(temp, file);
@@ -102,11 +103,27 @@ export function readCatalog(text, { url = MARKET_URL } = {}) {
102
103
  // Drawings are markup: they travel signed, and the page keeps only the shapes it knows (market.js).
103
104
  icon: typeof raw.icon === 'string' && raw.icon.length <= 8000 ? raw.icon : null,
104
105
  art: typeof raw.art === 'string' && raw.art.length <= 60000 ? raw.art : null,
106
+ // Two more pictures for its page (1.0.5), drawings like `art`.
107
+ shots: Array.isArray(raw.shots) ? raw.shots.filter((one) => typeof one === 'string' && one.length <= 60000).slice(0, 2) : [],
105
108
  version: typeof raw.version === 'string' && /^\d+\.\d+\.\d+$/.test(raw.version) ? raw.version : null,
106
109
  minMadre: typeof raw.minMadre === 'string' && /^\d+\.\d+\.\d+$/.test(raw.minMadre) ? raw.minMadre : null,
107
110
  changes: words(raw.changes, 400),
108
111
  file: null,
112
+ // Where a paid module is bought (an https page) and whose license opens it (market-license.mjs).
113
+ checkout: null,
114
+ license: null,
115
+ // A module of the community (2026-10-28, scripts/market-publish.mjs --community): who made it,
116
+ // and the license of its code. Signed like every entry: the author of MADRE read it first.
117
+ community: raw.community === true,
118
+ author: raw.author && typeof raw.author === 'object' && typeof raw.author.name === 'string' && raw.author.name.trim()
119
+ ? { name: raw.author.name.trim().slice(0, 60), github: /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/.test(raw.author.github ?? '') ? raw.author.github : null }
120
+ : null,
121
+ spdx: typeof raw.spdx === 'string' && /^[A-Za-z0-9.+-]{2,40}$/.test(raw.spdx) ? raw.spdx : null,
109
122
  };
123
+ if (entry.price > 0) {
124
+ try { const page = new URL(raw.checkout); if (page.protocol === 'https:') entry.checkout = page.href; } catch { /* no page to buy it */ }
125
+ if (raw.license?.provider === 'lemonsqueezy' && Number.isInteger(raw.license.store) && Number.isInteger(raw.license.product)) entry.license = { provider: 'lemonsqueezy', store: raw.license.store, product: raw.license.product };
126
+ }
110
127
  if (raw.file) {
111
128
  const href = fileUrl(raw.file.url, url);
112
129
  if (!href || !SHA.test(raw.file.sha256 ?? '') || !entry.version) continue;
@@ -118,10 +135,25 @@ export function readCatalog(text, { url = MARKET_URL } = {}) {
118
135
  // What the author has to say to everyone who opens MADRE: one line each, said once, and the
119
136
  // module it is about when there is one.
120
137
  const news = (Array.isArray(data.news) ? data.news : []).filter((one) => ID.test(one?.id ?? '')).map((one) => ({ id: one.id, text: words(one.text, 240), module: ID.test(one.module ?? '') ? one.module : null })).filter((one) => one.text).slice(0, 10);
121
- return { schema: 1, issued: new Date(issued).toISOString(), shelves, featured, modules, news };
138
+ // NEWER FILES FOR MADRE'S OWN MODULES (2026-10-25, R-2 of the 1.1 road map): Notes, Reminders…
139
+ // come with MADRE and are kept up to date from here. A list of their own, so a MADRE that does not
140
+ // know it (1.0.5 and before) never sees one as a module to install. Each file carries, besides its
141
+ // sha256, the signature of the FACTORY key (src/market-key.mjs): the Market's key alone cannot
142
+ // replace a module every MADRE runs (src/builtin-updates.mjs).
143
+ const builtins = [];
144
+ for (const raw of (Array.isArray(data.builtins) ? data.builtins : []).slice(0, 50)) {
145
+ if (!ID.test(raw?.id ?? '') || typeof raw.version !== 'string' || !/^\d+\.\d+\.\d+$/.test(raw.version) || !Number.isInteger(raw.sdk) || raw.sdk < 1) continue;
146
+ const href = fileUrl(raw.file?.url, url);
147
+ if (!href || !SHA.test(raw.file?.sha256 ?? '') || typeof raw.file?.factory !== 'string' || raw.file.factory.length > MAX_SIGNATURE) continue;
148
+ builtins.push({ id: raw.id, version: raw.version, sdk: raw.sdk, changes: words(raw.changes, 400), file: { url: href, sha256: raw.file.sha256, size: Number(raw.file.size) || null, factory: raw.file.factory.trim() } });
149
+ }
150
+ // TAKEN BACK: a module, or one version of it, that must not run anywhere any more. A module got
151
+ // from the Market is removed; a newer file of one of MADRE's own goes back to the one MADRE came with.
152
+ const revoked = (Array.isArray(data.revoked) ? data.revoked : []).filter((one) => ID.test(one?.id ?? '')).map((one) => ({ id: one.id, version: typeof one.version === 'string' && /^\d+\.\d+\.\d+$/.test(one.version) ? one.version : null, why: words(one.why, 240) })).slice(0, 100);
153
+ return { schema: 1, issued: new Date(issued).toISOString(), shelves, featured, modules, news, builtins, revoked };
122
154
  }
123
155
 
124
- async function bytesFrom(url, { fetchImpl, max }) {
156
+ export async function bytesFrom(url, { fetchImpl, max }) {
125
157
  const controller = new AbortController();
126
158
  const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
127
159
  try {
@@ -149,7 +181,12 @@ export async function refreshCatalog({ stateRoot, env = process.env, fetchImpl =
149
181
  if (!force && kept && state.checkedAt && now() - Date.parse(state.checkedAt) < FRESH_MS) return { catalog: kept, fresh: false };
150
182
  const url = marketUrl(env);
151
183
  try {
152
- const [bytes, signature] = await Promise.all([bytesFrom(url, { fetchImpl, max: MAX_CATALOG }), bytesFrom(`${url}.sig`, { fetchImpl, max: MAX_SIGNATURE })]);
184
+ // Both answers are waited for, also when one fails: the other one used to be still out when
185
+ // the ask was over, and was written in the outbound log of a room already closed (2026-10-21).
186
+ const asked = await Promise.allSettled([bytesFrom(url, { fetchImpl, max: MAX_CATALOG }), bytesFrom(`${url}.sig`, { fetchImpl, max: MAX_SIGNATURE })]);
187
+ const refused = asked.find((one) => one.status === 'rejected');
188
+ if (refused) throw refused.reason;
189
+ const [bytes, signature] = asked.map((one) => one.value);
153
190
  if (!verifySigned(bytes, signature.toString('utf8'), publicKey)) throw new Error(t('The Market catalog is not signed with MADRE\'s key, so MADRE did not read it.'));
154
191
  const catalog = readCatalog(bytes.toString('utf8'), { url });
155
192
  if (kept && Date.parse(catalog.issued) < Date.parse(kept.issued)) throw new Error(t('The Market served a catalog older than the one this computer has, so MADRE kept its own.'));
@@ -169,15 +206,22 @@ export const installedFromMarket = async (stateRoot) => (await readJson(join(fol
169
206
 
170
207
  // One module from the catalog onto this computer, for every project (each one turns it on).
171
208
  // `verify` and `install` are src/modules/index.mjs's own checks and writer.
172
- export async function installFromMarket({ stateRoot, projectRoot, id, catalog, madre, fetchImpl = globalThis.fetch, verifyText, installText }) {
209
+ // Two steps since 2026-10-25: asked with `review`, the file is fetched and checked but nothing is
210
+ // installed, and what it declares comes back with its sha256; installed only when the person
211
+ // accepted that very file (`accept` = its sha256), so what is installed is what was read.
212
+ // A module MADRE updates on its own later (updateFromMarket) was accepted once, by the person.
213
+ export async function installFromMarket({ stateRoot, projectRoot, id, catalog, madre, fetchImpl = globalThis.fetch, verifyText, installText, review = false, accept = null, accepted = false }) {
173
214
  const entry = catalog?.modules.find((one) => one.id === id && one.file);
174
215
  if (!entry) throw new Error(t('The Market has no module «{id}» to install.', { id }));
175
216
  if (!fitsVersion(madre, entry.minMadre)) throw new Error(t('This module needs MADRE {version} or newer.', { version: entry.minMadre }));
217
+ if (!(await mayInstall(stateRoot, entry))) throw new Error(t('«{name}» is a paid module: buy it, or activate the license you already have.', { name: entry.id }));
176
218
  const bytes = await bytesFrom(entry.file.url, { fetchImpl, max: MAX_MODULE });
177
219
  if (sha256(bytes) !== entry.file.sha256) throw new Error(t('The module file is not the one the Market signed, so MADRE did not install it.'));
178
220
  const text = bytes.toString('utf8');
179
221
  const checked = await verifyText({ text, name: `${id}.mjs`, replace: true });
180
222
  if (checked.id !== id) throw new Error(t('The file says it is «{found}», not «{id}», so MADRE did not install it.', { found: checked.id, id }));
223
+ if (review) return { review: true, id, name: checked.name, version: entry.version, sha256: entry.file.sha256, declares: checked.declares ?? null };
224
+ if (!accepted && accept !== entry.file.sha256) throw Object.assign(new Error(t('Read what {name} does before installing it.', { name: checked.name ?? id })), { code: 'REVIEW_FIRST' });
181
225
  const done = await installText({ text, name: `${id}.mjs`, scope: 'user', stateRoot, projectRoot, source: { kind: 'market', from: entry.file.url }, replace: true });
182
226
  const dir = folder(stateRoot);
183
227
  await mkdir(dir, { recursive: true });
@@ -220,19 +264,33 @@ export async function marketNewsSeen(stateRoot) { await writeAtomic(join(folder(
220
264
 
221
265
  // Every module got from the Market whose signed file changed: the new one, installed, and a line
222
266
  // for the person. One that fails stays as it was and is tried again next time.
223
- export async function updateFromMarket({ stateRoot, projectRoot, catalog, madre, fetchImpl = globalThis.fetch, verifyText, installText, names = {} }) {
267
+ export async function updateFromMarket({ stateRoot, projectRoot, catalog, madre, fetchImpl = globalThis.fetch, verifyText, installText, names = {}, remove = null }) {
224
268
  const installed = await installedFromMarket(stateRoot);
225
269
  const updated = [];
270
+ const removed = [];
271
+ // Taken back (2026-10-25): a module, or the version of it this computer has, that the catalog says
272
+ // must not run any more is removed and forgotten here, so no next catalog brings it back.
273
+ for (const [id, have] of Object.entries(installed)) {
274
+ const taken = (catalog?.revoked ?? []).find((one) => one.id === id && (!one.version || one.version === have.version));
275
+ if (!taken || typeof remove !== 'function') continue;
276
+ try { await remove(id); } catch { /* already gone by hand */ }
277
+ await forgetFromMarket(stateRoot, id);
278
+ delete installed[id];
279
+ // Its name as the Market says it, in both languages when it has them; the page picks the room's.
280
+ removed.push({ id, name: catalog?.modules?.find((one) => one.id === id)?.name ?? names[id] ?? id, kind: 'removed', version: have.version ?? null, why: taken.why ?? null, at: new Date().toISOString() });
281
+ }
226
282
  for (const [id, have] of Object.entries(installed)) {
227
283
  const entry = catalog?.modules.find((one) => one.id === id && one.file);
228
284
  if (!entry || entry.file.sha256 === have.sha256 || !fitsVersion(madre, entry.minMadre)) continue;
229
285
  try {
230
- await installFromMarket({ stateRoot, projectRoot, id, catalog, madre, fetchImpl, verifyText, installText });
286
+ await installFromMarket({ stateRoot, projectRoot, id, catalog, madre, fetchImpl, verifyText, installText, accepted: true });
231
287
  updated.push({ id, name: names[id] ?? (typeof entry.name === 'string' ? entry.name : entry.name?.en) ?? id, from: have.version ?? null, to: entry.version, changes: entry.changes ?? null, at: new Date().toISOString() });
232
288
  } catch { /* tried again the next time MADRE opens */ }
233
289
  }
234
- if (updated.length) {
235
- const news = [...(await marketNews(stateRoot)).filter((one) => !updated.some((fresh) => fresh.id === one.id)), ...updated];
290
+ // Said once each: what updated itself, and what was taken out of this computer and why.
291
+ const told = [...updated, ...removed];
292
+ if (told.length) {
293
+ const news = [...(await marketNews(stateRoot)).filter((one) => !told.some((fresh) => fresh.id === one.id)), ...told];
236
294
  await writeAtomic(join(folder(stateRoot), 'updates.json'), JSON.stringify(news, null, 2));
237
295
  }
238
296
  return updated;
package/src/maturity.mjs CHANGED
@@ -1,5 +1,5 @@
1
- // SPDX-License-Identifier: AGPL-3.0-only
2
- // MADRE · © 2026 Jossue Alcalá · GNU AGPL v3 with additional terms (Section 7): ADDITIONAL-TERMS.md
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
3
  // How grown a room is, and how far from being worth training on.
4
4
  //
5
5
  // Pure functions. The room hands in what it has; nothing here reads a file or calls a model.
@@ -1,5 +1,5 @@
1
- // SPDX-License-Identifier: AGPL-3.0-only
2
- // MADRE · © 2026 Jossue Alcalá · GNU AGPL v3 with additional terms (Section 7): ADDITIONAL-TERMS.md
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
3
  // CONNECT MCP: the MCP servers a person adds to one project, for its agents (2026-10-14).
4
4
  //
5
5
  // Pure-ish helpers shared by the module (src/modules/mcp-connect.mjs), which owns the settings and
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- // SPDX-License-Identifier: AGPL-3.0-only
3
- // MADRE · © 2026 Jossue Alcalá · GNU AGPL v3 with additional terms (Section 7): ADDITIONAL-TERMS.md
2
+ // SPDX-License-Identifier: BUSL-1.1
3
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
4
4
  // MADRE GITHUB: a small MCP server (stdio, JSON-RPC 2.0) that lets an agent read the GitHub side
5
5
  // of this project — pull requests, issues, checks — and, in #4 AIRLOCK only, open a pull request,
6
6
  // open an issue or leave a comment. There is no MADRE in the middle: this process asks gh, or
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- // SPDX-License-Identifier: AGPL-3.0-only
3
- // MADRE · © 2026 Jossue Alcalá · GNU AGPL v3 with additional terms (Section 7): ADDITIONAL-TERMS.md
2
+ // SPDX-License-Identifier: BUSL-1.1
3
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
4
4
  // MADRE Image Studio: a tiny MCP server (stdio, JSON-RPC 2.0) that exposes one
5
5
  // tool, generate_image, backed by the Gemini API image models and the user's
6
6
  // own Gemini key. MADRE attaches it to the isolated homes of the CLIs that
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- // SPDX-License-Identifier: AGPL-3.0-only
3
- // MADRE · © 2026 Jossue Alcalá · GNU AGPL v3 with additional terms (Section 7): ADDITIONAL-TERMS.md
2
+ // SPDX-License-Identifier: BUSL-1.1
3
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
4
4
  // MADRE memory: a tiny MCP server (stdio, JSON-RPC 2.0) that lets the agent in
5
5
  // a turn consult the room's memory itself: everything said outside GHOST,
6
6
  // the distilled notes, exact stretches of the ledger, and AHP+'s project