agent-mp 0.5.5 → 0.5.6

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/dist/core/engine.js +146 -32
  2. package/package.json +1 -1
@@ -981,60 +981,174 @@ INSTRUCCIONES:
981
981
  await fs.mkdir(path.join(agentDir, 'rules'), { recursive: true });
982
982
  // Clean up stray files before running
983
983
  await this._cleanContextDir(contextDir);
984
- // Read existing architecture doc if any
984
+ // Build a quick filesystem snapshot to give the explorer context
985
+ let fsSnapshot = '';
986
+ try {
987
+ const { execSync } = await import('child_process');
988
+ // Use find but exclude .agent, node_modules, .git, dist, __pycache__, .venv, target, build
989
+ 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/*' -not -path '*/build/*' -not -name '.git' | sort | head -300`, { encoding: 'utf-8', timeout: 10000 });
990
+ }
991
+ catch { /* ignore */ }
992
+ // Read existing architecture docs if any
985
993
  const archPath = path.join(contextDir, 'architecture.md');
986
994
  let existingArch = '';
987
995
  try {
988
996
  existingArch = await readFile(archPath);
989
997
  }
990
998
  catch { /* new project */ }
991
- // Build a quick filesystem snapshot to give the explorer context
992
- let fsSnapshot = '';
999
+ // Read existing module docs if any
1000
+ const modulesDir = path.join(contextDir, 'modules');
1001
+ let existingModules = '';
993
1002
  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 });
1003
+ const modFiles = await fs.readdir(modulesDir);
1004
+ for (const f of modFiles.filter(f => f.endsWith('.md'))) {
1005
+ existingModules += `\n--- ${f} ---\n${await readFile(path.join(modulesDir, f)).then(c => c.slice(0, 2000))}\n`;
1006
+ }
997
1007
  }
998
- catch { /* ignore */ }
1008
+ catch { /* no modules yet */ }
999
1009
  const effectiveTask = task || 'Explorar y documentar todas las aplicaciones y servicios del proyecto';
