siesa-agents 2.1.91 → 2.1.92

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.
@@ -11,6 +11,35 @@ function run(command, cwd) {
11
11
  return execSync(command, { cwd, stdio: 'pipe' }).toString().trim();
12
12
  }
13
13
 
14
+ // Extrae el detalle real de un error de execSync. Con stdio:'pipe', git escribe el
15
+ // motivo (identidad faltante, "nothing to commit", etc.) en stdout/stderr, NO en
16
+ // error.message — que solo dice "Command failed: <cmd>". Sin esto el usuario ve un
17
+ // fallo sin causa. Preferimos stderr y caemos a stdout.
18
+ function gitErr(error) {
19
+ const err = (error.stderr ? error.stderr.toString() : '').trim();
20
+ const out = (error.stdout ? error.stdout.toString() : '').trim();
21
+ return [err, out].filter(Boolean).join('\n') || error.message;
22
+ }
23
+
24
+ // En una máquina recién configurada (git init sin ~/.gitconfig) `git commit` falla
25
+ // con "unable to auto-detect email address". Si no hay identidad, seteamos una local
26
+ // de respaldo para que el flujo no se caiga, y avisamos para que el usuario ponga la suya.
27
+ function ensureGitIdentity(projectRoot) {
28
+ const has = (key) => {
29
+ try { return run(`git config ${key}`, projectRoot).length > 0; }
30
+ catch { return false; }
31
+ };
32
+ if (has('user.email') && has('user.name')) return;
33
+ console.warn('⚠️ Git no tiene identidad configurada; usando una de respaldo local.');
34
+ console.warn(' Configura la tuya: git config user.name "Tu Nombre" && git config user.email tu@correo');
35
+ try {
36
+ if (!has('user.name')) run('git config user.name "Siesa Agents"', projectRoot);
37
+ if (!has('user.email')) run('git config user.email "agents@siesa.com"', projectRoot);
38
+ } catch (e) {
39
+ console.warn(' No se pudo setear identidad de respaldo:', gitErr(e));
40
+ }
41
+ }
42
+
14
43
  function createSolutioningBranch(projectRoot) {
15
44
  console.log(`\n🛠️ Phase 3 - Creando rama "${BRANCH_NAME}"...`);
16
45
 
@@ -78,19 +107,28 @@ function commitAll(comentario, projectRoot) {
78
107
 
79
108
  console.log('\n📦 Agregando todos los archivos al stage...');
80
109
  try {
81
- run('git add .', projectRoot);
82
- console.log('✓ git add . ejecutado correctamente.');
110
+ run('git add -A', projectRoot);
111
+ console.log('✓ git add ejecutado correctamente.');
83
112
  } catch (error) {
84
- console.error('❌ Error al ejecutar git add .:', error.message);
113
+ console.error('❌ Error al ejecutar git add:\n' + gitErr(error));
85
114
  process.exit(1);
86
115
  }
87
116
 
117
+ ensureGitIdentity(projectRoot);
118
+
88
119
  console.log(`\n💾 Creando commit: "${comentario}"...`);
89
120
  try {
90
121
  run(`git commit -m "${comentario.replace(/"/g, '\\"')}"`, projectRoot);
91
122
  console.log('✅ Commit creado correctamente.');
92
123
  } catch (error) {
93
- console.error('❌ Error al crear el commit:', error.message);
124
+ const detail = gitErr(error);
125
+ // "nothing to commit, working tree clean" no es un error del flujo: no había
126
+ // cambios que commitear, así que continuamos sin abortar.
127
+ if (/working tree clean|nada para (confirmar|hacer commit)/i.test(detail)) {
128
+ console.log('ℹ️ No había cambios nuevos para commitear; continuando.');
129
+ return;
130
+ }
131
+ console.error('❌ Error al crear el commit:\n' + detail);
94
132
  process.exit(1);
95
133
  }
96
134
  }