agent-mp 0.5.7 → 0.5.8

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 +106 -81
  2. package/package.json +1 -1
@@ -985,27 +985,32 @@ INSTRUCCIONES:
985
985
  let fsSnapshot = '';
986
986
  try {
987
987
  const { execSync } = await import('child_process');
988
- // Use find but exclude .agent, node_modules, .git, dist, __pycache__, .venv, target, build
989
988
  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
989
  }
991
990
  catch { /* ignore */ }
992
- // Read existing architecture docs if any
993
- const archPath = path.join(contextDir, 'architecture.md');
994
- let existingArch = '';
991
+ // Read existing main architecture doc
992
+ const mainArchPath = path.join(contextDir, 'architecture.md');
993
+ let existingMainArch = '';
995
994
  try {
996
- existingArch = await readFile(archPath);
995
+ existingMainArch = await readFile(mainArchPath);
997
996
  }
998
- catch { /* new project */ }
999
- // Read existing module docs if any
1000
- const modulesDir = path.join(contextDir, 'modules');
1001
- let existingModules = '';
997
+ catch { /* new */ }
998
+ // Read existing per-component docs
999
+ let existingComponentDocs = '';
1002
1000
  try {
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`;
1001
+ const ctxEntries = await fs.readdir(contextDir);
1002
+ for (const entry of ctxEntries.filter(e => e !== 'architecture.md' && e !== 'explorer-last.md' && e !== 'modules')) {
1003
+ const entryPath = path.join(contextDir, entry);
1004
+ const stat = await fs.stat(entryPath);
1005
+ if (stat.isDirectory()) {
1006
+ const compArch = path.join(entryPath, 'architecture.md');
1007
+ if (await fileExists(compArch)) {
1008
+ existingComponentDocs += `\n=== EXISTING: ${entry}/architecture.md ===\n${(await readFile(compArch)).slice(0, 1500)}\n`;
1009
+ }
1010
+ }
1006
1011
  }
1007
1012
  }
1008
- catch { /* no modules yet */ }
1013
+ catch { /* ignore */ }
1009
1014
  const effectiveTask = task || 'Explorar y documentar todas las aplicaciones y servicios del proyecto';
1010
1015
  const prompt = `TAREA DE EXPLORACION: ${effectiveTask}
1011
1016
  DIRECTORIO_TRABAJO: ${this.projectDir}
@@ -1015,114 +1020,124 @@ STACK: ${this.config.stack}
1015
1020
  ESTRUCTURA DE ARCHIVOS DEL PROYECTO (excluyendo .agent, node_modules, .git, dist, __pycache__, .venv, target, build):
1016
1021
  ${fsSnapshot}
1017
1022
 
1018
- ${existingArch ? `--- DOCUMENTACION EXISTENTE: architecture.md ---\n${existingArch.slice(0, 2000)}\n` : ''}
1019
- ${existingModules ? `--- DOCUMENTACION EXISTENTE: modules/ ---\n${existingModules.slice(0, 3000)}\n` : ''}
1023
+ ${existingMainArch ? `=== DOCUMENTACION EXISTENTE: architecture.md (principal) ===\n${existingMainArch.slice(0, 2000)}\n` : ''}
1024
+ ${existingComponentDocs ? `=== DOCUMENTACION EXISTENTE por componente ===\n${existingComponentDocs.slice(0, 3000)}\n` : ''}
1020
1025
 
1021
1026
  INSTRUCCIONES:
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.
1027
+ Analiza la estructura de archivos y genera documentación ESCALONADA en DOS NIVELES:
1028
+
1029
+ NIVEL 1: architecture.md (raiz de .agent/context/)
1030
+ - Lista TODOS los directorios al nivel del proyecto
1031
+ - Indica si son independientes o conectados entre si (ej: front consume back, dos APIs se consumen entre si)
1032
+ - Prerequisitos generales para levantar el proyecto
1033
+ - Comandos globales de desarrollo
1024
1034
 
1025
- IMPORTANTE: Si un directorio contiene una API o servicio con multiples modulos (rutas, controllers, models, etc.),
1026
- ese directorio debe tener SU PROPIA subcarpeta dentro de modules/ con un index.md y un archivo por cada modulo interno.
1035
+ NIVEL 2: Para CADA directorio que sea un servicio/API/app/funcionalidad:
1036
+ - Crea subcarpeta: [nombre-del-directorio]/architecture.md explica como se estructura internamente
1037
+ - Crea subcarpeta: [nombre-del-directorio]/modules/[modulo].md → detalle de cada modulo interno
1038
+ - Si un directorio es trivial (solo scripts, docs, configs), NO crees subcarpeta, solo mencionarlo en el architecture.md principal
1027
1039
 
1028
- DEVUELVE el contenido de TODOS los archivos a crear en este formato EXACTO (separados por marcadores):
1040
+ FORMATO EXACTO de los archivos a devolver (separados por marcadores):
1029
1041
 
1030
- === ARCHITECTURE.md ===
1031
- # ${this.config.project} — Architecture
1042
+ === architecture.md ===
1043
+ # ${this.config.project} — Architecture Overview
1032
1044
 
1033
- Breve descripcion del proyecto y su stack.
1045
+ Descripcion general del proyecto.
1034
1046
 
1035
- ## Estructura General
1047
+ ## Componentes del Proyecto
1036
1048
 
1037
- Tabla resumen de todos los directorios al nivel del proyecto:
1038
- | Directorio | Tipo | Stack | Proposito | Entry Point |
1049
+ | Componente | Tipo | Stack | Proposito | Entry Point |
1050
+ |------------|------|-------|-----------|-------------|
1051
+ | datamart-data-access-api | API Backend | NestJS | Acceso a datos | src/main.ts |
1052
+ | nexus-core-api | API Backend | NestJS | Core business logic | src/main.ts |
1039
1053
 
1040
- ## Como se relacionan los componentes
1054
+ ## Como se Relacionan los Componentes
1041
1055
 
1042
- Explica como interactuan entre si los directorios/servicios:
1043
- - Dependencias entre componentes
1044
- - Flujo de datos principal
1045
- - Variables de entorno compartidas
1046
- - Bases de datos o servicios externos comunes
1056
+ Explica las conexiones entre componentes:
1057
+ - Si un front consume un back, explicar como
1058
+ - Si dos APIs se consumen entre sí (fetch, HTTP), explicar el flujo
1059
+ - Si son independientes, indicar que cada uno funciona por su cuenta
1060
+
1061
+ ### Diagrama de Flujo (texto)
1062
+ \`\`\`
1063
+ [Frontend] --fetch--> [API 1] --HTTP--> [API 2]
1064
+ [API 1] --> [Database]
1065
+ \`\`\`
1047
1066
 
1048
1067
  ## Prerequisitos Generales
1049
- - Que se necesita instalado globalmente (node, python, java, docker, etc.)
1050
- - Versiones requeridas
1051
- - Servicios externos necesarios (BD, cache, etc.)
1068
+ - Node.js x.x, Python x.x, Docker, etc.
1069
+ - Bases de datos, servicios externos
1052
1070
 
1053
1071
  ## Comandos de Desarrollo Globales
1054
-
1055
1072
  | Comando | Descripcion | Directorio |
1056
1073
  |---------|-------------|------------|
1057
1074
  | ... | ... | ... |
1058
1075
 
1059
- === modules/[nombre]/index.md ===
1060
- # [nombre] — Estructura Interna
1076
+ === [nombre]/architecture.md ===
1077
+ # [nombre] — Arquitectura Interna
1061
1078
 
1062
- Descripcion general de este servicio/API y que problema resuelve.
1079
+ Descripcion de este componente y su rol en el proyecto.
1063
1080
 
1064
- ## Estructura del Servicio
1081
+ ## Estructura Interna
1065
1082
  \`\`\`
1066
1083
  src/
1067
- ├── main.py # entry point
1068
- ├── models/ # modelos de datos
1069
- └── routes/ # endpoints
1084
+ ├── main.ts # entry point
1085
+ ├── config/ # configuracion
1086
+ ├── controllers/ # endpoints
1087
+ └── services/ # logica de negocio
1070
1088
  \`\`\`
1071
1089
 
1072
1090
  ## Modulos Internos
1073
1091
  | Modulo | Archivo | Descripcion |
1074
1092
  |--------|---------|-------------|
1075
- | auth | auth.md | Autenticacion y tokens |
1076
- | users | users.md | Gestion de usuarios |
1093
+ | config | modules/config.md | Configuracion |
1094
+ | controller | modules/controller.md | Endpoints |
1077
1095
 
1078
1096
  ## Como Levantar
1079
- - **Dependencias:** instalar con \`npm install\` o \`pip install -r requirements.txt\`
1097
+ - **Instalar deps:** comando
1080
1098
  - **Servicios necesarios:** BD, redis, etc.
1081
- - **Variables de entorno:** cuales y para que
1082
- - **Comando para iniciar:** \`npm run dev\` o equivalente
1099
+ - **Variables de entorno:** listarlas con su proposito
1100
+ - **Comando para iniciar:** \`...\`
1083
1101
 
1084
1102
  ## Comandos Disponibles
1085
-
1086
1103
  | Comando | Que hace |
1087
1104
  |---------|----------|
1088
1105
  | ... | ... |
1089
1106
 
1090
- === modules/[nombre]/[modulo].md ===
1107
+ ## Comunicacion con Otros Componentes
1108
+ - A que APIs llama o que APIs lo llaman
1109
+ - Protocolo (fetch, HTTP, gRPC, etc.)
1110
+
1111
+ === [nombre]/modules/[modulo].md ===
1091
1112
  # [nombre-del-modulo]
1092
1113
 
1093
1114
  ## Funcion
1094
- Que hace este modulo y que parte del servicio cubre.
1115
+ Que hace este modulo especifico.
1095
1116
 
1096
1117
  ## Archivo Principal
1097
- - **Ruta:** path relativo al proyecto
1098
- - **Funciones/Clases principales:** listar las mas importantes
1118
+ - **Ruta:** path relativo
1119
+ - **Funciones/Clases principales**
1099
1120
 
1100
1121
  ## Endpoints / Interfaces Publicas
1101
- Si es un modulo de API:
1102
- - \`GET /endpoint\` — descripcion
1103
- - \`POST /endpoint\` — descripcion
1104
-
1105
- Si es otro tipo de modulo:
1106
- - Funciones publicas exportadas
1107
- - Interfaces que implementa
1122
+ Si es un controller/router:
1123
+ - \`GET /ruta\` — descripcion
1124
+ - \`POST /ruta\` — descripcion
1108
1125
 
1109
1126
  ## Dependencias
1110
- - **Internas:** otros modulos del mismo servicio que usa
1111
- - **Externas:** librerias de terceros especificas de este modulo
1112
-
1113
- ## Notas
1114
- Cualquier detalle relevante especifico de este modulo.
1127
+ - **Internas:** modulos del mismo componente
1128
+ - **Externas:** librerias de terceros
1115
1129
 
1116
1130
  REGLAS:
1117
- - Devuelve UNICAMENTE los archivos separados por === modules/path/file.md ===
1118
- - NO incluyas explicaciones fuera de los archivos
1119
- - Para CADA API/servicio con modulos internos: crea modules/[nombre]/index.md + un archivo por cada modulo
1120
- - Para directorios triviales (solo docs, configs sueltos): documenta en architecture.md sin crear subcarpeta
1131
+ - Devuelve UNICAMENTE los archivos separados por === path/file.md ===
1132
+ - NO incluyas texto explicativo fuera de los archivos
1133
+ - El archivo principal SIEMPRE es === architecture.md ===
1134
+ - Para cada componente con modulos internos: === [nombre]/architecture.md === + === [nombre]/modules/[modulo].md ===
1135
+ - Para componentes triviales (scripts, docs): solo mencionarlos en architecture.md principal
1121
1136
  - Documenta TODOS los directorios al nivel de DIRECTORIO_TRABAJO (excluyendo .agent)
1122
1137
  - Si hay documentacion existente, actualizala con los cambios detectados`;
1123
1138
  const res = await this.runWithFallback('explorer', prompt, 'Exploracion');
1124
1139
  const text = extractCliText(res);
1125
- // Parse the response: split by === FILENAME.md === markers
1140
+ // Parse sections separated by === path/file.md === markers
1126
1141
  const sections = text.split(/===\s+(.+?\.md)\s*===/).slice(1);
1127
1142
  let filesWritten = 0;
1128
1143
  for (let i = 0; i < sections.length; i += 2) {
@@ -1133,20 +1148,30 @@ REGLAS:
1133
1148
  // Clean up code fences if present
1134
1149
  content = content.replace(/^```markdown\s*/i, '').replace(/^```\s*$/gm, '').trim();
1135
1150
  try {
1136
- if (fileName === 'ARCHITECTURE.md') {
1137
- await writeFile(archPath, content);
1138
- filesWritten++;
1151
+ let targetPath;
1152
+ if (fileName === 'architecture.md' || fileName === 'ARCHITECTURE.md') {
1153
+ // Main architecture doc
1154
+ targetPath = mainArchPath;
1139
1155
  }
1140
- else if (fileName.toLowerCase().includes('modules/')) {
1141
- // Extract the modules/ path from the marker
1142
- const modMatch = fileName.match(/modules\/(.+\.md)/i);
1143
- if (modMatch) {
1144
- const modPath = path.join(contextDir, 'modules', modMatch[1]);
1145
- await fs.mkdir(path.dirname(modPath), { recursive: true });
1146
- await writeFile(modPath, content);
1147
- filesWritten++;
1156
+ else {
1157
+ // Component doc: [component]/architecture.md or [component]/modules/[mod].md
1158
+ // fileName could be: "datamart-data-access-api/architecture.md" or "datamart-data-access-api/modules/config.md"
1159
+ const compMatch = fileName.match(/^(.+?)\/architecture\.md$/i);
1160
+ const modMatch = fileName.match(/^(.+?)\/modules\/(.+\.md)$/i);
1161
+ if (compMatch) {
1162
+ targetPath = path.join(contextDir, compMatch[1], 'architecture.md');
1163
+ }
1164
+ else if (modMatch) {
1165
+ targetPath = path.join(contextDir, modMatch[1], 'modules', modMatch[2]);
1166
+ }
1167
+ else {
1168
+ // Fallback: treat as modules file in legacy modules/ dir
1169
+ targetPath = path.join(contextDir, 'modules', fileName.replace(/.*\//, ''));
1148
1170
  }
1149
1171
  }
1172
+ await fs.mkdir(path.dirname(targetPath), { recursive: true });
1173
+ await writeFile(targetPath, content);
1174
+ filesWritten++;
1150
1175
  }
1151
1176
  catch (err) {
1152
1177
  log.warn(`Failed to write ${fileName}: ${err.message}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-mp",
3
- "version": "0.5.7",
3
+ "version": "0.5.8",
4
4
  "description": "Deterministic multi-agent CLI orchestrator — plan, code, review",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",