1000
1010
  const prompt = `TAREA DE EXPLORACION: ${effectiveTask}
1001
1011
  DIRECTORIO_TRABAJO: ${this.projectDir}
1002
1012
  PROYECTO: ${this.config.project}
1003
1013
  STACK: ${this.config.stack}
1004
1014
 
1005
- LISTADO DE ARCHIVOS DEL PROYECTO (excluyendo .agent, node_modules, .git, dist, __pycache__, .venv):
1015
+ ESTRUCTURA DE ARCHIVOS DEL PROYECTO (excluyendo .agent, node_modules, .git, dist, __pycache__, .venv, target, build):
1006
1016
  ${fsSnapshot}
1007
1017
 
1008
- ${existingArch ? `DOCUMENTACION EXISTENTE (actualizar si hay cambios):\n${existingArch.slice(0, 3000)}\n` : 'DOCUMENTACION EXISTENTE: ninguna — crear desde cero.\n'}
1018
+ ${existingArch ? `--- DOCUMENTACION EXISTENTE: architecture.md ---\n${existingArch.slice(0, 2000)}\n` : ''}
1019
+ ${existingModules ? `--- DOCUMENTACION EXISTENTE: modules/ ---\n${existingModules.slice(0, 3000)}\n` : ''}
1020
+
1009
1021
  INSTRUCCIONES:
1010
- Analiza el listado de archivos y genera documentación completa.
1011
- DEVUELVE SOLO el contenido del archivo architecture.md como texto markdown. No incluyas explicaciones adicionales.
1022
+ Analiza la estructura de archivos y genera documentación COMPLETA y ESCALONADA del proyecto.
1023
+ Para cada directorio/modulo debes documentar: QUE ES, COMO SE ESTRUCTURA, QUE NECESITA PARA LEVANTAR, y QUE COMANDOS PUEDE EJECUTAR.
1024
+
1025
+ DEVUELVE el contenido de TODOS los archivos a crear en este formato EXACTO (separados por marcadores):
1026
+
1027
+ === ARCHITECTURE.md ===
1028
+ # ${this.config.project} — Architecture
1029
+
1030
+ Breve descripcion del proyecto y su stack.
1031
+
1032
+ ## Estructura General
1033
+
1034
+ Tabla resumen de todos los directorios/modulos al nivel del proyecto:
1035
+ | Directorio/Modulo | Stack | Proposito | Entry Point | Estado |
1036
+
1037
+ ## Como se relacionan los componentes
1038
+
1039
+ Explica como interactuan entre si los modulos/servicios:
1040
+ - Dependencias entre componentes
1041
+ - Flujo de datos principal
1042
+ - Variables de entorno compartidas
1043
+ - Bases de datos o servicios externos comunes
1044
+
1045
+ ## Prerequisitos Generales
1046
+ - Que se necesita instalado globalmente (node, python, java, docker, etc.)
1047
+ - Versiones requeridas
1048
+ - Servicios externos necesarios (BD, cache, etc.)
1049
+
1050
+ ## Directorios
1012
1051
 
1013
- El archivo DEBE contener:
1014
- 1. Tabla resumen: | Servicio/Modulo | Stack | Proposito | Entry Point | Archivos clave |
1015
- 2. Analisis de la estructura de directorios principal
1016
- 3. Por cada servicio/app: dependencias clave (de package.json, pyproject.toml, pom.xml, build.gradle, etc.), entry points, modulos principales
1017
- 4. Mapa de dependencias entre componentes
1018
- 5. Variables de entorno o configuraciones relevantes
1019
- 6. Comandos de desarrollo comunes (build, test, run)
1052
+ Para CADA directorio al nivel del proyecto (excluyendo .agent):
1053
+ ### [nombre-del-directorio]
1054
+ - **Proposito:** que hace
1055
+ - **Stack:** tecnologias
1056
+ - **Entry point:** archivo principal
1057
+ - **Como levantar:** comando para iniciar
1058
+ - **Documentacion detallada:** [modules/nombre-del-directorio.md](modules/nombre-del-directorio.md)
1059
+
1060
+ ## Comandos de Desarrollo Globales
1061
+
1062
+ | Comando | Descripcion | Directorio |
1063
+ |---------|-------------|------------|
1064
+ | build | como compilar todo | . |
1065
+ | test | como testear todo | . |
1066
+ | run | como ejecutar todo | . |
1067
+ | install | como instalar deps | . |
1068
+
1069
+ === modules/[nombre].md ===
1070
+ # [nombre-del-directorio]
1071
+
1072
+ ## Descripcion
1073
+ Que es este modulo y que problema resuelve.
1074
+
1075
+ ## Estructura
1076
+ \`\`\`
1077
+ src/
1078
+ ├── main.py # entry point
1079
+ ├── models/ # modelos de datos
1080
+ └── routes/ # endpoints API
1081
+ \`\`\`
1082
+
1083
+ ## Componentes Principales
1084
+ ### [componente]
1085
+ - **Archivo:** ruta relativa
1086
+ - **Funcion:** que hace
1087
+ - **Dependencias:** que necesita
1088
+
1089
+ ## Que necesita para levantar
1090
+ - **Dependencias locales:** libs del package.json, requirements.txt, pom.xml, etc.
1091
+ - **Servicios:** BD, redis, APIs externas que necesita
1092
+ - **Variables de entorno:** cuales necesita y para que sirven
1093
+ - **Prerequisitos:** que debe estar corriendo antes
1094
+
1095
+ ## Comandos para ejecutar
1096
+
1097
+ | Comando | Que hace |
1098
+ |---------|----------|
1099
+ | \`npm run dev\` | levanta en modo desarrollo |
1100
+ | \`npm run build\` | compila para produccion |
1101
+ | \`npm test\` | ejecuta tests |
1102
+ | (incluir TODOS los comandos utiles del package.json, Makefile, etc.) |
1103
+
1104
+ ## API / Interfaces
1105
+ Endpoints, funciones publicas, interfaces expuestas.
1106
+
1107
+ ## Dependencias
1108
+ - Internas: que modulos del proyecto usa
1109
+ - Externas: librerias de terceros
1110
+
1111
+ ## Configuracion
1112
+ Variables de entorno, archivos de config relevantes.
1020
1113
 
1021
1114
  REGLAS:
1022
- - Devuelve UNICAMENTE el contenido markdown del archivo
1023
- - NO incluyas texto de explicacion fuera del markdown
1024
- - NO incluyas bloques de codigo
1025
- - Documenta TODO el proyecto (todos los subdirectorios al nivel de DIRECTORIO_TRABAJO, excluyendo .agent)`;
1115
+ - Devuelve UNICAMENTE los archivos separados por === NOMBRE.md ===
1116
+ - NO incluyas explicaciones fuera de los archivos
1117
+ - Documenta TODOS los directorios al nivel de DIRECTORIO_TRABAJO (excluyendo .agent)
1118
+ - Si un directorio es trivial (solo config o docs), documentalo brevemente en architecture.md sin modulo separado
1119
+ - Para cada modulo incluye SIEMPRE: estructura, que necesita para levantar, comandos ejecutables
1120
+ - Si hay documentacion existente, actualizala con los cambios detectados`;
1026
1121
  const res = await this.runWithFallback('explorer', prompt, 'Exploracion');
1027
1122
  const text = extractCliText(res);
1028
- // The LLM returns the CONTENT of architecture.md as plain text.
1029
- // We need to write it to the file ourselves.
1030
- const cleanText = text
1031
- .replace(/^```markdown\s*/i, '')
1032
- .replace(/^```\s*$/gm, '')
1033
- .replace(/```/g, '')
1034
- .trim();
1035
- if (cleanText) {
1036
- await writeFile(archPath, cleanText);
1037
- log.ok(`architecture.md written (${cleanText.length} chars)`);
1123
+ // Parse the response: split by === FILENAME.md === markers
1124
+ // and write each section to its corresponding file
1125
+ const sections = text.split(/===\s+(.+?\.md)\s*===/).slice(1);
1126
+ let filesWritten = 0;
1127
+ for (let i = 0; i < sections.length; i += 2) {
1128
+ const fileName = sections[i].trim();
1129
+ let content = sections[i + 1] ? sections[i + 1].trim() : '';
1130
+ if (!content)
1131
+ continue;
1132
+ // Clean up code fences if present
1133
+ content = content.replace(/^```markdown\s*/i, '').replace(/^```\s*$/gm, '').trim();
1134
+ try {
1135
+ if (fileName === 'ARCHITECTURE.md') {
1136
+ await writeFile(archPath, content);
1137
+ filesWritten++;
1138
+ }
1139
+ else if (fileName.startsWith('modules/')) {
1140
+ const modPath = path.join(contextDir, fileName);
1141
+ await fs.mkdir(path.dirname(modPath), { recursive: true });
1142
+ await writeFile(modPath, content);
1143
+ filesWritten++;
1144
+ }
1145
+ }
1146
+ catch (err) {
1147
+ log.warn(`Failed to write ${fileName}: ${err.message}`);
1148
+ }
1149
+ }
1150
+ if (filesWritten > 0) {
1151
+ log.ok(`${filesWritten} documentation file(s) written`);
1038
1152
  }
1039
1153
  // Overwrite the single last-run report (no timestamp accumulation)
1040
1154
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-mp",
3
- "version": "0.5.5",
3
+ "version": "0.5.6",
4
4
  "description": "Deterministic multi-agent CLI orchestrator — plan, code, review",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",