agent-mp 0.5.6 → 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.
- package/dist/core/engine.js +122 -92
- package/package.json +1 -1
package/dist/core/engine.js
CHANGED
|
@@ -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
|
|
993
|
-
const
|
|
994
|
-
let
|
|
991
|
+
// Read existing main architecture doc
|
|
992
|
+
const mainArchPath = path.join(contextDir, 'architecture.md');
|
|
993
|
+
let existingMainArch = '';
|
|
995
994
|
try {
|
|
996
|
-
|
|
995
|
+
existingMainArch = await readFile(mainArchPath);
|
|
997
996
|
}
|
|
998
|
-
catch { /* new
|
|
999
|
-
// Read existing
|
|
1000
|
-
|
|
1001
|
-
let existingModules = '';
|
|
997
|
+
catch { /* new */ }
|
|
998
|
+
// Read existing per-component docs
|
|
999
|
+
let existingComponentDocs = '';
|
|
1002
1000
|
try {
|
|
1003
|
-
const
|
|
1004
|
-
for (const
|
|
1005
|
-
|
|
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 { /*
|
|
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,113 +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
|
-
${
|
|
1019
|
-
${
|
|
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
|
|
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:
|
|
1024
1028
|
|
|
1025
|
-
|
|
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
|
|
1026
1034
|
|
|
1027
|
-
|
|
1028
|
-
|
|
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
|
|
1029
1039
|
|
|
1030
|
-
|
|
1040
|
+
FORMATO EXACTO de los archivos a devolver (separados por marcadores):
|
|
1031
1041
|
|
|
1032
|
-
|
|
1042
|
+
=== architecture.md ===
|
|
1043
|
+
# ${this.config.project} — Architecture Overview
|
|
1033
1044
|
|
|
1034
|
-
|
|
1035
|
-
| Directorio/Modulo | Stack | Proposito | Entry Point | Estado |
|
|
1045
|
+
Descripcion general del proyecto.
|
|
1036
1046
|
|
|
1037
|
-
##
|
|
1047
|
+
## Componentes del Proyecto
|
|
1038
1048
|
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
-
|
|
1042
|
-
-
|
|
1043
|
-
- Bases de datos o servicios externos comunes
|
|
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 |
|
|
1044
1053
|
|
|
1045
|
-
##
|
|
1046
|
-
- Que se necesita instalado globalmente (node, python, java, docker, etc.)
|
|
1047
|
-
- Versiones requeridas
|
|
1048
|
-
- Servicios externos necesarios (BD, cache, etc.)
|
|
1054
|
+
## Como se Relacionan los Componentes
|
|
1049
1055
|
|
|
1050
|
-
|
|
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
|
|
1051
1060
|
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
- **Como levantar:** comando para iniciar
|
|
1058
|
-
- **Documentacion detallada:** [modules/nombre-del-directorio.md](modules/nombre-del-directorio.md)
|
|
1061
|
+
### Diagrama de Flujo (texto)
|
|
1062
|
+
\`\`\`
|
|
1063
|
+
[Frontend] --fetch--> [API 1] --HTTP--> [API 2]
|
|
1064
|
+
[API 1] --> [Database]
|
|
1065
|
+
\`\`\`
|
|
1059
1066
|
|
|
1060
|
-
##
|
|
1067
|
+
## Prerequisitos Generales
|
|
1068
|
+
- Node.js x.x, Python x.x, Docker, etc.
|
|
1069
|
+
- Bases de datos, servicios externos
|
|
1061
1070
|
|
|
1071
|
+
## Comandos de Desarrollo Globales
|
|
1062
1072
|
| Comando | Descripcion | Directorio |
|
|
1063
1073
|
|---------|-------------|------------|
|
|
1064
|
-
|
|
|
1065
|
-
| test | como testear todo | . |
|
|
1066
|
-
| run | como ejecutar todo | . |
|
|
1067
|
-
| install | como instalar deps | . |
|
|
1074
|
+
| ... | ... | ... |
|
|
1068
1075
|
|
|
1069
|
-
===
|
|
1070
|
-
# [nombre
|
|
1076
|
+
=== [nombre]/architecture.md ===
|
|
1077
|
+
# [nombre] — Arquitectura Interna
|
|
1071
1078
|
|
|
1072
|
-
|
|
1073
|
-
Que es este modulo y que problema resuelve.
|
|
1079
|
+
Descripcion de este componente y su rol en el proyecto.
|
|
1074
1080
|
|
|
1075
|
-
## Estructura
|
|
1081
|
+
## Estructura Interna
|
|
1076
1082
|
\`\`\`
|
|
1077
1083
|
src/
|
|
1078
|
-
├── main.
|
|
1079
|
-
├──
|
|
1080
|
-
|
|
1084
|
+
├── main.ts # entry point
|
|
1085
|
+
├── config/ # configuracion
|
|
1086
|
+
├── controllers/ # endpoints
|
|
1087
|
+
└── services/ # logica de negocio
|
|
1081
1088
|
\`\`\`
|
|
1082
1089
|
|
|
1083
|
-
##
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
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
|
|
1090
|
+
## Modulos Internos
|
|
1091
|
+
| Modulo | Archivo | Descripcion |
|
|
1092
|
+
|--------|---------|-------------|
|
|
1093
|
+
| config | modules/config.md | Configuracion |
|
|
1094
|
+
| controller | modules/controller.md | Endpoints |
|
|
1094
1095
|
|
|
1095
|
-
##
|
|
1096
|
+
## Como Levantar
|
|
1097
|
+
- **Instalar deps:** comando
|
|
1098
|
+
- **Servicios necesarios:** BD, redis, etc.
|
|
1099
|
+
- **Variables de entorno:** listarlas con su proposito
|
|
1100
|
+
- **Comando para iniciar:** \`...\`
|
|
1096
1101
|
|
|
1102
|
+
## Comandos Disponibles
|
|
1097
1103
|
| Comando | Que hace |
|
|
1098
1104
|
|---------|----------|
|
|
1099
|
-
|
|
|
1100
|
-
| \`npm run build\` | compila para produccion |
|
|
1101
|
-
| \`npm test\` | ejecuta tests |
|
|
1102
|
-
| (incluir TODOS los comandos utiles del package.json, Makefile, etc.) |
|
|
1105
|
+
| ... | ... |
|
|
1103
1106
|
|
|
1104
|
-
##
|
|
1105
|
-
|
|
1107
|
+
## Comunicacion con Otros Componentes
|
|
1108
|
+
- A que APIs llama o que APIs lo llaman
|
|
1109
|
+
- Protocolo (fetch, HTTP, gRPC, etc.)
|
|
1106
1110
|
|
|
1107
|
-
|
|
1108
|
-
-
|
|
1109
|
-
|
|
1111
|
+
=== [nombre]/modules/[modulo].md ===
|
|
1112
|
+
# [nombre-del-modulo]
|
|
1113
|
+
|
|
1114
|
+
## Funcion
|
|
1115
|
+
Que hace este modulo especifico.
|
|
1116
|
+
|
|
1117
|
+
## Archivo Principal
|
|
1118
|
+
- **Ruta:** path relativo
|
|
1119
|
+
- **Funciones/Clases principales**
|
|
1120
|
+
|
|
1121
|
+
## Endpoints / Interfaces Publicas
|
|
1122
|
+
Si es un controller/router:
|
|
1123
|
+
- \`GET /ruta\` — descripcion
|
|
1124
|
+
- \`POST /ruta\` — descripcion
|
|
1110
1125
|
|
|
1111
|
-
##
|
|
1112
|
-
|
|
1126
|
+
## Dependencias
|
|
1127
|
+
- **Internas:** modulos del mismo componente
|
|
1128
|
+
- **Externas:** librerias de terceros
|
|
1113
1129
|
|
|
1114
1130
|
REGLAS:
|
|
1115
|
-
- Devuelve UNICAMENTE los archivos separados por ===
|
|
1116
|
-
- NO incluyas
|
|
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
|
|
1117
1136
|
- 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
1137
|
- Si hay documentacion existente, actualizala con los cambios detectados`;
|
|
1121
1138
|
const res = await this.runWithFallback('explorer', prompt, 'Exploracion');
|
|
1122
1139
|
const text = extractCliText(res);
|
|
1123
|
-
// Parse
|
|
1124
|
-
// and write each section to its corresponding file
|
|
1140
|
+
// Parse sections separated by === path/file.md === markers
|
|
1125
1141
|
const sections = text.split(/===\s+(.+?\.md)\s*===/).slice(1);
|
|
1126
1142
|
let filesWritten = 0;
|
|
1127
1143
|
for (let i = 0; i < sections.length; i += 2) {
|
|
@@ -1132,16 +1148,30 @@ REGLAS:
|
|
|
1132
1148
|
// Clean up code fences if present
|
|
1133
1149
|
content = content.replace(/^```markdown\s*/i, '').replace(/^```\s*$/gm, '').trim();
|
|
1134
1150
|
try {
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1151
|
+
let targetPath;
|
|
1152
|
+
if (fileName === 'architecture.md' || fileName === 'ARCHITECTURE.md') {
|
|
1153
|
+
// Main architecture doc
|
|
1154
|
+
targetPath = mainArchPath;
|
|
1138
1155
|
}
|
|
1139
|
-
else
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
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(/.*\//, ''));
|
|
1170
|
+
}
|
|
1144
1171
|
}
|
|
1172
|
+
await fs.mkdir(path.dirname(targetPath), { recursive: true });
|
|
1173
|
+
await writeFile(targetPath, content);
|
|
1174
|
+
filesWritten++;
|
|
1145
1175
|
}
|
|
1146
1176
|
catch (err) {
|
|
1147
1177
|
log.warn(`Failed to write ${fileName}: ${err.message}`);
|