siesa-agents 2.1.91 → 2.1.93

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.
@@ -98,18 +98,30 @@ To securely persist the verified and approved code changes to the repository fol
98
98
 
99
99
  2. **Construct Commit Message**:
100
100
  <action>
101
- Per Section 3 of `{gitFlowGuide}`, use Conventional Commits format:
102
- - For features: `feat: {description}`
103
- - For fixes: `fix: {description}`
104
-
105
- Derive type from story context and construct message.
101
+ Build the message STRICTLY from Section 3 (template) and Section 6 (deterministic
102
+ derivation) of `{gitFlowGuide}`. Do NOT redefine or invent the format here — the
103
+ guide is the single source of truth.
104
+
105
+ 1. Parse `{{story_key}}` into `NNN`, `E`, `HH` per Section 6.
106
+ 2. Resolve `<feature_scope>` per Section 6.1: FIRST look up `FEATURE_CODE_JIRA` in the
107
+ epic shard (then the PRD shard). If it is a real synced Jira issue key (NOT
108
+ `PENDING:...`) → use it as the scope. Otherwise fall back to `feat-<NNN3>`.
109
+ 3. Fill the template:
110
+ `<tipo>(<feature_scope>): <descripción>` + `Epic:` and `Story:` trailers.
111
+ 4. Take epic/story titles literally from the epic/story files; if absent, omit the
112
+ `— título` (never invent one).
113
+ 5. Run the Section 6 validation checklist. If any item fails, STOP and report the
114
+ missing field instead of committing.
115
+
116
+ Store the result as `{{commit_message}}` (subject + trailers).
106
117
  </action>
107
118
 
108
119
  3. **User Confirmation**:
109
120
  <output>
110
121
  READY TO COMMIT:
111
122
  - Branch: {{current_branch}}
112
- - Message: "feat: implementation for story {{story_key}}"
123
+ - Message:
124
+ {{commit_message}}
113
125
 
114
126
  Do you want to proceed with the commit and push?
115
127
  </output>
@@ -129,7 +141,7 @@ To securely persist the verified and approved code changes to the repository fol
129
141
  </logic>
130
142
 
131
143
  4. **Commit Changes**:
132
- <action>Run command `git commit -m "feat: implementation for story {{story_key}}"`</action>
144
+ <action>Commit using `{{commit_message}}` (one `-m` for the subject and one `-m` per trailer line, per the example in Section 3.2 of `{gitFlowGuide}`).</action>
133
145
  <check if="Commit failed (no changes?)">
134
146
  <output>ℹ️ No changes to commit.</output>
135
147
  </check>
@@ -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 createDiscoveryBranch(projectRoot) {
15
44
  console.log(`\n🔍 Phase 1 - 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
  }
@@ -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 createPlanningBranch(projectRoot) {
15
44
  console.log(`\n📋 Phase 2 - 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
  }
@@ -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
  }