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.
- package/dist/core/engine.js +106 -81
- 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,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
|
-
${
|
|
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
|
-
|
|
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
|
-
|
|
1026
|
-
|
|
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
|
-
|
|
1040
|
+
FORMATO EXACTO de los archivos a devolver (separados por marcadores):
|
|
1029
1041
|
|
|
1030
|
-
===
|
|
1031
|
-
# ${this.config.project} — Architecture
|
|
1042
|
+
=== architecture.md ===
|
|
1043
|
+
# ${this.config.project} — Architecture Overview
|
|
1032
1044
|
|
|
1033
|
-
|
|
1045
|
+
Descripcion general del proyecto.
|
|
1034
1046
|
|
|
1035
|
-
##
|
|
1047
|
+
## Componentes del Proyecto
|
|
1036
1048
|
|
|
1037
|
-
|
|
1038
|
-
|
|
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
|
|
1054
|
+
## Como se Relacionan los Componentes
|
|
1041
1055
|
|
|
1042
|
-
Explica
|
|
1043
|
-
-
|
|
1044
|
-
-
|
|
1045
|
-
-
|
|
1046
|
-
|
|
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
|
-
-
|
|
1050
|
-
-
|
|
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
|
-
===
|
|
1060
|
-
# [nombre] —
|
|
1076
|
+
=== [nombre]/architecture.md ===
|
|
1077
|
+
# [nombre] — Arquitectura Interna
|
|
1061
1078
|
|
|
1062
|
-
Descripcion
|
|
1079
|
+
Descripcion de este componente y su rol en el proyecto.
|
|
1063
1080
|
|
|
1064
|
-
## Estructura
|
|
1081
|
+
## Estructura Interna
|
|
1065
1082
|
\`\`\`
|
|
1066
1083
|
src/
|
|
1067
|
-
├── main.
|
|
1068
|
-
├──
|
|
1069
|
-
|
|
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
|
-
|
|
|
1076
|
-
|
|
|
1093
|
+
| config | modules/config.md | Configuracion |
|
|
1094
|
+
| controller | modules/controller.md | Endpoints |
|
|
1077
1095
|
|
|
1078
1096
|
## Como Levantar
|
|
1079
|
-
- **
|
|
1097
|
+
- **Instalar deps:** comando
|
|
1080
1098
|
- **Servicios necesarios:** BD, redis, etc.
|
|
1081
|
-
- **Variables de entorno:**
|
|
1082
|
-
- **Comando para iniciar:**
|
|
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
|
-
|
|
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
|
|
1115
|
+
Que hace este modulo especifico.
|
|
1095
1116
|
|
|
1096
1117
|
## Archivo Principal
|
|
1097
|
-
- **Ruta:** path relativo
|
|
1098
|
-
- **Funciones/Clases principales
|
|
1118
|
+
- **Ruta:** path relativo
|
|
1119
|
+
- **Funciones/Clases principales**
|
|
1099
1120
|
|
|
1100
1121
|
## Endpoints / Interfaces Publicas
|
|
1101
|
-
Si es un
|
|
1102
|
-
- \`GET /
|
|
1103
|
-
- \`POST /
|
|
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:**
|
|
1111
|
-
- **Externas:** librerias de terceros
|
|
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 ===
|
|
1118
|
-
- NO incluyas
|
|
1119
|
-
-
|
|
1120
|
-
- Para
|
|
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
|
|
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
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1151
|
+
let targetPath;
|
|
1152
|
+
if (fileName === 'architecture.md' || fileName === 'ARCHITECTURE.md') {
|
|
1153
|
+
// Main architecture doc
|
|
1154
|
+
targetPath = mainArchPath;
|
|
1139
1155
|
}
|
|
1140
|
-
else
|
|
1141
|
-
//
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
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}`);
|