agent-mp 0.5.2 → 0.5.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.
@@ -994,6 +994,16 @@ export async function runRepl(resumeSession) {
994
994
  const dir = await resolveProjectDir(process.cwd());
995
995
  const config = await loadProjectConfig(dir);
996
996
  if (args[0] === 'orch' || args[0] === 'orchestrator') {
997
+ // Ensure documentation exists before orchestrator runs
998
+ const contextDir = path.join(dir, '.agent', 'context');
999
+ const archPath = path.join(contextDir, 'architecture.md');
1000
+ if (!(await fileExists(archPath))) {
1001
+ fi.println(chalk.yellow('\n ── Generando documentación del proyecto ──'));
1002
+ fi.println(chalk.dim(' El orquestador necesita conocer la estructura del proyecto primero.\n'));
1003
+ const prepEngine = new AgentEngine(config, dir, gCoordinatorCmd, rl, fi, handleCmd);
1004
+ await prepEngine.runExplorer('Document the complete project structure, services, dependencies, and entry points. Create/update .agent/context/architecture.md');
1005
+ fi.println(chalk.green(' ✓ Documentación del proyecto generada.\n'));
1006
+ }
997
1007
  const task = args.slice(1).join(' ');
998
1008
  const engine = new AgentEngine(config, dir, gCoordinatorCmd, rl, fi, handleCmd);
999
1009
  const result = await engine.runOrchestrator(task);
@@ -1106,6 +1116,16 @@ export async function runRepl(resumeSession) {
1106
1116
  fi.println(chalk.red(' No roles configured. Run /config-multi first.'));
1107
1117
  }
1108
1118
  else {
1119
+ // Before running the orchestrator, ensure project documentation exists
1120
+ const contextDir = path.join(dir, '.agent', 'context');
1121
+ const archPath = path.join(contextDir, 'architecture.md');
1122
+ if (!(await fileExists(archPath))) {
1123
+ fi.println(chalk.yellow('\n ── Generando documentación del proyecto ──'));
1124
+ fi.println(chalk.dim(' El orquestador necesita conocer la estructura del proyecto primero.\n'));
1125
+ const engine = new AgentEngine(config, dir, gCoordinatorCmd, rl, fi, handleCmd);
1126
+ await engine.runExplorer('Document the complete project structure, services, dependencies, and entry points. Create/update .agent/context/architecture.md');
1127
+ fi.println(chalk.green(' ✓ Documentación del proyecto generada.\n'));
1128
+ }
1109
1129
  const engine = new AgentEngine(config, dir, gCoordinatorCmd, rl, fi, handleCmd);
1110
1130
  await engine.runFullCycle(trimmed);
1111
1131
  session.messages.push({ role: 'agent', content: `[task cycle completed for: ${trimmed}]`, ts: new Date().toISOString() });
@@ -988,31 +988,44 @@ INSTRUCCIONES:
988
988
  existingArch = await readFile(archPath);
989
989
  }
990
990
  catch { /* new project */ }
991
+ // Build a quick filesystem snapshot to give the explorer context
992
+ let fsSnapshot = '';
993
+ try {
994
+ const { execSync } = await import('child_process');
995
+ // Use tree/find but exclude .agent, node_modules, .git, dist, __pycache__, .venv
996
+ fsSnapshot = execSync(`find "${this.projectDir}" -maxdepth 3 -not -path '*/.agent/*' -not -path '*/node_modules/*' -not -path '*/.git/*' -not -path '*/dist/*' -not -path '*/__pycache__/*' -not -path '*/.venv/*' -not -path '*/target/*' | head -200`, { encoding: 'utf-8', timeout: 10000 });
997
+ }
998
+ catch { /* ignore */ }
991
999
  const effectiveTask = task || 'Explorar y documentar todas las aplicaciones y servicios del proyecto';
992
1000
  const prompt = `TAREA DE EXPLORACION: ${effectiveTask}
993
1001
  DIRECTORIO_TRABAJO: ${this.projectDir}
994
1002
  PROYECTO: ${this.config.project}
995
1003
  STACK: ${this.config.stack}
996
1004
 
1005
+ LISTADO DE ARCHIVOS DEL PROYECTO (excluyendo .agent, node_modules, .git, dist, __pycache__, .venv):
1006
+ ${fsSnapshot}
1007
+
997
1008
  ${existingArch ? `DOCUMENTACION EXISTENTE (actualizar si hay cambios):\n${existingArch.slice(0, 3000)}\n` : 'DOCUMENTACION EXISTENTE: ninguna — crear desde cero.\n'}
998
1009
  INSTRUCCIONES:
999
- 1. Lista el directorio raiz para identificar todos los servicios/aplicaciones.
1000
- 2. Para cada servicio/app: lee su package.json / requirements.txt / pyproject.toml para obtener nombre, stack y dependencias clave.
1001
- 3. Explora src/ o app/ de cada servicio: identifica entry point, modulos principales, rutas/endpoints expuestos, puerto configurado.
1002
- 4. Identifica dependencias ENTRE servicios (llamadas HTTP, variables de entorno compartidas, bases de datos comunes).
1003
- 5. Crea o actualiza el archivo ${archPath} con:
1004
- - Tabla resumen: | Servicio | Stack | Puerto | Proposito | Entry Point |
1005
- - Por cada servicio: modulos principales, rutas API clave, dependencias externas
1006
- - Mapa de dependencias entre servicios
1007
- 6. Crea o actualiza archivos individuales en ${contextDir}/<servicio>/architecture.md para cada servicio.
1008
- 7. Al terminar lista todos los archivos creados/actualizados.
1010
+ Analiza el listado de archivos de arriba y genera documentación completa del proyecto. Escribe el archivo de architecture.md usando el formato de write_file tool.
1011
+
1012
+ El archivo DEBE contener:
1013
+ 1. Tabla resumen: | Servicio/Modulo | Stack | Proposito | Entry Point | Archivos clave |
1014
+ 2. Analisis de la estructura de directorios principal
1015
+ 3. Por cada servicio/app: dependencias clave (de package.json, pyproject.toml, pom.xml, build.gradle, etc.), entry points, modulos principales
1016
+ 4. Mapa de dependencias entre componentes
1017
+ 5. Variables de entorno o configuraciones relevantes
1018
+ 6. Comandos de desarrollo comunes (build, test, run)
1019
+
1020
+ FORMATO DEL ARCHIVO A CREAR (${archPath}):
1021
+ Escribe el contenido completo del archivo architecture.md usando la herramienta write_file.
1009
1022
 
1010
1023
  REGLAS:
1011
- - Escribe UNICAMENTE los archivos indicados: ${archPath} y ${contextDir}/<servicio>/architecture.md
1012
- - NO crees archivos adicionales ni con otros nombres
1024
+ - Crea UNICAMENTE: ${archPath}
1025
+ - NO crees subdirectorios ni archivos adicionales
1013
1026
  - NO modifiques archivos de aplicacion
1014
- - NO ejecutes comandos que cambien estado (npm install, migraciones, etc.)
1015
- - Si un directorio esta en node_modules, dist, .git: ignoralo`;
1027
+ - NO ejecutes comandos
1028
+ - Documenta TODO el proyecto (todos los subdirectorios al nivel de DIRECTORIO_TRABAJO, excluyendo .agent)`;
1016
1029
  const res = await this.runWithFallback('explorer', prompt, 'Exploracion');
1017
1030
  const text = extractCliText(res);
1018
1031
  // Overwrite the single last-run report (no timestamp accumulation)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-mp",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "Deterministic multi-agent CLI orchestrator — plan, code, review",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",