@jossuealcala/madre 1.1.2 → 1.1.4

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 (166) hide show
  1. package/CHANGELOG.en.md +40 -1
  2. package/CHANGELOG.md +40 -1
  3. package/README.en.md +3 -3
  4. package/README.md +3 -3
  5. package/SECURITY.md +11 -6
  6. package/TRADEMARKS.md +6 -2
  7. package/bin/madre.mjs +76 -11
  8. package/docs/REFERENCE.md +16 -10
  9. package/docs/SDK.md +36 -9
  10. package/docs/en/REFERENCE.md +12 -8
  11. package/docs/en/SDK.md +34 -8
  12. package/docs/en/training/README.md +1 -1
  13. package/docs/sdk/connector-module.mjs +1 -1
  14. package/docs/sdk/hello-module.mjs +39 -4
  15. package/docs/training/README.md +1 -1
  16. package/docs/training/train.sh +3 -0
  17. package/habilidades/explicamelo-facil/HABILIDAD.md +19 -0
  18. package/habilidades/hojas-de-calculo/HABILIDAD.md +18 -0
  19. package/habilidades/mensajes-a-clientes/HABILIDAD.md +19 -0
  20. package/habilidades/publicaciones-para-redes/HABILIDAD.md +19 -0
  21. package/habilidades/resumen-y-pendientes/HABILIDAD.md +18 -0
  22. package/habilidades/tu-pagina-paso-a-paso/HABILIDAD.md +19 -0
  23. package/package.json +7 -4
  24. package/public/activity.js +66 -22
  25. package/public/app.js +4947 -894
  26. package/public/assets/brand/OFL-SpaceGrotesk.txt +93 -0
  27. package/public/assets/brand/SpaceGrotesk-latin-ext.woff2 +0 -0
  28. package/public/assets/brand/SpaceGrotesk-latin.woff2 +0 -0
  29. package/public/assets/brand/madre-app-180.png +0 -0
  30. package/public/assets/brand/madre-app-192.png +0 -0
  31. package/public/assets/brand/madre-app-512.png +0 -0
  32. package/public/assets/brand/madre-app.svg +1 -1
  33. package/public/assets/brand/madre-favicon.svg +1 -1
  34. package/public/attribution.js +29 -19
  35. package/public/auto-open.js +102 -0
  36. package/public/brands.js +36 -19
  37. package/public/changes.js +63 -0
  38. package/public/en.js +1085 -102
  39. package/public/es.js +2940 -1656
  40. package/public/i18n.js +11 -0
  41. package/public/index.html +31 -27
  42. package/public/loader.js +322 -117
  43. package/public/macroverso.js +57 -355
  44. package/public/manual-content.js +69 -9
  45. package/public/manual.js +21 -6
  46. package/public/market-view.js +298 -84
  47. package/public/market.js +25 -2
  48. package/public/mcp-catalog.js +7 -2
  49. package/public/missions.js +169 -0
  50. package/public/news-scenes.js +292 -0
  51. package/public/nostromo-engine.js +935 -654
  52. package/public/notices.js +78 -0
  53. package/public/notifications.js +119 -0
  54. package/public/power.js +1 -1
  55. package/public/provider-marks.js +170 -0
  56. package/public/provider-pick.js +147 -0
  57. package/public/resay.js +4 -0
  58. package/public/review-ask.js +16 -13
  59. package/public/routing.js +29 -3
  60. package/public/salas-mac.css +467 -47
  61. package/public/salas-mac.html +8 -5
  62. package/public/salas-mac.js +805 -109
  63. package/public/salas.css +2 -2
  64. package/public/salas.html +2 -2
  65. package/public/salas.js +1 -1
  66. package/public/starters.js +128 -0
  67. package/public/styles.css +3036 -340
  68. package/public/subscription.js +303 -0
  69. package/public/terms-field.js +170 -0
  70. package/public/terms.js +117 -19
  71. package/public/tips.js +158 -0
  72. package/public/tour-chapters.js +88 -88
  73. package/public/tour.js +364 -46
  74. package/public/troubleshooting.js +313 -27
  75. package/public/welcome-scene.js +446 -0
  76. package/public/welcome.js +827 -282
  77. package/src/adapters/claude.mjs +2 -1
  78. package/src/adapters/codex.mjs +2 -1
  79. package/src/adapters/cursor.mjs +9 -6
  80. package/src/adapters/gemini-rest.mjs +236 -0
  81. package/src/adapters/gemini.mjs +13 -7
  82. package/src/adapters/grok.mjs +290 -0
  83. package/src/adapters/madre.mjs +71 -23
  84. package/src/adapters/opencode.mjs +15 -2
  85. package/src/adapters/process.mjs +14 -3
  86. package/src/adapters/steps.mjs +176 -0
  87. package/src/app-invite.mjs +90 -0
  88. package/src/auth-probe.mjs +32 -0
  89. package/src/billing-key.mjs +8 -0
  90. package/src/billing.mjs +317 -0
  91. package/src/bridge/policy.mjs +1 -1
  92. package/src/capabilities.mjs +46 -10
  93. package/src/chats.mjs +44 -2
  94. package/src/checkpoint.mjs +119 -1
  95. package/src/codex-route.mjs +113 -0
  96. package/src/commands.mjs +5 -2
  97. package/src/credentials.mjs +46 -8
  98. package/src/dataset.mjs +18 -7
  99. package/src/directives.mjs +1 -0
  100. package/src/event-store.mjs +25 -2
  101. package/src/extensions.mjs +5 -1
  102. package/src/ficha.mjs +158 -0
  103. package/src/files.mjs +36 -2
  104. package/src/image-studio.mjs +13 -3
  105. package/src/install-metrics.mjs +9 -3
  106. package/src/lease.mjs +6 -1
  107. package/src/looks.mjs +4 -1
  108. package/src/market-check.mjs +1 -1
  109. package/src/market-remote.mjs +135 -1
  110. package/src/mcp/image-server.mjs +59 -90
  111. package/src/mcp/memory-server.mjs +10 -0
  112. package/src/memory-tools.mjs +3 -0
  113. package/src/memory.mjs +29 -4
  114. package/src/models.mjs +21 -3
  115. package/src/modules/ahp.mjs +10 -4
  116. package/src/modules/bishop-exam.mjs +41 -12
  117. package/src/modules/bishop.mjs +2 -2
  118. package/src/modules/choices.mjs +12 -10
  119. package/src/modules/fetch-alone.mjs +7 -0
  120. package/src/modules/github.mjs +6 -2
  121. package/src/modules/helpers.mjs +23 -5
  122. package/src/modules/image-providers.mjs +281 -0
  123. package/src/modules/image-studio.mjs +106 -39
  124. package/src/modules/index.mjs +61 -12
  125. package/src/modules/intents-observe.mjs +3 -1
  126. package/src/modules/isolated.mjs +160 -0
  127. package/src/modules/ollama.mjs +35 -6
  128. package/src/modules/playwright.mjs +78 -20
  129. package/src/modules/reminders.mjs +42 -2
  130. package/src/modules/ripley.mjs +2 -1
  131. package/src/modules/run-alone.mjs +122 -0
  132. package/src/modules/runs.mjs +11 -8
  133. package/src/modules/sdk.mjs +10 -3
  134. package/src/notices-key.mjs +8 -0
  135. package/src/notices.mjs +185 -0
  136. package/src/ollama.mjs +57 -15
  137. package/src/opencode-health.mjs +1 -1
  138. package/src/outbound.mjs +124 -13
  139. package/src/quota-sources.mjs +148 -3
  140. package/src/review-ask.mjs +55 -31
  141. package/src/room/archivist.mjs +30 -5
  142. package/src/room/busy.mjs +16 -0
  143. package/src/room/changes.mjs +79 -0
  144. package/src/room/control.mjs +36 -6
  145. package/src/room/economy.mjs +1 -1
  146. package/src/room/guard.mjs +39 -2
  147. package/src/room/prompt.mjs +49 -6
  148. package/src/room/vectors.mjs +7 -1
  149. package/src/room.mjs +181 -49
  150. package/src/router.mjs +1 -1
  151. package/src/runs.mjs +39 -0
  152. package/src/runtime-detection.mjs +46 -6
  153. package/src/salas.mjs +181 -18
  154. package/src/server.mjs +1101 -118
  155. package/src/service.mjs +116 -0
  156. package/src/setup-trouble.mjs +20 -1
  157. package/src/setup.mjs +1 -1
  158. package/src/skill-check.mjs +269 -0
  159. package/src/skills-import.mjs +128 -0
  160. package/src/skills.mjs +502 -0
  161. package/src/terms.mjs +23 -5
  162. package/src/tour.mjs +31 -5
  163. package/src/updates.mjs +47 -4
  164. package/src/web-preview.mjs +181 -0
  165. package/src/whats-new.mjs +121 -1
  166. package/src/rumbo.mjs +0 -337
