@meiti/healer 0.2.2 → 0.2.5

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 (2) hide show
  1. package/mcp/servidor.mjs +66 -2
  2. package/package.json +1 -1
package/mcp/servidor.mjs CHANGED
@@ -14,7 +14,7 @@ import path from 'node:path';
14
14
  import crypto from 'node:crypto';
15
15
  import readline from 'node:readline';
16
16
 
17
- const VERSION = '0.3.6';
17
+ const VERSION = '0.3.9';
18
18
  const API = (process.env.HEALER_API_URL || 'https://healer-api.meiti.dev').replace(/\/$/, '');
19
19
  const leerClave = () => String(process.env.CLAUDE_PLUGIN_OPTION_API_KEY || '').trim();
20
20
  const ESTADO = path.join(os.tmpdir(), 'healer-claude-code');
@@ -137,6 +137,43 @@ async function revisar({ ruta, nivel, tests }) {
137
137
  ].join('\n');
138
138
  }
139
139
 
140
+ // 🖥️ [REVISIÓN DE PANTALLA, 2026-11-15] Healer levanta la app en su sandbox y revisa sus páginas, sin reparar ni usar IA.
141
+ async function revisarPantalla({ ruta, start_command, port, pages }) {
142
+ const raiz = path.resolve(ruta || process.cwd());
143
+ if (!fs.existsSync(raiz) || !fs.statSync(raiz).isDirectory()) throw new Error(`Folder not found: ${raiz}.`);
144
+ const { files, total, omitidos } = archivosDelProyecto(raiz);
145
+ if (!Object.keys(files).length) throw new Error('No text files to send were found in that folder.');
146
+ const appId = `claude-code/${path.basename(raiz).replace(/[^\w.-]/g, '-').slice(0, 60) || 'proyecto'}`;
147
+ // Sin start_command, port ni pages, Healer los busca (.healer.json "screen", la última corrida que funcionó, package.json).
148
+ const envio = await api('POST', '/v1/screen', { files, app_id: appId, start_command: start_command || undefined, port: port || undefined, pages: Array.isArray(pages) && pages.length ? pages : undefined });
149
+ return [
150
+ `Screen review started: job ${envio.job_id}.`,
151
+ `${Object.keys(files).length} files, ${Math.round(total / 1024)} KB${omitidos ? `, ${omitidos} skipped (binary or too large)` : ''}.`,
152
+ 'Healer starts the app in its sandbox and checks the pages, without repairing anything. It usually takes under a minute: check with healer_resultado.'
153
+ ].join('\n');
154
+ }
155
+
156
+ // El informe de una revisión de pantalla: estado de cada página, lo que se esperaba y la prueba (igual que el conector remoto).
157
+ function informePantalla(r) {
158
+ const lineas = [];
159
+ const titulo = { checked: 'Screen review finished.', did_not_start: 'The app did not start, so no page could be checked.', unsupported_stack: 'Unsupported stack: no supported language was found to install and start the app.' }[r.status] || r.status;
160
+ lineas.push(`Result: ${titulo}`, `Summary: ${r.message}`);
161
+ if (r.start) lineas.push(`Started with: "${r.start.command}" on port ${r.start.port} · source: ${r.start.source} (${r.start.detail}) · ${r.start.verified ? 'verified: the app answered' : 'not verified: the app did not answer'}.`);
162
+ if (r.server_log) lineas.push('Server log (last lines):', ...String(r.server_log).split('\n').slice(-25).map((l) => ` ${l}`));
163
+ if (r.ms) lineas.push(`Time: ${Math.round((r.ms.total || 0) / 1000)} s (install ${Math.round((r.ms.install || 0) / 1000)} s, start ${Math.round((r.ms.start || 0) / 1000)} s, pages ${Math.round((r.ms.pages || 0) / 1000)} s).`);
164
+ for (const pg of r.pages || []) {
165
+ lineas.push('', `Page ${pg.path}: ${pg.state}${pg.http ? ` (HTTP ${pg.http})` : ''}${pg.title ? `, title "${pg.title}"` : ''}`);
166
+ if (pg.reasons?.length) lineas.push(` Why: ${pg.reasons.join('; ')}`);
167
+ for (const e of pg.expectations || []) lineas.push(` ${e.answer} ${JSON.stringify(e.expectation)} · ${e.proof}`);
168
+ if (pg.failed_requests?.length) lineas.push(` Requests that failed: ${pg.failed_requests.join(', ')}`);
169
+ if (pg.page_errors?.length) lineas.push(` Page errors: ${pg.page_errors.slice(0, 5).join(' | ')}`);
170
+ if (pg.visual_issues?.length) lineas.push(` Visual issues: ${pg.visual_issues.slice(0, 8).map((v) => `${v.type}${v.element ? ` at ${v.element}` : ''}: ${v.detail}`).join(' | ')}`);
171
+ if (pg.map) lineas.push(' Screen map:', ...String(pg.map).split('\n').slice(0, 60).map((l) => ` ${l}`));
172
+ }
173
+ lineas.push('', 'CANNOT PROVE means the page did not load or is not the expected one: report it as such, never as "it is not there". Nothing was changed in the project.');
174
+ return lineas.join('\n');
175
+ }
176
+
140
177
  async function resultado({ job_id, esperar_segundos }) {
141
178
  const limite = Date.now() + Math.min(Math.max(Number(esperar_segundos) || 45, 0), 50) * 1000;
142
179
  let r;
@@ -148,6 +185,7 @@ async function resultado({ job_id, esperar_segundos }) {
148
185
  // El servidor manda en qué va (proyecto, minutos, etapa, lo hecho): se muestra eso en vez de solo "running".
149
186
  if (r.status === 'queued' || r.status === 'running') return `${r.progress?.message || `Still ${r.status}.`}\nCall healer_resultado again in a moment.\nJob id: ${job_id}`;
150
187
  if (r.status === 'error') return `Healer could not finish: ${r.error || 'unknown error'}.`;
188
+ if (r.tipo === 'pantalla') return informePantalla(r);
151
189
 
152
190
  const meta = fs.existsSync(archivoDeTrabajo(job_id)) ? JSON.parse(fs.readFileSync(archivoDeTrabajo(job_id), 'utf8')) : null;
153
191
  const cambiados = r.changed_files || [];
@@ -157,7 +195,18 @@ async function resultado({ job_id, esperar_segundos }) {
157
195
  const lineas = [];
158
196
  const titulo = { production_ready: 'Production ready: every check passes.', unresolved: r.partial_fix ? 'Partial delivery: some failures fixed, some remain.' : 'Unresolved: Healer could not leave every check passing.', unsupported_stack: 'Unsupported stack: no supported language was found to verify.' }[r.status] || r.status;
159
197
  lineas.push(`Result: ${titulo}`);
160
- if (r.failures) lineas.push(`Failures: ${r.failures.found ?? '?'} found, ${r.failures.fixed ?? '?'} fixed.${(r.failures.remaining || []).length ? ` Remaining: ${r.failures.remaining.map((f) => `[${f.origen}] ${String(f.detalle).slice(0, 160)}`).join(' | ')}` : ''}`);
198
+ // 📋 [2026-11-14, pedido del usuario: "el usuario no ve lo que vemos, no lo demos por hecho"] El informe de Healer (report):
199
+ // qué se reparó, tests antes y después, y cada pendiente con qué es, por qué quedó y qué hace falta. Sin informe (Healer
200
+ // de antes), la línea de fallas de siempre.
201
+ if (r.report) {
202
+ lineas.push(`Summary: ${r.report.headline}`);
203
+ for (const x of r.report.fixed || []) lineas.push(`Fixed: ${x}`);
204
+ if ((r.report.pending || []).length) {
205
+ lineas.push('Pending (tell the user every item and what it needs; they decide whether to send it again or handle it themselves):');
206
+ for (const p of r.report.pending) lineas.push(`- [${p.check}] ${p.what} Why: ${p.why} Needs: ${p.needs}`);
207
+ }
208
+ for (const x of r.report.support_updates || []) lineas.push(`Optional support update: ${x}`);
209
+ } else if (r.failures) lineas.push(`Failures: ${r.failures.found ?? '?'} found, ${r.failures.fixed ?? '?'} fixed.${(r.failures.remaining || []).length ? ` Remaining: ${r.failures.remaining.map((f) => `[${f.origen}] ${String(f.detalle).slice(0, 160)}`).join(' | ')}` : ''}`);
161
210
  if (r.audit_report?.vulnerabilities_found) lineas.push(`Security: ${r.audit_report.vulnerabilities_found} findings (${(r.audit_report.findings || []).slice(0, 5).map((f) => `${f.archivo}:${f.linea} ${f.severidad}`).join(', ')}).`);
162
211
  if (r.pentagono_report?.puntaje != null) lineas.push(`Quality score (Pentagon): ${r.pentagono_report.puntaje}/100.`);
163
212
  if ((r.pending_improvements || []).length) lineas.push(`Non-blocking suggestions: ${r.pending_improvements.length} (not applied).`);
@@ -290,6 +339,21 @@ const HERRAMIENTAS = [
290
339
  inputSchema: { type: 'object', properties: { job_id: { type: 'string' }, archivos: { type: 'array', items: { type: 'string' }, description: 'Optional: paths (as listed by healer_resultado) of the only files to write.' } }, required: ['job_id'] },
291
340
  run: aplicar
292
341
  },
342
+ {
343
+ name: 'healer_revisar_pantalla',
344
+ description: 'Start the app in Healer\'s isolated sandbox and check what its pages really show, WITHOUT repairing anything and without AI (much faster than a full review). Per page: the load state (LOADED, DID NOT LOAD with the reason, or NOT THE EXPECTED PAGE), failed requests, measured visual issues, a text map of the screen, and YES / NO / CANNOT PROVE for each expectation. Only the folder is needed: without start_command and port, Healer finds how to start the app (.healer.json "screen", the command that worked last time, or package.json / the Python entry file) and says where it came from; without pages it checks "/". You set the expectations from what you know about the code. Returns a job id; then call healer_resultado.',
345
+ inputSchema: {
346
+ type: 'object',
347
+ properties: {
348
+ ruta: { type: 'string', description: 'Project folder. Defaults to the current working directory.' },
349
+ start_command: { type: 'string', description: 'Optional: the command that starts the app, e.g. "npm run dev". It must listen on 0.0.0.0. Leave it out and Healer finds it.' },
350
+ port: { type: 'number', description: 'Optional: the port the app listens on (1024-65535). Leave it out and Healer finds it.' },
351
+ pages: { type: 'array', items: { type: 'object' }, description: 'Optional (default: [{ "path": "/" }]). Up to 10 pages: [{ "path": "/", "expect_page": { "title_is": "My App" }, "expectations": [{ "exists": "Save" }, { "not_exists": "Delete all" }, { "text": "Total", "contains": "0" }, { "no_issues": true }], "storage": { "session": "test-token" }, "wait_for": "Dashboard", "width": 375 }]. Test accounts only in storage.' }
352
+ },
353
+ required: []
354
+ },
355
+ run: revisarPantalla
356
+ },
293
357
  {
294
358
  name: 'healer_informar_decision',
295
359
  description: 'Tell Healer which of its changes the user decided not to apply (or applied by hand). healer_aplicar reports this by itself; use this when the user applies none, or edits by hand. Healer stores only fingerprints of the file paths, never code.',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meiti/healer",
3
- "version": "0.2.2",
3
+ "version": "0.2.5",
4
4
  "description": "Connect Healer to Claude Code (and any MCP agent) in a minute: a short code, one click in the browser, done.",
5
5
  "type": "module",
6
6
  "bin": {