github-proyect-tracking 0.4.0 → 0.4.1

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.
Files changed (2) hide show
  1. package/bin/cli.js +51 -9
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -68,6 +68,22 @@ function parseArgs(argv) {
68
68
  return out;
69
69
  }
70
70
 
71
+ function mostRecentProfile(hermesHome) {
72
+ // último recurso: el perfil con actividad más reciente (Hermes no
73
+ // persiste "perfil activo" global; en su terminal no hay HERMES_*).
74
+ const dir = path.join(hermesHome, 'profiles');
75
+ try {
76
+ let best = null, bestT = -1;
77
+ for (const name of fs.readdirSync(dir)) {
78
+ const p = path.join(dir, name);
79
+ if (!fs.statSync(p).isDirectory()) continue;
80
+ const t = fs.statSync(p).mtimeMs;
81
+ if (t > bestT) { bestT = t; best = name; }
82
+ }
83
+ return best;
84
+ } catch { return null; }
85
+ }
86
+
71
87
  function profileFromAgentMd(cwd) {
72
88
  for (const f of ['AGENT.md', 'AGENTS.md']) {
73
89
  const p = path.join(cwd, f);
@@ -89,19 +105,45 @@ function resolveDest(flags) {
89
105
  let profile = flags.profile || process.env.HERMES_PROFILE
90
106
  || profileFromAgentMd(process.cwd());
91
107
  const exists = (p) => fs.existsSync(path.join(hermesHome, 'profiles', p));
92
- // E-24: --profile EXPLÍCITO inexistente → error claro, no default
108
+ const available = () => fs.readdirSync(path.join(hermesHome, 'profiles'))
109
+ .filter((n) => fs.statSync(path.join(hermesHome, 'profiles', n)).isDirectory());
110
+ // --profile EXPLÍCITO inexistente → error claro (nunca fallback silencioso)
93
111
  if (explicit && !exists(profile)) {
94
112
  die(`el perfil '${profile}' no existe en ${hermesHome}/profiles/ ` +
95
- '(usa --profile con un perfil válido o --user)', 2);
113
+ `(disponibles: ${available().join(', ') || 'ninguno'})`, 2);
96
114
  }
97
- // V2-E-11: AUTOMÁTICO inexistente → fallback a default CON aviso
98
- // (paridad con lib/common.sh)
115
+ // Automático inexistente → elegir uno sensato en vez de abortar:
116
+ // 1) 'default' si existe, 2) el ÚNICO perfil si solo hay uno.
99
117
  if (!profile || !exists(profile)) {
100
- console.error(`ADVERTENCIA: el perfil automático '${profile || "(ninguno)"}' ` +
101
- 'no existe; usando default (pasa --profile para elegir uno)');
102
- profile = 'default';
103
- if (!exists(profile)) {
104
- die(`tampoco existe el perfil 'default' en ${hermesHome}/profiles/`, 2);
118
+ const sugerido = profile;
119
+ const perfs = available();
120
+ if (exists('default')) {
121
+ if (sugerido) {
122
+ console.error(`ADVERTENCIA: el perfil automático '${sugerido}' no existe; ` +
123
+ "usando 'default'");
124
+ }
125
+ profile = 'default';
126
+ } else if (perfs.length === 1) {
127
+ profile = perfs[0];
128
+ console.error(`ADVERTENCIA: perfil automático '${sugerido || "(no detectado)"}' ` +
129
+ `no disponible; usando el único perfil existente '${profile}'`);
130
+ } else if (perfs.length > 1) {
131
+ const recent = mostRecentProfile(hermesHome);
132
+ if (recent) {
133
+ profile = recent;
134
+ console.error(`ADVERTENCIA: no se detectó perfil ` +
135
+ `(${sugerido ? `'${sugerido}' no existe` : 'sin HERMES_PROFILE ni AGENT.md'}); ` +
136
+ `usando el de actividad más reciente '${profile}'. ` +
137
+ 'Usa --profile PERFIL para elegirlo explícitamente');
138
+ } else {
139
+ die(`no se pudo determinar el perfil: ${sugerido
140
+ ? `'${sugerido}' no existe` : 'no se detectó (ejecuta desde el repo o define HERMES_PROFILE)'}. ` +
141
+ `Perfiles disponibles: ${perfs.join(', ')}. ` +
142
+ 'Usa --profile PERFIL o --dest RUTA', 2);
143
+ }
144
+ } else {
145
+ die(`no hay perfiles de Hermes en ${hermesHome}/profiles/; ` +
146
+ 'usa --dest RUTA para indicar el destino', 2);
105
147
  }
106
148
  }
107
149
  return path.join(hermesHome, 'profiles', profile, 'skills');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-proyect-tracking",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Instalador npx del skill github-proyect-tracking para Hermes Agent: rastrea el estado de procesos en GitHub Issues con reanudacion.",
5
5
  "bin": {
6
6
  "github-proyect-tracking": "bin/cli.js"