@@ -0,0 +1,116 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
+ // MADRE as a service of the Linux it runs on (L-3, Carlos's server, 2026-11-04). Installed on a
4
+ // server, MADRE was started by hand and did not come back when the server restarted or MADRE
5
+ // fell: Carlos's own workaround was a script and a cron line. Here, from Home's Settings or
6
+ // `madre servicio`, it becomes a systemd unit of the person's own user (no root): Home starts when
7
+ // the computer does and again if it falls, and Home opens the projects that were open.
8
+ //
9
+ // What it starts is a small script MADRE writes in its own folder and rewrites every time Home
10
+ // opens: the same version that ran last, the way this copy was installed, and the PATH it had
11
+ // (the agents and Node of nvm live there). A server never updates itself on a restart; a version
12
+ // changes only when the person presses Restart with it.
13
+
14
+ import { execFile } from 'node:child_process';
15
+ import { access, chmod, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
16
+ import { homedir, userInfo } from 'node:os';
17
+ import { join } from 'node:path';
18
+
19
+ export const UNIT_NAME = 'madre.service';
20
+ const shq = (value) => `'${String(value).replace(/'/g, `'\\''`)}'`;
21
+ const quiet = (command, args) => new Promise((resolve) => {
22
+ try {
23
+ execFile(command, args, { timeout: 15000, windowsHide: true }, (error, stdout, stderr) => resolve({ ok: !error, stdout: String(stdout ?? '').trim(), stderr: String(stderr ?? '').trim() }));
24
+ } catch (error) { resolve({ ok: false, stdout: '', stderr: String(error?.message ?? error) }); }
25
+ });
26
+ const there = (file) => access(file).then(() => true, () => false);
27
+ const whoami = () => { try { return userInfo().username; } catch { return process.env.USER ?? ''; } };
28
+
29
+ export const unitFile = (home = homedir()) => join(home, '.config', 'systemd', 'user', UNIT_NAME);
30
+ export const launcherFile = (stateRoot) => join(stateRoot, 'servicio', 'arrancar.sh');
31
+
32
+ // The line Home starts with, by how this copy was installed. Inside a project's node_modules
33
+ // there is no command of its own to start Home with: none.
34
+ export function launcherScript({ install, name, version, execPath = process.execPath, script = process.argv[1], port = 4317, env = process.env }) {
35
+ const start = `lobby --no-open --port ${Number(port) || 4317}`;
36
+ let line = null;
37
+ if (install === 'npx') line = `exec npx -y ${shq(`${name}@${version}`)} ${start}`;
38
+ else if (install === 'global') line = `exec ${shq(String(name).split('/').pop())} ${start}`;
39
+ else if (install === 'source') line = `exec ${shq(execPath)} ${shq(script)} ${start}`;
40
+ if (!line) return null;
41
+ const kept = ['PATH', 'PULSE_HOME', 'LANG', 'OLLAMA_HOST'].filter((key) => env[key]).map((key) => `export ${key}=${shq(env[key])}`);
42
+ return ['#!/bin/sh', '# Written by MADRE every time Home opens (src/service.mjs); systemd starts it as madre.service.', ...kept, 'export MADRE_SERVICE=1', line, ''].join('\n');
43
+ }
44
+
45
+ export function unitText(launcher) {
46
+ return [
47
+ '[Unit]',
48
+ 'Description=MADRE',
49
+ 'After=network-online.target',
50
+ '',
51
+ '[Service]',
52
+ 'Type=simple',
53
+ `ExecStart=/bin/sh "${launcher}"`,
54
+ 'Restart=on-failure',
55
+ 'RestartSec=5',
56
+ // 2 is a start MADRE refused (Home already open, an option it does not know): trying again
57
+ // every five seconds would only say it again.
58
+ 'RestartPreventExitStatus=2',
59
+ // The projects run as processes of their own: Home falling or restarting does not take them down.
60
+ 'KillMode=process',
61
+ '',
62
+ '[Install]',
63
+ 'WantedBy=default.target',
64
+ '',
65
+ ].join('\n');
66
+ }
67
+
68
+ // Where it stands: whether this computer can have it at all, whether it is on, and whether the
69
+ // user's services run without a session open (linger), which a server restarted at night needs.
70
+ export async function serviceState({ platform = process.platform, home = homedir(), user = whoami(), run = quiet } = {}) {
71
+ if (platform !== 'linux') return { supported: false, why: 'linux' };
72
+ const systemd = await run('systemctl', ['--user', 'show-environment']);
73
+ if (!systemd.ok) return { supported: false, why: 'systemd' };
74
+ const enabled = (await run('systemctl', ['--user', 'is-enabled', UNIT_NAME])).stdout === 'enabled';
75
+ const active = (await run('systemctl', ['--user', 'is-active', UNIT_NAME])).stdout === 'active';
76
+ const linger = (await run('loginctl', ['show-user', user, '-p', 'Linger', '--value'])).stdout === 'yes';
77
+ return { supported: true, enabled: enabled && await there(unitFile(home)), active, linger, user, lingerCommand: linger ? null : `sudo loginctl enable-linger ${user}` };
78
+ }
79
+
80
+ // Turning it on: the script, the unit, enabled for the next start. It is not started now: Home is
81
+ // already open, and a second one would be refused. Linger is asked for without a password; where
82
+ // the system wants one, the command to type is said instead.
83
+ export async function enableService({ stateRoot, launcher, platform = process.platform, home = homedir(), user = whoami(), run = quiet } = {}) {
84
+ const before = await serviceState({ platform, home, user, run });
85
+ if (!before.supported) return before;
86
+ if (!launcher) return { ...before, refused: 'install' };
87
+ const script = launcherFile(stateRoot);
88
+ await mkdir(join(stateRoot, 'servicio'), { recursive: true });
89
+ await writeFile(script, launcher, { mode: 0o700 });
90
+ await chmod(script, 0o700);
91
+ await mkdir(join(home, '.config', 'systemd', 'user'), { recursive: true });
92
+ await writeFile(unitFile(home), unitText(script));
93
+ await run('systemctl', ['--user', 'daemon-reload']);
94
+ const enabled = await run('systemctl', ['--user', 'enable', UNIT_NAME]);
95
+ if (!enabled.ok) return { ...before, refused: 'enable', detail: enabled.stderr.slice(0, 300) };
96
+ if (!before.linger) await run('loginctl', ['enable-linger', user]);
97
+ return serviceState({ platform, home, user, run });
98
+ }
99
+
100
+ export async function disableService({ stateRoot, platform = process.platform, home = homedir(), user = whoami(), run = quiet } = {}) {
101
+ const before = await serviceState({ platform, home, user, run });
102
+ if (!before.supported) return before;
103
+ await run('systemctl', ['--user', 'disable', UNIT_NAME]);
104
+ await rm(unitFile(home), { force: true });
105
+ await run('systemctl', ['--user', 'daemon-reload']);
106
+ await rm(launcherFile(stateRoot), { force: true });
107
+ return serviceState({ platform, home, user, run });
108
+ }
109
+
110
+ // Every time Home opens with the service on: the script says the version and the PATH of now.
111
+ export async function refreshLauncher({ stateRoot, launcher, home = homedir() } = {}) {
112
+ if (!launcher || !(await there(unitFile(home))) || !(await there(launcherFile(stateRoot)))) return false;
113
+ if ((await readFile(launcherFile(stateRoot), 'utf8').catch(() => '')) === launcher) return false;
114
+ await writeFile(launcherFile(stateRoot), launcher, { mode: 0o700 });
115
+ return true;
116
+ }
@@ -6,7 +6,23 @@
6
6
  // a way out (salas-mac.js, TROUBLE_WORDS). A failure nothing here recognises is `unknown`, and the
7
7
  // page shows its last line as it was said rather than guess.
8
8
 
9
- const NETWORK = /ENOTFOUND|EAI_AGAIN|ECONNREFUSED|ECONNRESET|ETIMEDOUT|ENETUNREACH|getaddrinfo|socket hang up|network (is )?unreachable|unable to get local issuer|self[- ]signed certificate|request to https?:\/\/\S+ failed/i;
9
+ // A name nobody could look up (D-3): Go's resolver, which Ollama uses, says it this way. It is not
10
+ // a download that took too long, though it ends in «i/o timeout».
11
+ const DNS = /\blookup \S+ on \S+:53\b|no such host|server misbehaving|Temporary failure in name resolution/i;
12
+ // Go's words too, which Ollama prints (D-20): a connection that reached the server and did not
13
+ // finish is the network, not a download that took too long, though it ends in «timeout».
14
+ const NETWORK = /ENOTFOUND|EAI_AGAIN|ECONNREFUSED|ECONNRESET|ETIMEDOUT|ENETUNREACH|getaddrinfo|socket hang up|network (is )?unreachable|unable to get local issuer|self[- ]signed certificate|request to https?:\/\/\S+ failed|TLS handshake timeout|connection reset by peer|no route to host|connect: connection refused/i;
15
+ // Ollama dropped or closed the connection mid-download (D-21, undici's TypeError: terminated / UND_ERR_SOCKET):
16
+ // said in plain words as Ollama closing, not a download that took too long.
17
+ // Only Ollama's own words, or undici's line alone: «terminated» inside an installer's output (npm's
18
+ // «Process terminated») is not Ollama closing, and installing an agent read as Ollama's download.
19
+ // The download itself marks its failure `ollama-closed` (src/ollama.mjs, pullModel).
20
+ const OLLAMA_CLOSED = /Ollama closed the connection|Ollama cerró la conexión|^(?:TypeError: )?terminated$|other side closed|UND_ERR_SOCKET/im;
21
+ // Ollama's model registry answered, with an error of its own (D-29, a copy of 1.1.2 in WSL,
22
+ // 2026-11-06): «pull model manifest: 503: upstream connect error or disconnect/reset before headers.
23
+ // reset reason: connection timeout». The person's connection reached it; the server behind it did
24
+ // not answer. It ends in «timeout», and read as a download that took too long and that MADRE stopped.
25
+ const REGISTRY = /pull model manifest: 5\d\d\b|upstream connect error or disconnect\/reset before headers/i;
10
26
  const PERMISSION = /EACCES|EPERM|permission denied|operation not permitted|access is denied/i;
11
27
  const DISK = /ENOSPC|no space left/i;
12
28
  const NO_NPM = /spawn npm(\.cmd)? ENOENT|npm(\.cmd)?: (command )?not found|'npm' is not recognized|command not found: npm/i;
@@ -19,6 +35,9 @@ export function installTrouble(text = '') {
19
35
  if (NO_NPM.test(said)) return 'npm-missing';
20
36
  if (NO_ZSTD.test(said)) return 'zstd-missing';
21
37
  if (DISK.test(said)) return 'disk';
38
+ if (REGISTRY.test(said)) return 'registry';
39
+ if (DNS.test(said)) return 'dns';
40
+ if (OLLAMA_CLOSED.test(said)) return 'ollama-closed';
22
41
  if (NETWORK.test(said)) return 'network';
23
42
  if (PERMISSION.test(said)) return 'permission';
24
43
  if (TIMEOUT.test(said)) return 'timeout';
package/src/setup.mjs CHANGED
@@ -27,7 +27,7 @@ export function makePalette({ colors = stdout.isTTY && !process.env.NO_COLOR, de
27
27
  };
28
28
  const wrap = (open) => (text) => `${open}${text}`;
29
29
  return {
30
- phosphor: wrap(fg('#9bff66')),
30
+ phosphor: wrap(fg('#34d399')),
31
31
  dim: wrap(''),
32
32
  bold: wrap(''),
33
33
  danger: wrap(truecolor ? fg('#ff7b72') : ''),
@@ -0,0 +1,269 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
+ // THE CHECK OF A SKILL SOMEBODY SENDS (2026-11-08, H-5). A skill sent to the Market — a pull request
4
+ // adding habilidades/<id>/ to the public `madre-mercado` repository, curated: the author of MADRE
5
+ // reads it, signs it and publishes it — is checked here first, the same way on the sender's
6
+ // computer, in the repository's CI (`madre check-skill`) and in scripts/market-publish.mjs before
7
+ // it is signed.
8
+ //
9
+ // WHAT IS DIFFERENT FROM A MODULE'S CHECK (src/market-check.mjs). A module is code, and the question
10
+ // is what that code reaches for. A skill is WORDS THAT REACH AN AGENT — one that may be holding
11
+ // CONTROL, or the airlock open — so the question is what those words ask the agent to do. The attack
12
+ // is injection, and it has a shape: tell the agent to hide something from the person, to ignore the
13
+ // briefing, to raise its own permission, to send something somewhere. None of that can be caught
14
+ // perfectly by reading text, and nothing here pretends to: what has no honest reading is refused,
15
+ // everything else is written out for the person who reads it next.
16
+ //
17
+ // The one thing a skill may carry that could ever RUN is a program in guiones/, and MADRE never runs
18
+ // one: an agent does, with the permission of its turn, so below #4 AIRLOCK every one of them is
19
+ // inert. Each is still read for what it reaches for, because #4 exists.
20
+
21
+ import { copyFile, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
22
+ import { dirname, join } from 'node:path';
23
+ import { t } from './i18n.mjs';
24
+ import { MAX_BODY, MARKET_MAX_FILES, SKILL_FILES, pick, readSkill, runnable } from './skills.mjs';
25
+
26
+ // The shelves of the Market a skill may sit on (public/market.js, MARKET_SHELVES).
27
+ export const SKILL_SHELVES = ['no-terminal', 'create', 'organize', 'save', 'connect'];
28
+ // Licenses a skill's text may carry: open ones a person can read, share and reuse. The list a
29
+ // module's code may carry, plus the Creative Commons ones, because a skill is prose, not software.
30
+ export const SKILL_LICENSES = ['CC0-1.0', 'CC-BY-4.0', 'CC-BY-SA-4.0', 'MIT', 'Apache-2.0', 'AGPL-3.0-only', 'AGPL-3.0-or-later', 'GPL-3.0-only', 'GPL-3.0-or-later', 'ISC'];
31
+ const GITHUB = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/;
32
+ const SEMVER = /^\d+\.\d+\.\d+$/;
33
+
34
+ // WHAT THE WORDS ASK FOR. Refused: an instruction with no honest reading, whoever wrote it. Said:
35
+ // something a good skill may well contain, and a reviewer should still see.
36
+ //
37
+ // Each pattern is in Spanish and English because a skill is written in the language of whoever
38
+ // wrote it, and the room MADRE serves writes in both.
39
+ const REFUSED = [
40
+ ['hide', 'it tells the agent to keep something from the person', /\b(?:no\s+(?:le\s+)?(?:digas|menciones|avises|informes|cuentes)|sin\s+(?:decirle|avisarle|que\s+(?:lo\s+)?sepa)|a\s+escondidas|en\s+secreto)\b|\b(?:do\s*n[o']?t\s+(?:tell|mention|inform|say)|without\s+(?:telling|informing|letting\s+\w+\s+know)|keep\s+(?:it\s+)?(?:secret|hidden)|silently|behind\s+(?:their|his|her)\s+back)\b/i],
41
+ // `[^.]` and not `[^.\n]`: a line break between «ignora» and «las instrucciones» is one keystroke,
42
+ // and it used to be enough to walk past this (seen while writing H-5). A full stop ends the clause.
43
+ ['ignore', 'it tells the agent to ignore what MADRE told it', /\b(?:ignora|olvida|desobedece|salta(?:te)?|pasa\s+por\s+alto)\b[^.]{0,40}\b(?:instruccion|instrucciones|regla|reglas|aviso|indicaciones|anterior|anteriores|sistema|madre)\b|\b(?:ignore|disregard|forget|override|bypass)\b[^.]{0,40}\b(?:instruction|instructions|rule|rules|prompt|previous|above|system|briefing)\b/i],
44
+ ['permission', 'it tells the agent to give itself permission it was not given', /\b(?:sin\s+(?:pedir\s+)?permiso|aunque\s+no\s+(?:te\s+)?(?:lo\s+)?(?:den|hayan\s+dado)|aun\s+en\s+modo|sin\s+esperar\s+(?:la\s+)?confirmaci)\b|\b(?:without\s+(?:asking\s+(?:for\s+)?)?permission|even\s+if\s+(?:you\s+)?(?:are\s+)?not\s+allowed|regardless\s+of\s+(?:the\s+)?mode|do\s+not\s+wait\s+for\s+(?:the\s+)?(?:human|confirmation))\b/i],
45
+ ];
46
+ const SAID = [
47
+ ['network', 'it names a place on the internet', /\bhttps?:\/\/[^\s)"'<>]+/i],
48
+ ['secrets', 'it names a file or a folder where credentials live', /\.env\b|\bid_rsa\b|\bcredentials?\.(?:json|yml|yaml)\b|~\/\.ssh|\bkeychain\b|\bllavero\b|\bAPI[_ -]?KEY\b|\bSECRET[_ -]?KEY\b|\btoken\b/i],
49
+ ['commands', 'it hands the agent a command to run', /^\s*\$\s+\S|\b(?:curl|wget|npm\s+(?:i|install|run)|pnpm|yarn|pip\s+install|brew\s+install|sudo|chmod|rm\s+-rf|git\s+push|docker\s+run)\b/im],
50
+ ['airlock', 'it talks about the modes or the airlock', /#\s*[34]\b|\bairlock\b|\bmodo\s*[34]\b/i],
51
+ ['madre', "it names MADRE's own folders", /\.pulse\b|\.madre\b/],
52
+ ['identity', 'it tells the agent who to be instead of what to do', /\b(?:eres\s+un[ao]?|act[uú]a\s+como|comp[oó]rtate\s+como|haz\s+de\s+cuenta)\b|\b(?:you\s+are\s+an?\b|act\s+as\s+an?\b|pretend\s+(?:to\s+be|you)|roleplay)\b/i],
53
+ ];
54
+ // Read without accents, so «ignóra» is «ignora» and a pattern does not have to carry every spelling
55
+ // somebody might reach for. Line breaks are left alone: some patterns are about the start of a line.
56
+ const plain = (text) => String(text ?? '').normalize('NFD').replace(/\p{M}/gu, '');
57
+ const scan = (list, text) => list.filter(([, , pattern]) => pattern.test(plain(text))).map(([id, words]) => ({ id, words: t(words) }));
58
+ export const refusedIn = (text) => scan(REFUSED, text);
59
+ export const saidIn = (text) => scan(SAID, text);
60
+
61
+ // WHAT A PROGRAM REACHES FOR, read from its text, whatever language it is written in. Not a parser:
62
+ // the words that mean «this leaves the computer» or «this changes something», for a person to read.
63
+ const PROGRAM = [
64
+ ['network', 'talks to the network', /\b(?:curl|wget|fetch\s*\(|requests\.|urllib|httpx|http\.client|net\/http|socket|nc\s+-)/i],
65
+ ['commands', 'runs other programs', /\b(?:subprocess|os\.system|os\.popen|child_process|execFile|spawn\s*\(|system\s*\(|`[^`]*`|\$\()/],
66
+ ['files', 'reads or writes files', /\b(?:open\s*\(|readFile|writeFile|shutil|pathlib|os\.remove|unlink|rm\s+-|mv\s+|cp\s+|>>?\s*["'$\w./-])/],
67
+ ['environment', 'reads environment variables', /\b(?:os\.environ|process\.env|getenv|\$\{?[A-Z_]{3,}\}?)\b/],
68
+ ['install', 'installs something', /\b(?:pip\s+install|npm\s+(?:i|install)|apt(?:-get)?\s+install|brew\s+install|gem\s+install)\b/i],
69
+ ['elevate', 'asks for the computer\'s permission', /\b(?:sudo|chmod\s+\+x|doas)\b/],
70
+ ];
71
+ export const programReaches = (text) => PROGRAM.filter(([, , pattern]) => pattern.test(plain(text))).map(([id, words]) => ({ id, words: t(words) }));
72
+
73
+ // The programs of a folder MADRE could not read as a skill: walked here so a reviewer still sees
74
+ // them. Shallow and plain — readSkillFiles is the one that enforces the rules, and it already said
75
+ // no to this folder.
76
+ async function programsIn(dir) {
77
+ const { readdir } = await import('node:fs/promises');
78
+ const out = [];
79
+ const walk = async (at, prefix = '') => {
80
+ for (const entry of (await readdir(at, { withFileTypes: true }).catch(() => []))) {
81
+ if (entry.name.startsWith('.')) continue;
82
+ if (entry.isDirectory()) { await walk(join(at, entry.name), `${prefix}${entry.name}/`); continue; }
83
+ if (entry.isFile() && runnable(entry.name)) out.push(`${prefix}${entry.name}`);
84
+ }
85
+ };
86
+ await walk(dir);
87
+ return out.sort();
88
+ }
89
+
90
+ const words = (value, max) => {
91
+ const said = pick(value, 'es') ?? pick(value, 'en');
92
+ return typeof said === 'string' && said.trim() && said.length <= max;
93
+ };
94
+
95
+ // WHAT THE MARKET SHOWS, read from the skill's own header and from nowhere else. A skill is one
96
+ // file: asking for a second one with the same facts in JSON is work for the sender and one more
97
+ // place for the two to disagree. `name`, `line` and `summary` may be in one language or in both —
98
+ // a skill whose instructions are in Spanish should not have to invent an English summary to be
99
+ // published, and the Market shows whichever it has.
100
+ export function skillFaults(skill) {
101
+ const wrong = [];
102
+ const say = (field, said) => wrong.push({ field, words: said });
103
+ if (!skill) return [];
104
+ if (!SEMVER.test(skill.version ?? '')) say('version', t('version: like 1.0.0, in the header of HABILIDAD.md.'));
105
+ if (!SEMVER.test(skill.minMadre ?? '')) say('minMadre', t('minMadre: the oldest MADRE it works with, like 1.1.2.'));
106
+ if (!words(skill.name, 60)) say('name', t('name: what it is called, up to 60 characters. In one language, or in both: { es, en }.'));
107
+ if (!words(skill.when, 400)) say('when', t('when: in which cases it is for, naming the words people actually say. Without it, nobody\'s MADRE will bring it into a turn on its own.'));
108
+ if (!words(skill.line, 140)) say('line', t('line: what it does in one line, up to 140 characters.'));
109
+ if (!words(skill.summary, 1200)) say('summary', t('summary: what it does and when to use it, up to 1200 characters.'));
110
+ if (!SKILL_SHELVES.includes(skill.shelf)) say('shelf', t('shelf: one of {list}.', { list: SKILL_SHELVES.join(', ') }));
111
+ // The name is what the Market shows; the GitHub user is only how a pull request is signed, so it
112
+ // is read when it is there and never demanded.
113
+ if (!words(skill.author?.name ?? skill.author, 60)) say('author', t('author: your name, the one the Market shows.'));
114
+ if (skill.author?.github && !GITHUB.test(skill.author.github)) say('author', t('author: the GitHub user, if you give one, is just the user name.'));
115
+ if (!SKILL_LICENSES.includes(skill.license)) say('license', t('license: the one your text carries, one of {list}.', { list: SKILL_LICENSES.join(', ') }));
116
+ if (!skill.body?.trim()) say('body', t('Under the header go the instructions themselves.'));
117
+ else if (skill.body.length > MAX_BODY) say('body', t('The instructions are too long ({has} characters, at most {max}). What does not fit goes in referencias/.', { has: skill.body.length, max: MAX_BODY }));
118
+ // The Market's bound, not the disk's: there each file is a signed download of its own.
119
+ if (skill.files?.length > MARKET_MAX_FILES) say('files', t('A skill sent to the Market carries at most {max} files.', { max: MARKET_MAX_FILES }));
120
+ if (skill.unknown?.length) say('header', t('Fields MADRE does not know: {list}', { list: skill.unknown.join(', ') }));
121
+ return wrong;
122
+ }
123
+
124
+ // EVERYTHING AT ONCE, from the folder a pull request adds: the skill as MADRE reads it, what its
125
+ // words ask for, and what each of its programs reaches for. Nothing is run.
126
+ //
127
+ // THE RAW TEXT IS SCANNED EVEN WHEN THE SKILL DOES NOT READ. Otherwise a wrong version number would
128
+ // be enough to hide the body from the reviewer: MADRE would stop at «version: like 1.0.0» and never
129
+ // say a word about the page that tells an agent to keep things from the person. What a skill asks
130
+ // for is read first, from the bytes, and the header's own faults come after.
131
+ export async function checkSkillFolder(dir) {
132
+ let skill = null;
133
+ const faults = [];
134
+ let raw = '';
135
+ for (const candidate of SKILL_FILES) {
136
+ const text = await readFile(join(dir, candidate), 'utf8').catch(() => null);
137
+ if (text !== null) { raw = text; break; }
138
+ }
139
+ if (!raw) faults.push({ field: 'skill', words: t('There is no HABILIDAD.md to read.') });
140
+ try {
141
+ if (raw) skill = await readSkill(dir);
142
+ } catch (error) {
143
+ faults.push({ field: 'skill', words: t('MADRE cannot read it as a skill: {error}', { error: error.message }) });
144
+ }
145
+ faults.push(...skillFaults(skill));
146
+ const refused = refusedIn(raw);
147
+ for (const one of refused) faults.push({ field: 'body', words: t('Refused: {what}. A skill advises inside the mode of the turn; it never asks an agent to go around the person.', { what: one.words }) });
148
+ const said = saidIn(raw);
149
+ // Each program by name, with what it reaches for: the first thing a reviewer looks at, and the
150
+ // only part of a skill that could ever run.
151
+ const programs = [];
152
+ for (const path of skill?.scripts ?? (raw ? await programsIn(dir) : [])) {
153
+ const text = await readFile(join(dir, path), 'utf8').catch(() => '');
154
+ programs.push({ path, bytes: text.length, reaches: programReaches(text) });
155
+ }
156
+ const result = {
157
+ ok: faults.length === 0,
158
+ faults,
159
+ problems: faults.map((one) => one.words),
160
+ fields: [...new Set(faults.map((one) => one.field))],
161
+ skill: skill ? { id: skill.id, name: skill.name, version: skill.version, when: skill.when, chars: skill.body.length, files: skill.files.length } : null,
162
+ said, refused, programs,
163
+ };
164
+ return { ...result, markdown: skillMarkdown(result, skill) };
165
+ }
166
+
167
+ // The summary a reviewer reads in the pull request (the CI writes it to the job's summary). It says
168
+ // what the skill tells the agents, whole: it is a page, and reading it is the review.
169
+ export function skillMarkdown(result, skill = null) {
170
+ const lines = [];
171
+ const title = pick(skill?.name, 'es') ?? pick(skill?.name, 'en') ?? skill?.id ?? 'skill';
172
+ lines.push(`## ${result.ok ? '✅' : '❌'} ${title} ${skill?.version ?? ''}`.trim());
173
+ const author = pick(skill?.author?.name ?? skill?.author, 'es');
174
+ if (author) lines.push(t('By **{name}**{github} · {license} · shelf `{shelf}`', { name: author, github: skill?.author?.github ? ` (@${skill.author.github})` : '', license: skill?.license ?? t('no license'), shelf: skill?.shelf ?? '—' }));
175
+ if (result.problems.length) {
176
+ lines.push('', `### ${t('To fix before it can be reviewed')}`);
177
+ for (const one of result.problems) lines.push(`- ${one}`);
178
+ }
179
+ if (skill?.when) lines.push('', `### ${t('When it comes into a turn')}`, pick(skill.when, 'es') ?? pick(skill.when, 'en'));
180
+ if (skill?.body) {
181
+ lines.push('', `### ${t('What it tells the agents ({chars} characters)', { chars: skill.body.length })}`, '', '```markdown', skill.body.trim(), '```');
182
+ }
183
+ if (result.programs.length) {
184
+ lines.push('', `### ${t('Programs it carries ({n})', { n: result.programs.length })}`);
185
+ lines.push(t('MADRE never runs one: an agent does, and only in #4 AIRLOCK. Below it they do nothing.'));
186
+ for (const one of result.programs) lines.push(`- \`${one.path}\` · ${one.reaches.length ? one.reaches.map((reach) => reach.words).join(', ') : t('nothing beyond reading itself')}`);
187
+ }
188
+ const carried = (skill?.files ?? []).filter((file) => !file.runs && !SKILL_FILES.includes(file.path)).map((file) => file.path);
189
+ if (carried.length) lines.push('', `### ${t('It also carries')}`, carried.map((path) => `- \`${path}\``).join('\n'));
190
+ if (result.said.length) {
191
+ lines.push('', `### ${t('Worth a look')}`);
192
+ for (const one of result.said) lines.push(`- ${one.words}`);
193
+ }
194
+ lines.push('', `_${t('Checked by MADRE (src/skill-check.mjs). A skill is words that reach an agent which may be holding CONTROL, so a person reads them before they are signed: no reading of text catches every instruction written to go around you.')}_`);
195
+ return lines.join('\n');
196
+ }
197
+
198
+ // ---- SENDING ONE'S OWN (2026-11-08, H-8). A skill is one file, so sending it is not a form full of
199
+ // facts MADRE already knows: it is the two or three things only the person can say — which shelf,
200
+ // their name, which license — written into the skill's own header, beside what it already said.
201
+ // Ready, the folder is copied where they can find it, with the page GitHub offers for adding files
202
+ // without a terminal.
203
+ export const MARKET_REPO = 'jossuealcacao-exe/madre-mercado';
204
+ export const skillUploadUrl = (id) => `https://github.com/${MARKET_REPO}/upload/main/habilidades/${id}`;
205
+ export const submissionFolder = (stateRoot, id) => join(stateRoot, 'market', 'submissions', 'habilidades', id);
206
+
207
+ // What is still missing from its header, in the order a person fills it in. Only the fields nobody
208
+ // but them can answer: everything else the skill already says about itself.
209
+ export const ASKS = ['line', 'summary', 'shelf', 'author', 'license', 'minMadre'];
210
+ export function submissionDraft(skill, { madre = null } = {}) {
211
+ const author = skill.author?.name ? skill.author : null;
212
+ return {
213
+ id: skill.id,
214
+ version: skill.version ?? '1.0.0',
215
+ line: skill.line ?? null,
216
+ summary: skill.summary ?? null,
217
+ shelf: SKILL_SHELVES.includes(skill.shelf) ? skill.shelf : null,
218
+ author: author ? { name: author.name, github: author.github ?? null } : null,
219
+ license: SKILL_LICENSES.includes(skill.license) ? skill.license : null,
220
+ minMadre: skill.minMadre ?? madre ?? null,
221
+ // What it carries, so the form can say plainly that programs are read before anything is signed.
222
+ scripts: skill.scripts ?? [],
223
+ files: (skill.files ?? []).length,
224
+ };
225
+ }
226
+
227
+ // The header of the skill as it will be sent: what it said, with what the person answered written in.
228
+ // Only the fields of ASKS are ever touched — the instructions, the id and the version are theirs.
229
+ export function withEntry(text, entry = {}) {
230
+ const match = String(text ?? '').match(/^(---\r?\n)([\s\S]*?)(\r?\n---\r?\n?)/);
231
+ if (!match) throw new Error(t('A skill starts with its header between two «---» lines: id, name and when it is for.'));
232
+ const lines = match[2].split(/\r?\n/);
233
+ const said = (key, value) => {
234
+ const at = lines.findIndex((line) => new RegExp(`^${key}\\s*:`).test(line));
235
+ if (value === null || value === undefined || value === '') { if (at >= 0) lines.splice(at, 1); return; }
236
+ const written = `${key}: ${value}`;
237
+ if (at >= 0) lines[at] = written; else lines.push(written);
238
+ };
239
+ const words = (value) => (value && typeof value === 'object'
240
+ ? `{ ${['es', 'en'].filter((lang) => value[lang]).map((lang) => `${lang}: ${JSON.stringify(String(value[lang]))}`).join(', ')} }`
241
+ : JSON.stringify(String(value ?? '')));
242
+ if (entry.line !== undefined) said('line', entry.line ? words(entry.line) : null);
243
+ if (entry.summary !== undefined) said('summary', entry.summary ? words(entry.summary) : null);
244
+ if (entry.shelf !== undefined) said('shelf', entry.shelf || null);
245
+ if (entry.license !== undefined) said('license', entry.license || null);
246
+ if (entry.minMadre !== undefined) said('minMadre', entry.minMadre || null);
247
+ if (entry.author !== undefined) {
248
+ const name = entry.author?.name?.trim();
249
+ said('author', name ? `{ name: ${JSON.stringify(name)}${entry.author.github ? `, github: ${JSON.stringify(String(entry.author.github).replace(/^@/, ''))}` : ''} }` : null);
250
+ }
251
+ return `${match[1]}${lines.join('\n')}${match[3]}${String(text).slice(match[0].length)}`;
252
+ }
253
+
254
+ // The folder a pull request adds, written where the person can find it: the skill as it will be
255
+ // sent, checked once more the way the repository will check it.
256
+ export async function writeSubmission({ stateRoot, dir, entry }) {
257
+ const skill = await readSkill(dir);
258
+ const folder = submissionFolder(stateRoot, skill.id);
259
+ await rm(folder, { recursive: true, force: true }).catch(() => {});
260
+ for (const file of skill.files) {
261
+ const from = join(skill.dir, file.path);
262
+ const to = join(folder, file.path);
263
+ await mkdir(dirname(to), { recursive: true });
264
+ if (SKILL_FILES.includes(file.path)) await writeFile(to, withEntry(await readFile(from, 'utf8'), entry));
265
+ else await copyFile(from, to);
266
+ }
267
+ const checked = await checkSkillFolder(folder);
268
+ return { folder, id: skill.id, files: skill.files.map((file) => file.path), upload: skillUploadUrl(skill.id), ...checked };
269
+ }
@@ -0,0 +1,128 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
+ // BRINGING IN THE SKILLS A PERSON ALREADY HAS (2026-11-08, H-7). MADRE keeps every agent's own
4
+ // skills out of a turn on purpose — Claude is run with no setting sources and without the Skill
5
+ // tool, Codex with --ephemeral, OpenCode with --pure — so what somebody already wrote never reached
6
+ // the room. That is the hole this closes: their skills are read where their CLI keeps them, and the
7
+ // person brings over the ones they want.
8
+ //
9
+ // WHERE THEY LIVE, on this computer:
10
+ //
11
+ // ~/.claude/skills/<name>/SKILL.md written by hand
12
+ // ~/.claude/skills/synced/<bucket>/<name>/ synced from their Claude account
13
+ // <project>/.claude/skills/<name>/ this project's own
14
+ // ~/.codex/skills/<name>/SKILL.md Codex's, written by hand
15
+ //
16
+ // A folder whose name starts with a dot is skipped, and that is not only hygiene: Codex keeps its
17
+ // OWN machinery in ~/.codex/skills/.system/ (skill-installer, skill-creator, review-agent). Those
18
+ // are the CLI's, not the person's, and they are about installing skills into Codex — meaningless
19
+ // inside MADRE.
20
+ //
21
+ // NOTHING IS BROUGHT ON ITS OWN. Each is read, measured against what MADRE can hold, and listed
22
+ // with what would happen to it; the person picks. A skill that does not fit says why, with the
23
+ // number, because «it did not work» is not something a person can do anything with.
24
+
25
+ import { readFile, readdir } from 'node:fs/promises';
26
+ import { homedir } from 'node:os';
27
+ import { join } from 'node:path';
28
+ import { t } from './i18n.mjs';
29
+ import { ID, MAX_BODY, installSkill, loadSkills, pick, readSkill, readSkillFiles } from './skills.mjs';
30
+
31
+ // Each place, with who keeps it. `label` is the agent's own name, so the list says where a skill
32
+ // comes from in the words the person already knows.
33
+ export function skillSources({ home = homedir(), projectRoot = null } = {}) {
34
+ const out = [
35
+ { who: 'claude', label: 'Claude', dir: join(home, '.claude', 'skills'), buckets: join(home, '.claude', 'skills', 'synced') },
36
+ { who: 'codex', label: 'Codex', dir: join(home, '.codex', 'skills') },
37
+ ];
38
+ if (projectRoot) out.push({ who: 'claude', label: 'Claude', dir: join(projectRoot, '.claude', 'skills'), project: true });
39
+ return out;
40
+ }
41
+
42
+ const folders = async (dir) => (await readdir(dir, { withFileTypes: true }).catch(() => []))
43
+ .filter((entry) => entry.isDirectory() && !entry.name.startsWith('.'))
44
+ .map((entry) => entry.name)
45
+ .sort();
46
+
47
+ // EVERY SKILL THIS COMPUTER ALREADY HAS, read as MADRE would read it, with what would happen to it
48
+ // here. Reading installs nothing and changes nothing.
49
+ export async function findSkills({ home = homedir(), projectRoot = null, stateRoot = null } = {}) {
50
+ const have = stateRoot ? (await loadSkills({ stateRoot, projectRoot: projectRoot ?? stateRoot }).catch(() => ({ loaded: [] }))).loaded : [];
51
+ const found = [];
52
+ const seen = new Set();
53
+ for (const source of skillSources({ home, projectRoot })) {
54
+ const places = [];
55
+ for (const name of await folders(source.dir)) {
56
+ if (source.buckets && join(source.dir, name) === source.buckets) continue; // read below, one level deeper
57
+ places.push({ name, dir: join(source.dir, name) });
58
+ }
59
+ // The synced ones sit one folder deeper, under the id of whoever they were synced for.
60
+ if (source.buckets) {
61
+ for (const bucket of await folders(source.buckets)) {
62
+ for (const name of await folders(join(source.buckets, bucket))) places.push({ name, dir: join(source.buckets, bucket, name), synced: true });
63
+ }
64
+ }
65
+ for (const place of places) {
66
+ if (seen.has(place.dir)) continue;
67
+ seen.add(place.dir);
68
+ const one = { who: source.who, label: source.label, id: place.name, dir: place.dir, synced: Boolean(place.synced), project: Boolean(source.project) };
69
+ try {
70
+ const skill = await readSkill(place.dir);
71
+ found.push({
72
+ ...one, id: skill.id, fits: true,
73
+ name: skill.name, when: skill.when, version: skill.version, license: skill.license,
74
+ chars: skill.body.length, files: skill.files.length, scripts: skill.scripts,
75
+ // Its name is its own: one already here is replaced, and the person is told before it is.
76
+ replaces: have.find((kept) => kept.id === skill.id) ? true : false,
77
+ });
78
+ } catch (error) {
79
+ // Why, with the number: what a person can act on. The commonest by far is a page written
80
+ // for a CLI that puts no budget on it (measured on this computer: five of nine).
81
+ found.push({ ...one, fits: false, why: error.message, ...(await measure(place.dir)) });
82
+ }
83
+ }
84
+ }
85
+ return found.sort((a, b) => a.id.localeCompare(b.id));
86
+ }
87
+
88
+ // What is there, for one MADRE could not read: enough for the person to see how far off it is.
89
+ async function measure(dir) {
90
+ const { files } = await readSkillFiles(dir, { maxFiles: Number.MAX_SAFE_INTEGER, maxBytes: Number.MAX_SAFE_INTEGER }).catch(() => ({ files: [] }));
91
+ return { files: files.length, scripts: files.filter((file) => file.runs).map((file) => file.path) };
92
+ }
93
+
94
+ // BRINGING THEM OVER. Only the ones the person named, each copied whole into MADRE's own folder —
95
+ // its page, its references and its programs — with where it came from written beside it. A skill
96
+ // that cannot be read is never brought: it would be a folder nobody could switch on.
97
+ export async function importSkills({ ids = [], home = homedir(), stateRoot, projectRoot, scope = 'user' } = {}) {
98
+ const wanted = new Set(ids.map((id) => String(id)));
99
+ const available = await findSkills({ home, projectRoot, stateRoot });
100
+ const brought = [];
101
+ const left = [];
102
+ for (const one of available) {
103
+ if (!wanted.has(one.id)) continue;
104
+ if (!one.fits) { left.push({ id: one.id, why: one.why }); continue; }
105
+ try {
106
+ if (!ID.test(one.id)) throw new Error(t('«{id}» is not a name MADRE can use for a skill: lowercase letters, numbers and dashes, 2 to 40, starting with a letter.', { id: one.id }));
107
+ const { files } = await readSkillFiles(one.dir);
108
+ const read = [];
109
+ for (const file of files) read.push({ path: file.path, text: await readFile(join(one.dir, file.path)) });
110
+ const done = await installSkill({ files: read, scope, stateRoot, projectRoot, source: { kind: 'import', from: one.dir, who: one.who, id: one.id } });
111
+ brought.push({ id: done.id, name: pick(done.name, 'es') ?? done.id, who: one.who, files: done.files.length, scripts: done.scripts.length, chars: done.body.length });
112
+ } catch (error) {
113
+ left.push({ id: one.id, why: error.message });
114
+ }
115
+ }
116
+ // Asked for something that is not here: said, never passed over in silence.
117
+ for (const id of wanted) if (!available.some((one) => one.id === id)) left.push({ id, why: t('There is no skill called «{id}» on this computer.', { id }) });
118
+ return { brought, left };
119
+ }
120
+
121
+ // One line for the person, for the room and for the terminal alike.
122
+ export const importSaid = ({ brought = [], left = [] } = {}) => (brought.length
123
+ ? t('{n} brought in. {rest}', { n: brought.length, rest: left.length ? t('{m} could not come: read why beside each one.', { m: left.length }) : '' }).trim()
124
+ : t('None could come. Each one says why.'));
125
+
126
+ // How far from fitting a page is, for the line that says so. MADRE never shortens somebody's
127
+ // instructions on its own: changing what an agent is told, without being asked, is not a favour.
128
+ export const overBy = (chars) => Math.max(0, Number(chars ?? 0) - MAX_BODY);