@meiti/healer 0.2.1 → 0.2.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 (2) hide show
  1. package/mcp/servidor.mjs +75 -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.5';
17
+ const VERSION = '0.3.8';
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,39 @@ 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
+ const envio = await api('POST', '/v1/screen', { files, app_id: appId, start_command, port, pages });
148
+ return [
149
+ `Screen review started: job ${envio.job_id}.`,
150
+ `${Object.keys(files).length} files, ${Math.round(total / 1024)} KB${omitidos ? `, ${omitidos} skipped (binary or too large)` : ''}.`,
151
+ 'Healer starts the app in its sandbox and checks the pages, without repairing anything. It usually takes under a minute: check with healer_resultado.'
152
+ ].join('\n');
153
+ }
154
+
155
+ // 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).
156
+ function informePantalla(r) {
157
+ const lineas = [];
158
+ 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;
159
+ lineas.push(`Result: ${titulo}`, `Summary: ${r.message}`);
160
+ 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).`);
161
+ for (const pg of r.pages || []) {
162
+ lineas.push('', `Page ${pg.path}: ${pg.state}${pg.http ? ` (HTTP ${pg.http})` : ''}${pg.title ? `, title "${pg.title}"` : ''}`);
163
+ if (pg.reasons?.length) lineas.push(` Why: ${pg.reasons.join('; ')}`);
164
+ for (const e of pg.expectations || []) lineas.push(` ${e.answer} ${JSON.stringify(e.expectation)} · ${e.proof}`);
165
+ if (pg.failed_requests?.length) lineas.push(` Requests that failed: ${pg.failed_requests.join(', ')}`);
166
+ 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(' | ')}`);
167
+ if (pg.map) lineas.push(' Screen map:', ...String(pg.map).split('\n').slice(0, 60).map((l) => ` ${l}`));
168
+ }
169
+ 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.');
170
+ return lineas.join('\n');
171
+ }
172
+
140
173
  async function resultado({ job_id, esperar_segundos }) {
141
174
  const limite = Date.now() + Math.min(Math.max(Number(esperar_segundos) || 45, 0), 50) * 1000;
142
175
  let r;
@@ -148,6 +181,7 @@ async function resultado({ job_id, esperar_segundos }) {
148
181
  // El servidor manda en qué va (proyecto, minutos, etapa, lo hecho): se muestra eso en vez de solo "running".
149
182
  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
183
  if (r.status === 'error') return `Healer could not finish: ${r.error || 'unknown error'}.`;
184
+ if (r.tipo === 'pantalla') return informePantalla(r);
151
185
 
152
186
  const meta = fs.existsSync(archivoDeTrabajo(job_id)) ? JSON.parse(fs.readFileSync(archivoDeTrabajo(job_id), 'utf8')) : null;
153
187
  const cambiados = r.changed_files || [];
@@ -157,7 +191,18 @@ async function resultado({ job_id, esperar_segundos }) {
157
191
  const lineas = [];
158
192
  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
193
  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(' | ')}` : ''}`);
194
+ // 📋 [2026-11-14, pedido del usuario: "el usuario no ve lo que vemos, no lo demos por hecho"] El informe de Healer (report):
195
+ // qué se reparó, tests antes y después, y cada pendiente con qué es, por qué quedó y qué hace falta. Sin informe (Healer
196
+ // de antes), la línea de fallas de siempre.
197
+ if (r.report) {
198
+ lineas.push(`Summary: ${r.report.headline}`);
199
+ for (const x of r.report.fixed || []) lineas.push(`Fixed: ${x}`);
200
+ if ((r.report.pending || []).length) {
201
+ lineas.push('Pending (tell the user every item and what it needs; they decide whether to send it again or handle it themselves):');
202
+ for (const p of r.report.pending) lineas.push(`- [${p.check}] ${p.what} Why: ${p.why} Needs: ${p.needs}`);
203
+ }
204
+ for (const x of r.report.support_updates || []) lineas.push(`Optional support update: ${x}`);
205
+ } 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
206
  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
207
  if (r.pentagono_report?.puntaje != null) lineas.push(`Quality score (Pentagon): ${r.pentagono_report.puntaje}/100.`);
163
208
  if ((r.pending_improvements || []).length) lineas.push(`Non-blocking suggestions: ${r.pending_improvements.length} (not applied).`);
@@ -254,9 +299,16 @@ async function aplicar({ job_id, archivos }) {
254
299
  }
255
300
  fs.writeFileSync(archivo, JSON.stringify({ ...t, aplicado: new Date().toISOString(), aplicados: elegidos }));
256
301
  const descartados = t.changed_files.filter((c) => !elegidos.includes(c));
302
+ // Le cuenta a Healer qué se aplicó y qué no (solo para medir qué cambios valen la pena; si falla, no importa).
303
+ await api('POST', `/v1/repair/${encodeURIComponent(job_id)}/decision`, { aplicados: elegidos, descartados, via: 'plugin_local' }).catch(() => {});
257
304
  return `Applied: ${elegidos.length} file(s) written (${elegidos.join(', ')}).${descartados.length ? ` Left out as requested: ${descartados.join(', ')}.` : ''} Review the diff with git before committing.`;
258
305
  }
259
306
 
307
+ async function informarDecision({ job_id, aplicados = [], descartados = [] }) {
308
+ const r = await api('POST', `/v1/repair/${encodeURIComponent(job_id)}/decision`, { aplicados, descartados, via: 'agente' });
309
+ return `Thanks: recorded ${r.registrados ?? 0} decision(s) (${aplicados.length} applied, ${descartados.length} left out).`;
310
+ }
311
+
260
312
  const HERRAMIENTAS = [
261
313
  {
262
314
  name: 'healer_revisar',
@@ -282,6 +334,27 @@ const HERRAMIENTAS = [
282
334
  description: 'Write Healer\'s proposed changes into the project. Only call it after the user agreed. Pass "archivos" to write only the files the user approved (the rest are left out). It refuses any file that changed since it was sent.',
283
335
  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'] },
284
336
  run: aplicar
337
+ },
338
+ {
339
+ name: 'healer_revisar_pantalla',
340
+ 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. You set the expectations from what you know about the code. Returns a job id; then call healer_resultado.',
341
+ inputSchema: {
342
+ type: 'object',
343
+ properties: {
344
+ ruta: { type: 'string', description: 'Project folder. Defaults to the current working directory.' },
345
+ start_command: { type: 'string', description: 'The command that starts the app, e.g. "npm run dev". It must listen on 0.0.0.0.' },
346
+ port: { type: 'number', description: 'The port the app listens on (1024-65535).' },
347
+ pages: { type: 'array', items: { type: 'object' }, description: '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.' }
348
+ },
349
+ required: ['start_command', 'port', 'pages']
350
+ },
351
+ run: revisarPantalla
352
+ },
353
+ {
354
+ name: 'healer_informar_decision',
355
+ 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.',
356
+ inputSchema: { type: 'object', properties: { job_id: { type: 'string' }, aplicados: { type: 'array', items: { type: 'string' } }, descartados: { type: 'array', items: { type: 'string' } } }, required: ['job_id'] },
357
+ run: informarDecision
285
358
  }
286
359
  ];
287
360
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meiti/healer",
3
- "version": "0.2.1",
3
+ "version": "0.2.4",
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": {