@meiti/healer 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/mcp/servidor.mjs +28 -12
- package/package.json +2 -2
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.
|
|
17
|
+
const VERSION = '0.3.5';
|
|
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');
|
|
@@ -145,7 +145,8 @@ async function resultado({ job_id, esperar_segundos }) {
|
|
|
145
145
|
if (!['queued', 'running'].includes(r.status) || Date.now() >= limite) break;
|
|
146
146
|
await new Promise((ok) => setTimeout(ok, 5000));
|
|
147
147
|
}
|
|
148
|
-
|
|
148
|
+
// El servidor manda en qué va (proyecto, minutos, etapa, lo hecho): se muestra eso en vez de solo "running".
|
|
149
|
+
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}`;
|
|
149
150
|
if (r.status === 'error') return `Healer could not finish: ${r.error || 'unknown error'}.`;
|
|
150
151
|
|
|
151
152
|
const meta = fs.existsSync(archivoDeTrabajo(job_id)) ? JSON.parse(fs.readFileSync(archivoDeTrabajo(job_id), 'utf8')) : null;
|
|
@@ -164,8 +165,13 @@ async function resultado({ job_id, esperar_segundos }) {
|
|
|
164
165
|
lineas.push('No file changes to apply.');
|
|
165
166
|
return lineas.join('\n');
|
|
166
167
|
}
|
|
167
|
-
|
|
168
|
-
lineas.push(
|
|
168
|
+
// Qué arregló en cada archivo, para que el usuario elija: se puede aplicar solo una parte (igual que el conector remoto).
|
|
169
|
+
lineas.push(`Proposed changes in ${cambiados.length} file(s). What each one fixes:`);
|
|
170
|
+
for (const ruta of cambiados) {
|
|
171
|
+
const motivos = (r.history || []).filter((h) => h?.file === ruta).map((h) => String(h.error || '').replace(/\s+/g, ' ').slice(0, 200)).filter(Boolean);
|
|
172
|
+
lineas.push(`- ${ruta}${motivos.length ? `\n ${motivos.map((m) => `· ${m}`).join('\n ')}` : ''}`);
|
|
173
|
+
}
|
|
174
|
+
lineas.push('Nothing has been written. Review each file against the rest of the project, show this to the user and apply only what they agree to, with healer_aplicar (pass "archivos" to apply only some files).');
|
|
169
175
|
if (meta) {
|
|
170
176
|
for (const ruta of cambiados) {
|
|
171
177
|
const local = path.join(meta.raiz, ruta);
|
|
@@ -220,27 +226,35 @@ function diffDe(antes, despues) {
|
|
|
220
226
|
return salida.join('\n').slice(0, 12000);
|
|
221
227
|
}
|
|
222
228
|
|
|
223
|
-
async function aplicar({ job_id }) {
|
|
229
|
+
async function aplicar({ job_id, archivos }) {
|
|
224
230
|
const archivo = archivoDeTrabajo(job_id);
|
|
225
231
|
if (!fs.existsSync(archivo)) throw new Error('No proposal stored for that job: call healer_resultado first.');
|
|
226
232
|
const t = JSON.parse(fs.readFileSync(archivo, 'utf8'));
|
|
227
233
|
if (!t.changed_files?.length) return 'That job has no changes to apply.';
|
|
234
|
+
// Solo lo que el usuario aprobó (si mandó "archivos"); un nombre que Healer no cambió frena todo.
|
|
235
|
+
const pedidos = Array.isArray(archivos) && archivos.length ? archivos.map(String) : null;
|
|
236
|
+
if (pedidos) {
|
|
237
|
+
const ajenos = pedidos.filter((p) => !t.changed_files.includes(p));
|
|
238
|
+
if (ajenos.length) throw new Error(`These are not among the files Healer changed: ${ajenos.join(', ')}. Changed files: ${t.changed_files.join(', ')}.`);
|
|
239
|
+
}
|
|
240
|
+
const elegidos = pedidos ?? t.changed_files;
|
|
228
241
|
// La base tiene que coincidir: si el usuario tocó un archivo después de mandarlo, ese no se pisa.
|
|
229
|
-
const distintos =
|
|
242
|
+
const distintos = elegidos.filter((ruta) => {
|
|
230
243
|
const local = path.join(t.raiz, ruta);
|
|
231
244
|
const actual = fs.existsSync(local) ? fs.readFileSync(local, 'utf8') : null;
|
|
232
245
|
return t.base_hashes[ruta] && (actual === null || sha256(actual) !== t.base_hashes[ruta]);
|
|
233
246
|
});
|
|
234
247
|
if (distintos.length) return `Not applied: these files changed since they were sent to Healer: ${distintos.join(', ')}. Send the project again with healer_revisar.`;
|
|
235
|
-
for (const ruta of
|
|
248
|
+
for (const ruta of elegidos) {
|
|
236
249
|
const destino = path.resolve(t.raiz, ruta);
|
|
237
250
|
if (!destino.startsWith(t.raiz + path.sep)) throw new Error(`Path outside the project: ${ruta}`);
|
|
238
251
|
if (typeof t.files[ruta] !== 'string') continue;
|
|
239
252
|
fs.mkdirSync(path.dirname(destino), { recursive: true });
|
|
240
253
|
fs.writeFileSync(destino, t.files[ruta]);
|
|
241
254
|
}
|
|
242
|
-
fs.writeFileSync(archivo, JSON.stringify({ ...t, aplicado: new Date().toISOString() }));
|
|
243
|
-
|
|
255
|
+
fs.writeFileSync(archivo, JSON.stringify({ ...t, aplicado: new Date().toISOString(), aplicados: elegidos }));
|
|
256
|
+
const descartados = t.changed_files.filter((c) => !elegidos.includes(c));
|
|
257
|
+
return `Applied: ${elegidos.length} file(s) written (${elegidos.join(', ')}).${descartados.length ? ` Left out as requested: ${descartados.join(', ')}.` : ''} Review the diff with git before committing.`;
|
|
244
258
|
}
|
|
245
259
|
|
|
246
260
|
const HERRAMIENTAS = [
|
|
@@ -265,8 +279,8 @@ const HERRAMIENTAS = [
|
|
|
265
279
|
},
|
|
266
280
|
{
|
|
267
281
|
name: 'healer_aplicar',
|
|
268
|
-
description: 'Write Healer\'s proposed changes into the project. Only call it after the user agreed. It refuses any file that changed since it was sent.',
|
|
269
|
-
inputSchema: { type: 'object', properties: { job_id: { type: 'string' } }, required: ['job_id'] },
|
|
282
|
+
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
|
+
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'] },
|
|
270
284
|
run: aplicar
|
|
271
285
|
}
|
|
272
286
|
];
|
|
@@ -282,7 +296,9 @@ readline.createInterface({ input: process.stdin }).on('line', async (linea) => {
|
|
|
282
296
|
if (m.id === undefined) return; // notificaciones (initialized, cancelled): nada que responder
|
|
283
297
|
try {
|
|
284
298
|
if (m.method === 'initialize') {
|
|
285
|
-
|
|
299
|
+
// Mismo ícono y título que el conector remoto, para los clientes que los muestran (MCP 2025-11-25).
|
|
300
|
+
const icono = (lado) => ({ src: `https://healer-api.meiti.dev/icono-${lado}.png?v=1`, mimeType: 'image/png', sizes: [`${lado}x${lado}`] });
|
|
301
|
+
return responder(m.id, { protocolVersion: m.params?.protocolVersion || '2025-06-18', capabilities: { tools: {} }, serverInfo: { name: 'healer', title: 'Healer', version: VERSION, websiteUrl: 'https://meiti.dev/healer', icons: [icono(512), icono(192), icono(64)] } });
|
|
286
302
|
}
|
|
287
303
|
if (m.method === 'ping') return responder(m.id, {});
|
|
288
304
|
if (m.method === 'tools/list') return responder(m.id, { tools: HERRAMIENTAS.map(({ run, ...h }) => h) });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meiti/healer",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
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": {
|
|
@@ -32,6 +32,6 @@
|
|
|
32
32
|
],
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"scripts": {
|
|
35
|
-
"prepack": "node -e \"require('fs').mkdirSync('mcp',{recursive:true});require('fs').copyFileSync('../claude-code/plugins/healer/mcp/servidor.mjs','mcp/servidor.mjs')\""
|
|
35
|
+
"prepack": "node -e \"require('fs').mkdirSync('mcp',{recursive:true});require('fs').copyFileSync('../claude-code/plugins/healer-local/mcp/servidor.mjs','mcp/servidor.mjs')\""
|
|
36
36
|
}
|
|
37
37
|
}
|