agent-mp 0.5.5 → 0.5.7
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 +151 -32
- package/package.json +1 -1
package/dist/core/engine.js
CHANGED
|
@@ -981,60 +981,179 @@ 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
|
-
//
|
|
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
|
-
//
|
|
992
|
-
|
|
999
|
+
// Read existing module docs if any
|
|
1000
|
+
const modulesDir = path.join(contextDir, 'modules');
|
|
1001
|
+
let existingModules = '';
|
|
993
1002
|
try {
|
|
994
|
-
const
|
|
995
|
-
|
|
996
|
-
|
|
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 { /*
|
|
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
|
-
|
|
1015
|
+
ESTRUCTURA DE ARCHIVOS DEL PROYECTO (excluyendo .agent, node_modules, .git, dist, __pycache__, .venv, target, build):
|
|
1006
1016
|
${fsSnapshot}
|
|
1007
1017
|
|
|
1008
|
-
${existingArch ?
|
|
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
|
|
1011
|
-
|
|
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
|
+
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.
|
|
1027
|
+
|
|
1028
|
+
DEVUELVE el contenido de TODOS los archivos a crear en este formato EXACTO (separados por marcadores):
|
|
1029
|
+
|
|
1030
|
+
=== ARCHITECTURE.md ===
|
|
1031
|
+
# ${this.config.project} — Architecture
|
|
1032
|
+
|
|
1033
|
+
Breve descripcion del proyecto y su stack.
|
|
1034
|
+
|
|
1035
|
+
## Estructura General
|
|
1036
|
+
|
|
1037
|
+
Tabla resumen de todos los directorios al nivel del proyecto:
|
|
1038
|
+
| Directorio | Tipo | Stack | Proposito | Entry Point |
|
|
1039
|
+
|
|
1040
|
+
## Como se relacionan los componentes
|
|
1041
|
+
|
|
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
|
|
1047
|
+
|
|
1048
|
+
## Prerequisitos Generales
|
|
1049
|
+
- Que se necesita instalado globalmente (node, python, java, docker, etc.)
|
|
1050
|
+
- Versiones requeridas
|
|
1051
|
+
- Servicios externos necesarios (BD, cache, etc.)
|
|
1052
|
+
|
|
1053
|
+
## Comandos de Desarrollo Globales
|
|
1054
|
+
|
|
1055
|
+
| Comando | Descripcion | Directorio |
|
|
1056
|
+
|---------|-------------|------------|
|
|
1057
|
+
| ... | ... | ... |
|
|
1012
1058
|
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1059
|
+
=== modules/[nombre]/index.md ===
|
|
1060
|
+
# [nombre] — Estructura Interna
|
|
1061
|
+
|
|
1062
|
+
Descripcion general de este servicio/API y que problema resuelve.
|
|
1063
|
+
|
|
1064
|
+
## Estructura del Servicio
|
|
1065
|
+
\`\`\`
|
|
1066
|
+
src/
|
|
1067
|
+
├── main.py # entry point
|
|
1068
|
+
├── models/ # modelos de datos
|
|
1069
|
+
└── routes/ # endpoints
|
|
1070
|
+
\`\`\`
|
|
1071
|
+
|
|
1072
|
+
## Modulos Internos
|
|
1073
|
+
| Modulo | Archivo | Descripcion |
|
|
1074
|
+
|--------|---------|-------------|
|
|
1075
|
+
| auth | auth.md | Autenticacion y tokens |
|
|
1076
|
+
| users | users.md | Gestion de usuarios |
|
|
1077
|
+
|
|
1078
|
+
## Como Levantar
|
|
1079
|
+
- **Dependencias:** instalar con \`npm install\` o \`pip install -r requirements.txt\`
|
|
1080
|
+
- **Servicios necesarios:** BD, redis, etc.
|
|
1081
|
+
- **Variables de entorno:** cuales y para que
|
|
1082
|
+
- **Comando para iniciar:** \`npm run dev\` o equivalente
|
|
1083
|
+
|
|
1084
|
+
## Comandos Disponibles
|
|
1085
|
+
|
|
1086
|
+
| Comando | Que hace |
|
|
1087
|
+
|---------|----------|
|
|
1088
|
+
| ... | ... |
|
|
1089
|
+
|
|
1090
|
+
=== modules/[nombre]/[modulo].md ===
|
|
1091
|
+
# [nombre-del-modulo]
|
|
1092
|
+
|
|
1093
|
+
## Funcion
|
|
1094
|
+
Que hace este modulo y que parte del servicio cubre.
|
|
1095
|
+
|
|
1096
|
+
## Archivo Principal
|
|
1097
|
+
- **Ruta:** path relativo al proyecto
|
|
1098
|
+
- **Funciones/Clases principales:** listar las mas importantes
|
|
1099
|
+
|
|
1100
|
+
## 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
|
|
1108
|
+
|
|
1109
|
+
## 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.
|
|
1020
1115
|
|
|
1021
1116
|
REGLAS:
|
|
1022
|
-
- Devuelve UNICAMENTE
|
|
1023
|
-
- NO incluyas
|
|
1024
|
-
-
|
|
1025
|
-
-
|
|
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
|
|
1121
|
+
- Documenta TODOS los directorios al nivel de DIRECTORIO_TRABAJO (excluyendo .agent)
|
|
1122
|
+
- Si hay documentacion existente, actualizala con los cambios detectados`;
|
|
1026
1123
|
const res = await this.runWithFallback('explorer', prompt, 'Exploracion');
|
|
1027
1124
|
const text = extractCliText(res);
|
|
1028
|
-
//
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
.
|
|
1033
|
-
.
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1125
|
+
// Parse the response: split by === FILENAME.md === markers
|
|
1126
|
+
const sections = text.split(/===\s+(.+?\.md)\s*===/).slice(1);
|
|
1127
|
+
let filesWritten = 0;
|
|
1128
|
+
for (let i = 0; i < sections.length; i += 2) {
|
|
1129
|
+
const fileName = sections[i].trim();
|
|
1130
|
+
let content = sections[i + 1] ? sections[i + 1].trim() : '';
|
|
1131
|
+
if (!content)
|
|
1132
|
+
continue;
|
|
1133
|
+
// Clean up code fences if present
|
|
1134
|
+
content = content.replace(/^```markdown\s*/i, '').replace(/^```\s*$/gm, '').trim();
|
|
1135
|
+
try {
|
|
1136
|
+
if (fileName === 'ARCHITECTURE.md') {
|
|
1137
|
+
await writeFile(archPath, content);
|
|
1138
|
+
filesWritten++;
|
|
1139
|
+
}
|
|
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++;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
catch (err) {
|
|
1152
|
+
log.warn(`Failed to write ${fileName}: ${err.message}`);
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
if (filesWritten > 0) {
|
|
1156
|
+
log.ok(`${filesWritten} documentation file(s) written`);
|
|
1038
1157
|
}
|
|
1039
1158
|
// Overwrite the single last-run report (no timestamp accumulation)
|
|
1040
1159
|
try {
|